merge 1.2.2

This commit is contained in:
David Turanski
2012-12-10 08:21:12 -05:00
parent 0a2fcb7324
commit c9de0477f9
7 changed files with 221 additions and 26 deletions

View File

@@ -142,10 +142,10 @@ abstract class AbstractRegionParser extends AliasReplacingBeanDefinitionParser {
// Parse child elements
parseCollectionOfCustomSubElements(parserContext, element, builder,
"com.gemstone.gemfire.cache.wan.GatewaySender", "gateway-sender","gatewaySenders");
parseCollectionOfCustomSubElements(parserContext, element, builder,
"com.gemstone.gemfire.cache.wan.GatewaySender", "gateway-sender", "gatewaySenders");
parseCollectionOfCustomSubElements(parserContext, element, builder,
"com.gemstone.gemfire.cache.wan.AsyncEventQueue", "async-event-queue", "asyncEventQueues");
"com.gemstone.gemfire.cache.asyncqueue.AsyncEventQueue", "async-event-queue", "asyncEventQueues");
List<Element> subElements = DomUtils.getChildElements(element);
for (Element subElement : subElements) {

View File

@@ -284,6 +284,8 @@ abstract class ParsingUtils {
result |= parseExpiration(element, "region-tti", "regionIdleTimeout", attrBuilder);
result |= parseExpiration(element, "entry-ttl", "entryTimeToLive", attrBuilder);
result |= parseExpiration(element, "entry-tti", "entryIdleTimeout", attrBuilder);
result |= parseCustomExpiration(parserContext, element,"custom-entry-ttl","customEntryTimeToLive",attrBuilder);
result |= parseCustomExpiration(parserContext, element,"custom-entry-tti","customEntryIdleTimeout",attrBuilder);
if (result) {
// turn on statistics
@@ -422,4 +424,18 @@ abstract class ParsingUtils {
return true;
}
private static boolean parseCustomExpiration(ParserContext parserContext, Element rootElement, String elementName, String propertyName,
BeanDefinitionBuilder attrBuilder) {
Element expirationElement = DomUtils.getChildElementByTagName(rootElement, elementName);
if (expirationElement == null)
return false;
Object customExpiry = parseRefOrSingleNestedBeanDeclaration(parserContext, expirationElement, attrBuilder);
attrBuilder.addPropertyValue(propertyName, customExpiry);
return true;
}
}

View File

@@ -37,7 +37,7 @@ class ReplicatedRegionParser extends AbstractRegionParser {
BeanDefinitionBuilder attrBuilder = subRegion ? builder : BeanDefinitionBuilder
.genericBeanDefinition(RegionAttributesFactoryBean.class);
super.doParseCommonRegionConfiguration(element, parserContext, builder, attrBuilder, subRegion);
if (!subRegion) {
builder.addPropertyValue("attributes", attrBuilder.getBeanDefinition());

View File

@@ -756,22 +756,57 @@ Time to idle (or idle timeout) configuration for the region itself. Default: no
]]></xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="entry-ttl" type="expirationType"
<xsd:choice>
<xsd:element name="entry-ttl" type="expirationType"
minOccurs="0" maxOccurs="1">
<xsd:annotation>
<xsd:annotation>
<xsd:documentation><![CDATA[[
Time to live configuration for the region entries. Default: no expiration.
]]></xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="entry-tti" type="expirationType"
</xsd:annotation>
</xsd:element>
<xsd:element name="custom-entry-ttl" type="customExpirationType"
minOccurs="0" maxOccurs="1">
<xsd:annotation>
<xsd:appinfo>
<tool:annotation>
<tool:exports
type="com.gemstone.gemfire.cache.CustomExpiry" />
</tool:annotation>
</xsd:appinfo>
<xsd:documentation><![CDATA[[
CustomExpiry time to live configuration for the region entries. Default: no expiration.
]]></xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:choice>
<xsd:choice>
<xsd:element name="entry-tti" type="expirationType"
minOccurs="0" maxOccurs="1">
<xsd:annotation>
<xsd:annotation>
<xsd:documentation><![CDATA[[
Time to idle (or idle timeout) configuration for the region entries. Default: no expiration.
]]></xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:annotation>
</xsd:element>
<xsd:element name="custom-entry-tti" type="customExpirationType"
minOccurs="0" maxOccurs="1">
<xsd:annotation>
<xsd:appinfo>
<tool:annotation>
<tool:exports
type="com.gemstone.gemfire.cache.CustomExpiry" />
</tool:annotation>
</xsd:appinfo>
<xsd:documentation><![CDATA[[
CustomExpiry Time to idle (or idle timeout) configuration for the region entries. Default: no expiration.
]]></xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:choice>
</xsd:sequence>
<xsd:attribute name="load-factor" type="xsd:string"
default="0.75">
@@ -1361,6 +1396,28 @@ When the region or cached object expires, it is destroyed locally only. Not supp
</xsd:simpleType>
</xsd:attribute>
</xsd:complexType>
<!-- -->
<!-- -->
<xsd:complexType name="customExpirationType">
<xsd:sequence>
<xsd:any namespace="##other" processContents="skip" minOccurs="0"
maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation><![CDATA[
Inner bean definition of the CustomExpiry.
]]></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 CustomExpiry 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:complexType name="evictionType">
<xsd:sequence minOccurs="0" maxOccurs="1">
@@ -2258,6 +2315,13 @@ Inner bean definition of the event filter
minOccurs="0" maxOccurs="1" />
</xsd:sequence>
<xsd:attributeGroup ref="commonWANQueueAttributes" />
<xsd:attribute name="name" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
Optionally specifies the GemFire gateway sender id. By default this value is the bean id or a generated value if an inner bean.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="remote-distributed-system-id"
type="xsd:string" use="required">
<xsd:annotation>
@@ -2506,6 +2570,13 @@ use inner bean declarations.
</xsd:element>
</xsd:sequence>
<xsd:attributeGroup ref="commonWANQueueAttributes" />
<xsd:attribute name="name" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
Optionally specifies the GemFire gateway sender id. By default this value is the bean id or a generated value if an inner bean.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:complexType>
<!-- -->
<xsd:element name="gateway-sender">

View File

@@ -758,22 +758,58 @@ Time to idle (or idle timeout) configuration for the region itself. Default: no
]]></xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="entry-ttl" type="expirationType"
<xsd:choice>
<xsd:element name="entry-ttl" type="expirationType"
minOccurs="0" maxOccurs="1">
<xsd:annotation>
<xsd:annotation>
<xsd:documentation><![CDATA[[
Time to live configuration for the region entries. Default: no expiration.
]]></xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="entry-tti" type="expirationType"
</xsd:annotation>
</xsd:element>
<xsd:element name="custom-entry-ttl" type="customExpirationType"
minOccurs="0" maxOccurs="1">
<xsd:annotation>
<xsd:appinfo>
<tool:annotation>
<tool:exports
type="com.gemstone.gemfire.cache.CustomExpiry" />
</tool:annotation>
</xsd:appinfo>
<xsd:documentation><![CDATA[[
CustomExpiry time to live configuration for the region entries. Default: no expiration.
]]></xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:choice>
<xsd:choice>
<xsd:element name="entry-tti" type="expirationType"
minOccurs="0" maxOccurs="1">
<xsd:annotation>
<xsd:annotation>
<xsd:documentation><![CDATA[[
Time to idle (or idle timeout) configuration for the region entries. Default: no expiration.
]]></xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:annotation>
</xsd:element>
<xsd:element name="custom-entry-tti" type="customExpirationType"
minOccurs="0" maxOccurs="1">
<xsd:annotation>
<xsd:appinfo>
<tool:annotation>
<tool:exports
type="com.gemstone.gemfire.cache.CustomExpiry" />
</tool:annotation>
</xsd:appinfo>
<xsd:documentation><![CDATA[[
CustomExpiry Time to idle (or idle timeout) configuration for the region entries. Default: no expiration.
]]></xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:choice>
</xsd:sequence>
<xsd:attribute name="load-factor" type="xsd:string"
default="0.75">
@@ -1308,9 +1344,10 @@ The name of the region definition.
</xsd:complexType>
<!-- -->
<xsd:element name="partitioned-region" type="partitionedRegionType" />
<!-- -->
<!-- -->
<xsd:complexType name="expirationType">
<xsd:attribute name="timeout" type="xsd:string"
<xsd:attribute name="timeout" type="xsd:string"
default="0">
<xsd:annotation>
<xsd:documentation><![CDATA[
@@ -1353,6 +1390,29 @@ When the region or cached object expires, it is destroyed locally only. Not supp
</xsd:simpleType>
</xsd:attribute>
</xsd:complexType>
<!-- -->
<xsd:complexType name="customExpirationType">
<xsd:sequence>
<xsd:any namespace="##other" processContents="skip" minOccurs="0"
maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation><![CDATA[
Inner bean definition of the CustomExpiry.
]]></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 CustomExpiry 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:complexType name="evictionType">
<xsd:sequence minOccurs="0" maxOccurs="1">

View File

@@ -18,6 +18,7 @@ package org.springframework.data.gemfire.config;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
@@ -39,6 +40,7 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.gemstone.gemfire.cache.Cache;
import com.gemstone.gemfire.cache.CustomExpiry;
import com.gemstone.gemfire.cache.DiskStore;
import com.gemstone.gemfire.cache.DiskStoreFactory;
import com.gemstone.gemfire.cache.EvictionAction;
@@ -47,6 +49,7 @@ import com.gemstone.gemfire.cache.EvictionAttributes;
import com.gemstone.gemfire.cache.ExpirationAction;
import com.gemstone.gemfire.cache.ExpirationAttributes;
import com.gemstone.gemfire.cache.Region;
import com.gemstone.gemfire.cache.Region.Entry;
import com.gemstone.gemfire.cache.RegionAttributes;
import com.gemstone.gemfire.cache.Scope;
import com.gemstone.gemfire.cache.util.ObjectSizer;
@@ -99,6 +102,7 @@ public class DiskStoreAndEvictionRegionParsingTest {
testReplicaDataOptions();
testPartitionDataOptions();
testEntryTtl();
testCustomExpiry();
}
private void testDiskStore() {
@@ -170,4 +174,39 @@ public class DiskStoreAndEvictionRegionParsingTest {
assertEquals(400, regionTTI.getTimeout());
assertEquals(ExpirationAction.INVALIDATE, regionTTI.getAction());
}
@SuppressWarnings("rawtypes")
private void testCustomExpiry() throws Exception {
assertTrue(context.containsBean("replicated-data-custom-expiry"));
RegionFactoryBean fb = context.getBean("&replicated-data-custom-expiry", RegionFactoryBean.class);
RegionAttributes attrs = TestUtils.readField("attributes", fb);
assertNotNull(attrs.getCustomEntryIdleTimeout());
assertNotNull(attrs.getCustomEntryTimeToLive());
assertTrue(attrs.getCustomEntryIdleTimeout() instanceof TestCustomExpiry);
assertTrue(attrs.getCustomEntryTimeToLive() instanceof TestCustomExpiry);
}
public static class TestCustomExpiry<K,V> implements CustomExpiry<K,V> {
/* (non-Javadoc)
* @see com.gemstone.gemfire.cache.CacheCallback#close()
*/
@Override
public void close() {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see com.gemstone.gemfire.cache.CustomExpiry#getExpiry(com.gemstone.gemfire.cache.Region.Entry)
*/
@Override
public ExpirationAttributes getExpiry(Entry<K, V> entry) {
return null;
}
}
}

View File

@@ -28,9 +28,9 @@
<gfe:disk-dir location="${location}" max-size="${maxSize}"/>
</gfe:disk-store>
<!-- <gfe:partitioned-region id="partitioned-data-with-timeout" disk-store-ref="diskStore1" persistent="true"> -->
<!-- <gfe:entry-ttl timeout="${ttl}" action="DESTROY"/> -->
<!-- </gfe:partitioned-region> -->
<gfe:partitioned-region id="partitioned-data-with-timeout" disk-store-ref="diskStore1" persistent="true">
<gfe:entry-ttl timeout="${ttl}" action="DESTROY"/>
</gfe:partitioned-region>
<gfe:replicated-region id="replicated-data" close="true" destroy="false" disk-store-ref="diskStore1">
<gfe:region-ttl timeout="${ttl}" action="DESTROY"/>
@@ -41,6 +41,13 @@
<gfe:eviction type="ENTRY_COUNT" threshold="50" action="OVERFLOW_TO_DISK"/>
</gfe:replicated-region>
<gfe:replicated-region id="replicated-data-custom-expiry" close="true" destroy="false">
<gfe:custom-entry-ttl ref="customExpiry"/>
<gfe:custom-entry-tti>
<bean class="org.springframework.data.gemfire.config.DiskStoreAndEvictionRegionParsingTest.TestCustomExpiry"/>
</gfe:custom-entry-tti>
</gfe:replicated-region>
<gfe:partitioned-region id="partition-data" persistent="true" disk-store-ref="ds2">
<gfe:eviction type="MEMORY_SIZE" threshold="10" action="LOCAL_DESTROY">
@@ -50,8 +57,10 @@
</gfe:eviction>
</gfe:partitioned-region>
<gfe:disk-store id="ds2" queue-size="50" auto-compact="true" max-oplog-size="10" time-interval="9999">
<gfe:disk-store id="ds2" queue-size="50" auto-compact="true" max-oplog-size="10" time-interval="9999">
<gfe:disk-dir location="./" max-size="1"/>
</gfe:disk-store>
<bean id="customExpiry" class="org.springframework.data.gemfire.config.DiskStoreAndEvictionRegionParsingTest.TestCustomExpiry"/>
</beans>