!495 [I2AMGW] When multiple coordinators are used, don't update memory pool info if work is not scheduled on coordinator

Merge pull request !495 from Arven/fix-ha-cn-memory-pool
This commit is contained in:
i-robot 2020-12-24 10:35:19 +08:00 committed by Gitee
commit 7eb2fcfece
1 changed files with 8 additions and 7 deletions

View File

@ -531,23 +531,24 @@ public class ClusterMemoryManager
// Add new nodes
for (InternalNode node : aliveNodes) {
if (!nodes.containsKey(node.getNodeIdentifier())) {
if (!nodes.containsKey(node.getNodeIdentifier()) && shouldIncludeNode(node)) {
nodes.put(node.getNodeIdentifier(), new RemoteNodeMemory(node, httpClient, memoryInfoCodec, assignmentsRequestCodec, locationFactory.createMemoryInfoLocation(node), isBinaryEncoding));
}
}
// If work isn't scheduled on the coordinator (the current node) there is no point
// in polling or updating (when moving queries to the reserved pool) its memory pools
if (!isWorkScheduledOnCoordinator) {
nodes.remove(nodeManager.getCurrentNode().getNodeIdentifier());
}
// Schedule refresh
for (RemoteNodeMemory node : nodes.values()) {
node.asyncRefresh(assignments);
}
}
private boolean shouldIncludeNode(InternalNode node)
{
// If work isn't scheduled on the coordinator (the current node) there is no point
// in polling or updating (when moving queries to the reserved pool) its memory pools
return isWorkScheduledOnCoordinator || !node.isCoordinator();
}
private synchronized void updatePools(Map<MemoryPoolId, Integer> queryCounts)
{
// Update view of cluster memory and pools