shell脚本

t3irkdon  于 2021-06-01  发布在  Hadoop
关注(0)|答案(0)|浏览(239)

我正在尝试制作一个脚本来检查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>

谢谢你的帮助

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题