我有一个客户端/服务器拓扑方案。
在本地运行一个Locator和两个服务器的简单集群,不同的JVM进程,服务器在启动时没有使用以下配置创建区域:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:gfe="http://www.springframework.org/schema/gemfire"
xmlns:util="http://www.springframework.org/schema/util"
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/gemfire http://www.springframework.org/schema/gemfire/spring-gemfire.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
<util:properties id="gemfireProperties">
<prop key="name">${gemfire.server.name}</prop>
<prop key="mcast-port">${gemfire.server.mcast-port}</prop>
<prop key="log-level">${gemfire.server.log-level}</prop>
<prop key="locators">${gemfire.server.locators}</prop>
</util:properties>
<gfe:cache properties-ref="gemfireProperties" use-cluster-configuration="true"/>
<gfe:cache-server auto-startup="true" bind-address="${gemfire.server.bind-address}"
host-name-for-clients="${gemfire.server.hostname-for-clients}"
port="${gemfire.server.port}"
max-connections="${gemfire.server.max-connections}"/>
然后,我正在运行具有以下配置的客户端:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:gfe="http://www.springframework.org/schema/gemfire"
xsi:schemaLocation="http://www.springframework.org/schema/gemfire http://www.springframework.org/schema/gemfire/spring-gemfire.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<beans>
<gfe:client-cache id="gemfireClientCache" pool-name="gemfireConnectionPool" ready-for-events="true"/>
<gfe:pool id="gemfireConnectionPool" subscription-enabled="true">
<gfe:locator host="localhost" port="10334"/>
</gfe:pool>
<gfe:client-region id="MYREGION"
shortcut="PROXY"
key-constraint="java.lang.String"
value-constraint="MYPOJO"
cache-ref="gemfireClientCache"
pool-name="gemfireConnectionPool"/>
</beans>
Spring Boot应用程序启动没有任何问题,但我发现以下日志很奇怪:
[info 2017/01/05 20:37:56.103 WET <main> tid=0x1] Running in local mode since mcast-port was 0 and locators was empty.
虽然我可以看到Pulse中的所有集群成员,但服务器没有&#34; MYREGION&#34;区域。所以,我想知道,可以缓存客户端实际上在服务器上创建区域,还是只能#34;使用&#34;现有地区?
Pivotal文档确实有一个部分用于&#34;动态创建区域&#34;但我还没有这样做,因为我失去了分区。
由于
答案 0 :(得分:1)
EnableClusterConfiguration可以为您执行此操作->选中此项-https://docs.spring.io/spring-data/gemfire/docs/current/reference/html/#bootstrap-annotation-config
考虑以下配置中表达的力量:
Spring ClientCache应用程序
@SpringBootApplication
@ClientCacheApplication
@EnableCachingDefinedRegions
@EnableEntityDefinedRegions
@EnableIndexing
@EnableGemfireCaching
@EnableGemfireRepositories
@EnableClusterConfiguration
class ClientApplication { .. }
您立即获得一个带有Pivotal GemFire ClientCache实例,Spring Data Repositories,带有Pivotal GemFire作为缓存提供程序的Spring Cache Abstraction的Spring Boot应用程序(区域和索引不仅在客户端上创建,而且被推送到服务器中的服务器上)群集)。
答案 1 :(得分:0)
所以,我想知道,缓存客户端是否可以在服务器上实际创建区域,还是只能“使用”现有区域?
OOTB,没有。默认情况下,缓存客户端仅使用现有的区域。
但是,可以使用GemFire功能在GemFire群集中的另外一个GemFire服务器上动态创建 Region 。这正是 Gfsh 所做的。
不过,还有很多事情需要考虑......
应该创建 Region 的“类型”(即PARTITION,REPLICATE等),这不仅仅是基于客户区域吗?
群集中的哪些服务器实际上应该托管区域?
这可以通过客户端用于在服务器上创建相应的 Region 的GemFire Pool来限制,这必须通过客户端的Function执行来完成,如前所述。
如果(特定)GemFire池配置了特定服务器“组”,则只有该“组”中群集中的服务器才能创建 Region 。
当您开始将其与其他内容(如群集配置)混合使用时,您可能会很快遇到问题(例如,名为 Regions 的冲突)。
虽然这在开发期间是一个有用的功能,但我甚至考虑在SDG中使用新的Annotation-based configuration model,再加上SD Repository抽象使用的(新)映射Region annotations,特别是在客户端上使用 new @ClientRegion
注释来注释应用程序域对象(实体),这在生产环境中可能是不可取的。
希望这有帮助! 约翰