SGF-71
+ add support for region interest receive-values property
This commit is contained in:
@@ -583,8 +583,12 @@ redundancy. Each copy provides extra backup at the expense of extra storages.</e
|
||||
<gfe:key-interest durable="true" result-policy="KEYS">
|
||||
<bean id="key" class="java.lang.String"/>
|
||||
</gfe:key-interest>
|
||||
<gfe:regex-interest pattern=".*"/>
|
||||
<gfe:regex-interest pattern=".*" receive-values="false"/>
|
||||
</gfe:client-region>]]></programlisting>
|
||||
|
||||
<para> <para>A special key <literal>ALL_KEYS</literal> means interest is registered for all keys (identical to a regex interest of <literal>.*</literal>.
|
||||
The <literal>receive-values</literal> attribute indicates whether or not the values are received for create and update events. If true, values are received; if false, only
|
||||
invalidation events are received - refer to the GemFire documentation for more details.</para></para>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
@@ -782,7 +786,12 @@ redundancy. Each copy provides extra backup at the expense of extra storages.</e
|
||||
|
||||
<programlisting language="xml"><![CDATA[<gfe:index id="myIndex" expression="someField" from="/someRegion"/>]]></programlisting>
|
||||
|
||||
<para>Note that index declaration are not bound to a region but rather are top-level elements (just like <literal>gfe:cache</literal>). This allows one to declare any number of indecies on any region
|
||||
<para>Before creating an index, SGF will verify whether one with the same name already exists. If it does, it will compare the properties and if they don't match, will remove the old one to create
|
||||
a new one. If the properties match, SGF will simply return the index (in case it does not exist it will simply create one). To prevent the update of the index, even if the properties do not match,
|
||||
set the property <literal>override</literal> to false.</para>
|
||||
|
||||
<para>
|
||||
Note that index declaration are not bound to a region but rather are top-level elements (just like <literal>gfe:cache</literal>). This allows one to declare any number of indecies on any region
|
||||
whether they are just created or already exist - an improvement versus the GemFire <literal>cache.xml</literal>. By default the index relies on the default cache declaration but one can customize it
|
||||
accordingly or use a pool (if need be) - see the namespace schema for the full set of options.</para>
|
||||
</section>
|
||||
|
||||
@@ -45,6 +45,7 @@ public class IndexFactoryBean implements InitializingBean, BeanNameAware, Factor
|
||||
private String beanName;
|
||||
private String name, expression, from, imports;
|
||||
private IndexType type = IndexType.FUNCTIONAL;
|
||||
private boolean override = true;
|
||||
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
if (queryService == null) {
|
||||
@@ -72,8 +73,23 @@ public class IndexFactoryBean implements InitializingBean, BeanNameAware, Factor
|
||||
|
||||
private Index createIndex(QueryService queryService, String indexName) throws Exception {
|
||||
Collection<Index> indexes = queryService.getIndexes();
|
||||
|
||||
Index old = null;
|
||||
|
||||
for (Index index : indexes) {
|
||||
if (indexName.equals(index.getName())) {
|
||||
if (!override) {
|
||||
return index;
|
||||
}
|
||||
old = index;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (old != null) {
|
||||
// compare indices
|
||||
if (from.equals(old.getFromClause()) && expression.equals(old.getIndexedExpression())
|
||||
&& type.equals(old.getType())) {
|
||||
return index;
|
||||
}
|
||||
}
|
||||
@@ -167,4 +183,11 @@ public class IndexFactoryBean implements InitializingBean, BeanNameAware, Factor
|
||||
public void setType(IndexType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param override the override to set
|
||||
*/
|
||||
public void setOverride(boolean override) {
|
||||
this.override = override;
|
||||
}
|
||||
}
|
||||
@@ -153,10 +153,12 @@ public class ClientRegionFactoryBean<K, V> extends RegionLookupFactoryBean<K, V>
|
||||
for (Interest<K> interest : interests) {
|
||||
if (interest instanceof RegexInterest) {
|
||||
// do the cast since it's safe
|
||||
region.registerInterestRegex((String) interest.getKey(), interest.getPolicy(), interest.isDurable());
|
||||
region.registerInterestRegex((String) interest.getKey(), interest.getPolicy(),
|
||||
interest.isDurable(), interest.isReceiveValues());
|
||||
}
|
||||
else {
|
||||
region.registerInterest(interest.getKey(), interest.getPolicy(), interest.isDurable());
|
||||
region.registerInterest(interest.getKey(), interest.getPolicy(), interest.isDurable(),
|
||||
interest.isReceiveValues());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ public class Interest<K> implements InitializingBean {
|
||||
private K key;
|
||||
private InterestResultPolicy policy = InterestResultPolicy.DEFAULT;
|
||||
private boolean durable = false;
|
||||
private boolean receiveValues = true;
|
||||
|
||||
public Interest() {
|
||||
}
|
||||
@@ -52,20 +53,25 @@ public class Interest<K> implements InitializingBean {
|
||||
}
|
||||
|
||||
public Interest(K key, String policy, boolean durable) {
|
||||
this.key = key;
|
||||
this.policy = (InterestResultPolicy) constants.asObject(policy);
|
||||
this.durable = durable;
|
||||
afterPropertiesSet();
|
||||
this(key, policy, false, true);
|
||||
}
|
||||
|
||||
public Interest(K key, String policy, boolean durable, boolean receiveValues) {
|
||||
this(key, (InterestResultPolicy) constants.asObject(policy), durable, receiveValues);
|
||||
}
|
||||
|
||||
public Interest(K key, InterestResultPolicy policy, boolean durable) {
|
||||
this(key, policy, durable, true);
|
||||
}
|
||||
|
||||
public Interest(K key, InterestResultPolicy policy, boolean durable, boolean receiveValues) {
|
||||
this.key = key;
|
||||
this.policy = policy;
|
||||
this.durable = durable;
|
||||
this.receiveValues = receiveValues;
|
||||
afterPropertiesSet();
|
||||
}
|
||||
|
||||
|
||||
public void afterPropertiesSet() {
|
||||
Assert.notNull(key, "a non-null key is required");
|
||||
}
|
||||
@@ -135,4 +141,22 @@ public class Interest<K> implements InitializingBean {
|
||||
public void setDurable(boolean durable) {
|
||||
this.durable = durable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type of values received by the listener.
|
||||
*
|
||||
* @return the receiveValues
|
||||
*/
|
||||
protected boolean isReceiveValues() {
|
||||
return receiveValues;
|
||||
}
|
||||
|
||||
/**
|
||||
* Switches between the different entities received by the listener.
|
||||
*
|
||||
* @param receiveValues the receiveValues to set
|
||||
*/
|
||||
public void setReceiveValues(boolean receiveValues) {
|
||||
this.receiveValues = receiveValues;
|
||||
}
|
||||
}
|
||||
@@ -145,5 +145,6 @@ class ClientRegionParser extends AliasReplacingBeanDefinitionParser {
|
||||
private void parseCommonInterestAttr(Element element, BeanDefinitionBuilder builder) {
|
||||
ParsingUtils.setPropertyValue(element, builder, "durable", "durable");
|
||||
ParsingUtils.setPropertyValue(element, builder, "result-policy", "policy");
|
||||
ParsingUtils.setPropertyValue(element, builder, "receive-values", "receiveValues");
|
||||
}
|
||||
}
|
||||
@@ -911,6 +911,15 @@ NONE - Does not initialize the local cache.
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="receive-values" type="xsd:string" default="true" use="optional">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
Indicates whether values are received with create and update events on keys of interest (true)
|
||||
or only invalidations are received and the value will be received on the next get instead (false).
|
||||
Default is true.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:element name="pool">
|
||||
@@ -1174,6 +1183,12 @@ The name of the index.]]></xsd:documentation>
|
||||
<xsd:attribute name="expression" use="required" type="xsd:string"/>
|
||||
<xsd:attribute name="from" use="required" type="xsd:string"/>
|
||||
<xsd:attribute name="imports" use="optional" type="xsd:string"/>
|
||||
<xsd:attribute name="override" use="optional" type="xsd:string" default="true">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
Indicates whether the index is created even if there is an index with the same name (default) or not.]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
|
||||
<xsd:attribute name="cache-ref" type="xsd:string" default="gemfire-cache" use="optional">
|
||||
<xsd:annotation>
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
<property name="interests">
|
||||
<array>
|
||||
<bean class="org.springframework.data.gemfire.client.Interest" p:key="Vlaicu" p:policy="NONE"/>
|
||||
<bean class="org.springframework.data.gemfire.client.RegexInterest" p:key=".*" p:policy="KEYS" p:durable="true"/>
|
||||
<bean class="org.springframework.data.gemfire.client.RegexInterest" p:key=".*" p:policy="KEYS" p:durable="true" p:receive-values="false"/>
|
||||
</array>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
Reference in New Issue
Block a user