SGF-121 - Fixed issue with data-policy
This commit is contained in:
@@ -23,6 +23,7 @@ import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.BeanFactoryAware;
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.data.gemfire.DataPolicyConverter;
|
||||
import org.springframework.data.gemfire.RegionLookupFactoryBean;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
@@ -75,6 +76,8 @@ public class ClientRegionFactoryBean<K, V> extends RegionLookupFactoryBean<K, V>
|
||||
|
||||
private String diskStoreName;
|
||||
|
||||
private String dataPolicyName;
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
super.afterPropertiesSet();
|
||||
@@ -90,6 +93,14 @@ public class ClientRegionFactoryBean<K, V> extends RegionLookupFactoryBean<K, V>
|
||||
if (cache instanceof GemFireCacheImpl) {
|
||||
Assert.isTrue(((GemFireCacheImpl) cache).isClient(), "A client-cache instance is required");
|
||||
}
|
||||
|
||||
Assert.isTrue(!(StringUtils.hasText(dataPolicyName) && dataPolicy != null), "Only one of 'dataPolicy' or 'dataPolicyName' can be set");
|
||||
|
||||
|
||||
if (StringUtils.hasText(dataPolicyName)) {
|
||||
dataPolicy = new DataPolicyConverter().convert(dataPolicyName);
|
||||
Assert.notNull(dataPolicy, "Data policy " + dataPolicyName + " is invalid");
|
||||
}
|
||||
|
||||
// first look at shortcut
|
||||
ClientRegionShortcut s = null;
|
||||
@@ -349,6 +360,16 @@ public class ClientRegionFactoryBean<K, V> extends RegionLookupFactoryBean<K, V>
|
||||
public void setDataPolicy(DataPolicy dataPolicy) {
|
||||
this.dataPolicy = dataPolicy;
|
||||
}
|
||||
|
||||
/**
|
||||
* An alternative way to set the data policy as a string. Useful for
|
||||
* property placeholders, etc.
|
||||
*
|
||||
* @param dataPolicyName
|
||||
*/
|
||||
public void setDataPolicyName(String dataPolicyName) {
|
||||
this.dataPolicyName = dataPolicyName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the name of disk store to use for overflow and persistence
|
||||
|
||||
@@ -55,10 +55,10 @@ class ClientRegionParser extends AliasReplacingBeanDefinitionParser {
|
||||
// setting the cache/DS to a be 'loner' isn't feasible
|
||||
// so to prevent both client and p2p communication in the region,
|
||||
// the scope is fixed to local
|
||||
ParsingUtils.setPropertyValue(element, builder, "data-policy", "dataPolicy");
|
||||
ParsingUtils.setPropertyValue(element, builder, "name", "name");
|
||||
ParsingUtils.setPropertyValue(element, builder, "pool-name", "poolName");
|
||||
ParsingUtils.setPropertyValue(element, builder, "shortcut", "shortcut");
|
||||
ParsingUtils.setPropertyValue(element, builder, "data-policy", "dataPolicyName");
|
||||
ParsingUtils.setPropertyValue(element, builder, "name");
|
||||
ParsingUtils.setPropertyValue(element, builder, "pool-name");
|
||||
ParsingUtils.setPropertyValue(element, builder, "shortcut");
|
||||
|
||||
// set the persistent policy
|
||||
String attr = element.getAttribute("persistent");
|
||||
|
||||
@@ -976,8 +976,7 @@ The action to take when performing eviction.
|
||||
<xsd:group ref="subRegionGroup" minOccurs="0"
|
||||
maxOccurs="unbounded" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="data-policy" type="xsd:string"
|
||||
default="NORMAL">
|
||||
<xsd:attribute name="data-policy" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
Indicates the DataPolicy to use for this region (NORMAL or PRELOADED)
|
||||
@@ -1553,9 +1552,7 @@ The action to take when performing eviction.
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="data-policy"
|
||||
type="xsd:string" use="optional"
|
||||
default="NORMAL">
|
||||
<xsd:attribute name="data-policy" type="xsd:string" use="optional">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
The data policy for this client. Can be either 'EMPTY' or 'NORMAL' (the default). In case persistence or overflow are
|
||||
|
||||
@@ -6,7 +6,7 @@ log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - <%m>%n
|
||||
|
||||
log4j.category.org.springframework.data.gemfire.listener=TRACE
|
||||
log4j.category.org.springframework.data.gemfire=DEBUG
|
||||
log4j.category.org.springframework=DEBUG
|
||||
#log4j.category.org.springframework=DEBUG
|
||||
|
||||
# for debugging datasource initialization
|
||||
# log4j.category.test.jdbc=DEBUG
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
<gfe:client-region id="simple" pool-name="gemfire-pool"/>
|
||||
|
||||
<gfe:client-region id="empty" pool-name="gemfire-pool" name="publisher" data-policy="EMPTY" close="true" destroy="false"/>
|
||||
<gfe:client-region id="empty" pool-name="gemfire-pool" name="publisher" data-policy="empty" close="true" destroy="false"/>
|
||||
|
||||
<gfe:client-region id="complex" pool-name="gemfire-pool" close="true" destroy="false">
|
||||
<gfe:cache-listener>
|
||||
|
||||
Reference in New Issue
Block a user