@@ -0,0 +1,3883 @@
+/*%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *      http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A%0Apackage com.codahale.gprcproxy;%0A%0Aimport com.codahale.grpcproxy.helloworld.GreeterGrpc.GreeterImplBase;%0Aimport com.codahale.grpcproxy.helloworld.HelloReply;%0Aimport com.codahale.grpcproxy.helloworld.HelloRequest;%0Aimport io.grpc.Server;%0Aimport io.grpc.netty.NettyServerBuilder;%0Aimport io.grpc.stub.StreamObserver;%0Aimport io.netty.channel.EventLoopGroup;%0Aimport java.io.IOException;%0Aimport java.util.concurrent.TimeUnit;%0Aimport java.util.logging.Logger;%0Aimport javax.net.ssl.SSLException;%0A%0Apublic class HelloWorldServer %7B%0A%0A  private static final Logger logger = Logger.getLogger(ProxyRpcServer.class.getName());%0A%0A  private final EventLoopGroup bossEventLoopGroup;%0A  private final EventLoopGroup workerEventLoopGroup;%0A  private final Server server;%0A  private final StatsTracerFactory stats;%0A%0A  private HelloWorldServer(int port) throws SSLException %7B%0A    this.stats = new StatsTracerFactory();%0A    this.bossEventLoopGroup = Netty.newEventLoopGroup();%0A    this.workerEventLoopGroup = Netty.newEventLoopGroup();%0A    this.server = NettyServerBuilder.forPort(port)%0A                                    .bossEventLoopGroup(bossEventLoopGroup)%0A                                    .workerEventLoopGroup(workerEventLoopGroup)%0A                                    .channelType(Netty.serverChannelType())%0A                                    .addStreamTracerFactory(stats)%0A                                    .sslContext(TLS.serverContext())%0A                                    .addService(new GreeterImplBase() %7B%0A                                      @Override%0A                                      public void sayHello(HelloRequest request,%0A                                          StreamObserver%3CHelloReply%3E responseObserver) %7B%0A                                        final String message = %22Hello %22 + request.getName();%0A                                        responseObserver.onNext(HelloReply.newBuilder()%0A                                                                          .setMessage(message)%0A                                                                          .build());%0A                                        responseObserver.onCompleted();%0A                                      %7D%0A                                    %7D)%0A                                    .build();%0A  %7D%0A%0A  public static void main(String%5B%5D args) throws IOException, InterruptedException %7B%0A    final HelloWorldServer server = new HelloWorldServer(50051);%0A    server.start();%0A    server.blockUntilShutdown();%0A  %7D%0A%0A  private void start() throws IOException %7B%0A    stats.start();%0A    server.start();%0A    logger.info(%22Server started, listening on %22 + server.getPort());%0A    Runtime.getRuntime().addShutdownHook(new Thread(() -%3E %7B%0A      // Use stderr here since the logger may have been reset by its JVM shutdown hook.%0A      System.err.println(%22*** shutting down gRPC server since JVM is shutting down%22);%0A      HelloWorldServer.this.stop();%0A      System.err.println(%22*** server shut down%22);%0A    %7D));%0A  %7D%0A%0A  private void stop() %7B%0A    stats.stop();%0A    if (!server.isShutdown()) %7B%0A      server.shutdown();%0A    %7D%0A    bossEventLoopGroup.shutdownGracefully(0, 0, TimeUnit.SECONDS);%0A    workerEventLoopGroup.shutdownGracefully(0, 0, TimeUnit.SECONDS);%0A  %7D%0A%0A  private void blockUntilShutdown() throws InterruptedException %7B%0A    server.awaitTermination();%0A  %7D%0A%7D%0A

Add a non-proxying gRPC service impl.