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


Java ConfigurableConsistencyLevel.setDefaultReadConsistencyLevel方法代码示例

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


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

示例1: init

import me.prettyprint.cassandra.model.ConfigurableConsistencyLevel; //导入方法依赖的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: prepare

import me.prettyprint.cassandra.model.ConfigurableConsistencyLevel; //导入方法依赖的package包/类
@Override
public void prepare(Map stormConf, TopologyContext context,
		OutputCollector collector) {
	ouc = collector;
	// load from properties file
	Properties prop = new Properties();
	try {
		prop.load(new FileInputStream("config.properties"));
	} catch (IOException ex) {
		log.error(ex.toString());
	}
	
	//cassandra configuration
	cluster = HFactory.getOrCreateCluster(
			prop.getProperty("CLUSTERNAME"), prop.getProperty("HOST"));
	ConfigurableConsistencyLevel ccl = new ConfigurableConsistencyLevel();
	ccl.setDefaultReadConsistencyLevel(HConsistencyLevel.ONE);
	keyspace = HFactory.createKeyspace("links", cluster, ccl,
			FailoverPolicy.FAIL_FAST);
	mutator = HFactory.createMutator(keyspace, StringSerializer.get());
}
 
开发者ID:mvogiatzis,项目名称:storm-unshortening,代码行数:22,代码来源:CassandraBolt.java

示例3: getOrCreateKeyspace

import me.prettyprint.cassandra.model.ConfigurableConsistencyLevel; //导入方法依赖的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

示例4: init

import me.prettyprint.cassandra.model.ConfigurableConsistencyLevel; //导入方法依赖的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

示例5: init

import me.prettyprint.cassandra.model.ConfigurableConsistencyLevel; //导入方法依赖的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

示例6: CassandraDatastore

import me.prettyprint.cassandra.model.ConfigurableConsistencyLevel; //导入方法依赖的package包/类
@Inject
public CassandraDatastore(@Named("HOSTNAME") final String hostname,
		CassandraConfiguration cassandraConfiguration,
		HectorConfiguration configuration,
		KairosDataPointFactory kairosDataPointFactory) throws DatastoreException
{
	try
	{
		m_cassandraConfiguration = cassandraConfiguration;
		m_singleRowReadSize = m_cassandraConfiguration.getSingleRowReadSize();
		m_multiRowSize = m_cassandraConfiguration.getMultiRowSize();
		m_multiRowReadSize = m_cassandraConfiguration.getMultiRowReadSize();
		m_kairosDataPointFactory = kairosDataPointFactory;
		m_keyspaceName = m_cassandraConfiguration.getKeyspaceName();

		m_rowKeyCache = new DataCache<DataPointsRowKey>(m_cassandraConfiguration.getRowKeyCacheSize());
		m_metricNameCache = new DataCache<String>(m_cassandraConfiguration.getStringCacheSize());
		m_tagNameCache = new DataCache<String>(m_cassandraConfiguration.getStringCacheSize());
		m_tagValueCache = new DataCache<String>(m_cassandraConfiguration.getStringCacheSize());

		CassandraHostConfigurator hostConfig = configuration.getConfiguration();
		int threadCount = hostConfig.buildCassandraHosts().length + 3;

		m_cluster = HFactory.getOrCreateCluster("kairosdb-cluster",
				hostConfig, m_cassandraConfiguration.getCassandraAuthentication());

		KeyspaceDefinition keyspaceDef = m_cluster.describeKeyspace(m_keyspaceName);

		if (keyspaceDef == null)
		{
			createSchema(m_cassandraConfiguration.getReplicationFactor());
		}

		//set global consistency level
		ConfigurableConsistencyLevel confConsLevel = new ConfigurableConsistencyLevel();
		confConsLevel.setDefaultReadConsistencyLevel(m_cassandraConfiguration.getDataReadLevel().getHectorLevel());
		confConsLevel.setDefaultWriteConsistencyLevel(m_cassandraConfiguration.getDataWriteLevel().getHectorLevel());

		//create keyspace instance with specified consistency
		m_keyspace = HFactory.createKeyspace(m_keyspaceName, m_cluster, confConsLevel);

		ReentrantLock mutatorLock = new ReentrantLock();

		m_dataPointWriteBuffer = new WriteBuffer<DataPointsRowKey, Integer, byte[]>(
				m_keyspace, CF_DATA_POINTS, m_cassandraConfiguration.getWriteDelay(),
				m_cassandraConfiguration.getMaxWriteSize(),
				DATA_POINTS_ROW_KEY_SERIALIZER,
				IntegerSerializer.get(),
				BytesArraySerializer.get(),
				createWriteBufferStats(CF_DATA_POINTS, hostname),
				mutatorLock, threadCount,
				m_cassandraConfiguration.getWriteBufferJobQueueSize());

		m_rowKeyWriteBuffer = new WriteBuffer<String, DataPointsRowKey, String>(
				m_keyspace, CF_ROW_KEY_INDEX, m_cassandraConfiguration.getWriteDelay(),
				m_cassandraConfiguration.getMaxWriteSize(),
				StringSerializer.get(),
				DATA_POINTS_ROW_KEY_SERIALIZER,
				StringSerializer.get(),
				createWriteBufferStats(CF_ROW_KEY_INDEX, hostname),
				mutatorLock, threadCount,
				m_cassandraConfiguration.getWriteBufferJobQueueSize());

		m_stringIndexWriteBuffer = new WriteBuffer<String, String, String>(
				m_keyspace, CF_STRING_INDEX,
				m_cassandraConfiguration.getWriteDelay(),
				m_cassandraConfiguration.getMaxWriteSize(),
				StringSerializer.get(),
				StringSerializer.get(),
				StringSerializer.get(),
				createWriteBufferStats(CF_STRING_INDEX, hostname),
				mutatorLock, threadCount,
				m_cassandraConfiguration.getWriteBufferJobQueueSize());
	}
	catch (HectorException e)
	{
		throw new DatastoreException(e);
	}
}
 
开发者ID:quqiangsheng,项目名称:abhot,代码行数:80,代码来源:CassandraDatastore.java


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