private void initializeIndexes() { for (MapIndexConfig index : getMapConfig().getMapIndexConfigs()) { if (index.getAttribute() != null) { addIndex(index.getAttribute(), index.isOrdered()); } } }
@Test public void testQueryCacheFullConfig() throws Exception { QueryCacheConfig queryCacheConfig = clientConfig.getQueryCacheConfigs().get("map-name").get("query-cache-name"); EntryListenerConfig entryListenerConfig = queryCacheConfig.getEntryListenerConfigs().get(0); assertEquals("query-cache-name", queryCacheConfig.getName()); assertTrue(entryListenerConfig.isIncludeValue()); assertFalse(entryListenerConfig.isLocal()); assertEquals("com.hazelcast.examples.EntryListener", entryListenerConfig.getClassName()); assertTrue(queryCacheConfig.isIncludeValue()); assertEquals(1, queryCacheConfig.getBatchSize()); assertEquals(16, queryCacheConfig.getBufferSize()); assertEquals(0, queryCacheConfig.getDelaySeconds()); assertEquals(EvictionPolicy.LRU, queryCacheConfig.getEvictionConfig().getEvictionPolicy()); assertEquals( EvictionConfig.MaxSizePolicy.ENTRY_COUNT, queryCacheConfig.getEvictionConfig().getMaximumSizePolicy()); assertEquals(10000, queryCacheConfig.getEvictionConfig().getSize()); assertEquals(InMemoryFormat.BINARY, queryCacheConfig.getInMemoryFormat()); assertFalse(queryCacheConfig.isCoalesce()); assertTrue(queryCacheConfig.isPopulate()); Iterator<MapIndexConfig> iterator = queryCacheConfig.getIndexConfigs().iterator(); while (iterator.hasNext()) { MapIndexConfig mapIndexConfig = iterator.next(); assertEquals("name", mapIndexConfig.getAttribute()); assertFalse(mapIndexConfig.isOrdered()); } assertEquals( "com.hazelcast.examples.ExamplePredicate", queryCacheConfig.getPredicateConfig().getClassName()); }
private void assertIndexesEqual(QueryCacheConfig queryCacheConfig) { Iterator<MapIndexConfig> iterator = queryCacheConfig.getIndexConfigs().iterator(); while (iterator.hasNext()) { MapIndexConfig mapIndexConfig = iterator.next(); assertEquals("name", mapIndexConfig.getAttribute()); assertFalse(mapIndexConfig.isOrdered()); } }
@Test public void testMapConfig() { assertNotNull(config); assertEquals(10, config.getMapConfigs().size()); MapConfig testMapConfig = config.getMapConfig("testMap"); assertNotNull(testMapConfig); assertEquals("testMap", testMapConfig.getName()); assertEquals(2, testMapConfig.getBackupCount()); assertEquals(EvictionPolicy.NONE, testMapConfig.getEvictionPolicy()); assertEquals(Integer.MAX_VALUE, testMapConfig.getMaxSizeConfig().getSize()); assertEquals(30, testMapConfig.getEvictionPercentage()); assertEquals(0, testMapConfig.getTimeToLiveSeconds()); assertEquals(1000, testMapConfig.getMinEvictionCheckMillis()); assertEquals("PUT_IF_ABSENT", testMapConfig.getMergePolicy()); assertTrue(testMapConfig.isReadBackupData()); assertEquals(2, testMapConfig.getMapIndexConfigs().size()); for (MapIndexConfig index : testMapConfig.getMapIndexConfigs()) { if ("name".equals(index.getAttribute())) { assertFalse(index.isOrdered()); } else if ("age".equals(index.getAttribute())) { assertTrue(index.isOrdered()); } else { fail("unknown index!"); } } assertEquals("my-quorum", testMapConfig.getQuorumName()); // Test that the testMapConfig has a mapStoreConfig and it is correct MapStoreConfig testMapStoreConfig = testMapConfig.getMapStoreConfig(); assertNotNull(testMapStoreConfig); assertEquals("com.hazelcast.spring.DummyStore", testMapStoreConfig.getClassName()); assertTrue(testMapStoreConfig.isEnabled()); assertEquals(0, testMapStoreConfig.getWriteDelaySeconds()); assertEquals(10, testMapStoreConfig.getWriteBatchSize()); assertTrue(testMapStoreConfig.isWriteCoalescing()); assertEquals(MapStoreConfig.InitialLoadMode.EAGER, testMapStoreConfig.getInitialLoadMode()); // Test that the testMapConfig has a nearCacheConfig and it is correct NearCacheConfig testNearCacheConfig = testMapConfig.getNearCacheConfig(); assertNotNull(testNearCacheConfig); assertEquals(0, testNearCacheConfig.getTimeToLiveSeconds()); assertEquals(60, testNearCacheConfig.getMaxIdleSeconds()); assertEquals("LRU", testNearCacheConfig.getEvictionPolicy()); assertEquals(5000, testNearCacheConfig.getMaxSize()); assertTrue(testNearCacheConfig.isInvalidateOnChange()); // Test that the testMapConfig2's mapStoreConfig implementation MapConfig testMapConfig2 = config.getMapConfig("testMap2"); assertNotNull(testMapConfig2.getMapStoreConfig().getImplementation()); assertEquals(dummyMapStore, testMapConfig2.getMapStoreConfig().getImplementation()); assertEquals( MapStoreConfig.InitialLoadMode.LAZY, testMapConfig2.getMapStoreConfig().getInitialLoadMode()); // Test testMapConfig2's WanReplicationConfig WanReplicationRef wanReplicationRef = testMapConfig2.getWanReplicationRef(); assertEquals("testWan", wanReplicationRef.getName()); assertEquals("PUT_IF_ABSENT", wanReplicationRef.getMergePolicy()); assertTrue(wanReplicationRef.isRepublishingEnabled()); assertEquals(1000, testMapConfig2.getMaxSizeConfig().getSize()); assertEquals( MaxSizeConfig.MaxSizePolicy.PER_NODE, testMapConfig2.getMaxSizeConfig().getMaxSizePolicy()); assertEquals(2, testMapConfig2.getEntryListenerConfigs().size()); for (EntryListenerConfig listener : testMapConfig2.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()); } } MapConfig simpleMapConfig = config.getMapConfig("simpleMap"); assertNotNull(simpleMapConfig); assertEquals("simpleMap", simpleMapConfig.getName()); assertEquals(3, simpleMapConfig.getBackupCount()); assertEquals(1, simpleMapConfig.getAsyncBackupCount()); assertEquals(EvictionPolicy.LRU, simpleMapConfig.getEvictionPolicy()); assertEquals(10, simpleMapConfig.getMaxSizeConfig().getSize()); assertEquals(50, simpleMapConfig.getEvictionPercentage()); assertEquals(1, simpleMapConfig.getTimeToLiveSeconds()); assertEquals("LATEST_UPDATE", simpleMapConfig.getMergePolicy()); // Test that the simpleMapConfig does NOT have a mapStoreConfig assertNull(simpleMapConfig.getMapStoreConfig()); // Test that the simpleMapConfig does NOT have a nearCacheConfig assertNull(simpleMapConfig.getNearCacheConfig()); MapConfig testMapConfig3 = config.getMapConfig("testMap3"); assertEquals( "com.hazelcast.spring.DummyStoreFactory", testMapConfig3.getMapStoreConfig().getFactoryClassName()); assertFalse(testMapConfig3.getMapStoreConfig().getProperties().isEmpty()); assertEquals(testMapConfig3.getMapStoreConfig().getProperty("dummy.property"), "value"); MapConfig testMapConfig4 = config.getMapConfig("testMap4"); assertEquals( dummyMapStoreFactory, testMapConfig4.getMapStoreConfig().getFactoryImplementation()); MapConfig mapWithOptimizedQueriesConfig = config.getMapConfig("mapWithOptimizedQueries"); assertTrue(mapWithOptimizedQueriesConfig.isOptimizeQueries()); MapConfig mapWithNotOptimizedQueriesConfig = config.getMapConfig("mapWithNotOptimizedQueries"); assertFalse(mapWithNotOptimizedQueriesConfig.isOptimizeQueries()); MapConfig mapWithDefaultOptimizedQueriesConfig = config.getMapConfig("mapWithDefaultOptimizedQueries"); assertFalse(mapWithDefaultOptimizedQueriesConfig.isOptimizeQueries()); }