本文整理汇总了Java中me.prettyprint.hector.api.HConsistencyLevel类的典型用法代码示例。如果您正苦于以下问题:Java HConsistencyLevel类的具体用法?Java HConsistencyLevel怎么用?Java HConsistencyLevel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HConsistencyLevel类属于me.prettyprint.hector.api包,在下文中一共展示了HConsistencyLevel类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: init
import me.prettyprint.hector.api.HConsistencyLevel; //导入依赖的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: testCassandraConsistencyPolicy
import me.prettyprint.hector.api.HConsistencyLevel; //导入依赖的package包/类
@Test
public void testCassandraConsistencyPolicy() {
Configuration configuration = ConfigUtils.getInstance().getConfiguration();
// The default configuration should be to set the consistency policies
// to Read.ONE and Write.ONE
HectorConsistencyPolicy policy = new HectorConsistencyPolicy("NoCF");
assertEquals(HConsistencyLevel.ONE, policy.get(OperationType.READ));
assertEquals(HConsistencyLevel.ONE, policy.get(OperationType.WRITE));
// Now set explicit policies and test those.
// Start with read properties.
checkOperationConfigurationLoading(configuration,
HecubaConstants.GLOBAL_PROP_NAME_PREFIX + ".consistencypolicy.read",
OperationType.READ);
checkOperationConfigurationLoading(configuration,
HecubaConstants.GLOBAL_PROP_NAME_PREFIX + ".consistencypolicy.write",
OperationType.WRITE);
}
开发者ID:WizeCommerce,项目名称:hecuba,代码行数:23,代码来源:HectorConsistencyPolicyTest.java
示例3: prepare
import me.prettyprint.hector.api.HConsistencyLevel; //导入依赖的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
示例4: getOrCreateKeyspace
import me.prettyprint.hector.api.HConsistencyLevel; //导入依赖的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
示例5: init
import me.prettyprint.hector.api.HConsistencyLevel; //导入依赖的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
示例6: init
import me.prettyprint.hector.api.HConsistencyLevel; //导入依赖的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
示例7: getConsisLevelForColFams
import me.prettyprint.hector.api.HConsistencyLevel; //导入依赖的package包/类
/**
* Method in charge of setting the consistency level for defined column families.
* @param pColFams Column families
* @return Map<String, HConsistencyLevel> with the mapping between colFams and consistency level.
*/
private Map<String, HConsistencyLevel> getConsisLevelForColFams(List<ColumnFamilyDefinition> pColFams) {
Map<String, HConsistencyLevel> clMap = new HashMap<>();
// Get columnFamily consistency level.
String colFamConsisLvl = (colFamConsLvl != null && !colFamConsLvl.isEmpty())?colFamConsLvl:DEFAULT_HECTOR_CONSIS_LEVEL;
LOG.debug("ColumnFamily consistency level configured to '" + colFamConsisLvl + "'.");
// Define consistency for ColumnFamily "ColumnFamily"
for (ColumnFamilyDefinition colFamDef : pColFams)
clMap.put(colFamDef.getName(), HConsistencyLevel.valueOf(colFamConsisLvl));
return clMap;
}
开发者ID:jianglibo,项目名称:gora-boot,代码行数:16,代码来源:CassandraClient.java
示例8: configureConsistencyLevel
import me.prettyprint.hector.api.HConsistencyLevel; //导入依赖的package包/类
private HConsistencyLevel configureConsistencyLevel(String columnFamilyName, String operation) {
// first get the default consistency policy.
String[] consistencyPolicyProperties = HecubaConstants.getConsistencyPolicyProperties(columnFamilyName, operation);
String consistencyParameter = "ONE";
for (String property : consistencyPolicyProperties) {
consistencyParameter = ConfigUtils.getInstance().getConfiguration().getString(property, consistencyParameter);
}
return StringUtils.isEmpty(consistencyParameter) ? HConsistencyLevel.ONE : HConsistencyLevel.valueOf(consistencyParameter);
}
开发者ID:WizeCommerce,项目名称:hecuba,代码行数:11,代码来源:HectorConsistencyPolicy.java
示例9: get
import me.prettyprint.hector.api.HConsistencyLevel; //导入依赖的package包/类
@Override
public HConsistencyLevel get(OperationType operationType) {
switch (operationType) {
case READ:
return readConsistency;
case WRITE:
return writeConsistency;
default:
return HConsistencyLevel.ONE; // Just in Case
}
}
开发者ID:WizeCommerce,项目名称:hecuba,代码行数:12,代码来源:HectorConsistencyPolicy.java
示例10: checkOperationConfigurationLoading
import me.prettyprint.hector.api.HConsistencyLevel; //导入依赖的package包/类
private void checkOperationConfigurationLoading(Configuration configuration, String operationProperty,
OperationType operationType) {
HectorConsistencyPolicy policy;
for (HConsistencyLevel consistencyLevel : HConsistencyLevel.values()) {
configuration.setProperty(operationProperty, consistencyLevel.toString());
policy = new HectorConsistencyPolicy("NoCF");
assertEquals("Error handling consistency level " + consistencyLevel.toString() +
" within HectorConsistencyPolicy.", consistencyLevel, policy.get(operationType));
}
}
开发者ID:WizeCommerce,项目名称:hecuba,代码行数:11,代码来源:HectorConsistencyPolicyTest.java
注:本文中的me.prettyprint.hector.api.HConsistencyLevel类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论