From 9b5b16ef11a492af54c7be5559c80496911351a6 Mon Sep 17 00:00:00 2001 From: Lingxuan Zuo Date: Thu, 6 Aug 2020 01:36:06 +0800 Subject: [PATCH] [GCS] fix gcs table get all nodes npe (#9927) --- .../java/io/ray/runtime/gcs/GcsClient.java | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/java/runtime/src/main/java/io/ray/runtime/gcs/GcsClient.java b/java/runtime/src/main/java/io/ray/runtime/gcs/GcsClient.java index 6398614b2..a0f0f218d 100644 --- a/java/runtime/src/main/java/io/ray/runtime/gcs/GcsClient.java +++ b/java/runtime/src/main/java/io/ray/runtime/gcs/GcsClient.java @@ -68,19 +68,12 @@ public class GcsClient { final UniqueId nodeId = UniqueId .fromByteBuffer(data.getNodeId().asReadOnlyByteBuffer()); - if (data.getState() == GcsNodeInfo.GcsNodeState.ALIVE) { - //Code path of node insertion. - NodeInfo nodeInfo = new NodeInfo( - nodeId, data.getNodeManagerAddress(), - data.getNodeManagerHostname(), - true, new HashMap<>()); - nodes.put(nodeId, nodeInfo); - } else { - // Code path of node deletion. - NodeInfo nodeInfo = new NodeInfo(nodeId, nodes.get(nodeId).nodeAddress, - nodes.get(nodeId).nodeHostname, false, new HashMap<>()); - nodes.put(nodeId, nodeInfo); - } + // NOTE(lingxuan.zlx): we assume no duplicated node id in fetched node list + // and it's only one final state for each node in recorded table. + NodeInfo nodeInfo = new NodeInfo( + nodeId, data.getNodeManagerAddress(), data.getNodeManagerHostname(), + data.getState() == GcsNodeInfo.GcsNodeState.ALIVE, new HashMap<>()); + nodes.put(nodeId, nodeInfo); } // Fill resources.