Commit 562637ad340d2f643e149528035f4c7b6a584101

Authored by Sergey Matvienko
Committed by Andrew Shvayka
1 parent e64b1074

ZKDiscoveryService: fix potential outdated server info on recalculatePartitions.…

… info logs added on application event
... ... @@ -125,8 +125,10 @@ public class ZkDiscoveryService implements DiscoveryService, PathChildrenCacheLi
125 125 log.debug("Ignoring application ready event, ZK client is not started, ZK client state [{}]", client.getState());
126 126 return;
127 127 }
  128 + log.info("Going to publish current server...");
128 129 publishCurrentServer();
129   - partitionService.recalculatePartitions(serviceInfoProvider.getServiceInfo(), getOtherServers());
  130 + log.info("Going to recalculate partitions...");
  131 + recalculatePartitions();
130 132 }
131 133
132 134 public synchronized void publishCurrentServer() {
... ... @@ -281,11 +283,19 @@ public class ZkDiscoveryService implements DiscoveryService, PathChildrenCacheLi
281 283 case CHILD_ADDED:
282 284 case CHILD_UPDATED:
283 285 case CHILD_REMOVED:
284   - partitionService.recalculatePartitions(serviceInfoProvider.getServiceInfo(), getOtherServers());
  286 + recalculatePartitions();
285 287 break;
286 288 default:
287 289 break;
288 290 }
289 291 }
290 292
  293 + /**
  294 + * A single entry point to recalculate partitions
  295 + * Synchronized to ensure that other servers info is up to date
  296 + * */
  297 + synchronized void recalculatePartitions() {
  298 + partitionService.recalculatePartitions(serviceInfoProvider.getServiceInfo(), getOtherServers());
  299 + }
  300 +
291 301 }
... ...