Results 1 to 5 of 5

Thread: Minimal Spring based Gemfire Client application

  1. #1
    Join Date
    Jan 2011
    Location
    codecentric AG, Germany
    Posts
    17

    Default Minimal Spring based Gemfire Client application

    Hi,

    I'm trying to setup a minial Gemfire client application. On the command line, I started

    a) a Gemfire locator: gemfire start-locator -server=true -port=41111

    b) a Gemfire cache server: cacheserver start -J-Xmx8000m locators=127.0.0.1:41111 cache-xml-file=../defaultConfigs/cache.xml

    with cache.xml looking like this:

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE cache PUBLIC "-//GemStone Systems, Inc.//GemFire Declarative Cache 6.5//EN" "http://www.gemstone.com/dtd/cache6_5.dtd">
    <cache lock-lease="120" lock-timeout="60" search-timeout="300" is-server="false" copy-on-read="false">
    	<cache-server port="40404" />
    	<region name="Customers">
    		<region-attributes data-policy="replicate" scope="distributed-ack">
    		</region-attributes>
    	</region>
    </cache>
    Both Java processes are up and running and listening on the TCP ports 40404 and 41111.

    From my understanding of http://static.springsource.org/sprin...otstrap:region , a pure client only needs a (pooled) Gemfire locator and a region definition. On the client side, my Spring app context looks like this

    Code:
    <?xml version="1.0"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    	xmlns:gfe="http://www.springframework.org/schema/gemfire" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    		http://www.springframework.org/schema/gemfire http://www.springframework.org/schema/gemfire/spring-gemfire.xsd">
    
    	<!-- pool declaration -->
    	<gfe:pool id="gemfire-pool">
    		<gfe:locator host="127.0.0.1" port="41111" />
    	</gfe:pool>
    
    	<!--  Region -->
    	<gfe:client-region id="someRegion" pool-name="gemfire-pool" />
    
    	<bean id="template" class="org.springframework.data.gemfire.GemfireTemplate">
    		<property name="region-ref" ref="someRegion" />
    	</bean>
    </beans>
    When I start the application, the following exception is thrown:

    Code:
    Caused by: java.lang.IllegalStateException: Distributed System must be created before creating pool
    	at com.gemstone.gemfire.cache.client.internal.PoolImpl.<init>(PoolImpl.java:172)
    	at com.gemstone.gemfire.cache.client.internal.PoolImpl.create(PoolImpl.java:114)
    	at com.gemstone.gemfire.internal.cache.PoolFactoryImpl.create(PoolFactoryImpl.java:382)
    	at org.springframework.data.gemfire.client.PoolFactoryBean.afterPropertiesSet(PoolFactoryBean.java:148)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1469)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1409)
    	... 37 more
    I don't want to start an embedded distributed system at all, I want to connect to the already running one.

    Any hints?

    TIA,
    Tobias

  2. #2
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    The DS (Distributed System) needs to be created at all times even for client - note that the DS per se acts as a (lightweight) registry rather then an actual grid. Based on your config, the grid starts to be initialized but whatever you choose, you need the DS.

    P.S. As you can see the error is thrown from within the Gemfire code. For Gemfire specific questions, I strongly recommend the GemFire forums - while I'd like all questions to be answered here, this forum is mainly targeted towards the Spring integration only rather then Gemfire as an entire product.
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  3. #3
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    In case I wasn't clear, try adding a simple <cache /> to your configuration and rerun your example.
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  4. #4
    Join Date
    Aug 2011
    Posts
    1

    Default

    Hi Costin,
    What is the means of setting the EntryTimeToLive on the client region in the configuration file. Nothing in the schema http://www.springframework.org/schem...ng-gemfire.xsd provides that option.

    Any directions please.

    Thanks
    Kiran

  5. #5

    Default

    A client region is your client side cache, and Gemfire allows you fine grained control on how much you want client side. So an app like a trading app, may only want to keep cache data around for a few minutes, while a logistics app may want to keep data around for a few days until an order is processed.

Tags for this Thread

Posting Permissions

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