new ClientIdRequiredFilter<byte[], byte[]>(serviceStatsReceiver).andThen( new StatsFilter<byte[], byte[]>(serviceStatsLogger).andThen( new DistributedLogService.Service(dlService, new TBinaryProtocol.Factory()))), serverBuilder);
/** * @return a Thrift protocol factory for communicating with server through the transport */ public static TProtocolFactory createThriftProtocolFactory() { return new TBinaryProtocol.Factory(true, true); }
/** * Creates a Thrift processor handler with the default binary protocol * @param processor Processor to handle incoming calls */ public ThriftServerHandler(TProcessor processor) { this.processor = processor; this.protocolFactory = new TBinaryProtocol.Factory(); }
ServerThread(TProcessor processor, int port) throws Exception { TNonblockingServerSocket serverTransport = new TNonblockingServerSocket(port); TThreadedSelectorServer.Args tArgs = new TThreadedSelectorServer.Args(serverTransport); TProcessorFactory processorFactory = new TProcessorFactory(processor); tArgs.processorFactory(processorFactory); tArgs.transportFactory(new TFramedTransport.Factory()); tArgs.protocolFactory( new TBinaryProtocol.Factory(true, true)); server = new TThreadedSelectorServer(tArgs); }
public void startThreadPoolServer() throws TTransportException { TServerTransport serverTransport = new TServerSocket(this.port); final Send.Processor<Send.Iface> processor = new Send.Processor<Send.Iface>(this.handler); TThreadPoolServer.Args args = new TThreadPoolServer.Args(serverTransport).processor(processor); args.maxWorkerThreads = 10; args.protocolFactory(new TBinaryProtocol.Factory()); TServer server = new TThreadPoolServer(args); server.serve(); }
public void startThreadedSelectorServer() throws TTransportException { TNonblockingServerTransport serverTransport = new TNonblockingServerSocket(this.port); TTransportFactory transportFactory = new TFramedTransport.Factory(); TProtocolFactory proFactory = new TBinaryProtocol.Factory(); final Send.Processor<Send.Iface> processor = new Send.Processor<Send.Iface>(this.handler); TThreadedSelectorServer.Args args = new TThreadedSelectorServer.Args(serverTransport); args.protocolFactory(proFactory); args.transportFactory(transportFactory); args.processor(processor); TServer server = new TThreadedSelectorServer(args); server.serve(); }
/** * Create a new TDeserializer that uses the TBinaryProtocol by default. */ public TDeserializer() { this(new TBinaryProtocol.Factory()); }
public ZipkinSpanReceiver() { this.queue = new ArrayBlockingQueue<Span>(1000); this.protocolFactory = new TBinaryProtocol.Factory(); tf = new ThreadFactoryBuilder().setDaemon(true) .setNameFormat("zipkinSpanReceiver-%d") .build(); }
@Test public void testOutOfOrderNot() { TestingServerMethodInvoker methodInvoker = new TestingServerMethodInvoker(); int invocationCount = testServerMethodInvoker(methodInvoker, true, ImmutableList.of( address -> testOutOfOrder(address, MESSAGES, new TTransportFactory(), new TBinaryProtocol.Factory(), methodInvoker.getFutureResults()), address -> testOutOfOrder(address, MESSAGES, new TTransportFactory(), new TCompactProtocol.Factory(), methodInvoker.getFutureResults()), address -> testOutOfOrder(address, MESSAGES, new TFramedTransport.Factory(), new TBinaryProtocol.Factory(), methodInvoker.getFutureResults()), address -> testOutOfOrder(address, MESSAGES, new TFramedTransport.Factory(), new TCompactProtocol.Factory(), methodInvoker.getFutureResults()))); List<DriftLogEntry> expectedMessages = newArrayList(concat(nCopies(invocationCount, DRIFT_MESSAGES))); assertEquals(ImmutableList.copyOf(methodInvoker.getMessages()), expectedMessages); }
/** * Default constructors. */ protected TServer(TProcessorFactory processorFactory, TServerTransport serverTransport) { this(processorFactory, serverTransport, new TTransportFactory(), new TTransportFactory(), new TBinaryProtocol.Factory(), new TBinaryProtocol.Factory()); }
@Override public @Nullable ByteBuf encodeBody(@NotNull Object body) { try { TSerializer serializer = new TSerializer(new TBinaryProtocol.Factory()); byte[] payloadBytes = serializer.serialize((TBase<?, ?>) body); return Unpooled.wrappedBuffer(payloadBytes); } catch (TException e) { logger.error("Failed to encode {} body", body.getClass().getName(), e); } return null; }
@Bean @ConditionalOnMissingBean(TProtocolFactory.class) TProtocolFactory thriftProtocolFactory() { return new TBinaryProtocol.Factory(); }
public SimpleServer(TProcessor processor, String ip, int port) { this.processor = processor; this.factory = new OioServerSocketChannelFactory(Executors.newFixedThreadPool(1), Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() * 2)); this.ip = ip; this.port = port; this.handler = new SimpleServerHandler(processor, new TBinaryProtocol.Factory()); this.pipleFactory = new SimplePipelineFactory(handler); this.bootstrap = new ServerBootstrap(factory); }
public TThreadPoolServer(TProcessorFactory processorFactory, TServerTransport serverTransport) { this(processorFactory, serverTransport, new TTransportFactory(), new TTransportFactory(), new TBinaryProtocol.Factory(), new TBinaryProtocol.Factory()); }
protected TServer(TProcessorFactory processorFactory, TServerTransport serverTransport, TTransportFactory transportFactory) { this(processorFactory, serverTransport, transportFactory, transportFactory, new TBinaryProtocol.Factory(), new TBinaryProtocol.Factory()); }
/** * Create server with specified processor factory and server transport. * TBinaryProtocol is assumed. TFramedTransport.Factory is used on both input * and output transports. */ public TNonblockingServer(TProcessorFactory processorFactory, TNonblockingServerTransport serverTransport) { this(processorFactory, serverTransport, new TFramedTransport.Factory(), new TBinaryProtocol.Factory(), new TBinaryProtocol.Factory()); }
public void startServer() throws Exception { TProcessor tprocessor = new HelloWorldService.Processor<HelloWorldService.Iface>( new HelloWorldImpl()); TServerSocket serverTransport = new TServerSocket(SERVER_PORT); TSimpleServer.Args tArgs = new TSimpleServer.Args(serverTransport); tArgs.processor(tprocessor); tArgs.protocolFactory(new TBinaryProtocol.Factory()); TServer server = new TSimpleServer(tArgs); server.serve(); } }
private static List<LogEntry> testProcessor(TProcessor processor) throws Exception { int invocationCount = testProcessor(processor, ImmutableList.of( address -> logThrift(address, MESSAGES, new TFramedTransport.Factory(), new TBinaryProtocol.Factory()), address -> logThriftAsync(address, MESSAGES), address -> logNiftyInvocationHandlerOptional(address, DRIFT_MESSAGES), address -> logNiftyInvocationHandler(address, DRIFT_MESSAGES, FRAMED, BINARY))); return newArrayList(concat(nCopies(invocationCount, MESSAGES))); }
@Test public void testOutOfOrderNotSupported() { TestingServerMethodInvoker methodInvoker = new TestingServerMethodInvoker(); int invocationCount = testServerMethodInvoker(methodInvoker, false, ImmutableList.of( address -> testOutOfOrderNotSupported(address, MESSAGES, new TTransportFactory(), new TBinaryProtocol.Factory(), methodInvoker.getFutureResults()), address -> testOutOfOrderNotSupported(address, MESSAGES, new TTransportFactory(), new TCompactProtocol.Factory(), methodInvoker.getFutureResults()), address -> testOutOfOrderNotSupported(address, MESSAGES, new TFramedTransport.Factory(), new TBinaryProtocol.Factory(), methodInvoker.getFutureResults()), address -> testOutOfOrderNotSupported(address, MESSAGES, new TFramedTransport.Factory(), new TCompactProtocol.Factory(), methodInvoker.getFutureResults()))); List<DriftLogEntry> expectedMessages = newArrayList(concat(nCopies(invocationCount, DRIFT_MESSAGES))); assertEquals(ImmutableList.copyOf(methodInvoker.getMessages()), expectedMessages); }
@Test public void testOutOfOrderNot() { TestingServerMethodInvoker methodInvoker = new TestingServerMethodInvoker(); int invocationCount = testServerMethodInvoker(methodInvoker, true, ImmutableList.of( address -> testOutOfOrder(address, MESSAGES, new TTransportFactory(), new TBinaryProtocol.Factory(), methodInvoker.getFutureResults()), address -> testOutOfOrder(address, MESSAGES, new TTransportFactory(), new TCompactProtocol.Factory(), methodInvoker.getFutureResults()), address -> testOutOfOrder(address, MESSAGES, new TFramedTransport.Factory(), new TBinaryProtocol.Factory(), methodInvoker.getFutureResults()), address -> testOutOfOrder(address, MESSAGES, new TFramedTransport.Factory(), new TCompactProtocol.Factory(), methodInvoker.getFutureResults()))); List<DriftLogEntry> expectedMessages = newArrayList(concat(nCopies(invocationCount, DRIFT_MESSAGES))); assertEquals(ImmutableList.copyOf(methodInvoker.getMessages()), expectedMessages); }