Spring Boot连接到关键云缓存
我的项目使用的是SpringBootVersion2.0.4-RELEASE。 我们正在部署到Pivotal Cloud Foundry,并使用使用ApacheGeode的Pivotal云缓存服务。 如果我使用gemfire shell创建云缓存区域,那么我的代码将启动并运行,但是我希望从我的代码中创建这些区域,这样就不会遗漏任何内容。 我有下面的配置类,我试图在其中创建一个区域Spring Boot连接到关键云缓存,spring,apache,spring-boot,cloud-foundry,geode,Spring,Apache,Spring Boot,Cloud Foundry,Geode,我的项目使用的是SpringBootVersion2.0.4-RELEASE。 我们正在部署到Pivotal Cloud Foundry,并使用使用ApacheGeode的Pivotal云缓存服务。 如果我使用gemfire shell创建云缓存区域,那么我的代码将启动并运行,但是我希望从我的代码中创建这些区域,这样就不会遗漏任何内容。 我有下面的配置类,我试图在其中创建一个区域 package com.mycompany.services.config; import org.apache.
package com.mycompany.services.config;
import org.apache.geode.cache.ExpirationAction;
import org.apache.geode.cache.ExpirationAttributes;
import org.apache.geode.cache.GemFireCache;
import org.apache.geode.cache.RegionShortcut;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.gemfire.PartitionedRegionFactoryBean;
import org.springframework.data.gemfire.config.annotation.EnableCachingDefinedRegions;
import org.springframework.data.gemfire.config.annotation.EnablePdx;
@Configuration
@EnableCachingDefinedRegions
@EnablePdx()
public class Config {
@Bean
public PartitionedRegionFactoryBean<?, ?> createCacheRegion(GemFireCache gemfireCache) {
int expirationTime = 600;
String regionName = "cacheRegion";
PartitionedRegionFactoryBean<?, ?> newRegion = new PartitionedRegionFactoryBean<>();
newRegion.setCache(gemfireCache);
newRegion.setClose(false);
newRegion.setPersistent(true);
newRegion.setName(regionName);
ExpirationAttributes entryTimeToLive = new ExpirationAttributes(expirationTime, ExpirationAction.INVALIDATE);
newRegion.setEntryTimeToLive(entryTimeToLive);
newRegion.setShortcut(RegionShortcut.REPLICATE);
return newRegion;
}
}
为了在代码中创建关键云缓存(ApacheGeode)区域,而不是使用gemfire shell创建它们,有人能提供一些建议吗
多谢各位
Damien客户端应用程序无法在服务器上创建区域,这是一项应由具有管理员权限的操作员执行的任务,可以通过单个配置文件或服务器来执行。允许客户端任意创建区域可能会适得其反,并在集群上生成大量未使用的区域以及不必要的噪音和开销,这在生产环境中是完全不推荐的 也就是说,它允许您自动从客户端应用程序中删除数据,这在开发环境中很有用。我不知道Pivotal云缓存内部策略和限制是否允许这样做,您可能希望直接与Pivotal进行检查 希望这有帮助。 干杯
2018-11-08T17:46:09.797+00:00 [APP/PROC/WEB/0] [OUT] 2018-11-08 17:46:09.795 ERROR 19 --- [ main] o.s.boot.SpringApplication : Application run failed
2018-11-08T17:46:09.797+00:00 [APP/PROC/WEB/0] [OUT] org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dqsCacheRegion' defined in class path resource [com/mycompany/services/config/Config.class]: Invocation of init method failed; nested exception is java.lang.UnsupportedOperationException: operation is not supported on a client cache
2018-11-08T17:46:09.797+00:00 [APP/PROC/WEB/0] [OUT] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1699) ~[spring-beans-5.0.8.RELEASE.jar!/:5.0.8.RELEASE]
2018-11-08T17:46:09.797+00:00 [APP/PROC/WEB/0] [OUT] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:573) ~[spring-beans-5.0.8.RELEASE.jar!/:5.0.8.RELEASE]
2018-11-08T17:46:09.797+00:00 [APP/PROC/WEB/0] [OUT] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:495) ~[spring-beans-5.0.8.RELEASE.jar!/:5.0.8.RELEASE]
2018-11-08T17:46:09.797+00:00 [APP/PROC/WEB/0] [OUT] at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317) ~[spring-beans-5.0.8.RELEASE.jar!/:5.0.8.RELEASE]
2018-11-08T17:46:09.797+00:00 [APP/PROC/WEB/0] [OUT] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.0.8.RELEASE.jar!/:5.0.8.RELEASE]
2018-11-08T17:46:09.797+00:00 [APP/PROC/WEB/0] [OUT] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) ~[spring-beans-5.0.8.RELEASE.jar!/:5.0.8.RELEASE]
2018-11-08T17:46:09.797+00:00 [APP/PROC/WEB/0] [OUT] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.0.8.RELEASE.jar!/:5.0.8.RELEASE]
2018-11-08T17:46:09.797+00:00 [APP/PROC/WEB/0] [OUT] at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:740) ~[spring-beans-5.0.8.RELEASE.jar!/:5.0.8.RELEASE]
2018-11-08T17:46:09.797+00:00 [APP/PROC/WEB/0] [OUT] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:869) ~[spring-context-5.0.8.RELEASE.jar!/:5.0.8.RELEASE]
2018-11-08T17:46:09.797+00:00 [APP/PROC/WEB/0] [OUT] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) ~[spring-context-5.0.8.RELEASE.jar!/:5.0.8.RELEASE]
2018-11-08T17:46:09.797+00:00 [APP/PROC/WEB/0] [OUT] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) ~[spring-boot-2.0.4.RELEASE.jar!/:2.0.4.RELEASE]
2018-11-08T17:46:09.797+00:00 [APP/PROC/WEB/0] [OUT] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:762) [spring-boot-2.0.4.RELEASE.jar!/:2.0.4.RELEASE]
2018-11-08T17:46:09.797+00:00 [APP/PROC/WEB/0] [OUT] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:398) [spring-boot-2.0.4.RELEASE.jar!/:2.0.4.RELEASE]
2018-11-08T17:46:09.797+00:00 [APP/PROC/WEB/0] [OUT] at org.springframework.boot.SpringApplication.run(SpringApplication.java:330) [spring-boot-2.0.4.RELEASE.jar!/:2.0.4.RELEASE]
2018-11-08T17:46:09.797+00:00 [APP/PROC/WEB/0] [OUT] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1258) [spring-boot-2.0.4.RELEASE.jar!/:2.0.4.RELEASE]
2018-11-08T17:46:09.797+00:00 [APP/PROC/WEB/0] [OUT] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1246) [spring-boot-2.0.4.RELEASE.jar!/:2.0.4.RELEASE]