Search in sources :

Example 1 with CfDef

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

Example 2 with CfDef

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

Example 3 with CfDef

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

Example 4 with CfDef

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);
    }
}
Also used : KsDef(org.apache.cassandra.thrift.KsDef) CfDef(org.apache.cassandra.thrift.CfDef) CharacterCodingException(java.nio.charset.CharacterCodingException) MetaException(org.apache.hadoop.hive.metastore.api.MetaException) NotFoundException(org.apache.cassandra.thrift.NotFoundException) InvalidRequestException(org.apache.cassandra.thrift.InvalidRequestException) ConfigurationException(org.apache.cassandra.config.ConfigurationException) InvalidObjectException(org.apache.hadoop.hive.metastore.api.InvalidObjectException) NoSuchObjectException(org.apache.hadoop.hive.metastore.api.NoSuchObjectException)

Example 5 with CfDef

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"));
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) KsDef(org.apache.cassandra.thrift.KsDef) CfDef(org.apache.cassandra.thrift.CfDef) Test(org.junit.Test)

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