use of org.apache.cassandra.distributed.api.IIsolatedExecutor.SerializableRunnable in project cassandra by apache.
the class InterceptingExecutorFactory method factory.
<F extends ThreadFactory> F factory(String name, Object extraInfo, ThreadGroup threadGroup, UncaughtExceptionHandler uncaughtExceptionHandler, InterceptibleThreadFactory.MetaFactory<F> factory) {
if (uncaughtExceptionHandler == null)
uncaughtExceptionHandler = transferToInstance.apply((SerializableFunction<Supplier<Boolean>, UncaughtExceptionHandler>) (reportUnchecked) -> (thread, throwable) -> {
if (!(throwable instanceof UncheckedInterruptedException) || reportUnchecked.get())
JVMStabilityInspector.uncaughtException(thread, throwable);
}).apply(() -> !isClosed);
if (threadGroup == null)
threadGroup = this.threadGroup;
else if (!this.threadGroup.parentOf(threadGroup))
throw new IllegalArgumentException();
Runnable onTermination = transferToInstance.apply((SerializableRunnable) FastThreadLocal::removeAll);
LocalTime time = transferToInstance.apply((IIsolatedExecutor.SerializableCallable<LocalTime>) SimulatedTime.Global::current).call();
return factory.create(name, Thread.NORM_PRIORITY, classLoader, uncaughtExceptionHandler, threadGroup, onTermination, time, this, extraInfo);
}
use of org.apache.cassandra.distributed.api.IIsolatedExecutor.SerializableRunnable in project cassandra by apache.
the class InternodeEncryptionEnforcementTest method testConnectionsAreAcceptedWithValidConfig.
@Test
public void testConnectionsAreAcceptedWithValidConfig() throws Throwable {
Cluster.Builder builder = builder().withNodes(2).withConfig(c -> {
c.with(Feature.NETWORK);
c.with(Feature.NATIVE_PROTOCOL);
HashMap<String, Object> encryption = new HashMap<>();
encryption.put("keystore", "test/conf/cassandra_ssl_test.keystore");
encryption.put("keystore_password", "cassandra");
encryption.put("truststore", "test/conf/cassandra_ssl_test.truststore");
encryption.put("truststore_password", "cassandra");
encryption.put("internode_encryption", "dc");
c.set("server_encryption_options", encryption);
}).withNodeIdTopology(ImmutableMap.of(1, NetworkTopology.dcAndRack("dc1", "r1a"), 2, NetworkTopology.dcAndRack("dc2", "r2a")));
try (Cluster cluster = builder.start()) {
openConnections(cluster);
/*
* instance (1) should connect to instance (2) without any issues;
* instance (2) should connect to instance (1) without any issues.
*/
SerializableRunnable runnable = () -> {
InboundMessageHandlers inbound = getOnlyElement(MessagingService.instance().messageHandlers.values());
assertTrue(inbound.count() > 0);
OutboundConnections outbound = getOnlyElement(MessagingService.instance().channelManagers.values());
assertTrue(outbound.small.isConnected() || outbound.large.isConnected() || outbound.urgent.isConnected());
};
cluster.get(1).runOnInstance(runnable);
cluster.get(2).runOnInstance(runnable);
}
}
Aggregations