本文整理汇总了Java中org.apache.thrift.transport.TServerSocket类的典型用法代码示例。如果您正苦于以下问题:Java TServerSocket类的具体用法?Java TServerSocket怎么用?Java TServerSocket使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TServerSocket类属于org.apache.thrift.transport包,在下文中一共展示了TServerSocket类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: poolServer
import org.apache.thrift.transport.TServerSocket; //导入依赖的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: createServerTransport
import org.apache.thrift.transport.TServerSocket; //导入依赖的package包/类
private static TServerSocket createServerTransport(boolean secure)
throws TTransportException
{
if (!secure) {
return new TServerSocket(0);
}
try {
SSLContext serverSslContext = ClientTestUtils.getServerSslContext();
SSLServerSocket serverSocket = (SSLServerSocket) serverSslContext.getServerSocketFactory().createServerSocket(0);
return new TServerSocket(serverSocket);
}
catch (Exception e) {
throw new TTransportException("Error initializing secure socket", e);
}
}
示例3: getSSLServerTransport
import org.apache.thrift.transport.TServerSocket; //导入依赖的package包/类
private TServerTransport getSSLServerTransport() {
try {
TServerTransport transport;
TSSLTransportFactory.TSSLTransportParameters params =
new TSSLTransportFactory.TSSLTransportParameters();
params.setKeyStore(keystore, keystorePassword, getkeyManagerAlgorithm(), keystoreType);
transport = TSSLTransportFactory.getServerSocket(
port, 120000, InetAddress.getByName(bindAddress), params);
ServerSocket serverSock = ((TServerSocket) transport).getServerSocket();
if (serverSock instanceof SSLServerSocket) {
SSLServerSocket sslServerSock = (SSLServerSocket) serverSock;
List<String> enabledProtocols = new ArrayList<String>();
for (String protocol : sslServerSock.getEnabledProtocols()) {
if (!excludeProtocols.contains(protocol)) {
enabledProtocols.add(protocol);
}
}
sslServerSock.setEnabledProtocols(enabledProtocols.toArray(new String[0]));
}
return transport;
} catch (Throwable throwable) {
throw new FlumeException("Cannot start Thrift source.", throwable);
}
}
示例4: start
import org.apache.thrift.transport.TServerSocket; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@Override
public void start() {
try {
InetSocketAddress bindAddr = new InetSocketAddress(host, port);
serverTransport = new TServerSocket(bindAddr);
ThriftFlumeEventServer.Processor processor =
new ThriftFlumeEventServer.Processor(new ThriftFlumeEventServerImpl());
server = new TThreadPoolServer(
new TThreadPoolServer.Args(serverTransport).processor(processor));
} catch (TTransportException e) {
throw new FlumeException("Failed starting source", e);
}
ThriftHandler thriftHandler = new ThriftHandler(server);
thriftHandlerThread = new Thread(thriftHandler);
thriftHandlerThread.start();
super.start();
}
示例5: startSchedulerThriftService
import org.apache.thrift.transport.TServerSocket; //导入依赖的package包/类
/**
* @Title: startSchedulerThriftService
* @Description: 开启scheduler 同步、异步调用服务
* @return void 返回类型
*/
private static void startSchedulerThriftService() {
LOG.info("start scheduler thrift service....");
new Thread() {
@Override
public void run(){
try {
SchedulerServiceImpl schedulerServiceImpl = SpringUtil.getBean(SchedulerServiceImpl.class);
TProcessor tprocessor = new SchedulerService.Processor<SchedulerService.Iface>(schedulerServiceImpl);
TServerSocket serverTransport = new TServerSocket(PropertyLoader.THRIFT_SCHEDULER_PORT);
TThreadPoolServer.Args ttpsArgs = new TThreadPoolServer.Args(serverTransport);
ttpsArgs.processor(tprocessor);
ttpsArgs.protocolFactory(new TBinaryProtocol.Factory());
//线程池服务模型,使用标准的阻塞式IO,预先创建一组线程处理请求。
TServer server = new TThreadPoolServer(ttpsArgs);
server.serve();
} catch (Exception e) {
LOG.error("start scheduler thrift service error,msg:"+ExceptionUtil.getStackTraceAsString(e));
}
}
}.start();
LOG.info("start scheduler thrift server success!");
}
示例6: startServer
import org.apache.thrift.transport.TServerSocket; //导入依赖的package包/类
public void startServer() {
try {
logger.info("TSimpleServer start ....");
// TMultiplexedProcessor
TMultiplexedProcessor processor = new TMultiplexedProcessor();
processor.registerProcessor("Algorithm",
new AlgorithmService.Processor<>(new AlgorithmServiceImpl()));
TServerSocket serverTransport = new TServerSocket(SERVER_PORT);
TServer.Args args = new TServer.Args(serverTransport);
args.processor(processor);
args.protocolFactory(new TBinaryProtocol.Factory());
// args.protocolFactory(new TJSONProtocol.Factory());
TServer server = new TSimpleServer(args);
server.serve();
} catch (Exception e) {
logger.error("Server start error!!!");
e.printStackTrace();
}
}
示例7: createServerSocket
import org.apache.thrift.transport.TServerSocket; //导入依赖的package包/类
private TServerSocket createServerSocket(boolean useSSL, int port) throws IOException, TTransportException {
TServerSocket serverSocket = null;
// enable SSL support for HMS
List<String> sslVersionBlacklist = new ArrayList<>();
for (String sslVersion : hiveConf.getVar(ConfVars.HIVE_SSL_PROTOCOL_BLACKLIST).split(",")) {
sslVersionBlacklist.add(sslVersion);
}
if (!useSSL) {
serverSocket = HiveAuthUtils.getServerSocket(null, port);
} else {
String keyStorePath = hiveConf.getVar(ConfVars.HIVE_METASTORE_SSL_KEYSTORE_PATH).trim();
if (keyStorePath.isEmpty()) {
throw new IllegalArgumentException(
ConfVars.HIVE_METASTORE_SSL_KEYSTORE_PASSWORD.varname + " Not configured for SSL connection");
}
String keyStorePassword = ShimLoader.getHadoopShims().getPassword(hiveConf,
HiveConf.ConfVars.HIVE_METASTORE_SSL_KEYSTORE_PASSWORD.varname);
serverSocket = HiveAuthUtils.getServerSSLSocket(null, port, keyStorePath, keyStorePassword, sslVersionBlacklist);
}
return serverSocket;
}
示例8: startRPCServer
import org.apache.thrift.transport.TServerSocket; //导入依赖的package包/类
public static void startRPCServer(leafServer leafserver , String ip , int port) throws Exception
{
ServerSocket serverSocket = new ServerSocket(port,10000, InetAddress.getByName(ip));
TServerSocket serverTransport = new TServerSocket(serverSocket);
//设置协议工厂为TBinaryProtocolFactory
Factory proFactory = new TBinaryProtocol.Factory();
//关联处理器leafrpc的实现
TProcessor processor = new leafrpc.Processor<leafrpc.Iface>(new RPCService(leafserver));
TThreadPoolServer.Args args2 = new TThreadPoolServer.Args(serverTransport);
args2.processor(processor);
args2.protocolFactory(proFactory);
TServer server = new TThreadPoolServer(args2);
LOG.info("leaf RPCServer(type:TThreadPoolServer) start at ip:port : "+ ip +":" + port );
server.serve();
}
示例9: ServerThread
import org.apache.thrift.transport.TServerSocket; //导入依赖的package包/类
ServerThread() throws TTransportException {
TMultiplexedProcessor processor = new TMultiplexedProcessor();
for (String beanName : serviceMap.keySet()) {
IThriftServerService serverService = (IThriftServerService) serviceMap.getService(beanName);
String processorName = serverService.getName();
TProcessor tProcessor = serverService.getProcessor(serverService);
processor.registerProcessor(processorName, tProcessor);
logger.info("Register a processorName {} processorImpl {}", processorName, tProcessor);
}
logger.info("init default TServerTransport in addr {} port {}", applicationProperties.getAddr(), applicationProperties.getPort());
TServerTransport tServerTransport = new TServerSocket(new InetSocketAddress(applicationProperties.getAddr(),
applicationProperties.getPort()));
TThreadPoolServer.Args args = new TThreadPoolServer.Args(tServerTransport);
args.processor(processor);
args.protocolFactory(tProtocolFactory);
server = new TThreadPoolServer(args);
}
示例10: getTThreadPoolServer
import org.apache.thrift.transport.TServerSocket; //导入依赖的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);
}
示例11: start
import org.apache.thrift.transport.TServerSocket; //导入依赖的package包/类
/**
* Server initialization.
*
* @throws Exception error
*/
public void start() throws Exception {
log.info("initializing thrift server {}", getServerName());
final ThreadFactory threadFactory = new ThreadFactoryBuilder()
.setNameFormat(threadPoolNameFormat)
.setUncaughtExceptionHandler((t, e) -> log.error("Uncaught exception in thread: {}", t.getName(), e))
.build();
final ExecutorService executorService = new ThreadPoolExecutor(
Math.min(2, config.getThriftServerMaxWorkerThreads()),
config.getThriftServerMaxWorkerThreads(),
60L,
TimeUnit.SECONDS,
new SynchronousQueue<>(),
threadFactory
);
RegistryUtil.registerThreadPool(registry, threadPoolNameFormat, (ThreadPoolExecutor) executorService);
final int timeout = config.getThriftServerSocketClientTimeoutInSeconds() * 1000;
final TServerTransport serverTransport = new TServerSocket(portNumber, timeout);
startServing(executorService, serverTransport);
}
示例12: start
import org.apache.thrift.transport.TServerSocket; //导入依赖的package包/类
public void start() throws TTransportException, UnknownHostException {
InetAddress inetAddress = InetAddress.getByName(hostName);
TSSLTransportFactory.TSSLTransportParameters params =
new TSSLTransportFactory.TSSLTransportParameters();
params.setKeyStore(keyStore, keyStorePassword);
TServerSocket serverTransport;
serverTransport = TSSLTransportFactory.getServerSocket(port, clientTimeout, inetAddress, params);
AuthenticatorService.Processor<AuthenticatorServiceImpl> processor =
new AuthenticatorService.Processor<AuthenticatorServiceImpl>(
new AuthenticatorServiceImpl(thriftAuthenticatorService));
authenticationServer = new TThreadPoolServer(
new TThreadPoolServer.Args(serverTransport).processor(processor));
Thread thread = new Thread(new ServerRunnable(authenticationServer));
if (log.isDebugEnabled()) {
log.debug("Thrift Authentication Service started at ssl://" + hostName + ":" + port);
}
thread.start();
}
示例13: main
import org.apache.thrift.transport.TServerSocket; //导入依赖的package包/类
public static void main(String[] args) {
try {
userProfileServerHandler = new UserProfileServerHandler();
userProfileProcessor = new UserProfileService.Processor(userProfileServerHandler);
TMultiplexedProcessor airavataServerProcessor = new TMultiplexedProcessor();
airavataServerProcessor.registerProcessor("UserProfileService", userProfileProcessor);
TServerTransport serverTransport = new TServerSocket(9190);
TServer server = new TThreadPoolServer(new TThreadPoolServer.Args(serverTransport).processor(airavataServerProcessor));
System.out.println("Starting User Profile server...");
server.serve();
} catch (Exception x) {
x.printStackTrace();
}
}
示例14: initializeServer
import org.apache.thrift.transport.TServerSocket; //导入依赖的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;
}
示例15: initializeClusterManagerCallbackServer
import org.apache.thrift.transport.TServerSocket; //导入依赖的package包/类
private synchronized void initializeClusterManagerCallbackServer()
throws IOException {
// Create thrift RPC to serve ClusterManager
int soTimeout = fConf.getInt(
CORONA_TASK_TRACKER_SERVER_CLIENTTIMEOUT_KEY, 30 * 1000);
ServerSocket serverSocket = new ServerSocket();
serverSocket.setReuseAddress(true);
serverSocket.bind(new InetSocketAddress(0));
TServerSocket tSocket = new TServerSocket(serverSocket, soTimeout);
CoronaTaskTrackerService.Processor proc =
new CoronaTaskTrackerService.Processor(this);
TBinaryProtocol.Factory protocolFactory =
new TBinaryProtocol.Factory(true, true);
TThreadPoolServer.Args args = new TThreadPoolServer.Args(tSocket);
args.processor(proc);
args.protocolFactory(protocolFactory);
clusterManagerCallbackServer = new TThreadPoolServer(args);
clusterManagerCallbackServerThread =
new TServerThread(clusterManagerCallbackServer);
clusterManagerCallbackServerThread.start();
clusterManagerCallbackServerAddr = new InetAddress(
getLocalHostname(), serverSocket.getLocalPort());
LOG.info("SessionServer up at " + serverSocket.getLocalSocketAddress());
}