为什么Flinkx抛出异常后就不在打印结果集!?(解析)

结果集长什么样子

在这里插入图片描述

结果集是在什么地方打印的

Main类的main方法里面

if(env instanceof MyLocalStreamEnvironment){
   ResultPrintUtil.printResult(result);
}

在这里插入图片描述
打印方法

// An highlighted block
ResultPrintUtil.printResult(result);

结果集数据是从什么地方来的

flinkx解析完json之后其实就是交给flink执行了,调用了flink的jar包进行下一步执行

JobResult类的变量accumulatorResults(这些都在flink的jar包里处理的)

在这里插入图片描述

从哪一步开始获取JobResult类的变量accumulatorResults的数据呢

MyLocalStreamEnvironment

执行方法进行调用数据结果

// An highlighted block
JobExecutionResult result =  miniCluster.executeJobBlocking(jobGraph);

跳转到类MiniCluster里面

//类
MiniCluster
 //方法
executeJobBlocking

在这里插入图片描述
这里看到JobResult获取了对象信息,这时候数据已经在里面了

JobResult
// 方法
public JobExecutionResult toJobExecutionResult(ClassLoader classLoader) throws JobExecutionException, IOException, ClassNotFoundException {
        if (this.applicationStatus == ApplicationStatus.SUCCEEDED) {
            return new JobExecutionResult(this.jobId, this.netRuntime, AccumulatorHelper.deserializeAccumulators(this.accumulatorResults, classLoader));
        } else {
            Throwable cause;
            if (this.serializedThrowable == null) {
                cause = null;
            } else {
                cause = this.serializedThrowable.deserializeError(classLoader);
            }

            Object exception;
            if (this.applicationStatus == ApplicationStatus.FAILED) {
                exception = new JobExecutionException(this.jobId, "Job execution failed.", cause);
            } else if (this.applicationStatus == ApplicationStatus.CANCELED) {
                exception = new JobCancellationException(this.jobId, "Job was cancelled.", cause);
            } else {
                exception = new JobExecutionException(this.jobId, "Job completed with illegal application status: " + this.applicationStatus + '.', cause);
            }

            throw exception;
        }
    }

数据迁移成功:返回 JobExecutionResult对象,里面包含结果集accumulators

// An highlighted block
return new JobExecutionResult(this.jobId, this.netRuntime, AccumulatorHelper.deserializeAccumulators(this.accumulatorResults, classLoader));

数据迁移失败:返回JobExecutionException,里面包含错误信息cause

// An highlighted block
Object exception;
            if (this.applicationStatus == ApplicationStatus.FAILED) {
                exception = new JobExecutionException(this.jobId, "Job execution failed.", cause);
            } else if (this.applicationStatus == ApplicationStatus.CANCELED) {
                exception = new JobCancellationException(this.jobId, "Job was cancelled.", cause);
            } else {
                exception = new JobExecutionException(this.jobId, "Job completed with illegal application status: " + this.applicationStatus + '.', cause);
            }

为什么数据迁移出错了,就没有信息了呢?

还记得最开始,打印需要我们返还什么类么!

JobExecutionResult

上面我们说了如果报错会返还什么类:

JobExecutionException

所以结果出来了,因为一旦flinkx抛出异常的时候,就不再返还类JobExecutionResult,所以我们无法接收到信息,所以无法打印结果集

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值