本文整理汇总了Java中com.datastax.driver.core.PoolingOptions.setMaxConnectionsPerHost方法的典型用法代码示例。如果您正苦于以下问题:Java PoolingOptions.setMaxConnectionsPerHost方法的具体用法?Java PoolingOptions.setMaxConnectionsPerHost怎么用?Java PoolingOptions.setMaxConnectionsPerHost使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.datastax.driver.core.PoolingOptions
的用法示例。
在下文中一共展示了PoolingOptions.setMaxConnectionsPerHost方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getReadPoolingOptions
import com.datastax.driver.core.PoolingOptions; //导入方法依赖的package包/类
private static PoolingOptions getReadPoolingOptions(Configuration conf)
{
Optional<Integer> coreConnections = getInputCoreConnections(conf);
Optional<Integer> maxConnections = getInputMaxConnections(conf);
Optional<Integer> maxSimultaneousRequests = getInputMaxSimultReqPerConnections(conf);
Optional<Integer> minSimultaneousRequests = getInputMinSimultReqPerConnections(conf);
PoolingOptions poolingOptions = new PoolingOptions();
for (HostDistance hostDistance : Arrays.asList(HostDistance.LOCAL, HostDistance.REMOTE))
{
if (coreConnections.isPresent())
poolingOptions.setCoreConnectionsPerHost(hostDistance, coreConnections.get());
if (maxConnections.isPresent())
poolingOptions.setMaxConnectionsPerHost(hostDistance, maxConnections.get());
if (minSimultaneousRequests.isPresent())
poolingOptions.setMinSimultaneousRequestsPerConnectionThreshold(hostDistance, minSimultaneousRequests.get());
if (maxSimultaneousRequests.isPresent())
poolingOptions.setMaxSimultaneousRequestsPerConnectionThreshold(hostDistance, maxSimultaneousRequests.get());
}
return poolingOptions;
}
示例2: setup
import com.datastax.driver.core.PoolingOptions; //导入方法依赖的package包/类
private void setup()
throws IOException, KeyStoreException, NoSuchAlgorithmException, KeyManagementException,
CertificateException, UnrecoverableKeyException {
// Connect to Cassandra
PoolingOptions pOpts = new PoolingOptions();
pOpts.setCoreConnectionsPerHost(HostDistance.LOCAL, 4);
pOpts.setMaxConnectionsPerHost(HostDistance.LOCAL, 4);
Cluster.Builder clusterBuilder = Cluster.builder()
.addContactPoint(host)
.withPort(port)
.withPoolingOptions(pOpts)
.withLoadBalancingPolicy(new TokenAwarePolicy( DCAwareRoundRobinPolicy.builder().build()));
if (null != username)
clusterBuilder = clusterBuilder.withCredentials(username, password);
if (null != truststorePath)
clusterBuilder = clusterBuilder.withSSL(createSSLOptions());
cluster = clusterBuilder.build();
if (null == cluster) {
throw new IOException("Could not create cluster");
}
session = cluster.connect();
}
示例3: copyPoolingOptions
import com.datastax.driver.core.PoolingOptions; //导入方法依赖的package包/类
private void copyPoolingOptions(Builder builder) {
PoolingOptions opts = new PoolingOptions();
opts.setCoreConnectionsPerHost(HostDistance.REMOTE,
remoteCoreConnectionsPerHost);
opts.setCoreConnectionsPerHost(HostDistance.LOCAL,
localCoreConnectionsPerHost);
opts.setMaxConnectionsPerHost(HostDistance.REMOTE,
remoteMaxConnectionsPerHost);
opts.setMaxConnectionsPerHost(HostDistance.LOCAL,
localMaxConnectionsPerHost);
opts.setMaxSimultaneousRequestsPerConnectionThreshold(
HostDistance.REMOTE,
remoteMaxSimultaneousRequestsPerConnectionThreshold);
opts.setMaxSimultaneousRequestsPerConnectionThreshold(
HostDistance.LOCAL,
localMaxSimultaneousRequestsPerConnectionThreshold);
opts.setMinSimultaneousRequestsPerConnectionThreshold(
HostDistance.REMOTE,
remoteMinSimultaneousRequestsPerConnectionThreshold);
opts.setMinSimultaneousRequestsPerConnectionThreshold(
HostDistance.LOCAL,
localMinSimultaneousRequestsPerConnectionThreshold);
builder.withPoolingOptions(opts);
}
示例4: getReadPoolingOptions
import com.datastax.driver.core.PoolingOptions; //导入方法依赖的package包/类
private static PoolingOptions getReadPoolingOptions(Configuration conf)
{
Optional<Integer> coreConnections = getInputCoreConnections(conf);
Optional<Integer> maxConnections = getInputMaxConnections(conf);
Optional<Integer> maxSimultaneousRequests = getInputMaxSimultReqPerConnections(conf);
PoolingOptions poolingOptions = new PoolingOptions();
for (HostDistance hostDistance : Arrays.asList(HostDistance.LOCAL, HostDistance.REMOTE))
{
if (coreConnections.isPresent())
poolingOptions.setCoreConnectionsPerHost(hostDistance, coreConnections.get());
if (maxConnections.isPresent())
poolingOptions.setMaxConnectionsPerHost(hostDistance, maxConnections.get());
if (maxSimultaneousRequests.isPresent())
poolingOptions.setNewConnectionThreshold(hostDistance, maxSimultaneousRequests.get());
}
return poolingOptions;
}
示例5: getReadPoolingOptions
import com.datastax.driver.core.PoolingOptions; //导入方法依赖的package包/类
private static PoolingOptions getReadPoolingOptions(Configuration conf)
{
Optional<Integer> coreConnections = getInputCoreConnections(conf);
Optional<Integer> maxConnections = getInputMaxConnections(conf);
Optional<Integer> maxSimultaneousRequests = getInputMaxSimultReqPerConnections(conf);
Optional<Integer> minSimultaneousRequests = getInputMinSimultReqPerConnections(conf);
PoolingOptions poolingOptions = new PoolingOptions();
if (coreConnections.isPresent())
poolingOptions.setCoreConnectionsPerHost(HostDistance.LOCAL, coreConnections.get());
if (maxConnections.isPresent())
poolingOptions.setMaxConnectionsPerHost(HostDistance.LOCAL, maxConnections.get());
if (maxSimultaneousRequests.isPresent())
poolingOptions.setMaxSimultaneousRequestsPerConnectionThreshold(HostDistance.LOCAL, maxSimultaneousRequests.get());
if (minSimultaneousRequests.isPresent())
poolingOptions.setMinSimultaneousRequestsPerConnectionThreshold(HostDistance.LOCAL, minSimultaneousRequests.get());
poolingOptions.setCoreConnectionsPerHost(HostDistance.REMOTE, 0)
.setMaxConnectionsPerHost(HostDistance.REMOTE, 0)
.setMaxSimultaneousRequestsPerConnectionThreshold(HostDistance.REMOTE, 0)
.setMinSimultaneousRequestsPerConnectionThreshold(HostDistance.REMOTE, 0);
return poolingOptions;
}
示例6: CassandraConn
import com.datastax.driver.core.PoolingOptions; //导入方法依赖的package包/类
public CassandraConn(String node, String keyspace, String username, String password) {
PoolingOptions pools = new PoolingOptions();
pools.setMaxSimultaneousRequestsPerConnectionThreshold(HostDistance.LOCAL, maxRequestPerConnection);
pools.setMaxSimultaneousRequestsPerConnectionThreshold(HostDistance.LOCAL, minRequestPerConnection);
pools.setCoreConnectionsPerHost(HostDistance.LOCAL, coreConnectionLocalPerHost);
pools.setMaxConnectionsPerHost(HostDistance.LOCAL, maxConnectionLocalPerHost);
pools.setCoreConnectionsPerHost(HostDistance.REMOTE, coreConnectionRemotePerHost);
pools.setMaxConnectionsPerHost(HostDistance.REMOTE, maxConnectionRemotePerHost);
cluster = Cluster.builder()
.addContactPoint(node)
.withPoolingOptions(pools)
.withCredentials(username, password)
.withSocketOptions(new SocketOptions().setTcpNoDelay(true))
.build();
Metadata metadata = cluster.getMetadata();
System.out.printf("Connected to cluster: %s\n",
metadata.getClusterName());
for ( Host host : metadata.getAllHosts() ) {
System.out.printf("Datatacenter: %s; Host: %s; Rack: %s\n",
host.getDatacenter(), host.getAddress(), host.getRack());
}
session = cluster.connect(keyspace);
}
示例7: setPoolingOptions
import com.datastax.driver.core.PoolingOptions; //导入方法依赖的package包/类
private void setPoolingOptions(PoolingOptions poolingOptions, HostDistance hostDistance, HostDistanceOptions options) {
if (options.getCoreConnections() != null) {
poolingOptions.setCoreConnectionsPerHost(hostDistance, options.getCoreConnections());
}
if (options.getMaxConnections() != null) {
poolingOptions.setMaxConnectionsPerHost(hostDistance, options.getMaxConnections());
}
if (options.getMaxRequestsPerConnection() != null) {
poolingOptions.setMaxRequestsPerConnection(hostDistance, options.getMaxRequestsPerConnection());
}
if (options.getNewConnectionThreshold() != null) {
poolingOptions.setNewConnectionThreshold(hostDistance, options.getNewConnectionThreshold());
}
}
示例8: populatePoolingSettings
import com.datastax.driver.core.PoolingOptions; //导入方法依赖的package包/类
private Cluster.Builder populatePoolingSettings(Properties properties, Cluster.Builder builder) {
String localCoreConnectionsPerHost = properties.getProperty(CassandraStoreParameters.LOCAL_CORE_CONNECTIONS_PER_HOST);
String remoteCoreConnectionsPerHost = properties.getProperty(CassandraStoreParameters.REMOTE_CORE_CONNECTIONS_PER_HOST);
String localMaxConnectionsPerHost = properties.getProperty(CassandraStoreParameters.LOCAL_MAX_CONNECTIONS_PER_HOST);
String remoteMaxConnectionsPerHost = properties.getProperty(CassandraStoreParameters.REMOTE_MAX_CONNECTIONS_PER_HOST);
String localNewConnectionThreshold = properties.getProperty(CassandraStoreParameters.LOCAL_NEW_CONNECTION_THRESHOLD);
String remoteNewConnectionThreshold = properties.getProperty(CassandraStoreParameters.REMOTE_NEW_CONNECTION_THRESHOLD);
String localMaxRequestsPerConnection = properties.getProperty(CassandraStoreParameters.LOCAL_MAX_REQUESTS_PER_CONNECTION);
String remoteMaxRequestsPerConnection = properties.getProperty(CassandraStoreParameters.REMOTE_MAX_REQUESTS_PER_CONNECTION);
PoolingOptions options = new PoolingOptions();
if (localCoreConnectionsPerHost != null) {
options.setCoreConnectionsPerHost(HostDistance.LOCAL, Integer.parseInt(localCoreConnectionsPerHost));
}
if (remoteCoreConnectionsPerHost != null) {
options.setCoreConnectionsPerHost(HostDistance.REMOTE, Integer.parseInt(remoteCoreConnectionsPerHost));
}
if (localMaxConnectionsPerHost != null) {
options.setMaxConnectionsPerHost(HostDistance.LOCAL, Integer.parseInt(localMaxConnectionsPerHost));
}
if (remoteMaxConnectionsPerHost != null) {
options.setMaxConnectionsPerHost(HostDistance.REMOTE, Integer.parseInt(remoteMaxConnectionsPerHost));
}
if (localNewConnectionThreshold != null) {
options.setNewConnectionThreshold(HostDistance.LOCAL, Integer.parseInt(localNewConnectionThreshold));
}
if (remoteNewConnectionThreshold != null) {
options.setNewConnectionThreshold(HostDistance.REMOTE, Integer.parseInt(remoteNewConnectionThreshold));
}
if (localMaxRequestsPerConnection != null) {
options.setMaxRequestsPerConnection(HostDistance.LOCAL, Integer.parseInt(localMaxRequestsPerConnection));
}
if (remoteMaxRequestsPerConnection != null) {
options.setMaxRequestsPerConnection(HostDistance.REMOTE, Integer.parseInt(remoteMaxRequestsPerConnection));
}
builder = builder.withPoolingOptions(options);
return builder;
}
示例9: populatePoolingSettings
import com.datastax.driver.core.PoolingOptions; //导入方法依赖的package包/类
private Builder populatePoolingSettings(Map<String, String> properties, Builder builder) {
String localCoreConnectionsPerHost = properties.get(DBConstants.Cassandra.LOCAL_CORE_CONNECTIONS_PER_HOST);
String remoteCoreConnectionsPerHost = properties.get(DBConstants.Cassandra.REMOTE_CORE_CONNECTIONS_PER_HOST);
String localMaxConnectionsPerHost = properties.get(DBConstants.Cassandra.LOCAL_MAX_CONNECTIONS_PER_HOST);
String remoteMaxConnectionsPerHost = properties.get(DBConstants.Cassandra.REMOTE_MAX_CONNECTIONS_PER_HOST);
String localNewConnectionThreshold = properties.get(DBConstants.Cassandra.LOCAL_NEW_CONNECTION_THRESHOLD);
String remoteNewConnectionThreshold = properties.get(DBConstants.Cassandra.REMOTE_NEW_CONNECTION_THRESHOLD);
String localMaxRequestsPerConnection = properties.get(DBConstants.Cassandra.LOCAL_MAX_REQUESTS_PER_CONNECTION);
String remoteMaxRequestsPerConnection = properties.get(DBConstants.Cassandra.REMOTE_MAX_REQUESTS_PER_CONNECTION);
PoolingOptions options = new PoolingOptions();
if (localCoreConnectionsPerHost != null) {
options.setCoreConnectionsPerHost(HostDistance.LOCAL, Integer.parseInt(localCoreConnectionsPerHost));
}
if (remoteCoreConnectionsPerHost != null) {
options.setCoreConnectionsPerHost(HostDistance.REMOTE, Integer.parseInt(remoteCoreConnectionsPerHost));
}
if (localMaxConnectionsPerHost != null) {
options.setMaxConnectionsPerHost(HostDistance.LOCAL, Integer.parseInt(localMaxConnectionsPerHost));
}
if (remoteMaxConnectionsPerHost != null) {
options.setMaxConnectionsPerHost(HostDistance.REMOTE, Integer.parseInt(remoteMaxConnectionsPerHost));
}
if (localNewConnectionThreshold != null) {
options.setNewConnectionThreshold(HostDistance.LOCAL, Integer.parseInt(localNewConnectionThreshold));
}
if (remoteNewConnectionThreshold != null) {
options.setNewConnectionThreshold(HostDistance.REMOTE, Integer.parseInt(remoteNewConnectionThreshold));
}
if (localMaxRequestsPerConnection != null) {
options.setMaxRequestsPerConnection(HostDistance.LOCAL, Integer.parseInt(localMaxRequestsPerConnection));
}
if (remoteMaxRequestsPerConnection != null) {
options.setMaxRequestsPerConnection(HostDistance.REMOTE, Integer.parseInt(remoteMaxRequestsPerConnection));
}
builder = builder.withPoolingOptions(options);
return builder;
}
示例10: createStandaloneConnection
import com.datastax.driver.core.PoolingOptions; //导入方法依赖的package包/类
/**
* Method to create the standalone cassandra connection .
*
* @param ip
* @param port
* @param userName
* @param password
* @param keyspace
* @return
*/
private boolean createStandaloneConnection(String ip, String port, String userName,
String password, String keyspace) {
Session cassandraSession = null;
boolean connection = false;
Cluster cluster = null;
try {
if (null == cassandraSessionMap.get(keyspace)) {
PropertiesCache cache = PropertiesCache.getInstance();
PoolingOptions poolingOptions = new PoolingOptions();
poolingOptions.setCoreConnectionsPerHost(HostDistance.LOCAL,
Integer.parseInt(cache.getProperty(Constants.CORE_CONNECTIONS_PER_HOST_FOR_LOCAL)));
poolingOptions.setMaxConnectionsPerHost(HostDistance.LOCAL,
Integer.parseInt(cache.getProperty(Constants.MAX_CONNECTIONS_PER_HOST_FOR_LOCAl)));
poolingOptions.setCoreConnectionsPerHost(HostDistance.REMOTE,
Integer.parseInt(cache.getProperty(Constants.CORE_CONNECTIONS_PER_HOST_FOR_REMOTE)));
poolingOptions.setMaxConnectionsPerHost(HostDistance.REMOTE,
Integer.parseInt(cache.getProperty(Constants.MAX_CONNECTIONS_PER_HOST_FOR_REMOTE)));
poolingOptions.setMaxRequestsPerConnection(HostDistance.LOCAL,
Integer.parseInt(cache.getProperty(Constants.MAX_REQUEST_PER_CONNECTION)));
poolingOptions.setHeartbeatIntervalSeconds(
Integer.parseInt(cache.getProperty(Constants.HEARTBEAT_INTERVAL)));
poolingOptions
.setPoolTimeoutMillis(Integer.parseInt(cache.getProperty(Constants.POOL_TIMEOUT)));
if (!ProjectUtil.isStringNullOREmpty(userName)
&& !ProjectUtil.isStringNullOREmpty(password)) {
cluster = createCluster(ip, port, userName, password, poolingOptions);
} else {
cluster = createCluster(ip, port, poolingOptions);
}
QueryLogger queryLogger = QueryLogger.builder().withConstantThreshold(
Integer.parseInt(cache.getProperty(Constants.QUERY_LOGGER_THRESHOLD))).build();
cluster.register(queryLogger);
cassandraSession = cluster.connect(keyspace);
if (null != cassandraSession) {
connection = true;
cassandraSessionMap.put(keyspace, cassandraSession);
cassandraclusterMap.put(keyspace, cluster);
}
final Metadata metadata = cluster.getMetadata();
String msg = String.format("Connected to cluster: %s", metadata.getClusterName());
ProjectLogger.log(msg);
for (final Host host : metadata.getAllHosts()) {
msg = String.format("Datacenter: %s; Host: %s; Rack: %s", host.getDatacenter(),
host.getAddress(), host.getRack());
ProjectLogger.log(msg);
}
}
} catch (Exception e) {
ProjectLogger.log("Error occured while creating connection :", e);
throw new ProjectCommonException(ResponseCode.internalError.getErrorCode(), e.getMessage(),
ResponseCode.SERVER_ERROR.getResponseCode());
}
if (null != cassandraSessionMap.get(keyspace)) {
connection = true;
}
return connection;
}
示例11: newCqlDriverBuilder
import com.datastax.driver.core.PoolingOptions; //导入方法依赖的package包/类
private com.datastax.driver.core.Cluster.Builder newCqlDriverBuilder(ConnectionPoolConfiguration poolConfig,
MetricRegistry metricRegistry) {
performHostDiscovery(metricRegistry);
String[] seeds = _seeds.split(",");
List<String> contactPoints = Lists.newArrayListWithCapacity(seeds.length);
// Each seed may be a host name or a host name and port (e.g.; "1.2.3.4" or "1.2.3.4:9160"). These need
// to be converted into host names only.
for (String seed : seeds) {
HostAndPort hostAndPort = HostAndPort.fromString(seed);
seed = hostAndPort.getHostText();
if (hostAndPort.hasPort()) {
if (hostAndPort.getPort() == _thriftPort) {
_log.debug("Seed {} found using RPC port; swapping for native port {}", seed, _cqlPort);
} else if (hostAndPort.getPort() != _cqlPort) {
throw new IllegalArgumentException(String.format(
"Seed %s found with invalid port %s. The port must match either the RPC (thrift) port %s " +
"or the native (CQL) port %s", seed, hostAndPort.getPort(), _thriftPort, _cqlPort));
}
}
contactPoints.add(seed);
}
PoolingOptions poolingOptions = new PoolingOptions();
if (poolConfig.getMaxConnectionsPerHost().or(getMaxConnectionsPerHost()).isPresent()) {
poolingOptions.setMaxConnectionsPerHost(HostDistance.LOCAL, poolConfig.getMaxConnectionsPerHost().or(getMaxConnectionsPerHost()).get());
}
if (poolConfig.getCoreConnectionsPerHost().or(getCoreConnectionsPerHost()).isPresent()) {
poolingOptions.setCoreConnectionsPerHost(HostDistance.LOCAL, poolConfig.getCoreConnectionsPerHost().or(getCoreConnectionsPerHost()).get());
}
SocketOptions socketOptions = new SocketOptions();
if (poolConfig.getConnectTimeout().or(getConnectTimeout()).isPresent()) {
socketOptions.setConnectTimeoutMillis(poolConfig.getConnectTimeout().or(getConnectTimeout()).get());
}
if (poolConfig.getSocketTimeout().or(getSocketTimeout()).isPresent()) {
socketOptions.setReadTimeoutMillis(poolConfig.getSocketTimeout().or(getSocketTimeout()).get());
}
AuthProvider authProvider = _authenticationCredentials != null
? new PlainTextAuthProvider(_authenticationCredentials.getUsername(), _authenticationCredentials.getPassword())
: AuthProvider.NONE;
return com.datastax.driver.core.Cluster.builder()
.addContactPoints(contactPoints.toArray(new String[contactPoints.size()]))
.withPort(_cqlPort)
.withPoolingOptions(poolingOptions)
.withSocketOptions(socketOptions)
.withRetryPolicy(Policies.defaultRetryPolicy())
.withAuthProvider(authProvider);
}
示例12: CQLClient
import com.datastax.driver.core.PoolingOptions; //导入方法依赖的package包/类
public CQLClient(LoaderOptions options, String keyspace)
throws NoSuchAlgorithmException, FileNotFoundException, IOException, KeyStoreException,
CertificateException, UnrecoverableKeyException, KeyManagementException, ConfigurationException {
// System.setProperty("com.datastax.driver.NON_BLOCKING_EXECUTOR_SIZE",
// "64");
PoolingOptions poolingOptions = new PoolingOptions();
int connections = options.connectionsPerHost;
if (connections == 0) {
connections = 8;
}
poolingOptions.setCoreConnectionsPerHost(HostDistance.LOCAL, Math.max(1, connections / 2));
poolingOptions.setCoreConnectionsPerHost(HostDistance.REMOTE, Math.max(1, connections / 4));
poolingOptions.setMaxConnectionsPerHost(HostDistance.LOCAL, connections);
poolingOptions.setMaxConnectionsPerHost(HostDistance.REMOTE, Math.max(1, connections / 2));
poolingOptions.setMaxRequestsPerConnection(HostDistance.LOCAL, 32768);
poolingOptions.setMaxRequestsPerConnection(HostDistance.REMOTE, 2000);
this.simulate = options.simulate;
this.verbose = options.verbose;
Cluster.Builder builder = builder().addContactPoints(options.hosts).withProtocolVersion(ProtocolVersion.V3)
.withCompression(Compression.LZ4).withPoolingOptions(poolingOptions);
if (options.user != null && options.passwd != null) {
builder = builder.withCredentials(options.user, options.passwd);
}
if (options.ssl) {
EncryptionOptions enco = options.encOptions;
SSLContext ctx = SSLContext.getInstance(options.encOptions.protocol);
try (FileInputStream tsf = new FileInputStream(enco.truststore);
FileInputStream ksf = new FileInputStream(enco.keystore)) {
KeyStore ts = KeyStore.getInstance(enco.store_type);
ts.load(tsf, enco.truststore_password.toCharArray());
TrustManagerFactory tmf = TrustManagerFactory
.getInstance(TrustManagerFactory.getDefaultAlgorithm());
tmf.init(ts);
KeyStore ks = KeyStore.getInstance("JKS");
ks.load(ksf, enco.keystore_password.toCharArray());
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
kmf.init(ks, enco.keystore_password.toCharArray());
ctx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), new SecureRandom());
}
SSLOptions sslOptions = JdkSSLOptions.builder().withSSLContext(ctx).withCipherSuites(enco.cipher_suites)
.build();
builder = builder.withSSL(sslOptions);
}
cluster = builder.build();
session = cluster.connect(keyspace);
metadata = cluster.getMetadata();
keyspaceMetadata = metadata.getKeyspace(keyspace);
org.apache.cassandra.schema.KeyspaceMetadata ksMetaData = org.apache.cassandra.schema.KeyspaceMetadata
.create(keyspaceMetadata.getName(), KeyspaceParams.create(keyspaceMetadata.isDurableWrites(),
keyspaceMetadata.getReplication()));
Schema.instance.load(ksMetaData);
loadUserTypes(keyspaceMetadata.getUserTypes(), keyspace);
partitioner = FBUtilities.newPartitioner(metadata.getPartitioner());
if (options.throttle != 0) {
rateLimiter = RateLimiter.create(options.throttle * 1000 * 1000 / 8);
}
this.batch = options.batch;
this.preparedStatements = options.prepare ? new ConcurrentHashMap<>() : null;
this.ignoreColumns = options.ignoreColumns;
}
示例13: configurePoolingOptions
import com.datastax.driver.core.PoolingOptions; //导入方法依赖的package包/类
/**
* Creates the pooling options for this factory.
*
* @param configuration the configuration.
* @return the pooling options for this factory.
*/
private PoolingOptions configurePoolingOptions(final Configuration<Map<String, Object>> configuration) {
final PoolingOptions poolingOptions = new PoolingOptions();
Integer value = configuration.getParameter("local_core_connections_per_host", null);
if (value != null) {
poolingOptions.setCoreConnectionsPerHost(HostDistance.LOCAL, value);
}
value = configuration.getParameter("local_max_connections_per_host", null);
if (value != null) {
poolingOptions.setMaxConnectionsPerHost(HostDistance.LOCAL, value);
}
value = configuration.getParameter("local_max_simultaneous_request_per_connection_threshold", null);
if (value != null) {
poolingOptions.setMaxSimultaneousRequestsPerConnectionThreshold(HostDistance.LOCAL, value);
}
value = configuration.getParameter("local_min_simultaneous_request_per_connection_threshold", null);
if (value != null) {
poolingOptions.setMinSimultaneousRequestsPerConnectionThreshold(HostDistance.LOCAL, value);
}
value = configuration.getParameter("remote_core_connections_per_host", null);
if (value != null) {
poolingOptions.setCoreConnectionsPerHost(HostDistance.REMOTE, value);
}
value = configuration.getParameter("remote_max_connections_per_host", null);
if (value != null) {
poolingOptions.setMaxConnectionsPerHost(HostDistance.REMOTE, value);
}
value = configuration.getParameter("remote_max_simultaneous_request_per_connection_threshold", null);
if (value != null) {
poolingOptions.setMaxSimultaneousRequestsPerConnectionThreshold(HostDistance.REMOTE, value);
}
value = configuration.getParameter("remote_min_simultaneous_request_per_connection_threshold", null);
if (value != null) {
poolingOptions.setMinSimultaneousRequestsPerConnectionThreshold(HostDistance.REMOTE, value);
}
return poolingOptions;
}