Below is my cluster configuration.
Cache 1 running on 1st JVM
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);
Cache 2 running on 2nd JVM (or another IP)
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);
The output of the above line i.e person retrieved from region.get()
is null
.
The question is: Is this the right configuration for peer to peer configuration?
Can you please suggest an example for creating a peer to peer cluster for Apache geode using a programmatic approach.
You basically need to configure the list of locators
used by the members so they can "see" each other, locators are mandatory even when using a peer to peer topology. Please have a look at Peer-to-Peer Configuration for further details.
Cheers