本文整理汇总了Java中me.prettyprint.cassandra.model.ConfigurableConsistencyLevel类的典型用法代码示例。如果您正苦于以下问题:Java ConfigurableConsistencyLevel类的具体用法?Java ConfigurableConsistencyLevel怎么用?Java ConfigurableConsistencyLevel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConfigurableConsistencyLevel类属于me.prettyprint.cassandra.model包,在下文中一共展示了ConfigurableConsistencyLevel类的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);
}
示例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());
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
}