Results 1 to 4 of 4

Thread: How to create region name like this '"/root/myRegion" using SGF 1.1.1

  1. #1
    Join Date
    Jul 2008
    Posts
    2

    Default How to create region name like this '"/root/myRegion" using SGF 1.1.1

    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.

  2. #2
    Join Date
    Oct 2004
    Location
    Berwyn, PA
    Posts
    57

    Default

    The gfe namespace doesn't support this yet but you can do something like this:
    Code:
    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.attributes);
    	}
    
    	@Override
    	public void setBeanName(String name) {
    		this.name = name;
    	}
    }
    In your spring xml:

    Code:
       <gfe:replicated-region id="root/>
    
       <bean id="accounts" class="org.springframework.data.gemfire.config.SubRegionFactoryBean">
            <constructor-arg ref="root"/>
        </bean>
    
        <bean id="transactions" class="org.springframework.data.gemfire.config.SubRegionFactoryBean">
            <constructor-arg ref="root"/>
        </bean>
    David Turanski
    SpringSource Senior Software Engineer

  3. #3
    Join Date
    Jul 2008
    Posts
    2

    Default

    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:
    Code:
        <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>

  4. #4
    Join Date
    Oct 2004
    Location
    Berwyn, PA
    Posts
    57

    Default

    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
    Last edited by dturanski; May 31st, 2012 at 07:37 AM.
    David Turanski
    SpringSource Senior Software Engineer

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •