SGF-505 - Add support for forwardExpirationDestroy in the AsyncEventQueueFactoryBean API and XML namespace.

This commit is contained in:
John Blum
2016-06-20 15:08:52 -07:00
parent fbe1ef1080
commit a5d6777589
7 changed files with 81 additions and 72 deletions

View File

@@ -42,6 +42,7 @@ class AsyncEventQueueParser extends AbstractSingleBeanDefinitionParser {
@Override
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
builder.setLazyInit(false);
parseAsyncEventListener(element, parserContext, builder);
@@ -54,12 +55,11 @@ class AsyncEventQueueParser extends AbstractSingleBeanDefinitionParser {
ParsingUtils.setPropertyValue(element, builder, "batch-time-interval");
ParsingUtils.setPropertyValue(element, builder, "disk-synchronous");
ParsingUtils.setPropertyValue(element, builder, "dispatcher-threads");
ParsingUtils.setPropertyValue(element, builder, "ignore-eviction-and-expiration");
ParsingUtils.setPropertyValue(element, builder, "foward-expiration-destroy");
ParsingUtils.setPropertyValue(element, builder, "maximum-queue-memory");
ParsingUtils.setPropertyValue(element, builder, "order-policy");
ParsingUtils.setPropertyValue(element, builder, "parallel");
ParsingUtils.setPropertyValue(element, builder, "persistent");
ParsingUtils.setPropertyValue(element, builder, NAME_ATTRIBUTE);
if (!StringUtils.hasText(element.getAttribute(NAME_ATTRIBUTE))) {
@@ -82,8 +82,7 @@ class AsyncEventQueueParser extends AbstractSingleBeanDefinitionParser {
}
}
private void parseAsyncEventListener(final Element element, final ParserContext parserContext,
final BeanDefinitionBuilder builder) {
private void parseAsyncEventListener(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
Element asyncEventListenerElement = DomUtils.getChildElementByTagName(element, "async-event-listener");
@@ -97,7 +96,7 @@ class AsyncEventQueueParser extends AbstractSingleBeanDefinitionParser {
}
}
private void parseCache(final Element element, final BeanDefinitionBuilder builder) {
private void parseCache(Element element, BeanDefinitionBuilder builder) {
String cacheRefAttribute = element.getAttribute("cache-ref");
String cacheName = (StringUtils.hasText(cacheRefAttribute) ? cacheRefAttribute
@@ -106,7 +105,7 @@ class AsyncEventQueueParser extends AbstractSingleBeanDefinitionParser {
builder.addConstructorArgReference(cacheName);
}
private void parseDiskStore(final Element element, final BeanDefinitionBuilder builder) {
private void parseDiskStore(Element element, BeanDefinitionBuilder builder) {
ParsingUtils.setPropertyValue(element, builder, "disk-store-ref");
String diskStoreRef = element.getAttribute("disk-store-ref");
@@ -115,5 +114,4 @@ class AsyncEventQueueParser extends AbstractSingleBeanDefinitionParser {
builder.addDependsOn(diskStoreRef);
}
}
}

View File

@@ -26,7 +26,7 @@ import com.gemstone.gemfire.cache.wan.GatewaySender;
/**
* FactoryBean for creating GemFire {@link AsyncEventQueue}s.
*
*
* @author David Turanski
* @author John Blum
*/
@@ -39,7 +39,7 @@ public class AsyncEventQueueFactoryBean extends AbstractWANComponentFactoryBean<
private Boolean batchConflationEnabled;
private Boolean diskSynchronous;
private Boolean ignoreEvictionAndExpiration;
private Boolean forwardExpirationDestroy;
private Boolean parallel;
private Boolean persistent;
@@ -53,21 +53,21 @@ public class AsyncEventQueueFactoryBean extends AbstractWANComponentFactoryBean<
/**
* Constructs an instance of the AsyncEventQueueFactoryBean for creating an GemFire AsyncEventQueue.
*
*
* @param cache the GemFire Cache reference.
* @see #AsyncEventQueueFactoryBean(com.gemstone.gemfire.cache.Cache, com.gemstone.gemfire.cache.asyncqueue.AsyncEventListener)
*/
public AsyncEventQueueFactoryBean(final Cache cache) {
public AsyncEventQueueFactoryBean(Cache cache) {
this(cache, null);
}
/**
* Constructs an instance of the AsyncEventQueueFactoryBean for creating an GemFire AsyncEventQueue.
*
*
* @param cache the GemFire Cache reference.
* @param asyncEventListener required {@link AsyncEventListener}
*/
public AsyncEventQueueFactoryBean(final Cache cache, final AsyncEventListener asyncEventListener) {
public AsyncEventQueueFactoryBean(Cache cache, AsyncEventListener asyncEventListener) {
super(cache);
setAsyncEventListener(asyncEventListener);
}
@@ -79,12 +79,13 @@ public class AsyncEventQueueFactoryBean extends AbstractWANComponentFactoryBean<
@Override
public Class<?> getObjectType() {
return AsyncEventQueue.class;
return (asyncEventQueue != null ? asyncEventQueue.getClass() : AsyncEventQueue.class);
}
@Override
protected void doInit() {
Assert.notNull(this.asyncEventListener, "The AsyncEventListener cannot be null.");
Assert.notNull(this.asyncEventListener, "AsyncEventListener must not be null");
AsyncEventQueueFactory asyncEventQueueFactory = (this.factory != null ? (AsyncEventQueueFactory) factory
: cache.createAsyncEventQueueFactory());
@@ -113,8 +114,8 @@ public class AsyncEventQueueFactoryBean extends AbstractWANComponentFactoryBean<
asyncEventQueueFactory.setDiskSynchronous(diskSynchronous);
}
if (ignoreEvictionAndExpiration != null) {
asyncEventQueueFactory.setIgnoreEvictionAndExpiration(ignoreEvictionAndExpiration);
if (forwardExpirationDestroy != null) {
asyncEventQueueFactory.setForwardExpirationDestroy(forwardExpirationDestroy);
}
if (maximumQueueMemory != null) {
@@ -124,10 +125,10 @@ public class AsyncEventQueueFactoryBean extends AbstractWANComponentFactoryBean<
asyncEventQueueFactory.setParallel(isParallelEventQueue());
if (orderPolicy != null) {
Assert.isTrue(isSerialEventQueue(), "Order Policy cannot be used with a Parallel Event Queue.");
Assert.isTrue(isSerialEventQueue(), "Order Policy cannot be used with a Parallel Event Queue");
Assert.isTrue(VALID_ORDER_POLICIES.contains(orderPolicy.toUpperCase()), String.format(
"The value of Order Policy '$1%s' is invalid.", orderPolicy));
"The value of Order Policy '$1%s' is invalid", orderPolicy));
asyncEventQueueFactory.setOrderPolicy(GatewaySender.OrderPolicy.valueOf(orderPolicy.toUpperCase()));
}
@@ -152,7 +153,8 @@ public class AsyncEventQueueFactoryBean extends AbstractWANComponentFactoryBean<
public final void setAsyncEventListener(AsyncEventListener listener) {
Assert.state(this.asyncEventQueue == null,
"Setting an AsyncEventListener is not allowed once the AsyncEventQueue has been created.");
"Setting an AsyncEventListener is not allowed once the AsyncEventQueue has been created");
this.asyncEventListener = listener;
}
@@ -209,9 +211,19 @@ public class AsyncEventQueueFactoryBean extends AbstractWANComponentFactoryBean<
this.dispatcherThreads = dispatcherThreads;
}
/* (non-Javadoc) */
public void setIgnoreEvictionAndExpiration(Boolean ignoreEvictionAndExpiration) {
this.ignoreEvictionAndExpiration = ignoreEvictionAndExpiration;
/**
* Forwards expiration (action-based) destroy events to the {@link AsyncEventQueue} (AEQ).
*
* By default, destroy events are not added to the AEQ. Setting this attribute to
* {@literal true} will add all expiration destroy events to the AEQ.
*
* @param forwardExpirationDestroy boolean value indicating whether to forward expiration destroy events.
* @see com.gemstone.gemfire.cache.asyncqueue.AsyncEventQueueFactory#setForwardExpirationDestroy(boolean)
* @see com.gemstone.gemfire.cache.ExpirationAttributes#getAction()
* @see com.gemstone.gemfire.cache.ExpirationAction#DESTROY
*/
public void setForwardExpirationDestroy(Boolean forwardExpirationDestroy) {
this.forwardExpirationDestroy = forwardExpirationDestroy;
}
public void setMaximumQueueMemory(Integer maximumQueueMemory) {
@@ -233,14 +245,14 @@ public class AsyncEventQueueFactoryBean extends AbstractWANComponentFactoryBean<
this.parallel = parallel;
}
public boolean isSerialEventQueue() {
return !isParallelEventQueue();
}
public boolean isParallelEventQueue() {
return Boolean.TRUE.equals(parallel);
}
public boolean isSerialEventQueue() {
return !isParallelEventQueue();
}
public void setPersistent(Boolean persistent) {
this.persistent = persistent;
}