Search in sources :

Example 6 with MapConfig

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

the class ClientWriteBehindFlushTest method newMapStoredConfig.

protected Config newMapStoredConfig(MapStore store, int writeDelaySeconds) {
    MapStoreConfig mapStoreConfig = new MapStoreConfig();
    mapStoreConfig.setEnabled(true);
    mapStoreConfig.setWriteDelaySeconds(writeDelaySeconds);
    mapStoreConfig.setImplementation(store);
    Config config = getConfig();
    MapConfig mapConfig = config.getMapConfig(MAP_NAME);
    mapConfig.setMapStoreConfig(mapStoreConfig);
    return config;
}
Also used : Config(com.hazelcast.config.Config) MapConfig(com.hazelcast.config.MapConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) MapConfig(com.hazelcast.config.MapConfig)

Example 7 with MapConfig

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

the class ClientMapLoadAllTest method givenSpecificKeysWereReloaded_whenLoadAllIsCalled_thenAllEntriesAreLoadedFromTheStore.

@Test
public void givenSpecificKeysWereReloaded_whenLoadAllIsCalled_thenAllEntriesAreLoadedFromTheStore() {
    String name = randomString();
    int keysInMapStore = 10000;
    Config config = new Config();
    MapConfig mapConfig = config.getMapConfig(name);
    MapStoreConfig mapStoreConfig = new MapStoreConfig();
    mapStoreConfig.setEnabled(true);
    mapStoreConfig.setImplementation(new MapLoaderTest.DummyMapLoader(keysInMapStore));
    mapStoreConfig.setInitialLoadMode(MapStoreConfig.InitialLoadMode.EAGER);
    mapConfig.setMapStoreConfig(mapStoreConfig);
    hazelcastFactory.newHazelcastInstance(config);
    HazelcastInstance client = hazelcastFactory.newHazelcastClient();
    IMap<Integer, Integer> map = client.getMap(name);
    //load specific keys
    map.loadAll(setOfValuesBetween(0, keysInMapStore), true);
    //remove everything
    map.clear();
    //assert loadAll with load all entries provided by the mapLoader
    map.loadAll(true);
    assertEquals(keysInMapStore, map.size());
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) MapConfig(com.hazelcast.config.MapConfig) Config(com.hazelcast.config.Config) MapStoreConfig(com.hazelcast.config.MapStoreConfig) MapLoaderTest(com.hazelcast.map.impl.mapstore.MapLoaderTest) MapConfig(com.hazelcast.config.MapConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) MapLoaderTest(com.hazelcast.map.impl.mapstore.MapLoaderTest) AbstractMapStoreTest(com.hazelcast.map.impl.mapstore.AbstractMapStoreTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 8 with MapConfig

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

the class ClientMapStoreTest method mapStore_OperationQueue_AtMaxCapacity.

@Test
public void mapStore_OperationQueue_AtMaxCapacity() {
    int maxCapacity = 1000;
    Config config = new Config();
    config.setProperty(GroupProperty.MAP_WRITE_BEHIND_QUEUE_CAPACITY.getName(), String.valueOf(maxCapacity));
    MapConfig mapConfig = new MapConfig();
    MapStoreConfig mapStoreConfig = new MapStoreConfig();
    MapStoreBackup store = new MapStoreBackup();
    mapStoreConfig.setEnabled(true);
    mapStoreConfig.setImplementation(store);
    mapStoreConfig.setWriteDelaySeconds(60);
    mapStoreConfig.setWriteCoalescing(false);
    mapConfig.setName(MAP_NAME);
    mapConfig.setMapStoreConfig(mapStoreConfig);
    config.addMapConfig(mapConfig);
    HazelcastInstance server = hazelcastFactory.newHazelcastInstance(config);
    HazelcastInstance client = hazelcastFactory.newHazelcastClient();
    IMap<Integer, Integer> map = client.getMap(MAP_NAME);
    for (int i = 0; i < maxCapacity; i++) {
        map.put(i, i);
    }
    assertEquals(maxCapacity, map.size());
    try {
        map.put(maxCapacity, maxCapacity);
        fail("Should not exceed max capacity");
    } catch (ReachedMaxSizeException expected) {
        ignore(expected);
    }
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) MapConfig(com.hazelcast.config.MapConfig) Config(com.hazelcast.config.Config) MapStoreConfig(com.hazelcast.config.MapStoreConfig) ReachedMaxSizeException(com.hazelcast.map.ReachedMaxSizeException) MapConfig(com.hazelcast.config.MapConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) Test(org.junit.Test) SlowTest(com.hazelcast.test.annotation.SlowTest)

Example 9 with MapConfig

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

the class ClientMapStoreTest method setup.

@Before
public void setup() {
    nodeConfig = new Config();
    MapConfig mapConfig = new MapConfig();
    MapStoreConfig mapStoreConfig = new MapStoreConfig();
    mapStoreConfig.setEnabled(true);
    mapStoreConfig.setImplementation(new SimpleMapStore());
    mapStoreConfig.setInitialLoadMode(MapStoreConfig.InitialLoadMode.EAGER);
    mapConfig.setName(MAP_NAME);
    mapConfig.setMapStoreConfig(mapStoreConfig);
    nodeConfig.addMapConfig(mapConfig);
}
Also used : MapConfig(com.hazelcast.config.MapConfig) Config(com.hazelcast.config.Config) MapStoreConfig(com.hazelcast.config.MapStoreConfig) MapConfig(com.hazelcast.config.MapConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) Before(org.junit.Before)

Example 10 with MapConfig

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

the class ClientMapWriteQuorumTest method initialize.

@BeforeClass
public static void initialize() throws Exception {
    QuorumConfig quorumConfig = new QuorumConfig();
    quorumConfig.setName(QUORUM_ID);
    quorumConfig.setEnabled(true);
    quorumConfig.setSize(3);
    quorumConfig.setType(QuorumType.WRITE);
    MapConfig mapConfig = new MapConfig(MAP_NAME_PREFIX + "*");
    mapConfig.setQuorumName(QUORUM_ID);
    factory = new TestHazelcastFactory();
    cluster = new PartitionedCluster(factory).partitionFiveMembersThreeAndTwo(mapConfig, quorumConfig);
    initializeClients();
    verifyClients();
}
Also used : QuorumConfig(com.hazelcast.config.QuorumConfig) TestHazelcastFactory(com.hazelcast.client.test.TestHazelcastFactory) PartitionedCluster(com.hazelcast.quorum.PartitionedCluster) MapConfig(com.hazelcast.config.MapConfig) BeforeClass(org.junit.BeforeClass)

Aggregations

MapConfig (com.hazelcast.config.MapConfig)178 Config (com.hazelcast.config.Config)123 HazelcastInstance (com.hazelcast.core.HazelcastInstance)78 Test (org.junit.Test)75 QuickTest (com.hazelcast.test.annotation.QuickTest)68 ParallelTest (com.hazelcast.test.annotation.ParallelTest)62 MapStoreConfig (com.hazelcast.config.MapStoreConfig)43 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)41 NearCacheConfig (com.hazelcast.config.NearCacheConfig)27 MaxSizeConfig (com.hazelcast.config.MaxSizeConfig)26 MapIndexConfig (com.hazelcast.config.MapIndexConfig)20 QuorumConfig (com.hazelcast.config.QuorumConfig)19 EntryListenerConfig (com.hazelcast.config.EntryListenerConfig)18 QueryCacheConfig (com.hazelcast.config.QueryCacheConfig)16 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)14 NightlyTest (com.hazelcast.test.annotation.NightlyTest)12 PartitionedCluster (com.hazelcast.quorum.PartitionedCluster)10 CountDownLatch (java.util.concurrent.CountDownLatch)10 BeforeClass (org.junit.BeforeClass)10 AssertTask (com.hazelcast.test.AssertTask)9