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


Java PoolingOptions.setMaxRequestsPerConnection方法代码示例

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


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

示例1: 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());
    }
}
 
开发者ID:composable-systems,项目名称:dropwizard-cassandra,代码行数:15,代码来源:PoolingOptionsFactory.java

示例2: 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;
}
 
开发者ID:apache,项目名称:gora,代码行数:38,代码来源:CassandraClient.java

示例3: 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;
}
 
开发者ID:wso2,项目名称:carbon-data,代码行数:38,代码来源:CassandraConfig.java

示例4: 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;


}
 
开发者ID:project-sunbird,项目名称:sunbird-utils,代码行数:74,代码来源:CassandraConnectionManagerImpl.java

示例5: 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;
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:71,代码来源:BulkLoader.java


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