.buildCluster(ThriftFamilyFactory.getInstance());
clusterContext.start();
if (TEST_INIT_KEYSPACE) {
Cluster cluster = clusterContext.getEntity();
try {
LOG.info("Dropping keyspace: " + TEST_KEYSPACE_NAME);
cluster.dropKeyspace(TEST_KEYSPACE_NAME);
Thread.sleep(10000);
} catch (ConnectionException e) {
LOG.warn(e.getMessage());
}
Map<String, String> stratOptions = new HashMap<String, String>();
stratOptions.put("replication_factor", "3");
try {
LOG.info("Creating keyspace: " + TEST_KEYSPACE_NAME);
KeyspaceDefinition ksDef = cluster.makeKeyspaceDefinition();
ksDef.setName(TEST_KEYSPACE_NAME)
.setStrategyOptions(stratOptions)
.setStrategyClass("SimpleStrategy")
.addColumnFamily(
cluster.makeColumnFamilyDefinition()
.setName(CF_DATA.getName())
.setComparatorType("UTF8Type")
// .setKeyValidationClass("LongType")
// .setDefaultValidationClass("BytesType")
)
.addColumnFamily(
cluster.makeColumnFamilyDefinition()
.setName(CF_INDEX.getName())
.setComparatorType(
"CompositeType(LongType, LongType)")
.setDefaultValidationClass("BytesType"));
cluster.addKeyspace(ksDef);
Thread.sleep(2000);
populateKeyspace();
} catch (ConnectionException e) {
LOG.error(e.getMessage());
}