diff --git a/getputremovetest/pom.xml b/getputremovetest/pom.xml
index 61d5313..e9bf406 100644
--- a/getputremovetest/pom.xml
+++ b/getputremovetest/pom.xml
@@ -80,7 +80,6 @@ THE POSSIBILITY OF SUCH DAMAGE.
7.7.0
-
diff --git a/getputremovetest/src/main/java/org/infinispan/InfinispanRemoteHolder.java b/getputremovetest/src/main/java/org/infinispan/InfinispanRemoteHolder.java
new file mode 100644
index 0000000..74cfecc
--- /dev/null
+++ b/getputremovetest/src/main/java/org/infinispan/InfinispanRemoteHolder.java
@@ -0,0 +1,106 @@
+package org.infinispan;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.LongAdder;
+
+import org.infinispan.client.hotrod.RemoteCache;
+import org.infinispan.client.hotrod.RemoteCacheManager;
+import org.infinispan.client.hotrod.configuration.ConfigurationBuilder;
+import org.infinispan.client.hotrod.impl.ConfigurationProperties;
+import org.infinispan.manager.DefaultCacheManager;
+import org.infinispan.server.hotrod.HotRodServer;
+import org.infinispan.server.hotrod.configuration.HotRodServerConfiguration;
+import org.infinispan.server.hotrod.configuration.HotRodServerConfigurationBuilder;
+import org.openjdk.jmh.annotations.Param;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.Setup;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.annotations.TearDown;
+
+@State(Scope.Benchmark)
+public class InfinispanRemoteHolder {
+
+ private static final AtomicInteger hotRodPort = new AtomicInteger(ConfigurationProperties.DEFAULT_HOTROD_PORT);
+
+ static final String cfg = System.getProperty( "infinispan.cfg", "dist-sync.xml" );
+
+ private final LongAdder gets = new LongAdder();
+ private final LongAdder puts = new LongAdder();
+ private final LongAdder removes = new LongAdder();
+
+ private final AtomicInteger cacheRequestCount = new AtomicInteger();
+
+ private DefaultCacheManager[] mgrs;
+ private RemoteCacheManager[] remotes;
+ private RemoteCache, ?>[] caches;
+
+ private HotRodServer[] servers;
+
+ @Param("3")
+ private int nodes;
+
+ @Param({"1", "3"})
+ private int remoteClients;
+
+ @Param({"-1"})
+ int maxPoolSize = -1;
+
+ @Setup
+ public void initializeState() throws IOException {
+ mgrs = new DefaultCacheManager[nodes];
+ servers = new HotRodServer[nodes];
+ remotes = new RemoteCacheManager[remoteClients];
+ caches = new RemoteCache[remoteClients];
+ HotRodServerConfiguration firstConfig = null;
+
+ for (int i = 0; i < nodes; ++i) {
+ mgrs[i] = new DefaultCacheManager(cfg);
+ HotRodServerConfigurationBuilder configurationBuilder = new HotRodServerConfigurationBuilder();
+ configurationBuilder.port(hotRodPort.getAndIncrement());
+ HotRodServerConfiguration hotRodServerConfiguration = configurationBuilder.build();
+ if (firstConfig == null) {
+ firstConfig = hotRodServerConfiguration;
+ }
+ servers[i] = new HotRodServer();
+ servers[i].start(hotRodServerConfiguration, mgrs[i]);
+ System.out.printf("Started server %d\n", hotRodServerConfiguration.port());
+ }
+
+ ConfigurationBuilder remoteCacheConfigurationBuilder = new ConfigurationBuilder();
+ remoteCacheConfigurationBuilder.connectionPool().maxActive(maxPoolSize);
+ remoteCacheConfigurationBuilder.addServer().host(firstConfig.host()).port(firstConfig.port());
+ for (int i = 0; i < remoteClients; ++i) {
+ remotes[i] = new RemoteCacheManager(remoteCacheConfigurationBuilder.build());
+ caches[i] = remotes[i].getCache();
+ }
+ }
+
+ @TearDown
+ public void shutdownState() {
+ Arrays.stream(servers).forEach(HotRodServer::stop);
+ Arrays.stream(mgrs).forEach(DefaultCacheManager::stop);
+ System.out.println( "Gets performed: " + gets.longValue() );
+ System.out.println( "Puts performed: " + puts.longValue() );
+ System.out.println( "Removes performed: " + removes.longValue() );
+ }
+
+ public RemoteCache getCache() {
+ int offset = cacheRequestCount.getAndIncrement();
+ return caches[offset % caches.length];
+ }
+
+ public void cacheGetDone() {
+ gets.increment();
+ }
+
+ public void cachePutDone() {
+ puts.increment();
+ }
+
+ public void cacheRemoveDone() {
+ removes.increment();
+ }
+}
+
diff --git a/getputremovetest/src/main/java/org/infinispan/JMHBenchmarks.java b/getputremovetest/src/main/java/org/infinispan/JMHBenchmarks.java
index 3168827..aa989be 100644
--- a/getputremovetest/src/main/java/org/infinispan/JMHBenchmarks.java
+++ b/getputremovetest/src/main/java/org/infinispan/JMHBenchmarks.java
@@ -1,5 +1,6 @@
package org.infinispan;
+import org.infinispan.client.hotrod.RemoteCache;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
@@ -23,36 +24,36 @@
@BenchmarkMode(Mode.Throughput)
public class JMHBenchmarks {
-// @Benchmark
-// @GroupThreads(2)
-// @Group("getPutHotRod")
-// public void infinispanRemoteRemove(InfinispanRemoteHolder ih, Blackhole bh, KeySequenceGenerator kg) {
-// Object key = kg.getNextKey();
-// RemoteCache cache = ih.getCache();
-// bh.consume( cache.remove( key) );
-// ih.cacheRemoveDone();
-// }
-//
-// @Benchmark
-// @GroupThreads(4)
-// @Group("getPutHotRod")
-// public void infinispanRemotePut(InfinispanRemoteHolder ih, Blackhole bh, KeySequenceGenerator kg) {
-// Object key = kg.getNextKey();
-// Object value = kg.getNextValue();
-// RemoteCache cache = ih.getCache();
-// bh.consume( cache.put( key, value ) );
-// ih.cachePutDone();
-// }
-//
-// @Benchmark
-// @GroupThreads(16)
-// @Group("getPutHotRod")
-// public void infinispanRemoteGet(InfinispanRemoteHolder ih, Blackhole bh, KeySequenceGenerator kg) {
-// Object key = kg.getNextKey();
-// RemoteCache cache = ih.getCache();
-// bh.consume( cache.get( key ) );
-// ih.cacheGetDone();
-// }
+ @Benchmark
+ @GroupThreads(2)
+ @Group("getPutHotRod")
+ public void infinispanRemoteRemove(InfinispanRemoteHolder ih, Blackhole bh, KeySequenceGenerator kg) {
+ Object key = kg.getNextKey();
+ RemoteCache cache = ih.getCache();
+ bh.consume( cache.remove( key) );
+ ih.cacheRemoveDone();
+ }
+
+ @Benchmark
+ @GroupThreads(4)
+ @Group("getPutHotRod")
+ public void infinispanRemotePut(InfinispanRemoteHolder ih, Blackhole bh, KeySequenceGenerator kg) {
+ Object key = kg.getNextKey();
+ Object value = kg.getNextValue();
+ RemoteCache cache = ih.getCache();
+ bh.consume( cache.put( key, value ) );
+ ih.cachePutDone();
+ }
+
+ @Benchmark
+ @GroupThreads(16)
+ @Group("getPutHotRod")
+ public void infinispanRemoteGet(InfinispanRemoteHolder ih, Blackhole bh, KeySequenceGenerator kg) {
+ Object key = kg.getNextKey();
+ RemoteCache cache = ih.getCache();
+ bh.consume( cache.get( key ) );
+ ih.cacheGetDone();
+ }
@Benchmark
@Threads(16)
diff --git a/getputremovetest/src/main/java/org/infinispan/KeySequenceGenerator.java b/getputremovetest/src/main/java/org/infinispan/KeySequenceGenerator.java
index 4508fb6..69520d6 100644
--- a/getputremovetest/src/main/java/org/infinispan/KeySequenceGenerator.java
+++ b/getputremovetest/src/main/java/org/infinispan/KeySequenceGenerator.java
@@ -1,10 +1,17 @@
package org.infinispan;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
import java.io.Serializable;
import java.util.Arrays;
+import java.util.Set;
import org.apache.commons.math3.random.JDKRandomGenerator;
import org.apache.commons.math3.random.RandomDataGenerator;
+import org.infinispan.commons.io.UnsignedNumeric;
+import org.infinispan.commons.marshall.AdvancedExternalizer;
+import org.infinispan.commons.util.Util;
import org.openjdk.jmh.annotations.Param;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
@@ -109,6 +116,32 @@ else if (obj instanceof ValueWrapper)
else
return false;
}
+ }
+
+ public static class ValueWrapperSerializer implements AdvancedExternalizer {
+ @Override
+ public Set> getTypeClasses() {
+ return Util.asSet(ValueWrapper.class);
+ }
+
+ @Override
+ public Integer getId() {
+ return 205;
+ }
+
+ @Override
+ public void writeObject(ObjectOutput objectOutput, ValueWrapper valueWrapper) throws IOException {
+ UnsignedNumeric.writeUnsignedInt(objectOutput, valueWrapper.bytes.length);
+ objectOutput.write(valueWrapper.bytes);
+ }
+
+ @Override
+ public ValueWrapper readObject(ObjectInput objectInput) throws IOException, ClassNotFoundException {
+ int size = UnsignedNumeric.readUnsignedInt(objectInput);
+ byte[] bytes = new byte[size];
+ objectInput.read(bytes);
+ return new ValueWrapper(bytes);
+ }
}
}
diff --git a/getputremovetest/src/main/resources/dist-sync.xml b/getputremovetest/src/main/resources/dist-sync.xml
new file mode 100644
index 0000000..d312ebc
--- /dev/null
+++ b/getputremovetest/src/main/resources/dist-sync.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+