use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.Server in project zemberek-nlp by ahmetaa.
the class ZemberekGrpcServer method start.
public void start() throws Exception {
Server server = NettyServerBuilder.forPort(port).addService(new LanguageIdServiceImpl()).addService(new PreprocessingServiceImpl()).addService(new NormalizationServiceImpl(context)).addService(new MorphologyServiceImpl(context)).build().start();
Log.info("Zemberek grpc server started at port: " + port);
server.awaitTermination();
}
use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.Server in project protoman by spotify.
the class Main method main.
public static void main(final String... args) throws IOException {
final SchemaRegistry schemaRegistry = createSchemaRegistry();
final SchemaRegistryService registryService = SchemaRegistryService.create(schemaRegistry, schemaRegistry);
final SchemaProtodocService protodocService = SchemaProtodocService.create(schemaRegistry);
final Server grpcServer = ServerBuilder.forPort(GRPC_PORT).addService(registryService).addService(protodocService).intercept(new LoggingServerInterceptor()).build();
grpcServer.start();
// HTTP server
SLF4JBridgeHandler.removeHandlersForRootLogger();
SLF4JBridgeHandler.install();
final ResourceConfig rc = resourceConfig(schemaRegistry);
// static files
final Path staticFilePath = staticFilesPathFromEnv();
logger.info("Loading static files from " + staticFilePath);
Files.list(staticFilePath).forEach(p -> logger.debug(p.toAbsolutePath().toString()));
final StaticHttpHandler staticHttpHandler = new IndexFallbackStaticHttpHandler(staticFilePath.toAbsolutePath().toString());
final ExtraHandler staticExtraHandler = ExtraHandler.create(staticHttpHandler, "/");
URI uri = UriBuilder.fromUri("http://0.0.0.0/api").port(HTTP_PORT).build();
startHttpServer(uri, rc, staticExtraHandler);
while (!grpcServer.isTerminated()) {
try {
grpcServer.awaitTermination();
} catch (InterruptedException e) {
}
}
}
use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.Server in project tutorials by eugenp.
the class GrpcServer method main.
public static void main(String[] args) throws IOException, InterruptedException {
Server server = ServerBuilder.forPort(8080).addService(new HelloServiceImpl()).build();
System.out.println("Starting server...");
server.start();
System.out.println("Server started!");
server.awaitTermination();
}
use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.Server in project ballerina by ballerina-lang.
the class Stop method execute.
@Override
public void execute(Context context) {
BStruct serviceEndpoint = (BStruct) context.getRefArgument(SERVICE_ENDPOINT_INDEX);
Server server = getServerInstance(serviceEndpoint);
stop(server);
context.setReturnValues();
}
use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.Server in project beam by apache.
the class ServerFactoryTest method runTestUsing.
private Endpoints.ApiServiceDescriptor runTestUsing(ServerFactory serverFactory, ManagedChannelFactory channelFactory) throws Exception {
Endpoints.ApiServiceDescriptor.Builder apiServiceDescriptorBuilder = Endpoints.ApiServiceDescriptor.newBuilder();
final Collection<Elements> serverElements = new ArrayList<>();
final CountDownLatch clientHangedUp = new CountDownLatch(1);
CallStreamObserver<Elements> serverInboundObserver = TestStreams.withOnNext(serverElements::add).withOnCompleted(clientHangedUp::countDown).build();
TestDataService service = new TestDataService(serverInboundObserver);
Server server = serverFactory.allocateAddressAndCreate(ImmutableList.of(service), apiServiceDescriptorBuilder);
assertFalse(server.isShutdown());
ManagedChannel channel = channelFactory.forDescriptor(apiServiceDescriptorBuilder.build());
BeamFnDataGrpc.BeamFnDataStub stub = BeamFnDataGrpc.newStub(channel);
final Collection<BeamFnApi.Elements> clientElements = new ArrayList<>();
final CountDownLatch serverHangedUp = new CountDownLatch(1);
CallStreamObserver<BeamFnApi.Elements> clientInboundObserver = TestStreams.withOnNext(clientElements::add).withOnCompleted(serverHangedUp::countDown).build();
StreamObserver<Elements> clientOutboundObserver = stub.data(clientInboundObserver);
StreamObserver<BeamFnApi.Elements> serverOutboundObserver = service.outboundObservers.take();
clientOutboundObserver.onNext(CLIENT_DATA);
serverOutboundObserver.onNext(SERVER_DATA);
clientOutboundObserver.onCompleted();
clientHangedUp.await();
serverOutboundObserver.onCompleted();
serverHangedUp.await();
assertThat(clientElements, contains(SERVER_DATA));
assertThat(serverElements, contains(CLIENT_DATA));
return apiServiceDescriptorBuilder.build();
}
Aggregations