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


Java Cluster类代码示例

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


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

示例1: init

import me.prettyprint.hector.api.Cluster; //导入依赖的package包/类
/**
 * Bean post init method. The following configuration is used
 * for initializing the ThresholdsDao cassandra cluster,
 * <p>
 * <ul>
 * <li>Active clients per node - 4</li>
 * <li>Cassandra Thrift timeout - 600 sec</li>
 * </ul>
 */
public void init() {
    logger.info("Initializing Monitor Thresholds Dao...");

    Cluster cluster = cb.getCluster(clusterName, 4, timeout);
    logger.info("Connected to cluster : " + clusterName);

    SchemaBuilder.createSchema(cluster, keyspaceName);
    ConfigurableConsistencyLevel cl = new ConfigurableConsistencyLevel();
    cl.setDefaultWriteConsistencyLevel(HConsistencyLevel.ONE);
    cl.setDefaultReadConsistencyLevel(HConsistencyLevel.ONE);

    keyspace = HFactory.createKeyspace(keyspaceName, cluster, cl);
    thresholdMutator = HFactory.createMutator(keyspace, longSerializer);
    manifestMapMutator = HFactory.createMutator(keyspace, longSerializer);
    realizedAsMutator = HFactory.createMutator(keyspace, longSerializer);
}
 
开发者ID:oneops,项目名称:oneops,代码行数:26,代码来源:ThresholdsDao.java

示例2: createKeyspace

import me.prettyprint.hector.api.Cluster; //导入依赖的package包/类
/** Creates the keyspace. */
private void createKeyspace(Cluster cluster) {
	ColumnFamilyDefinition cfDef = HFactory.createColumnFamilyDefinition(
			KEYSPACE_NAME, COLUMN_FAMILY_NAME, ComparatorType.BYTESTYPE);
	cfDef.setGcGraceSeconds(1);
	cfDef.setCompactionStrategy("LeveledCompactionStrategy");

	BasicColumnDefinition column = new BasicColumnDefinition();
	column.setName(StringSerializer.get().toByteBuffer(COLUMN_NAME));
	column.setValidationClass(ComparatorType.BYTESTYPE.getClassName());
	cfDef.addColumnDefinition(column);

	KeyspaceDefinition newKeyspace = HFactory.createKeyspaceDefinition(
			KEYSPACE_NAME, ThriftKsDef.DEF_STRATEGY_CLASS, 1,
			Arrays.asList(cfDef));
	cluster.addKeyspace(newKeyspace, true);
}
 
开发者ID:vimaier,项目名称:conqat,代码行数:18,代码来源:CassandraStorageSystem.java

示例3: retrieveCassandraCluster

import me.prettyprint.hector.api.Cluster; //导入依赖的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

示例4: getCurrentCassandraCluster

import me.prettyprint.hector.api.Cluster; //导入依赖的package包/类
private Cluster getCurrentCassandraCluster() throws SummarizerException {
    LoggingConfig config;
    try {
        config = LoggingConfigManager.loadLoggingConfiguration();
    } catch (Exception e) {
        throw new SummarizerException("Cannot read the Summarizer config file", e);
    }
    String connectionUrl = config.getCassandraHost();
    String userName = config.getCassUsername();
    String password = config.getCassPassword();
    String clusterName = config.getCluster();
    Map<String, String> credentials = new HashMap<String, String>();
    credentials.put(SummarizingConstants.USERNAME_KEY, userName);
    credentials.put(SummarizingConstants.PASSWORD_KEY, password);
    return getCluster(clusterName, connectionUrl, credentials);
}
 
开发者ID:wso2,项目名称:carbon-commons,代码行数:17,代码来源:ColumnFamilyHandler.java

示例5: getOrCreateKeyspace

import me.prettyprint.hector.api.Cluster; //导入依赖的package包/类
@Override public Keyspace getOrCreateKeyspace(String keyspaceName, int replicationFactor, Cluster cluster) {
    KeyspaceDefinition keyspaceDef = cluster.describeKeyspace(keyspaceName);
    List<ColumnFamilyDefinition> cfDefs = new LinkedList<ColumnFamilyDefinition>();
    // If keyspace does not exist create it without CFs.
    if (keyspaceDef == null) {
        keyspaceDef = HFactory.createKeyspaceDefinition(keyspaceName, ThriftKsDef.DEF_STRATEGY_CLASS, replicationFactor, cfDefs);
        cluster.addKeyspace(keyspaceDef);
    }

    Keyspace keyspace = HFactory.createKeyspace(keyspaceName, cluster);

    ConfigurableConsistencyLevel consistencyLevel = new ConfigurableConsistencyLevel();
    consistencyLevel.setDefaultReadConsistencyLevel(HConsistencyLevel.QUORUM);
    consistencyLevel.setDefaultWriteConsistencyLevel(HConsistencyLevel.QUORUM);
    keyspace.setConsistencyLevelPolicy(consistencyLevel);

    return keyspace;
}
 
开发者ID:appmetr,项目名称:hercules,代码行数:19,代码来源:ThriftDataDriver.java

示例6: init

import me.prettyprint.hector.api.Cluster; //导入依赖的package包/类
/**
 * Bean post init method. The following configuration is used
 * for initializing the OpsEventDao cassandra cluster,
 * <p>
 * <ul>
 * <li>Active clients per node - 4</li>
 * <li>Cassandra Thrift timeout - 5 sec </li>
 * </ul>
 */
public void init() {
    logger.info("Initializing OpsEvent Dao...");
    Cluster cluster = cb.getCluster(clusterName, 4, 5 * 1000);
    logger.info("Connected to cluster : " + clusterName);

    SchemaBuilder.createSchema(cluster, keyspaceName);
    ConfigurableConsistencyLevel cl = new ConfigurableConsistencyLevel();
    cl.setDefaultWriteConsistencyLevel(HConsistencyLevel.ONE);
    cl.setDefaultReadConsistencyLevel(HConsistencyLevel.ONE);
    keyspace = createKeyspace(keyspaceName, cluster, cl);
    eventMutator = HFactory.createMutator(keyspace, bytesSerializer);
    ciMutator = HFactory.createMutator(keyspace, longSerializer);
    orphanCloseMutator = HFactory.createMutator(keyspace, longSerializer);
}
 
开发者ID:oneops,项目名称:oneops,代码行数:24,代码来源:OpsEventDao.java

示例7: init

import me.prettyprint.hector.api.Cluster; //导入依赖的package包/类
/**
 * Bean post init method. The following configuration is used
 * for initializing the OpsCiStateDao cassandra cluster,
 * <p/>
 * <ul>
 * <li>Active clients per node - 4</li>
 * <li>Cassandra Thrift timeout - 5 sec </li>
 * </ul>
 */
public void init() {
    logger.info("Initializing OpsCiState Dao...");
    Cluster cluster = cb.getCluster(clusterName, 4, 5 * 1000);
    logger.info("Connected to cluster : " + clusterName);

    SchemaBuilder.createSchema(cluster, keyspaceName);
    ConfigurableConsistencyLevel cl = new ConfigurableConsistencyLevel();
    HConsistencyLevel wrCL = System.getProperty("com.sensor.cistates.cl","LOCAL_QUORUM").equals("ONE") ? HConsistencyLevel.ONE :HConsistencyLevel.LOCAL_QUORUM;
    cl.setDefaultWriteConsistencyLevel(wrCL);
    cl.setDefaultReadConsistencyLevel(HConsistencyLevel.ONE);
    keyspace = createKeyspace(keyspaceName, cluster, cl);
    ciStateHistMutator = HFactory.createMutator(keyspace, longSerializer);
    componentStateMutator = HFactory.createMutator(keyspace, longSerializer);
}
 
开发者ID:oneops,项目名称:oneops,代码行数:24,代码来源:OpsCiStateDao.java

示例8: getCluster

import me.prettyprint.hector.api.Cluster; //导入依赖的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

示例9: clear

import me.prettyprint.hector.api.Cluster; //导入依赖的package包/类
@Override
public void clear() {
	final Cluster cluster = _dataAccessLayerFactory.getCluster();
	final String keyspaceName = _dataAccessLayerFactory.getKeyspaceName();
	cluster.truncate(keyspaceName, S_POC);
	cluster.truncate(keyspaceName, O_SPC);
	cluster.truncate(keyspaceName, PO_SC);
	cluster.truncate(keyspaceName, RN_SP_O);
	cluster.truncate(keyspaceName, RN_PO_S);
	cluster.truncate(keyspaceName, RDT_PO_S);		
	cluster.truncate(keyspaceName, RDT_SP_O);		
}
 
开发者ID:cumulusrdf,项目名称:cumulusrdf,代码行数:13,代码来源:Cassandra12xTripleIndexDAO.java

示例10: clear

import me.prettyprint.hector.api.Cluster; //导入依赖的package包/类
@Override
public void clear() {
	super.clear();

	final Cluster cluster = _dataAccessLayerFactory.getCluster();
	final String keyspaceName = _dataAccessLayerFactory.getKeyspaceName();
	cluster.truncate(keyspaceName, OC_PS);
	cluster.truncate(keyspaceName, SC_OP);
	cluster.truncate(keyspaceName, SPC_O);	
}
 
开发者ID:cumulusrdf,项目名称:cumulusrdf,代码行数:11,代码来源:Cassandra12xQuadIndexDAO.java

示例11: daoWasClosed

import me.prettyprint.hector.api.Cluster; //导入依赖的package包/类
/**
 * Informs the {@link DAOManager} that a DAO was closed. Shuts down the given cluster if all DAOs are closed.
 * 
 * @param cluster the cluster to shutdown if necessary.
 */
public synchronized void daoWasClosed(final Cluster cluster) {
	_daoCount--;

	if (_daoCount == 0) {
		HFactory.shutdownCluster(cluster);
	}
}
 
开发者ID:cumulusrdf,项目名称:cumulusrdf,代码行数:13,代码来源:DAOManager.java

示例12: CassandraStorageSystem

import me.prettyprint.hector.api.Cluster; //导入依赖的package包/类
/** Constructor. */
public CassandraStorageSystem(int port) throws StorageException {
	try {
		Cluster cluster = createCluster(port);
		if (cluster.describeKeyspace(KEYSPACE_NAME) == null) {
			createKeyspace(cluster);
		}
		keyspace = HFactory.createKeyspace(KEYSPACE_NAME, cluster);
		template = new ThriftColumnFamilyTemplate<byte[], String>(keyspace,
				COLUMN_FAMILY_NAME, BytesArraySerializer.get(),
				StringSerializer.get());
	} catch (HectorException e) {
		throw new StorageException(e);
	}
}
 
开发者ID:vimaier,项目名称:conqat,代码行数:16,代码来源:CassandraStorageSystem.java

示例13: createCluster

import me.prettyprint.hector.api.Cluster; //导入依赖的package包/类
/** Removes all data. This is used for testing. */
/* package */static void clearAllData() {
	// As this method is only used from tests, we can use the default port
	// here.
	Cluster cluster = createCluster(DEFAULT_PORT);
	if (cluster.describeKeyspace(KEYSPACE_NAME) != null) {
		cluster.dropKeyspace(KEYSPACE_NAME);
	}
}
 
开发者ID:vimaier,项目名称:conqat,代码行数:10,代码来源:CassandraStorageSystem.java

示例14: setup

import me.prettyprint.hector.api.Cluster; //导入依赖的package包/类
@Before
public void setup() {
	try {
		ConfigUtils.getInstance().getConfiguration().setProperty(HecubaConstants.GLOBAL_PROP_NAME_PREFIX + ".consistencypolicy.read", "ONE");
		ConfigUtils.getInstance().getConfiguration().setProperty(HecubaConstants.GLOBAL_PROP_NAME_PREFIX + ".consistencypolicy.write", "ONE");

		// Find the test methods that you have in the sub class.
		List<String> columnFamilyNames = getColumnFamilies(testName.getMethodName());

		// now load this information into Cassandra cluster.
		EmbeddedCassandraServerHelper.startEmbeddedCassandra();

		//wait until cluster is ready
		while (true) {
			Cluster cluster = HFactory.getOrCreateCluster(CLUSTER_NAME, LOCATION + ":" + PORT);
			logger.info("Cluster: {}, name: {}", cluster, CLUSTER_NAME);
			if (cluster != null && cluster.getConnectionManager().getActivePools().size() > 0) {
				break;
			} else {
				logger.info("Sleep {}ms to check if server is ready", cassandraServerWaitTime);
				Thread.sleep(cassandraServerWaitTime);
			}
		}

		DataLoader loader = new DataLoader(CLUSTER_NAME, LOCATION + ":" + PORT);
		loader.load(new StringXMLDataSet(createCassandraUnitConfigFile(columnFamilyNames)));
	} catch (ConfigurationException | TTransportException | IOException | InterruptedException e) {
		throw new RuntimeException(e);
	}
}
 
开发者ID:WizeCommerce,项目名称:hecuba,代码行数:31,代码来源:CassandraTestBase.java

示例15: createSchema

import me.prettyprint.hector.api.Cluster; //导入依赖的package包/类
private void createSchema(Cluster cluster, String keyspace) {
    ColumnFamilyDefinition cfDef = HFactory.createColumnFamilyDefinition(keyspace,
            COLUMN_FAMILY_NAME,
            ComparatorType.BYTESTYPE);

    KeyspaceDefinition newKeyspace = HFactory.createKeyspaceDefinition(keyspace,
            ThriftKsDef.DEF_STRATEGY_CLASS,
            1,
            Arrays.asList(cfDef));

    cluster.addKeyspace(newKeyspace, true);
}
 
开发者ID:ChaosXu,项目名称:rrd4j-cassandra,代码行数:13,代码来源:CassandraBackendFactory.java


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