private int handleMap(MemberStateImpl memberState, int count, Config config, Map<String, LocalMapStats> maps) { for (Map.Entry<String, LocalMapStats> entry : maps.entrySet()) { String name = entry.getKey(); if (config.findMapConfig(name).isStatisticsEnabled()) { LocalMapStats stats = entry.getValue(); memberState.putLocalMapStats(name, stats); ++count; } } return count; }
private int handleMap(MemberStateImpl memberState, int count, Config config, Map<String, LocalMapStats> maps) { for (Map.Entry<String, LocalMapStats> entry : maps.entrySet()) { String name = entry.getKey(); if (config.findMapConfig(name).isStatisticsEnabled()) { LocalMapStats stats = entry.getValue(); memberState.putLocalMapStats(name, stats); ++count; } } return count; }
/** * Get the current MapConfig for the given IMap * * @param mapName the name of the map * @return The current mapConfig for that map if it exists, null otherwise */ @Nullable MapConfig getMapConfig(@Nonnull String mapName) { MapConfig mapConfig = hazelcast.getConfig().findMapConfig(mapName); if (!mapConfig.getName().equals(mapName)) { return null; } else { return mapConfig; } }
/** * Returns the Vert.x Hazelcast instance. * * @return The Vert.x Hazelcast instance. */ public static HazelcastInstance getHazelcastInstance() { for (HazelcastInstance instance : Hazelcast.getAllHazelcastInstances()) { MapConfig map = instance.getConfig().findMapConfig("subs"); if (map != null && map.getName().equals("subs")) { return instance; } } return null; }
/** * Update the cache settings of an existing cache. Called by {@link com.atlassian.cache.ManagedCache} methods * * @param mapName The name of the map to update * @param newSettings CacheSettings object representing the new settings * @return true if the update succeeded, false otherwise */ public boolean updateCacheSettings(@Nonnull String mapName, @Nonnull CacheSettings newSettings) { //Do nothing if the map doesn't exist MapConfig mapConfig = hazelcast.getConfig().findMapConfig(mapName); if (!mapConfig.getName().equals(mapName)) { return false; } MapConfig newConfig = reconfigureMap(mapName, newSettings); boolean result = updateMapContainer(mapName, newConfig); if (result) { // store the config in the settings map to trigger other nodes to also configure the IMap mapSettings.put(mapName, asSerializable(newSettings)); } return result; }
@ManagedAnnotation("config") @ManagedDescription("MapConfig") public String getConfig() { return service.instance.getConfig().findMapConfig(managedObject.getName()).toString(); }
private static InMemoryFormat getInMemoryFormat(MapStoreContext mapStoreContext) { MapServiceContext mapServiceContext = mapStoreContext.getMapServiceContext(); NodeEngine nodeEngine = mapServiceContext.getNodeEngine(); Config config = nodeEngine.getConfig(); String mapName = mapStoreContext.getMapName(); MapConfig mapConfig = config.findMapConfig(mapName); return mapConfig.getInMemoryFormat(); }
protected MapConfig configureMap(String mapName, CacheSettings settings) { Config config = hazelcast.getConfig(); MapConfig mapConfig = config.findMapConfig(mapName); if (!mapConfig.getName().equals(mapName)) { mapConfig = convertAndStoreMapConfig(mapName, settings, config, mapConfig); // store the config in the settings map to trigger other nodes to also configure the IMap mapSettings.putIfAbsent(mapName, asSerializable(settings)); } else { log.debug("Using existing cache configuration for cache {}", mapName); } updateMapContainerIfAbsent(mapName, mapConfig); return mapConfig.getAsReadOnly(); }
private static InMemoryFormat getInMemoryFormat(MapStoreContext mapStoreContext) { MapServiceContext mapServiceContext = mapStoreContext.getMapServiceContext(); NodeEngine nodeEngine = mapServiceContext.getNodeEngine(); Config config = nodeEngine.getConfig(); String mapName = mapStoreContext.getMapName(); MapConfig mapConfig = config.findMapConfig(mapName); return mapConfig.getInMemoryFormat(); }
@ManagedAnnotation("config") @ManagedDescription("MapConfig") public String getConfig() { return service.instance.getConfig().findMapConfig(managedObject.getName()).toString(); }
public static int getTimeout(final HazelcastInstance instance, final 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); } return CacheEnvironment.getDefaultCacheTimeoutInMillis(); }
/** * @param name the name for this region cache, which is also used to retrieve configuration/topic * @param hazelcastInstance the {@code HazelcastInstance} to which this region cache belongs, used to retrieve * configuration and to lookup an {@link ITopic} to register a {@link MessageListener} * with if {@code withTopic} is {@code true} (optional) * @param metadata metadata describing the cached data, used to compare data versions (optional) * @param withTopic {@code true} to register a {@link MessageListener} with the {@link ITopic} whose name * matches this region cache <i>if</i> a {@code HazelcastInstance} was provided to look * up the topic; otherwise, {@code false} not to register a listener even if an instance * was provided */ public LocalRegionCache(final String name, final HazelcastInstance hazelcastInstance, final CacheDataDescription metadata, final boolean withTopic) { this.hazelcastInstance = hazelcastInstance; try { config = hazelcastInstance != null ? hazelcastInstance.getConfig().findMapConfig(name) : null; } catch (UnsupportedOperationException ignored) { EmptyStatement.ignore(ignored); } versionComparator = metadata != null && metadata.isVersioned() ? metadata.getVersionComparator() : null; cache = new ConcurrentHashMap<Object, Expirable>(); markerIdCounter = new AtomicLong(); messageListener = createMessageListener(); if (withTopic && hazelcastInstance != null) { topic = hazelcastInstance.getTopic(name); topic.addMessageListener(messageListener); } else { topic = null; } }
public static int getTimeout(final HazelcastInstance instance, final 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); } return CacheEnvironment.getDefaultCacheTimeoutInMillis(); }
this.hazelcastInstance = hazelcastInstance; try { config = hazelcastInstance != null ? hazelcastInstance.getConfig().findMapConfig(name) : null; } catch (UnsupportedOperationException ignored) { EmptyStatement.ignore(ignored);
public static int getTimeout(final HazelcastInstance instance, final 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); } return CacheEnvironment.getDefaultCacheTimeoutInMillis(); }
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); } return CacheEnvironment.getDefaultCacheTimeoutInMillis(); }
@Override public DistributedObject createDistributedObject(String name) { Config config = nodeEngine.getConfig(); MapConfig mapConfig = config.findMapConfig(name); MergePolicyProvider mergePolicyProvider = mapServiceContext.getMergePolicyProvider(); checkMapConfig(mapConfig, mergePolicyProvider); Object mergePolicy = mergePolicyProvider.getMergePolicy(mapConfig.getMergePolicyConfig().getPolicy()); checkMergePolicySupportsInMemoryFormat(name, mergePolicy, mapConfig.getInMemoryFormat(), true, nodeEngine.getLogger(getClass())); if (mapConfig.isNearCacheEnabled()) { initDefaultMaxSizeForOnHeapMaps(mapConfig.getNearCacheConfig()); checkNearCacheConfig(name, mapConfig.getNearCacheConfig(), config.getNativeMemoryConfig(), false); return new NearCachedMapProxyImpl(name, mapServiceContext.getService(), nodeEngine, mapConfig); } else { return new MapProxyImpl(name, mapServiceContext.getService(), nodeEngine, mapConfig); } }
TransactionalMapProxySupport(String name, MapService mapService, NodeEngine nodeEngine, Transaction transaction) { super(nodeEngine, mapService, transaction); this.name = name; this.mapServiceContext = mapService.getMapServiceContext(); this.mapNearCacheManager = mapServiceContext.getMapNearCacheManager(); MapConfig mapConfig = nodeEngine.getConfig().findMapConfig(name); this.operationProvider = mapServiceContext.getMapOperationProvider(mapConfig); this.partitionStrategy = mapServiceContext.getPartitioningStrategy(name, mapConfig.getPartitioningStrategyConfig()); this.partitionService = nodeEngine.getPartitionService(); this.operationService = nodeEngine.getOperationService(); this.ss = ((InternalSerializationService) nodeEngine.getSerializationService()); this.nearCacheEnabled = mapConfig.isNearCacheEnabled(); this.serializeKeys = nearCacheEnabled && mapConfig.getNearCacheConfig().isSerializeKeys(); this.valueComparator = mapServiceContext.getValueComparatorOf(mapConfig.getInMemoryFormat()); }
TransactionalMapProxySupport(String name, MapService mapService, NodeEngine nodeEngine, Transaction transaction) { super(nodeEngine, mapService, transaction); this.name = name; this.mapServiceContext = mapService.getMapServiceContext(); this.mapNearCacheManager = mapServiceContext.getMapNearCacheManager(); MapConfig mapConfig = nodeEngine.getConfig().findMapConfig(name); this.operationProvider = mapServiceContext.getMapOperationProvider(mapConfig); this.partitionStrategy = mapServiceContext.getPartitioningStrategy(name, mapConfig.getPartitioningStrategyConfig()); this.partitionService = nodeEngine.getPartitionService(); this.operationService = nodeEngine.getOperationService(); this.ss = ((InternalSerializationService) nodeEngine.getSerializationService()); this.nearCacheEnabled = mapConfig.isNearCacheEnabled(); this.serializeKeys = nearCacheEnabled && mapConfig.getNearCacheConfig().isSerializeKeys(); this.valueComparator = mapServiceContext.getValueComparatorOf(mapConfig.getInMemoryFormat()); }
@Override public DistributedObject createDistributedObject(String name) { Config config = nodeEngine.getConfig(); MapConfig mapConfig = config.findMapConfig(name); MergePolicyProvider mergePolicyProvider = mapServiceContext.getMergePolicyProvider(); checkMapConfig(mapConfig, mergePolicyProvider); Object mergePolicy = mergePolicyProvider.getMergePolicy(mapConfig.getMergePolicyConfig().getPolicy()); checkMergePolicySupportsInMemoryFormat(name, mergePolicy, mapConfig.getInMemoryFormat(), nodeEngine.getClusterService().getClusterVersion(), true, nodeEngine.getLogger(getClass())); if (mapConfig.isNearCacheEnabled()) { initDefaultMaxSizeForOnHeapMaps(mapConfig.getNearCacheConfig()); checkNearCacheConfig(name, mapConfig.getNearCacheConfig(), config.getNativeMemoryConfig(), false); return new NearCachedMapProxyImpl(name, mapServiceContext.getService(), nodeEngine, mapConfig); } else { return new MapProxyImpl(name, mapServiceContext.getService(), nodeEngine, mapConfig); } }