Search in sources :

Example 1 with InstanceControlFutureStub

use of org.apache.pulsar.functions.proto.InstanceControlGrpc.InstanceControlFutureStub in project incubator-pulsar by apache.

the class ProcessRuntime method main.

public static void main(String[] args) throws ExecutionException, InterruptedException {
    int port = Integer.parseInt(args[0]);
    ManagedChannel channel = ManagedChannelBuilder.forAddress("127.0.0.1", port).usePlaintext(true).build();
    InstanceControlFutureStub stub = InstanceControlGrpc.newFutureStub(channel);
    ListenableFuture<FunctionStatus> response = stub.getFunctionStatus(Empty.newBuilder().build());
    CompletableFuture<FunctionStatus> future = new CompletableFuture<>();
    Futures.addCallback(response, new FutureCallback<FunctionStatus>() {

        @Override
        public void onFailure(Throwable throwable) {
            log.info("GetFunctionStatus:", throwable);
            future.completeExceptionally(throwable);
        }

        @Override
        public void onSuccess(InstanceCommunication.FunctionStatus t) {
            log.info("GetFunctionStatus: {}", t);
            future.complete(t);
        }
    });
    FunctionStatus status = future.get();
    log.info("Function Status : {}", status);
}
Also used : FunctionStatus(org.apache.pulsar.functions.proto.InstanceCommunication.FunctionStatus) CompletableFuture(java.util.concurrent.CompletableFuture) ManagedChannel(io.grpc.ManagedChannel) InstanceCommunication(org.apache.pulsar.functions.proto.InstanceCommunication) InstanceControlFutureStub(org.apache.pulsar.functions.proto.InstanceControlGrpc.InstanceControlFutureStub) FunctionStatus(org.apache.pulsar.functions.proto.InstanceCommunication.FunctionStatus)

Aggregations

ManagedChannel (io.grpc.ManagedChannel)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 InstanceCommunication (org.apache.pulsar.functions.proto.InstanceCommunication)1 FunctionStatus (org.apache.pulsar.functions.proto.InstanceCommunication.FunctionStatus)1 InstanceControlFutureStub (org.apache.pulsar.functions.proto.InstanceControlGrpc.InstanceControlFutureStub)1