Search in sources :

Example 1 with CustomEvent

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

the class ClientClusterEventsTest method testFilterCustomEventsInCluster.

public void testFilterCustomEventsInCluster() {
    final Integer key0 = HotRodClientTestingUtil.getIntKeyForServer(server(0));
    final Integer key1 = HotRodClientTestingUtil.getIntKeyForServer(server(1));
    final FilterCustomEventLogListener<Integer> l = new FilterCustomEventLogListener<>(client(0).getCache());
    withClientListener(l, new Object[] { key0 }, null, remote -> {
        remote.put(key0, "one");
        l.expectCreatedEvent(new CustomEvent(key0, null, 1));
        remote.put(key0, "newone");
        l.expectModifiedEvent(new CustomEvent(key0, null, 2));
        remote.put(key1, "two");
        l.expectCreatedEvent(new CustomEvent(key1, "two", 1));
        remote.put(key1, "dos");
        l.expectModifiedEvent(new CustomEvent(key1, "dos", 2));
        remote.remove(key0);
        l.expectRemovedEvent(new CustomEvent(key0, null, 3));
        remote.remove(key1);
        l.expectRemovedEvent(new CustomEvent(key1, null, 3));
    });
}
Also used : CustomEvent(org.infinispan.client.hotrod.event.CustomEventLogListener.CustomEvent) FilterCustomEventLogListener(org.infinispan.client.hotrod.event.CustomEventLogListener.FilterCustomEventLogListener)

Example 2 with CustomEvent

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

the class ClientClusterExpirationEventsTest method testFilterCustomEventsInCluster.

public void testFilterCustomEventsInCluster() {
    final Integer key0 = HotRodClientTestingUtil.getIntKeyForServer(server(0));
    final Integer key1 = HotRodClientTestingUtil.getIntKeyForServer(server(1));
    final FilterCustomEventLogListener<Integer> l = new FilterCustomEventLogListener<>(client(0).getCache());
    withClientListener(l, new Object[] { key0 }, null, remote -> {
        remote.put(key0, "one", 10, TimeUnit.MINUTES);
        l.expectCreatedEvent(new CustomEvent(key0, null, 1));
        remote.put(key1, "two", 10, TimeUnit.MINUTES);
        l.expectCreatedEvent(new CustomEvent(key1, "two", 1));
        // 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, null, 2));
        assertNull(remote.get(key1));
        l.expectExpiredEvent(new CustomEvent(key1, "two", 2));
    });
}
Also used : CustomEvent(org.infinispan.client.hotrod.event.CustomEventLogListener.CustomEvent) FilterCustomEventLogListener(org.infinispan.client.hotrod.event.CustomEventLogListener.FilterCustomEventLogListener)

Example 3 with CustomEvent

use of org.infinispan.client.hotrod.event.CustomEventLogListener.CustomEvent 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 4 with CustomEvent

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

the class ClientCustomEventsTest method testParameterBasedConversion.

public void testParameterBasedConversion() {
    final DynamicCustomEventLogListener<Integer> l = new DynamicCustomEventLogListener<>(remoteCacheManager.getCache());
    withClientListener(l, null, new Object[] { 2 }, remote -> {
        l.expectNoEvents();
        remote.put(1, "one");
        l.expectCreatedEvent(new CustomEvent(1, "one", 0));
        remote.put(2, "two");
        l.expectCreatedEvent(new CustomEvent(2, null, 0));
    });
}
Also used : CustomEvent(org.infinispan.client.hotrod.event.CustomEventLogListener.CustomEvent) DynamicCustomEventLogListener(org.infinispan.client.hotrod.event.CustomEventLogListener.DynamicCustomEventLogListener)

Example 5 with CustomEvent

use of org.infinispan.client.hotrod.event.CustomEventLogListener.CustomEvent 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)

Aggregations

CustomEvent (org.infinispan.client.hotrod.event.CustomEventLogListener.CustomEvent)10 StaticCustomEventLogListener (org.infinispan.client.hotrod.event.CustomEventLogListener.StaticCustomEventLogListener)4 FilterCustomEventLogListener (org.infinispan.client.hotrod.event.CustomEventLogListener.FilterCustomEventLogListener)3 DynamicCustomEventLogListener (org.infinispan.client.hotrod.event.CustomEventLogListener.DynamicCustomEventLogListener)2 DynamicCustomEventWithStateLogListener (org.infinispan.client.hotrod.event.CustomEventLogListener.DynamicCustomEventWithStateLogListener)1 RawStaticCustomEventLogListener (org.infinispan.client.hotrod.event.CustomEventLogListener.RawStaticCustomEventLogListener)1 StaticCustomEventLogWithStateListener (org.infinispan.client.hotrod.event.CustomEventLogListener.StaticCustomEventLogWithStateListener)1