org.infinispan.configuration.cache.AsyncStoreConfigurationBuilder Maven / Gradle / Ivy
package org.infinispan.configuration.cache;
import static org.infinispan.configuration.cache.AsyncStoreConfiguration.*;
import java.util.concurrent.TimeUnit;
import org.infinispan.commons.configuration.Builder;
import org.infinispan.commons.configuration.attributes.AttributeSet;
import org.infinispan.configuration.global.GlobalConfiguration;
/**
* Configuration for the async cache store. If enabled, this provides you with asynchronous writes
* to the cache store, giving you 'write-behind' caching.
*
* @author pmuir
*
*/
public class AsyncStoreConfigurationBuilder extends AbstractStoreConfigurationChildBuilder implements Builder {
private final AttributeSet attributes;
AsyncStoreConfigurationBuilder(AbstractStoreConfigurationBuilder extends AbstractStoreConfiguration, ?> builder) {
super(builder);
this.attributes = AsyncStoreConfiguration.attributeDefinitionSet();
}
/**
* If true, all modifications to this cache store happen asynchronously, on a separate thread.
*/
public AsyncStoreConfigurationBuilder enable() {
attributes.attribute(ENABLED).set(true);
return this;
}
public AsyncStoreConfigurationBuilder disable() {
attributes.attribute(ENABLED).set(false);
return this;
}
public AsyncStoreConfigurationBuilder enabled(boolean enabled) {
attributes.attribute(ENABLED).set(enabled);
return this;
}
/**
* Unused.
*/
@Deprecated
public AsyncStoreConfigurationBuilder flushLockTimeout(long l) {
return this;
}
/**
* Unused.
*/
@Deprecated
public AsyncStoreConfigurationBuilder flushLockTimeout(long l, TimeUnit unit) {
return this;
}
/**
* Sets the size of the modification queue for the async store. If updates are made at a rate
* that is faster than the underlying cache store can process this queue, then the async store
* behaves like a synchronous store for that period, blocking until the queue can accept more
* elements.
*/
public AsyncStoreConfigurationBuilder modificationQueueSize(int i) {
attributes.attribute(MODIFICATION_QUEUE_SIZE).set(i);
return this;
}
/**
* Unused.
*/
@Deprecated
public AsyncStoreConfigurationBuilder shutdownTimeout(long l) {
return this;
}
/**
* Unused.
*/
@Deprecated
public AsyncStoreConfigurationBuilder shutdownTimeout(long l, TimeUnit unit) {
return this;
}
/**
* Size of the thread pool whose threads are responsible for applying the modifications.
*/
public AsyncStoreConfigurationBuilder threadPoolSize(int i) {
attributes.attribute(THREAD_POOL_SIZE).set(i);
return this;
}
@Override
public
void validate() {
}
@Override
public void validate(GlobalConfiguration globalConfig) {
}
@Override
public AsyncStoreConfiguration create() {
return new AsyncStoreConfiguration(attributes.protect());
}
@Override
public AsyncStoreConfigurationBuilder read(AsyncStoreConfiguration template) {
this.attributes.read(template.attributes());
return this;
}
@Override
public String toString() {
return "AsyncStoreConfigurationBuilder [attributes=" + attributes + "]";
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy