Search in sources :

Example 16 with CfDef

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);
}
Also used : CfDef(org.apache.cassandra.thrift.CfDef)

Example 17 with CfDef

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);
}
Also used : TemporaryStorageException(com.thinkaurelius.titan.diskstorage.TemporaryStorageException) PermanentStorageException(com.thinkaurelius.titan.diskstorage.PermanentStorageException) SchemaDisagreementException(org.apache.cassandra.thrift.SchemaDisagreementException) CfDef(org.apache.cassandra.thrift.CfDef) ImmutableMap(com.google.common.collect.ImmutableMap) NotFoundException(org.apache.cassandra.thrift.NotFoundException) PermanentStorageException(com.thinkaurelius.titan.diskstorage.PermanentStorageException) InvalidRequestException(org.apache.cassandra.thrift.InvalidRequestException) TemporaryStorageException(com.thinkaurelius.titan.diskstorage.TemporaryStorageException) TException(org.apache.thrift.TException) StorageException(com.thinkaurelius.titan.diskstorage.StorageException) SchemaDisagreementException(org.apache.cassandra.thrift.SchemaDisagreementException)

Example 18 with CfDef

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);
    }
}
Also used : CTConnection(com.thinkaurelius.titan.diskstorage.cassandra.thrift.thriftpool.CTConnection) TemporaryStorageException(com.thinkaurelius.titan.diskstorage.TemporaryStorageException) Cassandra(org.apache.cassandra.thrift.Cassandra) InvalidRequestException(org.apache.cassandra.thrift.InvalidRequestException) KsDef(org.apache.cassandra.thrift.KsDef) CfDef(org.apache.cassandra.thrift.CfDef) NotFoundException(org.apache.cassandra.thrift.NotFoundException) PermanentStorageException(com.thinkaurelius.titan.diskstorage.PermanentStorageException) InvalidRequestException(org.apache.cassandra.thrift.InvalidRequestException) TemporaryStorageException(com.thinkaurelius.titan.diskstorage.TemporaryStorageException) TException(org.apache.thrift.TException) StorageException(com.thinkaurelius.titan.diskstorage.StorageException) SchemaDisagreementException(org.apache.cassandra.thrift.SchemaDisagreementException)

Example 19 with CfDef

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);
}
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)

Example 20 with CfDef

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;
}
Also used : KsDef(org.apache.cassandra.thrift.KsDef) CfDef(org.apache.cassandra.thrift.CfDef)

Aggregations

CfDef (org.apache.cassandra.thrift.CfDef)24 KsDef (org.apache.cassandra.thrift.KsDef)10 Test (org.junit.Test)7 InvalidRequestException (org.apache.cassandra.thrift.InvalidRequestException)6 NotFoundException (org.apache.cassandra.thrift.NotFoundException)6 TException (org.apache.thrift.TException)6 PermanentStorageException (com.thinkaurelius.titan.diskstorage.PermanentStorageException)4 StorageException (com.thinkaurelius.titan.diskstorage.StorageException)4 TemporaryStorageException (com.thinkaurelius.titan.diskstorage.TemporaryStorageException)4 Cassandra (org.apache.cassandra.thrift.Cassandra)4 SchemaDisagreementException (org.apache.cassandra.thrift.SchemaDisagreementException)4 CTConnection (com.thinkaurelius.titan.diskstorage.cassandra.thrift.thriftpool.CTConnection)3 ColumnDef (org.apache.cassandra.thrift.ColumnDef)3 Cluster (com.netflix.astyanax.Cluster)2 ConnectionException (com.netflix.astyanax.connectionpool.exceptions.ConnectionException)2 OperationException (com.netflix.astyanax.connectionpool.exceptions.OperationException)2 HashMap (java.util.HashMap)2 CoordinatorClient (com.emc.storageos.coordinator.client.service.CoordinatorClient)1 DbClient (com.emc.storageos.db.client.DbClient)1 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)1