java - GemFire 缓存客户端可以在服务器上创建区域吗?

标签 java spring gemfire spring-data-gemfire geode

我有一个客户端/服务器拓扑场景。

在本地运行由一个定位器和两台服务器组成的简单集群,不同的 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 文档确实有一个“动态创建区域”的部分,但我还不会这样做,因为我丢失了分区。

谢谢

最佳答案

So, I'm wondering, can cache-clients actually create regions on servers or can they only "use" existing regions?

开箱即用,没有。默认情况下,缓存客户端仅使用现有的区域

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

不过,还有很多事情需要考虑......

  1. 应该创建什么“类型”的区域(即 PARTITION、REPLICATE 等),这不容易单独基于客户端区域?

  2. 集群中的哪些服务器应实际托管区域

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

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

  • 除了区域应具有的数据策略类型外,还有许多其他配置设置和注意事项(一致性、逐出/过期策略、安全性、事务范围、序列化(特别是在多语言客户端的情况下)将涉及...想想.NET)等),在客户端可以任意让一台服务器或一组服务器创建一些任意区域之前,需要对其进行适当权衡。
  • 当您开始将其与集群配置等其他内容混合使用时,您很快就会遇到问题(例如,命名区域发生冲突)。

    虽然这是开发过程中的一个有用功能,我什至正在考虑将其用于新的 Annotation-based configuration model在 SDG 中,加上(新)映射 Region annotations由 SD 存储库抽象使用,特别是在带有用于注释应用程序域对象(实体)的 new @ClientRegion 注释的客户端上,这在生产中可能是不可取的环境。

    希望这有帮助! 约翰

    关于java - GemFire 缓存客户端可以在服务器上创建区域吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41494715/

    相关文章:

    基于 Spring Security 一次性密码 (OTP) 的登录

    java - Gemfire异常处理

    java.lang.IllegalAccessException : Tried to access visual service WindowManager from a non-visual Context

    java - 如何使用 WireVariable 修复将 bean 注入(inject)到 ViewModel 的问题?

    具有动态宽度和精度的 Java 格式字符串

    java - @Configuration & @Bean 多个可注入(inject)

    java - 我怎样才能从 Gemfire 获得独特的长?

    tomcat - 基于 Spring 的 GemFire 客户端可以处理的并发请求数

    java - ArrayList添加不增加列表

    Java : new Filter(){} to kotlin