upgraded to 1.2.1 - GemFire 7.0 support
This commit is contained in:
@@ -48,6 +48,7 @@ import com.gemstone.gemfire.cache.DynamicRegionFactory;
|
||||
import com.gemstone.gemfire.cache.GemFireCache;
|
||||
import com.gemstone.gemfire.cache.TransactionListener;
|
||||
import com.gemstone.gemfire.cache.TransactionWriter;
|
||||
import com.gemstone.gemfire.cache.util.GatewayConflictResolver;
|
||||
import com.gemstone.gemfire.distributed.DistributedMember;
|
||||
import com.gemstone.gemfire.distributed.DistributedSystem;
|
||||
import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
|
||||
@@ -130,6 +131,10 @@ public class CacheFactoryBean implements BeanNameAware, BeanFactoryAware, BeanCl
|
||||
if (messageSyncInterval != null) {
|
||||
cacheImpl.setMessageSyncInterval(messageSyncInterval);
|
||||
}
|
||||
|
||||
if (gatewayConflictResolver != null) {
|
||||
cacheImpl.setGatewayConflictResolver((GatewayConflictResolver) gatewayConflictResolver);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -259,6 +264,9 @@ public class CacheFactoryBean implements BeanNameAware, BeanFactoryAware, BeanCl
|
||||
|
||||
protected List<JndiDataSource> jndiDataSources;
|
||||
|
||||
// Defined this way for backward compatibility
|
||||
protected Object gatewayConflictResolver;
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
// initialize locator
|
||||
@@ -647,6 +655,15 @@ public class CacheFactoryBean implements BeanNameAware, BeanFactoryAware, BeanCl
|
||||
public void setTransactionWriter(TransactionWriter transactionWriter) {
|
||||
this.transactionWriter = transactionWriter;
|
||||
}
|
||||
/**
|
||||
* Requires GemFire 7.0 or higher
|
||||
* @param gatewayConflictResolver defined as Object in the signature for backward
|
||||
* compatibility with Gemfire 6 compatibility. This must be an instance of
|
||||
* {@link com.gemstone.gemfire.cache.util.GatewayConflictResolver}
|
||||
*/
|
||||
public void setGatewayConflictResolver(Object gatewayConflictResolver) {
|
||||
this.gatewayConflictResolver = gatewayConflictResolver;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -663,4 +680,4 @@ public class CacheFactoryBean implements BeanNameAware, BeanFactoryAware, BeanCl
|
||||
public void setJndiDataSources(List<JndiDataSource> jndiDataSources) {
|
||||
this.jndiDataSources = jndiDataSources;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
import com.gemstone.gemfire.cache.asyncqueue.AsyncEventQueue;
|
||||
import com.gemstone.gemfire.cache.AttributesFactory;
|
||||
import com.gemstone.gemfire.cache.Cache;
|
||||
import com.gemstone.gemfire.cache.CacheClosedException;
|
||||
@@ -39,6 +40,7 @@ import com.gemstone.gemfire.cache.Region;
|
||||
import com.gemstone.gemfire.cache.RegionAttributes;
|
||||
import com.gemstone.gemfire.cache.RegionFactory;
|
||||
import com.gemstone.gemfire.cache.Scope;
|
||||
import com.gemstone.gemfire.cache.wan.GatewaySender;
|
||||
|
||||
/**
|
||||
* Base class for FactoryBeans used to create GemFire {@link Region}s. Will try
|
||||
@@ -69,6 +71,10 @@ public class RegionFactoryBean<K, V> extends RegionLookupFactoryBean<K, V> imple
|
||||
|
||||
private CacheWriter<K, V> cacheWriter;
|
||||
|
||||
private Object gatewaySenders[];
|
||||
|
||||
private Object asyncEventQueues[];
|
||||
|
||||
private RegionAttributes<K, V> attributes;
|
||||
|
||||
private Scope scope;
|
||||
@@ -98,10 +104,9 @@ public class RegionFactoryBean<K, V> extends RegionLookupFactoryBean<K, V> imple
|
||||
|
||||
Cache c = (Cache) cache;
|
||||
|
||||
if (attributes != null) {
|
||||
if (attributes != null)
|
||||
AttributesFactory.validateAttributes(attributes);
|
||||
}
|
||||
|
||||
|
||||
final RegionFactory<K, V> regionFactory = (attributes != null ? c.createRegionFactory(attributes) : c
|
||||
.<K, V> createRegionFactory());
|
||||
|
||||
@@ -111,17 +116,33 @@ public class RegionFactoryBean<K, V> extends RegionLookupFactoryBean<K, V> imple
|
||||
|
||||
regionFactory.setGatewayHubId(hubId);
|
||||
}
|
||||
|
||||
if (enableGateway !=null) {
|
||||
if (enableGateway != null) {
|
||||
if (enableGateway) {
|
||||
Assert.notNull(hubId, "enableGateway requires the hubId property to be true");
|
||||
}
|
||||
regionFactory.setEnableGateway(enableGateway);
|
||||
}
|
||||
|
||||
if (!ObjectUtils.isEmpty(cacheListeners)) {
|
||||
for (CacheListener<K, V> listener : cacheListeners) {
|
||||
regionFactory.addCacheListener(listener);
|
||||
}
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
if (!ObjectUtils.isEmpty(asyncEventQueues)) {
|
||||
for (Object asyncEventQueue : asyncEventQueues) {
|
||||
regionFactory.addAsyncEventQueueId(((AsyncEventQueue) asyncEventQueue).getId());
|
||||
}
|
||||
}
|
||||
|
||||
if (cacheLoader != null) {
|
||||
regionFactory.setCacheLoader(cacheLoader);
|
||||
}
|
||||
@@ -349,6 +370,24 @@ public class RegionFactoryBean<K, V> extends RegionLookupFactoryBean<K, V> imple
|
||||
this.diskStoreName = diskStoreName;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param gatewaySenders defined as Object for backward compatibility with
|
||||
* Gemfire 6
|
||||
*/
|
||||
public void setGatewaySenders(Object[] gatewaySenders) {
|
||||
this.gatewaySenders = gatewaySenders;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param asyncEventQueues defined as Object for backward compatibility with
|
||||
* Gemfire 6
|
||||
*/
|
||||
public void setAsyncEventQueues(Object[] asyncEventQueues) {
|
||||
this.asyncEventQueues = asyncEventQueues;
|
||||
}
|
||||
|
||||
public void setEnableGateway(boolean enableGateway) {
|
||||
this.enableGateway = enableGateway;
|
||||
}
|
||||
@@ -375,4 +414,4 @@ public class RegionFactoryBean<K, V> extends RegionLookupFactoryBean<K, V> imple
|
||||
protected boolean isNotPersistent() {
|
||||
return persistent != null && !persistent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright 2010-2012 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 org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.data.gemfire.wan.AsyncEventQueueFactoryBean;
|
||||
import org.springframework.util.xml.DomUtils;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import com.gemstone.gemfire.internal.lang.StringUtils;
|
||||
|
||||
/**
|
||||
* @author David Turanski
|
||||
*
|
||||
*/
|
||||
public class AsyncEventQueueParser extends AbstractSingleBeanDefinitionParser {
|
||||
|
||||
@Override
|
||||
protected Class<?> getBeanClass(Element element) {
|
||||
return AsyncEventQueueFactoryBean.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
|
||||
builder.setLazyInit(false);
|
||||
Element asyncEventListenerElement = DomUtils.getChildElementByTagName(element, "async-event-listener");
|
||||
Object asyncEventListener = ParsingUtils.parseRefOrSingleNestedBeanDeclaration(parserContext,
|
||||
asyncEventListenerElement, builder);
|
||||
String cacheName = StringUtils.isEmpty(element.getAttribute("cache-ref")) ? "gemfireCache" : element
|
||||
.getAttribute("cache-ref");
|
||||
builder.addConstructorArgReference(cacheName);
|
||||
builder.addConstructorArgValue(asyncEventListener);
|
||||
ParsingUtils.setPropertyValue(element, builder, "batch-size");
|
||||
ParsingUtils.setPropertyValue(element, builder, "maximum-queue-memory");
|
||||
ParsingUtils.setPropertyValue(element, builder, "disk-store-ref");
|
||||
ParsingUtils.setPropertyValue(element, builder, "persistent");
|
||||
ParsingUtils.setPropertyValue(element, builder, "parallel");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright 2010-2012 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 org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.xml.AbstractSimpleBeanDefinitionParser;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.data.gemfire.wan.GatewayReceiverFactoryBean;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
* @author David Turanski
|
||||
*
|
||||
*/
|
||||
class GatewayReceiverParser extends AbstractSimpleBeanDefinitionParser {
|
||||
@Override
|
||||
protected Class<?> getBeanClass(Element element) {
|
||||
return GatewayReceiverFactoryBean.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
|
||||
builder.setLazyInit(false);
|
||||
String cacheRef = element.getAttribute("cache-ref");
|
||||
// add cache reference (fallback to default if nothing is specified)
|
||||
builder.addConstructorArgReference((StringUtils.hasText(cacheRef) ? cacheRef : "gemfireCache"));
|
||||
ParsingUtils.setPropertyValue(element, builder, "start-port");
|
||||
ParsingUtils.setPropertyValue(element, builder, "end-port");
|
||||
ParsingUtils.setPropertyValue(element, builder, "socket-buffer-size");
|
||||
ParsingUtils.setPropertyValue(element, builder, "maximum-time-between-pings");
|
||||
ParsingUtils.setPropertyValue(element, builder, "bind-address");
|
||||
ParsingUtils.parseTransportFilters(element, parserContext, builder);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright 2010-2012 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 org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.xml.AbstractSimpleBeanDefinitionParser;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.data.gemfire.wan.GatewaySenderFactoryBean;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.util.xml.DomUtils;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
* @author David Turanski
|
||||
*
|
||||
*/
|
||||
class GatewaySenderParser extends AbstractSimpleBeanDefinitionParser {
|
||||
|
||||
@Override
|
||||
protected Class<?> getBeanClass(Element element) {
|
||||
return GatewaySenderFactoryBean.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
|
||||
builder.setLazyInit(false);
|
||||
String cacheRef = element.getAttribute("cache-ref");
|
||||
// add cache reference (fallback to default if nothing is specified)
|
||||
builder.addConstructorArgReference((StringUtils.hasText(cacheRef) ? cacheRef : "gemfireCache"));
|
||||
ParsingUtils.setPropertyValue(element, builder, "alert-threshold");
|
||||
ParsingUtils.setPropertyValue(element, builder, "batch-size");
|
||||
ParsingUtils.setPropertyValue(element, builder, "batch-time-interval");
|
||||
ParsingUtils.setPropertyValue(element, builder, "disk-store-ref");
|
||||
ParsingUtils.setPropertyValue(element, builder, "disk-synchronous");
|
||||
ParsingUtils.setPropertyValue(element, builder, "dispatcher-threads");
|
||||
ParsingUtils.setPropertyValue(element, builder, "enable-batch-conflation");
|
||||
ParsingUtils.setPropertyValue(element, builder, "manual-start");
|
||||
ParsingUtils.setPropertyValue(element, builder, "maximum-queue-memory");
|
||||
ParsingUtils.setPropertyValue(element, builder, "order-policy");
|
||||
ParsingUtils.setPropertyValue(element, builder, "remote-distributed-system-id");
|
||||
ParsingUtils.setPropertyValue(element, builder, "socket-buffer-size");
|
||||
ParsingUtils.setPropertyValue(element, builder, "socket-read-timeout");
|
||||
ParsingUtils.setPropertyValue(element, builder, "persistent");
|
||||
ParsingUtils.setPropertyValue(element, builder, "parallel");
|
||||
|
||||
Element eventFilterElement = DomUtils.getChildElementByTagName(element, "event-filter");
|
||||
if (eventFilterElement != null) {
|
||||
builder.addPropertyValue("eventFilters",
|
||||
ParsingUtils.parseRefOrNestedBeanDeclaration(parserContext, eventFilterElement, builder));
|
||||
}
|
||||
|
||||
ParsingUtils.parseTransportFilters(element, parserContext, builder);
|
||||
}
|
||||
}
|
||||
@@ -61,8 +61,11 @@ class GemfireNamespaceHandler extends NamespaceHandlerSupport {
|
||||
registerBeanDefinitionParser("cache-server", new CacheServerParser());
|
||||
registerBeanDefinitionParser("transaction-manager", new TransactionManagerParser());
|
||||
registerBeanDefinitionParser("cq-listener-container", new GemfireListenerContainerParser());
|
||||
registerBeanDefinitionParser("async-event-queue", new AsyncEventQueueParser());
|
||||
registerBeanDefinitionParser("gateway-sender", new GatewaySenderParser());
|
||||
registerBeanDefinitionParser("gateway-receiver", new GatewayReceiverParser());
|
||||
registerBeanDefinitionParser("function-service", new FunctionServiceParser());
|
||||
// V6 WAN parsers
|
||||
registerBeanDefinitionParser("gateway-hub", new GatewayHubParser());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
* Copyright 2010-2012 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.util.Assert;
|
||||
|
||||
import com.gemstone.gemfire.cache.asyncqueue.AsyncEventQueue;
|
||||
import com.gemstone.gemfire.cache.asyncqueue.AsyncEventQueueFactory;
|
||||
import com.gemstone.gemfire.cache.Cache;
|
||||
import com.gemstone.gemfire.cache.CacheClosedException;
|
||||
import com.gemstone.gemfire.cache.asyncqueue.AsyncEventListener;
|
||||
|
||||
/**
|
||||
* FactoryBean for creating GemFire {@link AsyncEventQueue}s.
|
||||
* @author David Turanski
|
||||
*
|
||||
*/
|
||||
public class AsyncEventQueueFactoryBean extends AbstractWANComponentFactoryBean<AsyncEventQueue> {
|
||||
|
||||
public void setDiskStoreRef(String diskStoreRef) {
|
||||
this.diskStoreRef = diskStoreRef;
|
||||
}
|
||||
|
||||
private final AsyncEventListener asyncEventListener;
|
||||
|
||||
private AsyncEventQueue asyncEventQueue;
|
||||
|
||||
private Integer batchSize;
|
||||
|
||||
private Integer maximumQueueMemory;
|
||||
|
||||
private Boolean persistent;
|
||||
|
||||
private String diskStoreRef;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param cache the gemfire cache
|
||||
* @param asyncEventListener required {@link AsyncEventListener}
|
||||
*/
|
||||
public AsyncEventQueueFactoryBean(Cache cache, AsyncEventListener asyncEventListener) {
|
||||
super(cache);
|
||||
this.asyncEventListener = asyncEventListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AsyncEventQueue getObject() throws Exception {
|
||||
return asyncEventQueue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getObjectType() {
|
||||
return AsyncEventQueue.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doInit() {
|
||||
Assert.notNull(asyncEventListener, "AsyncEventListener cannot be null");
|
||||
AsyncEventQueueFactory asyncEventQueueFactory = null;
|
||||
if (this.factory == null) {
|
||||
asyncEventQueueFactory = cache.createAsyncEventQueueFactory();
|
||||
} else {
|
||||
asyncEventQueueFactory = (AsyncEventQueueFactory)factory;
|
||||
}
|
||||
|
||||
if (persistent != null) {
|
||||
asyncEventQueueFactory.setPersistent(persistent);
|
||||
}
|
||||
if (batchSize != null) {
|
||||
asyncEventQueueFactory.setBatchSize(batchSize);
|
||||
}
|
||||
if (diskStoreRef != null) {
|
||||
persistent = (persistent == null) ? Boolean.TRUE : persistent;
|
||||
Assert.isTrue(persistent, "specifying a disk store requires persistent property to be true");
|
||||
asyncEventQueueFactory.setDiskStoreName(diskStoreRef);
|
||||
}
|
||||
|
||||
if (maximumQueueMemory != null) {
|
||||
asyncEventQueueFactory.setMaximumQueueMemory(maximumQueueMemory);
|
||||
}
|
||||
|
||||
asyncEventQueue = asyncEventQueueFactory.create(name, asyncEventListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() throws Exception {
|
||||
if (!cache.isClosed()) {
|
||||
try {
|
||||
asyncEventListener.close();
|
||||
}
|
||||
catch (CacheClosedException cce) {
|
||||
// nothing to see folks, move on.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setBatchSize(Integer batchSize) {
|
||||
this.batchSize = batchSize;
|
||||
}
|
||||
|
||||
public void setMaximumQueueMemory(Integer maximumQueueMemory) {
|
||||
this.maximumQueueMemory = maximumQueueMemory;
|
||||
}
|
||||
|
||||
public void setPersistent(Boolean persistent) {
|
||||
this.persistent = persistent;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* Copyright 2010-2012 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.List;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import com.gemstone.gemfire.cache.Cache;
|
||||
import com.gemstone.gemfire.cache.wan.GatewayReceiver;
|
||||
import com.gemstone.gemfire.cache.wan.GatewayReceiverFactory;
|
||||
import com.gemstone.gemfire.cache.wan.GatewayTransportFilter;
|
||||
|
||||
/**
|
||||
* FactoryBean for creating a GemFire {@link GatewayReceiver}.
|
||||
*
|
||||
* @author David Turanski
|
||||
*
|
||||
*/
|
||||
public class GatewayReceiverFactoryBean extends AbstractWANComponentFactoryBean<GatewayReceiver> {
|
||||
private GatewayReceiver gatewayReceiver;
|
||||
|
||||
private List<GatewayTransportFilter> transportFilters;
|
||||
|
||||
private Integer startPort;
|
||||
|
||||
private Integer endPort;
|
||||
|
||||
private Integer maximumTimeBetweenPings;
|
||||
|
||||
private Integer socketBufferSize;
|
||||
|
||||
private String bindAddress;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param cache
|
||||
*/
|
||||
public GatewayReceiverFactoryBean(Cache cache) {
|
||||
super(cache);
|
||||
// Bean name not required.
|
||||
this.name = "gateway-receiver";
|
||||
}
|
||||
|
||||
@Override
|
||||
public GatewayReceiver getObject() throws Exception {
|
||||
return gatewayReceiver;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getObjectType() {
|
||||
return GatewayReceiver.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doInit() {
|
||||
GatewayReceiverFactory gatewayReceiverFactory = cache.createGatewayReceiverFactory();
|
||||
if (!CollectionUtils.isEmpty(transportFilters)) {
|
||||
for (GatewayTransportFilter transportFilter : transportFilters) {
|
||||
gatewayReceiverFactory.addGatewayTransportFilter(transportFilter);
|
||||
}
|
||||
}
|
||||
int minPort = (startPort == null) ? GatewayReceiver.DEFAULT_START_PORT : startPort;
|
||||
int maxPort = (endPort == null) ? GatewayReceiver.DEFAULT_END_PORT : endPort;
|
||||
Assert.isTrue(minPort <= maxPort, "startPort must be less then or equal to " + maxPort);
|
||||
gatewayReceiverFactory.setStartPort(minPort);
|
||||
gatewayReceiverFactory.setEndPort(maxPort);
|
||||
if (socketBufferSize != null) {
|
||||
gatewayReceiverFactory.setSocketBufferSize(socketBufferSize);
|
||||
}
|
||||
if (maximumTimeBetweenPings != null) {
|
||||
gatewayReceiverFactory.setMaximumTimeBetweenPings(maximumTimeBetweenPings);
|
||||
}
|
||||
if (bindAddress != null) {
|
||||
gatewayReceiverFactory.setBindAddress(bindAddress);
|
||||
}
|
||||
|
||||
gatewayReceiver = gatewayReceiverFactory.create();
|
||||
}
|
||||
|
||||
public void setGatewayReceiver(GatewayReceiver gatewayReceiver) {
|
||||
this.gatewayReceiver = gatewayReceiver;
|
||||
}
|
||||
|
||||
public void setTransportFilters(List<GatewayTransportFilter> transportFilters) {
|
||||
this.transportFilters = transportFilters;
|
||||
}
|
||||
|
||||
public void setStartPort(Integer startPort) {
|
||||
this.startPort = startPort;
|
||||
}
|
||||
|
||||
public void setEndPort(Integer endPort) {
|
||||
this.endPort = endPort;
|
||||
}
|
||||
|
||||
public void setMaximumTimeBetweenPings(Integer maximumTimeBetweenPings) {
|
||||
this.maximumTimeBetweenPings = maximumTimeBetweenPings;
|
||||
}
|
||||
|
||||
public void setSocketBufferSize(Integer socketBufferSize) {
|
||||
this.socketBufferSize = socketBufferSize;
|
||||
}
|
||||
|
||||
public void setBindAddress(String bindAddress) {
|
||||
this.bindAddress = bindAddress;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,237 @@
|
||||
/*
|
||||
* Copyright 2010-2012 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.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
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.GatewaySender;
|
||||
import com.gemstone.gemfire.cache.wan.GatewaySenderFactory;
|
||||
import com.gemstone.gemfire.cache.wan.GatewayTransportFilter;
|
||||
|
||||
/**
|
||||
* FactoryBean for creating a GemFire {@link GatewaySender}.
|
||||
* @author David Turanski
|
||||
*
|
||||
*/
|
||||
public class GatewaySenderFactoryBean extends AbstractWANComponentFactoryBean<GatewaySender> {
|
||||
private static List<String> validOrderPolicyValues = Arrays.asList("KEY", "PARTITION", "THREAD");
|
||||
|
||||
private GatewaySender gatewaySender;
|
||||
|
||||
private int remoteDistributedSystemId;
|
||||
|
||||
private List<GatewayEventFilter> eventFilters;
|
||||
|
||||
private List<GatewayTransportFilter> transportFilters;
|
||||
|
||||
private Integer alertThreshold;
|
||||
|
||||
private Boolean enableBatchConflation;
|
||||
|
||||
private Integer batchSize;
|
||||
|
||||
private Integer batchTimeInterval;
|
||||
|
||||
private String diskStoreRef;
|
||||
|
||||
private Boolean diskSynchronous;
|
||||
|
||||
private Integer dispatcherThreads;
|
||||
|
||||
private Boolean manualStart;
|
||||
|
||||
private Integer maximumQueueMemory;
|
||||
|
||||
private String orderPolicy;
|
||||
|
||||
private Boolean parallel;
|
||||
|
||||
private Boolean persistent;
|
||||
|
||||
private Integer socketBufferSize;
|
||||
|
||||
private Integer socketReadTimeout;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param cache the Gemfire cache
|
||||
*/
|
||||
public GatewaySenderFactoryBean(Cache cache) {
|
||||
super(cache);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GatewaySender getObject() throws Exception {
|
||||
return gatewaySender;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getObjectType() {
|
||||
return GatewaySender.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doInit() {
|
||||
GatewaySenderFactory gatewaySenderFactory = null;
|
||||
if (this.factory == null) {
|
||||
gatewaySenderFactory = cache.createGatewaySenderFactory();
|
||||
} else {
|
||||
gatewaySenderFactory = (GatewaySenderFactory)factory;
|
||||
}
|
||||
if (diskStoreRef != null) {
|
||||
persistent = (persistent == null) ? Boolean.TRUE : persistent;
|
||||
Assert.isTrue(persistent, "specifying a disk store requires persistent property to be true");
|
||||
gatewaySenderFactory.setDiskStoreName(diskStoreRef);
|
||||
}
|
||||
|
||||
if (diskSynchronous != null) {
|
||||
persistent = (persistent == null) ? Boolean.TRUE : persistent;
|
||||
Assert.isTrue(persistent, "specifying a disk synchronous requires persistent property to be true");
|
||||
gatewaySenderFactory.setDiskSynchronous(diskSynchronous);
|
||||
}
|
||||
|
||||
if (persistent != null) {
|
||||
gatewaySenderFactory.setPersistenceEnabled(persistent);
|
||||
}
|
||||
|
||||
parallel = (parallel == null) ? Boolean.FALSE : parallel;
|
||||
|
||||
gatewaySenderFactory.setParallel(parallel);
|
||||
|
||||
if (orderPolicy != null) {
|
||||
Assert.isTrue(parallel, "specifying an order policy requires the parallel property to be true");
|
||||
|
||||
Assert.isTrue(validOrderPolicyValues.contains(orderPolicy.toUpperCase()), "The value of order policy:'"
|
||||
+ orderPolicy + "' is invalid");
|
||||
gatewaySenderFactory.setOrderPolicy(Gateway.OrderPolicy.valueOf(orderPolicy.toUpperCase()));
|
||||
}
|
||||
|
||||
if (!CollectionUtils.isEmpty(eventFilters)) {
|
||||
for (GatewayEventFilter eventFilter : eventFilters) {
|
||||
gatewaySenderFactory.addGatewayEventFilter(eventFilter);
|
||||
}
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(transportFilters)) {
|
||||
for (GatewayTransportFilter transportFilter : transportFilters) {
|
||||
gatewaySenderFactory.addGatewayTransportFilter(transportFilter);
|
||||
}
|
||||
}
|
||||
if (alertThreshold != null) {
|
||||
gatewaySenderFactory.setAlertThreshold(alertThreshold);
|
||||
}
|
||||
if (enableBatchConflation != null) {
|
||||
gatewaySenderFactory.setBatchConflationEnabled(enableBatchConflation);
|
||||
}
|
||||
if (batchSize != null) {
|
||||
gatewaySenderFactory.setBatchSize(batchSize);
|
||||
}
|
||||
if (batchTimeInterval != null) {
|
||||
gatewaySenderFactory.setBatchTimeInterval(batchTimeInterval);
|
||||
}
|
||||
if (dispatcherThreads != null) {
|
||||
gatewaySenderFactory.setDispatcherThreads(dispatcherThreads);
|
||||
}
|
||||
if (manualStart != null) {
|
||||
gatewaySenderFactory.setManualStart(manualStart);
|
||||
}
|
||||
if (maximumQueueMemory != null) {
|
||||
gatewaySenderFactory.setMaximumQueueMemory(maximumQueueMemory);
|
||||
}
|
||||
if (socketBufferSize != null) {
|
||||
gatewaySenderFactory.setSocketBufferSize(socketBufferSize);
|
||||
}
|
||||
if (socketReadTimeout != null) {
|
||||
gatewaySenderFactory.setSocketReadTimeout(socketReadTimeout);
|
||||
}
|
||||
gatewaySender = gatewaySenderFactory.create(name, remoteDistributedSystemId);
|
||||
}
|
||||
|
||||
public void setRemoteDistributedSystemId(int remoteDistributedSystemId) {
|
||||
this.remoteDistributedSystemId = remoteDistributedSystemId;
|
||||
}
|
||||
|
||||
public void setEventFilters(List<GatewayEventFilter> gatewayEventFilters) {
|
||||
this.eventFilters = gatewayEventFilters;
|
||||
}
|
||||
|
||||
public void setTransportFilters(List<GatewayTransportFilter> gatewayTransportFilters) {
|
||||
this.transportFilters = gatewayTransportFilters;
|
||||
}
|
||||
|
||||
public void setAlertThreshold(Integer alertThreshold) {
|
||||
this.alertThreshold = alertThreshold;
|
||||
}
|
||||
|
||||
public void setEnableBatchConflation(Boolean enableBatchConflation) {
|
||||
this.enableBatchConflation = enableBatchConflation;
|
||||
}
|
||||
|
||||
public void setBatchSize(Integer batchSize) {
|
||||
this.batchSize = batchSize;
|
||||
}
|
||||
|
||||
public void setBatchTimeInterval(Integer batchTimeInterval) {
|
||||
this.batchTimeInterval = batchTimeInterval;
|
||||
}
|
||||
|
||||
public void setDiskStoreRef(String diskStoreRef) {
|
||||
this.diskStoreRef = diskStoreRef;
|
||||
}
|
||||
|
||||
public void setDiskSynchronous(Boolean diskSynchronous) {
|
||||
this.diskSynchronous = diskSynchronous;
|
||||
}
|
||||
|
||||
public void setDispatcherThreads(Integer dispatcherThreads) {
|
||||
this.dispatcherThreads = dispatcherThreads;
|
||||
}
|
||||
|
||||
public void setManualStart(Boolean manualStart) {
|
||||
this.manualStart = manualStart;
|
||||
}
|
||||
|
||||
public void setMaximumQueueMemory(Integer maximumQueueMemory) {
|
||||
this.maximumQueueMemory = maximumQueueMemory;
|
||||
}
|
||||
|
||||
public void setOrderPolicy(String orderPolicy) {
|
||||
this.orderPolicy = orderPolicy;
|
||||
}
|
||||
|
||||
public void setParallel(Boolean parallel) {
|
||||
this.parallel = parallel;
|
||||
}
|
||||
|
||||
public void setPersistent(Boolean persistent) {
|
||||
this.persistent = persistent;
|
||||
}
|
||||
|
||||
public void setSocketBufferSize(Integer socketBufferSize) {
|
||||
this.socketBufferSize = socketBufferSize;
|
||||
}
|
||||
|
||||
public void setSocketReadTimeout(Integer socketReadTimeout) {
|
||||
this.socketReadTimeout = socketReadTimeout;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user