Search in sources :

Example 1 with ReachedMaxSizeException

use of com.hazelcast.map.ReachedMaxSizeException 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)

Aggregations

Config (com.hazelcast.config.Config)1 MapConfig (com.hazelcast.config.MapConfig)1 MapStoreConfig (com.hazelcast.config.MapStoreConfig)1 HazelcastInstance (com.hazelcast.core.HazelcastInstance)1 ReachedMaxSizeException (com.hazelcast.map.ReachedMaxSizeException)1 SlowTest (com.hazelcast.test.annotation.SlowTest)1 Test (org.junit.Test)1