com.hazelcast.config.Config.findMapConfig()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(12.5k)|赞(0)|评价(0)|浏览(112)

本文整理了Java中com.hazelcast.config.Config.findMapConfig()方法的一些代码示例,展示了Config.findMapConfig()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Config.findMapConfig()方法的具体详情如下:
包路径:com.hazelcast.config.Config
类名称:Config
方法名:findMapConfig

Config.findMapConfig介绍

[英]Returns a read-only com.hazelcast.core.IMap configuration for the given name.

The name is matched by pattern to the configuration and by stripping the partition ID qualifier from the given name. If there is no config found by the name, it will return the configuration with the name default. For non-default configurations and on-heap maps, it will also initialise the Near Cache eviction if not previously set.
[中]返回只读com。黑泽尔卡斯特。果心给定名称的IMap配置。
该名称通过模式与配置匹配,并从给定名称中剥离分区ID限定符。如果没有通过名称找到配置,它将返回名为default的配置。对于非默认配置和堆映射,如果之前未设置,它还将初始化近缓存逐出。

代码示例

代码示例来源:origin: hazelcast/hazelcast-jet

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;
}

代码示例来源:origin: com.hazelcast/hazelcast-all

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;
}

代码示例来源:origin: com.atlassian.cache/atlassian-cache-hazelcast

/**
 * 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;
  }
}

代码示例来源:origin: net.kuujo/xync

/**
 * 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;
}

代码示例来源:origin: com.atlassian.cache/atlassian-cache-hazelcast

/**
 * 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;
}

代码示例来源:origin: hazelcast/hazelcast-jet

@ManagedAnnotation("config")
@ManagedDescription("MapConfig")
public String getConfig() {
  return service.instance.getConfig().findMapConfig(managedObject.getName()).toString();
}

代码示例来源:origin: hazelcast/hazelcast-jet

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();
}

代码示例来源:origin: com.atlassian.cache/atlassian-cache-hazelcast

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();
}

代码示例来源:origin: com.hazelcast/hazelcast-all

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();
}

代码示例来源:origin: com.hazelcast/hazelcast-all

@ManagedAnnotation("config")
@ManagedDescription("MapConfig")
public String getConfig() {
  return service.instance.getConfig().findMapConfig(managedObject.getName()).toString();
}

代码示例来源:origin: com.hazelcast/hazelcast-hibernate5

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();
}

代码示例来源:origin: com.hazelcast/hazelcast-hibernate5

/**
 * @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;
  }
}

代码示例来源:origin: com.hazelcast/hazelcast-all

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();
}

代码示例来源:origin: com.hazelcast/hazelcast-hibernate4

this.hazelcastInstance = hazelcastInstance;
try {
  config = hazelcastInstance != null ? hazelcastInstance.getConfig().findMapConfig(name) : null;
} catch (UnsupportedOperationException ignored) {
  EmptyStatement.ignore(ignored);

代码示例来源:origin: com.hazelcast/hazelcast-hibernate52

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();
}

代码示例来源:origin: com.hazelcast/hazelcast-hibernate4

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();
}

代码示例来源:origin: hazelcast/hazelcast-jet

@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);
  }
}

代码示例来源:origin: hazelcast/hazelcast-jet

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());
}

代码示例来源:origin: com.hazelcast/hazelcast-all

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());
}

代码示例来源:origin: com.hazelcast/hazelcast-all

@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);
  }
}

相关文章

微信公众号

最新文章

更多

Config类方法