io.grpc.ServerMethodDefinition Java Examples

The following examples show how to use io.grpc.ServerMethodDefinition. 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: BinaryLogProvider.java    From grpc-nebula-java with Apache License 2.0 6 votes vote down vote up
/**
 * Wraps a {@link ServerMethodDefinition} such that it performs binary logging if needed.
 */
@Override
public final <ReqT, RespT> ServerMethodDefinition<?, ?> wrapMethodDefinition(
    ServerMethodDefinition<ReqT, RespT> oMethodDef) {
  ServerInterceptor binlogInterceptor =
      getServerInterceptor(oMethodDef.getMethodDescriptor().getFullMethodName());
  if (binlogInterceptor == null) {
    return oMethodDef;
  }
  MethodDescriptor<byte[], byte[]> binMethod =
      BinaryLogProvider.toByteBufferMethod(oMethodDef.getMethodDescriptor());
  ServerMethodDefinition<byte[], byte[]> binDef =
      InternalServerInterceptors.wrapMethod(oMethodDef, binMethod);
  ServerCallHandler<byte[], byte[]> binlogHandler =
      InternalServerInterceptors.interceptCallHandlerCreate(
          binlogInterceptor, binDef.getServerCallHandler());
  return ServerMethodDefinition.create(binMethod, binlogHandler);
}
 
Example #2
Source File: BinaryLogProviderTest.java    From grpc-nebula-java with Apache License 2.0 6 votes vote down vote up
private static <ReqT, RespT> ServerCall.Listener<ReqT> startServerCallHelper(
    final ServerMethodDefinition<ReqT, RespT> methodDef,
    final List<Object> serializedResp) {
  ServerCall<ReqT, RespT> serverCall = new NoopServerCall<ReqT, RespT>() {
    @Override
    public void sendMessage(RespT message) {
      serializedResp.add(message);
    }

    @Override
    public MethodDescriptor<ReqT, RespT> getMethodDescriptor() {
      return methodDef.getMethodDescriptor();
    }
  };
  return methodDef.getServerCallHandler().startCall(serverCall, new Metadata());
}
 
Example #3
Source File: ServerImpl.java    From grpc-nebula-java with Apache License 2.0 6 votes vote down vote up
/** Never returns {@code null}. */
private <ReqT, RespT> ServerStreamListener startCall(ServerStream stream, String fullMethodName,
    ServerMethodDefinition<ReqT, RespT> methodDef, Metadata headers,
    Context.CancellableContext context, StatsTraceContext statsTraceCtx) {
  // TODO(ejona86): should we update fullMethodName to have the canonical path of the method?
  statsTraceCtx.serverCallStarted(
      new ServerCallInfoImpl<ReqT, RespT>(
          methodDef.getMethodDescriptor(), // notify with original method descriptor
          stream.getAttributes(),
          stream.getAuthority()));
  ServerCallHandler<ReqT, RespT> handler = methodDef.getServerCallHandler();
  for (ServerInterceptor interceptor : interceptors) {
    handler = InternalServerInterceptors.interceptCallHandler(interceptor, handler);
  }
  ServerMethodDefinition<ReqT, RespT> interceptedDef = methodDef.withServerCallHandler(handler);
  ServerMethodDefinition<?, ?> wMethodDef = binlog == null
      ? interceptedDef : binlog.wrapMethodDefinition(interceptedDef);
  return startWrappedCall(fullMethodName, wMethodDef, stream, headers, context);
}
 
Example #4
Source File: ServerImpl.java    From grpc-nebula-java with Apache License 2.0 6 votes vote down vote up
private <WReqT, WRespT> ServerStreamListener startWrappedCall(
    String fullMethodName,
    ServerMethodDefinition<WReqT, WRespT> methodDef,
    ServerStream stream,
    Metadata headers,
    Context.CancellableContext context) {
  ServerCallImpl<WReqT, WRespT> call = new ServerCallImpl<WReqT, WRespT>(
      stream,
      methodDef.getMethodDescriptor(),
      headers,
      context,
      decompressorRegistry,
      compressorRegistry,
      serverCallTracer);

  ServerCall.Listener<WReqT> listener =
      methodDef.getServerCallHandler().startCall(call, headers);
  if (listener == null) {
    throw new NullPointerException(
        "startCall() returned a null listener for method " + fullMethodName);
  }
  return call.newServerStreamListener(listener);
}
 
Example #5
Source File: MutableHandlerRegistryTest.java    From grpc-java with Apache License 2.0 6 votes vote down vote up
@Test
public void replaceAndLookup() {
  assertNull(registry.addService(basicServiceDefinition));
  assertNotNull(registry.lookupMethod("basic/flow"));
  MethodDescriptor<String, Integer> anotherMethod = MethodDescriptor.<String, Integer>newBuilder()
      .setType(MethodType.UNKNOWN)
      .setFullMethodName("basic/another")
      .setRequestMarshaller(requestMarshaller)
      .setResponseMarshaller(responseMarshaller)
      .build();
  ServerServiceDefinition replaceServiceDefinition = ServerServiceDefinition.builder(
      new ServiceDescriptor("basic", anotherMethod))
      .addMethod(anotherMethod, flowHandler).build();
  ServerMethodDefinition<?, ?> anotherMethodDefinition =
      replaceServiceDefinition.getMethod("basic/another");
  assertSame(basicServiceDefinition, registry.addService(replaceServiceDefinition));

  assertNull(registry.lookupMethod("basic/flow"));
  ServerMethodDefinition<?, ?> method = registry.lookupMethod("basic/another");
  assertSame(anotherMethodDefinition, method);
}
 
Example #6
Source File: BinaryLogProvider.java    From grpc-java with Apache License 2.0 6 votes vote down vote up
/**
 * Wraps a {@link ServerMethodDefinition} such that it performs binary logging if needed.
 */
@Override
public final <ReqT, RespT> ServerMethodDefinition<?, ?> wrapMethodDefinition(
    ServerMethodDefinition<ReqT, RespT> oMethodDef) {
  ServerInterceptor binlogInterceptor =
      getServerInterceptor(oMethodDef.getMethodDescriptor().getFullMethodName());
  if (binlogInterceptor == null) {
    return oMethodDef;
  }
  MethodDescriptor<byte[], byte[]> binMethod =
      BinaryLogProvider.toByteBufferMethod(oMethodDef.getMethodDescriptor());
  ServerMethodDefinition<byte[], byte[]> binDef =
      InternalServerInterceptors.wrapMethod(oMethodDef, binMethod);
  ServerCallHandler<byte[], byte[]> binlogHandler =
      InternalServerInterceptors.interceptCallHandlerCreate(
          binlogInterceptor, binDef.getServerCallHandler());
  return ServerMethodDefinition.create(binMethod, binlogHandler);
}
 
Example #7
Source File: TripleServer.java    From sofa-rpc with Apache License 2.0 6 votes vote down vote up
private ServerServiceDefinition buildSofaServiceDef(GenericServiceImpl genericService,
                                                    ProviderConfig providerConfig, Invoker instance) {
    ServerServiceDefinition templateDefinition = genericService.bindService();
    ServerCallHandler<Request, Response> templateHandler = (ServerCallHandler<Request, Response>) templateDefinition
        .getMethods().iterator().next().getServerCallHandler();
    List<MethodDescriptor<Request, Response>> methodDescriptor = getMethodDescriptor(providerConfig);
    List<ServerMethodDefinition<Request, Response>> methodDefs = getMethodDefinitions(templateHandler,
        methodDescriptor);
    ServerServiceDefinition.Builder builder = ServerServiceDefinition.builder(getServiceDescriptor(
        templateDefinition, providerConfig, methodDescriptor));
    for (ServerMethodDefinition<Request, Response> methodDef : methodDefs) {
        builder.addMethod(methodDef);

    }
    return builder.build();

}
 
Example #8
Source File: MutableHandlerRegistryTest.java    From grpc-nebula-java with Apache License 2.0 6 votes vote down vote up
@Test
public void replaceAndLookup() {
  assertNull(registry.addService(basicServiceDefinition));
  assertNotNull(registry.lookupMethod("basic/flow"));
  MethodDescriptor<String, Integer> anotherMethod = MethodDescriptor.<String, Integer>newBuilder()
      .setType(MethodType.UNKNOWN)
      .setFullMethodName("basic/another")
      .setRequestMarshaller(requestMarshaller)
      .setResponseMarshaller(responseMarshaller)
      .build();
  ServerServiceDefinition replaceServiceDefinition = ServerServiceDefinition.builder(
      new ServiceDescriptor("basic", anotherMethod))
      .addMethod(anotherMethod, flowHandler).build();
  ServerMethodDefinition<?, ?> anotherMethodDefinition =
      replaceServiceDefinition.getMethod("basic/another");
  assertSame(basicServiceDefinition, registry.addService(replaceServiceDefinition));

  assertNull(registry.lookupMethod("basic/flow"));
  ServerMethodDefinition<?, ?> method = registry.lookupMethod("basic/another");
  assertSame(anotherMethodDefinition, method);
}
 
Example #9
Source File: BinaryLogProviderTest.java    From grpc-java with Apache License 2.0 6 votes vote down vote up
private static <ReqT, RespT> ServerCall.Listener<ReqT> startServerCallHelper(
    final ServerMethodDefinition<ReqT, RespT> methodDef,
    final List<Object> serializedResp) {
  ServerCall<ReqT, RespT> serverCall = new NoopServerCall<ReqT, RespT>() {
    @Override
    public void sendMessage(RespT message) {
      serializedResp.add(message);
    }

    @Override
    public MethodDescriptor<ReqT, RespT> getMethodDescriptor() {
      return methodDef.getMethodDescriptor();
    }
  };
  return methodDef.getServerCallHandler().startCall(serverCall, new Metadata());
}
 
Example #10
Source File: ServerImpl.java    From grpc-java with Apache License 2.0 6 votes vote down vote up
private <WReqT, WRespT> ServerStreamListener startWrappedCall(
    String fullMethodName,
    ServerMethodDefinition<WReqT, WRespT> methodDef,
    ServerStream stream,
    Metadata headers,
    Context.CancellableContext context,
    Tag tag) {

  ServerCallImpl<WReqT, WRespT> call = new ServerCallImpl<>(
      stream,
      methodDef.getMethodDescriptor(),
      headers,
      context,
      decompressorRegistry,
      compressorRegistry,
      serverCallTracer,
      tag);

  ServerCall.Listener<WReqT> listener =
      methodDef.getServerCallHandler().startCall(call, headers);
  if (listener == null) {
    throw new NullPointerException(
        "startCall() returned a null listener for method " + fullMethodName);
  }
  return call.newServerStreamListener(listener);
}
 
Example #11
Source File: ServerImpl.java    From grpc-java with Apache License 2.0 6 votes vote down vote up
/** Never returns {@code null}. */
private <ReqT, RespT> ServerStreamListener startCall(ServerStream stream, String fullMethodName,
    ServerMethodDefinition<ReqT, RespT> methodDef, Metadata headers,
    Context.CancellableContext context, StatsTraceContext statsTraceCtx, Tag tag) {
  // TODO(ejona86): should we update fullMethodName to have the canonical path of the method?
  statsTraceCtx.serverCallStarted(
      new ServerCallInfoImpl<>(
          methodDef.getMethodDescriptor(), // notify with original method descriptor
          stream.getAttributes(),
          stream.getAuthority()));
  ServerCallHandler<ReqT, RespT> handler = methodDef.getServerCallHandler();
  for (ServerInterceptor interceptor : interceptors) {
    handler = InternalServerInterceptors.interceptCallHandler(interceptor, handler);
  }
  ServerMethodDefinition<ReqT, RespT> interceptedDef = methodDef.withServerCallHandler(handler);
  ServerMethodDefinition<?, ?> wMethodDef = binlog == null
      ? interceptedDef : binlog.wrapMethodDefinition(interceptedDef);
  return startWrappedCall(fullMethodName, wMethodDef, stream, headers, context, tag);
}
 
Example #12
Source File: HandlerRegistry.java    From armeria with Apache License 2.0 5 votes vote down vote up
HandlerRegistry build() {
    final ImmutableMap.Builder<String, ServerMethodDefinition<?, ?>> mapBuilder =
            ImmutableMap.builder();
    for (ServerServiceDefinition service : services.values()) {
        for (ServerMethodDefinition<?, ?> method : service.getMethods()) {
            mapBuilder.put(method.getMethodDescriptor().getFullMethodName(), method);
        }
    }
    return new HandlerRegistry(ImmutableList.copyOf(services.values()), mapBuilder.build());
}
 
Example #13
Source File: BinaryLogProviderTest.java    From grpc-nebula-java with Apache License 2.0 5 votes vote down vote up
@Test
public void wrapMethodDefinition_methodDescriptor() throws Exception {
  ServerMethodDefinition<String, Integer> methodDef =
      ServerMethodDefinition.create(
          method,
          new ServerCallHandler<String, Integer>() {
            @Override
            public Listener<String> startCall(
                ServerCall<String, Integer> call, Metadata headers) {
              throw new UnsupportedOperationException();
            }
          });
  ServerMethodDefinition<?, ?> wMethodDef = binlogProvider.wrapMethodDefinition(methodDef);
  validateWrappedMethod(wMethodDef.getMethodDescriptor());
}
 
Example #14
Source File: UnframedGrpcService.java    From armeria with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new instance that decorates the specified {@link HttpService}.
 */
UnframedGrpcService(GrpcService delegate) {
    super(delegate);
    checkArgument(delegate.isFramed(), "Decorated service must be a framed GrpcService.");
    delegateGrpcService = delegate;
    methodsByName = delegate.services()
                            .stream()
                            .flatMap(service -> service.getMethods().stream())
                            .map(ServerMethodDefinition::getMethodDescriptor)
                            .collect(toImmutableMap(MethodDescriptor::getFullMethodName,
                                                    Function.identity()));
}
 
Example #15
Source File: BinaryLogProviderTest.java    From grpc-java with Apache License 2.0 5 votes vote down vote up
@Test
public void wrapMethodDefinition_methodDescriptor() throws Exception {
  ServerMethodDefinition<String, Integer> methodDef =
      ServerMethodDefinition.create(
          method,
          new ServerCallHandler<String, Integer>() {
            @Override
            public ServerCall.Listener<String> startCall(
                ServerCall<String, Integer> call, Metadata headers) {
              throw new UnsupportedOperationException();
            }
          });
  ServerMethodDefinition<?, ?> wMethodDef = binlogProvider.wrapMethodDefinition(methodDef);
  validateWrappedMethod(wMethodDef.getMethodDescriptor());
}
 
Example #16
Source File: InternalHandlerRegistry.java    From grpc-java with Apache License 2.0 5 votes vote down vote up
InternalHandlerRegistry build() {
  Map<String, ServerMethodDefinition<?, ?>> map =
      new HashMap<>();
  for (ServerServiceDefinition service : services.values()) {
    for (ServerMethodDefinition<?, ?> method : service.getMethods()) {
      map.put(method.getMethodDescriptor().getFullMethodName(), method);
    }
  }
  return new InternalHandlerRegistry(
      Collections.unmodifiableList(new ArrayList<>(services.values())),
      Collections.unmodifiableMap(map));
}
 
Example #17
Source File: MutableHandlerRegistry.java    From grpc-java with Apache License 2.0 5 votes vote down vote up
/**
 * Note: This does not actually honor the authority provided.  It will, eventually in the future.
 */
@Override
@Nullable
public ServerMethodDefinition<?, ?> lookupMethod(String methodName, @Nullable String authority) {
  String serviceName = MethodDescriptor.extractFullServiceName(methodName);
  if (serviceName == null) {
    return null;
  }
  ServerServiceDefinition service = services.get(serviceName);
  if (service == null) {
    return null;
  }
  return service.getMethod(methodName);
}
 
Example #18
Source File: ManagedChannelImplTest.java    From grpc-java with Apache License 2.0 5 votes vote down vote up
@Test
public void binaryLogInstalled() throws Exception {
  final SettableFuture<Boolean> intercepted = SettableFuture.create();
  channelBuilder.binlog = new BinaryLog() {
    @Override
    public void close() throws IOException {
      // noop
    }

    @Override
    public <ReqT, RespT> ServerMethodDefinition<?, ?> wrapMethodDefinition(
        ServerMethodDefinition<ReqT, RespT> oMethodDef) {
      return oMethodDef;
    }

    @Override
    public Channel wrapChannel(Channel channel) {
      return ClientInterceptors.intercept(channel,
          new ClientInterceptor() {
            @Override
            public <ReqT, RespT> ClientCall<ReqT, RespT> interceptCall(
                MethodDescriptor<ReqT, RespT> method,
                CallOptions callOptions,
                Channel next) {
              intercepted.set(true);
              return next.newCall(method, callOptions);
            }
          });
    }
  };

  createChannel();
  ClientCall<String, Integer> call = channel.newCall(method, CallOptions.DEFAULT);
  call.start(mockCallListener, new Metadata());
  assertTrue(intercepted.get());
}
 
Example #19
Source File: ServerImplTest.java    From grpc-java with Apache License 2.0 5 votes vote down vote up
@Test
public void binaryLogInstalled() throws Exception {
  final SettableFuture<Boolean> intercepted = SettableFuture.create();
  final ServerInterceptor interceptor = new ServerInterceptor() {
    @Override
    public <ReqT, RespT> Listener<ReqT> interceptCall(ServerCall<ReqT, RespT> call,
        Metadata headers,
        ServerCallHandler<ReqT, RespT> next) {
      intercepted.set(true);
      return next.startCall(call, headers);
    }
  };

  builder.binlog = new BinaryLog() {
    @Override
    public void close() throws IOException {
      // noop
    }

    @Override
    public <ReqT, RespT> ServerMethodDefinition<?, ?> wrapMethodDefinition(
        ServerMethodDefinition<ReqT, RespT> oMethodDef) {
      return ServerMethodDefinition.create(
          oMethodDef.getMethodDescriptor(),
          InternalServerInterceptors.interceptCallHandlerCreate(
              interceptor,
              oMethodDef.getServerCallHandler()));
    }

    @Override
    public Channel wrapChannel(Channel channel) {
      return channel;
    }
  };
  createAndStartServer();
  basicExchangeHelper(METHOD, "Lots of pizza, please", 314, 50);
  assertTrue(intercepted.get());
}
 
Example #20
Source File: MutableHandlerRegistryTest.java    From grpc-java with Apache License 2.0 5 votes vote down vote up
@Test
public void simpleLookup() {
  assertNull(registry.addService(basicServiceDefinition));
  ServerMethodDefinition<?, ?> method = registry.lookupMethod("basic/flow");
  assertSame(flowMethodDefinition, method);

  assertNull(registry.lookupMethod("/basic/flow"));
  assertNull(registry.lookupMethod("basic/basic"));
  assertNull(registry.lookupMethod("flow/flow"));
  assertNull(registry.lookupMethod("completely/random"));
}
 
Example #21
Source File: MutableHandlerRegistryTest.java    From grpc-java with Apache License 2.0 5 votes vote down vote up
@Test
public void simpleLookupWithBindable() {
  BindableService bindableService =
      new BindableService() {
        @Override
        public ServerServiceDefinition bindService() {
          return basicServiceDefinition;
        }
      };

  assertNull(registry.addService(bindableService));

  ServerMethodDefinition<?, ?> method = registry.lookupMethod("basic/flow");
  assertSame(flowMethodDefinition, method);
}
 
Example #22
Source File: UtilServerInterceptorsTest.java    From grpc-java with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
private static ServerMethodDefinition<Void, Void> getSoleMethod(
    ServerServiceDefinition serviceDef) {
  if (serviceDef.getMethods().size() != 1) {
    throw new AssertionError("Not exactly one method present");
  }
  return (ServerMethodDefinition<Void, Void>) getOnlyElement(serviceDef.getMethods());
}
 
Example #23
Source File: ProxyHandlerRegistry.java    From grpc-proxy with Apache License 2.0 5 votes vote down vote up
@Override
public ServerMethodDefinition<?, ?> lookupMethod(String methodName, @Nullable String authority) {
  return ServerMethodDefinition.create(
      MethodDescriptor.<byte[], byte[]>newBuilder()
          .setRequestMarshaller(new ByteArrayMarshaller())
          .setResponseMarshaller(new ByteArrayMarshaller())
          .setType(MethodType.UNARY)
          .setFullMethodName(methodName)
          .build(),
      ServerCalls.asyncUnaryCall(new ProxyUnaryMethod(backend, methodName)));
}
 
Example #24
Source File: InternalHandlerRegistry.java    From grpc-nebula-java with Apache License 2.0 5 votes vote down vote up
/**
 * 重新设置服务和方法
 *
 * @author sxp
 * @since 2019/7/16
 */
@Override
public void resetServicesAndMethods(List<ServerServiceDefinition> newServices) {
  Map<String, ServerMethodDefinition<?, ?>> map = new HashMap<>();
  for (ServerServiceDefinition service : newServices) {
    for (ServerMethodDefinition<?, ?> method : service.getMethods()) {
      map.put(method.getMethodDescriptor().getFullMethodName(), method);
    }
  }

  this.services = Collections.unmodifiableList(newServices);
  this.methods = Collections.unmodifiableMap(map);
}
 
Example #25
Source File: TripleServer.java    From sofa-rpc with Apache License 2.0 5 votes vote down vote up
private List<ServerMethodDefinition<Request, Response>> getMethodDefinitions(ServerCallHandler<Request, Response> templateHandler,List<MethodDescriptor<Request, Response>> methodDescriptors) {
    List<ServerMethodDefinition<Request, Response>> result = new ArrayList<>();

    for (MethodDescriptor<Request, Response> methodDescriptor : methodDescriptors) {
        ServerMethodDefinition<Request, Response> serverMethodDefinition = ServerMethodDefinition.create(methodDescriptor, templateHandler);
        result.add(serverMethodDefinition);
    }
    return result;
}
 
Example #26
Source File: UtilServerInterceptorsTest.java    From grpc-nebula-java with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
private static ServerMethodDefinition<Void, Void> getSoleMethod(
    ServerServiceDefinition serviceDef) {
  if (serviceDef.getMethods().size() != 1) {
    throw new AssertionError("Not exactly one method present");
  }
  return (ServerMethodDefinition<Void, Void>) getOnlyElement(serviceDef.getMethods());
}
 
Example #27
Source File: InternalHandlerRegistry.java    From grpc-nebula-java with Apache License 2.0 5 votes vote down vote up
InternalHandlerRegistry build() {
  Map<String, ServerMethodDefinition<?, ?>> map =
      new HashMap<String, ServerMethodDefinition<?, ?>>();
  for (ServerServiceDefinition service : services.values()) {
    for (ServerMethodDefinition<?, ?> method : service.getMethods()) {
      map.put(method.getMethodDescriptor().getFullMethodName(), method);
    }
  }
  return new InternalHandlerRegistry(
      Collections.unmodifiableList(new ArrayList<>(services.values())),
      Collections.unmodifiableMap(map));
}
 
Example #28
Source File: MutableHandlerRegistryTest.java    From grpc-nebula-java with Apache License 2.0 5 votes vote down vote up
@Test
public void simpleLookupWithBindable() {
  BindableService bindableService =
      new BindableService() {
        @Override
        public ServerServiceDefinition bindService() {
          return basicServiceDefinition;
        }
      };

  assertNull(registry.addService(bindableService));

  ServerMethodDefinition<?, ?> method = registry.lookupMethod("basic/flow");
  assertSame(flowMethodDefinition, method);
}
 
Example #29
Source File: MutableHandlerRegistryTest.java    From grpc-nebula-java with Apache License 2.0 5 votes vote down vote up
@Test
public void simpleLookup() {
  assertNull(registry.addService(basicServiceDefinition));
  ServerMethodDefinition<?, ?> method = registry.lookupMethod("basic/flow");
  assertSame(flowMethodDefinition, method);

  assertNull(registry.lookupMethod("/basic/flow"));
  assertNull(registry.lookupMethod("basic/basic"));
  assertNull(registry.lookupMethod("flow/flow"));
  assertNull(registry.lookupMethod("completely/random"));
}
 
Example #30
Source File: ServerImplTest.java    From grpc-nebula-java with Apache License 2.0 5 votes vote down vote up
@Test
public void binaryLogInstalled() throws Exception {
  final SettableFuture<Boolean> intercepted = SettableFuture.create();
  final ServerInterceptor interceptor = new ServerInterceptor() {
    @Override
    public <ReqT, RespT> Listener<ReqT> interceptCall(ServerCall<ReqT, RespT> call,
        Metadata headers,
        ServerCallHandler<ReqT, RespT> next) {
      intercepted.set(true);
      return next.startCall(call, headers);
    }
  };

  builder.binlog = new BinaryLog() {
    @Override
    public void close() throws IOException {
      // noop
    }

    @Override
    public <ReqT, RespT> ServerMethodDefinition<?, ?> wrapMethodDefinition(
        ServerMethodDefinition<ReqT, RespT> oMethodDef) {
      return ServerMethodDefinition.create(
          oMethodDef.getMethodDescriptor(),
          InternalServerInterceptors.interceptCallHandlerCreate(
              interceptor,
              oMethodDef.getServerCallHandler()));
    }

    @Override
    public Channel wrapChannel(Channel channel) {
      return channel;
    }
  };
  createAndStartServer();
  basicExchangeHelper(METHOD, "Lots of pizza, please", 314, 50);
  assertTrue(intercepted.get());
}