当前位置: 首页>>代码示例>>Java>>正文


Java DatabaseDescriptor.getClientEncryptionOptions方法代码示例

本文整理汇总了Java中org.apache.cassandra.config.DatabaseDescriptor.getClientEncryptionOptions方法的典型用法代码示例。如果您正苦于以下问题:Java DatabaseDescriptor.getClientEncryptionOptions方法的具体用法?Java DatabaseDescriptor.getClientEncryptionOptions怎么用?Java DatabaseDescriptor.getClientEncryptionOptions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.cassandra.config.DatabaseDescriptor的用法示例。


在下文中一共展示了DatabaseDescriptor.getClientEncryptionOptions方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildTServer

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的package包/类
public TServer buildTServer(Args args)
{
    if (DatabaseDescriptor.getClientEncryptionOptions().enabled)
        throw new RuntimeException("Client SSL is not supported for non-blocking sockets. Please remove client ssl from the configuration.");

    final InetSocketAddress addr = args.addr;
    TNonblockingServerTransport serverTransport;
    try
    {
        serverTransport = new TCustomNonblockingServerSocket(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);
    }

    // This is single threaded hence the invocation will be all
    // in one thread.
    TNonblockingServer.Args serverArgs = new TNonblockingServer.Args(serverTransport).inputTransportFactory(args.inTransportFactory)
                                                                                     .outputTransportFactory(args.outTransportFactory)
                                                                                     .inputProtocolFactory(args.tProtocolFactory)
                                                                                     .outputProtocolFactory(args.tProtocolFactory)
                                                                                     .processor(args.processor);
    return new CustomTNonBlockingServer(serverArgs);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:26,代码来源:CustomTNonBlockingServer.java

示例2: buildTServer

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的package包/类
@SuppressWarnings("resource")
public TServer buildTServer(Args args)
{
    if (DatabaseDescriptor.getClientEncryptionOptions().enabled)
        throw new RuntimeException("Client SSL is not supported for non-blocking sockets. Please remove client ssl from the configuration.");

    final InetSocketAddress addr = args.addr;
    TNonblockingServerTransport serverTransport;
    try
    {
        serverTransport = new TCustomNonblockingServerSocket(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);
    }

    // This is single threaded hence the invocation will be all
    // in one thread.
    TNonblockingServer.Args serverArgs = new TNonblockingServer.Args(serverTransport).inputTransportFactory(args.inTransportFactory)
                                                                                     .outputTransportFactory(args.outTransportFactory)
                                                                                     .inputProtocolFactory(args.tProtocolFactory)
                                                                                     .outputProtocolFactory(args.tProtocolFactory)
                                                                                     .processor(args.processor);
    return new CustomTNonBlockingServer(serverArgs);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:27,代码来源:CustomTNonBlockingServer.java

示例3: testSSLOnly

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的package包/类
@Test
public void testSSLOnly()
{
    // default ssl settings: client encryption enabled and default native transport port used for ssl only
    DatabaseDescriptor.getClientEncryptionOptions().enabled = true;
    DatabaseDescriptor.getClientEncryptionOptions().optional = false;

    withService((NativeTransportService service) ->
                {
                    service.initialize();
                    assertEquals(1, service.getServers().size());
                    Server server = service.getServers().iterator().next();
                    assertTrue(server.useSSL);
                    assertEquals(server.socket.getPort(), DatabaseDescriptor.getNativeTransportPort());
                }, false, 1);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:17,代码来源:NativeTransportServiceTest.java

示例4: testSSLOptional

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的package包/类
@Test
public void testSSLOptional()
{
    // default ssl settings: client encryption enabled and default native transport port used for optional ssl
    DatabaseDescriptor.getClientEncryptionOptions().enabled = true;
    DatabaseDescriptor.getClientEncryptionOptions().optional = true;

    withService((NativeTransportService service) ->
                {
                    service.initialize();
                    assertEquals(1, service.getServers().size());
                    Server server = service.getServers().iterator().next();
                    assertTrue(server.useSSL);
                    assertEquals(server.socket.getPort(), DatabaseDescriptor.getNativeTransportPort());
                }, false, 1);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:17,代码来源:NativeTransportServiceTest.java

示例5: testSSLWithNonSSL

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的package包/类
@Test
public void testSSLWithNonSSL()
{
    // ssl+non-ssl settings: client encryption enabled and additional ssl port specified
    DatabaseDescriptor.getClientEncryptionOptions().enabled = true;
    DatabaseDescriptor.setNativeTransportPortSSL(8432);

    withService((NativeTransportService service) ->
                {
                    service.initialize();
                    assertEquals(2, service.getServers().size());
                    assertEquals(
                                Sets.newHashSet(Arrays.asList(
                                                             Pair.create(true, DatabaseDescriptor.getNativeTransportPortSSL()),
                                                             Pair.create(false, DatabaseDescriptor.getNativeTransportPort())
                                                )
                                ),
                                service.getServers().stream().map((Server s) ->
                                                                  Pair.create(s.useSSL, s.socket.getPort())).collect(Collectors.toSet())
                    );
                }, false, 1);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:23,代码来源:NativeTransportServiceTest.java

示例6: buildTServer

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的package包/类
public TServer buildTServer(Args args)
{
    if (DatabaseDescriptor.getClientEncryptionOptions().enabled)
        throw new RuntimeException("Client SSL is not supported for non-blocking sockets (hsha). Please remove client ssl from the configuration.");

    final InetSocketAddress addr = args.addr;
    TNonblockingServerTransport serverTransport;
    try
    {
        serverTransport = new TCustomNonblockingServerSocket(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);
    }

    ThreadPoolExecutor invoker = new JMXEnabledThreadPoolExecutor(DatabaseDescriptor.getRpcMinThreads(),
                                                                  DatabaseDescriptor.getRpcMaxThreads(),
                                                                  60L,
                                                                  TimeUnit.SECONDS,
                                                                  new SynchronousQueue<Runnable>(),
                                                                  new NamedThreadFactory("RPC-Thread"), "RPC-THREAD-POOL");

    com.thinkaurelius.thrift.util.TBinaryProtocol.Factory protocolFactory = new com.thinkaurelius.thrift.util.TBinaryProtocol.Factory(true, true);

    TDisruptorServer.Args serverArgs = new TDisruptorServer.Args(serverTransport).useHeapBasedAllocation(true)
                                                                                 .inputTransportFactory(args.inTransportFactory)
                                                                                 .outputTransportFactory(args.outTransportFactory)
                                                                                 .inputProtocolFactory(protocolFactory)
                                                                                 .outputProtocolFactory(protocolFactory)
                                                                                 .processor(args.processor)
                                                                                 .maxFrameSizeInBytes(DatabaseDescriptor.getThriftFramedTransportSize())
                                                                                 .invocationExecutor(invoker)
                                                                                 .alwaysReallocateBuffers(true);

    return new THsHaDisruptorServer(serverArgs);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:38,代码来源:THsHaDisruptorServer.java

示例7: run

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的package包/类
private void run()
{
    // Check that a SaslAuthenticator can be provided by the configured
    // IAuthenticator. If not, don't start the server.
    IAuthenticator authenticator = DatabaseDescriptor.getAuthenticator();
    if (authenticator.requireAuthentication() && !(authenticator instanceof ISaslAwareAuthenticator))
    {
        logger.error("Not starting native transport as the configured IAuthenticator is not capable of SASL authentication");
        isRunning.compareAndSet(true, false);
        return;
    }

    // Configure the server.
    executionHandler = new ExecutionHandler(new RequestThreadPoolExecutor());
    factory = new NioServerSocketChannelFactory(Executors.newCachedThreadPool(), Executors.newCachedThreadPool());
    ServerBootstrap bootstrap = new ServerBootstrap(factory);

    bootstrap.setOption("child.tcpNoDelay", true);

    // Set up the event pipeline factory.
    final EncryptionOptions.ClientEncryptionOptions clientEnc = DatabaseDescriptor.getClientEncryptionOptions();
    if (clientEnc.enabled)
    {
        logger.info("Enabling encrypted CQL connections between client and server");
        bootstrap.setPipelineFactory(new SecurePipelineFactory(this, clientEnc));
    }
    else
    {
        bootstrap.setPipelineFactory(new PipelineFactory(this));
    }

    // Bind and start to accept incoming connections.
    logger.info("Starting listening for CQL clients on {}...", socket);
    Channel channel = bootstrap.bind(socket);
    connectionTracker.allChannels.add(channel);
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:37,代码来源:Server.java

示例8: buildTServer

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的package包/类
public TServer buildTServer(Args args)
{
    if (DatabaseDescriptor.getClientEncryptionOptions().enabled)
        throw new RuntimeException("Client SSL is not supported for non-blocking sockets (hsha). Please remove client ssl from the configuration.");

    final InetSocketAddress addr = args.addr;
    TNonblockingServerTransport serverTransport;
    try
    {
        serverTransport = new TCustomNonblockingServerSocket(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);
    }

    com.thinkaurelius.thrift.util.TBinaryProtocol.Factory protocolFactory = new com.thinkaurelius.thrift.util.TBinaryProtocol.Factory(true, true);

    TDisruptorServer.Args serverArgs = new TDisruptorServer.Args(serverTransport).inputTransportFactory(args.inTransportFactory)
                                                                                 .outputTransportFactory(args.outTransportFactory)
                                                                                 .inputProtocolFactory(protocolFactory)
                                                                                 .outputProtocolFactory(protocolFactory)
                                                                                 .processor(args.processor)
                                                                                 .maxFrameSizeInBytes(DatabaseDescriptor.getThriftFramedTransportSize());

    return new THsHaDisruptorServer(serverArgs);
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:28,代码来源:THsHaDisruptorServer.java

示例9: buildTServer

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的package包/类
@SuppressWarnings("resource")
public TServer buildTServer(Args args)
{
    if (DatabaseDescriptor.getClientEncryptionOptions().enabled)
        throw new RuntimeException("Client SSL is not supported for non-blocking sockets (hsha). Please remove client ssl from the configuration.");

    final InetSocketAddress addr = args.addr;
    TNonblockingServerTransport serverTransport;
    try
    {
        serverTransport = new TCustomNonblockingServerSocket(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);
    }

    ThreadPoolExecutor invoker = new JMXEnabledThreadPoolExecutor(DatabaseDescriptor.getRpcMinThreads(),
                                                                  DatabaseDescriptor.getRpcMaxThreads(),
                                                                  60L,
                                                                  TimeUnit.SECONDS,
                                                                  new SynchronousQueue<Runnable>(),
                                                                  new NamedThreadFactory("RPC-Thread"), "RPC-THREAD-POOL");

    com.thinkaurelius.thrift.util.TBinaryProtocol.Factory protocolFactory = new com.thinkaurelius.thrift.util.TBinaryProtocol.Factory(true, true);

    TDisruptorServer.Args serverArgs = new TDisruptorServer.Args(serverTransport).useHeapBasedAllocation(true)
                                                                                 .inputTransportFactory(args.inTransportFactory)
                                                                                 .outputTransportFactory(args.outTransportFactory)
                                                                                 .inputProtocolFactory(protocolFactory)
                                                                                 .outputProtocolFactory(protocolFactory)
                                                                                 .processor(args.processor)
                                                                                 .maxFrameSizeInBytes(DatabaseDescriptor.getThriftFramedTransportSize())
                                                                                 .invocationExecutor(invoker)
                                                                                 .alwaysReallocateBuffers(true);

    return new THsHaDisruptorServer(serverArgs);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:39,代码来源:THsHaDisruptorServer.java

示例10: run

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的package包/类
private void run()
{
    // Check that a SaslAuthenticator can be provided by the configured
    // IAuthenticator. If not, don't start the server.
    IAuthenticator authenticator = DatabaseDescriptor.getAuthenticator();
    if (authenticator.requireAuthentication() && !(authenticator instanceof ISaslAwareAuthenticator))
    {
        logger.error("Not starting native transport as the configured IAuthenticator is not capable of SASL authentication");
        isRunning.compareAndSet(true, false);
        return;
    }

    // Configure the server.
    eventExecutorGroup = new RequestThreadPoolExecutor();


    boolean hasEpoll = enableEpoll ? Epoll.isAvailable() : false;
    if (hasEpoll)
    {
        workerGroup = new EpollEventLoopGroup();
        logger.info("Netty using native Epoll event loop");
    }
    else
    {
        workerGroup = new NioEventLoopGroup();
        logger.info("Netty using Java NIO event loop");
    }

    ServerBootstrap bootstrap = new ServerBootstrap()
                                .group(workerGroup)
                                .channel(hasEpoll ? EpollServerSocketChannel.class : NioServerSocketChannel.class)
                                .childOption(ChannelOption.TCP_NODELAY, true)
                                .childOption(ChannelOption.SO_LINGER, 0)
                                .childOption(ChannelOption.SO_KEEPALIVE, DatabaseDescriptor.getRpcKeepAlive())
                                .childOption(ChannelOption.ALLOCATOR, CBUtil.allocator)
                                .childOption(ChannelOption.WRITE_BUFFER_HIGH_WATER_MARK, 32 * 1024)
                                .childOption(ChannelOption.WRITE_BUFFER_LOW_WATER_MARK, 8 * 1024);

    final EncryptionOptions.ClientEncryptionOptions clientEnc = DatabaseDescriptor.getClientEncryptionOptions();
    if (clientEnc.enabled)
    {
        logger.info("Enabling encrypted CQL connections between client and server");
        bootstrap.childHandler(new SecureInitializer(this, clientEnc));
    }
    else
    {
        bootstrap.childHandler(new Initializer(this));
    }

    // Bind and start to accept incoming connections.
    logger.info("Using Netty Version: {}", Version.identify().entrySet());
    logger.info("Starting listening for CQL clients on {}...", socket);

    ChannelFuture bindFuture = bootstrap.bind(socket);
    if (!bindFuture.awaitUninterruptibly().isSuccess())
        throw new IllegalStateException(String.format("Failed to bind port %d on %s.", socket.getPort(), socket.getAddress().getHostAddress()));

    connectionTracker.allChannels.add(bindFuture.channel());
    isRunning.set(true);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:61,代码来源:Server.java

示例11: buildTServer

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的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

示例12: buildTServer

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的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

示例13: initialize

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的package包/类
/**
 * Creates netty thread pools and event loops.
 */
@VisibleForTesting
synchronized void initialize()
{
    if (initialized)
        return;

    // prepare netty resources
    eventExecutorGroup = new RequestThreadPoolExecutor();

    if (useEpoll())
    {
        workerGroup = new EpollEventLoopGroup();
        logger.info("Netty using native Epoll event loop");
    }
    else
    {
        workerGroup = new NioEventLoopGroup();
        logger.info("Netty using Java NIO event loop");
    }

    int nativePort = DatabaseDescriptor.getNativeTransportPort();
    int nativePortSSL = DatabaseDescriptor.getNativeTransportPortSSL();
    InetAddress nativeAddr = DatabaseDescriptor.getRpcAddress();

    org.apache.cassandra.transport.Server.Builder builder = new org.apache.cassandra.transport.Server.Builder()
                                                            .withEventExecutor(eventExecutorGroup)
                                                            .withEventLoopGroup(workerGroup)
                                                            .withHost(nativeAddr);

    if (!DatabaseDescriptor.getClientEncryptionOptions().enabled)
    {
        servers = Collections.singleton(builder.withSSL(false).withPort(nativePort).build());
    }
    else
    {
        if (nativePort != nativePortSSL)
        {
            // user asked for dedicated ssl port for supporting both non-ssl and ssl connections
            servers = Collections.unmodifiableList(
                                                  Arrays.asList(
                                                               builder.withSSL(false).withPort(nativePort).build(),
                                                               builder.withSSL(true).withPort(nativePortSSL).build()
                                                  )
            );
        }
        else
        {
            // ssl only mode using configured native port
            servers = Collections.singleton(builder.withSSL(true).withPort(nativePort).build());
        }
    }

    // register metrics
    ClientMetrics.instance.addCounter("connectedNativeClients", () ->
    {
        int ret = 0;
        for (Server server : servers)
            ret += server.getConnectedClients();
        return ret;
    });

    initialized = true;
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:67,代码来源:NativeTransportService.java

示例14: start

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的package包/类
public synchronized void start()
{
    if(isRunning()) 
        return;

    // Configure the server.
    ServerBootstrap bootstrap = new ServerBootstrap()
                                .channel(useEpoll ? EpollServerSocketChannel.class : NioServerSocketChannel.class)
                                .childOption(ChannelOption.TCP_NODELAY, true)
                                .childOption(ChannelOption.SO_LINGER, 0)
                                .childOption(ChannelOption.SO_KEEPALIVE, DatabaseDescriptor.getRpcKeepAlive())
                                .childOption(ChannelOption.ALLOCATOR, CBUtil.allocator)
                                .childOption(ChannelOption.WRITE_BUFFER_HIGH_WATER_MARK, 32 * 1024)
                                .childOption(ChannelOption.WRITE_BUFFER_LOW_WATER_MARK, 8 * 1024);
    if (workerGroup != null)
        bootstrap = bootstrap.group(workerGroup);

    final EncryptionOptions.ClientEncryptionOptions clientEnc = DatabaseDescriptor.getClientEncryptionOptions();
    if (this.useSSL)
    {
        if (clientEnc.optional)
        {
            logger.info("Enabling optionally encrypted CQL connections between client and server");
            bootstrap.childHandler(new OptionalSecureInitializer(this, clientEnc));
        }
        else
        {
            logger.info("Enabling encrypted CQL connections between client and server");
            bootstrap.childHandler(new SecureInitializer(this, clientEnc));
        }
    }
    else
    {
        bootstrap.childHandler(new Initializer(this));
    }

    // Bind and start to accept incoming connections.
    logger.info("Using Netty Version: {}", Version.identify().entrySet());
    logger.info("Starting listening for CQL clients on {} ({})...", socket, this.useSSL ? "encrypted" : "unencrypted");

    ChannelFuture bindFuture = bootstrap.bind(socket);
    if (!bindFuture.awaitUninterruptibly().isSuccess())
        throw new IllegalStateException(String.format("Failed to bind port %d on %s.", socket.getPort(), socket.getAddress().getHostAddress()));

    connectionTracker.allChannels.add(bindFuture.channel());
    isRunning.set(true);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:48,代码来源:Server.java

示例15: buildTServer

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的package包/类
@SuppressWarnings("resource")
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, new String[0]);
            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();
            String[] suites = SSLFactory.filterCipherSuites(sslServerSocket.getSupportedCipherSuites(), clientEnc.cipher_suites);
            sslServerSocket.setEnabledCipherSuites(suites);
            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:scylladb,项目名称:scylla-tools-java,代码行数:52,代码来源:CustomTThreadPoolServer.java


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