Java GemFire缓存客户端能否在服务器上创建区域?
我有一个客户机/服务器拓扑方案 在本地运行一个由一个定位器和两个服务器组成的简单集群,使用不同的JVM进程,这些服务器在启动时没有使用以下配置创建的区域:Java GemFire缓存客户端能否在服务器上创建区域?,java,spring,gemfire,spring-data-gemfire,geode,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" x
<?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>
${gemfire.server.name}
${gemfire.server.mcast端口}
${gemfire.server.log level}
${gemfire.server.locators}
然后,我使用以下配置运行客户端:
<?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.
[info 2017/01/05 20:37:56.103湿tid=0x1]在本地模式下运行,因为mcast端口为0,定位器为空。
虽然我可以在Pulse中看到所有集群成员,但服务器没有“MYREGION”区域。所以,我想知道,缓存客户端是否真的可以在服务器上创建区域,还是只能“使用”现有区域
关键文档中确实有“动态创建区域”一节,但我还没有这样做,因为我丢失了分区
谢谢
所以,我想知道,缓存客户端是否真的可以在服务器上创建区域,还是只能“使用”现有区域
OOTB,否。默认情况下,缓存客户端仅使用现有区域
但是,可以使用GemFire函数在GemFire集群中的一个或多个GemFire服务器上动态创建区域。这正是Gfsh所做的
但是,还有很多事情要考虑……<
@ClientRegion
注释来注释应用程序域对象(实体),这在生产环境中可能不可取
希望这有帮助!
JohnEnableClusterConfiguration可以为u-->执行此操作检查- 考虑以下配置中表示的功率:
<?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>
SpringClientCache应用程序
@SpringBootApplication
@ClientCacheApplication
@EnableCachingDefinedRegions
@EnableEntityDefinedRegions
@EnableIndexing
@EnableGemfireCaching
@EnableGemfireRepositories
@EnableClusterConfiguration
class ClientApplication { .. }
您可以立即获得一个Spring启动应用程序,其中包含一个Pivotal GemFire ClientCache实例、Spring数据存储库、Spring的缓存抽象,其中Pivotal GemFire作为缓存提供程序(其中区域和索引不仅在客户机上创建,而且推送到集群中的服务器).谢谢你的邀请feedback@JohnBlum如何动态创建子区域?我有一个用例:所有帐户的区域。我的应用程序接收与不同帐户关联的事务。如果不存在子区域,我是否可以动态创建子区域(使用区域过期TTL)?每个子区域映射到一个帐号。在子区域内,我将事务ID作为键,事务内容作为值。当我使用事务时,我将使用一个帐户的所有事务。Gemfire可行吗?嗨,Prashanth,我试过这个注释,得到了下面的错误-