Search in sources :

Example 11 with CfDef

use of org.apache.cassandra.thrift.CfDef in project atlasdb by palantir.

the class ColumnFamilyDefinitionsTest method cfDefWithDifferingGcGraceSecondsValuesShouldNotMatch.

@Test
public void cfDefWithDifferingGcGraceSecondsValuesShouldNotMatch() {
    CfDef clientSideTable = ColumnFamilyDefinitions.getCfDef("test_keyspace", TableReference.fromString("test_table"), CassandraConstants.DEFAULT_GC_GRACE_SECONDS, AtlasDbConstants.GENERIC_TABLE_METADATA);
    CfDef clusterSideTable = ColumnFamilyDefinitions.getCfDef("test_keyspace", TableReference.fromString("test_table"), FOUR_DAYS_IN_SECONDS, AtlasDbConstants.GENERIC_TABLE_METADATA);
    assertFalse("ColumnDefinitions with different gc_grace_seconds should not match", ColumnFamilyDefinitions.isMatchingCf(clientSideTable, clusterSideTable));
}
Also used : CfDef(org.apache.cassandra.thrift.CfDef) Test(org.junit.Test)

Example 12 with CfDef

use of org.apache.cassandra.thrift.CfDef in project atlasdb by palantir.

the class ColumnFamilyDefinitionsTest method nonDefaultFeaturesCorrectlyCompared.

@Test
public void nonDefaultFeaturesCorrectlyCompared() {
    CfDef cf1 = ColumnFamilyDefinitions.getCfDef("test_keyspace", TableReference.fromString("test_table"), FOUR_DAYS_IN_SECONDS, TABLE_METADATA_WITH_MANY_NON_DEFAULT_FEATURES);
    CfDef cf2 = ColumnFamilyDefinitions.getCfDef("test_keyspace", TableReference.fromString("test_table"), FOUR_DAYS_IN_SECONDS, TABLE_METADATA_WITH_MANY_NON_DEFAULT_FEATURES);
    assertTrue("identical CFs should equal each other", ColumnFamilyDefinitions.isMatchingCf(cf1, cf2));
}
Also used : CfDef(org.apache.cassandra.thrift.CfDef) Test(org.junit.Test)

Example 13 with CfDef

use of org.apache.cassandra.thrift.CfDef in project atlasdb by palantir.

the class ColumnFamilyDefinitionsTest method identicalCfsAreEqual.

@Test
public void identicalCfsAreEqual() {
    CfDef cf1 = ColumnFamilyDefinitions.getCfDef("test_keyspace", TableReference.fromString("test_table"), FOUR_DAYS_IN_SECONDS, AtlasDbConstants.GENERIC_TABLE_METADATA);
    CfDef cf2 = ColumnFamilyDefinitions.getCfDef("test_keyspace", TableReference.fromString("test_table"), FOUR_DAYS_IN_SECONDS, AtlasDbConstants.GENERIC_TABLE_METADATA);
    assertTrue("identical CFs should equal each other", ColumnFamilyDefinitions.isMatchingCf(cf1, cf2));
}
Also used : CfDef(org.apache.cassandra.thrift.CfDef) Test(org.junit.Test)

Example 14 with CfDef

use of org.apache.cassandra.thrift.CfDef in project atlasdb by palantir.

the class ColumnFamilyDefinitions method getStandardCfDef.

/**
 *  Provides a basic column family definition. This is a subset of #getCfDef, and does not
 *  include compression options, but also does not require raw metadata to be passed in.
 *
 *  Warning to developers: you must update CKVS.isMatchingCf if you update this method
 */
static CfDef getStandardCfDef(String keyspace, String internalTableName) {
    CfDef cf = new CfDef(keyspace, internalTableName);
    cf.setComparator_type("CompositeType(BytesType,LongType)");
    cf.setCompaction_strategy(CassandraConstants.LEVELED_COMPACTION_STRATEGY);
    cf.setCompression_options(Maps.<String, String>newHashMap());
    cf.setGc_grace_seconds(CassandraConstants.DEFAULT_GC_GRACE_SECONDS);
    // explicitly set fields to default values
    cf.setCaching("KEYS_ONLY");
    cf.setDclocal_read_repair_chance(0.1);
    cf.setTriggers(new ArrayList<TriggerDef>());
    cf.setCells_per_row_to_cache("0");
    cf.setMin_index_interval(128);
    cf.setMax_index_interval(2048);
    cf.setComment("");
    cf.setColumn_metadata(new ArrayList<ColumnDef>());
    cf.setMin_compaction_threshold(4);
    cf.setMax_compaction_threshold(32);
    cf.setKey_validation_class("org.apache.cassandra.db.marshal.BytesType");
    cf.setCompaction_strategy_options(new HashMap<String, String>());
    cf.setDefault_validation_class("org.apache.cassandra.db.marshal.BytesType");
    return cf;
}
Also used : ColumnDef(org.apache.cassandra.thrift.ColumnDef) TriggerDef(org.apache.cassandra.thrift.TriggerDef) CfDef(org.apache.cassandra.thrift.CfDef)

Example 15 with CfDef

use of org.apache.cassandra.thrift.CfDef in project atlasdb by palantir.

the class ColumnFamilyDefinitions method getCfDef.

/**
 *  Provides a default column family definition given raw metadata, which is generally obtained from the _metadata
 *  table.
 *
 *  Warning to developers: you must update CKVS.isMatchingCf if you update this method
 */
@SuppressWarnings("CyclomaticComplexity")
static CfDef getCfDef(String keyspace, TableReference tableRef, int gcGraceSeconds, byte[] rawMetadata) {
    Map<String, String> compressionOptions = Maps.newHashMap();
    CfDef cf = getStandardCfDef(keyspace, AbstractKeyValueService.internalTableName(tableRef));
    boolean negativeLookups = false;
    double falsePositiveChance = CassandraConstants.DEFAULT_LEVELED_COMPACTION_BLOOM_FILTER_FP_CHANCE;
    int explicitCompressionBlockSizeKb = 0;
    boolean appendHeavyAndReadLight = false;
    TableMetadataPersistence.CachePriority cachePriority = TableMetadataPersistence.CachePriority.WARM;
    if (!CassandraKeyValueServices.isEmptyOrInvalidMetadata(rawMetadata)) {
        TableMetadata tableMetadata = TableMetadata.BYTES_HYDRATOR.hydrateFromBytes(rawMetadata);
        negativeLookups = tableMetadata.hasNegativeLookups();
        explicitCompressionBlockSizeKb = tableMetadata.getExplicitCompressionBlockSizeKB();
        appendHeavyAndReadLight = tableMetadata.isAppendHeavyAndReadLight();
        cachePriority = tableMetadata.getCachePriority();
    }
    if (explicitCompressionBlockSizeKb != 0) {
        compressionOptions.put(CassandraConstants.CFDEF_COMPRESSION_TYPE_KEY, CassandraConstants.DEFAULT_COMPRESSION_TYPE);
        compressionOptions.put(CassandraConstants.CFDEF_COMPRESSION_CHUNK_LENGTH_KEY, Integer.toString(explicitCompressionBlockSizeKb));
    } else {
        // We don't really need compression here nor anticipate it will garner us any gains
        // (which is why we're doing such a small chunk size), but this is how we can get "free" CRC checking.
        compressionOptions.put(CassandraConstants.CFDEF_COMPRESSION_TYPE_KEY, CassandraConstants.DEFAULT_COMPRESSION_TYPE);
        compressionOptions.put(CassandraConstants.CFDEF_COMPRESSION_CHUNK_LENGTH_KEY, Integer.toString(AtlasDbConstants.MINIMUM_COMPRESSION_BLOCK_SIZE_KB));
    }
    if (negativeLookups) {
        falsePositiveChance = CassandraConstants.NEGATIVE_LOOKUPS_BLOOM_FILTER_FP_CHANCE;
    }
    if (appendHeavyAndReadLight) {
        cf.setCompaction_strategy(CassandraConstants.SIZE_TIERED_COMPACTION_STRATEGY);
        // clear out the now nonsensical "keep it at 80MB per sstable" option from LCS
        cf.setCompaction_strategy_optionsIsSet(false);
        if (!negativeLookups) {
            falsePositiveChance = CassandraConstants.DEFAULT_SIZE_TIERED_COMPACTION_BLOOM_FILTER_FP_CHANCE;
        } else {
            falsePositiveChance = CassandraConstants.NEGATIVE_LOOKUPS_SIZE_TIERED_BLOOM_FILTER_FP_CHANCE;
        }
    }
    switch(cachePriority) {
        case COLDEST:
            break;
        case COLD:
            break;
        case WARM:
            break;
        case HOT:
            break;
        case HOTTEST:
            cf.setPopulate_io_cache_on_flushIsSet(true);
            break;
        default:
            throw new PalantirRuntimeException("Unknown cache priority: " + cachePriority);
    }
    cf.setGc_grace_seconds(gcGraceSeconds);
    cf.setBloom_filter_fp_chance(falsePositiveChance);
    cf.setCompression_options(compressionOptions);
    return cf;
}
Also used : TableMetadata(com.palantir.atlasdb.table.description.TableMetadata) PalantirRuntimeException(com.palantir.common.exception.PalantirRuntimeException) TableMetadataPersistence(com.palantir.atlasdb.protos.generated.TableMetadataPersistence) 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