I created repository SpringbootGeodeExample for demo purpose.
Started a Locator in Gfsh, and cache server embedded in Spring Boot application with some Regions defined in the Spring context for embedded cache server. Now I can list the Region, but failed to query & destroy Region, execute "describe" Region shows "Hosting Members" is blank.
gfsh>describe region --name=Region1
..........................................................
Name : Region1
Data Policy : partition
Hosting Members :
gfsh>query --query="select * from /Region1"
Result : false
Message : Cannot find regions <[/Region1]> in any of the members
gfsh>destroy region --name=Region1
Could not find a Region with Region path "Region1" in this Geode cluster. If region was recently created, please wait for at least jmx-manager-update-rate milliseconds to allow the associated Management resources to be federated.
I can do above on Regions created in Gfsh, how can I do the same CRUD operations on Regions created in Spring context?
I tried add --enable-cluster-configuration=true and use-cluster-configuration="true" in locator and cache server, but still not working.
More details: Cache server application config:
@SpringBootApplication
@CacheServerApplication
@EnableCacheServer(autoStartup = true, port = 41414)
@ImportResource("classpath:spring-cache-context-cluster-side.xml")
public class CacheServerApplication {
public static void main(String[] args) {
SpringApplication.run(CacheServerApplication.class, args);
}
}
Region definition in spring context:
<gfe:partitioned-region id="Region1" copies="1">
<gfe:eviction type="MEMORY_SIZE" threshold="512" action="LOCAL_DESTROY"/>
</gfe:partitioned-region>
Update according to comment from John:
Update 1:
List members shows cache server name is blank, is this the root cause?
gfsh>list members
Name | Id
-------- | -----------------------------------------------
locator2 | 192.168.1.2(locator2:1396:locator)<ec><v0>:1024
| 192.168.1.2(6032)<v3>:1025
I tried to change annotations to:
@SpringBootApplication
@CacheServerApplication(name = "MyServer", locators="localhost[10334]", autoStartup = true, port = 41415)
@EnableCacheServer(name = "MyServer", autoStartup = true, port = 41414)
@ImportResource("classpath:spring-cache-context-cluster-side.xml")
but still with no luck, server name is empty.
Update 2:
I'm using spring-data-geode 2.0.6.RELEASE geode-core 1.2.1 My maven dependencies:
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<spring-cloud.version>Finchley.RC1</spring-cloud.version>
<spring-cloud-services.version>1.5.0.RELEASE</spring-cloud-services.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>io.pivotal.spring.cloud</groupId>
<artifactId>spring-cloud-services-dependencies</artifactId>
<version>${spring-cloud-services.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-geode</artifactId>
</dependency>
Update 3:
spring-cache-context-cluster-side.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:gfe="http://www.springframework.org/schema/geode"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:context="http://www.springframework.org/schema/context"
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.xsd
http://www.springframework.org/schema/geode http://www.springframework.org/schema/gemfire/spring-geode.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<bean id="pdxSerializer" class="org.apache.geode.pdx.ReflectionBasedAutoSerializer">
<constructor-arg value="com.WMModel.model.*"/>
</bean>
<util:properties id="gemfireProperties">
<prop key="locators">${geode.cache.server.locators}</prop>
<prop key="mcast-port">0</prop>
</util:properties>
<gfe:cache
properties-ref="gemfireProperties"
id="gemfireCache"
use-cluster-configuration="true"
pdx-serializer-ref="pdxSerializer"
copy-on-read="false"
critical-heap-percentage="85"
eviction-heap-percentage="80">
<gfe:transaction-listener>
<bean class="com.WMCacheServer.db.op.WmTransactionListener"/>
</gfe:transaction-listener>
<gfe:transaction-writer>
<bean class="com.WMCacheServer.db.op.WmTransactionWriter"/>
</gfe:transaction-writer>
<gfe:dynamic-region-factory/>
</gfe:cache>
<!-- configure the cache and set the port to 0 for it picks the first available port -->
<gfe:cache-server
id="advanced-config"
port="${geode.cache.server.port}"
auto-startup="true"
cache-ref="gemfireCache" />
<context:property-placeholder location="classpath:cache-server.properties"/>
<gfe:partitioned-region id="Region1" copies="1">
<gfe:eviction type="MEMORY_SIZE" threshold="512" action="LOCAL_DESTROY"/>
</gfe:partitioned-region>
</beans>
cache-server.properties:
### For complete options list: http://gemfire.docs.gopivotal.com/index.html?q=/reference/topics/gemfire_properties.html ###
### Logging ###
log-level=config
### Turn Off Multi Cast ###
mcast-port=0
### Turn on Statistics ###
statistic-archive-file=stats.gfs
statistic-sample-rate=1000
statistic-sampling-enabled=true
enable-network-partition-detection=false
##Conserve Sockets##
conserve-sockets=false
geode.cache.server.port=40434
#geode.cache.server.locators=peer2.com[10334],localhost[10334]
geode.cache.server.locators=localhost[10334]