Ejemplo n.º 1
0
  @Test
  public void setMapStoreConfigImplementationTest() {
    String mapName = "mapStoreImpObjTest";
    String xml =
        "<hazelcast xmlns=\"http://www.hazelcast.com/schema/config\">\n"
            + "<map name=\""
            + mapName
            + "\">\n"
            + "<map-store enabled=\"true\">\n"
            + "<class-name>com.hazelcast.config.helpers.DummyMapStore</class-name>\n"
            + "<write-delay-seconds>5</write-delay-seconds>\n"
            + "</map-store>\n"
            + "</map>\n"
            + "</hazelcast>\n";

    Config config = buildConfig(xml);
    HazelcastInstance hz = createHazelcastInstance(config);
    hz.getMap(mapName);

    MapConfig mapConfig = hz.getConfig().getMapConfig(mapName);
    MapStoreConfig mapStoreConfig = mapConfig.getMapStoreConfig();
    Object o = mapStoreConfig.getImplementation();

    assertNotNull(o);
    assertTrue(o instanceof DummyMapStore);
  }
Ejemplo n.º 2
0
  @Test
  public void testMapStoreConfig_writeCoalescing_whenSetTrue() {
    boolean writeCoalescingEnabled = true;
    final MapStoreConfig mapStoreConfig =
        getWriteCoalescingMapStoreConfig(writeCoalescingEnabled, false);

    assertTrue(mapStoreConfig.isWriteCoalescing());
  }
Ejemplo n.º 3
0
  @Test
  public void testMapStoreConfig_writeCoalescing_whenDefault() {
    boolean writeCoalescingEnabled = MapStoreConfig.DEFAULT_WRITE_COALESCING;
    final MapStoreConfig mapStoreConfig =
        getWriteCoalescingMapStoreConfig(writeCoalescingEnabled, true);

    assertTrue(mapStoreConfig.isWriteCoalescing());
  }
Ejemplo n.º 4
0
 @Test
 public void testMapStoreInitialModeEager() {
   String xml =
       "<hazelcast xmlns=\"http://www.hazelcast.com/schema/config\">\n"
           + "<map name=\"mymap\">"
           + "<map-store enabled=\"true\" initial-mode=\"EAGER\"></map-store>"
           + "</map>"
           + "</hazelcast>";
   final Config config = buildConfig(xml);
   System.out.println("config = " + config);
   final MapStoreConfig mapStoreConfig = config.getMapConfig("mymap").getMapStoreConfig();
   assertTrue(mapStoreConfig.isEnabled());
   assertEquals(MapStoreConfig.InitialLoadMode.EAGER, mapStoreConfig.getInitialLoadMode());
 }
Ejemplo n.º 5
0
 @Test
 public void testMapStoreInitialModeEager() {
   String xml =
       HAZELCAST_START_TAG
           + "<map name=\"mymap\">"
           + "<map-store enabled=\"true\" initial-mode=\"EAGER\"></map-store>"
           + "</map>"
           + "</hazelcast>";
   final Config config = buildConfig(xml);
   System.out.println("config = " + config);
   final MapStoreConfig mapStoreConfig = config.getMapConfig("mymap").getMapStoreConfig();
   assertTrue(mapStoreConfig.isEnabled());
   assertEquals(MapStoreConfig.InitialLoadMode.EAGER, mapStoreConfig.getInitialLoadMode());
 }
Ejemplo n.º 6
0
 @Test
 public void testMapStoreInitialModeLazy() {
   String xml =
       "<hazelcast>\n"
           + "<map name=\"mymap\">"
           + "<map-store enabled=\"true\" initial-mode=\"LAZY\"></map-store>"
           + "</map>"
           + "</hazelcast>";
   final Config config = buildConfig(xml);
   System.out.println("config = " + config);
   final MapStoreConfig mapStoreConfig = config.getMapConfig("mymap").getMapStoreConfig();
   assertTrue(mapStoreConfig.isEnabled());
   assertEquals(MapStoreConfig.InitialLoadMode.LAZY, mapStoreConfig.getInitialLoadMode());
 }
Ejemplo n.º 7
0
 @Test
 public void testMapStoreWriteBatchSize() {
   String xml =
       "<hazelcast xmlns=\"http://www.hazelcast.com/schema/config\">\n"
           + "<map name=\"mymap\">"
           + "<map-store >"
           + "<write-batch-size>23</write-batch-size>"
           + "</map-store>"
           + "</map>"
           + "</hazelcast>";
   final Config config = buildConfig(xml);
   System.out.println("config = " + config);
   final MapStoreConfig mapStoreConfig = config.getMapConfig("mymap").getMapStoreConfig();
   assertEquals(23, mapStoreConfig.getWriteBatchSize());
 }
Ejemplo n.º 8
0
 @Test
 public void testMapStoreWriteBatchSize() {
   String xml =
       HAZELCAST_START_TAG
           + "<map name=\"mymap\">"
           + "<map-store >"
           + "<write-batch-size>23</write-batch-size>"
           + "</map-store>"
           + "</map>"
           + "</hazelcast>";
   final Config config = buildConfig(xml);
   System.out.println("config = " + config);
   final MapStoreConfig mapStoreConfig = config.getMapConfig("mymap").getMapStoreConfig();
   assertEquals(23, mapStoreConfig.getWriteBatchSize());
 }
 @Test
 public void testMapConfig() {
   assertNotNull(config);
   assertEquals(6, config.getMapConfigs().size());
   MapConfig testMapConfig = config.getMapConfig("testMap");
   assertNotNull(testMapConfig);
   assertEquals("testMap", testMapConfig.getName());
   assertEquals(2, testMapConfig.getBackupCount());
   assertEquals(MapConfig.EvictionPolicy.NONE, testMapConfig.getEvictionPolicy());
   assertEquals(Integer.MAX_VALUE, testMapConfig.getMaxSizeConfig().getSize());
   assertEquals(30, testMapConfig.getEvictionPercentage());
   assertEquals(0, testMapConfig.getTimeToLiveSeconds());
   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!");
     }
   }
   // 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(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());
   assertEquals("testWan", testMapConfig2.getWanReplicationRef().getName());
   //        assertEquals("hz.ADD_NEW_ENTRY",
   // testMapConfig2.getWanReplicationRef().getMergePolicy());
   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(MapConfig.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());
 }