Hi devs,
https://ci.apache.org/projects/flink/flink-docs-release-1.4/dev/stream/operators/asyncio.html
<https://ci.apache.org/projects/flink/flink-docs-release-1.4/dev/stream/operators/asyncio.html>
Has this example of asyncInvoke:
> @Override
> public void asyncInvoke(final String str, final
> ResultFuture<Tuple2<String, String>> resultFuture) throws Exception {
>
> // issue the asynchronous request, receive a future for result
> Future<String> resultFuture = client.query(str);
>
> // set the callback to be executed once the request by the client is
> complete
> // the callback simply forwards the result to the result future
> resultFuture.thenAccept( (String result) -> {
>
> resultFuture.complete(Collections.singleton(new Tuple2<>(str,
> result)));
>
> });
> }
1. there’s a resultFuture parameter, and a resultFuture variable.
2. resultFuture.thenAccept() is a method available for CompletableFuture
<https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CompletableFuture.html>,
not Future.
I can fix this up, but I’m wondering what you think the code should do,
assuming there’s a typical client that returns a Future vs. a CompletableFuture.
e.g. I could use CompletableFuture.supplyAsync(new Supplier<String>() { } with
a get that calls the Future’s get().
Thanks,
— Ken
--------------------------------------------
http://about.me/kkrugler
+1 530-210-6378