/** * Produced a serialized form which can be served up as JSON * @param naming map of priority -> value for naming entries * @return a summary of the current role status. */ public synchronized NodeInformation serialize(Map<Integer, String> naming) { NodeInformation info = new NodeInformation(); info.hostname = hostname; // null-handling state constructor info.state = "" + nodeState; info.lastUpdated = nodeStateUpdateTime; info.labels = nodeLabels; if (nodeReport != null) { info.httpAddress = nodeReport.getHttpAddress(); info.rackName = nodeReport.getRackName(); info.healthReport = nodeReport.getHealthReport(); } info.entries = new HashMap<>(nodeEntries.size()); for (NodeEntry nodeEntry : nodeEntries) { String name = naming.get(nodeEntry.rolePriority); if (name == null) { name = Integer.toString(nodeEntry.rolePriority); } info.entries.put(name, nodeEntry.serialize()); } return info; }
/** * Produced a serialized form which can be served up as JSON * @param naming map of priority -> value for naming entries * @return a summary of the current role status. */ public synchronized NodeInformation serialize(Map<Integer, String> naming) { NodeInformation info = new NodeInformation(); info.hostname = hostname; // null-handling state constructor info.state = "" + nodeState; info.lastUpdated = nodeStateUpdateTime; info.labels = nodeLabels; if (nodeReport != null) { info.httpAddress = nodeReport.getHttpAddress(); info.rackName = nodeReport.getRackName(); info.healthReport = nodeReport.getHealthReport(); } info.entries = new HashMap<>(nodeEntries.size()); for (NodeEntry nodeEntry : nodeEntries) { String name = naming.get(nodeEntry.rolePriority); if (name == null) { name = Integer.toString(nodeEntry.rolePriority); } info.entries.put(name, nodeEntry.serialize()); } return info; }