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

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

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

Config.getFlakeIdGeneratorConfig介绍

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

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

代码示例

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

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

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

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

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

/**
 * Returns a {@link FlakeIdGeneratorConfig} configuration for the given flake ID generator 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 flake ID generator config
 * @return the flake ID generator configuration
 * @throws ConfigurationException if ambiguous configurations are found
 * @see com.hazelcast.partition.strategy.StringPartitioningStrategy#getBaseName(java.lang.String)
 * @see #setConfigPatternMatcher(ConfigPatternMatcher)
 * @see #getConfigPatternMatcher()
 */
public FlakeIdGeneratorConfig findFlakeIdGeneratorConfig(String name) {
  String baseName = getBaseName(name);
  FlakeIdGeneratorConfig config = lookupByPattern(configPatternMatcher, flakeIdGeneratorConfigMap, baseName);
  if (config != null) {
    return config;
  }
  return getFlakeIdGeneratorConfig("default");
}

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

/**
 * Returns a {@link FlakeIdGeneratorConfig} configuration for the given flake ID generator 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 flake ID generator config
 * @return the flake ID generator configuration
 * @throws ConfigurationException if ambiguous configurations are found
 * @see com.hazelcast.partition.strategy.StringPartitioningStrategy#getBaseName(java.lang.String)
 * @see #setConfigPatternMatcher(ConfigPatternMatcher)
 * @see #getConfigPatternMatcher()
 */
public FlakeIdGeneratorConfig findFlakeIdGeneratorConfig(String name) {
  String baseName = getBaseName(name);
  FlakeIdGeneratorConfig config = lookupByPattern(configPatternMatcher, flakeIdGeneratorConfigMap, baseName);
  if (config != null) {
    return config;
  }
  return getFlakeIdGeneratorConfig("default");
}

相关文章

微信公众号

最新文章

更多

Config类方法