use of org.apache.cassandra.thrift.CfDef in project atlasdb by palantir.
the class ColumnFamilyDefinitionsTest method compactionStrategiesShouldMatchWithOrWithoutPackageName.
@Test
public void compactionStrategiesShouldMatchWithOrWithoutPackageName() {
CfDef standard = ColumnFamilyDefinitions.getCfDef("test_keyspace", TableReference.fromString("test_table"), CassandraConstants.DEFAULT_GC_GRACE_SECONDS, new byte[0]);
CfDef fullyQualified = standard.setCompaction_strategy("com.palantir.AwesomeCompactionStrategy");
CfDef onlyClassName = standard.deepCopy().setCompaction_strategy("AwesomeCompactionStrategy");
assertTrue(String.format("Compaction strategies %s and %s should match", fullyQualified.compaction_strategy, onlyClassName.compaction_strategy), ColumnFamilyDefinitions.isMatchingCf(fullyQualified, onlyClassName));
}
use of org.apache.cassandra.thrift.CfDef in project atlasdb by palantir.
the class CassandraKeyValueServiceIntegrationTest method assertThatGcGraceSecondsIs.
private void assertThatGcGraceSecondsIs(CassandraKeyValueService kvs, int gcGraceSeconds) throws TException {
List<CfDef> knownCfs = kvs.getClientPool().runWithRetry(client -> client.describe_keyspace("atlasdb").getCf_defs());
CfDef clusterSideCf = Iterables.getOnlyElement(knownCfs.stream().filter(cf -> cf.getName().equals(getInternalTestTableName())).collect(Collectors.toList()));
assertThat(clusterSideCf.gc_grace_seconds, equalTo(gcGraceSeconds));
}
use of org.apache.cassandra.thrift.CfDef in project eiger by wlloyd.
the class CliCompiler method getColumnFamily.
public static String getColumnFamily(String cfName, List<CfDef> cfDefs) {
int matches = 0;
String lastMatchedName = "";
for (CfDef cfDef : cfDefs) {
if (cfDef.name.equals(cfName)) {
return cfName;
} else if (cfDef.name.toUpperCase().equals(cfName.toUpperCase())) {
lastMatchedName = cfDef.name;
matches++;
}
}
if (matches > 1 || matches == 0)
throw new RuntimeException(cfName + " not found in current keyspace.");
return lastMatchedName;
}
use of org.apache.cassandra.thrift.CfDef in project brisk by riptano.
the class SchemaManagerService method createMetaStoreIfNeeded.
/**
* Create the meta store keyspace if it does not already exist.
* @return true if the keyspace did no exist and the creation was successful. False if the
* keyspace already existed.
* @throws {@link CassandraHiveMetaStoreException} wrapping the underlying exception if we
* failed to create the keyspace.
*/
public boolean createMetaStoreIfNeeded() {
if (configuration.getBoolean("cassandra.skipMetaStoreCreate", false))
return false;
try {
cassandraClientHolder.applyKeyspace();
return false;
} catch (CassandraHiveMetaStoreException chmse) {
log.debug("Attempting to create meta store keyspace: First set_keyspace call failed. Sleeping.");
}
// Sleep a random amount of time to stagger ks creations on many nodes
try {
Thread.sleep(5000);
} catch (InterruptedException e1) {
}
// check again...
try {
cassandraClientHolder.applyKeyspace();
return false;
} catch (CassandraHiveMetaStoreException chmse) {
log.debug("Attempting to create meta store keyspace after sleep.");
}
CfDef cf = new CfDef(cassandraClientHolder.getKeyspaceName(), cassandraClientHolder.getColumnFamily());
cf.setKey_validation_class("UTF8Type");
cf.setComparator_type("UTF8Type");
KsDef ks = new KsDef(cassandraClientHolder.getKeyspaceName(), "org.apache.cassandra.locator.SimpleStrategy", Arrays.asList(cf));
ks.setStrategy_options(KSMetaData.optsWithRF(configuration.getInt(CassandraClientHolder.CONF_PARAM_REPLICATION_FACTOR, 1)));
try {
cassandraClientHolder.getClient().system_add_keyspace(ks);
return true;
} catch (Exception e) {
throw new CassandraHiveMetaStoreException("Could not create Hive MetaStore database: " + e.getMessage(), e);
}
}
use of org.apache.cassandra.thrift.CfDef in project brisk by riptano.
the class CassandraHiveMetaStoreTest method testAutoCreateFromKeyspace.
@Test
public void testAutoCreateFromKeyspace() throws Exception {
CassandraHiveMetaStore metaStore = new CassandraHiveMetaStore();
Configuration conf = buildConfiguration();
CassandraClientHolder clientHolder = new CassandraClientHolder(conf);
KsDef ksDef = setupOtherKeyspace(conf, "AutoCreatedFromKeyspace", false);
clientHolder.getClient().system_add_keyspace(ksDef);
conf.setBoolean("cassandra.autoCreateHiveSchema", true);
metaStore.setConf(conf);
Database foundDb = metaStore.getDatabase("AutoCreatedFromKeyspace");
assertNotNull(foundDb);
CfDef cf = new CfDef("AutoCreatedFromKeyspace", "OtherCf2");
cf.setKey_validation_class("UTF8Type");
cf.setComparator_type("UTF8Type");
clientHolder.getClient().set_keyspace("HiveMetaStore");
clientHolder.getClient().system_add_column_family(cf);
metaStore.getAllTables("AutoCreatedFromKeyspace");
assertNotNull(metaStore.getTable("AutoCreatedFromKeyspace", "OtherCf2"));
}
Aggregations