• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java TSSLTransportFactory类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.thrift.transport.TSSLTransportFactory的典型用法代码示例。如果您正苦于以下问题:Java TSSLTransportFactory类的具体用法?Java TSSLTransportFactory怎么用?Java TSSLTransportFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



TSSLTransportFactory类属于org.apache.thrift.transport包,在下文中一共展示了TSSLTransportFactory类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getSSLServerTransport

import org.apache.thrift.transport.TSSLTransportFactory; //导入依赖的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


示例2: start

import org.apache.thrift.transport.TSSLTransportFactory; //导入依赖的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


示例3: getServer

import org.apache.thrift.transport.TSSLTransportFactory; //导入依赖的package包/类
@Override
protected TServer getServer(TProcessor processor) throws TTransportException {
    LOGGER.debug("Setting Secured Server on port {} and keystore", remotePort, keystoreFile);

    TSSLTransportFactory.TSSLTransportParameters params = new TSSLTransportFactory.TSSLTransportParameters();
    params.setKeyStore(keystoreFile, keystorePass);

    TServerSocket serverTransport;
    try {
        serverTransport = TSSLTransportFactory.getServerSocket(remotePort, 1000, InetAddress.getByName("localhost"), params);
    } catch (UnknownHostException e) {
        throw new TTransportException(e);
    }

    return new TThreadPoolServer(new TThreadPoolServer.Args(serverTransport).processor(processor));
}
 
开发者ID:sergypv,项目名称:spring-thrift-service-manager,代码行数:17,代码来源:SecuredThreadPoolWrapper.java


示例4: createAiravataSecureClient

import org.apache.thrift.transport.TSSLTransportFactory; //导入依赖的package包/类
/**
 * This method returns a Airavata Client that talks to the API Server exposed over TLS.
 *
 * @param serverHost
 * @param serverPort
 * @param trustStorePath
 * @param trustStorePassword
 * @param clientTimeOut
 * @return
 * @throws AiravataClientConnectException
 */
public static Airavata.Client createAiravataSecureClient(String serverHost, int serverPort, String trustStorePath,
                                                         String trustStorePassword, int clientTimeOut)
        throws AiravataClientException {
    try {
        TSSLTransportFactory.TSSLTransportParameters params =
                new TSSLTransportFactory.TSSLTransportParameters();
        params.setTrustStore(trustStorePath, trustStorePassword);
        TSocket transport = TSSLTransportFactory.getClientSocket(serverHost, serverPort, clientTimeOut, params);
        TProtocol protocol = new TBinaryProtocol(transport);
        return new Airavata.Client(protocol);
    } catch (TTransportException e) {
        logger.error(e.getMessage(), e);
        AiravataClientException clientError = new AiravataClientException();
        clientError.setParameter("Unable to connect to the server at " + serverHost + ":" + serverPort);
        throw clientError;
    }
}
 
开发者ID:apache,项目名称:airavata,代码行数:29,代码来源:AiravataClientFactory.java


示例5: secure

import org.apache.thrift.transport.TSSLTransportFactory; //导入依赖的package包/类
private void secure(Asker.Processor processor) {
    try {
   /*
   * Use TSSLTransportParameters to setup the required SSL parameters. In this example
   * we are setting the keystore and the keystore password. Other things like algorithms,
   * cipher suites, client auth etc can be set.
   */
        TSSLTransportFactory.TSSLTransportParameters params = new TSSLTransportFactory.TSSLTransportParameters();
        // The Keystore contains the private key
        params.setKeyStore(keyStore, keyPass, null, null);

  /*
   * Use any of the TSSLTransportFactory to get a server transport with the appropriate
   * SSL configuration. You can use the default settings if properties are set in the command line.
   * Ex: -Djavax.net.ssl.keyStore=.keystore and -Djavax.net.ssl.keyStorePassword=thrift
   *
   * Note: You need not explicitly call open(). The underlying server socket is bound on return
   * from the factory class.
   */
        TServerTransport serverTransport = TSSLTransportFactory.getServerSocket(port, 0, null, params);
        TServer server = new TSimpleServer(new Args(serverTransport).processor(processor));

        // Use this for a multi threaded server
        // TServer server = new TThreadPoolServer(new TThreadPoolServer.Args(serverTransport).processor(processor));

        System.out.println("Starting the secure server...");
        server.serve();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:altiplanogao,项目名称:rpc-comparison,代码行数:32,代码来源:SecureAskerServer.java


示例6: ThriftTestingSource

import org.apache.thrift.transport.TSSLTransportFactory; //导入依赖的package包/类
public ThriftTestingSource(String handlerName, int port,
                           String protocol, String keystore,
                           String keystorePassword, String keyManagerType,
                           String keystoreType) throws Exception {
  TSSLTransportFactory.TSSLTransportParameters params =
          new TSSLTransportFactory.TSSLTransportParameters();
  params.setKeyStore(keystore, keystorePassword, keyManagerType, keystoreType);

  TServerSocket serverTransport = TSSLTransportFactory.getServerSocket(
          port, 10000, InetAddress.getByName("0.0.0.0"), params);

  ThriftSourceProtocol.Iface handler = getHandler(handlerName);

  Class serverClass = Class.forName("org.apache.thrift" +
          ".server.TThreadPoolServer");
  Class argsClass = Class.forName("org.apache.thrift.server" +
          ".TThreadPoolServer$Args");
  TServer.AbstractServerArgs args = (TServer.AbstractServerArgs) argsClass
          .getConstructor(TServerTransport.class)
          .newInstance(serverTransport);
  Method m = argsClass.getDeclaredMethod("maxWorkerThreads", int.class);
  m.invoke(args, Integer.MAX_VALUE);
  TProtocolFactory transportProtocolFactory = null;
  if (protocol != null && protocol == ThriftRpcClient.BINARY_PROTOCOL) {
    transportProtocolFactory = new TBinaryProtocol.Factory();
  } else {
    transportProtocolFactory = new TCompactProtocol.Factory();
  }
  args.protocolFactory(transportProtocolFactory);
  args.inputTransportFactory(new TFastFramedTransport.Factory());
  args.outputTransportFactory(new TFastFramedTransport.Factory());
  args.processor(new ThriftSourceProtocol.Processor<ThriftSourceProtocol.Iface>(handler));
  server = (TServer) serverClass.getConstructor(argsClass).newInstance(args);
  Executors.newSingleThreadExecutor().submit(new Runnable() {
    @Override
    public void run() {
      server.serve();
    }
  });
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:41,代码来源:ThriftTestingSource.java


示例7: init

import org.apache.thrift.transport.TSSLTransportFactory; //导入依赖的package包/类
public synchronized void init() throws TTransportException {
	if (null != client) {
		return;
	}
	if (null == truststore) {
		transport = new TSocket(ip, port);
		transport.open();
	} else {
		/*
		 * Similar to the server, you can use the parameters to setup
		 * client parameters or use the default settings. On the client
		 * side, you will need a TrustStore which contains the trusted
		 * certificate along with the public key. For this example it's
		 * a self-signed cert.
		 */
		String truststore_arr[] = truststore.split("@");
		if (truststore_arr.length != 2) {
			throw new RuntimeException("client.truststore 格式错误(缺少 @密码):" + truststore);
		}
		TSSLTransportParameters params = new TSSLTransportParameters();
		if (truststore_arr[0].endsWith(".truststore")) {
			params.setTrustStore(truststore_arr[0], truststore_arr[1], "SunX509", "JKS");
		} else {
			params.setTrustStore(truststore_arr[0], truststore_arr[1], "X509", "BKS");
		}
		/*
		 * Get a client transport instead of a server transport. The
		 * connection is opened on invocation of the factory method, no
		 * need to specifically call open()
		 */
		transport = TSSLTransportFactory.getClientSocket(ip, port, RemoteSyncConfig.getTimeout(), params);
	}

	TProtocol protocol = new TBinaryProtocol(transport);
	client = new SyncFileServer.Client(protocol);
}
 
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:37,代码来源:ThriftClientPool.java


示例8: openTransport

import org.apache.thrift.transport.TSSLTransportFactory; //导入依赖的package包/类
@Override
public TTransport openTransport(String host, int port) throws Exception
{
    TSSLTransportFactory.TSSLTransportParameters params = new TSSLTransportFactory.TSSLTransportParameters(protocol, cipherSuites);
    params.setTrustStore(truststore, truststorePassword);
    if (null != keystore)
        params.setKeyStore(keystore, keystorePassword);
    TTransport trans = TSSLTransportFactory.getClientSocket(host, port, SOCKET_TIMEOUT, params);
    int frameSize = 15 * 1024 * 1024; // 15 MiB
    return new TFramedTransport(trans, frameSize);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:12,代码来源:SSLTransportFactory.java


示例9: getTransport

import org.apache.thrift.transport.TSSLTransportFactory; //导入依赖的package包/类
public TTransport getTransport(TTransport trans)
{
    final CliSessionState sessionState = CliMain.sessionState;
    try
    {
        TSSLTransportParameters params = new TSSLTransportParameters(sessionState.encOptions.protocol, sessionState.encOptions.cipher_suites);
        params.setTrustStore(sessionState.encOptions.truststore, sessionState.encOptions.truststore_password);
        trans = TSSLTransportFactory.getClientSocket(sessionState.hostName, sessionState.thriftPort, SOCKET_TIMEOUT, params);
        return new FramedTransportFactory().getTransport(trans);
    }
    catch (TTransportException e)
    {
        throw new RuntimeException("Failed to create a client SSL connection.", e);
    }
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:16,代码来源:SSLTransportFactory.java


示例10: secure

import org.apache.thrift.transport.TSSLTransportFactory; //导入依赖的package包/类
public static void secure(Calculator.Processor<CalculatorHandler> processor) throws Exception {
	/*
	 * Use TSSLTransportParameters to setup the required SSL parameters. In this
	 * example we are setting the keystore and the keystore password. Other things
	 * like algorithms, cipher suites, client auth etc can be set.
	 */
	TSSLTransportParameters params = new TSSLTransportParameters();
	// The Keystore contains the private key
	params.setKeyStore("../../lib/java/test/.keystore", "thrift", null, null);

	/*
	 * Use any of the TSSLTransportFactory to get a server transport with the
	 * appropriate SSL configuration. You can use the default settings if properties
	 * are set in the command line. Ex: -Djavax.net.ssl.keyStore=.keystore and
	 * -Djavax.net.ssl.keyStorePassword=thrift
	 * 
	 * Note: You need not explicitly call open(). The underlying server socket is
	 * bound on return from the factory class.
	 */
	TServerTransport serverTransport = TSSLTransportFactory.getServerSocket(9091, 0, null, params);
	TServer server = new TSimpleServer(new Args(serverTransport).processor(processor));

	// Use this for a multi threaded server
	// TServer server = new TThreadPoolServer(new
	// TThreadPoolServer.Args(serverTransport).processor(processor));

	System.out.println("Starting the secure server...");
	server.serve();
}
 
开发者ID:haogrgr,项目名称:haogrgr-projects,代码行数:30,代码来源:ServerMain.java


示例11: getTransportParams

import org.apache.thrift.transport.TSSLTransportFactory; //导入依赖的package包/类
public static TSSLTransportFactory.TSSLTransportParameters getTransportParams(final Properties configuration) {
    SslConfigurationHelper sslHelper = new SslConfigurationHelper(configuration);
    TSSLTransportFactory.TSSLTransportParameters params = new TSSLTransportFactory.TSSLTransportParameters(
            sslHelper.getSslProtocol(),
            sslHelper.getSslCiphers()
    );

    File ks = getCertificatesDirectoryFile(configuration, sslHelper.getKeystoreFile());
    String ksUrl = ks.getAbsolutePath();
    params.setKeyStore(
            ksUrl,
            sslHelper.getKeystorePass(),
            null,
            sslHelper.getKeystoreType()
    );

    File ts = getCertificatesDirectoryFile(configuration, sslHelper.getTruststoreFile());
    String tsUrl = ts.getAbsolutePath();
    params.setTrustStore(
            tsUrl,
            sslHelper.getTruststorePass(),
            null,
            sslHelper.getTruststoreType()
    );

    params.requireClientAuth(sslHelper.isPeerAuthRequired());

    return params;
}
 
开发者ID:ezbake,项目名称:ezbake-common-java,代码行数:30,代码来源:EzSSL.java


示例12: openTransport

import org.apache.thrift.transport.TSSLTransportFactory; //导入依赖的package包/类
@Override
@SuppressWarnings("resource")
public TTransport openTransport(String host, int port) throws Exception
{
    TSSLTransportFactory.TSSLTransportParameters params = new TSSLTransportFactory.TSSLTransportParameters(protocol, cipherSuites);
    params.setTrustStore(truststore, truststorePassword);
    if (null != keystore)
        params.setKeyStore(keystore, keystorePassword);
    TTransport trans = TSSLTransportFactory.getClientSocket(host, port, SOCKET_TIMEOUT, params);
    return new TFramedTransport(trans, DEFAULT_MAX_FRAME_SIZE);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:12,代码来源:SSLTransportFactory.java


示例13: getThriftClient

import org.apache.thrift.transport.TSSLTransportFactory; //导入依赖的package包/类
private EntitlementThriftClient.Client getThriftClient() throws Exception {

        TSSLTransportFactory.TSSLTransportParameters param = new TSSLTransportFactory.TSSLTransportParameters();
        param.setTrustStore(trustStore, trustStorePass);
        TTransport transport;
        transport = TSSLTransportFactory.getClientSocket(thriftHost, thriftPort, ProxyConstants.THRIFT_TIME_OUT, param);
        TProtocol protocol = new TBinaryProtocol(transport);
        return new EntitlementThriftClient.Client(protocol);
    }
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:10,代码来源:ThriftEntitlementServiceClient.java


示例14: openTransport

import org.apache.thrift.transport.TSSLTransportFactory; //导入依赖的package包/类
@Override
public TTransport openTransport(String host, int port) throws Exception
{
    TSSLTransportFactory.TSSLTransportParameters params = new TSSLTransportFactory.TSSLTransportParameters(protocol, cipherSuites);
    params.setTrustStore(truststore, truststorePassword);
    if (null != keystore)
        params.setKeyStore(keystore, keystorePassword);
    TTransport trans = TSSLTransportFactory.getClientSocket(host, port, SOCKET_TIMEOUT, params);
    return new FramedTransportFactory().getTransport(trans);
}
 
开发者ID:daidong,项目名称:GraphTrek,代码行数:11,代码来源:SSLTransportFactory.java


示例15: getClientProtocol

import org.apache.thrift.transport.TSSLTransportFactory; //导入依赖的package包/类
@Override
public TProtocol getClientProtocol(String serviceInterfaceClassName, String host, Integer port) throws TTransportException {
    if(truststoreFile == null || truststorePass == null){
        throw new IllegalStateException("truststore not defined. Initialize the Factory properly");
    }

    TSSLTransportFactory.TSSLTransportParameters paramsClient = new TSSLTransportFactory.TSSLTransportParameters();
    paramsClient.setTrustStore(truststoreFile, truststorePass);
    TTransport transport = TSSLTransportFactory.getClientSocket(host, port, 1000, paramsClient);
    TProtocol protocol = new TBinaryProtocol(transport);

    return new TMultiplexedProtocol(protocol, serviceInterfaceClassName);
}
 
开发者ID:sergypv,项目名称:spring-thrift-service-manager,代码行数:14,代码来源:SecuredThreadPoolWrapper.java


示例16: createTLSSocket

import org.apache.thrift.transport.TSSLTransportFactory; //导入依赖的package包/类
private TSocket createTLSSocket(String host) throws TTransportException {
    TSSLTransportParameters sslParams = new TSSLTransportParameters("SSL", m_dbtls_cipher_suites);
    if (!Utils.isEmpty(m_keystore)) {
        sslParams.setKeyStore(m_keystore, m_keystorepassword);
    }
    if (!Utils.isEmpty(m_truststore)) {
        sslParams.setTrustStore(m_truststore, m_truststorepassword);
    }
    return TSSLTransportFactory.getClientSocket(host, m_dbport, m_db_timeout_millis, sslParams);
}
 
开发者ID:QSFT,项目名称:Doradus,代码行数:11,代码来源:DBConn.java


示例17: secure

import org.apache.thrift.transport.TSSLTransportFactory; //导入依赖的package包/类
public static void secure(Calculator.Processor processor) {
  try {
    /*
     * Use TSSLTransportParameters to setup the required SSL parameters. In this example
     * we are setting the keystore and the keystore password. Other things like algorithms,
     * cipher suites, client auth etc can be set. 
     */
    TSSLTransportParameters params = new TSSLTransportParameters();
    // The Keystore contains the private key
    params.setKeyStore("../../lib/java/test/.keystore", "thrift", null, null);

    /*
     * Use any of the TSSLTransportFactory to get a server transport with the appropriate
     * SSL configuration. You can use the default settings if properties are set in the command line.
     * Ex: -Djavax.net.ssl.keyStore=.keystore and -Djavax.net.ssl.keyStorePassword=thrift
     * 
     * Note: You need not explicitly call open(). The underlying server socket is bound on return
     * from the factory class. 
     */
    TServerTransport serverTransport = TSSLTransportFactory.getServerSocket(9091, 0, null, params);
    TServer server = new TSimpleServer(new Args(serverTransport).processor(processor));

    // Use this for a multi threaded server
    // TServer server = new TThreadPoolServer(new TThreadPoolServer.Args(serverTransport).processor(processor));

    System.out.println("Starting the secure server...");
    server.serve();
  } catch (Exception e) {
    e.printStackTrace();
  }
}
 
开发者ID:YinYanfei,项目名称:CadalWorkspace,代码行数:32,代码来源:JavaServer.java


示例18: main

import org.apache.thrift.transport.TSSLTransportFactory; //导入依赖的package包/类
public static void main(String [] args) {

    if (args.length != 1) {
      System.out.println("Please enter 'simple' or 'secure'");
      System.exit(0);
    }

    try {
      TTransport transport;
      if (args[0].contains("simple")) {
        transport = new TSocket("localhost", 9090);
        transport.open();
      }
      else {
        /*
         * Similar to the server, you can use the parameters to setup client parameters or
         * use the default settings. On the client side, you will need a TrustStore which
         * contains the trusted certificate along with the public key. 
         * For this example it's a self-signed cert. 
         */
        TSSLTransportParameters params = new TSSLTransportParameters();
        params.setTrustStore("../../lib/java/test/.truststore", "thrift", "SunX509", "JKS");
        /*
         * Get a client transport instead of a server transport. The connection is opened on
         * invocation of the factory method, no need to specifically call open()
         */
        transport = TSSLTransportFactory.getClientSocket("localhost", 9091, 0, params);
      }

      TProtocol protocol = new  TBinaryProtocol(transport);
      Calculator.Client client = new Calculator.Client(protocol);

      perform(client);

      transport.close();
    } catch (TException x) {
      x.printStackTrace();
    } 
  }
 
开发者ID:YinYanfei,项目名称:CadalWorkspace,代码行数:40,代码来源:JavaClient.java


示例19: buildTServer

import org.apache.thrift.transport.TSSLTransportFactory; //导入依赖的package包/类
public TServer buildTServer(Args args)
{
    final InetSocketAddress addr = args.addr;
    TServerTransport serverTransport;
    try
    {
        final ClientEncryptionOptions clientEnc = DatabaseDescriptor.getClientEncryptionOptions();
        if (clientEnc.enabled)
        {
            logger.info("enabling encrypted thrift connections between client and server");
            TSSLTransportParameters params = new TSSLTransportParameters(clientEnc.protocol, clientEnc.cipher_suites);
            params.setKeyStore(clientEnc.keystore, clientEnc.keystore_password);
            if (clientEnc.require_client_auth)
            {
                params.setTrustStore(clientEnc.truststore, clientEnc.truststore_password);
                params.requireClientAuth(true);
            }
            TServerSocket sslServer = TSSLTransportFactory.getServerSocket(addr.getPort(), 0, addr.getAddress(), params);
            SSLServerSocket sslServerSocket = (SSLServerSocket) sslServer.getServerSocket();
            sslServerSocket.setEnabledProtocols(SSLFactory.ACCEPTED_PROTOCOLS);
            serverTransport = new TCustomServerSocket(sslServer.getServerSocket(), args.keepAlive, args.sendBufferSize, args.recvBufferSize);
        }
        else
        {
            serverTransport = new TCustomServerSocket(addr, args.keepAlive, args.sendBufferSize, args.recvBufferSize, args.listenBacklog);
        }
    }
    catch (TTransportException e)
    {
        throw new RuntimeException(String.format("Unable to create thrift socket to %s:%s", addr.getAddress(), addr.getPort()), e);
    }
    // ThreadPool Server and will be invocation per connection basis...
    TThreadPoolServer.Args serverArgs = new TThreadPoolServer.Args(serverTransport)
                                                             .minWorkerThreads(DatabaseDescriptor.getRpcMinThreads())
                                                             .maxWorkerThreads(DatabaseDescriptor.getRpcMaxThreads())
                                                             .inputTransportFactory(args.inTransportFactory)
                                                             .outputTransportFactory(args.outTransportFactory)
                                                             .inputProtocolFactory(args.tProtocolFactory)
                                                             .outputProtocolFactory(args.tProtocolFactory)
                                                             .processor(args.processor);
    ExecutorService executorService = new ThreadPoolExecutor(serverArgs.minWorkerThreads,
                                                             serverArgs.maxWorkerThreads,
                                                             60,
                                                             TimeUnit.SECONDS,
                                                             new SynchronousQueue<Runnable>(),
                                                             new NamedThreadFactory("Thrift"));
    return new CustomTThreadPoolServer(serverArgs, executorService);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:49,代码来源:CustomTThreadPoolServer.java


示例20: buildTServer

import org.apache.thrift.transport.TSSLTransportFactory; //导入依赖的package包/类
public TServer buildTServer(Args args)
{
    final InetSocketAddress addr = args.addr;
    TServerTransport serverTransport;
    try
    {
        final ClientEncryptionOptions clientEnc = DatabaseDescriptor.getClientEncryptionOptions();
        if (clientEnc.enabled)
        {
            logger.info("enabling encrypted thrift connections between client and server");
            TSSLTransportParameters params = new TSSLTransportParameters(clientEnc.protocol, clientEnc.cipher_suites);
            params.setKeyStore(clientEnc.keystore, clientEnc.keystore_password);
            if (clientEnc.require_client_auth)
            {
                params.setTrustStore(clientEnc.truststore, clientEnc.truststore_password);
                params.requireClientAuth(true);
            }
            TServerSocket sslServer = TSSLTransportFactory.getServerSocket(addr.getPort(), 0, addr.getAddress(), params);
            serverTransport = new TCustomServerSocket(sslServer.getServerSocket(), args.keepAlive, args.sendBufferSize, args.recvBufferSize);
        }
        else
        {
            serverTransport = new TCustomServerSocket(addr, args.keepAlive, args.sendBufferSize, args.recvBufferSize);
        }
    }
    catch (TTransportException e)
    {
        throw new RuntimeException(String.format("Unable to create thrift socket to %s:%s", addr.getAddress(), addr.getPort()), e);
    }
    // ThreadPool Server and will be invocation per connection basis...
    TThreadPoolServer.Args serverArgs = new TThreadPoolServer.Args(serverTransport)
                                                             .minWorkerThreads(DatabaseDescriptor.getRpcMinThreads())
                                                             .maxWorkerThreads(DatabaseDescriptor.getRpcMaxThreads())
                                                             .inputTransportFactory(args.inTransportFactory)
                                                             .outputTransportFactory(args.outTransportFactory)
                                                             .inputProtocolFactory(args.tProtocolFactory)
                                                             .outputProtocolFactory(args.tProtocolFactory)
                                                             .processor(args.processor);
    ExecutorService executorService = new ThreadPoolExecutor(serverArgs.minWorkerThreads,
                                                             serverArgs.maxWorkerThreads,
                                                             60,
                                                             TimeUnit.SECONDS,
                                                             new SynchronousQueue<Runnable>(),
                                                             new NamedThreadFactory("Thrift"));
    return new CustomTThreadPoolServer(serverArgs, executorService);
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:47,代码来源:CustomTThreadPoolServer.java



注:本文中的org.apache.thrift.transport.TSSLTransportFactory类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java RequestHandle类代码示例发布时间:2022-05-21
下一篇:
Java NativeFont类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap