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


Java CassandraHostConfigurator.setHosts方法代码示例

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


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

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

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

示例4: CassandraUserStoreManager

import me.prettyprint.cassandra.service.CassandraHostConfigurator; //导入方法依赖的package包/类
public CassandraUserStoreManager(RealmConfiguration realmConfig, int tenantId) throws UserStoreException {
    this.realmConfig = realmConfig;
    Util.setRealmConfig(realmConfig);
    this.tenantIdString = Integer.toString(tenantId);
    this.tenantId = tenantId;

    // Set groups read/write configuration
    if (realmConfig.getUserStoreProperty(UserCoreConstants.RealmConfig.READ_GROUPS_ENABLED) != null) {
        readGroupsEnabled = Boolean.parseBoolean(realmConfig
                .getUserStoreProperty(UserCoreConstants.RealmConfig.READ_GROUPS_ENABLED));
    }

    if (realmConfig.getUserStoreProperty(UserCoreConstants.RealmConfig.WRITE_GROUPS_ENABLED) != null) {
        writeGroupsEnabled = Boolean.parseBoolean(realmConfig
                .getUserStoreProperty(UserCoreConstants.RealmConfig.WRITE_GROUPS_ENABLED));
    } else {
        if (!isReadOnly()) {
            writeGroupsEnabled = true;
        }
    }
    if (writeGroupsEnabled) {
        readGroupsEnabled = true;
    }

    /*
     * Initialize user roles cache as implemented in AbstractUserStoreManager
     */
    initUserRolesCache();

    Map<String, String> credentials = new HashMap<String, String>();
    credentials.put(CFConstants.USERNAME_PROPERTY,
            realmConfig.getUserStoreProperty(CFConstants.USERNAME_XML_ATTRIB));
    credentials.put(CFConstants.PASSWORD_PROPERTY,
            realmConfig.getUserStoreProperty(CFConstants.PASSWORD_XML_ATTRIB));

    CassandraHostConfigurator hostConf = new CassandraHostConfigurator();
    hostConf.setHosts(realmConfig.getUserStoreProperty(CFConstants.HOST_XML_ATTRIB));
    hostConf.setPort(Integer.parseInt(realmConfig.getUserStoreProperty(CFConstants.PORT_XML_ATTRIB)));
    // set Cassandra specific properties
    cluster = HFactory.getOrCreateCluster(realmConfig.getUserStoreProperty(CFConstants.KEYSPACE_NAME_XML_ATTRIB),
            hostConf, credentials);
    keyspace = HFactory.createKeyspace(realmConfig.getUserStoreProperty(CFConstants.KEYSPACE_NAME_XML_ATTRIB),
            cluster);
    insertInitialData(keyspace);
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:46,代码来源:CassandraUserStoreManager.java


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