Search in sources :

Example 11 with HotRodClient

use of org.infinispan.server.hotrod.test.HotRodClient in project infinispan by infinispan.

the class AbstractHotRodClusterEventsTest method testNoEventReplayAfterAddingListenerInCluster.

public void testNoEventReplayAfterAddingListenerInCluster(Method m) {
    HotRodClient client1 = clients().get(0);
    HotRodClient client2 = clients().get(1);
    HotRodClient client3 = clients().get(2);
    byte[] k1 = k(m, "k1-");
    byte[] v1 = v(m, "v1-");
    byte[] k2 = k(m, "k2-");
    byte[] v2 = v(m, "v2-");
    byte[] k3 = k(m, "k3-");
    byte[] v3 = v(m, "v3-");
    client1.put(k1, 0, 0, v1);
    client2.put(k2, 0, 0, v2);
    client3.put(k3, 0, 0, v3);
    EventLogListener listener1 = new EventLogListener();
    withClientListener(client1, listener1, Optional.empty(), Optional.empty(), false, true, () -> {
        listener1.expectNoEvents(Optional.empty());
        client1.remove(k1);
        listener1.expectOnlyRemovedEvent(anyCache(), k1);
        client2.remove(k2);
        listener1.expectOnlyRemovedEvent(anyCache(), k2);
        client3.remove(k3);
        listener1.expectOnlyRemovedEvent(anyCache(), k3);
    });
}
Also used : HotRodClient(org.infinispan.server.hotrod.test.HotRodClient)

Example 12 with HotRodClient

use of org.infinispan.server.hotrod.test.HotRodClient in project infinispan by infinispan.

the class AbstractHotRodClusterEventsTest method testEventReplayAfterAddingListenerInCluster.

public void testEventReplayAfterAddingListenerInCluster(Method m) {
    HotRodClient client1 = clients().get(0);
    HotRodClient client2 = clients().get(1);
    HotRodClient client3 = clients().get(2);
    byte[] k1 = k(m, "k1-");
    byte[] v1 = v(m, "v1-");
    byte[] k2 = k(m, "k2-");
    byte[] v2 = v(m, "v2-");
    byte[] k3 = k(m, "k3-");
    byte[] v3 = v(m, "v3-");
    client1.put(k1, 0, 0, v1);
    client2.put(k2, 0, 0, v2);
    client3.put(k3, 0, 0, v3);
    EventLogListener listener1 = new EventLogListener();
    withClientListener(client1, listener1, Optional.empty(), Optional.empty(), true, true, () -> {
        List<byte[]> keys = Arrays.asList(k1, k2, k3);
        listener1.expectUnorderedEvents(anyCache(), keys, Event.Type.CACHE_ENTRY_CREATED);
        client1.remove(k1);
        listener1.expectOnlyRemovedEvent(anyCache(), k1);
        client2.remove(k2);
        listener1.expectOnlyRemovedEvent(anyCache(), k2);
        client3.remove(k3);
        listener1.expectOnlyRemovedEvent(anyCache(), k3);
    });
}
Also used : HotRodClient(org.infinispan.server.hotrod.test.HotRodClient)

Example 13 with HotRodClient

use of org.infinispan.server.hotrod.test.HotRodClient in project infinispan by infinispan.

the class AbstractHotRodClusterEventsTest method testFilteringInCluster.

public void testFilteringInCluster(Method m) {
    HotRodClient client1 = clients().get(0);
    HotRodClient client2 = clients().get(1);
    EventLogListener listener1 = new EventLogListener();
    Optional<KeyValuePair<String, List<byte[]>>> filterFactory = Optional.of(new KeyValuePair<String, List<byte[]>>("accepted-key-filter-factory", Collections.emptyList()));
    byte[] key1 = k(m, "k1-");
    withClusterClientListener(client1, listener1, filterFactory, Optional.empty(), key1, false, () -> {
        client2.put(k(m, "k-99"), 0, 0, v(m));
        listener1.expectNoEvents(Optional.empty());
        client2.remove(k(m, "k-99"));
        listener1.expectNoEvents(Optional.empty());
        client2.put(key1, 0, 0, v(m));
        listener1.expectOnlyCreatedEvent(anyCache(), key1);
        client1.remove(key1);
        listener1.expectOnlyRemovedEvent(anyCache(), key1);
    });
}
Also used : KeyValuePair(org.infinispan.util.KeyValuePair) HotRodClient(org.infinispan.server.hotrod.test.HotRodClient) ArrayList(java.util.ArrayList) List(java.util.List)

Example 14 with HotRodClient

use of org.infinispan.server.hotrod.test.HotRodClient in project infinispan by infinispan.

the class AbstractHotRodClusterEventsTest method testParameterBasedFilteringInCluster.

public void testParameterBasedFilteringInCluster(Method m) {
    HotRodClient client1 = clients().get(0);
    HotRodClient client2 = clients().get(1);
    EventLogListener listener1 = new EventLogListener();
    byte[] dynamicAcceptedKey = new byte[] { 4, 5, 6 };
    Optional<KeyValuePair<String, List<byte[]>>> filterFactory = Optional.of(new KeyValuePair<>("accepted-key-filter-factory", Collections.singletonList(dynamicAcceptedKey)));
    withClusterClientListener(client1, listener1, filterFactory, Optional.empty(), null, false, () -> {
        byte[] key1 = k(m, "k1-");
        client2.put(k(m, "k-99"), 0, 0, v(m));
        listener1.expectNoEvents(Optional.empty());
        client2.remove(k(m, "k-99"));
        listener1.expectNoEvents(Optional.empty());
        client2.put(key1, 0, 0, v(m));
        listener1.expectNoEvents(Optional.empty());
        client2.put(dynamicAcceptedKey, 0, 0, v(m));
        listener1.expectOnlyCreatedEvent(anyCache(), dynamicAcceptedKey);
        client1.remove(dynamicAcceptedKey);
        listener1.expectOnlyRemovedEvent(anyCache(), dynamicAcceptedKey);
    });
}
Also used : KeyValuePair(org.infinispan.util.KeyValuePair) HotRodClient(org.infinispan.server.hotrod.test.HotRodClient)

Example 15 with HotRodClient

use of org.infinispan.server.hotrod.test.HotRodClient in project infinispan by infinispan.

the class AbstractHotRodClusterEventsTest method testEventForwarding.

public void testEventForwarding(Method m) {
    // Registering listener in one node and executing operations against
    // different nodes should still result in events received
    HotRodClient client1 = clients().get(0);
    HotRodClient client2 = clients().get(1);
    HotRodClient client3 = clients().get(2);
    EventLogListener listener1 = new EventLogListener();
    withClientListener(client1, listener1, Optional.empty(), Optional.empty(), false, true, () -> {
        byte[] key = k(m);
        client2.put(key, 0, 0, v(m));
        listener1.expectOnlyCreatedEvent(anyCache(), key);
        client3.put(key, 0, 0, v(m, "v2-"));
        listener1.expectOnlyModifiedEvent(anyCache(), key);
        client2.remove(key);
        listener1.expectOnlyRemovedEvent(anyCache(), key);
    });
}
Also used : 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