为了账号安全,请及时绑定邮箱和手机立即绑定

创建区域并将区域保留到磁盘时出现问题 Geode Gemfire Spring Boot

创建区域并将区域保留到磁盘时出现问题 Geode Gemfire Spring Boot

陪伴而非守候 2024-01-05 09:57:22
我观看了 Springone Platform 和 John Blum 作为演讲者的视频,并有兴趣尝试一下 Geode/Gemfire 设置,但设置如Spring Data for Apache Geode 参考指南中所述所以我使用 Eclipse 制作 spring boot geode 客户端、定位器和缓存服务器,并且在以下情况下遇到问题:启动 spring locator,启动缓存服务器,并使用 Restcontroller 启动客户端,以便我可以发布我的 POJO TitleContent 并获取 TitleContent 列表。客户给我异常原因: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)我注释@EnableClusterConfiguration(useHttp=true)并再次启动客户端,现在可以运行了。现在我尝试将 POJO 发布到我的 Restcontroller 并得到此异常:2019-10-29 09:43:08.193 ERROR 57276 --- [io-15050-exec-1] oaccC[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] 在上下文中path[]抛出异常[请求处理失败;嵌套异常是 org.springframework.dao.DataAccessResourceFailureException: Remote server on 192.168.100.8(SpringBasedCacheClientApplication:57276:loner):64494:51246215:SpringBasedCacheClientApplication: : 执行远程放置时;嵌套异常是 org.apache.geode.cache.client.ServerOperationException: 192.168.100.8(SpringBasedCacheClientApplication:57276:loner):64494:51246215:SpringBasedCacheClientApplication: 上的远程服务器::执行远程放置时],其根本原因org.apache.geode.cache.RegionDestroyedException:来自 [identity(192.168.100.8(SpringBasedCacheClientApplication:57276:loner):64494:51246215:SpringBasedCacheClientApplication,connection=1; port=64498] 的服务器连接:期间未找到名为 /TitleContent 的区域将请求放在 org.apache.geode.internal.cache.tier.sockets.BaseCommand.writeRegionDestroyedEx(BaseCommand.java:624) ~[geode-core-1.9.1.jar:na] 处 这次我取消了 //@EnableClusterConfiguration(useHttp=true) 的注释,但我删除了 useHttp 并仅使用 @EnableClusterConfiguration,(因此我怀疑错误)。我停止 Spring Client 并再次启动它。现在它失败了,并显示:org.apache.geode.cache.RegionExistsException:/TitleContent。
查看完整描述

1 回答

?
慕森卡

TA贡献1806条经验 获得超8个赞

在我的例子中,我绝对不能使用@EnableClusterConfiguration(仍然想知道为什么)。根据 John 的说法,我们可以使用 gfsh 创建区域。由此我想到在 Spring Boot CacheServer 上做同样的事情。那么,如果我在 CacheServer 定义 POJO 并让注释 @EnableEntityDefinedRegions 完成在 CacheServer 端创建区域的工作,该怎么办?我又借了

serverRegionShortcut = RegionShortcut.PARTITION_PERSISTENT

来自约翰,但我把它放在

@EnableEntityDefinedRegions

除此之外,我还需要保留我的 PDX 类型(如果我不在 CacheServer 端保留 Pdx 类型,Spring 和/或 Geode Gemfire 不喜欢我)。因此,我使用相同的方法从SpringData Gemfire DiskStore进行持久化,但我在 CacheServer 端实现它,并在 application.properties 中添加一些附加条目来告诉 spring 也持久化 Pdx 类型。

这样,我就能够在 CacheServer 端成功创建和持久化 Region,并且还能够持久化 Pdx。

这是我借用SpringData Gemfire DiskStore的想法制作的完整代码和 application.properties 。

如果有人能够告诉我这个解决方法是否是一个好方法,或者是否有其他方法或更好的想法(仍然想知道为什么 @EnableClusterConfiguration 不喜欢我,而其他人对此没有问题:= (所以,如果有人能够告诉我我的错误在哪里,我真的很感激)。

客户 :

@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);


    }


}

在客户端,相同的 POJO、Repository 和 RestController,除了 server.port 定义之外,application.properties 中没有任何内容。


缓存服务器:


@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 :


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

CacheServer 启动后,区域将被创建并能够持久/保存到磁盘。


查看完整回答
反对 回复 2024-01-05
  • 1 回答
  • 0 关注
  • 42 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信