use of org.apache.cassandra.config.ParameterizedClass in project cassandra by apache.
the class SettingsTableTest method testAuditOverride.
@Test
public void testAuditOverride() throws Throwable {
String pre = "audit_logging_options_";
check(pre + "enabled", "false");
String all = "SELECT * FROM vts.settings WHERE " + "name > 'audit_logging' AND name < 'audit_loggingz' ALLOW FILTERING";
config.audit_logging_options.enabled = true;
Assert.assertEquals(9, executeNet(all).all().size());
check(pre + "enabled", "true");
check(pre + "logger", "BinAuditLogger");
config.audit_logging_options.logger = new ParameterizedClass("logger", null);
check(pre + "logger", "logger");
config.audit_logging_options.audit_logs_dir = "dir";
check(pre + "audit_logs_dir", "dir");
check(pre + "included_keyspaces", "");
config.audit_logging_options.included_keyspaces = "included_keyspaces";
check(pre + "included_keyspaces", "included_keyspaces");
check(pre + "excluded_keyspaces", "system,system_schema,system_virtual_schema");
config.audit_logging_options.excluded_keyspaces = "excluded_keyspaces";
check(pre + "excluded_keyspaces", "excluded_keyspaces");
check(pre + "included_categories", "");
config.audit_logging_options.included_categories = "included_categories";
check(pre + "included_categories", "included_categories");
check(pre + "excluded_categories", "");
config.audit_logging_options.excluded_categories = "excluded_categories";
check(pre + "excluded_categories", "excluded_categories");
check(pre + "included_users", "");
config.audit_logging_options.included_users = "included_users";
check(pre + "included_users", "included_users");
check(pre + "excluded_users", "");
config.audit_logging_options.excluded_users = "excluded_users";
check(pre + "excluded_users", "excluded_users");
}
use of org.apache.cassandra.config.ParameterizedClass in project cassandra by apache.
the class PEMBasedSslContextFactoryTest method getSslContextOpenSSL.
@Test
public void getSslContextOpenSSL() throws IOException {
ParameterizedClass sslContextFactory = new ParameterizedClass(PEMBasedSslContextFactory.class.getSimpleName(), new HashMap<>());
EncryptionOptions options = new EncryptionOptions().withTrustStore("test/conf/cassandra_ssl_test.truststore.pem").withKeyStore("test/conf/cassandra_ssl_test.keystore.pem").withKeyStorePassword("cassandra").withRequireClientAuth(false).withCipherSuites("TLS_RSA_WITH_AES_128_CBC_SHA").withSslContextFactory(sslContextFactory);
SslContext sslContext = SSLFactory.getOrCreateSslContext(options, true, ISslContextFactory.SocketType.CLIENT);
Assert.assertNotNull(sslContext);
if (OpenSsl.isAvailable())
Assert.assertTrue(sslContext instanceof OpenSslContext);
else
Assert.assertTrue(sslContext instanceof SslContext);
}
use of org.apache.cassandra.config.ParameterizedClass in project cassandra by apache.
the class SSLFactoryTest method testCacheKeyEqualityForCustomSslContextFactory.
@Test
public void testCacheKeyEqualityForCustomSslContextFactory() {
Map<String, String> parameters1 = new HashMap<>();
parameters1.put("key1", "value1");
parameters1.put("key2", "value2");
EncryptionOptions encryptionOptions1 = new EncryptionOptions().withSslContextFactory(new ParameterizedClass(DummySslContextFactoryImpl.class.getName(), parameters1)).withProtocol("TLSv1.1").withRequireClientAuth(true).withRequireEndpointVerification(false);
SSLFactory.CacheKey cacheKey1 = new SSLFactory.CacheKey(encryptionOptions1, ISslContextFactory.SocketType.SERVER);
Map<String, String> parameters2 = new HashMap<>();
parameters2.put("key1", "value1");
parameters2.put("key2", "value2");
EncryptionOptions encryptionOptions2 = new EncryptionOptions().withSslContextFactory(new ParameterizedClass(DummySslContextFactoryImpl.class.getName(), parameters2)).withProtocol("TLSv1.1").withRequireClientAuth(true).withRequireEndpointVerification(false);
SSLFactory.CacheKey cacheKey2 = new SSLFactory.CacheKey(encryptionOptions2, ISslContextFactory.SocketType.SERVER);
Assert.assertEquals(cacheKey1, cacheKey2);
}
use of org.apache.cassandra.config.ParameterizedClass in project cassandra by apache.
the class EncryptionContextGenerator method createEncryptionOptions.
public static TransparentDataEncryptionOptions createEncryptionOptions() {
Map<String, String> params = new HashMap<>();
params.put("keystore", "test/conf/cassandra.keystore");
params.put("keystore_password", "cassandra");
params.put("store_type", "JCEKS");
ParameterizedClass keyProvider = new ParameterizedClass(JKSKeyProvider.class.getName(), params);
return new TransparentDataEncryptionOptions("AES/CBC/PKCS5Padding", KEY_ALIAS_1, keyProvider);
}
use of org.apache.cassandra.config.ParameterizedClass in project cassandra by apache.
the class CommitLogSegmentManagerTest method testCompressedCommitLogBackpressure.
@Test
@BMRules(rules = { @BMRule(name = "Acquire Semaphore before sync", targetClass = "AbstractCommitLogService$1", targetMethod = "run", targetLocation = "AT INVOKE org.apache.cassandra.db.commitlog.CommitLog.sync", action = "org.apache.cassandra.db.commitlog.CommitLogSegmentManagerTest.allowSync.acquire()"), @BMRule(name = "Release Semaphore after sync", targetClass = "AbstractCommitLogService$1", targetMethod = "run", targetLocation = "AFTER INVOKE org.apache.cassandra.db.commitlog.CommitLog.sync", action = "org.apache.cassandra.db.commitlog.CommitLogSegmentManagerTest.allowSync.release()") })
public void testCompressedCommitLogBackpressure() throws Throwable {
// Perform all initialization before making CommitLog.Sync blocking
// Doing the initialization within the method guarantee that Byteman has performed its injections when we start
new Random().nextBytes(entropy);
DatabaseDescriptor.daemonInitialization();
DatabaseDescriptor.setCommitLogCompression(new ParameterizedClass("LZ4Compressor", ImmutableMap.of()));
DatabaseDescriptor.setCommitLogSegmentSize(1);
DatabaseDescriptor.setCommitLogSync(CommitLogSync.periodic);
DatabaseDescriptor.setCommitLogSyncPeriod(10 * 1000);
DatabaseDescriptor.setCommitLogMaxCompressionBuffersPerPool(3);
SchemaLoader.prepareServer();
SchemaLoader.createKeyspace(KEYSPACE1, KeyspaceParams.simple(1), SchemaLoader.standardCFMD(KEYSPACE1, STANDARD1, 0, AsciiType.instance, BytesType.instance), SchemaLoader.standardCFMD(KEYSPACE1, STANDARD2, 0, AsciiType.instance, BytesType.instance));
CompactionManager.instance.disableAutoCompaction();
ColumnFamilyStore cfs1 = Keyspace.open(KEYSPACE1).getColumnFamilyStore(STANDARD1);
final Mutation m = new RowUpdateBuilder(cfs1.metadata(), 0, "k").clustering("bytes").add("val", ByteBuffer.wrap(entropy)).build();
Thread dummyThread = new Thread(() -> {
for (int i = 0; i < 20; i++) CommitLog.instance.add(m);
});
try {
// Makes sure any call to CommitLog.sync is blocking
allowSync.acquire();
dummyThread.start();
AbstractCommitLogSegmentManager clsm = CommitLog.instance.segmentManager;
Util.spinAssertEquals(3, () -> clsm.getActiveSegments().size(), 5);
Thread.sleep(1000);
// Should only be able to create 3 segments not 7 because it blocks waiting for truncation that never comes
Assert.assertEquals(3, clsm.getActiveSegments().size());
// Discard the currently active segments so allocation can continue.
// Take snapshot of the list, otherwise this will also discard newly allocated segments.
new ArrayList<>(clsm.getActiveSegments()).forEach(clsm::archiveAndDiscard);
// The allocated count should reach the limit again.
Util.spinAssertEquals(3, () -> clsm.getActiveSegments().size(), 5);
} finally {
// Allow the CommitLog.sync to perform normally.
allowSync.release();
}
try {
// Wait for the dummy thread to die
dummyThread.join();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}
Aggregations