Package com.netflix.astyanax.impl

Examples of com.netflix.astyanax.impl.AstyanaxConfigurationImpl


//        hs = new EurekaAstyanaxHostSupplier();
        AstyanaxContext<Keyspace> keyspaceContext = new AstyanaxContext.Builder()
        .forCluster(clusterNameOnly)
        .forKeyspace(MetaConstants.META_KEY_SPACE)
        .withAstyanaxConfiguration(
                new AstyanaxConfigurationImpl()
                        .setDiscoveryType(
                                NodeDiscoveryType.RING_DESCRIBE)
                        .setConnectionPoolType(
                                ConnectionPoolType.TOKEN_AWARE)
                        .setDiscoveryDelayInSeconds(60000)
View Full Code Here


    if (supplier!=null) {
    keyspaceContext = new AstyanaxContext.Builder()
        .forCluster("Casss_Paas")
        .forKeyspace(db)
        .withAstyanaxConfiguration(
            new AstyanaxConfigurationImpl()
                .setDiscoveryType(
                    NodeDiscoveryType.DISCOVERY_SERVICE)
                .setConnectionPoolType(
                    ConnectionPoolType.TOKEN_AWARE)
                .setDiscoveryDelayInSeconds(60)
                .setTargetCassandraVersion("1.2")
                .setCqlVersion("3.0.0"))
        .withHostSupplier(supplier.getSupplier(clustername))
        .withConnectionPoolConfiguration(
            new ConnectionPoolConfigurationImpl(clusterNameOnly
                + "_" + db)
                .setSocketTimeout(10000)
                .setPort(7102)
                .setMaxConnsPerHost(10).setInitConnsPerHost(3)
                .setSeeds(null))
        .withConnectionPoolMonitor(new CountingConnectionPoolMonitor())
        .buildKeyspace(ThriftFamilyFactory.getInstance());
    } else {
      keyspaceContext = new AstyanaxContext.Builder()
          .forCluster(clusterNameOnly)
          .forKeyspace(db)
          .withAstyanaxConfiguration(
                  new AstyanaxConfigurationImpl()
                          .setDiscoveryType(
                                  NodeDiscoveryType.RING_DESCRIBE)
                          .setConnectionPoolType(
                                  ConnectionPoolType.TOKEN_AWARE)
                          .setDiscoveryDelayInSeconds(60)
View Full Code Here

       
        CassandraKeyspaceHolder keyspace = new CassandraKeyspaceHolder(new AstyanaxContext.Builder()
                .forCluster(clusterName)
                .forKeyspace(keyspaceName)
                .withAstyanaxConfiguration(
                        new AstyanaxConfigurationImpl()
                                .setDiscoveryType(NodeDiscoveryType.RING_DESCRIBE)
                                .setConnectionPoolType(ConnectionPoolType.ROUND_ROBIN)
                                .setDiscoveryDelayInSeconds(60000))
                .withConnectionPoolConfiguration(
                        new ConnectionPoolConfigurationImpl(
View Full Code Here

        }
        AstyanaxContext<Keyspace> keyspaceContext = new AstyanaxContext.Builder()
        .forCluster(clusterNameOnly)
        .forKeyspace(MetaConstants.META_KEY_SPACE)
        .withAstyanaxConfiguration(
                new AstyanaxConfigurationImpl()
                        .setDiscoveryType(
                                NodeDiscoveryType.RING_DESCRIBE)
                        .setConnectionPoolType(
                                ConnectionPoolType.TOKEN_AWARE)
                        .setDiscoveryDelayInSeconds(60)
View Full Code Here

public class DefaultAstyanaxConfigurationProvider implements AstyanaxConfigurationProvider {

    @Override
    public AstyanaxConfiguration get(String name) {
        return new AstyanaxConfigurationImpl()
            .setDiscoveryType(NodeDiscoveryType.NONE)
            .setConnectionPoolType(ConnectionPoolType.ROUND_ROBIN)
            .setDiscoveryDelayInSeconds(60000)
            .setCqlVersion("3.0.0");
    }
View Full Code Here

    private static AstyanaxContext<Keyspace> createPreferredHostContext() {
        return createCustomHostContext(createPreferredAstyanaxConfiguration(), createPreferredConnectionPoolConfiguration());
    }

    private static AstyanaxConfigurationImpl createPreferredAstyanaxConfiguration() {
        AstyanaxConfigurationImpl astyconfig = new AstyanaxConfigurationImpl()
                .setDiscoveryType(NodeDiscoveryType.NONE)
                .setConnectionPoolType(ConnectionPoolType.ROUND_ROBIN);

        int numRetries = config.getIntegerProperty(CoreConfig.CASSANDRA_MAX_RETRIES);
        if (numRetries > 0) {
            astyconfig.setRetryPolicy(new RetryNTimes(numRetries));
        }

        return astyconfig;
    }
View Full Code Here

    }
   
    private static AstyanaxContext<Keyspace> connect(String host, int port, String keyspace, int threads, NodeDiscoveryType discovery) {
        AstyanaxContext<Keyspace> context = new AstyanaxContext.Builder()
                        .forKeyspace(keyspace)
                .withAstyanaxConfiguration(new AstyanaxConfigurationImpl()
                    .setDiscoveryType(discovery)
                    .setRetryPolicy(new RetryNTimes(10)))
                   
                .withConnectionPoolConfiguration(new ConnectionPoolConfigurationImpl(host + ":" + keyspace)
                        .setMaxConns(threads * 2)
 
View Full Code Here

  protected void createBestCassandraConfig(Map<String, Object> properties,
      String clusterName, String keyspace2, String seeds2) {
    Builder builder = new AstyanaxContext.Builder()
      .forCluster(clusterName)
      .forKeyspace(keyspace2)
      .withAstyanaxConfiguration(new AstyanaxConfigurationImpl()     
          .setDiscoveryType(NodeDiscoveryType.RING_DESCRIBE)
      )
      .withConnectionPoolConfiguration(new ConnectionPoolConfigurationImpl("MyConnectionPool")
          .setMaxConnsPerHost(2)
          .setInitConnsPerHost(2)
          .setSeeds(seeds2)
      )
      .withConnectionPoolMonitor(new CountingConnectionPoolMonitor());
   
   
  if(seeds2.contains(",")) {
    //for a multi-node cluster, we want the test suite using quorum on writes and
    //reads so we have no issues...
    AstyanaxConfigurationImpl config = new AstyanaxConfigurationImpl();
    config.setDefaultWriteConsistencyLevel(ConsistencyLevel.CL_QUORUM);
    config.setDefaultReadConsistencyLevel(ConsistencyLevel.CL_QUORUM);
    builder = builder.withAstyanaxConfiguration(config);
  }
  properties.put(Bootstrap.CASSANDRA_BUILDER, builder);
  }
View Full Code Here

  protected void createBestCassandraConfig(Map<String, Object> properties,
      String clusterName, String keyspace2, String seeds2) {
    Builder builder = new AstyanaxContext.Builder()
      .forCluster(clusterName)
      .forKeyspace(keyspace2)
      .withAstyanaxConfiguration(new AstyanaxConfigurationImpl()     
          .setDiscoveryType(NodeDiscoveryType.RING_DESCRIBE)
      )
      .withConnectionPoolConfiguration(new ConnectionPoolConfigurationImpl("MyConnectionPool")
          .setMaxConnsPerHost(2)
          .setInitConnsPerHost(2)
          .setSeeds(seeds2)
      )
      .withConnectionPoolMonitor(new CountingConnectionPoolMonitor());
   
   
    if(!"localhost:9160".equals(seeds2)) {
      if(!seeds2.contains(","))
        throw new IllegalArgumentException("You must specify a comma delimited list of seeds OR 'localhost:9160' as the seed");
      //for a multi-node cluster, we want the test suite using quorum on writes and
      //reads so we have no issues...
      AstyanaxConfigurationImpl config = new AstyanaxConfigurationImpl();
      config.setDefaultWriteConsistencyLevel(ConsistencyLevel.CL_QUORUM);
      config.setDefaultReadConsistencyLevel(ConsistencyLevel.CL_QUORUM);
      builder = builder.withAstyanaxConfiguration(config);
    }   
    properties.put(Bootstrap.CASSANDRA_BUILDER, builder);
  }
View Full Code Here

    }
   
    Builder builder = new AstyanaxContext.Builder()
      .forCluster(clusterName)
      .forKeyspace(keyspace2)
      .withAstyanaxConfiguration(new AstyanaxConfigurationImpl()     
          .setDiscoveryType(NodeDiscoveryType.RING_DESCRIBE)
          .setConnectionPoolType(ConnectionPoolType.TOKEN_AWARE)
    .setClock(new MicrosecondsAsyncClock())
      )
      .withConnectionPoolConfiguration(poolConfig)
      .withConnectionPoolMonitor(new CountingConnectionPoolMonitor());

    String clStr = (String) properties.get(Bootstrap.CASSANDRA_DEFAULT_CONSISTENCY_LEVEL);
    if(clStr != null) {
      ConsistencyLevel cl = null;
      for(ConsistencyLevel l : ConsistencyLevel.values()) {
        if(l.toString().equals(clStr)) {
          cl = l;
          break;
        }
      }
      if(cl == null)
        throw new IllegalArgumentException("Consistency level must be one of the strings mathcin astyanax ConsistencyLevel.XXXX");

      AstyanaxConfigurationImpl config = new AstyanaxConfigurationImpl();
      config.setDefaultWriteConsistencyLevel(cl);
      config.setDefaultReadConsistencyLevel(cl);
      builder = builder.withAstyanaxConfiguration(config);
    } else if(seeds2.contains(",")) {
      //for a multi-node cluster, we want the test suite using quorum on writes and
      //reads so we have no issues...
      AstyanaxConfigurationImpl config = new AstyanaxConfigurationImpl();
      config.setDefaultWriteConsistencyLevel(ConsistencyLevel.CL_QUORUM);
      config.setDefaultReadConsistencyLevel(ConsistencyLevel.CL_QUORUM);
      builder = builder.withAstyanaxConfiguration(config);
    }
    properties.put(Bootstrap.CASSANDRA_BUILDER, builder);
  }
View Full Code Here

TOP

Related Classes of com.netflix.astyanax.impl.AstyanaxConfigurationImpl

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.