Package me.prettyprint.cassandra.service

Examples of me.prettyprint.cassandra.service.CassandraHostConfigurator


    public synchronized void init() throws Exception {
        super.init();
        log.debug("initializing factory");
        //favor an existing cassandraHostConfigurator
        if (cassandraHostConfigurator == null) {
            cassandraHostConfigurator = new CassandraHostConfigurator();
            cassandraHostConfigurator.setPort(getThriftPort());
            cassandraHostConfigurator.setHosts(StringUtils.join(getContactNodes(), ','));
            cassandraHostConfigurator.setAutoDiscoverHosts(autoDiscoverHosts);
        }
        cluster = HFactory.getOrCreateCluster(clusterName, cassandraHostConfigurator, credentials);
View Full Code Here


        return cmd;
    }
   
    private void initializeCommandRunner(CommandLine cmd) throws Exception {

        CassandraHostConfigurator cassandraHostConfigurator = new CassandraHostConfigurator(seedHost);
       
        if ( cmd.hasOption("unframed")) {
            cassandraHostConfigurator.setUseThriftFramedTransport(false);
        }
        if (cmd.hasOption("max-wait")) {
            cassandraHostConfigurator.setMaxWaitTimeWhenExhausted(getIntValueOrExit(cmd, "max-wait"));
        }       
        if (cmd.hasOption("thrift-timeout")) {
            cassandraHostConfigurator.setCassandraThriftSocketTimeout(getIntValueOrExit(cmd, "thrift-timeout"));
        }           
        cassandraHostConfigurator.setMaxActive(commandArgs.clients);
       
        if (cmd.hasOption("discovery-delay")) {
            cassandraHostConfigurator.setAutoDiscoverHosts(true);
            cassandraHostConfigurator.setAutoDiscoveryDelayInSeconds(getIntValueOrExit(cmd, "discovery-delay"));
        }
        if (cmd.hasOption("retry-delay")) {         
            cassandraHostConfigurator.setRetryDownedHostsDelayInSeconds(getIntValueOrExit(cmd, "retry-delay"));
        }
        if (cmd.hasOption("skip-retry-delay")) {         
            cassandraHostConfigurator.setRetryDownedHosts(false);
        }
        ConfigurableConsistencyLevel clc = null;
        if ( cmd.hasOption("consistency-levels")) {
            String[] levels = cmd.getOptionValues("consistency-levels")[0].split(":");
            clc = new ConfigurableConsistencyLevel();                       
View Full Code Here

  private void initPersistence() {

    long ts1 = System.currentTimeMillis();
    logger.info("event=initializing_hector");

    CassandraHostConfigurator cassandraHostConfigurator = new CassandraHostConfigurator();

    cassandraHostConfigurator.setHosts(CLUSTER_URL);
    cassandraHostConfigurator.setMaxActive(hectorPoolSize);
    cassandraHostConfigurator.setCassandraThriftSocketTimeout(CMBProperties.getInstance().getCassandraThriftSocketTimeOutMS());

    cassandraHostConfigurator.setAutoDiscoverHosts(CMBProperties.getInstance().isHectorAutoDiscovery());
    cassandraHostConfigurator.setAutoDiscoveryDelayInSeconds(CMBProperties.getInstance().getHectorAutoDiscoveryDelaySeconds());

    String dataCenter = CMBProperties.getInstance().getCassandraDataCenter();

    if (dataCenter != null && !dataCenter.equals("")) {
      cassandraHostConfigurator.setAutoDiscoveryDataCenter(dataCenter);
    }

    // some other settings we may be interested in down the road, see here for more details:
    // https://github.com/rantav/hector/wiki/User-Guide

    if (hectorBalancingPolicy != null) {
      if (hectorBalancingPolicy.equals("LeastActiveBalancingPolicy")) {
        cassandraHostConfigurator.setLoadBalancingPolicy(new LeastActiveBalancingPolicy());
      } else if (hectorBalancingPolicy.equals("RoundRobinBalancingPolicy")) {
        cassandraHostConfigurator.setLoadBalancingPolicy(new RoundRobinBalancingPolicy()); //default
      } else if (hectorBalancingPolicy.equals("DynamicLoadBalancingPolicy")) {
        cassandraHostConfigurator.setLoadBalancingPolicy(new DynamicLoadBalancingPolicy());
      }
    }

    //cassandraHostConfigurator.setExhaustedPolicy(ExhaustedPolicy.WHEN_EXHAUSTED_GROW);
View Full Code Here

    if ( hostsRefAddr == null || hostsRefAddr.getContent() == null) {
      throw new Exception("A url and port on which Cassandra is installed and listening " +
      "on must be provided as a ResourceParams in the context.xml");
    }       

    cassandraHostConfigurator = new CassandraHostConfigurator((String)hostsRefAddr.getContent());
    if ( autoDiscoverHosts != null ) {
      cassandraHostConfigurator.setAutoDiscoverHosts(Boolean.parseBoolean((String)autoDiscoverHosts.getContent()));
      if ( runAutoDiscoverAtStartup  != null )
        cassandraHostConfigurator.setRunAutoDiscoveryAtStartup(Boolean.parseBoolean((String)autoDiscoverHosts.getContent()));
    }   
View Full Code Here

   *          host:ip format string
   * @return
   */
  public static Cluster getOrCreateCluster(String clusterName, String hostIp) {
    return getOrCreateCluster(clusterName,
        new CassandraHostConfigurator(hostIp));
  }
View Full Code Here

    private final CassandraBuilder builder = IoCs.findOrCreateInstance(CassandraBuilder.class);
    private final Cluster cluster;
    private final Keyspace keyspace;

    public CassandraSirona() {
        final CassandraHostConfigurator configurator = new CassandraHostConfigurator(builder.getHosts());
        configurator.setMaxActive(builder.getMaxActive());
        cluster = HFactory.getOrCreateCluster(builder.getCluster(), configurator);

        final String keyspaceName = builder.getKeyspace();

        final ConfigurableConsistencyLevel consistencyLevelPolicy = new ConfigurableConsistencyLevel();
View Full Code Here

TOP

Related Classes of me.prettyprint.cassandra.service.CassandraHostConfigurator

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.