View Full Version : How to create region name like this '"/root/myRegion" using SGF 1.1.1
csmsmk3
May 29th, 2012, 03:45 PM
We have a PROD GF Distributed System running (6.5.1.31) and have some region names like these: /root/account, /root/transactions. We are planning to migrate to GF 6.6 and use SGF 1.1.1 but having issues in our POC when creating region names with "/" as indicated above for backward compatibility. Additionally we have existing clients using GF .Net NativeClient 3.5.
We would like not to change the region names to minimize changing client codes and function service code.
Anybody have done this already?
Thanks.
dturanski
May 30th, 2012, 06:22 PM
The gfe namespace doesn't support this yet but you can do something like this:
package org.springframework.data.gemfire.config;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.InitializingBean ;
import com.gemstone.gemfire.cache.Region;
import com.gemstone.gemfire.cache.RegionAttributes;
public class SubRegionFactoryBean implements FactoryBean<Region<?,?>>, InitializingBean, BeanNameAware {
private String name;
private Region<?,?> parent;
private Region<?,?> region;
private RegionAttributes<?,?> attributes;
@Override
public Region<?,?> getObject() throws Exception {
return this.region;
}
SubRegionFactoryBean(Region<?,?> parent){
this.parent = parent;
}
@Override
public Class<?> getObjectType() {
return Region.class;
}
@Override
public boolean isSingleton() {
return true;
}
public void setAttributes(RegionAttributes<?,?> attributes) {
this.attributes = attributes;
}
@Override
public void afterPropertiesSet() throws Exception {
if (this.attributes == null){
this.attributes = parent.getAttributes();
}
this.region = this.parent.createSubregion(this.name,this.attribu tes);
}
@Override
public void setBeanName(String name) {
this.name = name;
}
}
In your spring xml:
<gfe:replicated-region id="root/>
<bean id="accounts" class="org.springframework.data.gemfire.config.SubRegionF actoryBean">
<constructor-arg ref="root"/>
</bean>
<bean id="transactions" class="org.springframework.data.gemfire.config.SubRegionF actoryBean">
<constructor-arg ref="root"/>
</bean>
csmsmk3
May 30th, 2012, 09:14 PM
Thanks for the response.
What I really would like to do is to be able to create a region name with "/" in my spring.xml:
<gfe:cache cache-xml-location="cache-server.xml"
properties-ref="props" />
<util:properties id="props" location="gemfire.properties" />
<gfe:replicated-region id="transRegion"
name="/root/transactionRegion"
cache-ref="gemfire-cache" persistent="true">
<gfe:disk-store max-oplog-size="2048"
synchronous-write="false" time-interval="60000">
<gfe:disk-dir location="/data/transaction" />
</gfe:disk-store>
</gfe:replicated-region>
dturanski
May 31st, 2012, 07:19 AM
I understand. That would essentially be a convenient way to do the same thing internally. Gemfire doesnt support region
names with '/' in them. It's really a syntax to reference subRegions in Gemfire OQL and should work with the configuration I proposed.
We will be adding namespace support for subregions in the next release but the complete solution is a bit more involved since sub regions may have their own attributes, etc. So we will require nested region elements in addition to supporting path expressions.
Watch https://jira.springsource.org/browse/SGF-95 if you want to be notified of the status
Powered by vBulletin® Version 4.2.1 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.