Package com.hazelcast.config

Examples of com.hazelcast.config.MapConfig


        }
        try {
            Config hzConfig = hazelcastInstance.getConfig();
            String sessionTTL = getParam("session-ttl-seconds");
            if (sessionTTL != null) {
                MapConfig mapConfig = hzConfig.getMapConfig(clusterMapName);
                mapConfig.setTimeToLiveSeconds(Integer.parseInt(sessionTTL));
                hzConfig.addMapConfig(mapConfig);
            }
        } catch (UnsupportedOperationException ignored) {
            // client cannot access Config.
        }
View Full Code Here


        return instance.getCluster().getClusterTime(); // System time in ms.
    }

    public static int getTimeout(HazelcastInstance instance, String regionName) {
        try {
            final MapConfig cfg = instance.getConfig().findMapConfig(regionName);
            if (cfg.getTimeToLiveSeconds() > 0) {
                return cfg.getTimeToLiveSeconds() * 1000; // TTL in ms.
            }
        } catch (UnsupportedOperationException ignored) {
            // HazelcastInstance is instance of HazelcastClient.
        }
        return CacheEnvironment.getDefaultCacheTimeoutInMillis();
View Full Code Here

    // this operation returns the object in data format except
    // it is got from near-cache and near-cache memory format is object.
    protected Object getInternal(Data key) {
        // todo: why does this method not make use of getAsyncInternal and just do a get on it?
        // now there is a lot of duplication.
        final MapConfig mapConfig = getMapConfig();
        final boolean nearCacheEnabled = mapConfig.isNearCacheEnabled();
        if (nearCacheEnabled) {
            final Object fromNearCache = getFromNearCache(key);
            if (fromNearCache != null) {
                if (isCachedAsNullInNearCache(fromNearCache)) {
                    return null;
                }
                return fromNearCache;
            }
        }
        // todo action for read-backup true is not well tested.
        if (mapConfig.isReadBackupData()) {
            final Object fromBackup = readBackupDataOrNull(key);
            if (fromBackup != null) {
                return fromBackup;
            }
        }
View Full Code Here

        return root;
    }

    @Override
    public void fromJson(JsonObject json) {
        config = new MapConfig();
        config.setName(getString(json, "name"));
        config.setInMemoryFormat(InMemoryFormat.valueOf(getString(json, "memoryFormat")));
        config.setBackupCount(getInt(json, "backupCount"));
        config.setAsyncBackupCount(getInt(json, "asyncBackupCount"));
        config.setEvictionPercentage(getInt(json, "evictionPercentage"));
View Full Code Here

        config.setMergePolicy(getString(json, "mergePolicy"));
    }

    @Override
    public void readData(ObjectDataInput in) throws IOException {
        config = new MapConfig();
        config.setName(in.readUTF());
        config.setInMemoryFormat(InMemoryFormat.valueOf(in.readUTF()));
        config.setBackupCount(in.readInt());
        config.setAsyncBackupCount(in.readInt());
        config.setEvictionPercentage(in.readInt());
View Full Code Here

    }

    @Override
    public void run() throws Exception {
        MapService service = getService();
        MapConfig oldConfig = service.getMapServiceContext().getMapContainer(mapName).getMapConfig();
        MapConfig newConfig = new MapConfig(oldConfig);
        newConfig.setTimeToLiveSeconds(mapConfig.getTimeToLiveSeconds());
        newConfig.setMaxIdleSeconds(mapConfig.getMaxIdleSeconds());
        newConfig.setEvictionPolicy(mapConfig.getEvictionPolicy());
        newConfig.setEvictionPercentage(mapConfig.getEvictionPercentage());
        newConfig.setReadBackupData(mapConfig.isReadBackupData());
        newConfig.setBackupCount(mapConfig.getBackupCount());
        newConfig.setAsyncBackupCount(mapConfig.getAsyncBackupCount());
        newConfig.setMaxSizeConfig(mapConfig.getMaxSizeConfig());
        service.getMapServiceContext().getMapContainer(mapName).setMapConfig(newConfig.getAsReadOnly());
    }
View Full Code Here

    private void removeEvictables() {
        final int evictableSize = getEvictableSize();
        if (evictableSize < 1) {
            return;
        }
        final MapConfig mapConfig = mapContainer.getMapConfig();
        removeEvictableRecords(this, evictableSize, mapConfig, mapServiceContext);
    }
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

        this.setPartitionId(partitionId).setReplicaIndex(replicaIndex);
        data = new HashMap<String, Set<RecordReplicationInfo>>(container.getMaps().size());
        for (Entry<String, RecordStore> entry : container.getMaps().entrySet()) {
            RecordStore recordStore = entry.getValue();
            MapContainer mapContainer = recordStore.getMapContainer();
            final MapConfig mapConfig = mapContainer.getMapConfig();
            if (mapConfig.getTotalBackupCount() < replicaIndex) {
                continue;
            }
            String name = entry.getKey();
            // now prepare data to migrate records
            Set<RecordReplicationInfo> recordSet = new HashSet<RecordReplicationInfo>(recordStore.size());
View Full Code Here

    }


    private void setupMapConfig(String name, int size) {
        MapConfig cfg = new MapConfig(NODE_CACHE);
        cfg.setMaxSizeConfig(new MaxSizeConfig(size, MaxSizeConfig.MaxSizePolicy.PER_PARTITION));
        cfg.setAsyncBackupCount(1);
        cfg.setBackupCount(0);
        cfg.setEvictionPolicy(MapConfig.EvictionPolicy.LRU);
        cfg.setMaxIdleSeconds(600);     // 10 minutes
        cfg.setTimeToLiveSeconds(3600); // 1 hour

        hcConfiguration.addMapConfig(cfg);
    }
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.