Search in sources :

Example 1 with SETTINGS

use of org.apache.cassandra.net.ConnectionTest.SETTINGS in project cassandra by apache.

the class ProxyHandlerConnectionsTest method doTestManual.

private void doTestManual(ConnectionTest.Settings settings, ManualSendTest test) throws Throwable {
    InetAddressAndPort endpoint = FBUtilities.getBroadcastAddressAndPort();
    InboundConnectionSettings inboundSettings = settings.inbound.apply(new InboundConnectionSettings()).withBindAddress(endpoint).withSocketFactory(factory);
    InboundSockets inbound = new InboundSockets(Collections.singletonList(inboundSettings));
    OutboundConnectionSettings outboundSettings = settings.outbound.apply(new OutboundConnectionSettings(endpoint)).withConnectTo(endpoint).withDefaultReserveLimits().withSocketFactory(factory);
    ResourceLimits.EndpointAndGlobal reserveCapacityInBytes = new ResourceLimits.EndpointAndGlobal(new ResourceLimits.Concurrent(outboundSettings.applicationSendQueueReserveEndpointCapacityInBytes), outboundSettings.applicationSendQueueReserveGlobalCapacityInBytes);
    OutboundConnection outbound = new OutboundConnection(settings.type, outboundSettings, reserveCapacityInBytes);
    try {
        InboundProxyHandler.Controller controller = new InboundProxyHandler.Controller();
        inbound.open(pipeline -> {
            InboundProxyHandler handler = new InboundProxyHandler(controller);
            pipeline.addLast(handler);
        }).sync();
        test.accept(Pair.create(inboundSettings, outboundSettings), inbound, outbound, endpoint, controller);
    } finally {
        outbound.close(false);
        inbound.close().get(30L, SECONDS);
        outbound.close(false).get(30L, SECONDS);
        MessagingService.instance().messageHandlers.clear();
    }
}
Also used : InetAddressAndPort(org.apache.cassandra.locator.InetAddressAndPort) CompactionManager(org.apache.cassandra.db.compaction.CompactionManager) BeforeClass(org.junit.BeforeClass) CommitLog(org.apache.cassandra.db.commitlog.CommitLog) TimeoutException(java.util.concurrent.TimeoutException) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) Supplier(java.util.function.Supplier) ByteBuf(io.netty.buffer.ByteBuf) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Pair(org.apache.cassandra.utils.Pair) InboundProxyHandler(org.apache.cassandra.net.proxy.InboundProxyHandler) Map(java.util.Map) After(org.junit.After) IVersionedAsymmetricSerializer(org.apache.cassandra.io.IVersionedAsymmetricSerializer) DataOutputPlus(org.apache.cassandra.io.util.DataOutputPlus) IVersionedSerializer(org.apache.cassandra.io.IVersionedSerializer) ToLongFunction(java.util.function.ToLongFunction) DatabaseDescriptor(org.apache.cassandra.config.DatabaseDescriptor) Global.approxTime(org.apache.cassandra.utils.MonotonicClock.Global.approxTime) Uninterruptibles(com.google.common.util.concurrent.Uninterruptibles) FBUtilities(org.apache.cassandra.utils.FBUtilities) IOException(java.io.IOException) Test(org.junit.Test) MILLISECONDS(java.util.concurrent.TimeUnit.MILLISECONDS) CRC(org.apache.cassandra.net.OutboundConnectionSettings.Framing.CRC) TimeUnit(java.util.concurrent.TimeUnit) CountDownLatch(java.util.concurrent.CountDownLatch) SETTINGS(org.apache.cassandra.net.ConnectionTest.SETTINGS) DataInputPlus(org.apache.cassandra.io.util.DataInputPlus) Assert(org.junit.Assert) Collections(java.util.Collections) SECONDS(java.util.concurrent.TimeUnit.SECONDS) InetAddressAndPort(org.apache.cassandra.locator.InetAddressAndPort) InboundProxyHandler(org.apache.cassandra.net.proxy.InboundProxyHandler)

Aggregations

Uninterruptibles (com.google.common.util.concurrent.Uninterruptibles)1 ByteBuf (io.netty.buffer.ByteBuf)1 IOException (java.io.IOException)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 TimeUnit (java.util.concurrent.TimeUnit)1 MILLISECONDS (java.util.concurrent.TimeUnit.MILLISECONDS)1 SECONDS (java.util.concurrent.TimeUnit.SECONDS)1 TimeoutException (java.util.concurrent.TimeoutException)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Supplier (java.util.function.Supplier)1 ToLongFunction (java.util.function.ToLongFunction)1 DatabaseDescriptor (org.apache.cassandra.config.DatabaseDescriptor)1 CommitLog (org.apache.cassandra.db.commitlog.CommitLog)1 CompactionManager (org.apache.cassandra.db.compaction.CompactionManager)1 IVersionedAsymmetricSerializer (org.apache.cassandra.io.IVersionedAsymmetricSerializer)1 IVersionedSerializer (org.apache.cassandra.io.IVersionedSerializer)1