ChannelPipeline next = Channels.pipeline(); next.addLast("frameDecoder", new ProtobufVarint32FrameDecoder()); next.addLast("protobufDecoder", new ProtobufDecoder(TestMessage.getDefaultInstance())); next.addLast("frameEncoder", new ProtobufVarint32LengthFieldPrepender()); next.addLast("protobufEncoder", new ProtobufEncoder()); next.addLast("protobufHandler", new ProtobufHandler()); //add this.
@Override public HandlerResponse<byte[]> call() { return pbHandler.apply(requestBytes); } });
@Override public void setServerRpcMetadata(RpcMetadataResponse metadata) { // Set the metadata for the normal service calls service.setRpcMetadata(metadata); // Also add it to the handler to include with exceptions pbHandler.setRpcMetadata(metadata); }
handlerResponse = pbHandler.apply(requestBytes); handlerResponse = pbHandler.unauthenticatedErrorResponse(e); } catch (RemoteUserDisallowedException e) { LOG.debug("Remote user is not authorized", e); handlerResponse = pbHandler.unauthorizedErrorResponse(e); } catch (Exception e) { LOG.debug("Error invoking request from {}", baseRequest.getRemoteAddr(), e); handlerResponse = pbHandler.convertToErrorResponse(e);
handlerResponse = pbHandler.apply(requestBytes); handlerResponse = pbHandler.unauthenticatedErrorResponse(e); } catch (RemoteUserDisallowedException e) { LOG.debug("Remote user is not authorized", e); handlerResponse = pbHandler.unauthorizedErrorResponse(e); } catch (Exception e) { LOG.debug("Error invoking request from {}", baseRequest.getRemoteAddr(), e); handlerResponse = pbHandler.convertToErrorResponse(e);
public AvaticaProtobufHandler(Service service, MetricsSystem metrics, AvaticaServerConfiguration serverConfig) { this.service = Objects.requireNonNull(service); this.metrics = Objects.requireNonNull(metrics); this.requestTimer = this.metrics.getTimer( MetricsHelper.concat(AvaticaProtobufHandler.class, MetricsAwareAvaticaHandler.REQUEST_TIMER_NAME)); this.protobufTranslation = new ProtobufTranslationImpl(); this.pbHandler = new ProtobufHandler(service, protobufTranslation, metrics); this.threadLocalBuffer = new ThreadLocal<UnsynchronizedBuffer>() { @Override public UnsynchronizedBuffer initialValue() { return new UnsynchronizedBuffer(); } }; this.serverConfig = serverConfig; }
@Override public HandlerResponse<byte[]> call() { return pbHandler.apply(requestBytes); } });
@Override public void setServerRpcMetadata(RpcMetadataResponse metadata) { // Set the metadata for the normal service calls service.setRpcMetadata(metadata); // Also add it to the handler to include with exceptions pbHandler.setRpcMetadata(metadata); }
public AvaticaProtobufHandler(Service service, MetricsSystem metrics, AvaticaServerConfiguration serverConfig) { this.service = Objects.requireNonNull(service); this.metrics = Objects.requireNonNull(metrics); this.requestTimer = this.metrics.getTimer( MetricsHelper.concat(AvaticaProtobufHandler.class, MetricsAwareAvaticaHandler.REQUEST_TIMER_NAME)); this.protobufTranslation = new ProtobufTranslationImpl(); this.pbHandler = new ProtobufHandler(service, protobufTranslation, metrics); this.threadLocalBuffer = new ThreadLocal<UnsynchronizedBuffer>() { @Override public UnsynchronizedBuffer initialValue() { return new UnsynchronizedBuffer(); } }; this.serverConfig = serverConfig; }
.thenReturn(response.serialize().toByteArray()); HandlerResponse<byte[]> handlerResponse = handler.apply(serializedRequest); byte[] serializedResponse = handlerResponse.getResponse(); assertEquals(200, handlerResponse.getStatusCode());
@Before public void setupMocks() { // Mocks service = Mockito.mock(Service.class); translation = Mockito.mock(ProtobufTranslation.class); // Real objects handler = new ProtobufHandler(service, translation); }
.thenReturn(response.serialize().toByteArray()); HandlerResponse<byte[]> handlerResponse = handler.apply(serializedRequest); byte[] serializedResponse = handlerResponse.getResponse(); assertEquals(200, handlerResponse.getStatusCode());
@Before public void setupMocks() { // Mocks service = Mockito.mock(Service.class); translation = Mockito.mock(ProtobufTranslation.class); // Real objects handler = new ProtobufHandler(service, translation, NoopMetricsSystem.getInstance()); }
.thenReturn(response.serialize().toByteArray()); HandlerResponse<byte[]> handlerResponse = handler.apply(serializedRequest); byte[] serializedResponse = handlerResponse.getResponse(); assertEquals(200, handlerResponse.getStatusCode());
@Before public void setupMocks() { // Mocks service = Mockito.mock(Service.class); translation = Mockito.mock(ProtobufTranslation.class); // Real objects handler = new ProtobufHandler(service, translation, NoopMetricsSystem.getInstance()); }