Search in sources :

Example 1 with StaticCustomEventLogListener

use of org.infinispan.client.hotrod.event.CustomEventLogListener.StaticCustomEventLogListener in project infinispan by infinispan.

the class ClientClusterExpirationEventsTest method testConversionInCluster.

public void testConversionInCluster() {
    final Integer key0 = HotRodClientTestingUtil.getIntKeyForServer(server(0));
    final Integer key1 = HotRodClientTestingUtil.getIntKeyForServer(server(1));
    final StaticCustomEventLogListener<Integer> l = new StaticCustomEventLogListener<>(client(0).getCache());
    withClientListener(l, remote -> {
        l.expectNoEvents();
        remote.put(key0, "one", 10, TimeUnit.MINUTES);
        l.expectCreatedEvent(new CustomEvent(key0, "one", 0));
        remote.put(key1, "two", 10, TimeUnit.MINUTES);
        l.expectCreatedEvent(new CustomEvent(key1, "two", 0));
        // Now expire both
        ts0.advance(TimeUnit.MINUTES.toMillis(10) + 1);
        ts1.advance(TimeUnit.MINUTES.toMillis(10) + 1);
        assertNull(remote.get(key0));
        l.expectExpiredEvent(new CustomEvent(key0, "one", 0));
        assertNull(remote.get(key1));
        l.expectExpiredEvent(new CustomEvent(key1, "two", 0));
    });
}
Also used : CustomEvent(org.infinispan.client.hotrod.event.CustomEventLogListener.CustomEvent) StaticCustomEventLogListener(org.infinispan.client.hotrod.event.CustomEventLogListener.StaticCustomEventLogListener)

Example 2 with StaticCustomEventLogListener

use of org.infinispan.client.hotrod.event.CustomEventLogListener.StaticCustomEventLogListener in project infinispan by infinispan.

the class EmbeddedHotRodTest method testCustomEvents.

public void testCustomEvents() {
    StaticCustomEventLogListener<Integer> l = new StaticCustomEventLogListener<>(cacheFactory.getHotRodCache());
    withClientListener(l, remote -> {
        l.expectNoEvents();
        remote.put(1, "one");
        Cache<Integer, String> embedded = getEmbeddedCache();
        assertEquals("one", embedded.get(1));
        l.expectCreatedEvent(new CustomEvent(1, "one", 0));
        remote.put(1, "new-one");
        assertEquals("new-one", embedded.get(1));
        l.expectModifiedEvent(new CustomEvent(1, "new-one", 0));
        remote.remove(1);
        assertNull(embedded.get(1));
        l.expectRemovedEvent(new CustomEvent(1, null, 0));
    });
}
Also used : CustomEvent(org.infinispan.client.hotrod.event.CustomEventLogListener.CustomEvent) StaticCustomEventLogListener(org.infinispan.client.hotrod.event.CustomEventLogListener.StaticCustomEventLogListener)

Example 3 with StaticCustomEventLogListener

use of org.infinispan.client.hotrod.event.CustomEventLogListener.StaticCustomEventLogListener in project infinispan by infinispan.

the class ClientCustomEventsTest method testCustomEvents.

public void testCustomEvents() {
    final StaticCustomEventLogListener<Integer> l = new StaticCustomEventLogListener<>(remoteCacheManager.getCache());
    withClientListener(l, remote -> {
        l.expectNoEvents();
        remote.put(1, "one");
        l.expectCreatedEvent(new CustomEvent(1, "one", 0));
        remote.put(1, "newone");
        l.expectModifiedEvent(new CustomEvent(1, "newone", 0));
        remote.remove(1);
        l.expectRemovedEvent(new CustomEvent(1, null, 0));
    });
}
Also used : CustomEvent(org.infinispan.client.hotrod.event.CustomEventLogListener.CustomEvent) StaticCustomEventLogListener(org.infinispan.client.hotrod.event.CustomEventLogListener.StaticCustomEventLogListener) RawStaticCustomEventLogListener(org.infinispan.client.hotrod.event.CustomEventLogListener.RawStaticCustomEventLogListener)

Example 4 with StaticCustomEventLogListener

use of org.infinispan.client.hotrod.event.CustomEventLogListener.StaticCustomEventLogListener in project infinispan by infinispan.

the class ClientCustomEventsTest method testConvertedNoEventsReplay.

public void testConvertedNoEventsReplay() {
    RemoteCache<Integer, String> cache = remoteCacheManager.getCache();
    StaticCustomEventLogListener staticEventListener = new StaticCustomEventLogListener<>(cache);
    cache.put(1, "one");
    withClientListener(staticEventListener, remote -> staticEventListener.expectNoEvents());
    DynamicCustomEventLogListener dynamicEventListener = new DynamicCustomEventLogListener<>(cache);
    cache.put(2, "two");
    withClientListener(dynamicEventListener, null, new Object[] { 2 }, remote -> staticEventListener.expectNoEvents());
}
Also used : StaticCustomEventLogListener(org.infinispan.client.hotrod.event.CustomEventLogListener.StaticCustomEventLogListener) RawStaticCustomEventLogListener(org.infinispan.client.hotrod.event.CustomEventLogListener.RawStaticCustomEventLogListener) DynamicCustomEventLogListener(org.infinispan.client.hotrod.event.CustomEventLogListener.DynamicCustomEventLogListener)

Example 5 with StaticCustomEventLogListener

use of org.infinispan.client.hotrod.event.CustomEventLogListener.StaticCustomEventLogListener in project infinispan by infinispan.

the class ClientClusterEventsTest method testConversionInCluster.

public void testConversionInCluster() {
    final Integer key0 = HotRodClientTestingUtil.getIntKeyForServer(server(0));
    final Integer key1 = HotRodClientTestingUtil.getIntKeyForServer(server(1));
    final StaticCustomEventLogListener<Integer> l = new StaticCustomEventLogListener<>(client(0).getCache());
    withClientListener(l, remote -> {
        l.expectNoEvents();
        remote.put(key0, "one");
        l.expectCreatedEvent(new CustomEvent(key0, "one", 0));
        remote.put(key1, "two");
        l.expectCreatedEvent(new CustomEvent(key1, "two", 0));
        remote.remove(key0);
        l.expectRemovedEvent(new CustomEvent(key0, null, 0));
        remote.remove(key1);
        l.expectRemovedEvent(new CustomEvent(key1, null, 0));
    });
}
Also used : CustomEvent(org.infinispan.client.hotrod.event.CustomEventLogListener.CustomEvent) StaticCustomEventLogListener(org.infinispan.client.hotrod.event.CustomEventLogListener.StaticCustomEventLogListener)

Aggregations

StaticCustomEventLogListener (org.infinispan.client.hotrod.event.CustomEventLogListener.StaticCustomEventLogListener)5 CustomEvent (org.infinispan.client.hotrod.event.CustomEventLogListener.CustomEvent)4 RawStaticCustomEventLogListener (org.infinispan.client.hotrod.event.CustomEventLogListener.RawStaticCustomEventLogListener)2 DynamicCustomEventLogListener (org.infinispan.client.hotrod.event.CustomEventLogListener.DynamicCustomEventLogListener)1