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

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

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

Config.getMapConfig介绍

[英]Returns the MapConfig for the given name, creating one if necessary and adding it to the collection of known configurations.

The configuration is found by matching the configuration name pattern to the provided name without the partition qualifier (the part of the name after '@'). If no configuration matches, it will create one by cloning the "default" configuration and add it to the configuration collection.

This method is intended to easily and fluently create and add configurations more specific than the default configuration without explicitly adding it by invoking #addMapConfig(MapConfig).

Because it adds new configurations if they are not already present, this method is intended to be used before this config is used to create a hazelcast instance. Afterwards, newly added configurations may be ignored.
[中]返回给定名称的MapConfig,必要时创建一个,并将其添加到已知配置的集合中。
通过将配置名称模式与不带分区限定符的提供名称(名称中“@”之后的部分)匹配,可以找到配置。如果没有匹配的配置,它将通过克隆“默认”配置创建一个配置,并将其添加到配置集合中。
此方法旨在轻松流畅地创建和添加比默认配置更具体的配置,而无需通过调用#addMapConfig(MapConfig)显式添加。
因为如果新配置尚未出现,它会添加新配置,所以此方法将在使用此配置创建hazelcast实例之前使用。之后,可能会忽略新添加的配置。

代码示例

代码示例来源:origin: spring-projects/spring-session

@Bean
public HazelcastInstance hazelcastInstance() {
  MapAttributeConfig attributeConfig = new MapAttributeConfig()
      .setName(HazelcastSessionRepository.PRINCIPAL_NAME_ATTRIBUTE)
      .setExtractor(PrincipalNameExtractor.class.getName());
  Config config = new Config();
  config.getMapConfig(HazelcastSessionRepository.DEFAULT_SESSION_MAP_NAME) // <2>
      .addMapAttributeConfig(attributeConfig)
      .addMapIndexConfig(new MapIndexConfig(
          HazelcastSessionRepository.PRINCIPAL_NAME_ATTRIBUTE, false));
  return Hazelcast.newHazelcastInstance(config); // <3>
}

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

@Override
public MapConfig getStaticConfig(@Nonnull Config staticConfig, @Nonnull String name) {
  return staticConfig.getMapConfig(name);
}

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

@Override
public MapConfig getStaticConfig(@Nonnull Config staticConfig, @Nonnull String name) {
  return staticConfig.getMapConfig(name);
}

代码示例来源:origin: stackoverflow.com

Config config = new XmlConfigBuilder().build();
config.getMapConfig("myMapName").setTimeToLiveSeconds(10000);

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

@Override
  public void removeConfiguration(String mapName, String cacheName) {
    MapConfig mapConfig = config.getMapConfig(mapName);
    List<QueryCacheConfig> queryCacheConfigs = mapConfig.getQueryCacheConfigs();
    if (queryCacheConfigs == null || queryCacheConfigs.isEmpty()) {
      return;
    }
    Iterator<QueryCacheConfig> iterator = queryCacheConfigs.iterator();
    while (iterator.hasNext()) {
      QueryCacheConfig config = iterator.next();
      if (config.getName().equals(cacheName)) {
        iterator.remove();
      }
    }
  }
}

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

protected MapConfig reconfigureMap(String mapName, CacheSettings newSettings)
{
  Config config = hazelcast.getConfig();
  MapConfig baseConfig = config.getMapConfig(mapName);
  return convertAndStoreMapConfig(mapName, newSettings, config, baseConfig);
}

代码示例来源:origin: com.hazelcast.simulator/tests-common

public static MapStoreConfig getMapStoreConfig(HazelcastInstance instance, String mapName) {
  return instance.getConfig().getMapConfig(mapName).getMapStoreConfig();
}

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

@Verify(global = false)
public void verify() throws Exception {
  try{
    MaxSizeConfig maxSizeConfig = targetInstance.getConfig().getMapConfig(basename).getMaxSizeConfig();
    IMap map = targetInstance.getMap(basename);
    System.out.println(maxSizeConfig);
    System.out.println(basename+": Map size = "+map.size());
  }catch(UnsupportedOperationException e){}
}

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

private static void setStoreImplToWritableMapStoreConfig(NodeEngine nodeEngine, String mapName, Object store) {
  final Config config = nodeEngine.getConfig();
  // get writable config (not read-only one) from node engine.
  final MapConfig mapConfig = config.getMapConfig(mapName);
  final MapStoreConfig mapStoreConfig = mapConfig.getMapStoreConfig();
  mapStoreConfig.setImplementation(store);
}

代码示例来源:origin: mokies/ratelimitj

private IMap<String, Long> getMap(String key, int longestDuration) {
  MapConfig mapConfig = hz.getConfig().getMapConfig(key);
  mapConfig.setTimeToLiveSeconds(longestDuration);
  mapConfig.setAsyncBackupCount(1);
  mapConfig.setBackupCount(0);
  return hz.getMap(key);
}

代码示例来源:origin: stackoverflow.com

class Foo{

  private InitialLoadMode initialLoadMode = InitialLoadMode.EAGER;
  final Config config= new Config();
  final MapConfig mapConfig = config.getMapConfig("*");
  final MapStoreConfig mapStoreConfig = mapConfig.getMapStoreConfig();
  {
    mapStoreConfig.setInitialLoadMode(initialLoadMode);
  }
}

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

private static void setStoreImplToWritableMapStoreConfig(NodeEngine nodeEngine, String mapName, Object store) {
  final Config config = nodeEngine.getConfig();
  // get writable config (not read-only one) from node engine.
  final MapConfig mapConfig = config.getMapConfig(mapName);
  final MapStoreConfig mapStoreConfig = mapConfig.getMapStoreConfig();
  mapStoreConfig.setImplementation(store);
}

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

@Override
public QueryCacheConfig getOrCreateConfiguration(String mapName, String cacheName, String cacheId) {
  MapConfig mapConfig = config.getMapConfig(mapName);
  QueryCacheConfig queryCacheConfig = findQueryCacheConfigFromMapConfig(mapConfig, cacheName);
  if (queryCacheConfig != null) {
    setPredicateImpl(queryCacheConfig);
    setEntryListener(mapName, cacheId, queryCacheConfig);
    return queryCacheConfig;
  }
  QueryCacheConfig newConfig = new QueryCacheConfig(cacheName);
  mapConfig.getQueryCacheConfigs().add(newConfig);
  return newConfig;
}

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

@Override
public QueryCacheConfig getOrCreateConfiguration(String mapName, String cacheName, String cacheId) {
  MapConfig mapConfig = config.getMapConfig(mapName);
  QueryCacheConfig queryCacheConfig = findQueryCacheConfigFromMapConfig(mapConfig, cacheName);
  if (queryCacheConfig != null) {
    setPredicateImpl(queryCacheConfig);
    setEntryListener(mapName, cacheId, queryCacheConfig);
    return queryCacheConfig;
  }
  QueryCacheConfig newConfig = new QueryCacheConfig(cacheName);
  mapConfig.getQueryCacheConfigs().add(newConfig);
  return newConfig;
}

代码示例来源:origin: dsukhoroslov/bagri

public void setRepository(SchemaRepositoryImpl repo) {
  this.repo = repo;
  this.factory = repo.getFactory();
  //this.model = repo.getModelManagement();
  this.txManager = (TransactionManagementImpl) repo.getTxManagement();
  this.triggerManager = (TriggerManagementImpl) repo.getTriggerManagement();
  binaryDocs = InMemoryFormat.BINARY == repo.getHzInstance().getConfig().getMapConfig(CN_XDM_DOCUMENT).getInMemoryFormat();
  binaryElts = InMemoryFormat.BINARY == repo.getHzInstance().getConfig().getMapConfig(CN_XDM_ELEMENT).getInMemoryFormat();
  binaryContent = InMemoryFormat.BINARY == repo.getHzInstance().getConfig().getMapConfig(CN_XDM_CONTENT).getInMemoryFormat();
  //keyCache = repo.getHzInstance().getMap(CN_XDM_KEY);
}

代码示例来源:origin: kloiasoft/eventapis

@Override
public Config configure(Config config) {
  List<MapIndexConfig> indexes = Arrays.asList(
      new MapIndexConfig("startTime", true),
      new MapIndexConfig("operationState", true)
  );
  config.getMapConfig(OPERATIONS_MAP_NAME)
      .setTimeToLiveSeconds(OPERATIONS_MAX_TTL_INSEC)
      .setMapIndexConfigs(indexes);
  config.getMapConfig(OPERATIONS_MAP_HISTORY_NAME)
      .setMapIndexConfigs(indexes)
      .setMaxSizeConfig(new MaxSizeConfig(evictFreePercentage, MaxSizeConfig.MaxSizePolicy.FREE_HEAP_PERCENTAGE))
      .setEvictionPolicy(EvictionPolicy.LRU);
  config.getReplicatedMapConfig(TOPICS_MAP_NAME);
  return config;
}

代码示例来源:origin: hazelcast/hazelcast-code-samples

public static void main(String[] args) {
    Config config = new Config();
    final MapConfig supplementsMapConfig = config.getMapConfig("supplements");

    final MapStoreConfig mapStoreConfig = supplementsMapConfig.getMapStoreConfig();
    mapStoreConfig
        .setEnabled(true)
        .setClassName("com.hazelcast.loader.MongoMapStore")
        .setProperty("mongo.url", "mongodb://localhost:27017")
        .setProperty("mongo.db", "mydb")
        .setProperty("mongo.collection", "supplements");

    final HazelcastInstance hazelcastInstance = newHazelcastInstance(config);
    new ReadWriteThroughCache(hazelcastInstance).run();
  }
}

代码示例来源:origin: hazelcast/hazelcast-code-samples

private static Config createNewConfig(String mapName) {
  SimpleStore simpleStore = new SimpleStore();
  MapStoreConfig mapStoreConfig = new MapStoreConfig();
  mapStoreConfig.setImplementation(simpleStore);
  mapStoreConfig.setWriteDelaySeconds(0);
  XmlConfigBuilder configBuilder = new XmlConfigBuilder();
  Config config = configBuilder.build();
  MapConfig mapConfig = config.getMapConfig(mapName);
  mapConfig.setMapStoreConfig(mapStoreConfig);
  return config;
}

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

private static HazelcastInstance createInstance(ClusteredSessionService sessionService, WebFilterConfig filterConfig)
    throws ServletException {
  LOGGER.info("Creating a new HazelcastInstance for session replication");
  Config config;
  if (filterConfig.getConfigUrl() == null) {
    config = new XmlConfigBuilder().build();
  } else {
    try {
      config = new UrlXmlConfig(filterConfig.getConfigUrl());
    } catch (IOException e) {
      throw new ServletException(e);
    }
  }
  config.getMapConfig(filterConfig.getMapName()).setMaxIdleSeconds(filterConfig.getSessionTtlSeconds());
  config.addListenerConfig(new ListenerConfig(new ServerLifecycleListener(sessionService)));
  return Hazelcast.newHazelcastInstance(config);
}

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

private void assertHazelcastConfig(Config cfg) {
    assertTrue(cfg.getManagedContext() instanceof SpringManagedContext);
    assertEquals("jet-spring", cfg.getGroupConfig().getName());
    assertEquals("jet-spring-pass", cfg.getGroupConfig().getPassword());

    NetworkConfig networkConfig = cfg.getNetworkConfig();
    assertEquals(5707, networkConfig.getPort());
    assertFalse(networkConfig.isPortAutoIncrement());

    JoinConfig join = networkConfig.getJoin();
    assertFalse(join.getMulticastConfig().isEnabled());

    TcpIpConfig tcpIpConfig = join.getTcpIpConfig();
    assertTrue(tcpIpConfig.isEnabled());
    List<String> members = tcpIpConfig.getMembers();
    assertEquals(1, members.size());
    assertEquals("127.0.0.1:5707", members.get(0));

    assertEquals(3, cfg.getMapConfig("map").getBackupCount());
  }
}

相关文章

Config类方法