bschuchardt commented on a change in pull request #6013:
URL: https://github.com/apache/geode/pull/6013#discussion_r577784529
##########
File path:
geode-wan/src/main/java/org/apache/geode/cache/client/internal/locator/wan/LocatorHelper.java
##########
@@ -46,13 +47,42 @@ public static boolean addLocator(int distributedSystemId,
DistributionLocatorId
Set<DistributionLocatorId> existingValue =
allLocatorsInfo.putIfAbsent(distributedSystemId, locatorsSet);
if (existingValue != null) {
- if (!existingValue.contains(locator)) {
+ if (!locator.getMemberName().equals(DistributionConfig.DEFAULT_NAME)) {
+ DistributionLocatorId existingLocator =
+ getLocatorWithSameMemberName(existingValue, locator);
+
+ if (existingLocator != null) {
+ // if locator with same name exist, check did all parameters are same
+ if (!locator.detailCompare(existingLocator)) {
+ // some parameters had changed for existing locator
+ // replace it
+ existingValue.remove(existingLocator);
+ ConcurrentHashMap<Integer, Set<String>> allServerLocatorsInfo =
+ (ConcurrentHashMap<Integer, Set<String>>) locatorListener
+ .getAllServerLocatorsInfo();
+ Set<String> alllocators =
allServerLocatorsInfo.get(distributedSystemId);
+ alllocators.remove(existingLocator.toString());
+ existingValue.add(locator);
+ addServerLocator(distributedSystemId, locatorListener, locator);
+ locatorListener.locatorJoined(distributedSystemId, locator,
sourceLocator);
+ return true;
+ }
+ return false;
+ }
existingValue.add(locator);
Review comment:
The new changes still seem to have the same problem. If I add a new
locator with the same host:port but a **different** member _name_ it will still
spawn a thread to invoke locatorJoined in the _else_ clause after "} else if
(!existingValue.contains(locator)) {".
Your PR's intent is to scrub an old ID for a new locator that has the
**same** member _name_ regardless of its host:port. If that check fails,
meaning there is no ID with the same member _name_, we should then check to see
if there is already an ID with the host:port. If a match is found we should
not invoke locatorJoined on the listener.
Every invocation of that method spawns a thread and that's causing problems.
Adding some unit tests for these required behaviors would help ensure that
things work correctly.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]