Search in sources :

Example 1 with EntryListenerConfig

use of com.hazelcast.config.EntryListenerConfig in project hazelcast by hazelcast.

the class TestClientApplicationContext method testFullQueryCacheConfig.

@Test
public void testFullQueryCacheConfig() throws Exception {
    ClientConfig config = client6.getClientConfig();
    QueryCacheConfig queryCacheConfig = getQueryCacheConfig(config);
    EntryListenerConfig entryListenerConfig = queryCacheConfig.getEntryListenerConfigs().get(0);
    assertTrue(entryListenerConfig.isIncludeValue());
    assertFalse(entryListenerConfig.isLocal());
    assertEquals("com.hazelcast.spring.DummyEntryListener", entryListenerConfig.getClassName());
    assertFalse(queryCacheConfig.isIncludeValue());
    assertEquals("my-query-cache-1", queryCacheConfig.getName());
    assertEquals(12, queryCacheConfig.getBatchSize());
    assertEquals(33, queryCacheConfig.getBufferSize());
    assertEquals(12, queryCacheConfig.getDelaySeconds());
    assertEquals(InMemoryFormat.OBJECT, queryCacheConfig.getInMemoryFormat());
    assertTrue(queryCacheConfig.isCoalesce());
    assertFalse(queryCacheConfig.isPopulate());
    assertEquals("__key > 12", queryCacheConfig.getPredicateConfig().getSql());
    assertEquals(EvictionPolicy.LRU, queryCacheConfig.getEvictionConfig().getEvictionPolicy());
    assertEquals(EvictionConfig.MaxSizePolicy.ENTRY_COUNT, queryCacheConfig.getEvictionConfig().getMaximumSizePolicy());
    assertEquals(111, queryCacheConfig.getEvictionConfig().getSize());
}
Also used : QueryCacheConfig(com.hazelcast.config.QueryCacheConfig) ClientConfig(com.hazelcast.client.config.ClientConfig) EntryListenerConfig(com.hazelcast.config.EntryListenerConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 2 with EntryListenerConfig

use of com.hazelcast.config.EntryListenerConfig in project hazelcast by hazelcast.

the class TestFullApplicationContext method testFullQueryCacheConfig.

@Test
public void testFullQueryCacheConfig() {
    MapConfig mapConfig = config.getMapConfig("map-with-query-cache");
    QueryCacheConfig queryCacheConfig = mapConfig.getQueryCacheConfigs().get(0);
    EntryListenerConfig entryListenerConfig = queryCacheConfig.getEntryListenerConfigs().get(0);
    assertTrue(entryListenerConfig.isIncludeValue());
    assertFalse(entryListenerConfig.isLocal());
    assertEquals("com.hazelcast.spring.DummyEntryListener", entryListenerConfig.getClassName());
    assertFalse(queryCacheConfig.isIncludeValue());
    assertEquals("my-query-cache-1", queryCacheConfig.getName());
    assertEquals(12, queryCacheConfig.getBatchSize());
    assertEquals(33, queryCacheConfig.getBufferSize());
    assertEquals(12, queryCacheConfig.getDelaySeconds());
    assertEquals(InMemoryFormat.OBJECT, queryCacheConfig.getInMemoryFormat());
    assertTrue(queryCacheConfig.isCoalesce());
    assertFalse(queryCacheConfig.isPopulate());
    assertIndexesEqual(queryCacheConfig);
    assertEquals("__key > 12", queryCacheConfig.getPredicateConfig().getSql());
    assertEquals(EvictionPolicy.LRU, queryCacheConfig.getEvictionConfig().getEvictionPolicy());
    assertEquals(EvictionConfig.MaxSizePolicy.ENTRY_COUNT, queryCacheConfig.getEvictionConfig().getMaximumSizePolicy());
    assertEquals(111, queryCacheConfig.getEvictionConfig().getSize());
}
Also used : QueryCacheConfig(com.hazelcast.config.QueryCacheConfig) MapConfig(com.hazelcast.config.MapConfig) ReplicatedMapConfig(com.hazelcast.config.ReplicatedMapConfig) MultiMapConfig(com.hazelcast.config.MultiMapConfig) EntryListenerConfig(com.hazelcast.config.EntryListenerConfig) Test(org.junit.Test) QuickTest(com.hazelcast.test.annotation.QuickTest)

Example 3 with EntryListenerConfig

use of com.hazelcast.config.EntryListenerConfig in project hazelcast by hazelcast.

the class TestFullApplicationContext method testMultimapConfig.

@Test
public void testMultimapConfig() {
    MultiMapConfig testMultiMapConfig = config.getMultiMapConfig("testMultimap");
    assertEquals(MultiMapConfig.ValueCollectionType.LIST, testMultiMapConfig.getValueCollectionType());
    assertEquals(2, testMultiMapConfig.getEntryListenerConfigs().size());
    assertFalse(testMultiMapConfig.isBinary());
    assertFalse(testMultiMapConfig.isStatisticsEnabled());
    for (EntryListenerConfig listener : testMultiMapConfig.getEntryListenerConfigs()) {
        if (listener.getClassName() != null) {
            assertNull(listener.getImplementation());
            assertTrue(listener.isIncludeValue());
            assertFalse(listener.isLocal());
        } else {
            assertNotNull(listener.getImplementation());
            assertEquals(entryListener, listener.getImplementation());
            assertTrue(listener.isLocal());
            assertTrue(listener.isIncludeValue());
        }
    }
}
Also used : MultiMapConfig(com.hazelcast.config.MultiMapConfig) EntryListenerConfig(com.hazelcast.config.EntryListenerConfig) Test(org.junit.Test) QuickTest(com.hazelcast.test.annotation.QuickTest)

Example 4 with EntryListenerConfig

use of com.hazelcast.config.EntryListenerConfig in project hazelcast by hazelcast.

the class QueryCacheConfigBuilderHelper method handleEntryListeners.

private void handleEntryListeners(QueryCacheConfig queryCacheConfig, Node childNode) {
    for (Node listenerNode : childElements(childNode)) {
        if ("entry-listener".equals(cleanNodeName(listenerNode))) {
            NamedNodeMap listenerNodeAttributes = listenerNode.getAttributes();
            boolean incValue = getBooleanValue(getTextContent(listenerNodeAttributes.getNamedItem("include-value")));
            boolean local = getBooleanValue(getTextContent(listenerNodeAttributes.getNamedItem("local")));
            String listenerClass = getTextContent(listenerNode);
            queryCacheConfig.addEntryListenerConfig(new EntryListenerConfig(listenerClass, local, incValue));
        }
    }
}
Also used : NamedNodeMap(org.w3c.dom.NamedNodeMap) Node(org.w3c.dom.Node) EntryListenerConfig(com.hazelcast.config.EntryListenerConfig)

Example 5 with EntryListenerConfig

use of com.hazelcast.config.EntryListenerConfig in project hazelcast by hazelcast.

the class AbstractQueryCacheConfigurator method setEntryListener.

protected void setEntryListener(String mapName, String cacheName, QueryCacheConfig config) {
    for (EntryListenerConfig listenerConfig : config.getEntryListenerConfigs()) {
        MapListener listener = getListener(listenerConfig);
        if (listener != null) {
            EventFilter filter = new EntryEventFilter(listenerConfig.isIncludeValue(), null);
            eventService.addListener(mapName, cacheName, listener, filter);
        }
    }
}
Also used : MapListener(com.hazelcast.map.listener.MapListener) EntryEventFilter(com.hazelcast.map.impl.EntryEventFilter) EntryListenerConfig(com.hazelcast.config.EntryListenerConfig) EntryEventFilter(com.hazelcast.map.impl.EntryEventFilter) EventFilter(com.hazelcast.spi.EventFilter)

Aggregations

EntryListenerConfig (com.hazelcast.config.EntryListenerConfig)17 QuickTest (com.hazelcast.test.annotation.QuickTest)12 Test (org.junit.Test)12 ParallelTest (com.hazelcast.test.annotation.ParallelTest)6 Config (com.hazelcast.config.Config)5 MapConfig (com.hazelcast.config.MapConfig)5 HazelcastInstance (com.hazelcast.core.HazelcastInstance)5 MultiMapConfig (com.hazelcast.config.MultiMapConfig)4 EntryAdapter (com.hazelcast.core.EntryAdapter)4 EntryEvent (com.hazelcast.core.EntryEvent)4 MapPartitionLostListenerConfig (com.hazelcast.config.MapPartitionLostListenerConfig)3 QueryCacheConfig (com.hazelcast.config.QueryCacheConfig)3 ReplicatedMapConfig (com.hazelcast.config.ReplicatedMapConfig)3 CountDownLatch (java.util.concurrent.CountDownLatch)3 MapIndexConfig (com.hazelcast.config.MapIndexConfig)2 NearCacheConfig (com.hazelcast.config.NearCacheConfig)2 AssertTask (com.hazelcast.test.AssertTask)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 ClientConfig (com.hazelcast.client.config.ClientConfig)1 MapAttributeConfig (com.hazelcast.config.MapAttributeConfig)1