【发布时间】:2018-05-11 06:20:11
【问题描述】:
我为演示目的创建了存储库SpringbootGeodeExample。
在 Gfsh 中启动了一个定位器,并在 Spring Boot 应用程序中嵌入了缓存服务器,并在 Spring 上下文中为嵌入式缓存服务器定义了一些区域。 现在可以列出 Region,但是查询 & 销毁 Region 失败,执行“describe” Region 显示“Hosting Members”为空。
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.
我可以在 Gfsh 中创建的 Region 上执行上述操作,如何对 Spring 上下文中创建的 Region 执行相同的 CRUD 操作?
我尝试在定位器和缓存服务器中添加 --enable-cluster-configuration=true 和 use-cluster-configuration="true",但仍然无法正常工作。
更多详情: 缓存服务器应用配置:
@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);
}
}
spring 上下文中的区域定义:
<gfe:partitioned-region id="Region1" copies="1">
<gfe:eviction type="MEMORY_SIZE" threshold="512" action="LOCAL_DESTROY"/>
</gfe:partitioned-region>
根据 John 的评论更新:
更新 1:
列表成员显示缓存服务器名称为空,这是根本原因吗?
gfsh>list members
Name | Id
-------- | -----------------------------------------------
locator2 | 192.168.1.2(locator2:1396:locator)<ec><v0>:1024
| 192.168.1.2(6032)<v3>:1025
我尝试将注释更改为:
@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")
但仍然没有运气,服务器名称为空。
更新 2:
我正在使用 弹簧数据geode 2.0.6.RELEASE geode-core 1.2.1 我的 Maven 依赖项:
<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>
更新 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>
缓存服务器属性:
### 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]
【问题讨论】:
-
您不能使用 Gfsh 销毁在 Spring 上下文中创建的区域。在您的应用程序中直接或间接地注入对这些区域的引用时会发生什么?
标签: gemfire geode spring-data-gemfire