Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/tfs/3.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
Apache flink 如何在Flink 1.4.0中查询可查询状态?_Apache Flink_Flink Streaming - Fatal编程技术网

Apache flink 如何在Flink 1.4.0中查询可查询状态?

Apache flink 如何在Flink 1.4.0中查询可查询状态?,apache-flink,flink-streaming,Apache Flink,Flink Streaming,我发现很难理解文档中的代码 QueryableStateClient client = new QueryableStateClient(tmHostname, proxyPort); // the state descriptor of the state to be fetched. ValueStateDescriptor<Tuple2<Long, Long>> descriptor = new ValueStateDescriptor<&g

我发现很难理解文档中的代码

QueryableStateClient client = new QueryableStateClient(tmHostname, proxyPort);

// the state descriptor of the state to be fetched.
ValueStateDescriptor<Tuple2<Long, Long>> descriptor =
        new ValueStateDescriptor<>(
          "average",
          TypeInformation.of(new TypeHint<Tuple2<Long, Long>>() {}),
          Tuple2.of(0L, 0L));

CompletableFuture<ValueState<Tuple2<Long, Long>>> resultFuture =
        client.getKvState(jobId, "query-name", key, BasicTypeInfo.LONG_TYPE_INFO, descriptor);

// now handle the returned value
resultFuture.thenAccept(response -> {
        try {
            Tuple2<Long, Long> res = response.get();
        } catch (Exception e) {
            e.printStackTrace();
        }
});
QueryableStateClient=newqueryablestateclient(tmHostname,proxyPort);
//要获取的状态的状态描述符。
ValueStateDescriptor描述符=
新的ValueStateDescriptor(
“平均”,
TypeInformation.of(新的TypeHint(){}),
(0L,0L)的Tuple2;
完全未来结果未来=
getKvState(jobId,“查询名称”,key,BasicTypeInfo.LONG\u TYPE\u INFO,描述符);
//现在处理返回的值
结果未来。然后接受(响应->{
试一试{
Tuple2 res=response.get();
}捕获(例外e){
e、 printStackTrace();
}
});

如何定义
key
jobId
flink可查询状态
模块中也没有要查看的测试用例。

jobId
是可查询状态所属作业的ID。
JobId
可以从
ExecutionEnvironment.execute()
或通过Flink的REST API返回的
JobSubmissionResult
中获取


可查询状态始终是键控状态,其作用类似于分布式哈希映射。
是应获取键控状态值的键。

jobId
是可查询状态所属作业的ID。
JobId
可以从
ExecutionEnvironment.execute()
或通过Flink的REST API返回的
JobSubmissionResult
中获取


可查询状态始终是键控状态,其作用类似于分布式哈希映射。
是应获取键控状态值的键。

JobId可从flink UI获取<代码>概述->
正在运行的作业
->
作业ID

或者您可以通过API获得它

JobGraph jobGraph = env.getStreamGraph().getJobGraph();

System.out.println("[info] Job ID: " + jobGraph.getJobID());
Key
是您指定给键控流的内容。如果按如下方式为流设置关键帧,则该关键帧应为
整数
类型:

source.keyBy(new KeySelector<Tuple2<Integer, Long>, Integer>() {
        private static final long serialVersionUID = 8470749712274833552L;

        @Override
        public Integer getKey(Tuple2<Integer, Long> value) {
            return value.f0;
        }
    }).transform(
            "TestAggregatingOperator",
            BasicTypeInfo.STRING_TYPE_INFO,
            new AggregatingTestOperator(aggrStateDescriptor)
    );
source.keyBy(新的KeySelector(){
私有静态最终长serialVersionUID=8470749712274833552L;
@凌驾
公共整数getKey(Tuple2值){
返回值0.f0;
}
}).变换(
“TestAggregatingOperator”,
BasicTypeInfo.STRING\u TYPE\u INFO,
新的AggregatingTestOperator(aggrStateDescriptor)
);
查询代码:

JobID jobID = JobID.fromHexString("ece5660c0e32a7d9780b8f24cd4fffc6");
    CompletableFuture<AggregatingState<Tuple2<Integer, Long>, String>> kvState = client.getKvState(jobID,
            "aggr-queryable",
            1, BasicTypeInfo.INT_TYPE_INFO,
            aggrStateDescriptor);
JobID JobID=JobID.fromHexString(“ece5660c0e32a7d9780b8f24cd4fffc6”);

完整的未来

作业ID可以从flink UI获得<代码>概述
->
正在运行的作业
->
作业ID

或者您可以通过API获得它

JobGraph jobGraph = env.getStreamGraph().getJobGraph();

System.out.println("[info] Job ID: " + jobGraph.getJobID());
Key
是您指定给键控流的内容。如果按如下方式为流设置关键帧,则该关键帧应为
整数
类型:

source.keyBy(new KeySelector<Tuple2<Integer, Long>, Integer>() {
        private static final long serialVersionUID = 8470749712274833552L;

        @Override
        public Integer getKey(Tuple2<Integer, Long> value) {
            return value.f0;
        }
    }).transform(
            "TestAggregatingOperator",
            BasicTypeInfo.STRING_TYPE_INFO,
            new AggregatingTestOperator(aggrStateDescriptor)
    );
source.keyBy(新的KeySelector(){
私有静态最终长serialVersionUID=8470749712274833552L;
@凌驾
公共整数getKey(Tuple2值){
返回值0.f0;
}
}).变换(
“TestAggregatingOperator”,
BasicTypeInfo.STRING\u TYPE\u INFO,
新的AggregatingTestOperator(aggrStateDescriptor)
);
查询代码:

JobID jobID = JobID.fromHexString("ece5660c0e32a7d9780b8f24cd4fffc6");
    CompletableFuture<AggregatingState<Tuple2<Integer, Long>, String>> kvState = client.getKvState(jobID,
            "aggr-queryable",
            1, BasicTypeInfo.INT_TYPE_INFO,
            aggrStateDescriptor);
JobID JobID=JobID.fromHexString(“ece5660c0e32a7d9780b8f24cd4fffc6”);
完全未来