Package com.netflix.astyanax.connectionpool.impl

Examples of com.netflix.astyanax.connectionpool.impl.ConnectionPoolConfigurationImpl


            }
        }
        // in the defaults case, we don't know the seed hosts until context
        // creation time
        if (settings.get(ASTYANAX_CONNECTION_POOL_CONFIGURATION) instanceof ConnectionPoolConfigurationImpl) {
            ConnectionPoolConfigurationImpl cpConfig = (ConnectionPoolConfigurationImpl) settings
                    .get(ASTYANAX_CONNECTION_POOL_CONFIGURATION);
            cpConfig.setSeeds((String) config.get(StormCassandraConstants.CASSANDRA_HOST));
        }

        return new AstyanaxContext.Builder()
                .forCluster((String) settings.get(CASSANDRA_CLUSTER_NAME))
                .forKeyspace((String) config.get(StormCassandraConstants.CASSANDRA_STATE_KEYSPACE))
View Full Code Here


            }
        }
        // in the defaults case, we don't know the seed hosts until context
        // creation time
        if (settings.get(ASTYANAX_CONNECTION_POOL_CONFIGURATION) instanceof ConnectionPoolConfigurationImpl) {
            ConnectionPoolConfigurationImpl cpConfig = (ConnectionPoolConfigurationImpl) settings
                    .get(ASTYANAX_CONNECTION_POOL_CONFIGURATION);
            cpConfig.setSeeds((String) config.get(StormCassandraConstants.CASSANDRA_HOST));
            Long port = (Long)config.get(StormCassandraConstants.CASSANDRA_PORT);
            if(port != null){
              cpConfig.setPort(port.intValue());
            }
           
            //
            String user = (String) config.get(StormCassandraConstants.CASSANDRA_USERNAME);

            if( user != null && ! user.trim().isEmpty() ){
                String password = config.containsKey(StormCassandraConstants.CASSANDRA_PASSWORD) ?
                    (String) config.get(StormCassandraConstants.CASSANDRA_PASSWORD) : "password";

            cpConfig.setAuthenticationCredentials(
                   new SimpleAuthenticationCredentials(new String(user), new String(password)));
            }
        }

        @SuppressWarnings("unchecked")
View Full Code Here

    public static Builder newBuilder(String hostString){
        return new AstyanaxContext.Builder()
        .forCluster("ClusterName")
        .withAstyanaxConfiguration(new AstyanaxConfigurationImpl().setDiscoveryType(NodeDiscoveryType.NONE))
        .withConnectionPoolConfiguration(
                new ConnectionPoolConfigurationImpl("MyConnectionPool").setPort(9160).setMaxConnsPerHost(1)
                        .setSeeds(hostString))
        .withConnectionPoolMonitor(new CountingConnectionPoolMonitor());
    }
View Full Code Here

                    .build();
        }

        AstyanaxConfiguration configuration = new AstyanaxConfigurationImpl().setDiscoveryType(NodeDiscoveryType.NONE);

        ConnectionPoolConfiguration connectionPoolConfiguration = new ConnectionPoolConfigurationImpl("AstyanaxPool")
                .setPort(port)
                .setMaxConnsPerHost(1)
                .setSeeds(cassandraHostname + ":" + port);

        ConnectionPoolMonitor connectionPoolMonitor = new CountingConnectionPoolMonitor();
View Full Code Here

                {
                    latencyScoreStrategy = new EmptyLatencyScoreStrategyImpl();
                }

                String maxConnection = com.netflix.jmeter.properties.Properties.instance.cassandra.getMaxConnsPerHost();
                ConnectionPoolConfigurationImpl poolConfig = new ConnectionPoolConfigurationImpl(getClusterName()).setPort(port);
                poolConfig.setMaxConnsPerHost(Integer.parseInt(maxConnection));
                poolConfig.setSeeds(StringUtils.join(endpoints, ":" + port + ","));
                poolConfig.setLatencyScoreStrategy(latencyScoreStrategy);

                logger.info("ConnectionPoolConfiguration: " + poolConfig.toString());

                ConnectionPoolMonitor connectionPoolMonitor = new CountingConnectionPoolMonitor();
                // set this as field for logging purpose only.
                Builder builder = new AstyanaxContext.Builder();
                builder.forCluster(getClusterName());
View Full Code Here

      .forKeyspace(keyspace2)
      .withAstyanaxConfiguration(new AstyanaxConfigurationImpl()     
          .setDiscoveryType(NodeDiscoveryType.RING_DESCRIBE)
          .setConnectionPoolType(ConnectionPoolType.TOKEN_AWARE)
      )
      .withConnectionPoolConfiguration(new ConnectionPoolConfigurationImpl("MyConnectionPool")
          .setMaxConnsPerHost(20)
          .setInitConnsPerHost(2)
          .setSeeds(seeds2)
          .setConnectTimeout(10000)
      )
View Full Code Here

  }
 
  @Override
  protected void createBestCassandraConfig(Map<String, Object> properties,
      String clusterName, String keyspace2, String seeds2) {
    ConnectionPoolConfigurationImpl poolConfig = new ConnectionPoolConfigurationImpl("MyConnectionPool")
        .setMaxConnsPerHost(20)
        .setInitConnsPerHost(2)
        .setSeeds(seeds2)
        .setConnectTimeout(10000)
        .setRetryBackoffStrategy(new FixedRetryBackoffStrategy(5000, 30000));

    Object username = properties.get(Bootstrap.CASSANDRA_USERNAME);
    Object password = properties.get(Bootstrap.CASSANDRA_PASSWORD);
    if (username != null && password != null) {
      poolConfig.setAuthenticationCredentials(new SimpleAuthenticationCredentials(""+username, ""+password));
    }
   
    Object port = properties.get(Bootstrap.CASSANDRA_THRIFT_PORT);
    if(port != null) {
      int portVal = 9160;
      if(port instanceof Integer)
        portVal = (Integer) port;
      else if(port instanceof String)
        portVal = Integer.valueOf((String) port);
      else
        throw new RuntimeException(Bootstrap.CASSANDRA_THRIFT_PORT+" key in map has a value of type="+port.getClass()+" but that must be a String or Integer");
      poolConfig.setPort(portVal);
    }
   
    Builder builder = new AstyanaxContext.Builder()
      .forCluster(clusterName)
      .forKeyspace(keyspace2)
View Full Code Here

        if (context == null) {
            context = new AstyanaxContext.Builder()
               .forCluster(getClusterName())
               .forKeyspace(getKeyspaceName())   
               .withConnectionPoolConfiguration(
                   new ConnectionPoolConfigurationImpl(getConnectionPoolName())
                   .setPort(getPort())
                   .setMaxConnsPerHost(getConnectionsPerHost())
                   .setSeeds(getSeeds()))
               .withConnectionPoolMonitor(new Slf4jConnectionPoolMonitorImpl())
               .withAstyanaxConfiguration(
View Full Code Here

            new AstyanaxConfigurationImpl()
                //.setCqlVersion( cqlVersion )
                .setDiscoveryType( NodeDiscoveryType.RING_DESCRIBE )
                .setConnectionPoolType( ConnectionPoolType.TOKEN_AWARE ) )
            .withConnectionPoolConfiguration(
                new ConnectionPoolConfigurationImpl( CLUSTER_NAME + "_" + KEYSPACE_NAME )
                    .setSocketTimeout( 30000 )
                    .setMaxTimeoutWhenExhausted( 2000 )
                    .setMaxConnsPerHost( 20 )
                    .setInitConnsPerHost( 10 )
                    .setSeeds( cassandraHost + ":" + cassandraPort ) )
View Full Code Here

    this.astyanaxContext = new AstyanaxContext.Builder()
        .forCluster(CLUSTER_NAME)
        .forKeyspace(config.getKeyspace())
        .withAstyanaxConfiguration(new AstyanaxConfigurationImpl().setDiscoveryType(NodeDiscoveryType.NONE))
        .withConnectionPoolConfiguration(
            new ConnectionPoolConfigurationImpl("MyConnectionPool").setMaxConnsPerHost(10)
                .setSeeds(config.getHost())).withConnectionPoolMonitor(new CountingConnectionPoolMonitor())
        .buildKeyspace(ThriftFamilyFactory.getInstance());
    this.astyanaxContext.start();
    this.keyspace = this.astyanaxContext.getEntity();
    this.config = config;
View Full Code Here

TOP

Related Classes of com.netflix.astyanax.connectionpool.impl.ConnectionPoolConfigurationImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.