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

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

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

Config.getCacheConfig介绍

[英]Returns the CacheSimpleConfig 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 #addCacheConfig(CacheSimpleConfig).

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.
[中]返回给定名称的CacheSimpleConfig,必要时创建一个,并将其添加到已知配置的集合中。
通过将配置名称模式与不带分区限定符的提供名称(名称中“@”之后的部分)匹配,可以找到配置。如果没有匹配的配置,它将通过克隆“默认”配置创建一个配置,并将其添加到配置集合中。
此方法旨在轻松流畅地创建和添加比默认配置更具体的配置,而无需通过调用#addCacheConfig(CacheSimpleConfig)显式添加。
因为如果新配置尚未出现,它会添加新配置,所以此方法将在使用此配置创建hazelcast实例之前使用。之后,可能会忽略新添加的配置。

代码示例

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

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

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

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

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

CacheConfig config = new CacheConfig(clusterA.getConfig().getCacheConfig("default"));
ICache<Object, Object> cache = manager.getOrCreateCache("default", config);

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

CacheConfig cacheConfig = new CacheConfig(clusterB.getConfig().getCacheConfig("default"));
ICache<Object, Object> cache = manager.getOrCreateCache("default", cacheConfig);

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

/**
 * Returns a read-only {@link CacheSimpleConfig} configuration for the given name.
 * <p>
 * The name is matched by pattern to the configuration and by stripping the
 * partition ID qualifier from the given {@code name}.
 * If there is no config found by the name, it will return the configuration
 * with the name {@code default}.
 *
 * @param name name of the cardinality estimator config
 * @return the cache configuration
 * @throws ConfigurationException if ambiguous configurations are found
 * @see StringPartitioningStrategy#getBaseName(java.lang.String)
 * @see #setConfigPatternMatcher(ConfigPatternMatcher)
 * @see #getConfigPatternMatcher()
 */
public CacheSimpleConfig findCacheConfig(String name) {
  name = getBaseName(name);
  final CacheSimpleConfig config = lookupByPattern(configPatternMatcher, cacheConfigs, name);
  if (config != null) {
    return config.getAsReadOnly();
  }
  return getCacheConfig("default").getAsReadOnly();
}

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

/**
 * Returns a read-only {@link CacheSimpleConfig} configuration for the given name.
 * <p>
 * The name is matched by pattern to the configuration and by stripping the
 * partition ID qualifier from the given {@code name}.
 * If there is no config found by the name, it will return the configuration
 * with the name {@code default}.
 *
 * @param name name of the cardinality estimator config
 * @return the cache configuration
 * @throws ConfigurationException if ambiguous configurations are found
 * @see StringPartitioningStrategy#getBaseName(java.lang.String)
 * @see #setConfigPatternMatcher(ConfigPatternMatcher)
 * @see #getConfigPatternMatcher()
 */
public CacheSimpleConfig findCacheConfig(String name) {
  name = getBaseName(name);
  final CacheSimpleConfig config = lookupByPattern(configPatternMatcher, cacheConfigs, name);
  if (config != null) {
    return config.getAsReadOnly();
  }
  return getCacheConfig("default").getAsReadOnly();
}

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

private Config getConfigClusterA() {
  Config config = new Config();
  config.setLicenseKey(ENTERPRISE_LICENSE_KEY);
  config.getGroupConfig().setName("clusterA").setPassword("clusterA-pass");
  config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
  config.getNetworkConfig().getJoin().getTcpIpConfig().setEnabled(true).addMember("127.0.0.1:5701");
  config.setInstanceName("clusterA");
  config.getNetworkConfig().setPort(5701);
  config.setClassLoader(createCacheManagerClassLoader());
  WanReplicationConfig wanReplicationConfig = new WanReplicationConfig();
  wanReplicationConfig.setName("AtoB");
  WanPublisherConfig publisherConfigClusterB = new WanPublisherConfig();
  publisherConfigClusterB.setClassName(WanBatchReplication.class.getName());
  publisherConfigClusterB.setGroupName("clusterB");
  Map<String, Comparable> props = publisherConfigClusterB.getProperties();
  props.put(WanReplicationProperties.ENDPOINTS.key(), "127.0.0.1:5702");
  props.put(WanReplicationProperties.GROUP_PASSWORD.key(), "clusterB-pass");
  // setting acknowledge type is optional, defaults to ACK_ON_OPERATION_COMPLETE
  props.put(WanReplicationProperties.ACK_TYPE.key(), WanAcknowledgeType.ACK_ON_OPERATION_COMPLETE.name());
  wanReplicationConfig.addWanPublisherConfig(publisherConfigClusterB);
  config.addWanReplicationConfig(wanReplicationConfig);
  WanReplicationRef wanReplicationRef = new WanReplicationRef();
  wanReplicationRef.setName("AtoB");
  config.setLicenseKey(ENTERPRISE_LICENSE_KEY);
  wanReplicationRef.setMergePolicy(HigherHitsCacheMergePolicy.class.getName());
  wanReplicationRef.addFilter(SampleCacheWanEventFilter.class.getName());
  config.getCacheConfig("default").setWanReplicationRef(wanReplicationRef);
  return config;
}

相关文章

微信公众号

最新文章

更多

Config类方法