运行管道后不要返回结果响应(结果失败) [英] don't return the result response after running pipeline (result is fail)

查看:103
本文介绍了运行管道后不要返回结果响应(结果失败)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

1)运行结果的管道成功完成后,我捕获了响应(DONE).并在控制台上显示"Pipiline运行结果=完成".

1) When the pipeline running the result has been successful and is done, I catch the response (DONE). and it print "Pipiline running result = DONE" on the console.

2)当运行结果的管道失败时,我没有捕获到响应(FAILED),它就结束了.它不打印"Pipiline运行结果= FAILED".我不能继续下一步.我已经尝试过使用 try/catch ,但是它没有捕获到'PipelineExecutionException'.

2) When the pipeline running the result has failed, I don't catch the response (FAILED), it just finishes. It does not print "Pipiline running result = FAILED". I can't go next step. I have tried using the try/catch, but it din't catch the 'PipelineExecutionException'.

    pipeline
        .apply(TextIO.Read.from(Path).named("TextIO.Read(" + Path + ")"))
        .apply(new MyTransforms());

    try{
        PipelineResult result = pipeline.run();

        LOG.info("  Pipiline running result = " + result.getState().toString());

        if (result.getState() != PipelineResult.State.DONE) {
            // i will send e-mail
        }
    }
    catch(PipelineExecutionException e){
        LOG.error(e.getMessage());
    }

失败的原因是路径(gcs)为空".我想要得到失败结果响应.

The failed cause is "path(gcs) is empty". I want to get the fail result response.

推荐答案

首先,请确保您正在使用BlockingDataflowPipelineRunner.否则,您的代码将在提交作业后终止.

First, make sure you are using the BlockingDataflowPipelineRunner. Otherwise, your code will terminate after the job as submitted.

使用BlockingDataflowPipelineRunner,您应该捕获DataflowJobExecutionException来处理意外的失败,DataflowJobCancelledException来处理取消,或者超类DataflowJobException来处理所有可能的不成功终止.

With the BlockingDataflowPipelineRunner, you should catch DataflowJobExecutionException to handle unexpected failures, DataflowJobCancelledException to handle cancellations, or the superclass DataflowJobException to handle all possible non-successful terminations.

仅当作业成功时才返回PipelineResult.如果要在发生故障的情况下查询作业的属性(例如状态或聚合器),则可以使用DataflowJobException#getJob()捕获的异常访问DataflowPipelineJob对象.

The PipelineResult will only be returned if the job is successful. If you want to query properties of the job such as state or aggregators in the case of a failure, you can access the DataflowPipelineJob object from the exception that you caught with DataflowJobException#getJob().

这篇关于运行管道后不要返回结果响应(结果失败)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆