SGF-734 - Upgrade to Pivotal GemFire 9.4.

This commit is contained in:
John Blum
2018-04-10 15:32:41 -07:00
parent 1113a1d0e4
commit cb74e3909d
32 changed files with 250 additions and 128 deletions

View File

@@ -205,6 +205,7 @@ public abstract class RegionLookupFactoryBean<K, V> extends AbstractFactoryBeanS
}
/**
>>>>>>> SGF-734 - Upgrade to Pivotal GemFire 9.4.
* Returns a reference to the {@link GemFireCache} used to create the {@link Region}.
*
* @return a reference to the {@link GemFireCache} used to create the {@link Region}..

View File

@@ -78,7 +78,6 @@ public abstract class PoolAdapter implements Pool {
throw new UnsupportedOperationException(NOT_IMPLEMENTED);
}
@Override
public List<InetSocketAddress> getOnlineLocators() {
throw new UnsupportedOperationException(NOT_IMPLEMENTED);
}
@@ -143,6 +142,10 @@ public abstract class PoolAdapter implements Pool {
throw new UnsupportedOperationException(NOT_IMPLEMENTED);
}
public int getSubscriptionTimeoutMultiplier() {
throw new UnsupportedOperationException(NOT_IMPLEMENTED);
}
public boolean getThreadLocalConnections() {
throw new UnsupportedOperationException(NOT_IMPLEMENTED);
}

View File

@@ -98,6 +98,7 @@ public class PoolFactoryBean extends AbstractFactoryBeanSupport<Pool> implements
private int subscriptionAckInterval = PoolFactory.DEFAULT_SUBSCRIPTION_ACK_INTERVAL;
private int subscriptionMessageTrackingTimeout = PoolFactory.DEFAULT_SUBSCRIPTION_MESSAGE_TRACKING_TIMEOUT;
private int subscriptionRedundancy = PoolFactory.DEFAULT_SUBSCRIPTION_REDUNDANCY;
private int subscriptionTimeoutMultiplier = PoolFactory.DEFAULT_SUBSCRIPTION_TIMEOUT_MULTIPLIER;
private long idleTimeout = PoolFactory.DEFAULT_IDLE_TIMEOUT;
private long pingInterval = PoolFactory.DEFAULT_PING_INTERVAL;
@@ -124,16 +125,18 @@ public class PoolFactoryBean extends AbstractFactoryBeanSupport<Pool> implements
* @see org.apache.geode.cache.client.PoolManager
* @see org.apache.geode.cache.client.PoolFactory
* @see org.apache.geode.cache.client.Pool
* @see #resolvePoolName()
*/
@Override
public void afterPropertiesSet() throws Exception {
init(Optional.ofNullable(find(resolvePoolName())));
}
Pool existingPool = find(resolvePoolName());
@SuppressWarnings("all")
private void init(Optional<Pool> existingPool) {
if (existingPool != null) {
if (existingPool.isPresent()) {
this.pool = existingPool;
this.pool = existingPool.get();
this.springManagedPool = false;
logDebug(() -> String.format("A Pool with name [%s] already exists; Using existing Pool",
@@ -308,6 +311,7 @@ public class PoolFactoryBean extends AbstractFactoryBeanSupport<Pool> implements
it.setSubscriptionEnabled(this.subscriptionEnabled);
it.setSubscriptionMessageTrackingTimeout(this.subscriptionMessageTrackingTimeout);
it.setSubscriptionRedundancy(this.subscriptionRedundancy);
it.setSubscriptionTimeoutMultiplier(this.subscriptionTimeoutMultiplier);
it.setThreadLocalConnections(this.threadLocalConnections);
nullSafeCollection(this.locators).forEach(locator ->
@@ -564,6 +568,11 @@ public class PoolFactoryBean extends AbstractFactoryBeanSupport<Pool> implements
return PoolFactoryBean.this.subscriptionRedundancy;
}
@Override
public int getSubscriptionTimeoutMultiplier() {
return PoolFactoryBean.this.subscriptionTimeoutMultiplier;
}
@Override
public boolean getThreadLocalConnections() {
return PoolFactoryBean.this.threadLocalConnections;
@@ -737,21 +746,19 @@ public class PoolFactoryBean extends AbstractFactoryBeanSupport<Pool> implements
this.subscriptionRedundancy = subscriptionRedundancy;
}
public void setSubscriptionTimeoutMultiplier(int subscriptionTimeoutMultiplier) {
this.subscriptionTimeoutMultiplier = subscriptionTimeoutMultiplier;
}
public void setThreadLocalConnections(boolean threadLocalConnections) {
this.threadLocalConnections = threadLocalConnections;
}
/*
* (non-Javadoc)
* internal framework use only
*/
// Internal framework use only.
public final void setLocatorsConfiguration(Object locatorsConfiguration) {
}
/*
* (non-Javadoc)
* internal framework use only
*/
// Internal framework use only.
public final void setServersConfiguration(Object serversConfiguration) {
}
@@ -771,5 +778,6 @@ public class PoolFactoryBean extends AbstractFactoryBeanSupport<Pool> implements
* @see org.apache.geode.cache.client.PoolFactory
*/
PoolFactory initialize(PoolFactory poolFactory);
}
}

View File

@@ -196,6 +196,11 @@ public abstract class DefaultableDelegatingPoolAdapter {
return defaultIfNull(defaultSubscriptionRedundancy, () -> getDelegate().getSubscriptionRedundancy());
}
public int getSubscriptionTimeoutMultiplier(Integer defaultSubscriptionTimeoutMultiplier) {
return defaultIfNull(defaultSubscriptionTimeoutMultiplier,
() -> getDelegate().getSubscriptionTimeoutMultiplier());
}
public boolean getThreadLocalConnections(Boolean defaultThreadLocalConnections) {
return defaultIfNull(defaultThreadLocalConnections, () -> getDelegate().getThreadLocalConnections());
}
@@ -204,7 +209,7 @@ public abstract class DefaultableDelegatingPoolAdapter {
getDelegate().destroy();
}
public void destroy(boolean keepAlive) {
public void destroy(final boolean keepAlive) {
getDelegate().destroy(keepAlive);
}
@@ -218,4 +223,8 @@ public abstract class DefaultableDelegatingPoolAdapter {
PREFER_POOL
}
interface ValueProvider<T> {
T getValue();
}
}

View File

@@ -258,6 +258,12 @@ public abstract class DelegatingPoolAdapter extends FactoryDefaultsPoolAdapter {
.orElseGet(super::getSubscriptionRedundancy);
}
@Override
public int getSubscriptionTimeoutMultiplier() {
return Optional.ofNullable(getDelegate()).map(Pool::getSubscriptionTimeoutMultiplier)
.orElseGet(super::getSubscriptionTimeoutMultiplier);
}
@Override
public boolean getThreadLocalConnections() {

View File

@@ -161,6 +161,11 @@ public abstract class FactoryDefaultsPoolAdapter extends PoolAdapter {
return PoolFactory.DEFAULT_SUBSCRIPTION_REDUNDANCY;
}
@Override
public int getSubscriptionTimeoutMultiplier() {
return PoolFactory.DEFAULT_SUBSCRIPTION_TIMEOUT_MULTIPLIER;
}
@Override
public boolean getThreadLocalConnections() {
return PoolFactory.DEFAULT_THREAD_LOCAL_CONNECTIONS;

View File

@@ -49,8 +49,8 @@ class LocalRegionParser extends AbstractRegionParser {
validateDataPolicyShortcutAttributesMutualExclusion(element, parserContext);
BeanDefinitionBuilder regionAttributesBuilder = BeanDefinitionBuilder.genericBeanDefinition(
RegionAttributesFactoryBean.class);
BeanDefinitionBuilder regionAttributesBuilder =
BeanDefinitionBuilder.genericBeanDefinition(RegionAttributesFactoryBean.class);
doParseRegionConfiguration(element, parserContext, builder, regionAttributesBuilder, subRegion);

View File

@@ -123,6 +123,7 @@ class PoolParser extends AbstractSingleBeanDefinitionParser {
ParsingUtils.setPropertyValue(element, poolBuilder, "subscription-enabled");
ParsingUtils.setPropertyValue(element, poolBuilder, "subscription-message-tracking-timeout");
ParsingUtils.setPropertyValue(element, poolBuilder, "subscription-redundancy");
ParsingUtils.setPropertyValue(element, poolBuilder, "subscription-timeout-multiplier");
ParsingUtils.setPropertyValue(element, poolBuilder, "thread-local-connections");
List<Element> childElements = DomUtils.getChildElements(element);

View File

@@ -33,6 +33,7 @@ import org.springframework.util.Assert;
* @author David Turanski
* @author John Blum
*/
@SuppressWarnings("unused")
abstract class AbstractFunctionExecution {
private final static String NO_RESULT_MESSAGE = "Cannot return any result as the Function#hasResult() is false";
@@ -60,14 +61,13 @@ abstract class AbstractFunctionExecution {
public AbstractFunctionExecution(String functionId, Object... args) {
Assert.hasText(functionId, "FunctionId cannot be null or empty");
Assert.hasText(functionId, "Function ID must not be null or empty");
this.functionId = functionId;
this.args = args;
}
AbstractFunctionExecution() {
}
AbstractFunctionExecution() { }
Object[] getArgs() {
return this.args;

View File

@@ -15,10 +15,16 @@ package org.springframework.data.gemfire.function.execution;
import org.apache.geode.cache.RegionService;
import org.apache.geode.cache.client.Pool;
import org.apache.geode.cache.execute.Execution;
import org.apache.geode.cache.execute.Function;
/**
* Creates an {@literal OnServer} {@link Function} {@link Execution} initialized with
* either {@link RegionService cache} or {@link Pool}.
*
* @author David Turanski
* @author John Blum
* @see org.springframework.data.gemfire.function.execution.AbstractFunctionTemplate
*/
public class GemfireOnServerFunctionTemplate extends AbstractFunctionTemplate {
@@ -37,7 +43,6 @@ public class GemfireOnServerFunctionTemplate extends AbstractFunctionTemplate {
@Override
protected AbstractFunctionExecution getFunctionExecution() {
return (pool != null ? new PoolServerFunctionExecution(this.pool) : new ServerFunctionExecution(this.cache));
return pool != null ? new PoolServerFunctionExecution(this.pool) : new ServerFunctionExecution(this.cache);
}
}

View File

@@ -20,47 +20,58 @@ import org.springframework.beans.factory.InitializingBean;
import org.springframework.util.Assert;
/**
* Creates a GemFire {@link Execution} using {code}FunctionService.onServer(Pool pool){code}
* @author David Turanski
* Creates an {@link Execution} from {@link FunctionService#onServer(Pool)}.
*
* @author David Turanski
* @author John Blum
* @see org.springframework.beans.factory.InitializingBean
* @see org.springframework.data.gemfire.function.execution.AbstractFunctionExecution
*/
class PoolServerFunctionExecution extends AbstractFunctionExecution implements InitializingBean {
private Pool pool;
private String poolname;
private String poolName;
/**
* @param pool the {@link Pool}
* Constructs a new instance of {@link PoolServerFunctionExecution} initialized with the given {@link Pool}.
*
* @param pool {@link Pool} used to initialize the {@link Execution}.
* @throws IllegalArgumentException if {@link Pool} is {@literal null}.
* @see org.apache.geode.cache.client.Pool
*/
public PoolServerFunctionExecution(Pool pool) {
super();
Assert.notNull(pool, "pool cannot be null");
Assert.notNull(pool, "Pool must not be null");
this.pool = pool;
}
public PoolServerFunctionExecution(String poolname) {
super();
Assert.notNull(poolname, "pool name cannot be null");
this.poolname = poolname;
/**
* Constructs a new instance of {@link PoolServerFunctionExecution} initialized with
* the given {@link String name} of the {@link Pool}.
*
* @param poolName {@link String} containing the name of the {@link Pool}
* used to initialize the {@link Execution}.
* @throws IllegalArgumentException if {@link String poolName} is {@literal null} or empty.
*/
public PoolServerFunctionExecution(String poolName) {
Assert.hasText(poolName, "Pool name must not be null or empty");
this.poolName = poolName;
}
@Override
protected Execution getExecution() {
return FunctionService.onServer(this.pool);
}
/* (non-Javadoc)
* @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
*/
@Override
public void afterPropertiesSet() throws Exception {
this.pool = PoolManager.find(poolname);
Assert.notNull(pool," pool " + poolname+ " does not exist");
this.pool = PoolManager.find(this.poolName);
Assert.notNull(this.pool,String.format("Pool [%s] not found", this.poolName));
}
}

View File

@@ -2666,6 +2666,7 @@ Comma-delimited list of Server endpoints used by this Pool in the form of: host1
<xsd:attribute name="subscription-enabled" type="xsd:string" use="optional"/>
<xsd:attribute name="subscription-message-tracking-timeout" type="xsd:string" use="optional"/>
<xsd:attribute name="subscription-redundancy" type="xsd:string" use="optional"/>
<xsd:attribute name="subscription-timeout-multiplier" type="xsd:string" use="optional"/>
<xsd:attribute name="thread-local-connections" type="xsd:string" use="optional"/>
</xsd:complexType>
</xsd:element>