Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Shell 使用Oozie检查HDFS位置中是否存在大小大于零的文件_Shell_Hdfs_Apache Pig_Oozie - Fatal编程技术网

Shell 使用Oozie检查HDFS位置中是否存在大小大于零的文件

Shell 使用Oozie检查HDFS位置中是否存在大小大于零的文件,shell,hdfs,apache-pig,oozie,Shell,Hdfs,Apache Pig,Oozie,我有一个Oozie工作流,其中包含一个Pig操作,生成一个零件文件作为输出 /user/wf\u user/app\u dir/output/part-v003-o000-r-00100 清管器动作后,有一个fs动作正在生成完成标志文件,并将零件-v003-o000-r-00100移动到警报消息(用于重命名)然后更改文件路径/user/wf\u user/app\u dir/output/alert\u message上的访问权限,以便通过后续工作流操作访问该文件 此后,有一个决策控制节点来检查

我有一个Oozie工作流,其中包含一个Pig操作,生成一个零件文件作为输出

/user/wf\u user/app\u dir/output/part-v003-o000-r-00100

清管器动作后,有一个fs动作正在生成完成标志文件,并将
零件-v003-o000-r-00100
移动到
警报消息
(用于重命名)然后更改文件路径
/user/wf\u user/app\u dir/output/alert\u message
上的访问权限,以便通过后续工作流操作访问该文件

此后,有一个决策控制节点来检查文件
/user/wf\u user/app\u dir/output/alert\u message
是否存在并且大小是否大于零。只有大小非零时,才会通过电子邮件发送警报消息

但是,即使文件存在并且大小非零,决策条件始终返回false,因此警告消息永远不会通过电子邮件发送给notify用户

<switch xmlns="uri:oozie:workflow:0.4">
  <case to="message_pref_alert">false</case>
  <default to="success_email" />
</switch>
研究了关于同一主题的其他类似SO讨论:

${alert\u message\u file}
作为工作流配置属性传递,以解决错误。实际上,除非通过工作流通过配置属性传递变量警报消息文件(在属性中定义),否则无法访问该文件,否则将出现“变量无法解析”错误

在workflow.xml中

<configuration>
    <property>
        ...
    </property>  
    <property>
        <name>alert_message_file</name>
        <value>${alert_message_file}</value>
    </property>
</configuration>

...
警报消息文件
${alert_message_file}
然后更改决策节点,如下所示

<decision name="if_alert_prefs_present">
    <switch>
<case to="message_pref_alert">${(fs:exists(wf:conf('alert_message_file'))) and (fs:fileSize(wf:conf('alert_message_file')) gt 0 )}</case>
<default to="success_email"/>
</switch>
</decision>

${(fs:exists(wf:conf('alert\u message\u file'))和(fs:fileSize(wf:conf('alert\u message\u file'))gt 0)}
<configuration>
    <property>
        ...
    </property>  
    <property>
        <name>alert_message_file</name>
        <value>${alert_message_file}</value>
    </property>
</configuration>
<decision name="if_alert_prefs_present">
    <switch>
<case to="message_pref_alert">${(fs:exists(wf:conf('alert_message_file'))) and (fs:fileSize(wf:conf('alert_message_file')) gt 0 )}</case>
<default to="success_email"/>
</switch>
</decision>