1

我有一个客户端/服务器拓扑方案。

在本地运行一个 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 中看到所有集群成员,但服务器没有“MYREGION”区域。所以,我想知道,缓存客户端可以实际在服务器上创建区域还是只能“使用”现有区域?

Pivotal 文档确实有一个“动态创建区域”部分,但我还没有这样做,因为我失去了分区。

谢谢

4

2 回答 2

1

所以,我想知道,缓存客户端实际上可以在服务器上创建区域还是只能“使用”现有区域?

OOTB,没有。默认情况下,缓存客户端仅使用现有的Regions

但是,可以使用 GemFire 函数在 GemFire 集群中的多台 GemFire 服务器上动态创建区域。这正是Gfsh所做的。

尽管如此,还有很多事情需要考虑......

  1. 应该创建哪种“类型”的Region(即 PARTITION、REPLICATE 等),仅基于客户端 Region 是不容易的?

  2. 集群中的哪些服务器实际上应该托管Region

这可以通过客户端用于在服务器上创建相应区域的 GemFire 池来限制,这必须通过客户端的函数执行来完成,如前所述。

如果(特定的)GemFire 池配置了特定的服务器“组”,则只有该“组”中的集群中的服务器才能创建该区域

  1. 除了区域应具有的数据策略类型外,还有许多其他配置设置和注意事项(一致性、驱逐/过期策略、安全性、事务范围、序列化(特别是如果涉及多种语言客户端......想想 .NET)等)在客户端可以任意让服务器或服务器组创建一些任意Region之前需要正确权衡。

当您开始将它与其他东西(如Cluster Config )混合使用时,您可能很快就会遇到问题(例如冲突的命名Regions)。

虽然这是开发过程中的一个有用功能,我什至考虑在 SDG 中使用新的基于注释的配置模型,再加上 SD 存储库抽象使用的(新)映射区域注释,特别是在客户端上使用用于注释应用程序域对象(实体)的新注释,这在生产环境中可能不建议使用。 @ClientRegion

希望这可以帮助!约翰

于 2017-01-06T06:51:20.463 回答
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、Spring 的 Cache Abstraction 的 Spring Boot 应用程序,其中 Pivotal GemFire 作为缓存提供程序(其中区域和索引不仅在客户端上创建,而且被推送到集群中的服务器)。

于 2018-08-17T21:58:31.257 回答