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


Java CassandraHostConfigurator类代码示例

本文整理汇总了Java中me.prettyprint.cassandra.service.CassandraHostConfigurator的典型用法代码示例。如果您正苦于以下问题:Java CassandraHostConfigurator类的具体用法?Java CassandraHostConfigurator怎么用?Java CassandraHostConfigurator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: retrieveCassandraCluster

import me.prettyprint.cassandra.service.CassandraHostConfigurator; //导入依赖的package包/类
private Cluster retrieveCassandraCluster(String clusterName, String connectionUrl,
                                         Map<String, String> credentials) throws SummarizerException {
    LoggingConfig config;
    try {
        config = LoggingConfigManager.loadLoggingConfiguration();
    } catch (Exception e) {
        throw new SummarizerException("Cannot read the Summarizer config file", e);
    }
    CassandraHostConfigurator hostConfigurator = new CassandraHostConfigurator(connectionUrl);
    hostConfigurator.setRetryDownedHosts(config.isRetryDownedHostsEnable());
    hostConfigurator.setRetryDownedHostsQueueSize(config.getRetryDownedHostsQueueSize());
    hostConfigurator.setAutoDiscoverHosts(config.isAutoDiscoveryEnable());
    hostConfigurator.setAutoDiscoveryDelayInSeconds(config.getAutoDiscoveryDelay());
    Cluster cluster = HFactory.createCluster(clusterName, hostConfigurator, credentials);
    return cluster;
}
 
开发者ID:wso2,项目名称:carbon-commons,代码行数:17,代码来源:ColumnFamilyHandler.java

示例2: createCassandraConfigurator

import me.prettyprint.cassandra.service.CassandraHostConfigurator; //导入依赖的package包/类
private CassandraHostConfigurator createCassandraConfigurator() {

		final CassandraHostConfigurator cassandraHostConfigurator = new CassandraHostConfigurator();
		cassandraHostConfigurator.setMaxActive(hectorClientConfiguration.getMaxActive());
		// cassandraHostConfigurator.setMaxIdle(hectorClientConfiguration.getMaxIdle());
		cassandraHostConfigurator.setCassandraThriftSocketTimeout(hectorClientConfiguration.getThriftSocketTimeout());
		cassandraHostConfigurator.setRetryDownedHosts(hectorClientConfiguration.isRetryDownedHosts());
		cassandraHostConfigurator.setRetryDownedHostsDelayInSeconds(
				hectorClientConfiguration.getRetryDownedHostsDelayInSeconds());
		cassandraHostConfigurator.setLoadBalancingPolicy(hectorClientConfiguration.getLoadBalancingPolicy());
		log.info("Hector Host Configurator Parameters \n" + cassandraHostConfigurator.toString());
		if (StringUtils.isNotBlank(username) && StringUtils.isNotBlank(password)) {
			Map<String, String> accessMap = new HashMap<>();
			accessMap.put("username", this.username);
			accessMap.put("password", this.password);
		}


		return cassandraHostConfigurator;
	}
 
开发者ID:WizeCommerce,项目名称:hecuba,代码行数:21,代码来源:HectorBasedHecubaClientManager.java

示例3: configureOurColumnFamilyTemplatePool

import me.prettyprint.cassandra.service.CassandraHostConfigurator; //导入依赖的package包/类
public void configureOurColumnFamilyTemplatePool(String[] splittedPorts, String[] splittedLocationURLs) {
	final CassandraHostConfigurator cassandraHostConfigurator = createCassandraConfigurator();
	for (int index = 0; index < splittedLocationURLs.length; index++) {
		String locationURL = splittedLocationURLs[index];
		String port = "";
		if (index < splittedPorts.length) {
			port = splittedPorts[index];
		}

		if (port == null || "".equals(port)) {
			port = "9160";
		}

		cassandraHostConfigurator.setHosts(locationURL + ":" + port);
		cluster = HFactory.getOrCreateCluster(clusterName, cassandraHostConfigurator);
		keysp = HFactory.createKeyspace(keyspace, cluster, consistencyLevel);
		columnFamilyTemplates.add(new ThriftColumnFamilyTemplate<K, String>(keysp, columnFamily, keySerializer,
				StringSerializer.get()));
	}
}
 
开发者ID:WizeCommerce,项目名称:hecuba,代码行数:21,代码来源:HectorBasedHecubaClientManager.java

示例4: init

import me.prettyprint.cassandra.service.CassandraHostConfigurator; //导入依赖的package包/类
protected void init(String clustername, String hosts, String username, String password, String keyspace) {
	CassandraHostConfigurator hostconfig = new CassandraHostConfigurator(hosts);
	hostconfig.setRetryDownedHosts(true);
	hostconfig.setRetryDownedHostsDelayInSeconds(5);
	hostconfig.setRetryDownedHostsQueueSize(-1); // no bounds		
	this.cluster = HFactory.getOrCreateCluster(clustername, hostconfig);
	
	Map<String,String> credentials = new HashMap<String, String>();
	if (username != null && username.length() > 0) {
		credentials.put("username", username);
		credentials.put("password", password);
	}
	
	this.keyspace = HFactory.createKeyspace(
			keyspace, 
			cluster, 
			new AllOneConsistencyLevelPolicy(), 
			FailoverPolicy.ON_FAIL_TRY_ALL_AVAILABLE);
}
 
开发者ID:eBay,项目名称:cassandra-river,代码行数:20,代码来源:CassandraDB.java

示例5: setUp

import me.prettyprint.cassandra.service.CassandraHostConfigurator; //导入依赖的package包/类
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception {
    // default to using cassandra on localhost, but can be overridden with a system property
    String cassandraHosts = System.getProperty(CASSANDRA_HOSTS_SYSTEM_PROPERTY, EMBEDDED_CASSANDRA_HOST);
    String[] hosts = StringUtils.split(cassandraHosts, ",");
    numHosts = hosts.length;

    if (EMBEDDED_CASSANDRA_HOST.equals(cassandraHosts)) {
        EmbeddedCassandraServerHelper.startEmbeddedCassandra();
    }

    // default cluster name can also be overridden with a system property
    String clusterName = System.getProperty(CLUSTER_NAME_PROPERTY, TEST_CLUSTER);

    hostConfigurator = new CassandraHostConfigurator(cassandraHosts);
    cluster = HFactory.getOrCreateCluster(clusterName, hostConfigurator);
    keyspace = HFactory.createKeyspace(TEST_KEYSPACE, cluster);

    dropAndCreateSchema();
    sleepAfterSchemaChangeIfNecessary();
}
 
开发者ID:ezoerner,项目名称:c-star-path-j,代码行数:22,代码来源:AbstractCassandraThriftSystemTest.java

示例6: initialize

import me.prettyprint.cassandra.service.CassandraHostConfigurator; //导入依赖的package包/类
public void initialize(Class<K> keyClass, Class<T> persistentClass) throws Exception {
  this.keyClass = keyClass;

  // get cassandra mapping with persistent class
  this.persistentClass = persistentClass;
  this.cassandraMapping = CassandraMappingManager.getManager().get(persistentClass);
  // LOG.info("persistentClass=" + persistentClass.getName() + " -> cassandraMapping=" + cassandraMapping);

  this.cluster = HFactory.getOrCreateCluster(this.cassandraMapping.getClusterName(), new CassandraHostConfigurator(this.cassandraMapping.getHostName()));
  
  // add keyspace to cluster
  checkKeyspace();
  
  // Just create a Keyspace object on the client side, corresponding to an already existing keyspace with already created column families.
  this.keyspace = HFactory.createKeyspace(this.cassandraMapping.getKeyspaceName(), this.cluster);
  
  this.keySerializer = GoraSerializerTypeInferer.getSerializer(keyClass);
  this.mutator = HFactory.createMutator(this.keyspace, this.keySerializer);
}
 
开发者ID:maestros,项目名称:gora-oraclenosql,代码行数:20,代码来源:CassandraClient.java

示例7: getCluster

import me.prettyprint.cassandra.service.CassandraHostConfigurator; //导入依赖的package包/类
/**
 * Create a hector cluster instance for an existing Cassandra cluster with the given configuration.
 * Default values for {@code CassandraHostConfigurator} are configured in properties.
 *
 * @param clusterName         cluster name. This is an identifying string for the cluster.
 *                            Clusters will be created on demand per each unique clusterName
 * @param activeClients       The maximum number of active clients to allowkey.
 * @param thriftSocketTimeout Cassandra Thrift Socket Timeout (in milliseconds)
 * @return cluster object
 * @see <a href="https://github.com/hector-client/hector/wiki/User-Guide#finer-grained-configuration">Hector config</a>
 */
public Cluster getCluster(String clusterName, int activeClients, int thriftSocketTimeout) {
    logger.info("Bootstrapping hector cluster client for " + clusterName);
    CassandraHostConfigurator config = new CassandraHostConfigurator();
    String hostStr = collectionToCommaDelimitedString(resolveHosts(clusterHosts,
            getProp("host_resolve", Boolean.class, true),
            getProp("host_ipv4", Boolean.class, true)));
    config.setHosts(hostStr);
    config.setPort(clusterPort);
    config.setUseThriftFramedTransport(getProp("thrift", Boolean.class, true));
    config.setUseSocketKeepalive(getProp("keep_alive", Boolean.class, true));
    config.setCassandraThriftSocketTimeout(thriftSocketTimeout);
    config.setMaxActive(activeClients);
    config.setExhaustedPolicy(ExhaustedPolicy.valueOf(getProp("exhausted_policy", String.class, WHEN_EXHAUSTED_GROW.toString())));
    config.setMaxWaitTimeWhenExhausted(getProp("exhausted_waittime", Integer.class, -1));
    config.setUseHostTimeoutTracker(getProp("ht_tracker", Boolean.class, true));
    config.setHostTimeoutCounter(getProp("ht_count", Integer.class, 3));
    config.setRetryDownedHosts(getProp("retry_hosts", Boolean.class, true));
    config.setRetryDownedHostsDelayInSeconds(getProp("retry_hosts_delay", Integer.class, 60));
    boolean autoDiscovery = getProp("auto_discovery", Boolean.class, false);
    config.setAutoDiscoverHosts(autoDiscovery);
    if (autoDiscovery) {
        config.setRunAutoDiscoveryAtStartup(true);
        config.setAutoDiscoveryDelayInSeconds(60);
    }

    logger.info(config.toString());
    Cluster cluster = HFactory.createCluster(clusterName, config);
    logger.info("Known pool hosts for " + clusterName + " cluster is " + cluster.getKnownPoolHosts(true));
    if (cluster.getKnownPoolHosts(true).size() == 0) {
    	logger.error("shutdown due to empty cluster.getKnownPoolHosts - hector doesnt throw java.net.ConnectException: Connection refused");
    }
    return cluster;
}
 
开发者ID:oneops,项目名称:oneops,代码行数:45,代码来源:ClusterBootstrap.java

示例8: initialize

import me.prettyprint.cassandra.service.CassandraHostConfigurator; //导入依赖的package包/类
/**
 * Given our key, persistentClass from 
 * {@link org.apache.gora.cassandra.store.CassandraStore#initialize(Class, Class, Properties)}
 * we make best efforts to dictate our data model. 
 * We make a quick check within {@link org.apache.gora.cassandra.store.CassandraClient#checkKeyspace(String)
 * to see if our keyspace has already been invented, this simple check prevents us from 
 * recreating the keyspace if it already exists. 
 * We then simple specify (based on the input keyclass) an appropriate serializer
 * via {@link org.apache.gora.cassandra.serializers.GoraSerializerTypeInferer} before
 * defining a mutator from and by which we can mutate this object.
 * @param keyClass the Key by which we wish o assign a record object
 * @param persistentClass the generated {@link org.apache.org.gora.persistency.Peristent} bean representing the data.
 * @param properties key value pairs from gora.properties
 * @throws Exception
 */
public void initialize(Class<K> keyClass, Class<T> persistentClass, Properties properties) throws Exception {
  this.keyClass = keyClass;

  // get cassandra mapping with persistent class
  this.persistentClass = persistentClass;
  this.cassandraMapping = CassandraMappingManager.getManager().get(persistentClass);
  Map<String, String> accessMap = null;
  if (properties != null) {
    String username = properties
        .getProperty("gora.cassandrastore.username");
    if (username != null) {
      accessMap = new HashMap<>();
      accessMap.put("username", username);
      String password = properties
          .getProperty("gora.cassandrastore.password");
      if (password != null) {
        accessMap.put("password", password);
      }
    }
  }

  this.cluster = HFactory.getOrCreateCluster(this.cassandraMapping.getClusterName(), 
      new CassandraHostConfigurator(this.cassandraMapping.getHostName()), accessMap);
  
  // add keyspace to cluster
  checkKeyspace();
  
  // Just create a Keyspace object on the client side, corresponding to an already 
  // existing keyspace with already created column families.
  this.keyspace = HFactory.createKeyspace(this.cassandraMapping.getKeyspaceName(), this.cluster);
  
  this.keySerializer = GoraSerializerTypeInferer.getSerializer(keyClass);
  if (this.keySerializer == null)
    LOG.error("Serializer for " + keyClass + " not found.");
  this.mutator = HFactory.createMutator(this.keyspace, this.keySerializer);
}
 
开发者ID:jianglibo,项目名称:gora-boot,代码行数:52,代码来源:CassandraClient.java

示例9: accept

import me.prettyprint.cassandra.service.CassandraHostConfigurator; //导入依赖的package包/类
@Override
public void accept(final Configuration<Map<String, Object>> configuration) {
	_hosts = configuration.getAttribute(HOSTS, "127.0.0.1:9160");
	_keyspaceName = configuration.getAttribute(KEYSPACE, "KeyspaceCumulus") + _keyspaceNameSuffix;
	_replicationFactor = configuration.getAttribute(REPLICATION_FACTOR, Integer.valueOf(1));
	_readConsistency = configuration.getAttribute(READ_CONSISTENCY, "ONE");
	_writeConsistency = configuration.getAttribute(WRITE_CONSISTENCY, "ONE");
	
	final CassandraHostConfigurator config = new CassandraHostConfigurator(_hosts);

	config.setRetryDownedHosts(configuration.getAttribute(RETRY_DOWNED_HOSTS, Boolean.TRUE));

	final Integer socketTimeout = configuration.getAttribute(THRIFT_SOCKET_TIMEOUT, null);
	if (socketTimeout != null) {
		config.setCassandraThriftSocketTimeout(socketTimeout);
	}
	
	config.setRetryDownedHostsDelayInSeconds(configuration.getAttribute(RETRY_DOWNED_HOSTS_DELAY_IN_SECONDS, Integer.valueOf(10)));
	config.setRetryDownedHostsQueueSize(configuration.getAttribute(RETRY_DOWNED_HOSTS_QUEUE_SIZE, Integer.valueOf(256)));
	
	
	config.setMaxWaitTimeWhenExhausted(configuration.getAttribute(MAX_WAIT_TIME_WHEN_EXHAUSTED, Integer.valueOf(0)));
	
	final String lbPolicy = configuration.getAttribute(LOAD_BALANCING_POLICY, null);
	if (lbPolicy != null) {
		try {
			config.setLoadBalancingPolicy((LoadBalancingPolicy) Class.forName(lbPolicy).newInstance());				
		} catch (Exception ignore) {
			// Just use the default value
		}
	}
	
	_cluster = HFactory.getOrCreateCluster("CumulusRDFCluster", config);		
}
 
开发者ID:cumulusrdf,项目名称:cumulusrdf,代码行数:35,代码来源:CumulusDataAccessLayerFactory.java

示例10: configureHectorPools

import me.prettyprint.cassandra.service.CassandraHostConfigurator; //导入依赖的package包/类
private void configureHectorPools() {

		final String listOfNodesAndPorts = getListOfNodesAndPorts(locationURLs, ports);

		CassandraHostConfigurator cassandraHostConfigurator = createCassandraConfigurator();
		cassandraHostConfigurator.setHosts(listOfNodesAndPorts);
		log.info("Hector pool created for " + listOfNodesAndPorts);

		if (StringUtils.isNotBlank(username) && StringUtils.isNotBlank(password)) {
			Map<String, String> accessMap = new HashMap<>();
			accessMap.put("username", this.username);
			accessMap.put("password", this.password);
			cluster = HFactory.getOrCreateCluster(clusterName, cassandraHostConfigurator, accessMap);
		} else {
			cluster = HFactory.getOrCreateCluster(clusterName, cassandraHostConfigurator);
		}

		keysp = HFactory.createKeyspace(keyspace, cluster, consistencyLevel);

		columnFamilyTemplates.add(new ThriftColumnFamilyTemplate<K, String>(keysp, columnFamily, keySerializer, StringSerializer.get()));

		// now, if we have secondary indexed columns, then go ahead and create its own column family template.
		if (isSecondaryIndexesByColumnNamesEnabled || (columnsToIndexOnColumnNameAndValue != null && columnsToIndexOnColumnNameAndValue.size() > 0)) {
			String secondaryIndexColumnFamilyProperty = HecubaConstants.getSecondaryIndexColumnFamilyProperty(columnFamily);
			String defaultSecondaryIndexColumnFamily = columnFamily + HecubaConstants.SECONDARY_INDEX_CF_NAME_SUFFIX;
			String secondaryIndexedColumnFamily = ConfigUtils.getInstance().getConfiguration().getString(secondaryIndexColumnFamilyProperty, defaultSecondaryIndexColumnFamily);
			secondaryIndexedColumnFamilyTemplate = new ThriftColumnFamilyTemplate<String, K>(keysp, secondaryIndexedColumnFamily, StringSerializer.get(), keySerializer);
		}

	}
 
开发者ID:WizeCommerce,项目名称:hecuba,代码行数:31,代码来源:HectorBasedHecubaClientManager.java

示例11: initialize

import me.prettyprint.cassandra.service.CassandraHostConfigurator; //导入依赖的package包/类
@PostConstruct
public void initialize() {
    String cassandraHosts = env.getProperty("ea.cassandra.hosts","localhost:9160");
    CassandraHostConfigurator hostConfigurator = new CassandraHostConfigurator(cassandraHosts);
    hostConfigurator.setAutoDiscoverHosts(false);
    hostConfigurator.setMaxActive(env.getProperty("ea.cassandra.maxActive",Integer.class,Runtime.getRuntime().availableProcessors() * 3));
    hostConfigurator.setRetryDownedHosts(true);
    hostConfigurator.setRetryDownedHostsDelayInSeconds(env.getProperty("ea.cassandra.retryDownedHostsDelayInSeconds",Integer.class,1));
    hostConfigurator.setMaxWaitTimeWhenExhausted(2000L);
    String cassandraClusterName = env.getProperty("ea.cassandra.cluster","ElasticActorsCluster");
    // it seems that there are issues with the CassandraHostRetryService and retrying downed hosts
    // if we don't let the HFactory manage the cluster then CassandraHostRetryService doesn't try to
    // be smart about finding out if a host was removed from the ring and so it will keep on retrying
    // all configured hosts (and ultimately fail-back when the host comes back online)
    // the default is TRUE, which will let HFactory manage the cluster
    Boolean manageClusterThroughHFactory = env.getProperty("ea.cassandra.hfactory.manageCluster", Boolean.class, Boolean.TRUE);
    Cluster cluster;
    if(manageClusterThroughHFactory) {
        cluster = HFactory.getOrCreateCluster(cassandraClusterName, hostConfigurator);
    } else {
        cluster = new ThriftCluster(cassandraClusterName, hostConfigurator, null);
    }
    String cassandraKeyspaceName = env.getProperty("ea.cassandra.keyspace","ElasticActors");
    Keyspace keyspace = HFactory.createKeyspace(cassandraKeyspaceName,cluster);
    persistentActorsColumnFamilyTemplate =
        new ThriftColumnFamilyTemplate<>(keyspace,"PersistentActors", CompositeSerializer.get(),StringSerializer.get());
    scheduledMessagesColumnFamilyTemplate =
        new ThriftColumnFamilyTemplate<>(keyspace,"ScheduledMessages",CompositeSerializer.get(), CompositeSerializer.get());
    actorSystemEventListenersColumnFamilyTemplate =
            new ThriftColumnFamilyTemplate<>(keyspace,"ActorSystemEventListeners", CompositeSerializer.get(),StringSerializer.get());
    // return
    // @TODO: make this configurable and use the ColumnSliceIterator
    scheduledMessagesColumnFamilyTemplate.setCount(Integer.MAX_VALUE);
    actorSystemEventListenersColumnFamilyTemplate.setCount(Integer.MAX_VALUE);
}
 
开发者ID:elasticsoftwarefoundation,项目名称:elasticactors,代码行数:36,代码来源:BackplaneConfiguration.java

示例12: CassandraService

import me.prettyprint.cassandra.service.CassandraHostConfigurator; //导入依赖的package包/类
public CassandraService( Properties properties, Cluster cluster,
                         CassandraHostConfigurator cassandraHostConfigurator,
                       final Injector injector) {
    this.properties = properties;
    this.cluster = cluster;
    chc = cassandraHostConfigurator;
    lockManager = injector.getInstance( LockManager.class );
    db_logger.info( "{}", cluster.getKnownPoolHosts( false ) );
    //getInjector
    applicationKeyspace  = injector.getInstance( CassandraFig.class ).getApplicationKeyspace();
}
 
开发者ID:apache,项目名称:usergrid,代码行数:12,代码来源:CassandraService.java

示例13: getOrCreateCluster

import me.prettyprint.cassandra.service.CassandraHostConfigurator; //导入依赖的package包/类
@Override public Cluster getOrCreateCluster(String clusterName, String host, int maxActiveConnections, long maxConnectTimeMillis, int cassandraThriftSocketTimeout) {
    CassandraHostConfigurator configurator = new CassandraHostConfigurator(host);
    configurator.setMaxActive(maxActiveConnections);
    configurator.setMaxConnectTimeMillis(maxConnectTimeMillis);
    configurator.setCassandraThriftSocketTimeout(cassandraThriftSocketTimeout);

    return HFactory.getOrCreateCluster(clusterName, configurator);
}
 
开发者ID:appmetr,项目名称:hercules,代码行数:9,代码来源:ThriftDataDriver.java

示例14: newCluster

import me.prettyprint.cassandra.service.CassandraHostConfigurator; //导入依赖的package包/类
private static Cluster newCluster() {

        String hostUrl = randomizeHosts(CONNECTION_STRING);
        CassandraHostConfigurator cf = new CassandraHostConfigurator(hostUrl);
        cf.setAutoDiscoverHosts(true);
        return HFactory.getOrCreateCluster("QubitCluster", cf);
    }
 
开发者ID:xuzhikethinker,项目名称:t4f-data,代码行数:8,代码来源:CassandraStresser.java

示例15: HectorConfiguration

import me.prettyprint.cassandra.service.CassandraHostConfigurator; //导入依赖的package包/类
@Inject
public HectorConfiguration(@Named(HOST_LIST_PROPERTY) String cassandraHostList)
{
	hostConfig = new CassandraHostConfigurator(cassandraHostList);
}
 
开发者ID:quqiangsheng,项目名称:abhot,代码行数:6,代码来源:HectorConfiguration.java


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