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


Java DatabaseDescriptor.getNativeTransportPort方法代码示例

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


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

示例1: getPort

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的package包/类
/**
 * Override how to get the port to connect to the Cassandra cluster
 * When deployed, the port is read by properties
 * For the tests we need to read the port dynamically to discover on which random port Cassandra-unit has started the
 * embedded cluster
 * @param properties
 * @return
 */
@Override
protected int getPort(CassandraProperties properties) {
    int port = properties.getPort();
    if (port == 0) {
        // random port for the tests
        int randomPort = DatabaseDescriptor.getNativeTransportPort();
        log.info("Starting the cassandra cluster connection to a random port for the tests: {}", randomPort);
        return randomPort;
    } else {
        return port;
    }
}
 
开发者ID:xm-online,项目名称:xm-ms-timeline,代码行数:21,代码来源:CassandraTestConfiguration.java

示例2: getClient

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的package包/类
public CassandraClient getClient() {
    return new CassandraClient(DatabaseDescriptor.getListenAddress().getCanonicalHostName(),
            DatabaseDescriptor.getNativeTransportPort());
}
 
开发者ID:intropro,项目名称:prairie,代码行数:5,代码来源:CassandraUnit.java

示例3: 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


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