如何为Apache Geode创建对等拓扑

问题描述 投票:2回答:1

下面是我的集群配置。

在第一个JVM上运行的高速缓存1

Properties properties = new Properties();        
properties.setProperty("mcast-address", "224.0.0.0");
properties.setProperty("mcast-port", "0");
// This line is commented. Need to know if locator is required for peer to peer configuration.
//properties.setProperty("locators", "localhost[13489]");

CacheFactory cacheFactory = new CacheFactory(properties);

// ...

Cache cache = cacheFactory.create();
RegionFactory<String, Person> regionFactory = cache.createRegionFactory();
Region<String, Person> region = regionFactory.create("Person");
Person person = new Person(firstName, lastName);
region.put(person.getFirstName(), person);

在第二个JVM(或另一个IP)上运行的缓存2

Properties properties = new Properties();        
properties.setProperty("mcast-address", "224.0.0.0");
properties.setProperty("mcast-port", "0");
// This line is commented. Need to know if locator is required for peer to peer configuration.
//properties.setProperty("locators", "localhost[13489]");

CacheFactory cacheFactory = new CacheFactory(properties);

Cache cache = cacheFactory.create();
RegionFactory<String, Person> regionFactory = cache.createRegionFactory();
Region<String, Person> region = regionFactory.create("Person");
Person person = region.get(firstName);

上述行的输出,即从region.get()中检索到的人是null

问题是:这是对等配置的正确配置吗?

您能提出一个使用编程方法为Apache geode创建对等集群的示例。

java geode
1个回答
1
投票

您基本上需要配置成员使用的locators列表,以便他们可以彼此“看到”,即使使用对等拓扑,定位器也是必需的。请查看Peer-to-Peer配置以获取更多详细信息。

欢呼声

© www.soinside.com 2019 - 2024. All rights reserved.