Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ISPN-2226 RemoteCacheStore Configuration #1280

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -0,0 +1,109 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2012 Red Hat Inc. and/or its affiliates and other contributors
* as indicated by the @author tags. All rights reserved.
* See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU Lesser General Public License, v. 2.1.
* This program is distributed in the hope that it will be useful, but WITHOUT A
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public License,
* v.2.1 along with this distribution; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
package org.infinispan.loaders.remote.configuration;

/**
* AbstractRemoteCacheStoreConfigurationChildBuilder.
*
* @author Tristan Tarrant
* @since 5.2
*/
public class AbstractRemoteCacheStoreConfigurationChildBuilder implements RemoteCacheStoreConfigurationChildBuilder {
private final RemoteCacheStoreConfigurationBuilder builder;

protected AbstractRemoteCacheStoreConfigurationChildBuilder(RemoteCacheStoreConfigurationBuilder builder) {
this.builder = builder;
}

@Override
public RemoteServerConfigurationBuilder addServer() {
return builder.addServer();
}

@Override
public ExecutorFactoryConfigurationBuilder asyncExecutorFactory() {
return builder.asyncExecutorFactory();
}

@Override
public RemoteCacheStoreConfigurationBuilder balancingStrategy(String balancingStrategy) {
return builder.balancingStrategy(balancingStrategy);
}

@Override
public ConnectionPoolConfigurationBuilder connectionPool() {
return builder.connectionPool();
}

@Override
public RemoteCacheStoreConfigurationBuilder connectionTimeout(long connectionTimeout) {
return builder.connectionTimeout(connectionTimeout);
}

@Override
public RemoteCacheStoreConfigurationBuilder forceReturnValues(boolean forceReturnValues) {
return builder.forceReturnValues(forceReturnValues);
}

@Override
public RemoteCacheStoreConfigurationBuilder keySizeEstimate(int keySizeEstimate) {
return builder.keySizeEstimate(keySizeEstimate);
}

@Override
public RemoteCacheStoreConfigurationBuilder marshaller(String marshaller) {
return builder.marshaller(marshaller);
}

@Override
public RemoteCacheStoreConfigurationBuilder pingOnStartup(boolean pingOnStartup) {
return builder.pingOnStartup(pingOnStartup);
}

@Override
public RemoteCacheStoreConfigurationBuilder protocolVersion(String protocolVersion) {
return builder.protocolVersion(protocolVersion);
}

@Override
public RemoteCacheStoreConfigurationBuilder remoteCacheName(String remoteCacheName) {
return builder.remoteCacheName(remoteCacheName);
}

@Override
public RemoteCacheStoreConfigurationBuilder socketTimeout(long socketTimeout) {
return builder.socketTimeout(socketTimeout);
}

@Override
public RemoteCacheStoreConfigurationBuilder tcpNoDelay(boolean tcpNoDelay) {
return builder.tcpNoDelay(tcpNoDelay);
}

@Override
public RemoteCacheStoreConfigurationBuilder transportFactory(String transportFactory) {
return builder.transportFactory(transportFactory);
}

@Override
public RemoteCacheStoreConfigurationBuilder valueSizeEstimate(int valueSizeEstimate) {
return builder.valueSizeEstimate(valueSizeEstimate);
}

}
@@ -0,0 +1,91 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2012 Red Hat Inc. and/or its affiliates and other contributors
* as indicated by the @author tags. All rights reserved.
* See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU Lesser General Public License, v. 2.1.
* This program is distributed in the hope that it will be useful, but WITHOUT A
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public License,
* v.2.1 along with this distribution; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
package org.infinispan.loaders.remote.configuration;

import java.util.HashMap;
import java.util.Map;

/**
* Enumerates the attributes used by the Remote cache store configuration
*
* @author Tristan Tarrant
* @since 5.2
*/
public enum Attribute {
// must be first
UNKNOWN(null),

BALANCING_STRATEGY("balancingStrategy"),
CONNECT_TIMEOUT("connectTimeout"),
EXHAUSTED_ACTION("exhaustedAction"),
FACTORY("factory"),
FORCE_RETURN_VALUES("forceReturnValues"),
HOST("host"),
MARSHALLER("marshaller"),
MAX_ACTIVE("maxActive"),
MAX_IDLE("maxIdle"),
MAX_TOTAL("maxTotal"),
MIN_EVICTABLE_IDLE_TIME("minEvictableIdleTime"),
MIN_IDLE("minIdle"),
KEY_SIZE_ESTIMATE("keySizeEstimate"),
PING_ON_STARTUP("pingOnStartup"),
PORT("port"),
PROTOCOL_VERSION("protocolVersion"),
REMOTE_CACHE_NAME("remoteCacheName"),
SOCKET_TIMEOUT("socketTimeout"),
TCP_NO_DELAY("tcpNoDelay"),
TEST_WHILE_IDLE("testWhileIdle"),
TIME_BETWEEN_EVICTION_RUNS("timeBetweenEvictionRuns"),
TRANSPORT_FACTORY("transportFactory"),
VALUE_SIZE_ESTIMATE("valueSizeEstimate"),
;

private final String name;

private Attribute(final String name) {
this.name = name;
}

/**
* Get the local name of this element.
*
* @return the local name
*/
public String getLocalName() {
return name;
}

private static final Map<String, Attribute> attributes;

static {
final Map<String, Attribute> map = new HashMap<String, Attribute>(64);
for (Attribute attribute : values()) {
final String name = attribute.getLocalName();
if (name != null) {
map.put(name, attribute);
}
}
attributes = map;
}

public static Attribute forName(final String localName) {
final Attribute attribute = attributes.get(localName);
return attribute == null ? UNKNOWN : attribute;
}
}
@@ -0,0 +1,83 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2012 Red Hat Inc. and/or its affiliates and other contributors
* as indicated by the @author tags. All rights reserved.
* See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU Lesser General Public License, v. 2.1.
* This program is distributed in the hope that it will be useful, but WITHOUT A
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public License,
* v.2.1 along with this distribution; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
package org.infinispan.loaders.remote.configuration;

public class ConnectionPoolConfiguration {
private final ExhaustedAction exhaustedAction;
private final int maxActive;
private final int maxTotal;
private final int maxIdle;
private final int minIdle;
private final long timeBetweenEvictionRuns;
private final long minEvictableIdleTime;
private final boolean testWhileIdle;

ConnectionPoolConfiguration(ExhaustedAction exhaustedAction, int maxActive, int maxTotal, int maxIdle, int minIdle,
long timeBetweenEvictionRuns, long minEvictableIdleTime, boolean testWhileIdle) {
this.exhaustedAction = exhaustedAction;
this.maxActive = maxActive;
this.maxTotal = maxTotal;
this.maxIdle = maxIdle;
this.minIdle = minIdle;
this.timeBetweenEvictionRuns = timeBetweenEvictionRuns;
this.minEvictableIdleTime = minEvictableIdleTime;
this.testWhileIdle = testWhileIdle;
}

public ExhaustedAction exhaustedAction() {
return exhaustedAction;
}

public int maxActive() {
return maxActive;
}

public int maxTotal() {
return maxTotal;
}

public int maxIdle() {
return maxIdle;
}

public int minIdle() {
return minIdle;
}

public long timeBetweenEvictionRuns() {
return timeBetweenEvictionRuns;
}

public long minEvictableIdleTime() {
return minEvictableIdleTime;
}

public boolean testWhileIdle() {
return testWhileIdle;
}

@Override
public String toString() {
return "ConnectionPoolConfiguration [exhaustedAction=" + exhaustedAction + ", maxActive=" + maxActive
+ ", maxTotal=" + maxTotal + ", maxIdle=" + maxIdle + ", minIdle=" + minIdle + ", timeBetweenEvictionRuns="
+ timeBetweenEvictionRuns + ", minEvictableIdleTime=" + minEvictableIdleTime + ", testWhileIdle="
+ testWhileIdle + "]";
}

}
@@ -0,0 +1,101 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2012 Red Hat Inc. and/or its affiliates and other contributors
* as indicated by the @author tags. All rights reserved.
* See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU Lesser General Public License, v. 2.1.
* This program is distributed in the hope that it will be useful, but WITHOUT A
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public License,
* v.2.1 along with this distribution; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
package org.infinispan.loaders.remote.configuration;

import org.infinispan.configuration.Builder;

public class ConnectionPoolConfigurationBuilder extends AbstractRemoteCacheStoreConfigurationChildBuilder implements
Builder<ConnectionPoolConfiguration> {
private ExhaustedAction exhaustedAction = ExhaustedAction.WAIT;
private int maxActive = -1;
private int maxTotal = -1;
private int maxIdle = -1;
private int minIdle = 1;
private long timeBetweenEvictionRuns = 120000;
private long minEvictableIdleTime = 1800000;
private boolean testWhileIdle = true;

ConnectionPoolConfigurationBuilder(RemoteCacheStoreConfigurationBuilder builder) {
super(builder);
}

public ConnectionPoolConfigurationBuilder exhaustedAction(ExhaustedAction exhaustedAction) {
this.exhaustedAction = exhaustedAction;
return this;
}

public ConnectionPoolConfigurationBuilder maxActive(int maxActive) {
this.maxActive = maxActive;
return this;
}

public ConnectionPoolConfigurationBuilder maxTotal(int maxTotal) {
this.maxTotal = maxTotal;
return this;
}

public ConnectionPoolConfigurationBuilder maxIdle(int maxIdle) {
this.maxIdle = maxIdle;
return this;
}

public ConnectionPoolConfigurationBuilder minIdle(int minIdle) {
this.minIdle = minIdle;
return this;
}

public ConnectionPoolConfigurationBuilder timeBetweenEvictionRuns(long timeBetweenEvictionRuns) {
this.timeBetweenEvictionRuns = timeBetweenEvictionRuns;
return this;
}

public ConnectionPoolConfigurationBuilder minEvictableIdleTime(long minEvictableIdleTime) {
this.minEvictableIdleTime = minEvictableIdleTime;
return this;
}

public ConnectionPoolConfigurationBuilder testWhileIdle(boolean testWhileIdle) {
this.testWhileIdle = testWhileIdle;
return this;
}

@Override
public void validate() {
}

@Override
public ConnectionPoolConfiguration create() {
return new ConnectionPoolConfiguration(exhaustedAction, maxActive, maxTotal, maxIdle, minIdle, timeBetweenEvictionRuns,
minEvictableIdleTime, testWhileIdle);
}

@Override
public ConnectionPoolConfigurationBuilder read(ConnectionPoolConfiguration template) {
exhaustedAction = template.exhaustedAction();
maxActive = template.maxActive();
maxTotal = template.maxTotal();
maxIdle = template.maxIdle();
minIdle = template.minIdle();
timeBetweenEvictionRuns = template.timeBetweenEvictionRuns();
minEvictableIdleTime = template.minEvictableIdleTime();
testWhileIdle = template.testWhileIdle();
return this;
}

}