SGF-398 - Provide early support of Apache Geode (Pivotal GemFire OSS).

Source compilation and resource processing build step complete.
This commit is contained in:
John Blum
2015-04-27 11:47:46 -07:00
parent d6dc23a440
commit 8c2d01262a
26 changed files with 52 additions and 1926 deletions

View File

@@ -20,6 +20,7 @@ description = 'Spring Data GemFire'
group = 'org.springframework.data'
repositories {
mavenLocal()
maven { url "https://repo.spring.io/libs-snapshot" }
maven { url "https://repo.spring.io/plugins-release"}
}
@@ -71,7 +72,10 @@ dependencies {
}
// GemFire
compile("com.gemstone.gemfire:gemfire:$gemfireVersion")
compile("com.gemstone.gemfire:gemfire-core:$gemfireVersion")
compile("com.gemstone.gemfire:gemfire-jgroups:$gemfireVersion")
compile("com.gemstone.gemfire:gemfire-joptsimple:$gemfireVersion")
compile("com.gemstone.gemfire:gemfire-json:$gemfireVersion")
optional("com.google.code.findbugs:annotations:2.0.2")
runtime("antlr:antlr:$antlrVersion")

View File

@@ -1,6 +1,6 @@
antlrVersion=2.7.7
aspectjVersion=1.8.5
gemfireVersion=8.1.0
gemfireVersion=1.0.0.0-SNAPSHOT
hamcrestVersion=1.3
jacksonVersion=2.5.1
junitVersion=4.12

View File

@@ -71,7 +71,6 @@ public abstract class RegionFactoryBean<K, V> extends RegionLookupFactoryBean<K,
private boolean destroy = false;
private boolean running;
private Boolean enableGateway;
private Boolean persistent;
private CacheListener<K, V>[] cacheListeners;
@@ -94,7 +93,6 @@ public abstract class RegionFactoryBean<K, V> extends RegionLookupFactoryBean<K,
private Scope scope;
private String diskStoreName;
private String hubId;
@Override
public void afterPropertiesSet() throws Exception {
@@ -112,23 +110,7 @@ public abstract class RegionFactoryBean<K, V> extends RegionLookupFactoryBean<K,
RegionFactory<K, V> regionFactory = createRegionFactory(cache);
if (hubId != null) {
enableGateway = (enableGateway == null || enableGateway);
Assert.isTrue(enableGateway, "The 'hubId' requires the 'enableGateway' property to be true.");
regionFactory.setGatewayHubId(hubId);
}
if (enableGateway != null) {
if (enableGateway) {
Assert.notNull(hubId, "The 'enableGateway' property requires the 'hubId' property to be set.");
}
regionFactory.setEnableGateway(enableGateway);
}
if (!ObjectUtils.isEmpty(gatewaySenders)) {
Assert.isTrue(hubId == null, "It is invalid to configure a region with both a hubId and gatewaySenders."
+ " Note that the enableGateway and hubId properties are deprecated since Gemfire 7.0");
for (Object gatewaySender : gatewaySenders) {
regionFactory.addGatewaySenderId(((GatewaySender) gatewaySender).getId());
}
@@ -666,10 +648,6 @@ public abstract class RegionFactoryBean<K, V> extends RegionLookupFactoryBean<K,
this.diskStoreName = diskStoreName;
}
public void setEnableGateway(boolean enableGateway) {
this.enableGateway = enableGateway;
}
/**
*
* @param gatewaySenders defined as Object for backward compatibility with
@@ -679,10 +657,6 @@ public abstract class RegionFactoryBean<K, V> extends RegionLookupFactoryBean<K,
this.gatewaySenders = gatewaySenders;
}
public void setHubId(String hubId) {
this.hubId = hubId;
}
public void setPersistent(Boolean persistent) {
this.persistent = persistent;
}

View File

@@ -33,15 +33,13 @@ import org.springframework.data.gemfire.client.InterestResultPolicyConverter;
import org.springframework.data.gemfire.server.SubscriptionEvictionPolicy;
import org.springframework.data.gemfire.server.SubscriptionEvictionPolicyConverter;
import org.springframework.data.gemfire.wan.OrderPolicyConverter;
import org.springframework.data.gemfire.wan.StartupPolicyConverter;
import org.springframework.data.gemfire.wan.StartupPolicyType;
import com.gemstone.gemfire.cache.EvictionAction;
import com.gemstone.gemfire.cache.ExpirationAction;
import com.gemstone.gemfire.cache.InterestPolicy;
import com.gemstone.gemfire.cache.InterestResultPolicy;
import com.gemstone.gemfire.cache.Scope;
import com.gemstone.gemfire.cache.util.Gateway;
import com.gemstone.gemfire.cache.wan.GatewaySender;
/**
* The CustomEditorRegistrationBeanFactoryPostProcessor class is a Spring BeanFactoryPostProcessor used to register
@@ -64,9 +62,8 @@ public class CustomEditorRegistrationBeanFactoryPostProcessor implements BeanFac
beanFactory.registerCustomEditor(IndexType.class, IndexTypeConverter.class);
beanFactory.registerCustomEditor(InterestPolicy.class, InterestPolicyConverter.class);
beanFactory.registerCustomEditor(InterestResultPolicy.class, InterestResultPolicyConverter.class);
beanFactory.registerCustomEditor(Gateway.OrderPolicy.class, OrderPolicyConverter.class);
beanFactory.registerCustomEditor(GatewaySender.OrderPolicy.class, OrderPolicyConverter.class);
beanFactory.registerCustomEditor(Scope.class, ScopeConverter.class);
beanFactory.registerCustomEditor(StartupPolicyType.class, StartupPolicyConverter.class);
beanFactory.registerCustomEditor(SubscriptionEvictionPolicy.class, SubscriptionEvictionPolicyConverter.class);
}

View File

@@ -1,151 +0,0 @@
/*
* Copyright 2010-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.gemfire.config;
import java.util.List;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.ManagedList;
import org.springframework.beans.factory.xml.AbstractSimpleBeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.data.gemfire.wan.GatewayHubFactoryBean;
import org.springframework.data.gemfire.wan.GatewayProxy;
import org.springframework.util.CollectionUtils;
import org.springframework.util.xml.DomUtils;
import org.w3c.dom.Element;
/**
* Parser for the &lt;gateway-hub&gt; SDG XML namespace element used to create GemFire GatewayHubs.
*
* @author David Turanski
* @author John Blum
* @see org.springframework.beans.factory.config.BeanDefinition
* @see org.springframework.beans.factory.support.BeanDefinitionBuilder
* @see org.springframework.beans.factory.support.ManagedList
* @see org.springframework.beans.factory.xml.AbstractSimpleBeanDefinitionParser
* @see org.springframework.beans.factory.xml.ParserContext
* @see org.springframework.data.gemfire.wan.GatewayHubFactoryBean
* @see org.springframework.data.gemfire.wan.GatewayProxy
*/
class GatewayHubParser extends AbstractSimpleBeanDefinitionParser {
@Override
protected Class<?> getBeanClass(Element element) {
return GatewayHubFactoryBean.class;
}
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
builder.addConstructorArgReference(ParsingUtils.resolveCacheReference(element.getAttribute("cache-ref")));
builder.setLazyInit(false);
ParsingUtils.setPropertyValue(element, builder, "bind-address");
ParsingUtils.setPropertyValue(element, builder, "manual-start");
ParsingUtils.setPropertyValue(element, builder, "max-connections");
ParsingUtils.setPropertyValue(element, builder, "max-time-between-pings", "maximumTimeBetweenPings");
ParsingUtils.setPropertyValue(element, builder, "port");
ParsingUtils.setPropertyValue(element, builder, "socket-buffer-size");
ParsingUtils.setPropertyValue(element, builder, "startup-policy");
parseGateways(element, parserContext, builder);
}
private void parseGateways(Element element, ParserContext parserContext, BeanDefinitionBuilder gatewayHubBuilder) {
List<Element> gatewayElements = DomUtils.getChildElementsByTagName(element, "gateway");
if (!CollectionUtils.isEmpty(gatewayElements)) {
ManagedList<BeanDefinition> gateways = new ManagedList<BeanDefinition>();
for (Element gatewayElement : gatewayElements) {
BeanDefinitionBuilder gatewayBuilder = BeanDefinitionBuilder.genericBeanDefinition(GatewayProxy.class);
ParsingUtils.setPropertyValue(gatewayElement, gatewayBuilder, "gateway-id", "id");
ParsingUtils.setPropertyValue(gatewayElement, gatewayBuilder, "concurrency-level");
ParsingUtils.setPropertyValue(gatewayElement, gatewayBuilder, "order-policy");
ParsingUtils.setPropertyValue(gatewayElement, gatewayBuilder, "socket-buffer-size");
ParsingUtils.setPropertyValue(gatewayElement, gatewayBuilder, "socket-read-timeout");
parseGatewayEndpoints(gatewayElement, gatewayBuilder);
parseGatewayListeners(gatewayElement, parserContext, gatewayBuilder);
parseGatewayQueue(gatewayElement, gatewayBuilder);
gateways.add(gatewayBuilder.getBeanDefinition());
}
gatewayHubBuilder.addPropertyValue("gateways", gateways);
}
}
private void parseGatewayEndpoints(Element gatewayElement, BeanDefinitionBuilder gatewayBuilder) {
List<Element> endpointElements = DomUtils.getChildElementsByTagName(gatewayElement, "gateway-endpoint");
if (!CollectionUtils.isEmpty(endpointElements)) {
ManagedList<BeanDefinition> endpoints = new ManagedList<BeanDefinition>();
for (Element endpointElement : endpointElements) {
BeanDefinitionBuilder endpointBuilder = BeanDefinitionBuilder.genericBeanDefinition(
GatewayProxy.GatewayEndpoint.class);
ParsingUtils.setPropertyValue(endpointElement, endpointBuilder, "endpoint-id", "id");
ParsingUtils.setPropertyValue(endpointElement, endpointBuilder, "host");
ParsingUtils.setPropertyValue(endpointElement, endpointBuilder, "port");
endpoints.add(endpointBuilder.getBeanDefinition());
}
gatewayBuilder.addPropertyValue("endpoints", endpoints);
}
}
private void parseGatewayListeners(Element gatewayElement, ParserContext parserContext,
BeanDefinitionBuilder gatewayBuilder) {
Element gatewayListenerElement = DomUtils.getChildElementByTagName(gatewayElement, "gateway-listener");
if (gatewayListenerElement != null) {
gatewayBuilder.addPropertyValue("listeners", ParsingUtils.parseRefOrNestedBeanDeclaration(
parserContext, gatewayListenerElement, gatewayBuilder));
}
}
private void parseGatewayQueue(Element gatewayElement, BeanDefinitionBuilder gatewayBuilder) {
Element gatewayQueueElement = DomUtils.getChildElementByTagName(gatewayElement, "gateway-queue");
if (gatewayQueueElement != null) {
BeanDefinitionBuilder queueBuilder = BeanDefinitionBuilder.genericBeanDefinition(
GatewayProxy.GatewayQueue.class);
ParsingUtils.setPropertyValue(gatewayQueueElement, queueBuilder, "alert-threshold");
ParsingUtils.setPropertyValue(gatewayQueueElement, queueBuilder, "batch-size");
ParsingUtils.setPropertyValue(gatewayQueueElement, queueBuilder, "batch-time-interval");
ParsingUtils.setPropertyValue(gatewayQueueElement, queueBuilder, "disk-store-ref");
ParsingUtils.setPropertyValue(gatewayQueueElement, queueBuilder, "enable-batch-conflation");
ParsingUtils.setPropertyValue(gatewayQueueElement, queueBuilder, "maximum-queue-memory");
ParsingUtils.setPropertyValue(gatewayQueueElement, queueBuilder, "persistent");
/* Make sure any disk store is created first */
if (gatewayQueueElement.hasAttribute("disk-store-ref")) {
gatewayBuilder.getBeanDefinition().setDependsOn(new String[] {
gatewayQueueElement.getAttribute("disk-store-ref") });
}
gatewayBuilder.addPropertyValue("queue", queueBuilder.getBeanDefinition());
}
}
}

View File

@@ -35,8 +35,11 @@ import org.w3c.dom.Element;
@SuppressWarnings("unused")
class GemfireNamespaceHandler extends NamespaceHandlerSupport {
protected static final List<String> GEMFIRE7_ELEMENTS = Arrays.asList("async-event-queue", "gateway-sender",
"gateway-receiver");
protected static final List<String> GEMFIRE7_ELEMENTS = Arrays.asList(
"async-event-queue",
"gateway-receiver",
"gateway-sender"
);
@Override
public BeanDefinition parse(Element element, ParserContext parserContext) {
@@ -66,7 +69,6 @@ class GemfireNamespaceHandler extends NamespaceHandlerSupport {
registerBeanDefinitionParser("async-event-queue", new AsyncEventQueueParser());
registerBeanDefinitionParser("disk-store", new DiskStoreParser());
registerBeanDefinitionParser("function-service", new FunctionServiceParser());
registerBeanDefinitionParser("gateway-hub", new GatewayHubParser());
registerBeanDefinitionParser("gateway-receiver", new GatewayReceiverParser());
registerBeanDefinitionParser("gateway-sender", new GatewaySenderParser());
registerBeanDefinitionParser("index", new IndexParser());

View File

@@ -22,7 +22,7 @@ import com.gemstone.gemfire.cache.CacheClosedException;
import com.gemstone.gemfire.cache.asyncqueue.AsyncEventListener;
import com.gemstone.gemfire.cache.asyncqueue.AsyncEventQueue;
import com.gemstone.gemfire.cache.asyncqueue.AsyncEventQueueFactory;
import com.gemstone.gemfire.cache.util.Gateway;
import com.gemstone.gemfire.cache.wan.GatewaySender;
/**
* FactoryBean for creating GemFire {@link AsyncEventQueue}s.
@@ -124,7 +124,7 @@ public class AsyncEventQueueFactoryBean extends AbstractWANComponentFactoryBean<
Assert.isTrue(VALID_ORDER_POLICIES.contains(orderPolicy.toUpperCase()), String.format(
"The value of Order Policy '$1%s' is invalid.", orderPolicy));
asyncEventQueueFactory.setOrderPolicy(Gateway.OrderPolicy.valueOf(orderPolicy.toUpperCase()));
asyncEventQueueFactory.setOrderPolicy(GatewaySender.OrderPolicy.valueOf(orderPolicy.toUpperCase()));
}
if (persistent != null) {

View File

@@ -1,222 +0,0 @@
/*
* Copyright 2010-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.gemfire.wan;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
import org.springframework.data.gemfire.wan.GatewayProxy.GatewayQueue;
import org.springframework.util.Assert;
import com.gemstone.gemfire.cache.Cache;
import com.gemstone.gemfire.cache.util.Gateway;
import com.gemstone.gemfire.cache.util.GatewayEventListener;
import com.gemstone.gemfire.cache.util.GatewayHub;
import com.gemstone.gemfire.cache.util.GatewayQueueAttributes;
import com.gemstone.gemfire.management.internal.cli.util.spring.StringUtils;
/**
* FactoryBean for creating a GemFire {@link GatewayHub} (deprecated in Gemfire 7).
*
* @author David Turanski
* @author John Blum
* @see org.springframework.data.gemfire.wan.AbstractWANComponentFactoryBean
* @see com.gemstone.gemfire.cache.Cache
* @see com.gemstone.gemfire.cache.util.Gateway
* @see com.gemstone.gemfire.cache.util.GatewayHub
* @see com.gemstone.gemfire.cache.util.GatewayEventListener
* @see com.gemstone.gemfire.cache.util.GatewayQueueAttributes
*/
@SuppressWarnings({"deprecation", "unused" })
public class GatewayHubFactoryBean extends AbstractWANComponentFactoryBean<GatewayHub> {
private Boolean manualStart;
private GatewayHub gatewayHub;
private Integer maxConnections;
private Integer maximumTimeBetweenPings;
private Integer port;
private Integer socketBufferSize;
private List<GatewayProxy> gateways;
private StartupPolicyType startupPolicy;
private String bindAddress;
/**
* Constructs an instance of the GatewayHubFactoryBean class used to create GemFire WAN GatewayHubs initialized
* with the specified GemFire Cache.
*
* @param cache a reference to the Gemfire Cache.
* @see com.gemstone.gemfire.cache.Cache
*/
public GatewayHubFactoryBean(final Cache cache) {
super(cache);
}
@Override
public GatewayHub getObject() throws Exception {
return gatewayHub;
}
@Override
public Class<?> getObjectType() {
return (gatewayHub != null ? gatewayHub.getClass() : GatewayHub.class);
}
@Override
protected void doInit() {
gatewayHub = cache.addGatewayHub(getName(), getPort());
if (log.isDebugEnabled()) {
log.debug(String.format("Adding GemFire GatewayHub (%1$s)", getName()));
}
Assert.notNull(cache.getGatewayHub(getName()));
gatewayHub.setBindAddress(getBindAddress());
gatewayHub.setManualStart(isManualStart(GatewayHub.DEFAULT_MANUAL_START));
gatewayHub.setMaxConnections(getMaxConnections());
gatewayHub.setMaximumTimeBetweenPings(getMaximumTimeBetweenPings());
gatewayHub.setSocketBufferSize(getSocketBufferSize());
gatewayHub.setStartupPolicy(getStartupPolicy().getName());
configureGateways();
autoStart();
}
private void configureGateways() {
for (GatewayProxy gatewayProxy : getGateways()) {
Gateway gateway = gatewayHub.addGateway(gatewayProxy.getId(), gatewayProxy.getConcurrencyLevel());
for (GatewayProxy.GatewayEndpoint endpoint : gatewayProxy.getEndpoints()) {
gateway.addEndpoint(endpoint.getId(), endpoint.getHost(), endpoint.getPort());
}
for (GatewayEventListener listener : gatewayProxy.getListeners()) {
gateway.addListener(listener);
}
gateway.setOrderPolicy(gatewayProxy.getOrderPolicy());
gateway.setSocketBufferSize(gatewayProxy.getSocketBufferSize());
gateway.setSocketReadTimeout(gatewayProxy.getSocketReadTimeout());
if (gatewayProxy.getQueue() != null) {
GatewayQueue queue = gatewayProxy.getQueue();
GatewayQueueAttributes queueAttributes = gateway.getQueueAttributes();
queueAttributes.setAlertThreshold(queue.getAlertThreshold());
queueAttributes.setBatchConflation(queue.getEnableBatchConflation());
queueAttributes.setBatchSize(queue.getBatchSize());
queueAttributes.setBatchTimeInterval(queue.getBatchTimeInterval());
queueAttributes.setMaximumQueueMemory(queue.getMaximumQueueMemory());
queueAttributes.setEnablePersistence(queue.getPersistent());
if (queue.getDiskStoreRef() != null) {
queueAttributes.setDiskStoreName(queue.getDiskStoreRef());
}
}
}
}
private void autoStart() {
if (!gatewayHub.getManualStart()) {
try {
gatewayHub.start();
}
catch (IOException e) {
throw new RuntimeException(e);
}
}
}
public void setBindAddress(String bindAddress) {
this.bindAddress = bindAddress;
}
/* (non-Javadoc) */
String getBindAddress() {
return (StringUtils.hasText(bindAddress) ? bindAddress : GatewayHub.DEFAULT_BIND_ADDRESS);
}
public void setGateways(List<GatewayProxy> gateways) {
this.gateways = gateways;
}
/* (non-Javadoc) */
List<GatewayProxy> getGateways() {
return (gateways != null ? gateways : Collections.<GatewayProxy>emptyList());
}
public void setManualStart(Boolean manualStart) {
this.manualStart = manualStart;
}
/* (non-Javadoc) */
boolean isManualStart(final boolean defaultManualStart) {
return (manualStart != null ? manualStart : defaultManualStart);
}
public void setMaxConnections(Integer maxConnections) {
this.maxConnections = maxConnections;
}
// (non-Javadoc)
Integer getMaxConnections() {
return (maxConnections != null ? maxConnections : GatewayHub.DEFAULT_MAX_CONNECTIONS);
}
public void setMaximumTimeBetweenPings(Integer maximumTimeBetweenPings) {
this.maximumTimeBetweenPings = maximumTimeBetweenPings;
}
// (non-Javadoc)
Integer getMaximumTimeBetweenPings() {
return (maximumTimeBetweenPings != null ? maximumTimeBetweenPings
: GatewayHub.DEFAULT_MAXIMUM_TIME_BETWEEN_PINGS);
}
public void setPort(Integer port) {
this.port = port;
}
/* (non-Javadoc) */
Integer getPort() {
return (port != null ? port : GatewayHub.DEFAULT_PORT);
}
public void setSocketBufferSize(Integer socketBufferSize) {
this.socketBufferSize = socketBufferSize;
}
/* (non-Javadoc) */
Integer getSocketBufferSize() {
return (socketBufferSize != null ? socketBufferSize : GatewayHub.DEFAULT_SOCKET_BUFFER_SIZE);
}
public void setStartupPolicy(StartupPolicyType startupPolicy) {
this.startupPolicy = startupPolicy;
}
/* (non-Javadoc) */
StartupPolicyType getStartupPolicy() {
return (startupPolicy != null ? startupPolicy : StartupPolicyType.DEFAULT);
}
}

View File

@@ -1,215 +0,0 @@
/*
* Copyright 2010-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.gemfire.wan;
import java.util.Collections;
import java.util.List;
import com.gemstone.gemfire.cache.util.Gateway;
import com.gemstone.gemfire.cache.util.GatewayEventListener;
import com.gemstone.gemfire.cache.util.GatewayQueueAttributes;
/**
* The GatewayProxy class used to allow decoupling of 'gateway' parsing from 'gateway-hub' parsing.
*
* @author David Turanski
* @author John Blum
* @since com.gemstone.gemfire.cache.util.Gateway
*/
@SuppressWarnings({ "deprecation", "unused" })
public class GatewayProxy {
private Gateway.OrderPolicy orderPolicy;
private GatewayQueue queue;
private Integer concurrencyLevel = Gateway.DEFAULT_CONCURRENCY_LEVEL;
private Integer socketBufferSize = Gateway.DEFAULT_SOCKET_BUFFER_SIZE;
private Integer socketReadTimeout = Gateway.DEFAULT_SOCKET_READ_TIMEOUT;
private List<GatewayEndpoint> endpoints;
private List<GatewayEventListener> listeners;
private String id;
public void setConcurrencyLevel(Integer concurrencyLevel) {
this.concurrencyLevel = concurrencyLevel;
}
public Integer getConcurrencyLevel() {
return (concurrencyLevel != null ? concurrencyLevel : Gateway.DEFAULT_CONCURRENCY_LEVEL);
}
public void setEndpoints(List<GatewayEndpoint> endpoints) {
this.endpoints = endpoints;
}
public List<GatewayEndpoint> getEndpoints() {
return (endpoints != null ? endpoints : Collections.<GatewayEndpoint>emptyList());
}
public void setId(String id) {
this.id = id;
}
public String getId() {
return this.id;
}
public void setListeners(List<GatewayEventListener> listeners) {
this.listeners = listeners;
}
public List<GatewayEventListener> getListeners() {
return (listeners != null ? listeners : Collections.<GatewayEventListener>emptyList());
}
public void setOrderPolicy(Gateway.OrderPolicy orderPolicy) {
this.orderPolicy = orderPolicy;
}
public Gateway.OrderPolicy getOrderPolicy() {
return this.orderPolicy;
}
public void setQueue(GatewayQueue queue) {
this.queue = queue;
}
public GatewayQueue getQueue() {
return this.queue;
}
public void setSocketBufferSize(int socketBufferSize) {
this.socketBufferSize = socketBufferSize;
}
public Integer getSocketBufferSize() {
return (socketBufferSize != null ? socketBufferSize : Gateway.DEFAULT_SOCKET_BUFFER_SIZE);
}
public void setSocketReadTimeout(final Integer socketReadTimeout) {
this.socketReadTimeout = socketReadTimeout;
}
public Integer getSocketReadTimeout() {
return (socketReadTimeout != null ? socketReadTimeout : Gateway.DEFAULT_SOCKET_READ_TIMEOUT);
}
public static class GatewayEndpoint {
private int port;
private String host;
private String id;
public String getHost() {
return host;
}
public void setHost(String host) {
this.host = host;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public int getPort() {
return port;
}
public void setPort(int port) {
this.port = port;
}
}
public static class GatewayQueue {
private Boolean enableBatchConflation;
private Boolean persistent;
private Integer alertThreshold;
private Integer batchSize;
private Integer batchTimeInterval;
private Integer maximumQueueMemory;
private String diskStoreRef;
public void setAlertThreshold(Integer alertThreshold) {
this.alertThreshold = alertThreshold;
}
public Integer getAlertThreshold() {
return (alertThreshold != null ? alertThreshold : GatewayQueueAttributes.DEFAULT_ALERT_THRESHOLD);
}
public void setBatchSize(Integer batchSize) {
this.batchSize = batchSize;
}
public Integer getBatchSize() {
return (batchSize != null ? batchSize : GatewayQueueAttributes.DEFAULT_BATCH_SIZE);
}
public void setBatchTimeInterval(Integer batchTimeInterval) {
this.batchTimeInterval = batchTimeInterval;
}
public Integer getBatchTimeInterval() {
return (batchTimeInterval != null ? batchTimeInterval : GatewayQueueAttributes.DEFAULT_BATCH_TIME_INTERVAL);
}
public void setDiskStoreRef(String diskStoreRef) {
this.diskStoreRef = diskStoreRef;
}
public String getDiskStoreRef() {
return diskStoreRef;
}
public void setEnableBatchConflation(Boolean enableBatchConflation) {
this.enableBatchConflation = enableBatchConflation;
}
public Boolean getEnableBatchConflation() {
return (enableBatchConflation != null ? enableBatchConflation
: GatewayQueueAttributes.DEFAULT_BATCH_CONFLATION);
}
public void setMaximumQueueMemory(Integer maximumQueueMemory) {
this.maximumQueueMemory = maximumQueueMemory;
}
public Integer getMaximumQueueMemory() {
return (maximumQueueMemory != null ? maximumQueueMemory
: GatewayQueueAttributes.DEFAULT_MAXIMUM_QUEUE_MEMORY);
}
public void setPersistent(Boolean persistent) {
this.persistent = persistent;
}
public Boolean getPersistent() {
return (persistent != null ? persistent : GatewayQueueAttributes.DEFAULT_ENABLE_PERSISTENCE);
}
}
}

View File

@@ -22,7 +22,6 @@ import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import com.gemstone.gemfire.cache.Cache;
import com.gemstone.gemfire.cache.util.Gateway;
import com.gemstone.gemfire.cache.wan.GatewayEventFilter;
import com.gemstone.gemfire.cache.wan.GatewayEventSubstitutionFilter;
import com.gemstone.gemfire.cache.wan.GatewaySender;
@@ -37,7 +36,6 @@ import com.gemstone.gemfire.cache.wan.GatewayTransportFilter;
* @see org.springframework.context.SmartLifecycle
* @see org.springframework.data.gemfire.wan.AbstractWANComponentFactoryBean
* @see com.gemstone.gemfire.cache.Cache
* @see com.gemstone.gemfire.cache.util.Gateway
* @see com.gemstone.gemfire.cache.wan.GatewaySender
* @see com.gemstone.gemfire.cache.wan.GatewaySenderFactory
* @since 1.2.2
@@ -149,7 +147,7 @@ public class GatewaySenderFactoryBean extends AbstractWANComponentFactoryBean<Ga
Assert.isTrue(VALID_ORDER_POLICIES.contains(orderPolicy.toUpperCase()),
String.format("The value for Order Policy '%1$s' is invalid.", orderPolicy));
gatewaySenderFactory.setOrderPolicy(Gateway.OrderPolicy.valueOf(orderPolicy.toUpperCase()));
gatewaySenderFactory.setOrderPolicy(GatewaySender.OrderPolicy.valueOf(orderPolicy.toUpperCase()));
}
gatewaySenderFactory.setParallel(isParallelGatewaySender());

View File

@@ -17,7 +17,6 @@ import java.util.List;
import org.springframework.util.Assert;
import com.gemstone.gemfire.cache.util.Gateway;
import com.gemstone.gemfire.cache.wan.GatewayEventFilter;
import com.gemstone.gemfire.cache.wan.GatewayEventSubstitutionFilter;
import com.gemstone.gemfire.cache.wan.GatewaySender;
@@ -176,7 +175,7 @@ public class GatewaySenderWrapper implements GatewaySender {
@Override
@SuppressWarnings("deprecation")
public Gateway.OrderPolicy getOrderPolicy() {
public GatewaySender.OrderPolicy getOrderPolicy() {
return delegate.getOrderPolicy();
}

View File

@@ -18,7 +18,7 @@ package org.springframework.data.gemfire.wan;
import org.springframework.data.gemfire.support.AbstractPropertyEditorConverterSupport;
import com.gemstone.gemfire.cache.util.Gateway;
import com.gemstone.gemfire.cache.wan.GatewaySender;
/**
* The OrderPolicyConverter class is a Spring Converter and JavaBeans PropertyEditor used to convert a String value
@@ -27,11 +27,11 @@ import com.gemstone.gemfire.cache.util.Gateway;
* @author John Blum
* @see org.springframework.data.gemfire.support.AbstractPropertyEditorConverterSupport
* @see org.springframework.data.gemfire.wan.OrderPolicyType
* @see com.gemstone.gemfire.cache.util.Gateway.OrderPolicy
* @see com.gemstone.gemfire.cache.wan.GatewaySender.OrderPolicy
* @since 1.7.0
*/
@SuppressWarnings({ "deprecation", "unused" })
public class OrderPolicyConverter extends AbstractPropertyEditorConverterSupport<Gateway.OrderPolicy> {
public class OrderPolicyConverter extends AbstractPropertyEditorConverterSupport<GatewaySender.OrderPolicy> {
/**
* Converts the given String into a GemFire Gateway.OrderPolicy enum.
@@ -44,9 +44,9 @@ public class OrderPolicyConverter extends AbstractPropertyEditorConverterSupport
* @see com.gemstone.gemfire.cache.util.Gateway.OrderPolicy
*/
@Override
public Gateway.OrderPolicy convert(final String source) {
public GatewaySender.OrderPolicy convert(final String source) {
return assertConverted(source, OrderPolicyType.getOrderPolicy(OrderPolicyType.valueOfIgnoreCase(source)),
Gateway.OrderPolicy.class);
GatewaySender.OrderPolicy.class);
}
}

View File

@@ -16,31 +16,31 @@
package org.springframework.data.gemfire.wan;
import com.gemstone.gemfire.cache.util.Gateway;
import com.gemstone.gemfire.cache.wan.GatewaySender;
/**
* The OrderPolicyType class is an enumeration of GemFire Gateway Order Policies.
*
* @author John Blum
* @see com.gemstone.gemfire.cache.util.Gateway.OrderPolicy
* @see com.gemstone.gemfire.cache.wan.GatewaySender.OrderPolicy
* @since 1.7.0
*/
@SuppressWarnings({ "deprecation", "unused" })
@SuppressWarnings("unused")
public enum OrderPolicyType {
KEY(Gateway.OrderPolicy.KEY),
PARTITION(Gateway.OrderPolicy.PARTITION),
THREAD(Gateway.OrderPolicy.THREAD);
KEY(GatewaySender.OrderPolicy.KEY),
PARTITION(GatewaySender.OrderPolicy.PARTITION),
THREAD(GatewaySender.OrderPolicy.THREAD);
private final Gateway.OrderPolicy orderPolicy;
private final GatewaySender.OrderPolicy orderPolicy;
/**
* Constructs an instance of the OrderPolicyType enum initialized with the matching GemFire Gateway.OrderPolicy
* enumerated value.
*
* @param orderPolicy the matching GemFire Gateway.OrderPolicy enumerated value.
* @see com.gemstone.gemfire.cache.util.Gateway.OrderPolicy
* @see com.gemstone.gemfire.cache.wan.GatewaySender.OrderPolicy
*/
OrderPolicyType(final Gateway.OrderPolicy orderPolicy) {
OrderPolicyType(final GatewaySender.OrderPolicy orderPolicy) {
this.orderPolicy = orderPolicy;
}
@@ -51,10 +51,10 @@ public enum OrderPolicyType {
* @param orderPolicyType the OrderPolicyType enum from which to extract the GemFire-based
* Gateway.OrderPolicy enumerated value.
* @return the GemFire Gateway.OrderPolicy enumerated value for the given OrderPolicyType.
* @see com.gemstone.gemfire.cache.util.Gateway.OrderPolicy
* @see com.gemstone.gemfire.cache.wan.GatewaySender.OrderPolicy
* @see #getOrderPolicy()
*/
public static Gateway.OrderPolicy getOrderPolicy(final OrderPolicyType orderPolicyType) {
public static GatewaySender.OrderPolicy getOrderPolicy(final OrderPolicyType orderPolicyType) {
return (orderPolicyType != null ? orderPolicyType.getOrderPolicy() : null);
}
@@ -64,10 +64,10 @@ public enum OrderPolicyType {
* @param orderPolicy the GemFire Gateway.OrderPolicy enumerated value used to match
* the desired OrderPolicyType.
* @return a OrderPolicyType matching the given GemFire Gateway.OrderPolicy enumerated value.
* @see com.gemstone.gemfire.cache.util.Gateway.OrderPolicy
* @see com.gemstone.gemfire.cache.wan.GatewaySender.OrderPolicy
* @see #getOrderPolicy()
*/
public static OrderPolicyType valueOf(final Gateway.OrderPolicy orderPolicy) {
public static OrderPolicyType valueOf(final GatewaySender.OrderPolicy orderPolicy) {
for (OrderPolicyType orderPolicyType : values()) {
if (orderPolicyType.getOrderPolicy().equals(orderPolicy)) {
return orderPolicyType;
@@ -99,9 +99,9 @@ public enum OrderPolicyType {
* Gets the GemFire Gateway.OrderPolicy corresponding to this OrderPolicyType enum.
*
* @return a GemFire Gateway.OrderPolicy for this enum.
* @see com.gemstone.gemfire.cache.util.Gateway.OrderPolicy
* @see com.gemstone.gemfire.cache.wan.GatewaySender.OrderPolicy
*/
public Gateway.OrderPolicy getOrderPolicy() {
public GatewaySender.OrderPolicy getOrderPolicy() {
return orderPolicy;
}

View File

@@ -1,48 +0,0 @@
/*
* Copyright 2010-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.gemfire.wan;
import org.springframework.data.gemfire.support.AbstractPropertyEditorConverterSupport;
/**
* The StartupPolicyConverter class is a Spring Converter and JavaBeans PropertyEditor responsible for
* converting String values into appropriate StartupPolicyType enumerated values.
*
* @author John Blum
* @see org.springframework.data.gemfire.support.AbstractPropertyEditorConverterSupport
* @see org.springframework.data.gemfire.wan.StartupPolicyType
* @since 1.7.0
*/
@SuppressWarnings("unused")
public class StartupPolicyConverter extends AbstractPropertyEditorConverterSupport<StartupPolicyType> {
/**
* Converts the given String value into an appropriate StartupPolicyType enumerated value.
*
* @param source the String to convert.
* @return a StartupPolicyType enumerated value for the given String.
* @throws java.lang.IllegalArgumentException if the String is not a valid GatewayHub Startup Policy.
* @see StartupPolicyType#valueOfIgnoreCase(String)
* @see #assertConverted(String, Object, Class)
*/
@Override
public StartupPolicyType convert(final String source) {
return assertConverted(source, StartupPolicyType.valueOfIgnoreCase(source),
StartupPolicyType.class);
}
}

View File

@@ -1,78 +0,0 @@
/*
* Copyright 2010-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.gemfire.wan;
import com.gemstone.gemfire.cache.util.GatewayHub;
/**
* The StartupPolicyType class is an enumeration of GemFire GatewayHub Startup Policies.
*
* @author John Blum
* @see com.gemstone.gemfire.cache.util.GatewayHub
* @since 1.7.0
*/
@SuppressWarnings({"deprecation", "unused" })
public enum StartupPolicyType {
NONE(GatewayHub.STARTUP_POLICY_NONE),
PRIMARY(GatewayHub.STARTUP_POLICY_PRIMARY),
SECONDARY(GatewayHub.STARTUP_POLICY_SECONDARY);
public static final StartupPolicyType DEFAULT = StartupPolicyType.valueOfIgnoreCase(
GatewayHub.DEFAULT_STARTUP_POLICY);
private final String name;
/**
* Constructs an instance of the StartupPolicyType enum initialized with the given GemFire "named",
* GatewayHub Startup Policy.
*
* @param name a String specifying the name used by GemFire for the GatewayHub Startup Policy.
*/
StartupPolicyType(final String name) {
this.name = name;
}
/**
* Returns a StartupPolicyType enumerated value matching the given official, case-insensitve "name"
* for the GatewayHub Startup Policy used by GemFire.
*
* @param name a String specifying the name used by GemFire for the GatewayHub Startup Policy.
* @return a StartupPolicyType enumerated value matching the given name used by GemFire to specify
* the GatewayHub Startup Policy.
* @see java.lang.String#equalsIgnoreCase(String)
* @see #getName()
*/
public static StartupPolicyType valueOfIgnoreCase(final String name) {
for (StartupPolicyType startupPolicyType : values()) {
if (startupPolicyType.getName().equalsIgnoreCase(name)) {
return startupPolicyType;
}
}
return null;
}
/**
* Gets the official name used by GemFire to specify the GatewayHub Startup Policy.
*
* @return the official GatewayHub Startup Policy name used by GemFire.
*/
public String getName() {
return name;
}
}

View File

@@ -3103,248 +3103,6 @@ Used for convenience. If no reference exists, use inner bean declarations.
</xsd:annotation>
</xsd:attribute>
</xsd:complexType>
<!-- GemFire 6 WAN Gateway schema -->
<xsd:complexType name="gatewayHubType">
<xsd:annotation>
<xsd:documentation><![CDATA[
Deprecated as of Gemfire 7
]]></xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="gateway" type="gatewayType" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation><![CDATA[
Deprecated as of Gemfire 7
]]></xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
<xsd:attribute name="id" type="xsd:string" use="required">
<xsd:annotation>
<xsd:documentation><![CDATA[
The id of this GatewayHub.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="cache-ref" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
The id of the cache - default is gemfireCache
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="bind-address" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
Specifies the bind address (IP address or host name) for the gateway hub
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="port" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
The port for this hub (integer value, if not specified, Gemfire will select an open port)
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="manual-start" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
Specifies if the gateway hub is manually (true) or automatically(false) started
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="max-connections" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
Sets the maximum number of Gateway connections allowed.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="max-time-between-pings" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
Sets the maximum amount of time between client pings.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="socket-buffer-size" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
Specifies the socket buffer size in bytes
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="startup-policy" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
Specifies the startup policy (primary,secondary, none) for the gateway hub
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:complexType>
<!-- -->
<xsd:complexType name="gatewayEndpointType">
<xsd:annotation>
<xsd:documentation><![CDATA[
Deprecated as of Gemfire 7
]]></xsd:documentation>
</xsd:annotation>
<xsd:attribute name="endpoint-id" type="xsd:string" use="required"/>
<xsd:attribute name="host" type="xsd:string" use="required"/>
<xsd:attribute name="port" type="xsd:string" use="required"/>
</xsd:complexType>
<!-- -->
<xsd:complexType name="gatewayQueueType">
<xsd:annotation>
<xsd:documentation><![CDATA[
Deprecated as of Gemfire 7
]]></xsd:documentation>
</xsd:annotation>
<xsd:attribute name="alert-threshold" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
Specifies the alert threshold in miliseconds, indicating the maximum time elapsed from when the gateway sent the message
to when the acknowldgement was received from the gateway receiver.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="batch-size" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
Specifies the batch size
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="batch-time-interval" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
The maximum time interval that can elapse before a partial batch is sent from a GatewaySender to its corresponding GatewayReceiver.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="disk-store-ref" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
Indicates the id of disk store to use for persistence
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="enable-batch-conflation" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
Specifies whether batch conflation is enabled (true or false)
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="maximum-queue-memory" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
Specifies the maximum memory in MB to allocate for the queue
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="persistent" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
Specifies whether persistence is enabled: true or false(default)
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:complexType>
<!-- -->
<xsd:complexType name="gatewayType">
<xsd:annotation>
<xsd:documentation><![CDATA[
Deprecated as of Gemfire 7
]]></xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:choice>
<xsd:element name="gateway-endpoint" type="gatewayEndpointType" minOccurs="1" maxOccurs="unbounded"/>
<xsd:element name="gateway-listener" minOccurs="1" maxOccurs="1">
<xsd:annotation>
<xsd:documentation
source="com.gemstone.gemfire.cache.util.GatewayEventListener"><![CDATA[
An gateway event listener definition for the gateway
]]></xsd:documentation>
<xsd:appinfo>
<tool:annotation>
<tool:exports type="com.gemstone.gemfire.cache.util.GatewayEventListener"/>
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:any namespace="##other" processContents="skip" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation><![CDATA[
Inner bean definition of the gateway event listener
]]></xsd:documentation>
</xsd:annotation>
</xsd:any>
</xsd:sequence>
<xsd:attribute name="ref" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
The name of the gateway event listener bean referred by this declaration. Used as a convenience method. If no reference exists,
use inner bean declarations.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:complexType>
</xsd:element>
</xsd:choice>
<xsd:element name="gateway-queue" type="gatewayQueueType" minOccurs="0" maxOccurs="1"/>
</xsd:sequence>
<xsd:attribute name="gateway-id" type="xsd:string" use="required">
<xsd:annotation>
<xsd:documentation><![CDATA[
Specifies the id for this gateway
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="concurrency-level" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
Specifies the number of parallel threads
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="order-policy" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
Specifies the order policy - This only applies if parallel is enabled:
KEY: Indicates that events will be parallelized based on the event's key,
PARTITION:Indicates that events will be parallelized based on the event's: partition (using the PartitionResolver)
THREAD:Indicates that events will be parallelized based on the event's originating member and thread
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="socket-buffer-size" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
Specifies the socket buffer size in bytes
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="socket-read-timeout" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
Specifies the socket read timeout in milliseconds
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:complexType>
<!-- -->
<xsd:element name="gateway-hub" type="gatewayHubType">
<xsd:annotation>
<xsd:documentation><![CDATA[
Deprecated as of Gemfire 7
]]></xsd:documentation>
</xsd:annotation>
</xsd:element>
<!-- End GemFire 6 WAN Gateway schema -->
<!-- Function Annotation Support -->
<xsd:element name="annotation-driven">
<xsd:annotation>

View File

@@ -37,15 +37,13 @@ import org.springframework.data.gemfire.client.InterestResultPolicyConverter;
import org.springframework.data.gemfire.server.SubscriptionEvictionPolicy;
import org.springframework.data.gemfire.server.SubscriptionEvictionPolicyConverter;
import org.springframework.data.gemfire.wan.OrderPolicyConverter;
import org.springframework.data.gemfire.wan.StartupPolicyConverter;
import org.springframework.data.gemfire.wan.StartupPolicyType;
import com.gemstone.gemfire.cache.EvictionAction;
import com.gemstone.gemfire.cache.ExpirationAction;
import com.gemstone.gemfire.cache.InterestPolicy;
import com.gemstone.gemfire.cache.InterestResultPolicy;
import com.gemstone.gemfire.cache.Scope;
import com.gemstone.gemfire.cache.util.Gateway;
import com.gemstone.gemfire.cache.wan.GatewaySender;
/**
* The CustomEditorRegistrationBeanFactoryPostProcessorTest class...
@@ -79,10 +77,8 @@ public class CustomEditorRegistrationBeanFactoryPostProcessorTest {
verify(mockBeanFactory, times(1)).registerCustomEditor(eq(InterestResultPolicy.class),
eq(InterestResultPolicyConverter.class));
verify(mockBeanFactory, times(1)).registerCustomEditor(eq(Scope.class), eq(ScopeConverter.class));
verify(mockBeanFactory, times(1)).registerCustomEditor(eq(Gateway.OrderPolicy.class),
verify(mockBeanFactory, times(1)).registerCustomEditor(eq(GatewaySender.OrderPolicy.class),
eq(OrderPolicyConverter.class));
verify(mockBeanFactory, times(1)).registerCustomEditor(eq(StartupPolicyType.class),
eq(StartupPolicyConverter.class));
verify(mockBeanFactory, times(1)).registerCustomEditor(eq(SubscriptionEvictionPolicy.class),
eq(SubscriptionEvictionPolicyConverter.class));
}

View File

@@ -1,221 +0,0 @@
/*
* Copyright 2010-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.gemfire.config;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import java.util.List;
import javax.annotation.Resource;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.gemfire.test.GemfireTestApplicationContextInitializer;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.gemstone.gemfire.cache.DataPolicy;
import com.gemstone.gemfire.cache.Region;
import com.gemstone.gemfire.cache.util.Gateway;
import com.gemstone.gemfire.cache.util.GatewayEvent;
import com.gemstone.gemfire.cache.util.GatewayEventListener;
import com.gemstone.gemfire.cache.util.GatewayHub;
import com.gemstone.gemfire.cache.util.GatewayQueueAttributes;
/**
* The GatewayHubNamespaceTest class is a test suite of test cases testing the contract and functionality
* of the GatewayHub SDG XML namespace (XSD) configuration meta-data.
*
* @author John Blum
* @see org.junit.Test
* @see org.junit.runner.RunWith
* @see org.springframework.data.gemfire.test.GemfireTestApplicationContextInitializer
* @see org.springframework.data.gemfire.wan.GatewayHubFactoryBean
* @see org.springframework.data.gemfire.wan.GatewayProxy
* @see org.springframework.test.context.ContextConfiguration
* @see org.springframework.test.context.junit4.SpringJUnit4ClassRunner
* @see com.gemstone.gemfire.cache.util.Gateway
* @see com.gemstone.gemfire.cache.util.GatewayHub
* @since 1.5.3
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(initializers = GemfireTestApplicationContextInitializer.class)
@SuppressWarnings({"deprecation", "unused" })
public class GatewayHubNamespaceTest {
@Resource(name = "Example")
private Region<?, ?> example;
@Autowired
private GatewayHub gatewayHub;
protected Gateway getGatewayById(final List<Gateway> gateways, final String id) {
for (Gateway gateway : gateways) {
if (gateway.getId().equals(id)) {
return gateway;
}
}
return null;
}
@Test
public void testRegionConfiguration() {
assertNotNull("The '/Example' Region was not properly initialized!", example);
assertEquals("Example", example.getName());
assertEquals("/Example", example.getFullPath());
assertNotNull(example.getAttributes());
assertEquals(DataPolicy.REPLICATE, example.getAttributes().getDataPolicy());
assertTrue(example.getAttributes().getEnableGateway());
assertEquals("testGatewayHub", example.getAttributes().getGatewayHubId());
}
@Test
public void testGatewayConfiguration() {
assertNotNull("The 'TestGatewayHub' GatewayHub was not properly initialized!", gatewayHub);
assertEquals("localhost", gatewayHub.getBindAddress());
assertEquals("TestGatewayHub", gatewayHub.getId());
assertTrue(gatewayHub.getManualStart());
assertEquals(125, gatewayHub.getMaxConnections());
assertEquals(5000, gatewayHub.getMaximumTimeBetweenPings());
assertEquals(45123, gatewayHub.getPort());
assertEquals(16384, gatewayHub.getSocketBufferSize());
assertEquals("primary", gatewayHub.getStartupPolicy());
List<Gateway> gateways = gatewayHub.getGateways();
assertNotNull(gateways);
assertFalse(gateways.isEmpty());
assertEquals(3, gateways.size());
Gateway gatewayOne = getGatewayById(gateways, "gateway1");
assertNotNull(gatewayOne);
assertEquals("gateway1", gatewayOne.getId());
assertEquals(8, gatewayOne.getConcurrencyLevel());
assertEquals(Gateway.OrderPolicy.THREAD, gatewayOne.getOrderPolicy());
assertEquals(65536, gatewayOne.getSocketBufferSize());
assertEquals(75000, gatewayOne.getSocketReadTimeout());
assertTrue(gatewayOne.getEndpoints() == null || gatewayOne.getEndpoints().isEmpty());
List<GatewayEventListener> gatewayEventListeners = gatewayOne.getListeners();
assertNotNull(gatewayEventListeners);
assertFalse(gatewayEventListeners.isEmpty());
assertEquals(2, gatewayEventListeners.size());
assertTrue(gatewayEventListeners.get(0) instanceof TestGatewayListener);
assertEquals("ListenerOne", gatewayEventListeners.get(0).toString());
assertTrue(gatewayEventListeners.get(1) instanceof TestGatewayListener);
assertEquals("ListenerTwo", gatewayEventListeners.get(1).toString());
GatewayQueueAttributes gatewayQueueAttributes = gatewayOne.getQueueAttributes();
assertNotNull(gatewayQueueAttributes);
assertEquals(99, gatewayQueueAttributes.getAlertThreshold());
assertTrue(gatewayQueueAttributes.getBatchConflation());
assertEquals(3, gatewayQueueAttributes.getBatchSize());
assertEquals(10, gatewayQueueAttributes.getBatchTimeInterval());
assertEquals("TestGatewayQueueDiskStore", gatewayQueueAttributes.getDiskStoreName());
assertFalse(gatewayQueueAttributes.getEnablePersistence());
assertEquals(5, gatewayQueueAttributes.getMaximumQueueMemory());
Gateway gatewayTwo = getGatewayById(gateways, "gateway2");
assertNotNull(gatewayTwo);
assertEquals("gateway2", gatewayTwo.getId());
assertEquals(Gateway.DEFAULT_CONCURRENCY_LEVEL, gatewayTwo.getConcurrencyLevel());
assertNull(gatewayTwo.getOrderPolicy());
assertEquals(Gateway.DEFAULT_SOCKET_BUFFER_SIZE, gatewayTwo.getSocketBufferSize());
assertEquals(Gateway.DEFAULT_SOCKET_READ_TIMEOUT, gatewayTwo.getSocketReadTimeout());
assertTrue(gatewayTwo.getListeners() == null || gatewayTwo.getListeners().isEmpty());
List gatewayEndpoints = gatewayTwo.getEndpoints();
assertNotNull(gatewayEndpoints);
assertFalse(gatewayEndpoints.isEmpty());
assertEquals(2, gatewayEndpoints.size());
Gateway.Endpoint gatewayEndpointOne = (Gateway.Endpoint) gatewayEndpoints.get(0);
assertEquals("endpoint1", gatewayEndpointOne.getId());
assertEquals("localhost", gatewayEndpointOne.getHost());
assertEquals(1234, gatewayEndpointOne.getPort());
Gateway.Endpoint gatewayEndpointTwo = (Gateway.Endpoint) gatewayEndpoints.get(1);
assertEquals("endpoint2", gatewayEndpointTwo.getId());
assertEquals("localhost", gatewayEndpointTwo.getHost());
assertEquals(4321, gatewayEndpointTwo.getPort());
gatewayQueueAttributes = gatewayTwo.getQueueAttributes();
assertNotNull(gatewayQueueAttributes);
assertEquals(GatewayQueueAttributes.DEFAULT_ALERT_THRESHOLD, gatewayQueueAttributes.getAlertThreshold());
assertFalse(gatewayQueueAttributes.getBatchConflation());
assertEquals(6, gatewayQueueAttributes.getBatchSize());
assertEquals(20, gatewayQueueAttributes.getBatchTimeInterval());
assertNull(gatewayQueueAttributes.getDiskStoreName());
assertTrue(gatewayQueueAttributes.getEnablePersistence());
assertEquals(GatewayQueueAttributes.DEFAULT_MAXIMUM_QUEUE_MEMORY, gatewayQueueAttributes.getMaximumQueueMemory());
Gateway gatewayThree = getGatewayById(gateways, "gateway3");
assertNotNull(gatewayThree);
assertEquals("gateway3", gatewayThree.getId());
assertEquals(Gateway.DEFAULT_CONCURRENCY_LEVEL, gatewayThree.getConcurrencyLevel());
assertNull(gatewayThree.getOrderPolicy());
assertEquals(Gateway.DEFAULT_SOCKET_BUFFER_SIZE, gatewayThree.getSocketBufferSize());
assertEquals(Gateway.DEFAULT_SOCKET_READ_TIMEOUT, gatewayThree.getSocketReadTimeout());
assertTrue(gatewayThree.getEndpoints() == null || gatewayThree.getEndpoints().isEmpty());
gatewayEventListeners = gatewayThree.getListeners();
assertNotNull(gatewayEventListeners);
assertFalse(gatewayEventListeners.isEmpty());
assertEquals(1, gatewayEventListeners.size());
assertTrue(gatewayEventListeners.get(0) instanceof TestGatewayListener);
assertEquals("ListenerTwo", gatewayEventListeners.get(0).toString());
}
public static final class TestGatewayListener implements GatewayEventListener {
private String name;
public void setName(final String name) {
this.name = name;
}
@Override
public boolean processEvents(final List<GatewayEvent> events) {
return false;
}
@Override
public void close() {
}
@Override
public String toString() {
return name;
}
}
}

View File

@@ -1,106 +0,0 @@
/*
* Copyright 2010-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.gemfire.config;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.util.List;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.data.gemfire.TestUtils;
import org.springframework.data.gemfire.test.GemfireTestApplicationContextInitializer;
import org.springframework.data.gemfire.wan.GatewayHubFactoryBean;
import org.springframework.data.gemfire.wan.GatewayProxy;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.gemstone.gemfire.cache.Cache;
import com.gemstone.gemfire.cache.Region;
import com.gemstone.gemfire.cache.util.GatewayEvent;
import com.gemstone.gemfire.cache.util.GatewayEventListener;
import com.gemstone.gemfire.cache.util.GatewayHub;
/**
* @author David Turanski
*
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations="/org/springframework/data/gemfire/config/gateway-v6-ns.xml",
initializers=GemfireTestApplicationContextInitializer.class)
public class GemfireV6GatewayNamespaceTest {
@Autowired ApplicationContext ctx;
@Test
public void testGatewayHubFactoryBean() throws Exception {
GatewayHubFactoryBean gwhfb = ctx.getBean("&gateway-hub", GatewayHubFactoryBean.class);
List<GatewayProxy> gateways = TestUtils.readField("gateways", gwhfb);
assertNotNull(gateways);
assertEquals(2, gateways.size());
GatewayProxy gwp = gateways.get(0);
assertEquals("gateway", gwp.getId());
assertTrue(gwp.getListeners().get(0) instanceof GatewayListener);
gwp = gateways.get(1);
assertEquals("gateway2", gwp.getId());
List<GatewayProxy.GatewayEndpoint> endpoints = gwp.getEndpoints();
assertEquals(2, endpoints.size());
GatewayProxy.GatewayEndpoint endpoint;
endpoint = endpoints.get(0);
assertEquals("endpoint1", endpoint.getId());
assertEquals("host1", endpoint.getHost());
assertEquals(1234, endpoint.getPort());
endpoint = endpoints.get(1);
assertEquals("endpoint2", endpoint.getId());
assertEquals("host2", endpoint.getHost());
assertEquals(2345, endpoint.getPort());
}
@SuppressWarnings("rawtypes")
@Test
public void testGatewaysInGemfire() {
Cache cache = ctx.getBean("gemfireCache", Cache.class);
GatewayHub gwh = cache.getGatewayHub("gateway-hub");
assertNotNull(gwh);
Region region = ctx.getBean("region-with-gateway", Region.class);
assertTrue(region.getAttributes().getEnableGateway());
assertEquals("gateway-hub", region.getAttributes().getGatewayHubId());
}
public static class GatewayListener implements GatewayEventListener {
@Override
public void close() {
// TODO Auto-generated method stub
}
@Override
public boolean processEvents(List<GatewayEvent> event) {
// TODO Auto-generated method stub
return false;
}
}
}

View File

@@ -1,324 +0,0 @@
/*
* Copyright 2010-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.gemfire.wan;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.eq;
import static org.mockito.Matchers.same;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.util.Arrays;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
import com.gemstone.gemfire.cache.Cache;
import com.gemstone.gemfire.cache.util.Gateway;
import com.gemstone.gemfire.cache.util.GatewayEventListener;
import com.gemstone.gemfire.cache.util.GatewayHub;
import com.gemstone.gemfire.cache.util.GatewayQueueAttributes;
/**
* The GatewayHubFactoryBeanTest class is a test suite of test cases testing the contract and functionality
* of the GatewayHubFactoryBean.
*
* @author John Blum
* @see org.junit.Test
* @see org.mockito.Mockito
* @see org.springframework.data.gemfire.wan.GatewayHubFactoryBean
* @since 1.7.0
*/
@SuppressWarnings("deprecation")
public class GatewayHubFactoryBeanTest {
private Cache mockCache;
private GatewayHubFactoryBean factoryBean;
@Before
public void setup() {
mockCache = mock(Cache.class, "GemFire Cache");
factoryBean = new GatewayHubFactoryBean(mockCache);
}
@Test
public void testGetObjectAndObjectType() throws Exception {
assertNull(factoryBean.getObject());
assertEquals(GatewayHub.class, factoryBean.getObjectType());
}
@Test
public void testSetAndGetBindAddress() {
assertEquals(GatewayHub.DEFAULT_BIND_ADDRESS, factoryBean.getBindAddress());
factoryBean.setBindAddress("10.127.255.1");
assertEquals("10.127.255.1", factoryBean.getBindAddress());
factoryBean.setBindAddress(null);
assertEquals(GatewayHub.DEFAULT_BIND_ADDRESS, factoryBean.getBindAddress());
}
@Test
public void testGetGateways() {
List<GatewayProxy> gateways = factoryBean.getGateways();
assertNotNull(gateways);
assertTrue(gateways.isEmpty());
}
@Test
public void testSetAndIsManualStart() {
assertEquals(GatewayHub.DEFAULT_MANUAL_START, factoryBean.isManualStart(GatewayHub.DEFAULT_MANUAL_START));
factoryBean.setManualStart(true);
assertTrue(factoryBean.isManualStart(GatewayHub.DEFAULT_MANUAL_START));
factoryBean.setManualStart(false);
assertFalse(factoryBean.isManualStart(true));
factoryBean.setManualStart(null);
assertEquals(GatewayHub.DEFAULT_MANUAL_START, factoryBean.isManualStart(GatewayHub.DEFAULT_MANUAL_START));
}
@Test
public void testSetAndGetMaxConnections() {
assertEquals(GatewayHub.DEFAULT_MAX_CONNECTIONS, factoryBean.getMaxConnections().intValue());
factoryBean.setMaxConnections(8192);
assertEquals(8192, factoryBean.getMaxConnections().intValue());
factoryBean.setMaxConnections(null);
assertEquals(GatewayHub.DEFAULT_MAX_CONNECTIONS, factoryBean.getMaxConnections().intValue());
}
@Test
public void testSetAndGetMaximumTimeBetweenPings() {
assertEquals(GatewayHub.DEFAULT_MAXIMUM_TIME_BETWEEN_PINGS, factoryBean.getMaximumTimeBetweenPings().intValue());
factoryBean.setMaximumTimeBetweenPings(15000);
assertEquals(15000, factoryBean.getMaximumTimeBetweenPings().intValue());
factoryBean.setMaximumTimeBetweenPings(null);
assertEquals(GatewayHub.DEFAULT_MAXIMUM_TIME_BETWEEN_PINGS, factoryBean.getMaximumTimeBetweenPings().intValue());
}
@Test
public void testSetAndGetPort() {
assertEquals(GatewayHub.DEFAULT_PORT, factoryBean.getPort().intValue());
factoryBean.setPort(15221);
assertEquals(15221, factoryBean.getPort().intValue());
factoryBean.setPort(null);
assertEquals(GatewayHub.DEFAULT_PORT, factoryBean.getPort().intValue());
}
@Test
public void testSetAndGetSocketBufferSize() {
assertEquals(GatewayHub.DEFAULT_SOCKET_BUFFER_SIZE, factoryBean.getSocketBufferSize().intValue());
factoryBean.setSocketBufferSize(16384);
assertEquals(16384, factoryBean.getSocketBufferSize().intValue());
factoryBean.setSocketBufferSize(null);
assertEquals(GatewayHub.DEFAULT_SOCKET_BUFFER_SIZE, factoryBean.getSocketBufferSize().intValue());
}
@Test
public void testSetAndGetStartUpPolicy() {
assertEquals(StartupPolicyType.DEFAULT, factoryBean.getStartupPolicy());
factoryBean.setStartupPolicy(StartupPolicyType.PRIMARY);
assertEquals(StartupPolicyType.PRIMARY, factoryBean.getStartupPolicy());
factoryBean.setStartupPolicy(null);
assertEquals(StartupPolicyType.DEFAULT, factoryBean.getStartupPolicy());
factoryBean.setStartupPolicy(StartupPolicyType.SECONDARY);
assertEquals(StartupPolicyType.SECONDARY, factoryBean.getStartupPolicy());
}
@Test(expected = IllegalArgumentException.class)
public void testAfterPropertiesSetWitNullCache() throws Exception {
try {
new GatewayHubFactoryBean(null).afterPropertiesSet();
}
catch (IllegalArgumentException expected) {
assertEquals("Cache must not be null.", expected.getMessage());
throw expected;
}
}
@Test(expected = IllegalArgumentException.class)
public void testAfterPropertiesSetWithNullName() throws Exception {
try {
factoryBean.afterPropertiesSet();
}
catch (IllegalArgumentException expected) {
assertEquals("Name must not be null.", expected.getMessage());
throw expected;
}
}
@Test
public void testDoInit() throws Exception {
String gatewayHubName = "testDoInit";
GatewayProxy.GatewayEndpoint gatewayEndpointOne = new GatewayProxy.GatewayEndpoint();
gatewayEndpointOne.setHost("localhost");
gatewayEndpointOne.setId("123");
gatewayEndpointOne.setPort(2121);
GatewayProxy.GatewayEndpoint gatewayEndpointTwo = new GatewayProxy.GatewayEndpoint();
gatewayEndpointOne.setHost("localhost");
gatewayEndpointOne.setId("456");
gatewayEndpointOne.setPort(4242);
GatewayEventListener mockGatewayListener = mock(GatewayEventListener.class,
"testDoInit.MockGatewayEventListener");
GatewayProxy.GatewayQueue gatewayQueue = new GatewayProxy.GatewayQueue();
gatewayQueue.setAlertThreshold(20);
gatewayQueue.setBatchSize(100);
gatewayQueue.setBatchTimeInterval(60000);
gatewayQueue.setDiskStoreRef("diskX");
gatewayQueue.setEnableBatchConflation(true);
gatewayQueue.setMaximumQueueMemory(1024);
gatewayQueue.setPersistent(true);
GatewayProxy gatewayProxy = new GatewayProxy();
gatewayProxy.setId("gatewayProxyId");
gatewayProxy.setConcurrencyLevel(4);
gatewayProxy.setEndpoints(Arrays.asList(gatewayEndpointOne, gatewayEndpointTwo));
gatewayProxy.setListeners(Arrays.asList(mockGatewayListener));
gatewayProxy.setOrderPolicy(Gateway.OrderPolicy.THREAD);
gatewayProxy.setQueue(gatewayQueue);
gatewayProxy.setSocketBufferSize(16384);
gatewayProxy.setSocketReadTimeout(300);
GatewayHub mockGatewayHub = mock(GatewayHub.class, "testDoInit.MockGatewayHub");
Gateway mockGateway = mock(Gateway.class, "testDoInit.MockGateway");
GatewayQueueAttributes mockGatewayQueueAttributes = mock(GatewayQueueAttributes.class,
"testDoInit.MockGatewayQueueAttributes");
when(mockCache.addGatewayHub(eq(gatewayHubName), eq(8484))).thenReturn(mockGatewayHub);
when(mockCache.getGatewayHub(eq(gatewayHubName))).thenReturn(mockGatewayHub);
when(mockGatewayHub.addGateway(eq(gatewayProxy.getId()), eq(gatewayProxy.getConcurrencyLevel().intValue())))
.thenReturn(mockGateway);
when(mockGatewayHub.getManualStart()).thenReturn(false);
when(mockGateway.getQueueAttributes()).thenReturn(mockGatewayQueueAttributes);
factoryBean.setBindAddress("10.124.210.42");
factoryBean.setGateways(Arrays.asList(gatewayProxy));
factoryBean.setManualStart(false);
factoryBean.setMaxConnections(50);
factoryBean.setMaximumTimeBetweenPings(20480);
factoryBean.setName(gatewayHubName);
factoryBean.setPort(8484);
factoryBean.setSocketBufferSize(4096);
factoryBean.setStartupPolicy(StartupPolicyType.PRIMARY);
factoryBean.afterPropertiesSet();
verify(mockGatewayHub, times(1)).setBindAddress(eq("10.124.210.42"));
verify(mockGatewayHub, times(1)).setManualStart(eq(false));
verify(mockGatewayHub, times(1)).setMaxConnections(eq(50));
verify(mockGatewayHub, times(1)).setMaximumTimeBetweenPings(eq(20480));
verify(mockGatewayHub, times(1)).setSocketBufferSize(eq(4096));
verify(mockGatewayHub, times(1)).setStartupPolicy(eq(StartupPolicyType.PRIMARY.getName()));
verify(mockGatewayHub, times(1)).addGateway(eq(gatewayProxy.getId()), eq(gatewayProxy.getConcurrencyLevel()));
verify(mockGatewayHub, times(1)).start();
verify(mockGateway, times(1)).addEndpoint(eq(gatewayEndpointOne.getId()), eq(gatewayEndpointOne.getHost()),
eq(gatewayEndpointOne.getPort()));
verify(mockGateway, times(1)).addEndpoint(eq(gatewayEndpointTwo.getId()), eq(gatewayEndpointTwo.getHost()),
eq(gatewayEndpointTwo.getPort()));
verify(mockGateway, times(1)).addListener(same(mockGatewayListener));
verify(mockGateway, times(1)).setOrderPolicy(eq(gatewayProxy.getOrderPolicy()));
verify(mockGateway, times(1)).setSocketBufferSize(eq(gatewayProxy.getSocketBufferSize()));
verify(mockGateway, times(1)).setSocketReadTimeout(eq(gatewayProxy.getSocketReadTimeout()));
verify(mockGateway, times(1)).getQueueAttributes();
verify(mockGatewayQueueAttributes, times(1)).setAlertThreshold(eq(gatewayQueue.getAlertThreshold()));
verify(mockGatewayQueueAttributes, times(1)).setBatchConflation(eq(gatewayQueue.getEnableBatchConflation()));
verify(mockGatewayQueueAttributes, times(1)).setBatchSize(eq(gatewayQueue.getBatchSize()));
verify(mockGatewayQueueAttributes, times(1)).setBatchTimeInterval(eq(gatewayQueue.getBatchTimeInterval()));
verify(mockGatewayQueueAttributes, times(1)).setDiskStoreName(eq(gatewayQueue.getDiskStoreRef()));
verify(mockGatewayQueueAttributes, times(1)).setMaximumQueueMemory(eq(gatewayQueue.getMaximumQueueMemory()));
verify(mockGatewayQueueAttributes, times(1)).setEnablePersistence(eq(gatewayQueue.getPersistent()));
}
@Test
public void testGatewayQueueWithOverflowNoPersistence() throws Exception {
String gatewayHubName = "testGatewayQueueWithOverflowNoPersistence";
GatewayProxy.GatewayQueue gatewayQueue = new GatewayProxy.GatewayQueue();
gatewayQueue.setAlertThreshold(100);
gatewayQueue.setBatchSize(250);
gatewayQueue.setBatchTimeInterval(120000);
gatewayQueue.setDiskStoreRef("diskZ");
gatewayQueue.setEnableBatchConflation(true);
gatewayQueue.setMaximumQueueMemory(2048);
gatewayQueue.setPersistent(false);
GatewayProxy gatewayProxy = new GatewayProxy();
gatewayProxy.setId("gatewayProxyId");
gatewayProxy.setConcurrencyLevel(2);
gatewayProxy.setEndpoints(null);
gatewayProxy.setListeners(null);
gatewayProxy.setOrderPolicy(Gateway.OrderPolicy.THREAD);
gatewayProxy.setQueue(gatewayQueue);
gatewayProxy.setSocketBufferSize(4096);
gatewayProxy.setSocketReadTimeout(60);
GatewayHub mockGatewayHub = mock(GatewayHub.class, "testGatewayQueueWithOverflowNoPersistence.MockGatewayHub");
Gateway mockGateway = mock(Gateway.class, "testGatewayQueueWithOverflowNoPersistence.MockGateway");
GatewayQueueAttributes mockGatewayQueueAttributes = mock(GatewayQueueAttributes.class,
"testGatewayQueueWithOverflowNoPersistence.MockGatewayQueueAttributes");
when(mockCache.addGatewayHub(eq(gatewayHubName), eq(10224))).thenReturn(mockGatewayHub);
when(mockCache.getGatewayHub(eq(gatewayHubName))).thenReturn(mockGatewayHub);
when(mockGatewayHub.addGateway(eq(gatewayProxy.getId()), eq(gatewayProxy.getConcurrencyLevel())))
.thenReturn(mockGateway);
when(mockGatewayHub.getManualStart()).thenReturn(GatewayHub.DEFAULT_MANUAL_START);
when(mockGateway.getQueueAttributes()).thenReturn(mockGatewayQueueAttributes);
factoryBean.setGateways(Arrays.asList(gatewayProxy));
factoryBean.setName(gatewayHubName);
factoryBean.setPort(10224);
factoryBean.afterPropertiesSet();
verify(mockGatewayHub, times(1)).setBindAddress(eq(GatewayHub.DEFAULT_BIND_ADDRESS));
verify(mockGatewayHub, times(1)).setManualStart(eq(GatewayHub.DEFAULT_MANUAL_START));
verify(mockGatewayHub, times(1)).setMaxConnections(GatewayHub.DEFAULT_MAX_CONNECTIONS);
verify(mockGatewayHub, times(1)).setMaximumTimeBetweenPings(eq(GatewayHub.DEFAULT_MAXIMUM_TIME_BETWEEN_PINGS));
verify(mockGatewayHub, times(1)).setSocketBufferSize(eq(GatewayHub.DEFAULT_SOCKET_BUFFER_SIZE));
verify(mockGatewayHub, times(1)).setStartupPolicy(eq(GatewayHub.DEFAULT_STARTUP_POLICY));
verify(mockGatewayHub, times(1)).start();
verify(mockGatewayHub, times(1)).addGateway(eq(gatewayProxy.getId()), eq(gatewayProxy.getConcurrencyLevel()));
verify(mockGateway, times(1)).setOrderPolicy(eq(gatewayProxy.getOrderPolicy()));
verify(mockGateway, times(1)).setSocketBufferSize(eq(gatewayProxy.getSocketBufferSize()));
verify(mockGateway, times(1)).setSocketReadTimeout(eq(gatewayProxy.getSocketReadTimeout()));
verify(mockGatewayQueueAttributes, times(1)).setAlertThreshold(gatewayQueue.getAlertThreshold());
verify(mockGatewayQueueAttributes, times(1)).setBatchConflation(gatewayQueue.getEnableBatchConflation());
verify(mockGatewayQueueAttributes, times(1)).setBatchSize(gatewayQueue.getBatchSize());
verify(mockGatewayQueueAttributes, times(1)).setBatchTimeInterval(gatewayQueue.getBatchTimeInterval());
verify(mockGatewayQueueAttributes, times(1)).setDiskStoreName(gatewayQueue.getDiskStoreRef());
verify(mockGatewayQueueAttributes, times(1)).setMaximumQueueMemory(gatewayQueue.getMaximumQueueMemory());
verify(mockGatewayQueueAttributes, times(1)).setEnablePersistence(gatewayQueue.getPersistent());
}
}

View File

@@ -22,7 +22,7 @@ import static org.junit.Assert.assertNull;
import org.junit.After;
import org.junit.Test;
import com.gemstone.gemfire.cache.util.Gateway;
import com.gemstone.gemfire.cache.wan.GatewaySender;
/**
* The OrderPolicyConverterTest class is a test suite of test cases testing the contract and functionality
@@ -31,6 +31,7 @@ import com.gemstone.gemfire.cache.util.Gateway;
* @author John Blum
* @see org.junit.Test
* @see org.springframework.data.gemfire.wan.OrderPolicyConverter
* @see com.gemstone.gemfire.cache.wan.GatewaySender.OrderPolicy
* @since 1.7.0
*/
@SuppressWarnings("deprecation")
@@ -45,9 +46,9 @@ public class OrderPolicyConverterTest {
@Test
public void testConvert() {
assertEquals(Gateway.OrderPolicy.KEY, converter.convert("key"));
assertEquals(Gateway.OrderPolicy.PARTITION, converter.convert("Partition"));
assertEquals(Gateway.OrderPolicy.THREAD, converter.convert("THREAD"));
assertEquals(GatewaySender.OrderPolicy.KEY, converter.convert("key"));
assertEquals(GatewaySender.OrderPolicy.PARTITION, converter.convert("Partition"));
assertEquals(GatewaySender.OrderPolicy.THREAD, converter.convert("THREAD"));
}
@Test(expected = IllegalArgumentException.class)
@@ -64,9 +65,9 @@ public class OrderPolicyConverterTest {
@Test
public void testSetAsText() {
converter.setAsText("PartItIOn");
assertEquals(Gateway.OrderPolicy.PARTITION, converter.getValue());
assertEquals(GatewaySender.OrderPolicy.PARTITION, converter.getValue());
converter.setAsText("thREAD");
assertEquals(Gateway.OrderPolicy.THREAD, converter.getValue());
assertEquals(GatewaySender.OrderPolicy.THREAD, converter.getValue());
}
@Test(expected = IllegalArgumentException.class)

View File

@@ -22,7 +22,7 @@ import static org.junit.Assert.assertNull;
import org.junit.Test;
import com.gemstone.gemfire.cache.util.Gateway;
import com.gemstone.gemfire.cache.wan.GatewaySender;
/**
* The OrderPolicyTypeTest class is a test suite of test cases testing the contract and functionality
@@ -31,7 +31,7 @@ import com.gemstone.gemfire.cache.util.Gateway;
* @author John Blum
* @see org.junit.Test
* @see org.springframework.data.gemfire.wan.OrderPolicyType
* @see com.gemstone.gemfire.cache.util.Gateway
* @see com.gemstone.gemfire.cache.wan.GatewaySender.OrderPolicy
* @since 1.7.0
*/
@SuppressWarnings("deprecation")
@@ -39,8 +39,8 @@ public class OrderPolicyTypeTest {
@Test
public void testStaticGetOrderPolicy() {
assertEquals(Gateway.OrderPolicy.KEY, OrderPolicyType.getOrderPolicy(OrderPolicyType.KEY));
assertEquals(Gateway.OrderPolicy.PARTITION, OrderPolicyType.getOrderPolicy(OrderPolicyType.PARTITION));
assertEquals(GatewaySender.OrderPolicy.KEY, OrderPolicyType.getOrderPolicy(OrderPolicyType.KEY));
assertEquals(GatewaySender.OrderPolicy.PARTITION, OrderPolicyType.getOrderPolicy(OrderPolicyType.PARTITION));
}
@Test
@@ -50,7 +50,7 @@ public class OrderPolicyTypeTest {
@Test
public void testValueOfGemFireOrderPolicies() {
for (Gateway.OrderPolicy orderPolicy : Gateway.OrderPolicy.values()) {
for (GatewaySender.OrderPolicy orderPolicy : GatewaySender.OrderPolicy.values()) {
OrderPolicyType orderPolicyType = OrderPolicyType.valueOf(orderPolicy);
assertNotNull(orderPolicyType);
@@ -60,7 +60,7 @@ public class OrderPolicyTypeTest {
@Test
public void testValueOfNullGemFireOrderPolicy() {
assertNull(OrderPolicyType.valueOf((Gateway.OrderPolicy) null));
assertNull(OrderPolicyType.valueOf((GatewaySender.OrderPolicy) null));
}
@Test

View File

@@ -1,85 +0,0 @@
/*
* Copyright 2010-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.gemfire.wan;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import org.junit.After;
import org.junit.Test;
/**
* The StartupPolicyConverterTest class is a test suite of test cases testing the contract and functionality
* of the StartupPolicyConverter class.
*
* @author John Blum
* @see org.junit.Test
* @see StartupPolicyType
* @see StartupPolicyConverter
* @since 1.6.0
*/
public class StartupPolicyConverterTest {
private StartupPolicyConverter converter = new StartupPolicyConverter();
@After
public void tearDown() {
converter.setValue(null);
}
@Test
public void testConvert() {
assertEquals(StartupPolicyType.NONE, converter.convert("none"));
assertEquals(StartupPolicyType.PRIMARY, converter.convert("Primary"));
assertEquals(StartupPolicyType.SECONDARY, converter.convert("SecONdARY"));
}
@Test(expected = IllegalArgumentException.class)
public void testConvertIllegalValue() {
try {
converter.convert("tertiary");
}
catch (IllegalArgumentException expected) {
assertEquals("(tertiary) is not a valid StartupPolicyType!", expected.getMessage());
throw expected;
}
}
@Test
public void testSetAsText() {
converter.setAsText("priMARY");
assertEquals(StartupPolicyType.PRIMARY, converter.getValue());
converter.setAsText("SecondAry");
assertEquals(StartupPolicyType.SECONDARY, converter.getValue());
}
@Test(expected = IllegalArgumentException.class)
public void testSetAsTextWithIllegalValue() {
try {
assertNull(converter.getValue());
converter.setAsText("invalid");
}
catch (IllegalArgumentException expected) {
assertEquals("(invalid) is not a valid StartupPolicyType!", expected.getMessage());
throw expected;
}
finally {
assertNull(converter.getValue());
}
}
}

View File

@@ -1,63 +0,0 @@
/*
* Copyright 2010-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.gemfire.wan;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import org.junit.Test;
import com.gemstone.gemfire.cache.util.GatewayHub;
/**
* The StartupPolicyTypeTest class is a test suite of test cases testing the contract and functionality
* of the StartupPolicyType enum.
*
* @author John Blum
* @see org.junit.Test
* @see StartupPolicyType
* @since 1.6.0
*/
@SuppressWarnings("deprecation")
public class StartupPolicyTypeTest {
@Test
public void testDefault() {
assertEquals(GatewayHub.DEFAULT_STARTUP_POLICY, StartupPolicyType.DEFAULT.getName());
assertSame(StartupPolicyType.NONE, StartupPolicyType.DEFAULT);
}
@Test
public void testValueOfIgnoreCase() {
assertEquals(StartupPolicyType.NONE, StartupPolicyType.valueOfIgnoreCase("NONE"));
assertEquals(StartupPolicyType.PRIMARY, StartupPolicyType.valueOfIgnoreCase("Primary"));
assertEquals(StartupPolicyType.SECONDARY, StartupPolicyType.valueOfIgnoreCase("secondary"));
assertEquals(StartupPolicyType.SECONDARY, StartupPolicyType.valueOfIgnoreCase("SECONDary"));
assertEquals(StartupPolicyType.PRIMARY, StartupPolicyType.valueOfIgnoreCase("PriMarY"));
}
@Test
public void testValueOfIgnoreCaseWithInvalidValues() {
assertNull(StartupPolicyType.valueOfIgnoreCase("NO"));
assertNull(StartupPolicyType.valueOfIgnoreCase("Prime"));
assertNull(StartupPolicyType.valueOfIgnoreCase("second"));
assertNull(StartupPolicyType.valueOfIgnoreCase("all"));
assertNull(StartupPolicyType.valueOfIgnoreCase("N0N3"));
}
}

View File

@@ -1,50 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:gfe="http://www.springframework.org/schema/gemfire"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/gemfire http://www.springframework.org/schema/gemfire/spring-gemfire.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
">
<util:properties id="gemfireProperties">
<prop key="name">GatewayHubNamespaceTest</prop>
<prop key="mcast-port">0</prop>
<prop key="log-level">warning</prop>
</util:properties>
<gfe:cache properties-ref="gemfireProperties"/>
<gfe:replicated-region id="Example" persistent="false" enable-gateway="true" hub-id="testGatewayHub"/>
<gfe:disk-store id="TestGatewayQueueDiskStore" auto-compact="true" allow-force-compaction="true" queue-size="50">
<gfe:disk-dir location="./gemfire/GatewayHubNamespaceTest/Gateway/Queue"/>
</gfe:disk-store>
<bean name="ListenerTwo" class="org.springframework.data.gemfire.config.GatewayHubNamespaceTest.TestGatewayListener" p:name="ListenerTwo"/>
<gfe:gateway-hub id="TestGatewayHub" bind-address="localhost" manual-start="true" max-connections="125"
max-time-between-pings="5000" port="45123" socket-buffer-size="16384" startup-policy="primary">
<gfe:gateway gateway-id="gateway1" concurrency-level="8" order-policy="thread" socket-buffer-size="65536"
socket-read-timeout="75000">
<gfe:gateway-listener>
<bean class="org.springframework.data.gemfire.config.GatewayHubNamespaceTest.TestGatewayListener" p:name="ListenerOne"/>
<ref bean="ListenerTwo"/>
</gfe:gateway-listener>
<gfe:gateway-queue alert-threshold="99" enable-batch-conflation="true" batch-size="3" batch-time-interval="10"
disk-store-ref="TestGatewayQueueDiskStore" maximum-queue-memory="5" persistent="false"/>
</gfe:gateway>
<gfe:gateway gateway-id="gateway2">
<gfe:gateway-endpoint endpoint-id="endpoint1" host="localhost" port="1234"/>
<gfe:gateway-endpoint endpoint-id="endpoint2" host="localhost" port="4321"/>
<gfe:gateway-queue batch-size="6" batch-time-interval="20" enable-batch-conflation="false" persistent="true"/>
</gfe:gateway>
<gfe:gateway gateway-id="gateway3">
<gfe:gateway-listener ref="ListenerTwo"/>
</gfe:gateway>
</gfe:gateway-hub>
</beans>

View File

@@ -1,40 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:gfe="http://www.springframework.org/schema/gemfire"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/gemfire http://www.springframework.org/schema/gemfire/spring-gemfire.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
" default-lazy-init="true">
<util:properties id="gemfireProperties">
<prop key="name">GatewayV6NamespaceConfig</prop>
<prop key="mcast-port">0</prop>
<prop key="log-level">warning</prop>
</util:properties>
<gfe:cache properties-ref="gemfireProperties" use-bean-factory-locator="false"/>
<gfe:replicated-region id="region-with-gateway" enable-gateway="true" hub-id="gateway-hub"/>
<gfe:gateway-hub id="gateway-hub" manual-start="true">
<gfe:gateway gateway-id="gateway">
<gfe:gateway-listener>
<bean class="org.springframework.data.gemfire.config.GemfireV6GatewayNamespaceTest.GatewayListener"/>
</gfe:gateway-listener>
<gfe:gateway-queue maximum-queue-memory="5" batch-size="3"
batch-time-interval="10" />
</gfe:gateway>
<gfe:gateway gateway-id="gateway2">
<gfe:gateway-endpoint port="1234" host="host1" endpoint-id="endpoint1"/>
<gfe:gateway-endpoint port="2345" host="host2" endpoint-id="endpoint2"/>
</gfe:gateway>
</gfe:gateway-hub>
<!-- SGF-169 -->
<gfe:gateway-hub id="uniDirectionalHub" manual-start="true" port="22222" startup-policy="none">
</gfe:gateway-hub>
</beans>