本文整理汇总了Java中org.apache.thrift.server.THsHaServer.Args方法的典型用法代码示例。如果您正苦于以下问题:Java THsHaServer.Args方法的具体用法?Java THsHaServer.Args怎么用?Java THsHaServer.Args使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.thrift.server.THsHaServer
的用法示例。
在下文中一共展示了THsHaServer.Args方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: nonBlockMode
import org.apache.thrift.server.THsHaServer; //导入方法依赖的package包/类
private void nonBlockMode() {
AskerHandler handler = new AskerHandler();
Asker.Processor processor = new Asker.Processor(handler);
try {
TNonblockingServerTransport transport = new TNonblockingServerSocket(port);
THsHaServer.Args arg = new THsHaServer.Args(transport);
arg.protocolFactory(new TCompactProtocol.Factory());
// arg.transportFactory(new TFramedTransport.Factory());
// arg.processorFactory(new TProcessorFactory(processor));
arg.processor(processor);
server = new THsHaServer(arg);
start.countDown();
System.out.println("Starting the nonBlock server...");
server.serve();
} catch (Exception e) {
e.printStackTrace();
}
}
示例2: run
import org.apache.thrift.server.THsHaServer; //导入方法依赖的package包/类
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.workerThreads(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);
}
}
示例3: hshaServer
import org.apache.thrift.server.THsHaServer; //导入方法依赖的package包/类
/**
* The function to create a thrift Half-Sync and Half-Async Server.
* @param processor
*/
public static void hshaServer(PacketStreamer.Processor<PacketStreamerHandler> processor) {
try {
TNonblockingServerTransport serverTransport = new TNonblockingServerSocket(port);
THsHaServer.Args args = new THsHaServer.Args(serverTransport);
args.processor(processor);
args.transportFactory(new TFramedTransport.Factory());
args.protocolFactory(new TBinaryProtocol.Factory(true, true));
TServer server = new THsHaServer(args);
log.info("Starting the packetstreamer hsha server on port {} ...", port);
server.serve();
} catch (Exception e) {
e.printStackTrace();
}
}
示例4: hshaServer
import org.apache.thrift.server.THsHaServer; //导入方法依赖的package包/类
/**
* The function to create a thrift Half-Sync and Half-Async Server.
* @param processor
*/
public static void hshaServer(PacketStreamer.Processor<PacketStreamerHandler> processor) {
try {
TNonblockingServerTransport serverTransport = new TNonblockingServerSocket(port);
THsHaServer.Args args = new THsHaServer.Args(serverTransport);
args.processor(processor);
args.transportFactory(new TFramedTransport.Factory());
args.protocolFactory(new TBinaryProtocol.Factory(true, true));
TServer server = new THsHaServer(args);
log.info("Starting the packetstreamer hsha server on port {} ...", port);
server.serve();
} catch (Exception e) {
e.printStackTrace();
}
}
示例5: startHshaServer
import org.apache.thrift.server.THsHaServer; //导入方法依赖的package包/类
@VisibleForTesting
public static TServer startHshaServer(TProcessor processor, int portNumber) throws Exception {
final TNonblockingServerSocket socket = new TNonblockingServerSocket(portNumber);
final THsHaServer.Args serverArgs = new THsHaServer.Args(socket);
serverArgs.processor(processor);
serverArgs.inputProtocolFactory(new TCompactProtocol.Factory());
serverArgs.outputProtocolFactory(new TCompactProtocol.Factory());
final TServer server = new THsHaServer(serverArgs);
final Thread t = new Thread(new Runnable() {
@Override
public void run() {
server.serve();
}
});
t.start();
return server;
}
示例6: initHandlerServer
import org.apache.thrift.server.THsHaServer; //导入方法依赖的package包/类
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));
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(queueSize));
targs.executorService(executor);
THsHaServer handlerServer = new THsHaServer(targs);
LOG.info("Successfully init Handler Server " + port);
return handlerServer;
}
示例7: initThrift
import org.apache.thrift.server.THsHaServer; //导入方法依赖的package包/类
@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();
}
示例8: getServer
import org.apache.thrift.server.THsHaServer; //导入方法依赖的package包/类
@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);
}
示例9: getTHsHaServer
import org.apache.thrift.server.THsHaServer; //导入方法依赖的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);
}
示例10: start
import org.apache.thrift.server.THsHaServer; //导入方法依赖的package包/类
public void start() throws Exception {
transport = new TNonblockingServerSocket(port);
processor = new SuroServer.Processor(this);
THsHaServer.Args serverArgs = new THsHaServer.Args(transport);
serverArgs.processor(processor);
serverArgs.workerThreads(2);
server = new THsHaServer(serverArgs);
System.out.println("Server started on port:" + port);
Thread t = new Thread() {
@Override
public void run() {
server.serve();
}
};
t.start();
Field serverSocketField = TNonblockingServerSocket.class.getDeclaredField("serverSocket_");
serverSocketField.setAccessible(true);
ServerSocket serverSocket = (ServerSocket) serverSocketField.get(transport);
port = serverSocket.getLocalPort();
}
示例11: startTHsHaServer
import org.apache.thrift.server.THsHaServer; //导入方法依赖的package包/类
/**
* 启动thrift的server端的服务
*/
public void startTHsHaServer() {
try {
TNonblockingServerSocket tnbSocketTransport = new TNonblockingServerSocket(
SERVER_PORT);
THsHaServer.Args thhsArgs = new THsHaServer.Args(tnbSocketTransport);
// 设置处理逻辑
thhsArgs.processor(tprocessor);
// 传输方式
thhsArgs.transportFactory(new TFramedTransport.Factory());
// 数据协议
thhsArgs.protocolFactory(new TCompactProtocol.Factory());
// 半同步半异步的服务模型
server = new THsHaServer(thhsArgs);
server.serve();
} catch (Exception e) {
System.out.println("Server start error!!!");
e.printStackTrace();
}
}
开发者ID:suhuanzheng7784877,项目名称:ParallelExecute,代码行数:28,代码来源:DistributedParalleExecuteTHsHaServer.java
示例12: initHandlerServer
import org.apache.thrift.server.THsHaServer; //导入方法依赖的package包/类
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;
}
示例13: initInvokeServer
import org.apache.thrift.server.THsHaServer; //导入方法依赖的package包/类
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;
}
示例14: apply
import org.apache.thrift.server.THsHaServer; //导入方法依赖的package包/类
@Override
public TServer apply(ServerSetup setup) throws TTransportException {
TNonblockingServerSocket socket = setup.getSocketTimeout() == null
? new TNonblockingServerSocket(new InetSocketAddress("0.0.0.0", setup.getPort()))
: new TNonblockingServerSocket(new InetSocketAddress("0.0.0.0", setup.getPort()),
setup.getSocketTimeout().as(Time.MILLISECONDS));
setup.setSocket(getServerSocketFor(socket));
THsHaServer.Args options = new THsHaServer.Args(socket);
options.processor(setup.getProcessor());
if (setup.getNumThreads() > 0) {
options.workerThreads(setup.getNumThreads());
}
// default queue size to num threads: max response time becomes double avg service time
final BlockingQueue<Runnable> queue =
new ArrayBlockingQueue<Runnable>(setup.getQueueSize() > 0 ? setup.getQueueSize()
: options.getWorkerThreads());
final ThreadPoolExecutor invoker = new ThreadPoolExecutor(options.getWorkerThreads(),
options.getWorkerThreads(), options.getStopTimeoutVal(), options.getStopTimeoutUnit(), queue);
final String serverName = (setup.getName() != null ? setup.getName() : "no-name");
return new THsHaServer(options);
}
示例15: getTHsHaServer
import org.apache.thrift.server.THsHaServer; //导入方法依赖的package包/类
private static TServer getTHsHaServer(TProtocolFactory protocolFactory,
TProcessor processor, TTransportFactory transportFactory,
int workerThreads,
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, metrics);
serverArgs.executorService(executorService);
serverArgs.processor(processor);
serverArgs.transportFactory(transportFactory);
serverArgs.protocolFactory(protocolFactory);
return new THsHaServer(serverArgs);
}