简而言之,SDG @EnableClusterConfiguration 注释(详细信息可用 here)允许从客户端推送在客户端(即 Spring [Boot] Data、GemFire/Geode 应用程序)上定义和声明的配置元数据到集群(GemFire/Geode 服务器)。
我说“启用”是因为它取决于客户端配置元数据(即您显式或隐式定义/声明的 Spring bean 定义)。显式配置是您使用 bean 定义定义的配置(在 XML 中,或带有 @Bean 的 JavaConfig 等)。隐式配置是自动配置或使用@EnableEntityDefinedRegions或@EnableCachingDefinedRegions等SDG注解。
默认情况下,@EnableClusterConfiguration 注释假定 GemFire 或 Geode 服务器集群已使用 Spring 进行配置和引导,特别是使用 SDG Annotation configuration model。当 GemFire 或 Geode 服务器配置并使用 Spring 引导时,SDG 继续注册一些提供的、罐装的 GemFire 函数,@EnableClusterConfiguration 注释调用(默认情况下和...)作为后备.
注意:请参阅 SBDG 参考文档中的 appendix,了解如何使用 Spring 配置和引导 GemFire 或 Geode 服务器,甚至是服务器集群。与使用 Gfsh 相比,这无疑简化了本地开发和调试。您可以进行各种有趣的组合:带有 Spring 服务器的 Gfsh Locator、带有 Gfsh 和 Spring 服务器的 Spring [embedded|standalone] Locator 等。
大多数时候,用户在客户端使用 Spring 和 Gfsh 来(部分)配置和引导他们的集群(服务器)。在这种情况下,Spring 通常不在服务器的类路径中,并且我上面提到的“提供的、固定的”函数不存在并自动注册。在这种情况下,您必须依靠 GemFire/Geodes 内部的管理 REST API(我知道一两件事,;-) 将配置元数据从客户端发送到服务器/集群。这就是为什么必须将@EnableClusterConfiguration 注释上的useHttp 属性设置为true。
这就是您看到异常的原因...
org.springframework.context.ApplicationContextException: Failed to start bean 'gemfireClusterSchemaObjectInitializer';
nested exception is org.apache.geode.cache.client.ServerOperationException: remote server on #.#.#.#(Web:9408:loner)###
The function is not registered for function id CreateRegionFunction
CreateRegionFunction 是 SDG 提供的开箱即用的预制函数,但仅当 Spring 用于配置和引导集群中的服务器时。
这通常适用于 CI/CD 环境,尤其是我们自己的测试基础架构,因为我们通常没有完整安装的 Apache Geode 或 Pivotal GemFire 可用于在这些环境中进行测试。对于 1,这些工件必须可以从 Maven Central 等工件存储库中解析。 Apache Geode(尤其是)Pivotal GemFire 发行版不是。 JAR 是,但完整的发行版不是。总之……
希望到目前为止,所有这些都是有意义的。
如果可以的话,我确实有一个建议。
鉴于您的应用程序类定义以...开头
@ClientCacheApplication(name = "Web", locators = @Locator,
logLevel = "debug", subscriptionEnabled = true)
@EnableClusterDefinedRegions
@EnableClusterConfiguration(useHttp = true)
@EnablePdx
public class MyCache { ... }
我强烈建议直接使用 Spring Boot for Apache Geode(和 Pivotal GemFire),即 SBDG,直接代替 SDG。
然后您的应用程序类可以简化为:
@SpringBootApplication
@EnableClusterAware
@EnableClusterDefinedRegions
public class MyCache { ... }
然后您可以使用 Spring Boot application.properties 文件将一些硬编码配置设置外部化:
spring.application.name=Web
spring.data.gemfire.cache.log-level=debug
spring.data.gemfire.pool.subscription-enabled=true
注意:@EnableClusterAware 是@EnableClusterConfiguration 的更强大和更强大的扩展。查看更多详细信息here。
这里有一些资源可以帮助您:
一般而言,基于 SDG、SSDG 和 STDG 的 SBDG 是 Apache Geode 和 Pivotal GemFire(或现在的 Pivotal Cloud Cache)所有事物的首选/推荐起点Spring .
希望这会有所帮助。