io.grpc.ManagedChannelBuilder Java Examples

The following examples show how to use io.grpc.ManagedChannelBuilder. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TriggerConstant007.java    From gsc-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * constructor.
 */

@BeforeClass(enabled = true)
public void beforeClass() {
  PublicMethed.printAddress(contractExcKey);
  channelFull = ManagedChannelBuilder.forTarget(fullnode)
      .usePlaintext(true)
      .build();
  blockingStubFull = WalletGrpc.newBlockingStub(channelFull);
  channelFull1 = ManagedChannelBuilder.forTarget(fullnode1)
      .usePlaintext(true)
      .build();
  blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1);

  channelConfirmed = ManagedChannelBuilder.forTarget(confirmednode)
      .usePlaintext(true)
      .build();
  blockingStubConfirmed = WalletConfirmedGrpc.newBlockingStub(channelConfirmed);
}
 
Example #2
Source File: UcoreSender.java    From dble with GNU General Public License v2.0 6 votes vote down vote up
public boolean renewLock(String sessionId) throws Exception {
    UcoreInterface.RenewSessionInput input = UcoreInterface.RenewSessionInput.newBuilder().setSessionId(sessionId).build();
    try {
        stub.withDeadlineAfter(GENERAL_GRPC_TIMEOUT, TimeUnit.SECONDS).renewSession(input);
        return true;
    } catch (Exception e1) {
        LOGGER.info("connect to ucore renew error and will retry");
        for (String ip : getIpList()) {
            ManagedChannel channel = null;
            try {
                channel = ManagedChannelBuilder.forAddress(ip,
                        Integer.parseInt(getValue(ClusterParamCfg.CLUSTER_PLUGINS_PORT))).usePlaintext(true).build();
                stub = UcoreGrpc.newBlockingStub(channel).withDeadlineAfter(GENERAL_GRPC_TIMEOUT, TimeUnit.SECONDS);
                stub.withDeadlineAfter(GENERAL_GRPC_TIMEOUT, TimeUnit.SECONDS).renewSession(input);
                return true;
            } catch (Exception e2) {
                LOGGER.info("connect to ucore renew error " + stub, e2);
                if (channel != null) {
                    channel.shutdownNow();
                }
            }
        }
        return false;
    }
}
 
Example #3
Source File: ReviewCommand.java    From startup-os with Apache License 2.0 6 votes vote down vote up
@Inject
public ReviewCommand(
    FileUtils utils,
    Config config,
    GitRepoFactory repoFactory,
    @Named("Workspace path") String workspacePath,
    @Named("Diff number") Integer diffNumber) {
  this.fileUtils = utils;
  this.gitRepoFactory = repoFactory;
  this.workspacePath = workspacePath;

  this.diffNumber = diffNumber;
  ManagedChannel channel =
      ManagedChannelBuilder.forAddress("localhost", GRPC_PORT).usePlaintext().build();
  codeReviewBlockingStub = CodeReviewServiceGrpc.newBlockingStub(channel);
}
 
Example #4
Source File: ChannelFactory.java    From client-java with Apache License 2.0 6 votes vote down vote up
public ManagedChannel getChannel(String addressStr) {
  return connPool.computeIfAbsent(
      addressStr,
      key -> {
        URI address;
        try {
          address = URI.create("http://" + key);
        } catch (Exception e) {
          throw new IllegalArgumentException("failed to form address " + key);
        }
        // Channel should be lazy without actual connection until first call
        // So a coarse grain lock is ok here
        return ManagedChannelBuilder.forAddress(address.getHost(), address.getPort())
            .maxInboundMessageSize(maxFrameSize)
            .usePlaintext(true)
            .idleTimeout(60, TimeUnit.SECONDS)
            .build();
      });
}
 
Example #5
Source File: ExtCodeHashTest005.java    From gsc-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * constructor.
 */
@BeforeClass(enabled = true)
public void beforeClass() {

  channelFull = ManagedChannelBuilder.forTarget(fullnode)
      .usePlaintext(true)
      .build();
  blockingStubFull = WalletGrpc.newBlockingStub(channelFull);

  PublicMethed.printAddress(dev001Key);
  PublicMethed.printAddress(user001Key);

  String fakeAddress = "";

  logger.info("realAddress: " + fakeAddress);
  byte[] fullHexAddr = new DataWord(fakeAddress).getData();
  logger.info("fullHexAddr  ++=  " + Hex.toHexString(fullHexAddr));

  fakeAddress = "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF";

  logger.info("realAddress: " + fakeAddress);
  fullHexAddr = new DataWord(fakeAddress).getData();
  logger.info("fullHexAddr  ++=  " + Hex.toHexString(fullHexAddr));

}
 
Example #6
Source File: TriggerConstant020.java    From gsc-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * constructor.
 */

@BeforeClass(enabled = true)
public void beforeClass() {
  PublicMethed.printAddress(contractExcKey);
  channelFull = ManagedChannelBuilder.forTarget(fullnode)
      .usePlaintext(true)
      .build();
  blockingStubFull = WalletGrpc.newBlockingStub(channelFull);
  channelFull1 = ManagedChannelBuilder.forTarget(fullnode1)
      .usePlaintext(true)
      .build();
  blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1);

  channelConfirmed = ManagedChannelBuilder.forTarget(confirmednode)
      .usePlaintext(true)
      .build();
  blockingStubConfirmed = WalletConfirmedGrpc.newBlockingStub(channelConfirmed);
}
 
Example #7
Source File: TransferFailed004.java    From gsc-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * constructor.
 */

@BeforeClass(enabled = true)
public void beforeClass() {
  PublicMethed.printAddress(contractExcKey);
  channelFull = ManagedChannelBuilder.forTarget(fullnode)
      .usePlaintext(true)
      .build();
  blockingStubFull = WalletGrpc.newBlockingStub(channelFull);
  channelFull1 = ManagedChannelBuilder.forTarget(fullnode1)
      .usePlaintext(true)
      .build();
  blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1);

  channelConfirmed = ManagedChannelBuilder.forTarget(confirmednode)
      .usePlaintext(true)
      .build();
  blockingStubConfirmed = WalletConfirmedGrpc.newBlockingStub(channelConfirmed);
}
 
Example #8
Source File: TriggerConstant008.java    From gsc-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * constructor.
 */

@BeforeClass(enabled = true)
public void beforeClass() {
  PublicMethed.printAddress(contractExcKey);
  channelFull = ManagedChannelBuilder.forTarget(fullnode)
      .usePlaintext(true)
      .build();
  blockingStubFull = WalletGrpc.newBlockingStub(channelFull);
  channelFull1 = ManagedChannelBuilder.forTarget(fullnode1)
      .usePlaintext(true)
      .build();
  blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1);

  channelConfirmed = ManagedChannelBuilder.forTarget(confirmednode)
      .usePlaintext(true)
      .build();
  blockingStubConfirmed = WalletConfirmedGrpc.newBlockingStub(channelConfirmed);
}
 
Example #9
Source File: TriggerConstant021.java    From gsc-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * constructor.
 */

@BeforeClass(enabled = true)
public void beforeClass() {
  PublicMethed.printAddress(contractExcKey);
  channelFull = ManagedChannelBuilder.forTarget(fullnode)
      .usePlaintext(true)
      .build();
  blockingStubFull = WalletGrpc.newBlockingStub(channelFull);
  channelFull1 = ManagedChannelBuilder.forTarget(fullnode1)
      .usePlaintext(true)
      .build();
  blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1);

  channelConfirmed = ManagedChannelBuilder.forTarget(confirmednode)
      .usePlaintext(true)
      .build();
  blockingStubConfirmed = WalletConfirmedGrpc.newBlockingStub(channelConfirmed);
}
 
Example #10
Source File: GrpcServiceServerTest.java    From armeria with Apache License 2.0 6 votes vote down vote up
@Test
void uncompressedClient_compressedEndpoint() throws Exception {
    final ManagedChannel nonDecompressingChannel =
            ManagedChannelBuilder.forAddress("127.0.0.1", server.httpPort())
                                 .decompressorRegistry(
                                         DecompressorRegistry.emptyInstance()
                                                             .with(Codec.Identity.NONE, false))
                                 .usePlaintext()
                                 .build();
    final UnitTestServiceBlockingStub client = UnitTestServiceGrpc.newBlockingStub(
            nonDecompressingChannel);
    assertThat(client.staticUnaryCallSetsMessageCompression(REQUEST_MESSAGE))
            .isEqualTo(RESPONSE_MESSAGE);
    nonDecompressingChannel.shutdownNow();

    checkRequestLog((rpcReq, rpcRes, grpcStatus) -> {
        assertThat(rpcReq.method()).isEqualTo(
                "armeria.grpc.testing.UnitTestService/StaticUnaryCallSetsMessageCompression");
        assertThat(rpcReq.params()).containsExactly(REQUEST_MESSAGE);
        assertThat(rpcRes.get()).isEqualTo(RESPONSE_MESSAGE);
    });
}
 
Example #11
Source File: ErrorHandlingClient.java    From grpc-nebula-java with Apache License 2.0 6 votes vote down vote up
void run() throws Exception {
  // Port 0 means that the operating system will pick an available port to use.
  Server server = ServerBuilder.forPort(0).addService(new GreeterGrpc.GreeterImplBase() {
    @Override
    public void sayHello(HelloRequest request, StreamObserver<HelloReply> responseObserver) {
      responseObserver.onError(Status.INTERNAL
          .withDescription("Eggplant Xerxes Crybaby Overbite Narwhal").asRuntimeException());
    }
  }).build().start();
  channel =
      ManagedChannelBuilder.forAddress("localhost", server.getPort()).usePlaintext().build();

  blockingCall();
  futureCallDirect();
  futureCallCallback();
  asyncCall();
  advancedAsyncCall();

  channel.shutdown();
  server.shutdown();
  channel.awaitTermination(1, TimeUnit.SECONDS);
  server.awaitTermination();
}
 
Example #12
Source File: JaegerRemoteSamplerIntegrationTest.java    From opentelemetry-java with Apache License 2.0 6 votes vote down vote up
@Test
public void remoteSampling_perOperation() {
  Assume.assumeNotNull(jaegerContainer);
  String jaegerHost =
      String.format("127.0.0.1:%d", jaegerContainer.getMappedPort(COLLECTOR_PORT));
  final JaegerRemoteSampler remoteSampler =
      JaegerRemoteSampler.newBuilder()
          .setChannel(ManagedChannelBuilder.forTarget(jaegerHost).usePlaintext().build())
          .setServiceName(SERVICE_NAME)
          .build();

  Awaitility.await()
      .atMost(10, TimeUnit.SECONDS)
      .until(samplerIsType(remoteSampler, PerOperationSampler.class));
  Assert.assertTrue(remoteSampler.getSampler() instanceof PerOperationSampler);
  Assert.assertTrue(remoteSampler.getDescription().contains("0.33"));
  Assert.assertFalse(remoteSampler.getDescription().contains("150"));
}
 
Example #13
Source File: ClearAbi005.java    From gsc-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * constructor.
 */

@BeforeClass(enabled = true)
public void beforeClass() {
  PublicMethed.printAddress(contractExcKey);
  channelFull = ManagedChannelBuilder.forTarget(fullnode)
      .usePlaintext(true)
      .build();
  blockingStubFull = WalletGrpc.newBlockingStub(channelFull);
  channelFull1 = ManagedChannelBuilder.forTarget(fullnode1)
      .usePlaintext(true)
      .build();
  blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1);

  channelConfirmed = ManagedChannelBuilder.forTarget(confirmednode)
      .usePlaintext(true)
      .build();
  blockingStubConfirmed = WalletConfirmedGrpc.newBlockingStub(channelConfirmed);
}
 
Example #14
Source File: ClientThreadIntegrationTest.java    From reactive-grpc with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Before
public void setupServer() throws Exception {
    StepVerifier.setDefaultTimeout(Duration.ofSeconds(3));

    server = ServerBuilder
            .forPort(0)
            .addService(service)
            .executor(Executors.newSingleThreadExecutor(
                    new ThreadFactoryBuilder().setNameFormat("TheGrpcServer").build()))
            .build()
            .start();
    channel = ManagedChannelBuilder
            .forAddress("localhost", server.getPort())
            .usePlaintext()
            .executor(Executors.newSingleThreadExecutor(
                    new ThreadFactoryBuilder().setNameFormat("TheGrpcClient").build()))
            .build();
}
 
Example #15
Source File: WalletTestAssetIssue004.java    From gsc-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
@BeforeClass(enabled = true)
public void beforeClass() {
  channelFull = ManagedChannelBuilder.forTarget(fullnode)
      .usePlaintext(true)
      .build();
  blockingStubFull = WalletGrpc.newBlockingStub(channelFull);

  ByteString addressBs1 = ByteString.copyFrom(fromAddress);
  Account request1 = Account.newBuilder().setAddress(addressBs1).build();
  GrpcAPI.AssetIssueList assetIssueList1 = blockingStubFull
      .getAssetIssueByAccount(request1);
  Optional<GrpcAPI.AssetIssueList> queryAssetByAccount = Optional.ofNullable(assetIssueList1);
  if (queryAssetByAccount.get().getAssetIssueCount() == 0) {
    Long start = System.currentTimeMillis() + 2000;
    Long end = System.currentTimeMillis() + 1000000000;
    //Create a new asset issue
    Assert.assertTrue(PublicMethed.createAssetIssue(fromAddress, name, totalSupply, 6, 1000,
        start, end, 2, description, url, 10000L, 10000L,
        1L, 1L, testKey002, blockingStubFull));
    PublicMethed.waitProduceNextBlock(blockingStubFull);
  } else {
    logger.info("This account already create an assetisue");
  }

}
 
Example #16
Source File: GrpcTest.java    From camel-quarkus with Apache License 2.0 6 votes vote down vote up
@Test
public void consumer() {
    ManagedChannel syncRequestChannel = null;
    try {
        syncRequestChannel = ManagedChannelBuilder.forAddress("localhost", consumerPort).usePlaintext().build();
        final PingPongBlockingStub blockingStub = PingPongGrpc.newBlockingStub(syncRequestChannel);

        final PingRequest pingRequest = PingRequest.newBuilder()
                .setPingName("foo")
                .setPingId(567)
                .build();
        final PongResponse pongResponse = blockingStub.pingSyncSync(pingRequest);
        Assertions.assertNotNull(pongResponse);
        Assertions.assertEquals(567, pongResponse.getPongId());
        Assertions.assertEquals("foo PONG", pongResponse.getPongName());
    } finally {
        if (syncRequestChannel != null) {
            syncRequestChannel.shutdownNow();
        }
    }
}
 
Example #17
Source File: ContractScenario003.java    From gsc-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * constructor.
 */

@BeforeClass(enabled = true)
public void beforeClass() {
  PublicMethed.printAddress(contract003Key);
  channelFull = ManagedChannelBuilder.forTarget(fullnode)
      .usePlaintext(true)
      .build();
  blockingStubFull = WalletGrpc.newBlockingStub(channelFull);
  logger.info(Long.toString(PublicMethed.queryAccount(contract003Key, blockingStubFull)
      .getBalance()));
  channelFull1 = ManagedChannelBuilder.forTarget(fullnode1)
      .usePlaintext(true)
      .build();
  blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1);
}
 
Example #18
Source File: ChaincodeBase.java    From fabric-chaincode-java with Apache License 2.0 6 votes vote down vote up
protected final void connectToPeer() throws IOException {

        // The ChaincodeSupport Client is a wrapper around the gRPC streams that
        // come from the single 'register' call that is made back to the peer
        //
        // Once this has been created, the InvocationTaskManager that is responsible
        // for the thread management can be created.
        //
        // This is then passed to the ChaincodeSupportClient to be connected to the
        // gRPC streams

        final ChaincodeID chaincodeId = ChaincodeID.newBuilder().setName(this.id).build();
        final ManagedChannelBuilder<?> channelBuilder = newChannelBuilder();
        final ChaincodeSupportClient chaincodeSupportClient = new ChaincodeSupportClient(channelBuilder);

        final InvocationTaskManager itm = InvocationTaskManager.getManager(this, chaincodeId);
        chaincodeSupportClient.start(itm);

    }
 
Example #19
Source File: CommitTest.java    From modeldb with Apache License 2.0 5 votes vote down vote up
@Before
public void initializeChannel() throws IOException {
  grpcCleanup.register(serverBuilder.build().start());
  channel = grpcCleanup.register(channelBuilder.maxInboundMessageSize(1024).build());
  client2Channel =
      grpcCleanup.register(client2ChannelBuilder.maxInboundMessageSize(1024).build());
  if (app.getAuthServerHost() != null && app.getAuthServerPort() != null) {
    authServiceChannel =
        ManagedChannelBuilder.forTarget(app.getAuthServerHost() + ":" + app.getAuthServerPort())
            .usePlaintext()
            .intercept(authClientInterceptor.getClient1AuthInterceptor())
            .build();
  }
}
 
Example #20
Source File: GetBlockByLimitNext2.java    From gsc-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
@BeforeClass
public void beforeClass() {
  channelFull = ManagedChannelBuilder.forTarget(fullnode)
      .usePlaintext(true)
      .build();
  blockingStubFull = WalletGrpc.newBlockingStub(channelFull);
}
 
Example #21
Source File: ConsulRegistrationTest.java    From grpc-spring-boot-starter with Apache License 2.0 5 votes vote down vote up
@Test
public void contextLoads() throws ExecutionException, InterruptedException {
    final String serviceId = "grpc-grpc-demo";
    final ConsulClient consulClient = new ConsulClient("localhost", Integer.parseInt(System.getProperty("spring.cloud.consul.port")));


    List<ServiceInstance> instances = discoveryClient.getInstances(serviceId);
    assertFalse(instances.isEmpty());

    ServiceInstance serviceInstance = instances.get(0);
    ManagedChannel channel = ManagedChannelBuilder.forAddress(serviceInstance.getHost(), serviceInstance.getPort())
            .usePlaintext()
            .build();

    final GreeterGrpc.GreeterFutureStub greeterFutureStub = GreeterGrpc.newFutureStub(channel);
    final GreeterOuterClass.HelloRequest helloRequest =GreeterOuterClass.HelloRequest.newBuilder().setName("Bob").build();
    final String reply = greeterFutureStub.sayHello(helloRequest).get().getMessage();
    assertNotNull("Replay should not be null",reply);

    boolean isHealthy = false;
    for(int i=0;i<5; ++i){
        final List<HealthService> healthServices = consulClient.getHealthServices(serviceId, true, QueryParams.DEFAULT).getValue();
        isHealthy =healthServices
                .stream()
                .flatMap(h->h.getChecks().stream())
                .anyMatch(c-> Check.CheckStatus.PASSING.equals(c.getStatus())&& c.getCheckId().contains(serviceId));
        if(isHealthy){
            break;
        }else{
            Thread.sleep(Duration.ofSeconds(10).toMillis());
        }
    }
    assertTrue(isHealthy);
    applicationContext.stop();
}
 
Example #22
Source File: Create2Test025.java    From gsc-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * constructor.
 */
@BeforeClass(enabled = true)
public void beforeClass() {

  channelFull = ManagedChannelBuilder.forTarget(fullnode)
      .usePlaintext(true)
      .build();
  blockingStubFull = WalletGrpc.newBlockingStub(channelFull);

  PublicMethed.printAddress(dev001Key);
  PublicMethed.printAddress(user001Key);
}
 
Example #23
Source File: WalletTestAssetIssue010.java    From gsc-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * constructor.
 */

@BeforeClass(enabled = true)
public void beforeClass() {
  channelFull = ManagedChannelBuilder.forTarget(fullnode)
      .usePlaintext(true)
      .build();
  blockingStubFull = WalletGrpc.newBlockingStub(channelFull);
}
 
Example #24
Source File: ContractGrcToken073.java    From gsc-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * constructor.
 */
@BeforeClass(enabled = true)
public void beforeClass() {

  channelFull = ManagedChannelBuilder.forTarget(fullnode)
      .usePlaintext(true)
      .build();
  blockingStubFull = WalletGrpc.newBlockingStub(channelFull);

  PublicMethed.printAddress(dev001Key);
}
 
Example #25
Source File: ContractGrcToken064.java    From gsc-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * constructor.
 */
@BeforeClass(enabled = true)
public void beforeClass() {

  channelFull = ManagedChannelBuilder.forTarget(fullnode)
      .usePlaintext(true)
      .build();
  blockingStubFull = WalletGrpc.newBlockingStub(channelFull);

  PublicMethed.printAddress(dev001Key);
  PublicMethed.printAddress(user001Key);
}
 
Example #26
Source File: AndroidChannelBuilder.java    From grpc-nebula-java with Apache License 2.0 5 votes vote down vote up
private AndroidChannelBuilder(String target) {
  if (OKHTTP_CHANNEL_BUILDER_CLASS == null) {
    throw new UnsupportedOperationException("No ManagedChannelBuilder found on the classpath");
  }
  try {
    delegateBuilder =
        (ManagedChannelBuilder)
            OKHTTP_CHANNEL_BUILDER_CLASS
                .getMethod("forTarget", String.class)
                .invoke(null, target);
  } catch (Exception e) {
    throw new RuntimeException("Failed to create ManagedChannelBuilder", e);
  }
}
 
Example #27
Source File: ContractGrcToken011.java    From gsc-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * constructor.
 */
@BeforeClass(enabled = true)
public void beforeClass() {

  channelFull = ManagedChannelBuilder.forTarget(fullnode)
      .usePlaintext(true)
      .build();
  blockingStubFull = WalletGrpc.newBlockingStub(channelFull);

  PublicMethed.printAddress(dev001Key);
  PublicMethed.printAddress(user001Key);
}
 
Example #28
Source File: FieldSourceRemote.java    From snowblossom with Apache License 2.0 5 votes vote down vote up
protected SharedMiningServiceBlockingStub getStub()
{
  if (stub_one != null) return stub_one;

  SharedMiningServiceBlockingStub stub = stub_local.get();
  if (stub == null)
  {
    ManagedChannel channel = ManagedChannelBuilder.forAddress(stub_host, stub_port).usePlaintext().build();
    stub = SharedMiningServiceGrpc.newBlockingStub(channel);
    stub_local.set(stub);
  }
  return stub;
}
 
Example #29
Source File: SnapshotCommand.java    From startup-os with Apache License 2.0 5 votes vote down vote up
@Inject
public SnapshotCommand(
    FileUtils fileUtils,
    GitRepoFactory repoFactory,
    @Named("Workspace path") String workspacePath,
    @Named("Diff number") Integer diffNumber) {
  this.fileUtils = fileUtils;
  this.gitRepoFactory = repoFactory;
  this.workspacePath = workspacePath;
  this.diffNumber = diffNumber;

  ManagedChannel channel =
      ManagedChannelBuilder.forAddress("localhost", GRPC_PORT).usePlaintext().build();
  CodeReviewServiceGrpc.newBlockingStub(channel);
}
 
Example #30
Source File: BackpressureController.java    From reactive-grpc with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@FXML
public void initialize() throws Exception {
    Server server = ServerBuilder.forPort(9000).addService(this).build().start();
    Channel channel = ManagedChannelBuilder.forAddress("localhost", server.getPort()).usePlaintext().build();
    stub = RxBackpressureDemoGrpc.newRxStub(channel);

    producedSeries.setName("Produced");
    consumedSeries.setName("Consumed");
    lineChart.getData().add(producedSeries);
    lineChart.getData().add(consumedSeries);
}