Search in sources :

Example 26 with HotRodClient

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));
}
Also used : HotRodClient(org.infinispan.server.hotrod.test.HotRodClient) HotRodServerConfigurationBuilder(org.infinispan.server.hotrod.configuration.HotRodServerConfigurationBuilder)

Example 27 with HotRodClient

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);
}
Also used : HotRodClient(org.infinispan.server.hotrod.test.HotRodClient) BeforeClass(org.testng.annotations.BeforeClass)

Example 28 with HotRodClient

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());
    }
}
Also used : HotRodClient(org.infinispan.server.hotrod.test.HotRodClient)

Example 29 with HotRodClient

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");
}
Also used : TestResponse(org.infinispan.server.hotrod.test.TestResponse) HotRodClient(org.infinispan.server.hotrod.test.HotRodClient)

Aggregations

HotRodClient (org.infinispan.server.hotrod.test.HotRodClient)29 KeyValuePair (org.infinispan.util.KeyValuePair)4 ArrayList (java.util.ArrayList)3 TestResponse (org.infinispan.server.hotrod.test.TestResponse)3 NetworkInterface (java.net.NetworkInterface)2 List (java.util.List)2 XidImpl (org.infinispan.commons.tx.XidImpl)2 TestSizeResponse (org.infinispan.server.hotrod.test.TestSizeResponse)2 TxResponse (org.infinispan.server.hotrod.test.TxResponse)2 BeforeClass (org.testng.annotations.BeforeClass)2 InetAddress (java.net.InetAddress)1 InterfaceAddress (java.net.InterfaceAddress)1 Future (java.util.concurrent.Future)1 SSLContext (javax.net.ssl.SSLContext)1 SSLEngine (javax.net.ssl.SSLEngine)1 SslContextFactory (org.infinispan.commons.util.SslContextFactory)1 ConfigurationBuilder (org.infinispan.configuration.cache.ConfigurationBuilder)1 SslConfiguration (org.infinispan.server.core.configuration.SslConfiguration)1 ServerTestingUtil (org.infinispan.server.core.test.ServerTestingUtil)1 HotRodServer (org.infinispan.server.hotrod.HotRodServer)1