本文整理匯總了Java中org.apache.thrift.transport.TTransportFactory類的典型用法代碼示例。如果您正苦於以下問題:Java TTransportFactory類的具體用法?Java TTransportFactory怎麽用?Java TTransportFactory使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
TTransportFactory類屬於org.apache.thrift.transport包,在下文中一共展示了TTransportFactory類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: poolServer
import org.apache.thrift.transport.TTransportFactory; //導入依賴的package包/類
@Bean(name = "pool-server")
public TServer poolServer() throws Exception {
TServerTransport transport = new TServerSocket(this.port());
TThreadPoolServer.Args args = new TThreadPoolServer.Args(transport);
args.transportFactory(new TTransportFactory());
args.protocolFactory(new TBinaryProtocol.Factory());
args.processor(this.processor());
args.executorService(new ThreadPoolExecutor(env.getProperty(
"rpc.server.min.worker.threads", Integer.class, 512), env
.getProperty("rpc.server.max.worker.threads", Integer.class,
65535), env.getProperty(
"rpc.server.thread.keep.alive.time", Long.class, 600l),
TimeUnit.SECONDS, new SynchronousQueue<Runnable>()));
return new TThreadPoolServer(args);
}
示例2: ApacheThriftMethodInvoker
import org.apache.thrift.transport.TTransportFactory; //導入依賴的package包/類
public ApacheThriftMethodInvoker(
ListeningExecutorService executorService,
ListeningScheduledExecutorService delayService,
TTransportFactory transportFactory,
TProtocolFactory protocolFactory,
Duration connectTimeout,
Duration requestTimeout,
Optional<HostAndPort> socksProxy,
Optional<SSLContext> sslContext)
{
this.executorService = requireNonNull(executorService, "executorService is null");
this.delayService = requireNonNull(delayService, "delayService is null");
this.transportFactory = requireNonNull(transportFactory, "transportFactory is null");
this.protocolFactory = requireNonNull(protocolFactory, "protocolFactory is null");
this.connectTimeoutMillis = Ints.saturatedCast(requireNonNull(connectTimeout, "connectTimeout is null").toMillis());
this.requestTimeoutMillis = Ints.saturatedCast(requireNonNull(requestTimeout, "requestTimeout is null").toMillis());
this.socksProxy = requireNonNull(socksProxy, "socksProxy is null");
this.sslContext = requireNonNull(sslContext, "sslContext is null");
}
示例3: getSASLTransportFactory
import org.apache.thrift.transport.TTransportFactory; //導入依賴的package包/類
private TTransportFactory getSASLTransportFactory() {
String[] names;
try {
names = FlumeAuthenticationUtil.splitKerberosName(principal);
} catch (IOException e) {
throw new FlumeException(
"Error while trying to resolve Principal name - " + principal, e);
}
Map<String, String> saslProperties = new HashMap<String, String>();
saslProperties.put(Sasl.QOP, "auth");
TSaslServerTransport.Factory saslTransportFactory =
new TSaslServerTransport.Factory();
saslTransportFactory.addServerDefinition(
"GSSAPI", names[0], names[1], saslProperties,
FlumeAuthenticationUtil.getSaslGssCallbackHandler());
return saslTransportFactory;
}
示例4: getTThreadPoolServer
import org.apache.thrift.transport.TTransportFactory; //導入依賴的package包/類
private static TServer getTThreadPoolServer(TProtocolFactory protocolFactory,
TProcessor processor,
TTransportFactory transportFactory,
int workerThreads,
InetSocketAddress inetSocketAddress,
int backlog,
int clientTimeout)
throws TTransportException {
TServerTransport serverTransport = new TServerSocket(
new TServerSocket.ServerSocketTransportArgs().
bindAddr(inetSocketAddress).backlog(backlog).
clientTimeout(clientTimeout));
log.info("starting HBase ThreadPool Thrift server on " + inetSocketAddress.toString());
TThreadPoolServer.Args serverArgs = new TThreadPoolServer.Args(serverTransport);
serverArgs.processor(processor);
serverArgs.transportFactory(transportFactory);
serverArgs.protocolFactory(protocolFactory);
if (workerThreads > 0) {
serverArgs.maxWorkerThreads(workerThreads);
}
return new TThreadPoolServer(serverArgs);
}
示例5: start
import org.apache.thrift.transport.TTransportFactory; //導入依賴的package包/類
public void start(CountDownLatch latch, int port) {
try {
TNonblockingServerSocket serverTransport = new TNonblockingServerSocket(port);
//異步IO,需要使用TFramedTransport,它將分塊緩存讀取。
TTransportFactory transportFactory = new TFramedTransport.Factory();
//使用高密度二進製協議
TProtocolFactory proFactory = new TBinaryProtocol.Factory();
//發布多個服務
TMultiplexedProcessor processor = new TMultiplexedProcessor();
processor.registerProcessor(ClassNameUtils.getClassName(Hello.class), new Hello.Processor<>(new HelloServer()));
TServer server = new TThreadedSelectorServer(new
TThreadedSelectorServer.Args(serverTransport)
.transportFactory(transportFactory)
.protocolFactory(proFactory)
.processor(processor)
);
System.out.println("Starting the hello server...");
latch.countDown();
server.serve();
} catch (Exception e) {
e.printStackTrace();
}
}
示例6: initializeServer
import org.apache.thrift.transport.TTransportFactory; //導入依賴的package包/類
/**
* Start the SessionDriver callback server
* @param conf the corona configuration for this session
* @return the server socket of the callback server
* @throws IOException
*/
private ServerSocket initializeServer(CoronaConf conf) throws IOException {
// Choose any free port.
ServerSocket sessionServerSocket =
new ServerSocket(0, 0, getLocalAddress());
TServerSocket tServerSocket = new TServerSocket(sessionServerSocket,
conf.getCMSoTimeout());
TFactoryBasedThreadPoolServer.Args args =
new TFactoryBasedThreadPoolServer.Args(tServerSocket);
args.processor(new SessionDriverServiceProcessor(incoming));
args.transportFactory(new TTransportFactory());
args.protocolFactory(new TBinaryProtocol.Factory(true, true));
args.stopTimeoutVal = 0;
server = new TFactoryBasedThreadPoolServer(
args, new TFactoryBasedThreadPoolServer.DaemonThreadFactory());
return sessionServerSocket;
}
示例7: HadoopThriftServer
import org.apache.thrift.transport.TTransportFactory; //導入依賴的package包/類
/**
* Constrcts a server object
*/
public HadoopThriftServer(String [] args) {
if (args.length > 0) {
serverPort = new Integer(args[0]);
}
try {
ServerSocket ssock = createServerSocket(serverPort);
TServerTransport serverTransport = new TServerSocket(ssock);
Iface handler = new HadoopThriftHandler("hdfs-thrift-dhruba");
ThriftHadoopFileSystem.Processor processor = new ThriftHadoopFileSystem.Processor(handler);
TThreadPoolServer.Args serverArgs = new TThreadPoolServer.Args(serverTransport);
serverArgs.minWorkerThreads = 10;
serverArgs.processor(processor);
serverArgs.transportFactory(new TTransportFactory());
serverArgs.protocolFactory(new TBinaryProtocol.Factory());
server = new TThreadPoolServer(serverArgs);
System.out.println("Starting the hadoop thrift server on port [" + serverPort + "]...");
HadoopThriftHandler.LOG.info("Starting the hadoop thrift server on port [" +serverPort + "]...");
System.out.flush();
} catch (Exception x) {
x.printStackTrace();
}
}
示例8: ThriftServerThread
import org.apache.thrift.transport.TTransportFactory; //導入依賴的package包/類
public ThriftServerThread(InetAddress listenAddr,
int listenPort,
int listenBacklog,
TProcessor processor,
TTransportFactory transportFactory)
{
// now we start listening for clients
logger.info(String.format("Binding thrift service to %s:%s", listenAddr, listenPort));
TServerFactory.Args args = new TServerFactory.Args();
args.tProtocolFactory = new TBinaryProtocol.Factory(true, true);
args.addr = new InetSocketAddress(listenAddr, listenPort);
args.listenBacklog = listenBacklog;
args.processor = processor;
args.keepAlive = DatabaseDescriptor.getRpcKeepAlive();
args.sendBufferSize = DatabaseDescriptor.getRpcSendBufferSize();
args.recvBufferSize = DatabaseDescriptor.getRpcRecvBufferSize();
args.inTransportFactory = transportFactory;
args.outTransportFactory = transportFactory;
serverEngine = new TServerCustomFactory(DatabaseDescriptor.getRpcServerType()).buildTServer(args);
}
示例9: ThriftServerThread
import org.apache.thrift.transport.TTransportFactory; //導入依賴的package包/類
public ThriftServerThread(InetAddress listenAddr,
int listenPort,
CassandraServer server,
TProcessor processor,
TTransportFactory transportFactory)
{
// now we start listening for clients
logger.info(String.format("Binding thrift service to %s:%s", listenAddr, listenPort));
TServerFactory.Args args = new TServerFactory.Args();
args.tProtocolFactory = new TBinaryProtocol.Factory(true, true);
args.addr = new InetSocketAddress(listenAddr, listenPort);
args.cassandraServer = server;
args.processor = processor;
args.keepAlive = DatabaseDescriptor.getRpcKeepAlive();
args.sendBufferSize = DatabaseDescriptor.getRpcSendBufferSize();
args.recvBufferSize = DatabaseDescriptor.getRpcRecvBufferSize();
args.inTransportFactory = transportFactory;
args.outTransportFactory = transportFactory;
serverEngine = new TServerCustomFactory(DatabaseDescriptor.getRpcServerType()).buildTServer(args);
}
示例10: validateAndSetTransportFactory
import org.apache.thrift.transport.TTransportFactory; //導入依賴的package包/類
private TTransportFactory validateAndSetTransportFactory(String transportFactory)
{
try
{
Class factory = Class.forName(transportFactory);
if(!TTransportFactory.class.isAssignableFrom(factory))
throw new IllegalArgumentException(String.format("transport factory '%s' " +
"not derived from TTransportFactory", transportFactory));
return (TTransportFactory) factory.newInstance();
}
catch (Exception e)
{
throw new IllegalArgumentException(String.format("Cannot create a transport factory '%s'.", transportFactory), e);
}
}
示例11: getServer
import org.apache.thrift.transport.TTransportFactory; //導入依賴的package包/類
@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);
}
示例12: getTHsHaServer
import org.apache.thrift.transport.TTransportFactory; //導入依賴的package包/類
private static TServer getTHsHaServer(TProtocolFactory protocolFactory,
TProcessor processor, TTransportFactory transportFactory,
int workerThreads, int maxCallQueueSize,
InetSocketAddress inetSocketAddress, ThriftMetrics metrics)
throws TTransportException {
TNonblockingServerTransport serverTransport = new TNonblockingServerSocket(inetSocketAddress);
log.info("starting HBase HsHA Thrift server on " + inetSocketAddress.toString());
THsHaServer.Args serverArgs = new THsHaServer.Args(serverTransport);
if (workerThreads > 0) {
// Could support the min & max threads, avoiding to preserve existing functionality.
serverArgs.minWorkerThreads(workerThreads).maxWorkerThreads(workerThreads);
}
ExecutorService executorService = createExecutor(
workerThreads, maxCallQueueSize, metrics);
serverArgs.executorService(executorService);
serverArgs.processor(processor);
serverArgs.transportFactory(transportFactory);
serverArgs.protocolFactory(protocolFactory);
return new THsHaServer(serverArgs);
}
示例13: getTThreadedSelectorServer
import org.apache.thrift.transport.TTransportFactory; //導入依賴的package包/類
private static TServer getTThreadedSelectorServer(TProtocolFactory protocolFactory,
TProcessor processor, TTransportFactory transportFactory,
int workerThreads, int selectorThreads, int maxCallQueueSize,
InetSocketAddress inetSocketAddress, ThriftMetrics metrics)
throws TTransportException {
TNonblockingServerTransport serverTransport = new TNonblockingServerSocket(inetSocketAddress);
log.info("starting HBase ThreadedSelector Thrift server on " + inetSocketAddress.toString());
TThreadedSelectorServer.Args serverArgs = new TThreadedSelectorServer.Args(serverTransport);
if (workerThreads > 0) {
serverArgs.workerThreads(workerThreads);
}
if (selectorThreads > 0) {
serverArgs.selectorThreads(selectorThreads);
}
ExecutorService executorService = createExecutor(
workerThreads, maxCallQueueSize, metrics);
serverArgs.executorService(executorService);
serverArgs.processor(processor);
serverArgs.transportFactory(transportFactory);
serverArgs.protocolFactory(protocolFactory);
return new TThreadedSelectorServer(serverArgs);
}
示例14: getServer
import org.apache.thrift.transport.TTransportFactory; //導入依賴的package包/類
private TServer getServer(int workerThreads, int selectorThreads, int maxCallQueueSize,
int readTimeout, int backlog, boolean nonblocking, boolean hsha, boolean selector,
ThriftMetrics metrics, TProtocolFactory protocolFactory, TProcessor processor,
TTransportFactory transportFactory, InetSocketAddress inetSocketAddress)
throws TTransportException {
TServer server;
if (nonblocking) {
server = getTNonBlockingServer(protocolFactory, processor, transportFactory,
inetSocketAddress);
} else if (hsha) {
server = getTHsHaServer(protocolFactory, processor, transportFactory, workerThreads,
maxCallQueueSize, inetSocketAddress, metrics);
} else if (selector) {
server = getTThreadedSelectorServer(protocolFactory, processor, transportFactory,
workerThreads, selectorThreads, maxCallQueueSize, inetSocketAddress, metrics);
} else {
server = getTThreadPoolServer(protocolFactory, processor, transportFactory, workerThreads,
inetSocketAddress, backlog, readTimeout, metrics);
}
return server;
}
示例15: createThreadedSelectorServer
import org.apache.thrift.transport.TTransportFactory; //導入依賴的package包/類
public static TServer createThreadedSelectorServer(TProcessorFactory processorFactory,
int port, int clientTimeoutMillisecs, int maxFrameSize, long maxReadBufferSize)
throws TTransportException {
int numThreads = Math.max(2, Runtime.getRuntime().availableProcessors());
int selectorThreads = Math.max(2, Runtime.getRuntime().availableProcessors() / 2);
TNonblockingServerTransport transport = new TNonblockingServerSocket(port,
clientTimeoutMillisecs);
TProtocolFactory protocolFactory = new TBinaryProtocol.Factory();
TTransportFactory transportFactory = new TFramedTransport.Factory(maxFrameSize);
TThreadedSelectorServer.Args args = new TThreadedSelectorServer.Args(transport)
.processorFactory(processorFactory).protocolFactory(protocolFactory)
.transportFactory(transportFactory).workerThreads(numThreads)
.acceptPolicy(AcceptPolicy.FAIR_ACCEPT).acceptQueueSizePerThread(10000)
.selectorThreads(selectorThreads);
args.maxReadBufferBytes = maxReadBufferSize;
TThreadedSelectorServer server = new TThreadedSelectorServer(args);
return server;
}