Search in sources :

Example 11 with ParameterizedClass

use of org.apache.cassandra.config.ParameterizedClass in project cassandra by apache.

the class CommitLogTest method testRecovery.

protected void testRecovery(final byte[] logData, Class<?> expected) throws Exception {
    ParameterizedClass commitLogCompression = DatabaseDescriptor.getCommitLogCompression();
    EncryptionContext encryptionContext = DatabaseDescriptor.getEncryptionContext();
    runExpecting(() -> testRecovery(logData, CommitLogDescriptor.current_version), expected);
}
Also used : EncryptionContext(org.apache.cassandra.security.EncryptionContext) ParameterizedClass(org.apache.cassandra.config.ParameterizedClass)

Example 12 with ParameterizedClass

use of org.apache.cassandra.config.ParameterizedClass in project cassandra by apache.

the class BinAuditLoggerTest method setUp.

@BeforeClass
public static void setUp() throws Exception {
    tempDir = BinLogTest.tempDir();
    AuditLogOptions options = new AuditLogOptions();
    options.enabled = true;
    options.logger = new ParameterizedClass("BinAuditLogger", null);
    options.roll_cycle = "TEST_SECONDLY";
    options.audit_logs_dir = tempDir.toString();
    DatabaseDescriptor.setAuditLoggingOptions(options);
    AuditLogManager.instance.enable(DatabaseDescriptor.getAuditLoggingOptions());
    requireNetwork();
}
Also used : ParameterizedClass(org.apache.cassandra.config.ParameterizedClass) BeforeClass(org.junit.BeforeClass)

Example 13 with ParameterizedClass

use of org.apache.cassandra.config.ParameterizedClass in project cassandra by apache.

the class CommitlogShutdownTest method testShutdownWithPendingTasks.

@Test
@BMRule(name = "Make removing commitlog segments slow", targetClass = "CommitLogSegment", targetMethod = "discard", action = "Thread.sleep(50)")
public void testShutdownWithPendingTasks() throws Exception {
    new Random().nextBytes(entropy);
    DatabaseDescriptor.daemonInitialization();
    DatabaseDescriptor.setCommitLogCompression(new ParameterizedClass("LZ4Compressor", ImmutableMap.of()));
    DatabaseDescriptor.setCommitLogSegmentSize(1);
    DatabaseDescriptor.setCommitLogSync(Config.CommitLogSync.periodic);
    DatabaseDescriptor.setCommitLogSyncPeriod(10 * 1000);
    SchemaLoader.prepareServer();
    SchemaLoader.createKeyspace(KEYSPACE1, KeyspaceParams.simple(1), SchemaLoader.standardCFMD(KEYSPACE1, STANDARD1, 0, AsciiType.instance, BytesType.instance));
    CompactionManager.instance.disableAutoCompaction();
    ColumnFamilyStore cfs1 = Keyspace.open(KEYSPACE1).getColumnFamilyStore(STANDARD1);
    final Mutation m = new RowUpdateBuilder(cfs1.metadata.get(), 0, "k").clustering("bytes").add("val", ByteBuffer.wrap(entropy)).build();
    // force creating several commitlog files
    for (int i = 0; i < 10; i++) {
        CommitLog.instance.add(m);
    }
    // schedule discarding completed segments and immediately issue a shutdown
    TableId tableId = m.getTableIds().iterator().next();
    CommitLog.instance.discardCompletedSegments(tableId, CommitLogPosition.NONE, CommitLog.instance.getCurrentPosition());
    CommitLog.instance.shutdownBlocking();
    // the shutdown should block until all logs except the currently active one and perhaps a new, empty one are gone
    Assert.assertTrue(new File(DatabaseDescriptor.getCommitLogLocation()).tryList().length <= 2);
}
Also used : TableId(org.apache.cassandra.schema.TableId) Random(java.util.Random) RowUpdateBuilder(org.apache.cassandra.db.RowUpdateBuilder) ParameterizedClass(org.apache.cassandra.config.ParameterizedClass) ColumnFamilyStore(org.apache.cassandra.db.ColumnFamilyStore) Mutation(org.apache.cassandra.db.Mutation) File(org.apache.cassandra.io.util.File) BMRule(org.jboss.byteman.contrib.bmunit.BMRule) Test(org.junit.Test)

Example 14 with ParameterizedClass

use of org.apache.cassandra.config.ParameterizedClass in project cassandra by apache.

the class CommitLogDescriptorTest method setup.

@Before
public void setup() {
    Map<String, String> params = new HashMap<>();
    compression = new ParameterizedClass(LZ4Compressor.class.getName(), params);
    enabledTdeOptions = EncryptionContextGenerator.createEncryptionOptions();
    enabledEncryption = new EncryptionContext(enabledTdeOptions, iv, false);
    neverEnabledEncryption = EncryptionContextGenerator.createDisabledContext();
    TransparentDataEncryptionOptions disaabledTdeOptions = new TransparentDataEncryptionOptions(false, enabledTdeOptions.cipher, enabledTdeOptions.key_alias, enabledTdeOptions.key_provider);
    previouslyEnabledEncryption = new EncryptionContext(disaabledTdeOptions);
}
Also used : EncryptionContext(org.apache.cassandra.security.EncryptionContext) HashMap(java.util.HashMap) ParameterizedClass(org.apache.cassandra.config.ParameterizedClass) TransparentDataEncryptionOptions(org.apache.cassandra.config.TransparentDataEncryptionOptions) Before(org.junit.Before)

Example 15 with ParameterizedClass

use of org.apache.cassandra.config.ParameterizedClass in project cassandra by apache.

the class HintsService method createDescriptorParams.

private static ImmutableMap<String, Object> createDescriptorParams() {
    ImmutableMap.Builder<String, Object> builder = ImmutableMap.builder();
    ParameterizedClass compressionConfig = DatabaseDescriptor.getHintsCompression();
    if (compressionConfig != null) {
        ImmutableMap.Builder<String, Object> compressorParams = ImmutableMap.builder();
        compressorParams.put(ParameterizedClass.CLASS_NAME, compressionConfig.class_name);
        if (compressionConfig.parameters != null) {
            compressorParams.put(ParameterizedClass.PARAMETERS, compressionConfig.parameters);
        }
        builder.put(HintsDescriptor.COMPRESSION, compressorParams.build());
    }
    return builder.build();
}
Also used : ParameterizedClass(org.apache.cassandra.config.ParameterizedClass) ImmutableMap(com.google.common.collect.ImmutableMap)

Aggregations

ParameterizedClass (org.apache.cassandra.config.ParameterizedClass)17 Test (org.junit.Test)8 HashMap (java.util.HashMap)5 BeforeClass (org.junit.BeforeClass)4 Random (java.util.Random)3 EncryptionOptions (org.apache.cassandra.config.EncryptionOptions)3 ColumnFamilyStore (org.apache.cassandra.db.ColumnFamilyStore)3 Mutation (org.apache.cassandra.db.Mutation)3 RowUpdateBuilder (org.apache.cassandra.db.RowUpdateBuilder)3 ServerEncryptionOptions (org.apache.cassandra.config.EncryptionOptions.ServerEncryptionOptions)2 TransparentDataEncryptionOptions (org.apache.cassandra.config.TransparentDataEncryptionOptions)2 EncryptionContext (org.apache.cassandra.security.EncryptionContext)2 EmbeddedCassandraService (org.apache.cassandra.service.EmbeddedCassandraService)2 BMRules (org.jboss.byteman.contrib.bmunit.BMRules)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 OpenSslContext (io.netty.handler.ssl.OpenSslContext)1 SslContext (io.netty.handler.ssl.SslContext)1 ByteBuffer (java.nio.ByteBuffer)1 ConfigurationException (org.apache.cassandra.exceptions.ConfigurationException)1 File (org.apache.cassandra.io.util.File)1