All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.wildfly.swarm.config.infinispan.RemoteCacheContainer Maven / Gradle / Ivy

There is a newer version: 2.7.0
Show newest version
package org.wildfly.swarm.config.infinispan;

import org.wildfly.swarm.config.runtime.AttributeDocumentation;
import org.wildfly.swarm.config.runtime.ResourceDocumentation;
import org.wildfly.swarm.config.runtime.SingletonResource;
import org.wildfly.swarm.config.runtime.Address;
import org.wildfly.swarm.config.runtime.ResourceType;
import java.beans.PropertyChangeSupport;
import java.beans.PropertyChangeListener;
import java.util.List;
import org.wildfly.swarm.config.runtime.Subresource;
import org.wildfly.swarm.config.infinispan.remote_cache_container.RemoteClusterConsumer;
import org.wildfly.swarm.config.infinispan.remote_cache_container.RemoteClusterSupplier;
import org.wildfly.swarm.config.infinispan.remote_cache_container.RemoteCluster;
import org.wildfly.swarm.config.runtime.SubresourceInfo;
import org.wildfly.swarm.config.infinispan.remote_cache_container.SecurityComponent;
import org.wildfly.swarm.config.infinispan.remote_cache_container.SecurityComponentConsumer;
import org.wildfly.swarm.config.infinispan.remote_cache_container.SecurityComponentSupplier;
import org.wildfly.swarm.config.infinispan.remote_cache_container.AsyncThreadPool;
import org.wildfly.swarm.config.infinispan.remote_cache_container.AsyncThreadPoolConsumer;
import org.wildfly.swarm.config.infinispan.remote_cache_container.AsyncThreadPoolSupplier;
import org.wildfly.swarm.config.infinispan.remote_cache_container.ConnectionPoolComponent;
import org.wildfly.swarm.config.infinispan.remote_cache_container.ConnectionPoolComponentConsumer;
import org.wildfly.swarm.config.infinispan.remote_cache_container.ConnectionPoolComponentSupplier;
import org.wildfly.swarm.config.infinispan.remote_cache_container.NoneNearCache;
import org.wildfly.swarm.config.infinispan.remote_cache_container.NoneNearCacheConsumer;
import org.wildfly.swarm.config.infinispan.remote_cache_container.NoneNearCacheSupplier;
import org.wildfly.swarm.config.infinispan.remote_cache_container.InvalidationNearCache;
import org.wildfly.swarm.config.infinispan.remote_cache_container.InvalidationNearCacheConsumer;
import org.wildfly.swarm.config.infinispan.remote_cache_container.InvalidationNearCacheSupplier;
import org.wildfly.swarm.config.runtime.ModelNodeBinding;
import java.util.Arrays;

/**
 * The configuration of a remote infinispan cache container.
 */
@Address("/subsystem=infinispan/remote-cache-container=*")
@ResourceType("remote-cache-container")
public class RemoteCacheContainer>
		implements
			org.wildfly.swarm.config.runtime.Keyed {

	private String key;
	private PropertyChangeSupport pcs;
	private RemoteCacheContainerResources subresources = new RemoteCacheContainerResources();
	@AttributeDocumentation("Defines the maximum socket connect timeout before giving up connecting to the server.")
	private Integer connectionTimeout;
	@AttributeDocumentation("Required default remote server cluster.")
	private String defaultRemoteCluster;
	@AttributeDocumentation("This hint allows sizing of byte buffers when serializing and deserializing keys, to minimize array resizing.")
	private Integer keySizeEstimate;
	@AttributeDocumentation("Sets the maximum number of retries for each request. A valid value should be greater or equals than 0. Zero means no retry will made in case of a network failure.")
	private Integer maxRetries;
	@AttributeDocumentation("Defines the module whose class loader should be used when configuring remote cache container marshaller.")
	private String module;
	@AttributeDocumentation("This property defines the protocol version that this client should use.")
	private ProtocolVersion protocolVersion;
	@AttributeDocumentation("Enable or disable SO_TIMEOUT on socket connections to remote Hot Rod servers with the specified timeout, in milliseconds. A timeout of 0 is interpreted as an infinite timeout.")
	private Integer socketTimeout;
	@AttributeDocumentation("Configures TCP Keepalive on the TCP stack.")
	private Boolean tcpKeepAlive;
	@AttributeDocumentation("Enable or disable TCP_NODELAY on socket connections to remote Hot Rod servers.")
	private Boolean tcpNoDelay;
	@AttributeDocumentation("This hint allows sizing of byte buffers when serializing and deserializing values, to minimize array resizing.")
	private Integer valueSizeEstimate;

	public RemoteCacheContainer(java.lang.String key) {
		super();
		this.key = key;
	}

	public String getKey() {
		return this.key;
	}

	/**
	 * Adds a property change listener
	 */
	public void addPropertyChangeListener(PropertyChangeListener listener) {
		if (null == this.pcs)
			this.pcs = new PropertyChangeSupport(this);
		this.pcs.addPropertyChangeListener(listener);
	}

	/**
	 * Removes a property change listener
	 */
	public void removePropertyChangeListener(
			java.beans.PropertyChangeListener listener) {
		if (this.pcs != null)
			this.pcs.removePropertyChangeListener(listener);
	}

	public RemoteCacheContainerResources subresources() {
		return this.subresources;
	}

	/**
	 * Add all RemoteCluster objects to this subresource
	 * 
	 * @return this
	 * @param value
	 *            List of RemoteCluster objects.
	 */
	@SuppressWarnings("unchecked")
	public T remoteClusters(java.util.List value) {
		this.subresources.remoteClusters = value;
		return (T) this;
	}

	/**
	 * Add the RemoteCluster object to the list of subresources
	 * 
	 * @param value
	 *            The RemoteCluster to add
	 * @return this
	 */
	@SuppressWarnings("unchecked")
	public T remoteCluster(RemoteCluster value) {
		this.subresources.remoteClusters.add(value);
		return (T) this;
	}

	/**
	 * Create and configure a RemoteCluster object to the list of subresources
	 * 
	 * @param key
	 *            The key for the RemoteCluster resource
	 * @param config
	 *            The RemoteClusterConsumer to use
	 * @return this
	 */
	@SuppressWarnings("unchecked")
	public T remoteCluster(java.lang.String childKey,
			RemoteClusterConsumer consumer) {
		RemoteCluster child = new RemoteCluster<>(
				childKey);
		if (consumer != null) {
			consumer.accept(child);
		}
		remoteCluster(child);
		return (T) this;
	}

	/**
	 * Create and configure a RemoteCluster object to the list of subresources
	 * 
	 * @param key
	 *            The key for the RemoteCluster resource
	 * @return this
	 */
	@SuppressWarnings("unchecked")
	public T remoteCluster(java.lang.String childKey) {
		remoteCluster(childKey, null);
		return (T) this;
	}

	/**
	 * Install a supplied RemoteCluster object to the list of subresources
	 */
	@SuppressWarnings("unchecked")
	public T remoteCluster(RemoteClusterSupplier supplier) {
		remoteCluster(supplier.get());
		return (T) this;
	}

	/**
	 * Security configuration.
	 */
	@SuppressWarnings("unchecked")
	public T securityComponent(SecurityComponent value) {
		this.subresources.securityComponent = value;
		return (T) this;
	}

	/**
	 * Security configuration.
	 */
	@SuppressWarnings("unchecked")
	public T securityComponent(SecurityComponentConsumer consumer) {
		SecurityComponent child = new SecurityComponent<>();
		if (consumer != null) {
			consumer.accept(child);
		}
		this.subresources.securityComponent = child;
		return (T) this;
	}

	/**
	 * Security configuration.
	 */
	@SuppressWarnings("unchecked")
	public T securityComponent() {
		SecurityComponent child = new SecurityComponent<>();
		this.subresources.securityComponent = child;
		return (T) this;
	}

	/**
	 * Security configuration.
	 */
	@SuppressWarnings("unchecked")
	public T securityComponent(SecurityComponentSupplier supplier) {
		this.subresources.securityComponent = supplier.get();
		return (T) this;
	}

	/**
	 * Defines a thread pool used for asynchronous operations.
	 */
	@SuppressWarnings("unchecked")
	public T asyncThreadPool(AsyncThreadPool value) {
		this.subresources.asyncThreadPool = value;
		return (T) this;
	}

	/**
	 * Defines a thread pool used for asynchronous operations.
	 */
	@SuppressWarnings("unchecked")
	public T asyncThreadPool(AsyncThreadPoolConsumer consumer) {
		AsyncThreadPool child = new AsyncThreadPool<>();
		if (consumer != null) {
			consumer.accept(child);
		}
		this.subresources.asyncThreadPool = child;
		return (T) this;
	}

	/**
	 * Defines a thread pool used for asynchronous operations.
	 */
	@SuppressWarnings("unchecked")
	public T asyncThreadPool() {
		AsyncThreadPool child = new AsyncThreadPool<>();
		this.subresources.asyncThreadPool = child;
		return (T) this;
	}

	/**
	 * Defines a thread pool used for asynchronous operations.
	 */
	@SuppressWarnings("unchecked")
	public T asyncThreadPool(AsyncThreadPoolSupplier supplier) {
		this.subresources.asyncThreadPool = supplier.get();
		return (T) this;
	}

	/**
	 * Configuration of the connection pool.
	 */
	@SuppressWarnings("unchecked")
	public T connectionPoolComponent(ConnectionPoolComponent value) {
		this.subresources.connectionPoolComponent = value;
		return (T) this;
	}

	/**
	 * Configuration of the connection pool.
	 */
	@SuppressWarnings("unchecked")
	public T connectionPoolComponent(ConnectionPoolComponentConsumer consumer) {
		ConnectionPoolComponent child = new ConnectionPoolComponent<>();
		if (consumer != null) {
			consumer.accept(child);
		}
		this.subresources.connectionPoolComponent = child;
		return (T) this;
	}

	/**
	 * Configuration of the connection pool.
	 */
	@SuppressWarnings("unchecked")
	public T connectionPoolComponent() {
		ConnectionPoolComponent child = new ConnectionPoolComponent<>();
		this.subresources.connectionPoolComponent = child;
		return (T) this;
	}

	/**
	 * Configuration of the connection pool.
	 */
	@SuppressWarnings("unchecked")
	public T connectionPoolComponent(ConnectionPoolComponentSupplier supplier) {
		this.subresources.connectionPoolComponent = supplier.get();
		return (T) this;
	}

	/**
	 * Disables near cache.
	 */
	@SuppressWarnings("unchecked")
	public T noneNearCache(NoneNearCache value) {
		this.subresources.noneNearCache = value;
		return (T) this;
	}

	/**
	 * Disables near cache.
	 */
	@SuppressWarnings("unchecked")
	public T noneNearCache(NoneNearCacheConsumer consumer) {
		NoneNearCache child = new NoneNearCache<>();
		if (consumer != null) {
			consumer.accept(child);
		}
		this.subresources.noneNearCache = child;
		return (T) this;
	}

	/**
	 * Disables near cache.
	 */
	@SuppressWarnings("unchecked")
	public T noneNearCache() {
		NoneNearCache child = new NoneNearCache<>();
		this.subresources.noneNearCache = child;
		return (T) this;
	}

	/**
	 * Disables near cache.
	 */
	@SuppressWarnings("unchecked")
	public T noneNearCache(NoneNearCacheSupplier supplier) {
		this.subresources.noneNearCache = supplier.get();
		return (T) this;
	}

	/**
	 * Configures using near cache in invalidated mode. When entries are updated
	 * or removed server-side, invalidation messages will be sent to clients to
	 * remove them from the near cache.
	 */
	@SuppressWarnings("unchecked")
	public T invalidationNearCache(InvalidationNearCache value) {
		this.subresources.invalidationNearCache = value;
		return (T) this;
	}

	/**
	 * Configures using near cache in invalidated mode. When entries are updated
	 * or removed server-side, invalidation messages will be sent to clients to
	 * remove them from the near cache.
	 */
	@SuppressWarnings("unchecked")
	public T invalidationNearCache(InvalidationNearCacheConsumer consumer) {
		InvalidationNearCache child = new InvalidationNearCache<>();
		if (consumer != null) {
			consumer.accept(child);
		}
		this.subresources.invalidationNearCache = child;
		return (T) this;
	}

	/**
	 * Configures using near cache in invalidated mode. When entries are updated
	 * or removed server-side, invalidation messages will be sent to clients to
	 * remove them from the near cache.
	 */
	@SuppressWarnings("unchecked")
	public T invalidationNearCache() {
		InvalidationNearCache child = new InvalidationNearCache<>();
		this.subresources.invalidationNearCache = child;
		return (T) this;
	}

	/**
	 * Configures using near cache in invalidated mode. When entries are updated
	 * or removed server-side, invalidation messages will be sent to clients to
	 * remove them from the near cache.
	 */
	@SuppressWarnings("unchecked")
	public T invalidationNearCache(InvalidationNearCacheSupplier supplier) {
		this.subresources.invalidationNearCache = supplier.get();
		return (T) this;
	}

	/**
	 * Child mutators for RemoteCacheContainer
	 */
	public static class RemoteCacheContainerResources {
		/**
		 * Configuration of a remote cluster.
		 */
		@ResourceDocumentation("Configuration of a remote cluster.")
		@SubresourceInfo("remoteCluster")
		private List remoteClusters = new java.util.ArrayList<>();
		@SingletonResource
		@ResourceDocumentation("Security configuration.")
		private SecurityComponent securityComponent;
		@SingletonResource
		@ResourceDocumentation("Defines a thread pool used for asynchronous operations.")
		private AsyncThreadPool asyncThreadPool;
		@SingletonResource
		@ResourceDocumentation("Configuration of the connection pool.")
		private ConnectionPoolComponent connectionPoolComponent;
		@SingletonResource
		@ResourceDocumentation("Disables near cache.")
		private NoneNearCache noneNearCache;
		@SingletonResource
		@ResourceDocumentation("Configures using near cache in invalidated mode. When entries are updated or removed server-side, invalidation messages will be sent to clients to remove them from the near cache.")
		private InvalidationNearCache invalidationNearCache;

		/**
		 * Get the list of RemoteCluster resources
		 * 
		 * @return the list of resources
		 */
		@Subresource
		public List remoteClusters() {
			return this.remoteClusters;
		}

		public RemoteCluster remoteCluster(java.lang.String key) {
			return this.remoteClusters.stream()
					.filter(e -> e.getKey().equals(key)).findFirst()
					.orElse(null);
		}
		/**
		 * Security configuration.
		 */
		@Subresource
		public SecurityComponent securityComponent() {
			return this.securityComponent;
		}

		/**
		 * Defines a thread pool used for asynchronous operations.
		 */
		@Subresource
		public AsyncThreadPool asyncThreadPool() {
			return this.asyncThreadPool;
		}

		/**
		 * Configuration of the connection pool.
		 */
		@Subresource
		public ConnectionPoolComponent connectionPoolComponent() {
			return this.connectionPoolComponent;
		}

		/**
		 * Disables near cache.
		 */
		@Subresource
		public NoneNearCache noneNearCache() {
			return this.noneNearCache;
		}

		/**
		 * Configures using near cache in invalidated mode. When entries are
		 * updated or removed server-side, invalidation messages will be sent to
		 * clients to remove them from the near cache.
		 */
		@Subresource
		public InvalidationNearCache invalidationNearCache() {
			return this.invalidationNearCache;
		}
	}

	public static enum ProtocolVersion {
		ONE_0("1.0"), ONE_1("1.1"), ONE_2("1.2"), ONE_3("1.3"), TWO_0("2.0"), TWO_1(
				"2.1"), TWO_2("2.2"), TWO_3("2.3"), TWO_4("2.4"), TWO_5("2.5"), TWO_6(
				"2.6"), TWO_7("2.7"), TWO_8("2.8");
		private final String allowedValue;

		/**
		 * Returns the allowed value for the management model.
		 * 
		 * @return the allowed model value
		 */
		public String getAllowedValue() {
			return allowedValue;
		}

		ProtocolVersion(java.lang.String allowedValue) {
			this.allowedValue = allowedValue;
		}

		@Override
		public String toString() {
			return allowedValue;
		}
	}

	/**
	 * Defines the maximum socket connect timeout before giving up connecting to
	 * the server.
	 */
	@ModelNodeBinding(detypedName = "connection-timeout")
	public Integer connectionTimeout() {
		return this.connectionTimeout;
	}

	/**
	 * Defines the maximum socket connect timeout before giving up connecting to
	 * the server.
	 */
	@SuppressWarnings("unchecked")
	public T connectionTimeout(java.lang.Integer value) {
		Object oldValue = this.connectionTimeout;
		this.connectionTimeout = value;
		if (this.pcs != null)
			this.pcs.firePropertyChange("connectionTimeout", oldValue, value);
		return (T) this;
	}

	/**
	 * Required default remote server cluster.
	 */
	@ModelNodeBinding(detypedName = "default-remote-cluster")
	public String defaultRemoteCluster() {
		return this.defaultRemoteCluster;
	}

	/**
	 * Required default remote server cluster.
	 */
	@SuppressWarnings("unchecked")
	public T defaultRemoteCluster(java.lang.String value) {
		Object oldValue = this.defaultRemoteCluster;
		this.defaultRemoteCluster = value;
		if (this.pcs != null)
			this.pcs.firePropertyChange("defaultRemoteCluster", oldValue, value);
		return (T) this;
	}

	/**
	 * This hint allows sizing of byte buffers when serializing and
	 * deserializing keys, to minimize array resizing.
	 */
	@ModelNodeBinding(detypedName = "key-size-estimate")
	public Integer keySizeEstimate() {
		return this.keySizeEstimate;
	}

	/**
	 * This hint allows sizing of byte buffers when serializing and
	 * deserializing keys, to minimize array resizing.
	 */
	@SuppressWarnings("unchecked")
	public T keySizeEstimate(java.lang.Integer value) {
		Object oldValue = this.keySizeEstimate;
		this.keySizeEstimate = value;
		if (this.pcs != null)
			this.pcs.firePropertyChange("keySizeEstimate", oldValue, value);
		return (T) this;
	}

	/**
	 * Sets the maximum number of retries for each request. A valid value should
	 * be greater or equals than 0. Zero means no retry will made in case of a
	 * network failure.
	 */
	@ModelNodeBinding(detypedName = "max-retries")
	public Integer maxRetries() {
		return this.maxRetries;
	}

	/**
	 * Sets the maximum number of retries for each request. A valid value should
	 * be greater or equals than 0. Zero means no retry will made in case of a
	 * network failure.
	 */
	@SuppressWarnings("unchecked")
	public T maxRetries(java.lang.Integer value) {
		Object oldValue = this.maxRetries;
		this.maxRetries = value;
		if (this.pcs != null)
			this.pcs.firePropertyChange("maxRetries", oldValue, value);
		return (T) this;
	}

	/**
	 * Defines the module whose class loader should be used when configuring
	 * remote cache container marshaller.
	 */
	@ModelNodeBinding(detypedName = "module")
	public String module() {
		return this.module;
	}

	/**
	 * Defines the module whose class loader should be used when configuring
	 * remote cache container marshaller.
	 */
	@SuppressWarnings("unchecked")
	public T module(java.lang.String value) {
		Object oldValue = this.module;
		this.module = value;
		if (this.pcs != null)
			this.pcs.firePropertyChange("module", oldValue, value);
		return (T) this;
	}

	/**
	 * This property defines the protocol version that this client should use.
	 */
	@ModelNodeBinding(detypedName = "protocol-version")
	public ProtocolVersion protocolVersion() {
		return this.protocolVersion;
	}

	/**
	 * This property defines the protocol version that this client should use.
	 */
	@SuppressWarnings("unchecked")
	public T protocolVersion(ProtocolVersion value) {
		Object oldValue = this.protocolVersion;
		this.protocolVersion = value;
		if (this.pcs != null)
			this.pcs.firePropertyChange("protocolVersion", oldValue, value);
		return (T) this;
	}

	/**
	 * Enable or disable SO_TIMEOUT on socket connections to remote Hot Rod
	 * servers with the specified timeout, in milliseconds. A timeout of 0 is
	 * interpreted as an infinite timeout.
	 */
	@ModelNodeBinding(detypedName = "socket-timeout")
	public Integer socketTimeout() {
		return this.socketTimeout;
	}

	/**
	 * Enable or disable SO_TIMEOUT on socket connections to remote Hot Rod
	 * servers with the specified timeout, in milliseconds. A timeout of 0 is
	 * interpreted as an infinite timeout.
	 */
	@SuppressWarnings("unchecked")
	public T socketTimeout(java.lang.Integer value) {
		Object oldValue = this.socketTimeout;
		this.socketTimeout = value;
		if (this.pcs != null)
			this.pcs.firePropertyChange("socketTimeout", oldValue, value);
		return (T) this;
	}

	/**
	 * Configures TCP Keepalive on the TCP stack.
	 */
	@ModelNodeBinding(detypedName = "tcp-keep-alive")
	public Boolean tcpKeepAlive() {
		return this.tcpKeepAlive;
	}

	/**
	 * Configures TCP Keepalive on the TCP stack.
	 */
	@SuppressWarnings("unchecked")
	public T tcpKeepAlive(java.lang.Boolean value) {
		Object oldValue = this.tcpKeepAlive;
		this.tcpKeepAlive = value;
		if (this.pcs != null)
			this.pcs.firePropertyChange("tcpKeepAlive", oldValue, value);
		return (T) this;
	}

	/**
	 * Enable or disable TCP_NODELAY on socket connections to remote Hot Rod
	 * servers.
	 */
	@ModelNodeBinding(detypedName = "tcp-no-delay")
	public Boolean tcpNoDelay() {
		return this.tcpNoDelay;
	}

	/**
	 * Enable or disable TCP_NODELAY on socket connections to remote Hot Rod
	 * servers.
	 */
	@SuppressWarnings("unchecked")
	public T tcpNoDelay(java.lang.Boolean value) {
		Object oldValue = this.tcpNoDelay;
		this.tcpNoDelay = value;
		if (this.pcs != null)
			this.pcs.firePropertyChange("tcpNoDelay", oldValue, value);
		return (T) this;
	}

	/**
	 * This hint allows sizing of byte buffers when serializing and
	 * deserializing values, to minimize array resizing.
	 */
	@ModelNodeBinding(detypedName = "value-size-estimate")
	public Integer valueSizeEstimate() {
		return this.valueSizeEstimate;
	}

	/**
	 * This hint allows sizing of byte buffers when serializing and
	 * deserializing values, to minimize array resizing.
	 */
	@SuppressWarnings("unchecked")
	public T valueSizeEstimate(java.lang.Integer value) {
		Object oldValue = this.valueSizeEstimate;
		this.valueSizeEstimate = value;
		if (this.pcs != null)
			this.pcs.firePropertyChange("valueSizeEstimate", oldValue, value);
		return (T) this;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy