简体   繁体   English

问题创建区域并将区域持久化到磁盘 Geode Gemfire Spring 引导

[英]Problem creating region and persist region to disk Geode Gemfire Spring Boot

I watched video from Springone Platform and John Blum as speaker and interested try myself in Geode/Gemfire setup but with setup as described in Spring Data for Apache Geode Reference Guide我观看了 Springone Platform 和 John Blum 作为演讲者的视频,并对 Geode/Gemfire 设置感兴趣,但使用Spring Data for Apache Geode Reference Guide中所述的设置

So i make spring boot geode client, locator and cache server using Eclipse, and i have problems when:所以我使用 Eclipse 制作 spring 引导 geode 客户端、定位器和缓存服务器,并且在以下情况下遇到问题:

  1. Start spring locator, start cache server, and start client with restcontroller so I can post my POJO TitleContent and get my list of TitleContent.启动 spring 定位器,启动缓存服务器,并使用 restcontroller 启动客户端,这样我就可以发布我的 POJO TitleContent 并获取我的 TitleContent 列表。 Client give me exception Caused by: org.springframework.web.client.ResourceAccessException: I/O error on POST request for "https://localhost:7070/gemfire/v1/regions": Connection refused (Connection refused); nested exception is java.net.ConnectException: Connection refused (Connection refused)客户端给我异常原因: org.springframework.web.client.ResourceAccessException: I/O error on POST request for "https://localhost:7070/gemfire/v1/regions": Connection refused (Connection refused); nested exception is java.net.ConnectException: Connection refused (Connection refused) org.springframework.web.client.ResourceAccessException: I/O error on POST request for "https://localhost:7070/gemfire/v1/regions": Connection refused (Connection refused); nested exception is java.net.ConnectException: Connection refused (Connection refused)

Complete log:完整的日志:

2019-10-29 09:54:12.461 ERROR 58556 --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.context.ApplicationContextException: Failed to start bean 'gemfireClusterSchemaObjectInitializer'; nested exception is org.springframework.web.client.ResourceAccessException: I/O error on POST request for "https://localhost:7070/gemfire/v1/regions": Connection refused (Connection refused); nested exception is java.net.ConnectException: Connection refused (Connection refused)
    at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:185) ~[spring-context-5.2.0.RELEASE.jar:5.2.0.RELEASE]
    at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:53) ~[spring-context-5.2.0.RELEASE.jar:5.2.0.RELEASE]
    at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:360) ~[spring-context-5.2.0.RELEASE.jar:5.2.0.RELEASE]
    at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:158) ~[spring-context-5.2.0.RELEASE.jar:5.2.0.RELEASE]
    at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:122) ~[spring-context-5.2.0.RELEASE.jar:5.2.0.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:894) ~[spring-context-5.2.0.RELEASE.jar:5.2.0.RELEASE]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.finishRefresh(ServletWebServerApplicationContext.java:162) ~[spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:553) ~[spring-context-5.2.0.RELEASE.jar:5.2.0.RELEASE]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141) ~[spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747) [spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) [spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
    at network.powerhouse.commercehost.CommerceHostGeodeApplication.main(CommerceHostGeodeApplication.java:51) [classes/:na]
Caused by: org.springframework.web.client.ResourceAccessException: I/O error on POST request for "https://localhost:7070/gemfire/v1/regions": Connection refused (Connection refused); nested exception is java.net.ConnectException: Connection refused (Connection refused)
    at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:751) ~[spring-web-5.2.0.RELEASE.jar:5.2.0.RELEASE]
    at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:644) ~[spring-web-5.2.0.RELEASE.jar:5.2.0.RELEASE]
    at org.springframework.data.gemfire.config.admin.remote.RestHttpGemfireAdminTemplate.createRegion(RestHttpGemfireAdminTemplate.java:267) ~[spring-data-geode-2.2.0.RELEASE.jar:2.2.0.RELEASE]
    at org.springframework.data.gemfire.config.schema.definitions.RegionDefinition.create(RegionDefinition.java:125) ~[spring-data-geode-2.2.0.RELEASE.jar:2.2.0.RELEASE]
    at org.springframework.data.gemfire.config.annotation.ClusterConfigurationConfiguration$ClusterSchemaObjectInitializer.lambda$null$0(ClusterConfigurationConfiguration.java:403) ~[spring-data-geode-2.2.0.RELEASE.jar:2.2.0.RELEASE]
    at java.base/java.util.Optional.ifPresent(Optional.java:172) ~[na:na]
    at org.springframework.data.gemfire.config.annotation.ClusterConfigurationConfiguration$ClusterSchemaObjectInitializer.lambda$start$1(ClusterConfigurationConfiguration.java:402) ~[spring-data-geode-2.2.0.RELEASE.jar:2.2.0.RELEASE]
    at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183) ~[na:na]
    at java.base/java.util.stream.SortedOps$SizedRefSortingSink.end(SortedOps.java:357) ~[na:na]
    at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:258) ~[na:na]
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485) ~[na:na]
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) ~[na:na]
    at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150) ~[na:na]
    at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173) ~[na:na]
    at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[na:na]
    at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497) ~[na:na]
    at org.springframework.data.gemfire.config.annotation.ClusterConfigurationConfiguration$ClusterSchemaObjectInitializer.start(ClusterConfigurationConfiguration.java:402) ~[spring-data-geode-2.2.0.RELEASE.jar:2.2.0.RELEASE]
    at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:182) ~[spring-context-5.2.0.RELEASE.jar:5.2.0.RELEASE]
    ... 14 common frames omitted
Caused by: java.net.ConnectException: Connection refused (Connection refused)
    at java.base/java.net.PlainSocketImpl.socketConnect(Native Method) ~[na:na]
    at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:400) ~[na:na]
    at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:243) ~[na:na]
    at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:225) ~[na:na]
    at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:402) ~[na:na]
    at java.base/java.net.Socket.connect(Socket.java:591) ~[na:na]
    at java.base/sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:657) ~[na:na]
    at java.base/sun.security.ssl.BaseSSLSocketImpl.connect(BaseSSLSocketImpl.java:174) ~[na:na]
    at java.base/sun.net.NetworkClient.doConnect(NetworkClient.java:182) ~[na:na]
    at java.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:474) ~[na:na]
    at java.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:569) ~[na:na]
    at java.base/sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:265) ~[na:na]
    at java.base/sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:372) ~[na:na]
    at java.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:191) ~[na:na]
    at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1181) ~[na:na]
    at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1075) ~[na:na]
    at java.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:177) ~[na:na]
    at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:163) ~[na:na]
    at org.springframework.http.client.SimpleBufferingClientHttpRequest.executeInternal(SimpleBufferingClientHttpRequest.java:76) ~[spring-web-5.2.0.RELEASE.jar:5.2.0.RELEASE]
    at org.springframework.http.client.AbstractBufferingClientHttpRequest.executeInternal(AbstractBufferingClientHttpRequest.java:48) ~[spring-web-5.2.0.RELEASE.jar:5.2.0.RELEASE]
    at org.springframework.http.client.AbstractClientHttpRequest.execute(AbstractClientHttpRequest.java:53) ~[spring-web-5.2.0.RELEASE.jar:5.2.0.RELEASE]
    at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:742) ~[spring-web-5.2.0.RELEASE.jar:5.2.0.RELEASE]
    ... 31 common frames omitted
  1. I remark @EnableClusterConfiguration(useHttp=true) and start Client again and now able to run.我注释了@EnableClusterConfiguration(useHttp=true) 并再次启动客户端,现在可以运行了。 Now I give it a try with a POJO post to my restcontroller and get this exception:现在我尝试将 POJO 帖子发送到我的 restcontroller 并得到这个异常:

    2019-10-29 09:43:08.193 ERROR 57276 --- [io-15050-exec-1] oac.c.C.[.[.[/].[dispatcherServlet]: Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; 2019-10-29 09:43:08.193 ERROR 57276 --- [io-15050-exec-1] oac.c.C.[.[.[/].[dispatcherServlet]: Servlet.service() for servlet [带有路径 [] 的上下文中的 dispatcherServlet] 引发异常 [请求处理失败; nested exception is org.springframework.dao.DataAccessResourceFailureException: remote server on 192.168.100.8(SpringBasedCacheClientApplication:57276:loner):64494:51246215:SpringBasedCacheClientApplication: : While performing a remote put;嵌套异常是 org.springframework.dao.DataAccessResourceFailureException: remote server on 192.168.100.8(SpringBasedCacheClientApplication:57276:loner):64494:51246215:SpringBasedCacheClientApplication: :执行远程放置时; nested exception is org.apache.geode.cache.client.ServerOperationException: remote server on 192.168.100.8(SpringBasedCacheClientApplication:57276:loner):64494:51246215:SpringBasedCacheClientApplication: : While performing a remote put] with root cause嵌套异常是 org.apache.geode.cache.client.ServerOperationException: remote server on 192.168.100.8(SpringBasedCacheClientApplication:57276:loner):64494:51246215:SpringBasedCacheClientApplication: : While perform a remote put] with root cause

    org.apache.geode.cache.RegionDestroyedException: Server connection from [identity(192.168.100.8(SpringBasedCacheClientApplication:57276:loner):64494:51246215:SpringBasedCacheClientApplication,connection=1; port=64498]: Region named /TitleContent was not found during put request at org.apache.geode.internal.cache.tier.sockets.BaseCommand.writeRegionDestroyedEx(BaseCommand.java:624) ~[geode-core-1.9.1.jar:na] at org.apache.geode.internal.cache.tier.sockets.command.Put65.cmdExecute(Put65.java:185) ~[geode-core-1.9.1.jar:na] at org.apache.geode.internal.cache.tier.sockets.BaseCommand.execute(BaseCommand.java:183) ~[geode-core-1.9.1.Z68995FCBF432492D15 org.apache.geode.cache.RegionDestroyedException: 服务器连接来自 [identity(192.168.100.8(SpringBasedCacheClientApplication:57276:loner):64494:51246215:SpringBasedCacheClientApplication,connection=1; port=64498] 期间找不到区域命名/TitleContent put request at org.apache.geode.internal.cache.tier.sockets.BaseCommand.writeRegionDestroyedEx(BaseCommand.java:624) ~[geode-core-1.9.1.jar:na] at org.apache.geode.internal. cache.tier.sockets.command.Put65.cmdExecute(Put65.java:185) ~[geode-core-1.9.1.jar:na] at org.apache.geode.internal.cache.tier.sockets.BaseCommand.execute (BaseCommand.java:183)~[geode-core-1.9.1.Z68995FCBF432492D15 484D04A9D2AC40Z:na] at org.apache.geode.internal.cache.tier.sockets.ServerConnection.doNormalMessage(ServerConnection.java:851) ~[geode-core-1.9.1.jar:na] at org.apache.geode.internal.cache.tier.sockets.OriginalServerConnection.doOneMessage(OriginalServerConnection.java:75) ~[geode-core-1.9.1.jar:na] at org.apache.geode.internal.cache.tier.sockets.ServerConnection.run(ServerConnection.java:1227) ~[geode-core-1.9.1.jar:na] at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135) ~[na:na] at java.base/java.util.concurrent. 484D04A9D2AC40Z:na] at org.apache.geode.internal.cache.tier.sockets.ServerConnection.doNormalMessage(ServerConnection.java:851) ~[geode-core-1.9.1.jar:na] at org.apache.geode. internal.cache.tier.sockets.OriginalServerConnection.doOneMessage(OriginalServerConnection.java:75) ~[geode-core-1.9.1.jar:na] at org.apache.geode.internal.cache.tier.sockets.ServerConnection.run (ServerConnection.java:1227) ~[geode-core-1.9.1.jar:na] at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135) ~[na:na] at java .base/java.util.concurrent。 ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[na:na] at org.apache.geode.internal.cache.tier.sockets.AcceptorImpl.lambda$initializeServerConnectionThreadPool$3(AcceptorImpl.java:616) ~[geode-core-1.9.1.jar:na] at org.apache.geode.internal.logging.LoggingThreadFactory.lambda$newThread$0(LoggingThreadFactory.java:121) ~[geode-core-1.9.1.jar:na] at java.base/java.lang.Thread.run(Thread.java:844) [na:na] ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[na:na] at org.apache.geode.internal.cache.tier.sockets.AcceptorImpl.lambda$initializeServerConnectionThreadPool$3(AcceptorImpl.java:616) ~[geode- core-1.9.1.jar:na] at org.apache.geode.internal.logging.LoggingThreadFactory.lambda$newThread$0(LoggingThreadFactory.java:121) ~[geode-core-1.9.1.jar:na] at java .base/java.lang.Thread.run(Thread.java:844) [na:na]

  2. This time I un-remark //@EnableClusterConfiguration(useHttp=true) but I remove useHttp and just use @EnableClusterConfiguration, (I suspected error because of this).这次我取消注释 //@EnableClusterConfiguration(useHttp=true) 但我删除了 useHttp 并只使用 @EnableClusterConfiguration,(因此我怀疑错误)。 I stop Spring Client and start it again.我停止 Spring 客户端并重新启动它。 Now it fails, and says: org.apache.geode.cache.RegionExistsException: /TitleContent.现在它失败了,并说:org.apache.geode.cache.RegionExistsException: /TitleContent。

The complete log:完整的日志:

Application run failed

org.springframework.context.ApplicationContextException: Failed to start bean 'gemfireClusterSchemaObjectInitializer'; nested exception is org.apache.geode.cache.execute.FunctionException: org.apache.geode.cache.RegionExistsException: /TitleContent
    at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:185) ~[spring-context-5.2.0.RELEASE.jar:5.2.0.RELEASE]
    at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:53) ~[spring-context-5.2.0.RELEASE.jar:5.2.0.RELEASE]
    at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:360) ~[spring-context-5.2.0.RELEASE.jar:5.2.0.RELEASE]
    at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:158) ~[spring-context-5.2.0.RELEASE.jar:5.2.0.RELEASE]
    at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:122) ~[spring-context-5.2.0.RELEASE.jar:5.2.0.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:894) ~[spring-context-5.2.0.RELEASE.jar:5.2.0.RELEASE]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.finishRefresh(ServletWebServerApplicationContext.java:162) ~[spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:553) ~[spring-context-5.2.0.RELEASE.jar:5.2.0.RELEASE]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141) ~[spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747) [spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) [spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
    at network.powerhouse.commercehost.CommerceHostGeodeApplication.main(CommerceHostGeodeApplication.java:51) [classes/:na]
Caused by: org.apache.geode.cache.execute.FunctionException: org.apache.geode.cache.RegionExistsException: /TitleContent
    at org.apache.geode.internal.cache.tier.sockets.command.ExecuteFunction66.cmdExecute(ExecuteFunction66.java:262) ~[geode-core-1.9.1.jar:na]
    at org.apache.geode.internal.cache.tier.sockets.command.ExecuteFunction70.cmdExecute(ExecuteFunction70.java:66) ~[geode-core-1.9.1.jar:na]
    at org.apache.geode.internal.cache.tier.sockets.BaseCommand.execute(BaseCommand.java:183) ~[geode-core-1.9.1.jar:na]
    at org.apache.geode.internal.cache.tier.sockets.ServerConnection.doNormalMessage(ServerConnection.java:851) ~[geode-core-1.9.1.jar:na]
    at org.apache.geode.internal.cache.tier.sockets.OriginalServerConnection.doOneMessage(OriginalServerConnection.java:75) ~[geode-core-1.9.1.jar:na]
    at org.apache.geode.internal.cache.tier.sockets.ServerConnection.run(ServerConnection.java:1227) ~[geode-core-1.9.1.jar:na]
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135) ~[na:na]
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[na:na]
    at org.apache.geode.internal.cache.tier.sockets.AcceptorImpl.lambda$initializeServerConnectionThreadPool$3(AcceptorImpl.java:616) ~[geode-core-1.9.1.jar:na]
    at org.apache.geode.internal.logging.LoggingThreadFactory.lambda$newThread$0(LoggingThreadFactory.java:121) ~[geode-core-1.9.1.jar:na]
    at java.base/java.lang.Thread.run(Thread.java:844) ~[na:na]
Caused by: org.apache.geode.cache.RegionExistsException: /TitleContent
    at org.apache.geode.internal.cache.GemFireCacheImpl.createVMRegion(GemFireCacheImpl.java:2983) ~[geode-core-1.9.1.jar:na]
    at org.apache.geode.internal.cache.GemFireCacheImpl.basicCreateRegion(GemFireCacheImpl.java:2938) ~[geode-core-1.9.1.jar:na]
    at org.apache.geode.internal.cache.GemFireCacheImpl.createRegion(GemFireCacheImpl.java:2925) ~[geode-core-1.9.1.jar:na]
    at org.apache.geode.cache.RegionFactory.create(RegionFactory.java:755) ~[geode-core-1.9.1.jar:na]
    at org.springframework.data.gemfire.config.admin.functions.CreateRegionFunction.createRegion(CreateRegionFunction.java:51) ~[spring-data-geode-2.2.0.RELEASE.jar:2.2.0.RELEASE]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
    at java.base/java.lang.reflect.Method.invoke(Method.java:564) ~[na:na]
    at org.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:279) ~[spring-core-5.2.0.RELEASE.jar:5.2.0.RELEASE]
    at org.springframework.data.gemfire.function.PojoFunctionWrapper.invokeTargetMethod(PojoFunctionWrapper.java:176) ~[spring-data-geode-2.2.0.RELEASE.jar:2.2.0.RELEASE]
    at org.springframework.data.gemfire.function.PojoFunctionWrapper.execute(PojoFunctionWrapper.java:155) ~[spring-data-geode-2.2.0.RELEASE.jar:2.2.0.RELEASE]
    at org.apache.geode.internal.cache.tier.sockets.command.ExecuteFunction66.executeFunctionLocally(ExecuteFunction66.java:320) ~[geode-core-1.9.1.jar:na]
    at org.apache.geode.internal.cache.tier.sockets.command.ExecuteFunction66.cmdExecute(ExecuteFunction66.java:250) ~[geode-core-1.9.1.jar:na]
    ... 10 common frames omitted
  1. This time I remark again //@EnableClusterConfiguration and start Spring Client again.这次我再次备注 //@EnableClusterConfiguration 并再次启动 Spring Client。 This time it runs and I give a try again with the same POJO.这次它运行了,我再次尝试使用相同的 POJO。 It success !它成功了!

Complete log:完整的日志:

Initializing Spring DispatcherServlet 'dispatcherServlet'
2019-10-29 10:04:04.477  INFO 59413 --- [io-15050-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2019-10-29 10:04:04.483  INFO 59413 --- [io-15050-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 6 ms
2019-10-29 10:04:04.598  INFO 59413 --- [io-15050-exec-1] o.a.geode.pdx.internal.TypeRegistry      : Caching PdxType[dsid=0, typenum=12150516
        name=network.powerhouse.commercehost.model.TitleContent
        fields=[
        id:Object:identity:0:idx0(relativeOffset)=0:idx1(vlfOffsetIndex)=-1
        code:String:1:1:idx0(relativeOffset)=0:idx1(vlfOffsetIndex)=1
        title:String:2:2:idx0(relativeOffset)=0:idx1(vlfOffsetIndex)=2
        content:String:3:3:idx0(relativeOffset)=0:idx1(vlfOffsetIndex)=3]]
  1. I try to get list of TitleContent with GET rest endpoint at the controller with success.我尝试在 controller 端点使用 GET rest 成功获取 TitleContent 列表。

  2. Now I shut down all of them and restart them all.现在我关闭所有这些并重新启动它们。 And i try to get the list as in point 5 and give me exception as in the complete log:我尝试获取第 5 点中的列表,并在完整日志中给我例外:

    Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; Servlet.service() 用于路径 [] 上下文中的 servlet [dispatcherServlet] 引发异常 [请求处理失败; nested exception is org.springframework.dao.DataAccessResourceFailureException: remote server on 192.168.100.8(SpringBasedCacheClientApplication:59853:loner):49745:69bf7c15:SpringBasedCacheClientApplication: While performing a remote query;嵌套异常是 org.springframework.dao.DataAccessResourceFailureException: remote server on 192.168.100.8(SpringBasedCacheClientApplication:59853:loner):49745:69bf7c15:SpringBasedCacheClientApplication: 执行远程查询时; nested exception is org.apache.geode.cache.client.ServerOperationException: remote server on 192.168.100.8(SpringBasedCacheClientApplication:59853:loner):49745:69bf7c15:SpringBasedCacheClientApplication: While performing a remote query] with root cause嵌套异常是 org.apache.geode.cache.client.ServerOperationException: remote server on 192.168.100.8(SpringBasedCacheClientApplication:59853:loner):49745:69bf7c15:SpringBasedCacheClientApplication: While perform a remote query] with root cause

    org.apache.geode.cache.query.RegionNotFoundException: Region not found: /TitleContent at org.apache.geode.cache.query.internal.DefaultQuery.checkQueryOnPR(DefaultQuery.java:464) ~[geode-core-1.9.1.jar:na] at org.apache.geode.cache.query.internal.DefaultQuery.execute(DefaultQuery.java:226) ~[geode-core-1.9.1.jar:na] at org.apache.geode.internal.cache.tier.sockets.BaseCommandQuery.processQueryUsingParams(BaseCommandQuery.java:120) ~[geode-core-1.9.1.jar:na] at org.apache.geode.internal.cache.tier.sockets.command.Query651.cmdExecute(Query651.java:135) ~[geode-core-1.9.1.Z68995FCBF432492D15 org.apache.geode.cache.query.RegionNotFoundException: Region not found: /TitleContent at org.apache.geode.cache.query.internal.DefaultQuery.checkQueryOnPR(DefaultQuery.java:464) ~[geode-core-1.9.1 .jar:na] at org.apache.geode.cache.query.internal.DefaultQuery.execute(DefaultQuery.java:226) ~[geode-core-1.9.1.jar:na] at org.apache.geode.internal .cache.tier.sockets.BaseCommandQuery.processQueryUsingParams(BaseCommandQuery.java:120) ~[geode-core-1.9.1.jar:na] at org.apache.geode.internal.cache.tier.sockets.command.Query651. cmdExecute(Query651.java:135) ~[geode-core-1.9.1.Z68995FCBF432492D15 484D04A9D2AC40Z:na] at org.apache.geode.internal.cache.tier.sockets.BaseCommand.execute(BaseCommand.java:183) ~[geode-core-1.9.1.jar:na] at org.apache.geode.internal.cache.tier.sockets.ServerConnection.doNormalMessage(ServerConnection.java:851) ~[geode-core-1.9.1.jar:na] at org.apache.geode.internal.cache.tier.sockets.OriginalServerConnection.doOneMessage(OriginalServerConnection.java:75) ~[geode-core-1.9.1.jar:na] at org.apache.geode.internal.cache.tier.sockets.ServerConnection.run(ServerConnection.java:1227) ~[geode-core-1.9.1.Z68995FCBF432492D15484D04A9D2AC4 484D04A9D2AC40Z:na] at org.apache.geode.internal.cache.tier.sockets.BaseCommand.execute(BaseCommand.java:183) ~[geode-core-1.9.1.jar:na] at org.apache.geode. internal.cache.tier.sockets.ServerConnection.doNormalMessage(ServerConnection.java:851) ~[geode-core-1.9.1.jar:na] at org.apache.geode.internal.cache.tier.sockets.OriginalServerConnection.doOneMessage (OriginalServerConnection.java:75) ~[geode-core-1.9.1.jar:na] at org.apache.geode.internal.cache.tier.sockets.ServerConnection.run(ServerConnection.java:1227) ~[geode-核心-1.9.1.Z68995FCBF432492D15484D04A9D2AC4 0Z:na] at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135) ~[na:na] at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[na:na] at org.apache.geode.internal.cache.tier.sockets.AcceptorImpl.lambda$initializeServerConnectionThreadPool$3(AcceptorImpl.java:616) ~[geode-core-1.9.1.jar:na] at org.apache.geode.internal.logging.LoggingThreadFactory.lambda$newThread$0(LoggingThreadFactory.java:121) ~[geode-core-1.9.1.jar:na] at java.base/java.lang.Thread.run(Thread.java:844) [na:na] 0Z:na] at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135) ~[na:na] at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor. java:635) ~[na:na] at org.apache.geode.internal.cache.tier.sockets.AcceptorImpl.lambda$initializeServerConnectionThreadPool$3(AcceptorImpl.java:616) ~[geode-core-1.9.1.jar: na] at org.apache.geode.internal.logging.LoggingThreadFactory.lambda$newThread$0(LoggingThreadFactory.java:121) ~[geode-core-1.9.1.jar:na] at java.base/java.lang.Thread .run(Thread.java:844) [na:na]

The Region looks like not persist to disk.该区域看起来不像持久化到磁盘。

Questions:问题:

At point 3 as exception was thrown, but definitely TitleContent region was created.在第 3 点抛出异常,但肯定创建了 TitleContent 区域。 But why exception is thrown?但是为什么会抛出异常?

Can somebody pinpoint what I missed, why @EnableClusterConfiguration behave strangely in my case and why Region is not persisted to disk (according to ref. manual, it should be persisted to disk by DEFAULT DiskStore at 7.12.7 ref. manual).有人可以指出我错过了什么,为什么@EnableClusterConfiguration 在我的情况下表现异常以及为什么 Region 没有持久化到磁盘(根据参考手册,它应该由 DEFAULT DiskStore 在 7.12.7 参考手册中持久化到磁盘)。 I am sorry for such very long questions.对于这么长的问题,我很抱歉。 I just couldn't make it shorter.我只是不能让它更短。

Thank you if somebody may be able to help, I really appreciate it.谢谢你,如果有人可以提供帮助,我真的很感激。

The complete source code list:完整的源代码列表:

SERVER:服务器:

@SpringBootApplication
@CacheServerApplication(locators="localhost[10334]", name="GeodeServerApplication" )
@EnableCacheServer(name="neptunus", autoStartup=true, hostnameForClients = "localhost", port = 48484)
//@EnableCachingDefinedRegions
//@EnableGemfireCaching
@EnablePdx
@EnableManager
@EnableHttpService
public class GeodeServerApplication {

    public static void main(String[] args) {
        SpringApplication.run(GeodeServerApplication.class, args);
    }

} 

LOCATOR:定位器:

@SpringBootApplication
@LocatorApplication(port = 10334)
public class GeodeLocatorApplication {

    public static void main(String[] args) {
        SpringApplication.run(GeodeLocatorApplication.class, args);
    }

}

CLIENT:客户:

@SpringBootApplication
@ClientCacheApplication(logLevel = "debug", locators = {@Locator(host = "localhost", port = 10334)})
@EnablePool(name="neptunusPool", servers=@Server(host="localhost", port=48484))
@EnableGemfireRepositories(basePackageClasses= {network.powerhouse.commercehost.repository.TitleContentRepository.class})
@EnableEntityDefinedRegions(basePackageClasses= {
        network.powerhouse.commercehost.model.TitleContent.class
})
@ReplicateRegion
@EnableClusterDefinedRegions
@EnableCachingDefinedRegions
@EnableGemfireCaching
@EnableIndexing
//@EnableClusterConfiguration
@EnablePdx
public class CommerceHostGeodeApplication {

    public static void main(String[] args) {

        SpringApplication.run(CommerceHostGeodeApplication.class, args);

    }

}

CLIENT CONTROLLER:客户 CONTROLLER:

@RestController
public class TitleContentController {

    @Autowired
    TitleContentService service;

    @PostMapping("/titlecontent")
    TitleContent postTitleContent(@RequestBody TitleContent titleContent) {

        return service.save(titleContent);
    }

    @GetMapping("titlecontent")
    List<TitleContent> getTitleContentByCode(@RequestParam("code") String code){

        return service.findByCode(code);

    }
}

CLIENT REPOSITORY:客户资料库:

@Region("TitleContent")
public interface TitleContentRepository extends CrudRepository<TitleContent, Long> {

    @Trace
    List<TitleContent> findByCode(String code);

}

CLIENT SERVICE:客户服务:

public interface TitleContentServiceInterface {

    public TitleContent save(TitleContent titleContent);
    public void delete(TitleContent titleContent);
    public TitleContent findById(Long id);
    List<TitleContent> findByCode(String code);

}

@Service
public class TitleContentService implements TitleContentServiceInterface{

    @Autowired
    TitleContentRepository repo;


    @Override
    public TitleContent save(TitleContent titleContent) {

        return repo.save(titleContent);
    }

    @Override
    public void delete(TitleContent titleContent) {
        repo.delete(titleContent);

    }

    @Override
    public TitleContent findById(Long id) {
        return repo.findById(id).get();
    }

    @Override
    public List<TitleContent> findByCode(String code) {
        return repo.findByCode(code);
    }

}

POJO: POJO:

@Region("TitleContent")
public class TitleContent {

    @Id
    private Long id;
    @Indexed
    private String code;
    private String title;
    private String content;
    public TitleContent(Long id, String code, String title, String content) {
        super();
        this.id = id;
        this.code = code;
        this.title = title;
        this.content = content;
    }
    public TitleContent() {
        super();
    }
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getTitle() {
        return title;
    }
    public void setTitle(String title) {
        this.title = title;
    }
    public String getContent() {
        return content;
    }
    public void setContent(String content) {
        this.content = content;
    }
    @Override
    public String toString() {
        return "TitleContent [id=" + id + ", code=" + code + ", title=" + title + ", content=" + content + "]";
    }



}

DEPENDENCIES:依赖项:

<dependency>
            <groupId>org.springframework.geode</groupId>
            <artifactId>spring-geode-starter</artifactId>
            <version>1.2.0.RELEASE</version>
        </dependency>

SPRING BOOT VERSION: SPRING 引导版本:

<groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.0.RELEASE</version>

I finally found the way around this, after reading answer from John Blum several time from SpringData Gemfire DiskStore .在从SpringData Gemfire DiskStore多次阅读 John Blum 的回答后,我终于找到了解决方法。

Definitely I couldn't use @EnableClusterConfiguration in my case (still wondering why).在我的情况下,我绝对不能使用@EnableClusterConfiguration(仍然想知道为什么)。 According to John, we are able to create Region using gfsh.根据 John 的说法,我们能够使用 gfsh 创建 Region。 From this I get an idea to do the same at Spring Boot CacheServer.由此我想到在 Spring Boot CacheServer 上做同样的事情。 So, how if I define my POJO at CacheServer and let annotation @EnableEntityDefinedRegions do the job to create the region at CacheServer side.那么,如果我在 CacheServer 定义我的 POJO 并让注释 @EnableEntityDefinedRegions 完成在 CacheServer 端创建区域的工作。 Again I borrow我又借了

serverRegionShortcut = RegionShortcut.PARTITION_PERSISTENT serverRegionShortcut = RegionShortcut.PARTITION_PERSISTENT

from John but I put it at来自约翰,但我把它放在

@EnableEntityDefinedRegions @EnableEntityDefinedRegions

Beside that I also need to persist my PDX type (Spring and/or Geode Gemfire do not like me if I am not persisting Pdx type at CacheServer side).除此之外,我还需要坚持我的 PDX 类型(如果我不在 CacheServer 端坚持 Pdx 类型,Spring 和/或 Geode Gemfire 不喜欢我)。 So, I am using the same method to persist from SpringData Gemfire DiskStore but I implement it at CacheServer side with some additional entry at application.properties to tell spring to persist Pdx type as well.因此,我使用相同的方法从SpringData Gemfire DiskStore持久化,但我在 CacheServer 端实现它,并在 application.properties 中添加一些额外条目,以告诉 spring 也持久化 Pdx 类型。

In that way, I am able to successfully create and persisting Region at CacheServer side and also persisting Pdx as well.通过这种方式,我能够在 CacheServer 端成功地创建和持久化 Region,并且还可以持久化 Pdx。

Here is the complete code and application.properties I made with borrowing the idea from SpringData Gemfire DiskStore .这是我借用SpringData Gemfire DiskStore的想法制作的完整代码和 application.properties。

I appreciate if anybody able to tell me whether this work around is a good way to do or is there any other way or any better idea (still wondering though why @EnableClusterConfiguration doesn't like me while anybody else has no problem with it:=(, so if there is anybody who is able to tell me where is(are) my mistake(s) I really appreciate it ).如果有人能够告诉我这种解决方法是否是一种好方法,或者是否有任何其他方法或更好的想法,我将不胜感激(仍然想知道为什么@EnableClusterConfiguration 不喜欢我,而其他人对此没有任何问题:= (所以如果有人能够告诉我我的错误在哪里,我真的很感激)。

CLIENT:客户:

@SpringBootApplication
@ClientCacheApplication(logLevel = "debug", locators = {@Locator(host = "localhost", port = 10334)})
@EnablePool(name="neptunusPool", servers=@Server(host="localhost", port=41414))
@EnableGemfireRepositories(basePackageClasses= {TitleContentRepository.class})
@EnableEntityDefinedRegions(basePackageClasses= {TitleContent.class
})
//@ReplicateRegion
//@EnableClusterDefinedRegions
//@EnableCachingDefinedRegions
//@EnableGemfireCaching
@EnableIndexing
//@EnableClusterConfiguration
@EnablePdx

public class CommerceHostGeodeApplication {

    public static void main(String[] args) {

        SpringApplication.run(CommerceHostGeodeApplication.class, args);

    }

}

At client side the same POJO, Repository and RestController and nothing in application.properties except for server.port definition.在客户端,相同的 POJO、Repository 和 RestController 和 application.properties 中除了 server.port 定义之外没有任何内容。

CACHESERVER:缓存服务器:

@SpringBootApplication
@CacheServerApplication(locators="localhost[10334]", name="GeodeServerApplication" )
@EnableCacheServer(name="neptunus", autoStartup=true, hostnameForClients = "localhost", port = 41414)
@EnableCachingDefinedRegions
@EnableGemfireCaching
@EnablePdx
@EnableManager
@EnableHttpService
@EnableDiskStore(name = "disk_store")
@EnableEntityDefinedRegions(basePackageClasses= {TitleContent.class
}, serverRegionShortcut = RegionShortcut.PARTITION_PERSISTENT)
public class GeodeServerApplication {

    public static void main(String[] args) {
        SpringApplication.run(GeodeServerApplication.class, args);
    }

}

CACHESERVER application.properties: CACHESERVER application.properties:

server.port=15010
spring.data.gemfire.disk.store.name=disk_store
spring.data.gemfire.disk.store.directory.location=/Users/ars/geode/data
spring.data.gemfire.pdx.disk-store-name=disk_store
spring.data.gemfire.pdx.persistent=true
spring.data.gemfire.management.use-http=true

Upon CacheServer start, region is created and is able to persist / save to disk.在 CacheServer 启动时,区域被创建并且能够持久化/保存到磁盘。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM