本文整理汇总了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;
}
}
示例2: getClient
import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的package包/类
public CassandraClient getClient() {
return new CassandraClient(DatabaseDescriptor.getListenAddress().getCanonicalHostName(),
DatabaseDescriptor.getNativeTransportPort());
}
示例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;
}