protected TProtocolFactory getProtocolFactory() { TProtocolFactory protocolFactory; if (conf.getBoolean(COMPACT_CONF_KEY, COMPACT_CONF_DEFAULT)) { LOG.debug("Using compact protocol"); protocolFactory = new TCompactProtocol.Factory(); } else { LOG.debug("Using binary protocol"); protocolFactory = new TBinaryProtocol.Factory(); } return protocolFactory; }
private TProtocolFactory getProtocolFactory() { if (protocol.equals(BINARY_PROTOCOL)) { logger.info("Using TBinaryProtocol"); return new TBinaryProtocol.Factory(); } else { logger.info("Using TCompactProtocol"); return new TCompactProtocol.Factory(); } }
messageProtocolFactory = ((Class<? extends TProtocolFactory>) Class.forName(factoryClassName)).newInstance(); } else messageProtocolFactory = new TBinaryProtocol.Factory();
.getTimeVar(HiveConf.ConfVars.HIVE_SERVER2_THRIFT_LOGIN_BEBACKOFF_SLOT_LENGTH, TimeUnit.MILLISECONDS); TThreadPoolServer.Args sargs = new TThreadPoolServer.Args(serverSocket).processorFactory(processorFactory) .transportFactory(transportFactory).protocolFactory(new TBinaryProtocol.Factory()) .inputProtocolFactory(new TBinaryProtocol.Factory(true, true, maxMessageSize, maxMessageSize)) .requestTimeout(requestTimeout).requestTimeoutUnit(TimeUnit.SECONDS).beBackoffSlotLength(beBackoffSlotLength) .beBackoffSlotLengthUnit(TimeUnit.MILLISECONDS).executorService(executorService);
TProtocolFactory protocolFactory = new TBinaryProtocol.Factory(); TServlet thriftHttpServlet = createTServlet(protocolFactory);
protocol = new TSimpleJSONProtocol.Factory(); } else if (mType.equals("binary")) { protocol = new TBinaryProtocol.Factory(); } else { throw new RuntimeException("Undefined message encoding type: " + mType);
TProtocolFactory transportProtocolFactory = null; if (protocol != null && protocol == ThriftRpcClient.BINARY_PROTOCOL) { transportProtocolFactory = new TBinaryProtocol.Factory(); } else { transportProtocolFactory = new TCompactProtocol.Factory();
lists.add(t1); lists.add(t2); TSerializer binarySerializer = new TSerializer(new TBinaryProtocol.Factory()); _tempFile = getSampleDataPath(); FileWriter writer = new FileWriter(_tempFile);
public void run() { try { Scribe.Processor processor = new Scribe.Processor(new Receiver()); TNonblockingServerTransport transport = new TNonblockingServerSocket(port); THsHaServer.Args args = new THsHaServer.Args(transport); args.minWorkerThreads(workers); args.maxWorkerThreads(workers); args.processor(processor); args.transportFactory(new TFramedTransport.Factory(maxReadBufferBytes)); args.protocolFactory(new TBinaryProtocol.Factory(false, false)); args.maxReadBufferBytes = maxReadBufferBytes; server = new THsHaServer(args); LOG.info("Starting Scribe Source on port " + port); server.serve(); } catch (Exception e) { LOG.warn("Scribe failed", e); } }
public ThriftTestingSource(String handlerName, int port, String protocol) throws Exception { TNonblockingServerTransport serverTransport = new TNonblockingServerSocket(new InetSocketAddress("0.0.0.0", port)); ThriftSourceProtocol.Iface handler = getHandler(handlerName); TProtocolFactory transportProtocolFactory = null; if (protocol != null && protocol == ThriftRpcClient.BINARY_PROTOCOL) { transportProtocolFactory = new TBinaryProtocol.Factory(); } else { transportProtocolFactory = new TCompactProtocol.Factory(); } server = new THsHaServer(new THsHaServer.Args(serverTransport).processor( new ThriftSourceProtocol.Processor(handler)).protocolFactory( transportProtocolFactory)); Executors.newSingleThreadExecutor().submit(new Runnable() { @Override public void run() { server.serve(); } }); }
@Override public TServer getServer(TProcessor processor) throws IOException, TTransportException { int port = type.getPort(storm_conf); TTransportFactory serverTransportFactory = getServerTransportFactory(); TServerSocket serverTransport = new TServerSocket(port); int numWorkerThreads = type.getNumThreads(storm_conf); Integer queueSize = type.getQueueSize(storm_conf); TThreadPoolServer.Args server_args = new TThreadPoolServer.Args(serverTransport).processor(new TUGIWrapProcessor(processor)).minWorkerThreads(numWorkerThreads) .maxWorkerThreads(numWorkerThreads).protocolFactory(new TBinaryProtocol.Factory(false, true)); if (serverTransportFactory != null) { server_args.transportFactory(serverTransportFactory); } BlockingQueue workQueue = new SynchronousQueue(); if (queueSize != null) { workQueue = new ArrayBlockingQueue(queueSize); } ThreadPoolExecutor executorService = new ExtendedThreadPoolExecutor(numWorkerThreads, numWorkerThreads, 60, TimeUnit.SECONDS, workQueue); server_args.executorService(executorService); return new TThreadPoolServer(server_args); }
public ThriftMessageParser(SecorConfig config) throws InstantiationException, IllegalAccessException, ClassNotFoundException { super(config); TProtocolFactory protocolFactory = null; String protocolName = mConfig.getThriftProtocolClass(); if (StringUtils.isNotEmpty(protocolName)) { String factoryClassName = protocolName.concat("$Factory"); protocolFactory = ((Class<? extends TProtocolFactory>) Class.forName(factoryClassName)).newInstance(); } else protocolFactory = new TBinaryProtocol.Factory(); mDeserializer = new TDeserializer(protocolFactory); mThriftPath = new ThriftPath(mConfig.getMessageTimestampName(),(short) mConfig.getMessageTimestampId()); mTimestampType = mConfig.getMessageTimestampType(); }
private Message buildMessage(long timestamp, int timestampTwo, long timestampThree) throws Exception { UnitTestMessage thriftMessage = new UnitTestMessage(timestamp, "notimportant", timestampTwo, timestampThree); TSerializer serializer = new TSerializer(new TBinaryProtocol.Factory()); byte[] data = serializer.serialize(thriftMessage); return new Message("test", 0, 0, null, data, timestamp); }
private THsHaServer initHandlerServer(Map conf, final Drpc service) throws Exception { int port = JStormUtils.parseInt(conf.get(Config.DRPC_PORT)); int workerThreadNum = JStormUtils.parseInt(conf.get(Config.DRPC_WORKER_THREADS)); int queueSize = JStormUtils.parseInt(conf.get(Config.DRPC_QUEUE_SIZE)); LOG.info("Begin to init DRPC handler server at port: " + port); TNonblockingServerSocket socket = new TNonblockingServerSocket(port); THsHaServer.Args targs = new THsHaServer.Args(socket); targs.workerThreads(64); targs.protocolFactory(new TBinaryProtocol.Factory()); targs.processor(new DistributedRPC.Processor<DistributedRPC.Iface>(service)); ThreadPoolExecutor executor = new ThreadPoolExecutor( workerThreadNum, workerThreadNum, 60, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(queueSize)); targs.executorService(executor); THsHaServer handlerServer = new THsHaServer(targs); LOG.info("Successfully inited DRPC handler server at port: " + port); return handlerServer; }
@Override @SuppressWarnings("unchecked") public ProxyClient build(SocketAddress address) { Service<ThriftClientRequest, byte[]> client = ClientBuilder.safeBuildFactory( clientBuilder .hosts((InetSocketAddress) address) .reportTo(clientStats.getFinagleStatsReceiver(address)) ).toService(); DistributedLogService.ServiceIface service = new DistributedLogService.ServiceToClient(client, new TBinaryProtocol.Factory()); return new ProxyClient(address, client, service); }
@Override public TServer getServer(TProcessor processor) throws IOException, TTransportException { int port = type.getPort(storm_conf); TNonblockingServerSocket serverTransport = new TNonblockingServerSocket(port); int numWorkerThreads = type.getNumThreads(storm_conf); int maxBufferSize = type.getMaxBufferSize(storm_conf); Integer queueSize = type.getQueueSize(storm_conf); THsHaServer.Args server_args = new THsHaServer.Args(serverTransport).processor(new SimpleWrapProcessor(processor)).workerThreads(numWorkerThreads) .protocolFactory(new TBinaryProtocol.Factory(false, true, maxBufferSize, -1)); if (queueSize != null) { server_args.executorService(new ThreadPoolExecutor(numWorkerThreads, numWorkerThreads, 60, TimeUnit.SECONDS, new ArrayBlockingQueue(queueSize))); } // construct THsHaServer return new THsHaServer(server_args); }
@Override public TSerializer initialValue() { return new TSerializer(new TBinaryProtocol.Factory()); } };
@SuppressWarnings("rawtypes") private void initThrift(Map conf) throws TTransportException { Integer thrift_port = JStormUtils.parseInt(conf.get(Config.NIMBUS_THRIFT_PORT)); TNonblockingServerSocket socket = new TNonblockingServerSocket(thrift_port); Integer maxReadBufSize = JStormUtils.parseInt(conf.get(Config.NIMBUS_THRIFT_MAX_BUFFER_SIZE)); THsHaServer.Args args = new THsHaServer.Args(socket); args.workerThreads(ServiceHandler.THREAD_NUM); args.protocolFactory(new TBinaryProtocol.Factory(false, true, maxReadBufSize, -1)); args.processor(new Nimbus.Processor<Iface>(serviceHandler)); args.maxReadBufferBytes = maxReadBufSize; thriftServer = new THsHaServer(args); LOG.info("Successfully started nimbus: started Thrift server..."); thriftServer.serve(); }
private THsHaServer initInvokeServer(Map conf, final Drpc service) throws Exception { int port = JStormUtils.parseInt(conf.get(Config.DRPC_INVOCATIONS_PORT)); LOG.info("Begin to init DRPC invoke server at port: " + port); TNonblockingServerSocket socket = new TNonblockingServerSocket(port); THsHaServer.Args targsInvoke = new THsHaServer.Args(socket); targsInvoke.workerThreads(64); targsInvoke.protocolFactory(new TBinaryProtocol.Factory()); targsInvoke.processor(new DistributedRPCInvocations.Processor<DistributedRPCInvocations.Iface>(service)); THsHaServer invokeServer = new THsHaServer(targsInvoke); LOG.info("Successfully inited DRPC invoke server at port: " + port); return invokeServer; }
@Override protected TDeserializer initialValue() { return new TDeserializer(new TBinaryProtocol.Factory()); } };