use of org.scale7.cassandra.pelops.KeyspaceManager in project scale7-pelops by s7.
the class AbstractIntegrationTest method setup.
/**
* Starts embedded cassandra server.
*
* @throws Exception
* if an error occurs
*/
public static void setup(List<CfDef> columnDefinitions) throws Exception {
if (cassandraServer == null) {
cassandraServer = new EmbeddedCassandraServer();
cassandraServer.start();
// wait until cassandra server starts up. could wait less time, but
// 2 seconds to be sure.
Thread.sleep(2000);
}
colFamilyDefs = columnDefinitions;
keyspaceManager = new KeyspaceManager(cluster);
columnFamilyManager = new ColumnFamilyManager(cluster, KEYSPACE);
List<KsDef> keyspaces = keyspaceManager.getKeyspaceNames();
for (KsDef ksDef : keyspaces) if (ksDef.name.equals(KEYSPACE)) {
keyspaceManager.dropKeyspace(KEYSPACE);
}
KsDef keyspaceDefinition = new KsDef(KEYSPACE, KeyspaceManager.KSDEF_STRATEGY_SIMPLE, new ArrayList<CfDef>());
Map<String, String> strategyOptions = new HashMap<String, String>();
strategyOptions.put("replication_factor", "1");
keyspaceDefinition.setStrategy_options(strategyOptions);
for (CfDef colFamilyDef : colFamilyDefs) {
keyspaceDefinition.addToCf_defs(colFamilyDef);
}
keyspaceManager.addKeyspace(keyspaceDefinition);
}
Aggregations