Search in sources :

Example 1 with ColumnFamilyManager

use of org.scale7.cassandra.pelops.ColumnFamilyManager 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);
}
Also used : KeyspaceManager(org.scale7.cassandra.pelops.KeyspaceManager) ColumnFamilyManager(org.scale7.cassandra.pelops.ColumnFamilyManager) HashMap(java.util.HashMap) KsDef(org.apache.cassandra.thrift.KsDef) CfDef(org.apache.cassandra.thrift.CfDef)

Aggregations

HashMap (java.util.HashMap)1 CfDef (org.apache.cassandra.thrift.CfDef)1 KsDef (org.apache.cassandra.thrift.KsDef)1 ColumnFamilyManager (org.scale7.cassandra.pelops.ColumnFamilyManager)1 KeyspaceManager (org.scale7.cassandra.pelops.KeyspaceManager)1