1

我正在尝试制作一个脚本来检查 hdfs 路径中是否缺少任何文件。这个想法是将它包含在一个 oozie 工作流程中,当没有找到文件时失败并且不会继续流程

ALTRAFI="/input/ALTrafi*.txt"
ALTDATOS="/ALTDatos*.txt"
ALTARVA="/ALTarva*.txt"
TRAFCIER="/TrafCier*.txt"

if hdfs dfs -test -e $ALTRAFI; then
   echo "[$ALTRAFI] Archive not found"
   exit 1
fi
if hdfs dfs -test -e $ALTDATOS; then
   echo "[$ALTDATOS] Archive not found"
   exit 2
fi
if hdfs dfs -test -e $ALTARVA; then
   echo "[$ALTARVA] Archive not found"
   exit 3
fi   
if hdfs dfs -test -e $TRAFCIER; then
   echo "[$TRAFCIER] Archive not found"
   exit 4
fi 

但是脚本在找不到文件时不会失败并继续 oozie 中的工作流流程

oozie 流:

<start to="ValidateFiles"/>
<kill name="Kill">
    <message>Action failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message>
</kill>
<action name="ValidateFiles">
    <shell xmlns="uri:oozie:shell-action:0.2">
        <job-tracker>${jobTracker}</job-tracker>
        <name-node>${nameNode}</name-node>
        <configuration>
            <property>
              <name>mapred.job.queue.name</name>
              <value>${queueName}</value>
            </property>
            <property>
                <name>tez.lib.uris</name>
                <value>/hdp/apps/2.5.0.0-1245/tez/tez.tar.gz</value>
            </property>
        </configuration>
        <exec>/produccion/apps/traficotasado/ValidateFiles.sh</exec>
        <file>/produccion/apps/traficotasado/ValidateFiles.sh#ValidateFiles.sh</file> <!--Copy the executable to compute node's current working directory -->
    </shell>
    <ok to="CopyFiles"/>
    <error to="Kill"/>
</action>   
  <action name="CopyFiles">
    <shell xmlns="uri:oozie:shell-action:0.2">
        <job-tracker>${jobTracker}</job-tracker>
        <name-node>${nameNode}</name-node>
        <configuration>
            <property>
              <name>mapred.job.queue.name</name>
              <value>${queueName}</value>
            </property>
            <property>
                <name>tez.lib.uris</name>
                <value>/hdp/apps/2.5.0.0-1245/tez/tez.tar.gz</value>
            </property>
        </configuration>
        <exec>/produccion/apps/traficotasado/CopyFiles.sh</exec>
        <file>/produccion/apps/traficotasado/CopyFiles.sh#CopyFiles.sh</file> <!--Copy the executable to compute node's current working directory -->
    </shell>
    <ok to="DepuraFilesStage"/>
    <error to="Kill"/>
</action>

谢谢您的帮助

4

0 回答 0