use of org.apache.cassandra.thrift.CfDef in project atlasdb by palantir.
the class SchemaMutationLockTables method createTableInternal.
private void createTableInternal(CassandraClient client, TableReference tableRef) throws TException {
CfDef cf = ColumnFamilyDefinitions.getStandardCfDef(config.getKeyspaceOrThrow(), CassandraKeyValueServiceImpl.internalTableName(tableRef));
client.system_add_column_family(cf);
CassandraKeyValueServices.waitForSchemaVersions(config, client, tableRef.getQualifiedName(), true);
}
use of org.apache.cassandra.thrift.CfDef in project titan by thinkaurelius.
the class CassandraThriftStoreManager method createColumnFamily.
private void createColumnFamily(Cassandra.Client client, String ksName, String cfName, String comparator) throws StorageException {
CfDef createColumnFamily = new CfDef();
createColumnFamily.setName(cfName);
createColumnFamily.setKeyspace(ksName);
createColumnFamily.setComparator_type(comparator);
ImmutableMap.Builder<String, String> compressionOptions = new ImmutableMap.Builder<String, String>();
if (compressionEnabled) {
compressionOptions.put("sstable_compression", compressionClass).put("chunk_length_kb", Integer.toString(compressionChunkSizeKB));
}
createColumnFamily.setCompression_options(compressionOptions.build());
// Hard-coded caching settings
if (cfName.startsWith(Backend.EDGESTORE_NAME)) {
createColumnFamily.setCaching("keys_only");
} else if (cfName.startsWith(Backend.VERTEXINDEX_STORE_NAME)) {
createColumnFamily.setCaching("rows_only");
}
log.debug("Adding column family {} to keyspace {}...", cfName, ksName);
try {
client.system_add_column_family(createColumnFamily);
} catch (SchemaDisagreementException e) {
throw new TemporaryStorageException("Error in setting up column family", e);
} catch (Exception e) {
throw new PermanentStorageException(e);
}
log.debug("Added column family {} to keyspace {}.", cfName, ksName);
}
use of org.apache.cassandra.thrift.CfDef in project titan by thinkaurelius.
the class CassandraThriftStoreManager method getCompressionOptions.
@Override
public Map<String, String> getCompressionOptions(String cf) throws StorageException {
CTConnection conn = null;
Map<String, String> result = null;
try {
conn = pool.borrowObject(keySpaceName);
Cassandra.Client client = conn.getClient();
KsDef ksDef = client.describe_keyspace(keySpaceName);
for (CfDef cfDef : ksDef.getCf_defs()) {
if (null != cfDef && cfDef.getName().equals(cf)) {
result = cfDef.getCompression_options();
break;
}
}
return result;
} catch (InvalidRequestException e) {
log.debug("Keyspace {} does not exist", keySpaceName);
return null;
} catch (Exception e) {
throw new TemporaryStorageException(e);
} finally {
pool.returnObjectUnsafe(keySpaceName, conn);
}
}
use of org.apache.cassandra.thrift.CfDef 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);
}
use of org.apache.cassandra.thrift.CfDef in project eiger by wlloyd.
the class KSMetaData method toThrift.
public KsDef toThrift() {
List<CfDef> cfDefs = new ArrayList<CfDef>();
for (CFMetaData cfm : cfMetaData().values()) cfDefs.add(cfm.toThrift());
KsDef ksdef = new KsDef(name, strategyClass.getName(), cfDefs);
ksdef.setStrategy_options(strategyOptions);
if (strategyOptions != null && strategyOptions.containsKey("replication_factor"))
ksdef.setReplication_factor(Integer.parseInt(strategyOptions.get("replication_factor")));
ksdef.setDurable_writes(durableWrites);
return ksdef;
}
Aggregations