Package com.hazelcast.config

Examples of com.hazelcast.config.MapConfig


        verify(description).isVersioned();
    }

    @Test
    public void testFourArgConstructorDoesNotRegisterTopicListenerIfNotRequested() {
        MapConfig mapConfig = mock(MapConfig.class);

        Config config = mock(Config.class);
        when(config.findMapConfig(eq(CACHE_NAME))).thenReturn(mapConfig);

        HazelcastInstance instance = mock(HazelcastInstance.class);
View Full Code Here


    // Verifies that the three-argument constructor still registers a listener with a topic if the HazelcastInstance
    // is provided. This ensures the old behavior has not been regressed by adding the new four argument constructor
    @Test
    public void testThreeArgConstructorRegistersTopicListener() {
        MapConfig mapConfig = mock(MapConfig.class);

        Config config = mock(Config.class);
        when(config.findMapConfig(eq(CACHE_NAME))).thenReturn(mapConfig);

        ITopic<Object> topic = mock(ITopic.class);
View Full Code Here

        return instance.getCluster().getClusterTime();
    }

    public static int getTimeout(HazelcastInstance instance, String regionName) {
        try {
            final MapConfig cfg = instance.getConfig().findMapConfig(regionName);
            if (cfg.getTimeToLiveSeconds() > 0) {
                // TTL in ms.
                return cfg.getTimeToLiveSeconds() * SEC_TO_MS;
            }
        } catch (UnsupportedOperationException e) {
            // HazelcastInstance is instance of HazelcastClient.
            Logger.getLogger(HazelcastTimestamper.class).finest(e);
        }
View Full Code Here

        assertEquals(map.get(1), (Object) 2);
    }

    @Test
    public void testMapLoaderLoadUpdatingIndex() throws Exception {
        MapConfig mapConfig = getInstance().getConfig().getMapConfig("testMapLoaderLoadUpdatingIndex");
        List<MapIndexConfig> indexConfigs = mapConfig.getMapIndexConfigs();
        indexConfigs.add(new MapIndexConfig("name", true));

        SampleIndexableObjectMapLoader loader = new SampleIndexableObjectMapLoader();
        MapStoreConfig storeConfig = new MapStoreConfig();
        storeConfig.setFactoryImplementation(loader);
        mapConfig.setMapStoreConfig(storeConfig);

        IMap<Integer, SampleIndexableObject> map = getInstance().getMap("testMapLoaderLoadUpdatingIndex");
        for (int i = 0; i < 10; i++) {
            map.put(i, new SampleIndexableObject("My-" + i, i));
        }
View Full Code Here

    @Test(timeout = 1000 * 60)
    public void testQueryWithTTL() throws Exception {

        Config cfg = new Config();
        MapConfig mapConfig = new MapConfig();
        mapConfig.setTimeToLiveSeconds(5);
        mapConfig.setName("employees");
        cfg.addMapConfig(mapConfig);

        HazelcastInstance h1 = createHazelcastInstance(cfg);

        IMap imap = h1.getMap("employees");
View Full Code Here

        final String mapName = "_testNearCacheEvictionByUsingMapTTLEviction_";
        final NearCacheConfig nearCacheConfig = new NearCacheConfig();
        nearCacheConfig.setInvalidateOnChange(true);
        nearCacheConfig.setInMemoryFormat(InMemoryFormat.OBJECT);
        cfg.getMapConfig(mapName).setNearCacheConfig(nearCacheConfig);
        final MapConfig mapConfig = cfg.getMapConfig(mapName);
        mapConfig.setTimeToLiveSeconds(ttl);
        final TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(instanceCount);
        final HazelcastInstance instance1 = factory.newHazelcastInstance(cfg);
        final HazelcastInstance instance2 = factory.newHazelcastInstance(cfg);
        final HazelcastInstance instance3 = factory.newHazelcastInstance(cfg);
        final IMap map1 = instance1.getMap(mapName);
View Full Code Here

        Config config = new Config();
        final NearCacheConfig nearCacheConfig = new NearCacheConfig();
        nearCacheConfig.setCacheLocalEntries(true);
        nearCacheConfig.setInvalidateOnChange(false);
        final MapConfig mapConfig = config.getMapConfig(mapName);
        mapConfig.setNearCacheConfig(nearCacheConfig);
        HazelcastInstance instance = createHazelcastInstanceFactory(n).newInstances(config)[0];

        IMap<String, String> map = instance.getMap(mapName);

        int noOfEntries = 100;
View Full Code Here

     * Nullify old value if in memory format is object and operation is not removal
     * since old and new value in fired event {@link com.hazelcast.core.EntryEvent}
     * may be same due to the object in memory format.
     */
    protected Object nullifyOldValueIfNecessary(Object oldValue, EntryEventType eventType) {
        final MapConfig mapConfig = mapContainer.getMapConfig();
        final InMemoryFormat format = mapConfig.getInMemoryFormat();
        if (format == InMemoryFormat.OBJECT && eventType != EntryEventType.REMOVED) {
            return null;
        } else {
            return oldValue;
        }
View Full Code Here

            for (Member member : members) {
                mcs.callOnMember(member, new UpdateMapConfigOperation(mapName, config.getMapConfig()));
            }
            result.add("updateResult", "success");
        } else {
            MapConfig cfg = (MapConfig) mcs.callOnThis(new GetMapConfigOperation(mapName));
            if (cfg != null) {
                result.add("hasMapConfig", true);
                result.add("mapConfig", new MapConfigAdapter(cfg).toJson());
            } else {
                result.add("hasMapConfig", false);
View Full Code Here

    private IMap<Integer, Integer> createMapWithMaxIdleSeconds(int maxIdleSeconds) {
        final String mapName = randomMapName();

        final Config config = new Config();
        final MapConfig mapConfig = config.getMapConfig(mapName);
        mapConfig.setMaxIdleSeconds(maxIdleSeconds);

        final HazelcastInstance node = createHazelcastInstance(config);
        return node.getMap(mapName);
    }
View Full Code Here

TOP

Related Classes of com.hazelcast.config.MapConfig

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.