Search in sources :

Example 6 with ReplicatedMapConfig

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

the class ReplicatedMapListenerTest method testRegisterListenerViaConfiguration.

@Test
public void testRegisterListenerViaConfiguration() {
    String mapName = randomMapName();
    Config config = new Config();
    ReplicatedMapConfig replicatedMapConfig = config.getReplicatedMapConfig(mapName);
    EntryListenerConfig listenerConfig = new EntryListenerConfig();
    final EventCountingListener<Integer, Integer> listener = new EventCountingListener<>();
    listenerConfig.setImplementation(listener);
    replicatedMapConfig.addEntryListenerConfig(listenerConfig);
    HazelcastInstance instance = createHazelcastInstance(config);
    ReplicatedMap<Object, Object> replicatedMap = instance.getReplicatedMap(mapName);
    replicatedMap.put(3, 3);
    assertTrueEventually(() -> {
        assertEquals(1, listener.addCount.get());
        assertEquals(Integer.valueOf(3), listener.keys.peek());
    }, 10);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config) EntryListenerConfig(com.hazelcast.config.EntryListenerConfig) ReplicatedMapConfig(com.hazelcast.config.ReplicatedMapConfig) ReplicatedMapConfig(com.hazelcast.config.ReplicatedMapConfig) EntryListenerConfig(com.hazelcast.config.EntryListenerConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 7 with ReplicatedMapConfig

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

the class ReplicatedMapLoadingTest method testAsyncFillUp.

@Test
public void testAsyncFillUp() {
    Config config = new Config();
    String mapName = randomMapName();
    ReplicatedMapConfig replicatedMapConfig = config.getReplicatedMapConfig(mapName);
    replicatedMapConfig.setAsyncFillup(true);
    TestHazelcastInstanceFactory nodeFactory = createHazelcastInstanceFactory();
    fillMapsAndAssertMapSizeEventually(nodeFactory, config, mapName);
}
Also used : Config(com.hazelcast.config.Config) ReplicatedMapConfig(com.hazelcast.config.ReplicatedMapConfig) ReplicatedMapConfig(com.hazelcast.config.ReplicatedMapConfig) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 8 with ReplicatedMapConfig

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

the class ReplicatedMapLoadingTest method testSyncFillUp.

@Test
public void testSyncFillUp() {
    Config config = new Config();
    String mapName = randomMapName();
    ReplicatedMapConfig replicatedMapConfig = config.getReplicatedMapConfig(mapName);
    replicatedMapConfig.setAsyncFillup(false);
    TestHazelcastInstanceFactory nodeFactory = createHazelcastInstanceFactory();
    fillMapsAndAssertMapSizeEventually(nodeFactory, config, mapName);
}
Also used : Config(com.hazelcast.config.Config) ReplicatedMapConfig(com.hazelcast.config.ReplicatedMapConfig) ReplicatedMapConfig(com.hazelcast.config.ReplicatedMapConfig) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 9 with ReplicatedMapConfig

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

the class ReplicatedMapServiceTest method testGetLocalReplicatedMapStatsNoObjectGenerationIfDisabledStats.

@Test
public void testGetLocalReplicatedMapStatsNoObjectGenerationIfDisabledStats() {
    String name = randomMapName();
    ReplicatedMapConfig replicatedMapConfig = new ReplicatedMapConfig();
    replicatedMapConfig.setName(name);
    replicatedMapConfig.setStatisticsEnabled(false);
    nodeEngine.getConfig().addReplicatedMapConfig(replicatedMapConfig);
    ReplicatedMapService service = new ReplicatedMapService(nodeEngine);
    LocalReplicatedMapStats stats = service.getLocalReplicatedMapStats(name);
    LocalReplicatedMapStats stats2 = service.getLocalReplicatedMapStats(name);
    LocalReplicatedMapStats stats3 = service.getLocalReplicatedMapStats(name);
    assertSame(stats, stats2);
    assertSame(stats2, stats3);
}
Also used : ReplicatedMapConfig(com.hazelcast.config.ReplicatedMapConfig) LocalReplicatedMapStats(com.hazelcast.replicatedmap.LocalReplicatedMapStats) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 10 with ReplicatedMapConfig

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

the class ReplicatedMapAbstractTest method buildConfig.

protected Config buildConfig(Config config, InMemoryFormat inMemoryFormat) {
    ReplicatedMapConfig replicatedMapConfig = config.getReplicatedMapConfig("default");
    replicatedMapConfig.setInMemoryFormat(inMemoryFormat);
    return config;
}
Also used : ReplicatedMapConfig(com.hazelcast.config.ReplicatedMapConfig)

Aggregations

ReplicatedMapConfig (com.hazelcast.config.ReplicatedMapConfig)36 Test (org.junit.Test)16 QuickTest (com.hazelcast.test.annotation.QuickTest)15 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)13 Config (com.hazelcast.config.Config)9 EntryListenerConfig (com.hazelcast.config.EntryListenerConfig)8 MergePolicyConfig (com.hazelcast.config.MergePolicyConfig)7 ListenerConfig (com.hazelcast.config.ListenerConfig)6 CacheSimpleConfig (com.hazelcast.config.CacheSimpleConfig)5 CacheSimpleEntryListenerConfig (com.hazelcast.config.CacheSimpleEntryListenerConfig)5 CardinalityEstimatorConfig (com.hazelcast.config.CardinalityEstimatorConfig)5 DurableExecutorConfig (com.hazelcast.config.DurableExecutorConfig)5 ExecutorConfig (com.hazelcast.config.ExecutorConfig)5 FlakeIdGeneratorConfig (com.hazelcast.config.FlakeIdGeneratorConfig)5 ListConfig (com.hazelcast.config.ListConfig)5 MapConfig (com.hazelcast.config.MapConfig)5 MultiMapConfig (com.hazelcast.config.MultiMapConfig)5 PNCounterConfig (com.hazelcast.config.PNCounterConfig)5 QueueConfig (com.hazelcast.config.QueueConfig)5 ReliableTopicConfig (com.hazelcast.config.ReliableTopicConfig)5