如何为 apache geode 创建对等拓扑

How to create peer to peer topology for apache geode

下面是我的集群配置。

在第一个 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 创建对等集群的示例。

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

干杯