|
|
@ -125,8 +125,10 @@ public class ZkDiscoveryService implements DiscoveryService, PathChildrenCacheLi |
|
|
log.debug("Ignoring application ready event, ZK client is not started, ZK client state [{}]", client.getState()); |
|
|
log.debug("Ignoring application ready event, ZK client is not started, ZK client state [{}]", client.getState()); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
log.info("Going to publish current server..."); |
|
|
publishCurrentServer(); |
|
|
publishCurrentServer(); |
|
|
partitionService.recalculatePartitions(serviceInfoProvider.getServiceInfo(), getOtherServers()); |
|
|
log.info("Going to recalculate partitions..."); |
|
|
|
|
|
recalculatePartitions(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public synchronized void publishCurrentServer() { |
|
|
public synchronized void publishCurrentServer() { |
|
|
@ -281,11 +283,19 @@ public class ZkDiscoveryService implements DiscoveryService, PathChildrenCacheLi |
|
|
case CHILD_ADDED: |
|
|
case CHILD_ADDED: |
|
|
case CHILD_UPDATED: |
|
|
case CHILD_UPDATED: |
|
|
case CHILD_REMOVED: |
|
|
case CHILD_REMOVED: |
|
|
partitionService.recalculatePartitions(serviceInfoProvider.getServiceInfo(), getOtherServers()); |
|
|
recalculatePartitions(); |
|
|
break; |
|
|
break; |
|
|
default: |
|
|
default: |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* A single entry point to recalculate partitions |
|
|
|
|
|
* Synchronized to ensure that other servers info is up to date |
|
|
|
|
|
* */ |
|
|
|
|
|
synchronized void recalculatePartitions() { |
|
|
|
|
|
partitionService.recalculatePartitions(serviceInfoProvider.getServiceInfo(), getOtherServers()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|