org.infinispan.lock.configuration.ClusteredLockManagerConfiguration Maven / Gradle / Ivy
Show all versions of infinispan-clustered-lock Show documentation
package org.infinispan.lock.configuration;
import java.util.Map;
import org.infinispan.commons.configuration.BuiltBy;
import org.infinispan.commons.configuration.attributes.AttributeDefinition;
import org.infinispan.commons.configuration.attributes.AttributeSet;
import org.infinispan.commons.logging.LogFactory;
import org.infinispan.lock.logging.Log;
/**
* The {@link org.infinispan.lock.api.ClusteredLockManager} configuration.
*
*
* @author Katia Aresti, [email protected]
* @since 9.4
*/
@BuiltBy(ClusteredLockManagerConfigurationBuilder.class)
public class ClusteredLockManagerConfiguration {
private static final Log log = LogFactory.getLog(ClusteredLockManagerConfiguration.class, Log.class);
static final AttributeDefinition RELIABILITY = AttributeDefinition
.builder(Attribute.RELIABILITY, Reliability.CONSISTENT)
.validator(value -> {
if (value == null) {
throw log.invalidReliabilityMode();
}
})
.immutable().build();
static final AttributeDefinition NUM_OWNERS = AttributeDefinition.builder(Attribute.NUM_OWNERS, -1)
.validator(value -> {
if (value <= 0 && value != -1) {
throw log.invalidNumOwners(value);
}
})
.immutable().build();
private final AttributeSet attributes;
private final Map locks;
ClusteredLockManagerConfiguration(AttributeSet attributes, Map locks) {
this.attributes = attributes;
this.locks = locks;
}
static AttributeSet attributeDefinitionSet() {
return new AttributeSet(ClusteredLockManagerConfiguration.class, NUM_OWNERS, RELIABILITY);
}
public int numOwners() {
return attributes.attribute(NUM_OWNERS).get();
}
public Reliability reliability() {
return attributes.attribute(RELIABILITY).get();
}
AttributeSet attributes() {
return attributes;
}
public Map locks() {
return locks;
}
}