Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ISPN-10407 Representation of the CacheManager configuration as JSON
- Loading branch information
1 parent
e3b652c
commit 6e51d36
Showing
59 changed files
with
3,484 additions
and
658 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
core/src/main/java/org/infinispan/configuration/global/BoundedThreadPoolConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,86 @@ | |||
package org.infinispan.configuration.global; | |||
|
|||
import org.infinispan.commons.configuration.ConfigurationInfo; | |||
import org.infinispan.commons.configuration.attributes.Attribute; | |||
import org.infinispan.commons.configuration.attributes.AttributeDefinition; | |||
import org.infinispan.commons.configuration.attributes.AttributeSet; | |||
import org.infinispan.commons.configuration.elements.DefaultElementDefinition; | |||
import org.infinispan.commons.configuration.elements.ElementDefinition; | |||
import org.infinispan.configuration.parsing.Element; | |||
|
|||
/** | |||
* @since 10.0 | |||
*/ | |||
class BoundedThreadPoolConfiguration implements ConfigurationInfo { | |||
static final AttributeDefinition<String> NAME = AttributeDefinition.builder("name", null, String.class).build(); | |||
static final AttributeDefinition<String> THREAD_FACTORY = AttributeDefinition.builder("threadFactory", null, String.class).build(); | |||
static final AttributeDefinition<Integer> MAX_THREADS = AttributeDefinition.builder("maxThreads", null, Integer.class).build(); | |||
static final AttributeDefinition<Integer> CORE_THREADS = AttributeDefinition.builder("coreThreads", null, Integer.class).build(); | |||
static final AttributeDefinition<Long> KEEP_ALIVE_TIME = AttributeDefinition.builder("keepAliveTime", null, Long.class).build(); | |||
static final AttributeDefinition<Integer> QUEUE_LENGTH = AttributeDefinition.builder("queue-length", null, Integer.class).build(); | |||
|
|||
private final AttributeSet attributes; | |||
private final Attribute<String> name; | |||
private final Attribute<String> threadFactory; | |||
private final Attribute<Integer> maxThreads; | |||
private final Attribute<Integer> coreThreads; | |||
private final Attribute<Long> keepAliveTime; | |||
private final Attribute<Integer> queueLength; | |||
|
|||
public static AttributeSet attributeDefinitionSet() { | |||
return new AttributeSet(BoundedThreadPoolConfiguration.class, NAME, THREAD_FACTORY, MAX_THREADS, CORE_THREADS, KEEP_ALIVE_TIME, QUEUE_LENGTH); | |||
} | |||
|
|||
static ElementDefinition ELEMENT_DEFINITION = new DefaultElementDefinition(Element.BLOCKING_BOUNDED_QUEUE_THREAD_POOL.getLocalName()); | |||
|
|||
BoundedThreadPoolConfiguration(AttributeSet attributes) { | |||
this.attributes = attributes.checkProtection(); | |||
this.name = attributes.attribute(NAME); | |||
this.threadFactory = attributes.attribute(THREAD_FACTORY); | |||
this.maxThreads = attributes.attribute(MAX_THREADS); | |||
this.coreThreads = attributes.attribute(CORE_THREADS); | |||
this.keepAliveTime = attributes.attribute(KEEP_ALIVE_TIME); | |||
this.queueLength = attributes.attribute(QUEUE_LENGTH); | |||
} | |||
|
|||
@Override | |||
public ElementDefinition getElementDefinition() { | |||
return ELEMENT_DEFINITION; | |||
} | |||
|
|||
public AttributeSet attributes() { | |||
return attributes; | |||
} | |||
|
|||
public String name() { | |||
return name.get(); | |||
} | |||
|
|||
public String threadFactory() { | |||
return threadFactory.get(); | |||
} | |||
|
|||
public Integer getMaxThreads() { | |||
return maxThreads.get(); | |||
} | |||
|
|||
public Integer getCoreThreads() { | |||
return coreThreads.get(); | |||
} | |||
|
|||
public Long getKeepAliveTime() { | |||
return keepAliveTime.get(); | |||
} | |||
|
|||
public Integer getQueueLength() { | |||
return queueLength.get(); | |||
} | |||
|
|||
@Override | |||
public String toString() { | |||
return "BoundedThreadPoolConfiguration{" + | |||
"attributes=" + attributes + | |||
'}'; | |||
} | |||
|
|||
} |
111 changes: 111 additions & 0 deletions
111
.../main/java/org/infinispan/configuration/global/BoundedThreadPoolConfigurationBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,111 @@ | |||
package org.infinispan.configuration.global; | |||
|
|||
import static org.infinispan.configuration.global.BoundedThreadPoolConfiguration.CORE_THREADS; | |||
import static org.infinispan.configuration.global.BoundedThreadPoolConfiguration.KEEP_ALIVE_TIME; | |||
import static org.infinispan.configuration.global.BoundedThreadPoolConfiguration.MAX_THREADS; | |||
import static org.infinispan.configuration.global.BoundedThreadPoolConfiguration.QUEUE_LENGTH; | |||
import static org.infinispan.configuration.global.CachedThreadPoolConfiguration.NAME; | |||
import static org.infinispan.configuration.global.CachedThreadPoolConfiguration.THREAD_FACTORY; | |||
|
|||
import org.infinispan.commons.configuration.Builder; | |||
import org.infinispan.commons.configuration.attributes.AttributeSet; | |||
import org.infinispan.commons.executors.BlockingThreadPoolExecutorFactory; | |||
import org.infinispan.factories.threads.DefaultThreadFactory; | |||
|
|||
/* | |||
* @since 10.0 | |||
*/ | |||
public class BoundedThreadPoolConfigurationBuilder extends AbstractGlobalConfigurationBuilder implements Builder<BoundedThreadPoolConfiguration>, ThreadPoolBuilderAdapter { | |||
private final AttributeSet attributes; | |||
|
|||
BoundedThreadPoolConfigurationBuilder(GlobalConfigurationBuilder globalConfig, String name) { | |||
super(globalConfig); | |||
attributes = BoundedThreadPoolConfiguration.attributeDefinitionSet(); | |||
attributes.attribute(NAME).set(name); | |||
|
|||
} | |||
|
|||
public AttributeSet attributes() { | |||
return attributes; | |||
} | |||
|
|||
public BoundedThreadPoolConfigurationBuilder threadFactory(String threadFactory) { | |||
attributes.attribute(THREAD_FACTORY).set(threadFactory); | |||
return this; | |||
} | |||
|
|||
public BoundedThreadPoolConfigurationBuilder maxThreads(Integer maxThreads) { | |||
attributes.attribute(MAX_THREADS).set(maxThreads); | |||
return this; | |||
} | |||
|
|||
public Integer maxThreads() { | |||
return attributes.attribute(MAX_THREADS).get(); | |||
} | |||
|
|||
public BoundedThreadPoolConfigurationBuilder coreThreads(Integer coreThreads) { | |||
attributes.attribute(CORE_THREADS).set(coreThreads); | |||
return this; | |||
} | |||
|
|||
public Integer coreThreads() { | |||
return attributes.attribute(CORE_THREADS).get(); | |||
} | |||
|
|||
public BoundedThreadPoolConfigurationBuilder keepAliveTime(Long keepAlive) { | |||
attributes.attribute(KEEP_ALIVE_TIME).set(keepAlive); | |||
return this; | |||
} | |||
|
|||
public Long keepAliveTime() { | |||
return attributes.attribute(KEEP_ALIVE_TIME).get(); | |||
} | |||
|
|||
public BoundedThreadPoolConfigurationBuilder queueLength(Integer queueLength) { | |||
attributes.attribute(QUEUE_LENGTH).set(queueLength); | |||
return this; | |||
} | |||
|
|||
public Integer queueLength() { | |||
return attributes.attribute(QUEUE_LENGTH).get(); | |||
} | |||
|
|||
public String name() { | |||
return attributes.attribute(NAME).get(); | |||
} | |||
|
|||
@Override | |||
public void validate() { | |||
} | |||
|
|||
@Override | |||
public BoundedThreadPoolConfiguration create() { | |||
return new BoundedThreadPoolConfiguration(attributes.protect()); | |||
} | |||
|
|||
@Override | |||
public BoundedThreadPoolConfigurationBuilder read(BoundedThreadPoolConfiguration template) { | |||
attributes.read(template.attributes()); | |||
return this; | |||
} | |||
|
|||
public String threadFactory() { | |||
return attributes.attribute(THREAD_FACTORY).get(); | |||
} | |||
|
|||
@Override | |||
public String toString() { | |||
return "BoundedThreadPoolConfigurationBuilder{" + | |||
"attributes=" + attributes + | |||
'}'; | |||
} | |||
|
|||
@Override | |||
public ThreadPoolConfiguration asThreadPoolConfigurationBuilder() { | |||
ThreadPoolConfigurationBuilder builder = new ThreadPoolConfigurationBuilder(getGlobalConfig()); | |||
builder.threadPoolFactory(new BlockingThreadPoolExecutorFactory(maxThreads(), coreThreads(), queueLength(), keepAliveTime())); | |||
DefaultThreadFactory threadFactory = getGlobalConfig().threads().getThreadFactory(threadFactory()).create().getThreadFactory(); | |||
builder.threadFactory(threadFactory); | |||
return builder.create(); | |||
} | |||
} |
Oops, something went wrong.