Java Code Examples for io.grpc.ServerBuilder

The following are top voted examples for showing how to use io.grpc.ServerBuilder. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: neo_grpc   File: RegistergRPCExtensionFactory.java   View source code 7 votes vote down vote up
@Override
public Lifecycle newInstance(KernelContext kernelContext, final Dependencies dependencies) throws Throwable {
    return new LifecycleAdapter() {

        private Server server;

        @Override
        public void start() throws Throwable {
            server  = ServerBuilder.forPort(9999).addService(new Neo4jGRPCService(dependencies.getGraphDatabaseService())).build();
            server.start();
            System.out.println("Started gRPC Server.");
        }

        @Override
        public void shutdown() throws Throwable {
            server.shutdown();
        }
    };
}
 
Example 2
Project: rejoiner   File: HelloWorldServer.java   View source code 6 votes vote down vote up
private void start() throws IOException {
  /* The port on which the server should run */
  int port = 50051;
  server = ServerBuilder.forPort(port).addService(new GreeterImpl()).build().start();
  logger.info("Server started, listening on " + port);
  Runtime.getRuntime()
      .addShutdownHook(
          new Thread() {
            @Override
            public void run() {
              // Use stderr here since the logger may have been reset by its JVM shutdown hook.
              System.err.println("*** shutting down gRPC server since JVM is shutting down");
              HelloWorldServer.this.stop();
              System.err.println("*** server shut down");
            }
          });
}
 
Example 3
Project: rejoiner   File: GraphQlGrpcServer.java   View source code 6 votes vote down vote up
private void start() throws IOException {
  /* The port on which the server should run */
  int port = 8888;
  server = ServerBuilder.forPort(port).addService(new GraphQlServiceImpl()).build().start();
  logger.info("Server started, listening on " + port);
  Runtime.getRuntime()
      .addShutdownHook(
          new Thread() {
            @Override
            public void run() {
              // Use stderr here since the logger may have been reset by its JVM shutdown hook.
              System.err.println("*** shutting down gRPC server since JVM is shutting down");
              GraphQlGrpcServer.this.stop();
              System.err.println("*** server shut down");
            }
          });
}
 
Example 4
Project: rejoiner   File: HelloWorldServer.java   View source code 6 votes vote down vote up
private void start() throws IOException {
  /* The port on which the server should run */
  int port = 50051;
  server = ServerBuilder.forPort(port).addService(new GreeterImpl()).build().start();
  logger.info("Server started, listening on " + port);
  Runtime.getRuntime()
      .addShutdownHook(
          new Thread() {
            @Override
            public void run() {
              // Use stderr here since the logger may have been reset by its JVM shutdown hook.
              System.err.println("*** shutting down gRPC server since JVM is shutting down");
              HelloWorldServer.this.stop();
              System.err.println("*** server shut down");
            }
          });
}
 
Example 5
Project: graphflow   File: GraphflowServer.java   View source code 6 votes vote down vote up
public void start() throws IOException {
    System.err.println("*** starting gRPC server...");
    grpcServer = ServerBuilder.forPort(GRPC_PORT).addService(new GraphflowQueryImpl()).build().
        start();
    System.err.println("*** gRPC server running.");

    System.err.println("*** starting http server...");
    final PlanViewerHttpServer graphflowUIHttpServer = new PlanViewerHttpServer(GRPC_HOST,
        GRPC_PORT);
    graphflowUIHttpServer.start();
    System.err.println("*** http server running.");

    Runtime.getRuntime().addShutdownHook(new Thread() {
        @Override
        public void run() {
            System.err.println("*** shutting down gRPC grpcServer...");
            GraphflowServer.this.stop();
            System.err.println("*** grpcServer shut down.");
        }
    });
}
 
Example 6
Project: devicehub   File: DeviceHubServer.java   View source code 6 votes vote down vote up
/**
 * Starts the server
 * @param port the port that the server listens to
 * @throws IOException
 * @throws IllegalStateException
 */
private void start(int port) throws IOException {

  deviceHubImpl = new DeviceHubImpl();
  try {
    server = ServerBuilder.forPort(port).addService(deviceHubImpl).build().start();
  } catch (IOException | IllegalStateException e) {
    stop();
    throw e;
  }
  logger.info("Server started, listening on " + port);
  Runtime.getRuntime()
      .addShutdownHook(
          new Thread() {
            @Override
            public void run() {
              // Use stderr here since the logger may have been reset by its JVM shutdown hook.
              System.err.println("*** shutting down gRPC server since JVM is shutting down");
              DeviceHubServer.this.stop();
              System.err.println("*** server shut down");
            }
          });
}
 
Example 7
Project: africastalking-java   File: Server.java   View source code 6 votes vote down vote up
public void start(File certChainFile, File privateKeyFile, int port) throws IOException {
    ServerBuilder builder = ServerBuilder.forPort(port).useTransportSecurity(certChainFile, privateKeyFile);
    if (mAuthenticator != null) {
        builder.addService(ServerInterceptors.intercept(
            mSdkService, new AuthenticationInterceptor(this.mAuthenticator)));
    } else {
        builder.addService(mSdkService);
    }
    mGrpc = builder.build();
    mGrpc.start();
}
 
Example 8
Project: grpc-java-contrib   File: CompletableFutureEndToEndTest.java   View source code 6 votes vote down vote up
@Test
public void serverRunsAndRespondsCorrectly() throws ExecutionException,
        IOException,
        InterruptedException,
        TimeoutException {
    final String name = UUID.randomUUID().toString();

    Server server = ServerBuilder.forPort(9999)
            .addService(new GreeterImpl())
            .build();

    server.start();

    ManagedChannel channel = ManagedChannelBuilder.forAddress("localhost", server.getPort())
            .usePlaintext(true)
            .build();

    GreeterGrpc8.GreeterCompletableFutureStub stub = GreeterGrpc8.newCompletableFutureStub(channel);

    CompletableFuture<HelloResponse> response = stub.sayHello(HelloRequest.newBuilder().setName(name).build());

    await().atMost(3, TimeUnit.SECONDS).until(() -> response.isDone() && response.get().getMessage().contains(name));

    channel.shutdown();
    channel.awaitTermination(1, TimeUnit.MINUTES);
    channel.shutdownNow();

    server.shutdown();
    server.awaitTermination(1, TimeUnit.MINUTES);
    server.shutdownNow();
}
 
Example 9
Project: seldon-core   File: SeldonGrpcServer.java   View source code 6 votes vote down vote up
@Autowired
public SeldonGrpcServer(PredictionService predictionService)
{
    { // setup the server port using the env vars
        String engineServerPortString = System.getenv().get(ENGINE_SERVER_PORT_KEY);
        if (engineServerPortString == null) {
            logger.error("FAILED to find env var [{}], will use defaults for engine server port {}", ENGINE_SERVER_PORT_KEY,SERVER_PORT);
            port = SERVER_PORT;
        } else {
            port = Integer.parseInt(engineServerPortString);
            logger.info("FOUND env var [{}], will use engine server port {}", ENGINE_SERVER_PORT_KEY,port);
        }
    }
    this.predictionService = predictionService;
    server = ServerBuilder
            .forPort(port)
            .addService(new SeldonService(this))
      .build();
}
 
Example 10
Project: grpcx   File: Provider.java   View source code 6 votes vote down vote up
public static void main(String[] args) throws InterruptedException {
	
	Server server=ServerBuilder.forPort(Config.getLocalPortProvider())
					.addService(new AddService())
					.build();
	try {
		server.start();
		
		ProviderBootstrap.init();
		
		server.awaitTermination();
	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}

}
 
Example 11
Project: book_ldrtc   File: HelloJsonServer.java   View source code 6 votes vote down vote up
private void start() throws IOException {
  server = ServerBuilder.forPort(port)
      .addService(bindService(new GreeterImpl()))
      .build()
      .start();
  logger.info("Server started, listening on " + port);
  Runtime.getRuntime().addShutdownHook(new Thread() {
    @Override
    public void run() {
      // Use stderr here since the logger may have been reset by its JVM shutdown hook.
      System.err.println("*** shutting down gRPC server since JVM is shutting down");
      HelloJsonServer.this.stop();
      System.err.println("*** server shut down");
    }
  });
}
 
Example 12
Project: book_ldrtc   File: CustomHeaderServer.java   View source code 6 votes vote down vote up
private void start() throws IOException {
  server = ServerBuilder.forPort(port)
      .addService(ServerInterceptors.intercept(new GreeterImpl(), new HeaderServerInterceptor()))
      .build()
      .start();
  logger.info("Server started, listening on " + port);
  Runtime.getRuntime().addShutdownHook(new Thread() {
    @Override
    public void run() {
      // Use stderr here since the logger may have been reset by its JVM shutdown hook.
      System.err.println("*** shutting down gRPC server since JVM is shutting down");
      CustomHeaderServer.this.stop();
      System.err.println("*** server shut down");
    }
  });
}
 
Example 13
Project: whatsmars   File: HelloWorldServer.java   View source code 6 votes vote down vote up
private void start() throws IOException {
    server = ServerBuilder.forPort(port)
            .addService(new HelloServiceImpl())
            .build()
            .start();

    System.out.println("service start...");

    Runtime.getRuntime().addShutdownHook(new Thread() {

        @Override
        public void run() {

            System.err.println("*** shutting down gRPC server since JVM is shutting down");
            HelloWorldServer.this.stop();
            System.err.println("*** server shut down");
        }
    });
}
 
Example 14
Project: grpc-java-by-example   File: RxMetricsServer.java   View source code 6 votes vote down vote up
public static void main(String[] args) throws IOException, InterruptedException {
  RxMetricsServiceGrpc.MetricsServiceImplBase service = new RxMetricsServiceGrpc.MetricsServiceImplBase() {

    @Override
    public Single<Streaming.Average> collect(Flowable<Streaming.Metric> request) {
      return request.map(m -> m.getMetric())
          .map(m -> new State(m, 1))
          .reduce((a, b) -> new State(a.sum + b.sum, a.count + b.count))
          .map(s -> Streaming.Average.newBuilder().setVal(s.sum / s.count).build())
          .toSingle();
    }
  };

  Server server = ServerBuilder.forPort(8080)
      .addService(service)
      .build();

  server.start();
  server.awaitTermination();
}
 
Example 15
Project: grpc-java-gradle-hello-world   File: HelloWorldServer.java   View source code 6 votes vote down vote up
private void start() throws Exception {
    logger.info("Starting the grpc server");

    server = ServerBuilder.forPort(port)
            .addService(new GreeterImpl())
            .build()
            .start();

    logger.info("Server started. Listening on port " + port);

    Runtime.getRuntime().addShutdownHook(new Thread(() -> {
        System.err.println("*** JVM is shutting down. Turning off grpc server as well ***");
        HelloWorldServer.this.stop();
        System.err.println("*** shutdown complete ***");
    }));
}
 
Example 16
Project: grpc   File: Backend.java   View source code 6 votes vote down vote up
private void start(int id) throws IOException {
    server = ServerBuilder.forPort((port + id))
            .addService(new GoogleImpl(id))
            .build()
            .start();
    logger.info("Server started, listening on " + (port + id));
    Runtime.getRuntime().addShutdownHook(new Thread() {
        @Override
        public void run() {
            // Use stderr here since the logger may have been reset by its JVM shutdown hook.
            System.err.println("*** shutting down gRPC server since JVM is shutting down");
            Backend.this.stop();
            System.err.println("*** server shut down");
        }
    });
}
 
Example 17
Project: yarpc-java   File: EchoServer.java   View source code 6 votes vote down vote up
/** Starts the server. */
public void start() throws IOException {
  /* The port on which the server should run */
  int port = 8089;
  server = ServerBuilder.forPort(port).addService(new EchoProtoHandler()).build().start();
  log.info("Server started, listening on " + port);
  Runtime.getRuntime()
      .addShutdownHook(
          new Thread() {
            @Override
            public void run() {
              log.error("*** shutting down gRPC server since JVM is shutting down");
              EchoServer.this.stop();
              log.error("*** server shut down");
            }
          });
}
 
Example 18
Project: java-docs-samples   File: HelloWorldServer.java   View source code 6 votes vote down vote up
private void start() throws IOException {
  server = ServerBuilder.forPort(port)
      .addService(new GreeterImpl())
      .build()
      .start();
  logger.info("Server started, listening on " + port);
  Runtime.getRuntime().addShutdownHook(new Thread() {
    @Override
    public void run() {
      // Use stderr here since the logger may have been reset by its JVM shutdown hook.
      System.err.println("*** shutting down gRPC server since JVM is shutting down");
      HelloWorldServer.this.stop();
      System.err.println("*** server shut down");
    }
  });
}
 
Example 19
Project: h2o-3   File: GrpcExtension.java   View source code 6 votes vote down vote up
@Override
public void onLocalNodeStarted() {
  if (grpcPort != 0) {
    ServerBuilder sb = ServerBuilder.forPort(grpcPort);
    RegisterGrpcApi.registerWithServer(sb);
    netty = sb.build();
    try {
      netty.start();
      Log.info("Started GRPC server on localhost:" + grpcPort);
    } catch (IOException e) {
      netty = null;
      throw new RuntimeException("Failed to start the GRPC server on port " + grpcPort, e);
    }
    Runtime.getRuntime().addShutdownHook(new Thread() {
      @Override
      public void run() {
        if (netty != null) {
          // Use stderr here since the logger may have been reset by its JVM shutdown hook.
          System.err.println("*** shutting down gRPC server since JVM is shutting down");
          netty.shutdown();
          System.err.println("*** server shut down");
        }
      }
    });
  }
}
 
Example 20
Project: grpc-java   File: HelloWorldServer.java   View source code 6 votes vote down vote up
private void start() throws IOException {
  /* The port on which the server should run */
  int port = 50051;
  server = ServerBuilder.forPort(port)
      .addService(new GreeterImpl())
      .build()
      .start();
  logger.info("Server started, listening on " + port);
  Runtime.getRuntime().addShutdownHook(new Thread() {
    @Override
    public void run() {
      // Use stderr here since the logger may have been reset by its JVM shutdown hook.
      System.err.println("*** shutting down gRPC server since JVM is shutting down");
      HelloWorldServer.this.stop();
      System.err.println("*** server shut down");
    }
  });
}
 
Example 21
Project: grpc-java   File: CustomHeaderServer.java   View source code 6 votes vote down vote up
private void start() throws IOException {
  server = ServerBuilder.forPort(PORT)
      .addService(ServerInterceptors.intercept(new GreeterImpl(), new HeaderServerInterceptor()))
      .build()
      .start();
  logger.info("Server started, listening on " + PORT);
  Runtime.getRuntime().addShutdownHook(new Thread() {
    @Override
    public void run() {
      // Use stderr here since the logger may have been reset by its JVM shutdown hook.
      System.err.println("*** shutting down gRPC server since JVM is shutting down");
      CustomHeaderServer.this.stop();
      System.err.println("*** server shut down");
    }
  });
}
 
Example 22
Project: grpc-java   File: HelloJsonServer.java   View source code 6 votes vote down vote up
private void start() throws IOException {
  /* The port on which the server should run */
  int port = 50051;
  server = ServerBuilder.forPort(port)
      .addService(new GreeterImpl())
      .build()
      .start();
  logger.info("Server started, listening on " + port);
  Runtime.getRuntime().addShutdownHook(new Thread() {
    @Override
    public void run() {
      // Use stderr here since the logger may have been reset by its JVM shutdown hook.
      System.err.println("*** shutting down gRPC server since JVM is shutting down");
      HelloJsonServer.this.stop();
      System.err.println("*** server shut down");
    }
  });
}
 
Example 23
Project: grpc-java   File: ErrorHandlingClient.java   View source code 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(true).build();

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

  channel.shutdown();
  server.shutdown();
  channel.awaitTermination(1, TimeUnit.SECONDS);
  server.awaitTermination();
}
 
Example 24
Project: grpc-java   File: DetailErrorSample.java   View source code 6 votes vote down vote up
void run() throws Exception {
  Server server = ServerBuilder.forPort(0).addService(new GreeterGrpc.GreeterImplBase() {
    @Override
    public void sayHello(HelloRequest request, StreamObserver<HelloReply> responseObserver) {
      Metadata trailers = new Metadata();
      trailers.put(DEBUG_INFO_TRAILER_KEY, DEBUG_INFO);
      responseObserver.onError(Status.INTERNAL.withDescription(DEBUG_DESC)
          .asRuntimeException(trailers));
    }
  }).build().start();
  channel =
      ManagedChannelBuilder.forAddress("localhost", server.getPort()).usePlaintext(true).build();

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

  channel.shutdown();
  server.shutdown();
  channel.awaitTermination(1, TimeUnit.SECONDS);
  server.awaitTermination();
}
 
Example 25
Project: muckery   File: GrpcTest.java   View source code 6 votes vote down vote up
@Before
public void setUp() throws Exception {

    final int port = NetUtil.findUnusedPort();
    this.server = ServerBuilder.forPort(port)
                               .executor(this.exec)
                               .addService(new HelloService())
                               .build()
                               .start();


    this.channel = ManagedChannelBuilder.forAddress("127.0.0.1", port)
                                        .executor(this.exec)
                                        .usePlaintext(true)
                                        .build();
}
 
Example 26
Project: grpc-samples-java   File: ChatServer.java   View source code 5 votes vote down vote up
public static void main(String[] args) throws InterruptedException, IOException {

        // Build server
        Server server = ServerBuilder.forPort(SERVER_PORT)
                .addService(new ChatServiceImpl())
                .build();

        // Start server
        System.out.println("Starting server on port " + SERVER_PORT);
        server.start();

        // Keep it running
        System.out.println("Server started!");
        server.awaitTermination();
    }
 
Example 27
Project: grpc-samples-java   File: GreeterServer.java   View source code 5 votes vote down vote up
public static void main(String[] args) throws IOException, InterruptedException {

        // Build server
        Server server = ServerBuilder.forPort(SERVER_PORT)
                .addService(new GreetingServiceImpl())
                .build();

        // Start server
        System.out.println("Starting GreeterServer on port " + SERVER_PORT);
        server.start();

        // Keep it running
        System.out.println("GreeterServer started!");
        server.awaitTermination();
    }
 
Example 28
Project: rejoiner   File: ShelfServer.java   View source code 5 votes vote down vote up
private void start() throws IOException {
  /* The port on which the server should run */
  int port = 50052;
  server = ServerBuilder.forPort(port).addService(new ShelfService()).build().start();
  logger.info("Server started, listening on " + port);
  Runtime.getRuntime()
      .addShutdownHook(
          new Thread(
              () -> {
                // Use stderr here since the logger may have been reset by its JVM shutdown hook.
                System.err.println("*** shutting down gRPC server since JVM is shutting down");
                ShelfServer.this.stop();
                System.err.println("*** server shut down");
              }));
}
 
Example 29
Project: rejoiner   File: BookServer.java   View source code 5 votes vote down vote up
private void start() throws IOException {
  /* The port on which the server should run */
  int port = 50051;
  server = ServerBuilder.forPort(port).addService(new BookService()).build().start();
  logger.info("Server started, listening on " + port);
  Runtime.getRuntime()
      .addShutdownHook(
          new Thread(
              () -> {
                // Use stderr here since the logger may have been reset by its JVM shutdown hook.
                System.err.println("*** shutting down gRPC server since JVM is shutting down");
                BookServer.this.stop();
                System.err.println("*** server shut down");
              }));
}
 
Example 30
Project: incubator-servicecomb-saga   File: LoadBalancedClusterMessageSenderTest.java   View source code 5 votes vote down vote up
private static void startServerOnPort(int port) {
  ServerBuilder<?> serverBuilder = ServerBuilder.forPort(port);
  serverBuilder.addService(new MyTxEventService(connected.get(port), eventsMap.get(port), delays.get(port)));
  Server server = serverBuilder.build();

  try {
    server.start();
    servers.put(port, server);
  } catch (IOException e) {
    fail(e.getMessage());
  }
}
 
Example 31
Project: spring-remoting-grpc   File: GrpcInvokerServiceExporter.java   View source code 5 votes vote down vote up
private void start() throws IOException {
    server = ServerBuilder.forPort(port).addService(new RemotingServiceImpl(this)).build().start();
    logger.info("Server started on port " + port);

    Runtime.getRuntime().addShutdownHook(new Thread() {

        @Override
        public void run() {
            GrpcInvokerServiceExporter.this.stop();
        }
    });
}
 
Example 32
Project: rpc-comparison   File: FunctionTest.java   View source code 5 votes vote down vote up
@Test
public void testSyncFunctions() throws IOException, InterruptedException {
    ServerBuilder.forPort(port);
    AskerServer server = new AskerServer();

    try {
        server.start();

        AskerClient client = new AskerClient();
        AskerBlockingStub blockingStub = client.blockingStub;

        SyncHelper helper = new SyncHelper(collector);

        helper.checkEcho(blockingStub);
        helper.checkCount(blockingStub);
        helper.checkReverse(blockingStub);
        helper.checkUpperCast(blockingStub);
        helper.checkLowerCast(blockingStub);

        helper.checkRandom(blockingStub, 5 + random.nextInt(10));

    } finally {
        if (server != null) {
            server.stop();
        }
    }
}
 
Example 33
Project: rpc-comparison   File: FunctionTest.java   View source code 5 votes vote down vote up
@Test
public void testAsyncFunctions() throws IOException, InterruptedException, ExecutionException {
    ServerBuilder.forPort(port);
    AskerServer server = new AskerServer();

    try {
        server.start();

        AskerClient client = new AskerClient();
        AskerStub stub = client.asyncStub;

        AsyncHelper helper = new AsyncHelper(collector);

        helper.checkEcho(stub);
        helper.checkCount(stub);
        helper.checkReverse(stub);
        helper.checkUpperCast(stub);
        helper.checkLowerCast(stub);

        helper.checkRandom(stub, 5 + random.nextInt(10));

    } finally {
        if (server != null) {
            server.stop();
        }
    }
}
 
Example 34
Project: tikv-client-lib-java   File: PDMockServer.java   View source code 5 votes vote down vote up
public void start(long clusterId) throws IOException {
  try (ServerSocket s = new ServerSocket(0)) {
    port = s.getLocalPort();
  }
  this.clusterId = clusterId;
  server = ServerBuilder.forPort(port).addService(this).build().start();

  Runtime.getRuntime().addShutdownHook(new Thread(PDMockServer.this::stop));
}
 
Example 35
Project: tikv-client-lib-java   File: KVMockServer.java   View source code 5 votes vote down vote up
public int start(TiRegion region) throws IOException {
  try (ServerSocket s = new ServerSocket(0)) {
    port = s.getLocalPort();
  }
  server = ServerBuilder.forPort(port).addService(this).build().start();

  this.region = region;
  Runtime.getRuntime().addShutdownHook(new Thread(KVMockServer.this::stop));
  return port;
}
 
Example 36
Project: africastalking-java   File: Server.java   View source code 5 votes vote down vote up
public void startInsecure(int port) throws IOException {
    ServerBuilder builder = ServerBuilder.forPort(port);
    if (mAuthenticator != null) {
        builder.addService(ServerInterceptors.intercept(
            mSdkService, new AuthenticationInterceptor(this.mAuthenticator)));
    } else {
        builder.addService(mSdkService);
    }
    mGrpc = builder.build();
    mGrpc.start();
}
 
Example 37
Project: grpc-java-contrib   File: SimpleGrpcServerFactory.java   View source code 5 votes vote down vote up
@Override
public Server buildServerForServices(int port, Collection<BindableService> services) {
    ServerBuilder builder = ServerBuilder.forPort(port);
    setupServer(builder);
    services.forEach(service -> registerService(builder, service));
    return builder.build();
}
 
Example 38
Project: seldon-core   File: SeldonGrpcServer.java   View source code 5 votes vote down vote up
public SeldonGrpcServer(AppProperties appProperties,DeploymentStore deploymentStore,TokenStore tokenStore,ServerBuilder<?> serverBuilder,DeploymentsHandler deploymentsHandler, int port) 
{
    this.appProperties = appProperties;
    this.deploymentStore = deploymentStore;
    this.tokenStore = tokenStore;
    this.grpcDeploymentsListener = new grpcDeploymentsListener(this);
    this.deploymentsHandler = deploymentsHandler;
    deploymentsHandler.addListener(this.grpcDeploymentsListener);
    this.port = port;
    server = serverBuilder
          .addService(ServerInterceptors.intercept(new SeldonService(this), new HeaderServerInterceptor(this)))
      .build();
}
 
Example 39
Project: seldon-core   File: FakeEngineServer.java   View source code 5 votes vote down vote up
public FakeEngineServer() 
{
    server = ServerBuilder
                .forPort(PORT)
                .addService(new FakeSeldonEngineService())
                .build();
}
 
Example 40
Project: rpc-thunderdome   File: GrpcServer.java   View source code 5 votes vote down vote up
public static void main(String... args) throws Exception {
  System.out.println("starting server");


  String host = System.getProperty("host", "127.0.0.1");
  int port = Integer.getInteger("port", 8001);

  io.grpc.Server start = ServerBuilder.forPort(port)
                             .addService(new DefaultService())
                             .build()
                             .start();

  System.out.println("server started");
  start.awaitTermination();
}