本文整理了Java中com.hazelcast.config.Config.getSemaphoreConfig()
方法的一些代码示例,展示了Config.getSemaphoreConfig()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Config.getSemaphoreConfig()
方法的具体详情如下:
包路径:com.hazelcast.config.Config
类名称:Config
方法名:getSemaphoreConfig
[英]Returns the SemaphoreConfig 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 #addSemaphoreConfig(SemaphoreConfig).
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.
[中]返回给定名称的信号量配置,必要时创建一个,并将其添加到已知配置的集合中。
通过将配置名称模式与不带分区限定符的提供名称(名称中“@”之后的部分)匹配,可以找到配置。如果没有匹配的配置,它将通过克隆“默认”配置创建一个配置,并将其添加到配置集合中。
此方法旨在轻松流畅地创建和添加比默认配置更具体的配置,而无需通过调用#addSemaphoreConfig(SemaphoreConfig)显式添加。
因为如果新配置尚未出现,它会添加新配置,所以此方法将在使用此配置创建hazelcast实例之前使用。之后,可能会忽略新添加的配置。
代码示例来源:origin: com.hazelcast/hazelcast-all
@Override
public SemaphoreConfig getStaticConfig(@Nonnull Config staticConfig, @Nonnull String name) {
return staticConfig.getSemaphoreConfig(name);
}
代码示例来源:origin: hazelcast/hazelcast-jet
@Override
public SemaphoreConfig getStaticConfig(@Nonnull Config staticConfig, @Nonnull String name) {
return staticConfig.getSemaphoreConfig(name);
}
代码示例来源:origin: org.sonatype.sisu/sisu-locks
/**
* @return Hazelcast configuration; ensures semaphores start with {@link Integer#MAX_VALUE} permits by default
*/
private static Config getHazelcastConfig( final File configFile )
{
final Config config;
if ( null != configFile && configFile.isFile() )
{
try
{
config = new FileSystemXmlConfig( configFile );
}
catch ( final FileNotFoundException e )
{
throw new IllegalArgumentException( e.getMessage() );
}
}
else
{
config = new XmlConfigBuilder().build();
}
config.getSemaphoreConfig( "default" ).setInitialPermits( Integer.MAX_VALUE );
config.setClassLoader( Hazelcast.class.getClassLoader() );
return config;
}
}
代码示例来源:origin: hazelcast/hazelcast-jet
/**
* Returns a read-only {@link com.hazelcast.core.ISemaphore}
* 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 semaphore config
* @return the semaphore configuration
* @throws ConfigurationException if ambiguous configurations are found
* @see StringPartitioningStrategy#getBaseName(java.lang.String)
* @see #setConfigPatternMatcher(ConfigPatternMatcher)
* @see #getConfigPatternMatcher()
* @see EvictionConfig#setSize(int)
*/
public SemaphoreConfig findSemaphoreConfig(String name) {
name = getBaseName(name);
SemaphoreConfig config = lookupByPattern(configPatternMatcher, semaphoreConfigs, name);
if (config != null) {
return config.getAsReadOnly();
}
return getSemaphoreConfig("default").getAsReadOnly();
}
代码示例来源:origin: com.hazelcast/hazelcast-all
/**
* Returns a read-only {@link com.hazelcast.core.ISemaphore}
* 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 semaphore config
* @return the semaphore configuration
* @throws ConfigurationException if ambiguous configurations are found
* @see StringPartitioningStrategy#getBaseName(java.lang.String)
* @see #setConfigPatternMatcher(ConfigPatternMatcher)
* @see #getConfigPatternMatcher()
* @see EvictionConfig#setSize(int)
*/
public SemaphoreConfig findSemaphoreConfig(String name) {
name = getBaseName(name);
SemaphoreConfig config = lookupByPattern(configPatternMatcher, semaphoreConfigs, name);
if (config != null) {
return config.getAsReadOnly();
}
return getSemaphoreConfig("default").getAsReadOnly();
}
内容来源于网络,如有侵权,请联系作者删除!