use of org.infinispan.server.hotrod.test.HotRodClient in project infinispan by infinispan.
the class HotRodSharedContainerTest method testSharedContainer.
public void testSharedContainer(Method m) {
int basePort = serverPort();
hotRodServer1 = startHotRodServer(cacheManagers.get(0), basePort, new HotRodServerConfigurationBuilder().name("1"));
hotRodServer2 = startHotRodServer(cacheManagers.get(0), basePort + 50, new HotRodServerConfigurationBuilder().name("2"));
hotRodClient1 = new HotRodClient("127.0.0.1", hotRodServer1.getPort(), cacheName, (byte) 20);
hotRodClient2 = new HotRodClient("127.0.0.1", hotRodServer2.getPort(), cacheName, (byte) 20);
hotRodClient1.put(k(m), 0, 0, v(m));
assertSuccess(hotRodClient2.get(k(m), 0), v(m));
}
use of org.infinispan.server.hotrod.test.HotRodClient in project infinispan by infinispan.
the class HotRodSingleClusteredTest method createBeforeClass.
@BeforeClass(alwaysRun = true)
@Override
public void createBeforeClass() throws Throwable {
super.createBeforeClass();
hotRodServer = startHotRodServer(cacheManagers.get(0));
hotRodClient = new HotRodClient("127.0.0.1", hotRodServer.getPort(), cacheName, (byte) 20);
}
use of org.infinispan.server.hotrod.test.HotRodClient in project infinispan by infinispan.
the class HotRodFunctionalTest method testLifespan3x.
public void testLifespan3x(Method m) {
try (HotRodClient client3x = connectClient(HotRodVersion.HOTROD_30.getVersion())) {
// Set a lifespan that would be interpreted as seconds since the Unix epoch in previous versions
int expirationSeconds = (int) TimeUnit.DAYS.toSeconds(90);
assertStatus(client3x.put(k(m), expirationSeconds, expirationSeconds, v(m)), Success);
CacheEntry<byte[], byte[]> entry = advancedCache.withStorageMediaType().getCacheEntry(k(m));
// The lifespan is interpreted as seconds since inserted, not since the Unix epoch
assertEquals(expirationSeconds * 1000L, entry.getLifespan());
assertEquals(expirationSeconds * 1000L, entry.getMaxIdle());
}
}
use of org.infinispan.server.hotrod.test.HotRodClient in project infinispan by infinispan.
the class HotRodStatsClusterTest method testClusterStats.
public void testClusterStats(Method m) throws Exception {
HotRodClient client1 = clients().get(0);
HotRodClient client2 = clients().get(1);
byte[] key1 = HotRodMagicKeyGenerator.newKey(cache(0, cacheName()));
byte[] value = v(m, "v1-");
TestResponse resp = client1.put(key1, 0, 0, value, INTELLIGENCE_HASH_DISTRIBUTION_AWARE, 0);
assertStatus(resp, Success);
assertSuccess(client1.get(key1, 0), value);
client1.remove(k(m));
Map<String, String> stats1 = client1.stats();
assertEquals(stats1.get("currentNumberOfEntries"), "1");
assertEquals(stats1.get("totalNumberOfEntries"), "1");
assertEquals(stats1.get("stores"), "1");
assertEquals(stats1.get("hits"), "1");
assertEquals(stats1.get("retrievals"), "1");
assertEquals(stats1.get("removeMisses"), "1");
assertEquals(stats1.get("globalCurrentNumberOfEntries"), "1");
assertEquals(stats1.get("globalStores"), "1");
assertEquals(stats1.get("globalHits"), "1");
assertEquals(stats1.get("globalRetrievals"), "1");
assertEquals(stats1.get("globalRemoveMisses"), "1");
Map<String, String> stats2 = client2.stats();
assertEquals(stats2.get("currentNumberOfEntries"), "0");
assertEquals(stats2.get("totalNumberOfEntries"), "0");
assertEquals(stats2.get("stores"), "0");
assertEquals(stats2.get("hits"), "0");
assertEquals(stats2.get("retrievals"), "0");
assertEquals(stats2.get("removeMisses"), "0");
assertEquals(stats2.get("globalCurrentNumberOfEntries"), "1");
assertEquals(stats2.get("globalStores"), "1");
assertEquals(stats2.get("globalHits"), "1");
assertEquals(stats2.get("globalRetrievals"), "1");
assertEquals(stats2.get("globalRemoveMisses"), "1");
timeService.advance(AbstractClusterStats.DEFAULT_STALE_STATS_THRESHOLD + 1);
client1.remove(key1);
assertKeyDoesNotExist(client1.get(key1, 0));
stats1 = client1.stats();
assertEquals(stats1.get("misses"), "1");
assertEquals(stats1.get("removeHits"), "1");
assertEquals(stats1.get("globalMisses"), "1");
assertEquals(stats1.get("globalRemoveHits"), "1");
stats2 = client2.stats();
assertEquals(stats2.get("misses"), "0");
assertEquals(stats2.get("removeHits"), "0");
assertEquals(stats2.get("globalMisses"), "1");
assertEquals(stats2.get("globalRemoveHits"), "1");
}
Aggregations