當前位置: 首頁>>代碼示例>>Java>>正文


Java TServerSocket類代碼示例

本文整理匯總了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);
}
 
開發者ID:jigsaw-projects,項目名稱:jigsaw-payment,代碼行數:19,代碼來源:HelloServerConfig.java

示例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);
    }
}
 
開發者ID:airlift,項目名稱:drift,代碼行數:17,代碼來源:TestClientsWithApacheServer.java

示例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);
  }
}
 
開發者ID:moueimei,項目名稱:flume-release-1.7.0,代碼行數:27,代碼來源:ThriftSource.java

示例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();
}
 
開發者ID:moueimei,項目名稱:flume-release-1.7.0,代碼行數:19,代碼來源:ThriftLegacySource.java

示例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!");
}
 
開發者ID:elves-project,項目名稱:scheduler,代碼行數:28,代碼來源:ProgramEntrance.java

示例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();
	}
}
 
開發者ID:kaichao,項目名稱:algorithm.annotation,代碼行數:22,代碼來源:SimpleBackendServer.java

示例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;
}
 
開發者ID:HotelsDotCom,項目名稱:waggle-dance,代碼行數:22,代碼來源:MetaStoreProxyServer.java

示例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();
}
 
開發者ID:weizhenyi,項目名稱:leaf-snowflake,代碼行數:18,代碼來源:rpcServer.java

示例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);
}
 
開發者ID:somewhereMrli,項目名稱:albedo-thrift,代碼行數:19,代碼來源:ThriftServer.java

示例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);
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:23,代碼來源:ThriftServer.java

示例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);
}
 
開發者ID:Netflix,項目名稱:metacat,代碼行數:25,代碼來源:AbstractThriftServer.java

示例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();
}
 
開發者ID:wso2,項目名稱:carbon-identity-framework,代碼行數:24,代碼來源:TCPThriftAuthenticationService.java

示例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();
    }
}
 
開發者ID:SciGaP,項目名稱:allocateme,代碼行數:21,代碼來源:UserProfileServer.java

示例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;
}
 
開發者ID:rhli,項目名稱:hadoop-EAR,代碼行數:24,代碼來源:SessionDriver.java

示例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());
}
 
開發者ID:rhli,項目名稱:hadoop-EAR,代碼行數:25,代碼來源:CoronaTaskTracker.java


注:本文中的org.apache.thrift.transport.TServerSocket類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。