use of org.apache.cassandra.thrift.KsDef in project scale7-pelops by s7.
the class Cluster method refreshInternal.
/**
* Refresh the snapshot of the list of nodes currently believed to exist in the Cassandra cluster.
* @return the list of nodes
*/
private String[] refreshInternal() throws Exception {
KeyspaceManager kspcMngr = new ClusterKeyspaceManager(this);
List<KsDef> keyspaces = kspcMngr.getKeyspaceNames();
Iterator<KsDef> k = keyspaces.iterator();
KsDef appKeyspace = null;
while (k.hasNext()) {
KsDef keyspace = k.next();
if (!keyspace.getName().equals("system")) {
appKeyspace = keyspace;
break;
}
}
if (appKeyspace == null)
throw new Exception("Cannot obtain a node list from a ring mapping. No keyspaces are defined for this cluster.");
return refreshInternal(appKeyspace.getName());
}
use of org.apache.cassandra.thrift.KsDef in project eiger by wlloyd.
the class CliCompiler method getKeySpace.
public static String getKeySpace(String ksName, List<KsDef> keyspaces) {
int matches = 0;
String lastMatchedName = "";
for (KsDef ksDef : keyspaces) {
if (ksDef.name.equals(ksName)) {
return ksName;
} else if (ksDef.name.toUpperCase().equals(ksName.toUpperCase())) {
lastMatchedName = ksDef.name;
matches++;
}
}
if (matches > 1 || matches == 0)
throw new RuntimeException("Keyspace '" + ksName + "' not found.");
return lastMatchedName;
}
use of org.apache.cassandra.thrift.KsDef in project brisk by riptano.
the class BriskSchema method createKeySpace.
public static KsDef createKeySpace() throws IOException {
try {
logger.info("Creating keyspace: " + KEYSPACE_NAME);
Thread.sleep(new Random().nextInt(5000));
KsDef cfsKs = checkKeyspace();
if (cfsKs != null) {
logger.info("keyspace already exists. Skipping creation.");
return cfsKs;
}
List<CfDef> cfs = new ArrayList<CfDef>();
CfDef cf = new CfDef();
cf.setName(JOB_TRACKER_CF);
cf.setComparator_type("BytesType");
// there is only one row and one column.
cf.setKey_cache_size(10);
cf.setRow_cache_size(10);
cf.setGc_grace_seconds(60);
cf.setComment("Stores the current JobTracker node");
cf.setKeyspace(KEYSPACE_NAME);
cfs.add(cf);
Map<String, String> stratOpts = new HashMap<String, String>();
stratOpts.put(BriskSimpleSnitch.BRISK_DC, System.getProperty("cfs.replication", "1"));
stratOpts.put(BriskSimpleSnitch.CASSANDRA_DC, "0");
cfsKs = new KsDef().setName(KEYSPACE_NAME).setStrategy_class("org.apache.cassandra.locator.NetworkTopologyStrategy").setStrategy_options(stratOpts).setCf_defs(cfs);
client.system_add_keyspace(cfsKs);
waitForSchemaAgreement(client);
return cfsKs;
} catch (Exception e) {
throw new IOException(e);
}
}
use of org.apache.cassandra.thrift.KsDef in project brisk by riptano.
the class MetaStoreTestBase method setupOtherKeyspace.
protected KsDef setupOtherKeyspace(Configuration configuration, String ksName, String keyValidator, String comparator, boolean addMetaData) throws Exception {
CfDef cf = new CfDef(ksName, "OtherCf1");
cf.setKey_validation_class(keyValidator);
cf.setComparator_type(comparator);
if (addMetaData) {
cf.addToColumn_metadata(new ColumnDef(ByteBufferUtil.bytes("col_name_utf8"), UTF8Type.class.getName()));
cf.addToColumn_metadata(new ColumnDef(ByteBufferUtil.bytes("col_name_bytes"), BytesType.class.getName()));
cf.addToColumn_metadata(new ColumnDef(ByteBufferUtil.bytes("col_name_int"), IntegerType.class.getName()));
cf.addToColumn_metadata(new ColumnDef(ByteBufferUtil.bytes("col_name_long"), LongType.class.getName()));
cf.addToColumn_metadata(new ColumnDef(ByteBufferUtil.bytes("col_name_timeuuid"), TimeUUIDType.class.getName()));
}
KsDef ks = new KsDef(ksName, "org.apache.cassandra.locator.SimpleStrategy", Arrays.asList(cf));
ks.setStrategy_options(KSMetaData.optsWithRF(configuration.getInt(CassandraClientHolder.CONF_PARAM_REPLICATION_FACTOR, 1)));
return ks;
}
use of org.apache.cassandra.thrift.KsDef in project brisk by riptano.
the class SchemaManagerServiceTest method testCreateKeyspaceSchema.
@Test
public void testCreateKeyspaceSchema() throws Exception {
KsDef ksDef = setupOtherKeyspace(configuration, "CreatedKeyspace", false);
cassandraClientHolder.getClient().system_add_keyspace(ksDef);
schemaManagerService.createKeyspaceSchema(ksDef);
List<KsDef> keyspaces = schemaManagerService.findUnmappedKeyspaces();
// don't impose a keyspace maintenance burden. Looking for specifics is good enough
for (KsDef ks : keyspaces) {
if (StringUtils.equals(ks.name, "CreatedKeyspace")) {
fail("created was not synched");
}
}
}
Aggregations