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


Java CassandraHostConfigurator.setCassandraThriftSocketTimeout方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

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


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