*
* @see http://hector-client.github.io/hector/build/html/content/consistency_level.html
*/
public void checkKeyspace() {
// "describe keyspace <keyspaceName>;" query
KeyspaceDefinition keyspaceDefinition = this.cluster.describeKeyspace(this.cassandraMapping.getKeyspaceName());
if (keyspaceDefinition == null) {
List<ColumnFamilyDefinition> columnFamilyDefinitions = this.cassandraMapping.getColumnFamilyDefinitions();
// GORA-197
for (ColumnFamilyDefinition cfDef : columnFamilyDefinitions) {
cfDef.setComparatorType(ComparatorType.BYTESTYPE);
}
keyspaceDefinition = HFactory.createKeyspaceDefinition(
this.cassandraMapping.getKeyspaceName(),
this.cassandraMapping.getKeyspaceReplicationStrategy(),
this.cassandraMapping.getKeyspaceReplicationFactor(),
columnFamilyDefinitions
);
this.cluster.addKeyspace(keyspaceDefinition, true);
// GORA-167 Create a customized Consistency Level
ConfigurableConsistencyLevel ccl = new ConfigurableConsistencyLevel();
Map<String, HConsistencyLevel> clmap = getConsisLevelForColFams(columnFamilyDefinitions);
// Column family consistency levels
ccl.setReadCfConsistencyLevels(clmap);
ccl.setWriteCfConsistencyLevels(clmap);
// Operations consistency levels
String opConsisLvl = (readOpConsLvl!=null || !readOpConsLvl.isEmpty())?readOpConsLvl:DEFAULT_HECTOR_CONSIS_LEVEL;
ccl.setDefaultReadConsistencyLevel(HConsistencyLevel.valueOf(opConsisLvl));
LOG.debug("Hector read consistency configured to '" + opConsisLvl + "'.");
opConsisLvl = (writeOpConsLvl!=null || !writeOpConsLvl.isEmpty())?writeOpConsLvl:DEFAULT_HECTOR_CONSIS_LEVEL;
ccl.setDefaultWriteConsistencyLevel(HConsistencyLevel.valueOf(opConsisLvl));
LOG.debug("Hector write consistency configured to '" + opConsisLvl + "'.");
HFactory.createKeyspace("Keyspace", this.cluster, ccl);
keyspaceDefinition = null;
}
else {
List<ColumnFamilyDefinition> cfDefs = keyspaceDefinition.getCfDefs();
if (cfDefs == null || cfDefs.size() == 0) {
LOG.warn(keyspaceDefinition.getName() + " does not have any column family.");
}
else {
for (ColumnFamilyDefinition cfDef : cfDefs) {
ComparatorType comparatorType = cfDef.getComparatorType();
if (! comparatorType.equals(ComparatorType.BYTESTYPE)) {