diff --git a/build.xml b/build.xml index c11a796b85..7cc06935ce 100644 --- a/build.xml +++ b/build.xml @@ -348,7 +348,7 @@ - + diff --git a/test/distributed/org/apache/cassandra/distributed/impl/DelegatingInvokableInstance.java b/test/distributed/org/apache/cassandra/distributed/impl/DelegatingInvokableInstance.java index dfd6406fe9..90260a440e 100644 --- a/test/distributed/org/apache/cassandra/distributed/impl/DelegatingInvokableInstance.java +++ b/test/distributed/org/apache/cassandra/distributed/impl/DelegatingInvokableInstance.java @@ -20,7 +20,6 @@ package org.apache.cassandra.distributed.impl; import java.io.Serializable; import java.net.InetSocketAddress; -import java.util.List; import java.util.UUID; import java.util.concurrent.Future; import java.util.function.BiConsumer; @@ -35,8 +34,6 @@ import org.apache.cassandra.distributed.api.IInvokableInstance; import org.apache.cassandra.distributed.api.IListen; import org.apache.cassandra.distributed.api.IMessage; import org.apache.cassandra.distributed.api.SimpleQueryResult; -import org.apache.cassandra.distributed.shared.NetworkTopology; -import org.apache.cassandra.utils.FBUtilities; public abstract class DelegatingInvokableInstance implements IInvokableInstance { @@ -142,12 +139,24 @@ public abstract class DelegatingInvokableInstance implements IInvokableInstance delegateForStartup().startup(cluster); } + @Override + public void postStartup() + { + delegateForStartup().postStartup(); + } + @Override public void receiveMessage(IMessage message) { delegate().receiveMessage(message); } + @Override + public void receiveMessageWithInvokingThread(IMessage message) + { + delegate().receiveMessageWithInvokingThread(message); + } + @Override public CallableNoExcept> async(CallableNoExcept call) { @@ -196,6 +205,18 @@ public abstract class DelegatingInvokableInstance implements IInvokableInstance return delegate().sync(consumer); } + @Override + public TriFunction> async(TriConsumer consumer) + { + return delegate().async(consumer); + } + + @Override + public TriConsumer sync(TriConsumer consumer) + { + return delegate().sync(consumer); + } + @Override public Function> async(Function f) { @@ -232,4 +253,27 @@ public abstract class DelegatingInvokableInstance implements IInvokableInstance return delegate().sync(f); } + @Override + public QuadFunction> async(QuadFunction f) + { + return delegate().async(f); + } + + @Override + public QuadFunction sync(QuadFunction f) + { + return delegate().sync(f); + } + + @Override + public QuintFunction> async(QuintFunction f) + { + return delegate().async(f); + } + + @Override + public QuintFunction sync(QuintFunction f) + { + return delegate().sync(f); + } } diff --git a/test/distributed/org/apache/cassandra/distributed/impl/Instance.java b/test/distributed/org/apache/cassandra/distributed/impl/Instance.java index dff47d0c9b..aad46dd2a4 100644 --- a/test/distributed/org/apache/cassandra/distributed/impl/Instance.java +++ b/test/distributed/org/apache/cassandra/distributed/impl/Instance.java @@ -470,40 +470,44 @@ public class Instance extends IsolatedExecutor implements IInvokableInstance public void receiveMessage(IMessage imessage) { - sync(() -> { - Pair, Integer> deserialized = null; - try - { - deserialized = deserializeMessage(imessage); - } - catch (Throwable t) - { - throw new RuntimeException("Exception occurred on node " + broadcastAddress(), t); - } + sync(() -> receiveMessageWithInvokingThread(imessage)).run(); + } - MessageIn message = deserialized.left; - int partial = deserialized.right; + @Override + public void receiveMessageWithInvokingThread(IMessage imessage) + { + Pair, Integer> deserialized = null; + try + { + deserialized = deserializeMessage(imessage); + } + catch (Throwable t) + { + throw new RuntimeException("Exception occurred on node " + broadcastAddress(), t); + } - long timestamp = System.currentTimeMillis(); - boolean isCrossNodeTimestamp = false; + MessageIn message = deserialized.left; + int partial = deserialized.right; - if (DatabaseDescriptor.hasCrossNodeTimeout()) - { - long crossNodeTimestamp = (timestamp & 0xFFFFFFFF00000000L) | (((partial & 0xFFFFFFFFL) << 2) >> 2); - isCrossNodeTimestamp = (timestamp != crossNodeTimestamp); - timestamp = crossNodeTimestamp; - } + long timestamp = System.currentTimeMillis(); + boolean isCrossNodeTimestamp = false; - if (message == null) - { - // callback expired; nothing to do - return; - } - if (message.version <= MessagingService.current_version) - { - MessagingService.instance().receive(message, imessage.id(), timestamp, isCrossNodeTimestamp); - } - }).run(); + if (DatabaseDescriptor.hasCrossNodeTimeout()) + { + long crossNodeTimestamp = (timestamp & 0xFFFFFFFF00000000L) | (((partial & 0xFFFFFFFFL) << 2) >> 2); + isCrossNodeTimestamp = (timestamp != crossNodeTimestamp); + timestamp = crossNodeTimestamp; + } + + if (message == null) + { + // callback expired; nothing to do + return; + } + if (message.version <= MessagingService.current_version) + { + MessagingService.instance().receive(message, imessage.id(), timestamp, isCrossNodeTimestamp); + } } public int getMessagingVersion() @@ -648,7 +652,7 @@ public class Instance extends IsolatedExecutor implements IInvokableInstance private static Config loadConfig(IInstanceConfig overrides) { - Map params = ((InstanceConfig) overrides).getParams(); + Map params = overrides.getParams(); boolean check = true; if (overrides.get(Constants.KEY_DTEST_API_CONFIG_CHECK) != null) check = (boolean) overrides.get(Constants.KEY_DTEST_API_CONFIG_CHECK); diff --git a/test/distributed/org/apache/cassandra/distributed/impl/InstanceConfig.java b/test/distributed/org/apache/cassandra/distributed/impl/InstanceConfig.java index b97cb75097..d6180c2335 100644 --- a/test/distributed/org/apache/cassandra/distributed/impl/InstanceConfig.java +++ b/test/distributed/org/apache/cassandra/distributed/impl/InstanceConfig.java @@ -36,7 +36,6 @@ import org.apache.cassandra.distributed.api.Feature; import org.apache.cassandra.distributed.api.IInstanceConfig; import org.apache.cassandra.distributed.shared.NetworkTopology; import org.apache.cassandra.distributed.shared.Shared; -import org.apache.cassandra.distributed.upgrade.UpgradeTestBase; import org.apache.cassandra.locator.InetAddressAndPort; import org.apache.cassandra.locator.SimpleSeedProvider; @@ -189,7 +188,7 @@ public class InstanceConfig implements IInstanceConfig return this; } - private InstanceConfig forceSet(String fieldName, Object value) + public InstanceConfig forceSet(String fieldName, Object value) { if (value == null) value = NULL; diff --git a/test/distributed/org/apache/cassandra/distributed/impl/IsolatedExecutor.java b/test/distributed/org/apache/cassandra/distributed/impl/IsolatedExecutor.java index fc31fdf978..53c1ad56b0 100644 --- a/test/distributed/org/apache/cassandra/distributed/impl/IsolatedExecutor.java +++ b/test/distributed/org/apache/cassandra/distributed/impl/IsolatedExecutor.java @@ -117,6 +117,9 @@ public class IsolatedExecutor implements IIsolatedExecutor public BiFunction> async(BiConsumer consumer) { return (a, b) -> isolatedExecutor.submit(() -> consumer.accept(a, b)); } public BiConsumer sync(BiConsumer consumer) { return (a, b) -> waitOn(async(consumer).apply(a, b)); } + public TriFunction> async(TriConsumer consumer) { return (a, b, c) -> isolatedExecutor.submit(() -> consumer.accept(a, b, c)); } + public TriConsumer sync(TriConsumer consumer) { return (a, b, c) -> waitOn(async(consumer).apply(a, b, c)); } + public Function> async(Function f) { return (a) -> isolatedExecutor.submit(() -> f.apply(a)); } public Function sync(Function f) { return (a) -> waitOn(async(f).apply(a)); } @@ -126,6 +129,12 @@ public class IsolatedExecutor implements IIsolatedExecutor public TriFunction> async(TriFunction f) { return (a, b, c) -> isolatedExecutor.submit(() -> f.apply(a, b, c)); } public TriFunction sync(TriFunction f) { return (a, b, c) -> waitOn(async(f).apply(a, b, c)); } + public QuadFunction> async(QuadFunction f) { return (a, b, c, d) -> isolatedExecutor.submit(() -> f.apply(a, b, c, d)); } + public QuadFunction sync(QuadFunction f) { return (a, b, c, d) -> waitOn(async(f).apply(a, b, c, d)); } + + public QuintFunction> async(QuintFunction f) { return (a, b, c, d, e) -> isolatedExecutor.submit(() -> f.apply(a, b, c, d, e)); } + public QuintFunction sync(QuintFunction f) { return (a, b, c, d,e ) -> waitOn(async(f).apply(a, b, c, d, e)); } + public E transfer(E object) { return (E) transferOneObject(object, classLoader, deserializeOnInstance);