private NodeState handleError(GetNodeStateRequest req, NodeInfo info, long currentTime) {
        String prefix = "Failed get node state request: ";
        NodeState newState = new NodeState(info.getNode().getType(), DOWN);
        if (req.getReply().getReturnCode() == ErrorCode.TIMEOUT) {
            String msg = "RPC timeout";
            if (info.getReportedState().getState().oneOf("ui")) {
                eventLog.addNodeOnlyEvent(NodeEvent.forBaseline(info, prefix + "RPC timeout talking to node.", NodeEvent.Type.REPORTED, currentTime), Level.INFO);
            } else if (!info.getReportedState().hasDescription() || !info.getReportedState().getDescription().equals(msg)) {
                log.log(Level.FINE, () -> "Failed to talk to node " + info + ": " + req.getReply().getReturnCode() + " " + req.getReply().getReturnMessage() + ": " + msg);
            }
            newState.setDescription(msg);
        } else if (req.getReply().getReturnCode() == ErrorCode.CONNECTION) {
            Target target = info.lastRequestInfoConnection;
            Exception reason = (target == null ? null : target.getConnectionLostReason());
            if (reason != null) {
                String msg = reason.getMessage();
                if (msg == null) msg = "(null)";
                newState.setDescription(msg);
                if (msg.equals("Connection refused")) {
                    msg = "Connection error: Connection refused";
                    if (info.getReportedState().getState().oneOf("ui")) {
                        eventLog.addNodeOnlyEvent(NodeEvent.forBaseline(info, prefix + msg, NodeEvent.Type.REPORTED, currentTime), Level.INFO);
                    } else if (!info.getReportedState().hasDescription() || !info.getReportedState().getDescription().equals(msg)) {
                        if (log.isLoggable(Level.FINE))
                            log.log(Level.FINE, "Failed to talk to node " + info + ": " + req.getReply().getReturnCode()
                                                + " " + req.getReply().getReturnMessage() + ": " + msg);
                    }
                    newState.setState(DOWN);
                } else if (msg.equals("jrt: Connection closed by peer") || msg.equals("Connection reset by peer")) {
                    msg = "Connection error: Closed at other end. (Node or switch likely shut down)";
                    if (info.isNotInSlobrok()) {
                        msg += " Node is no longer in slobrok.";
                    }
                    if (info.getReportedState().getState().oneOf("ui")) {
                        eventLog.addNodeOnlyEvent(NodeEvent.forBaseline(info, prefix + msg, NodeEvent.Type.REPORTED, currentTime), Level.INFO);
                    } else if (!info.getReportedState().hasDescription() || !info.getReportedState().getDescription().equals(msg)) {
                        if (log.isLoggable(Level.FINE))
                            log.log(Level.FINE, "Failed to talk to node " + info + ": " + req.getReply().getReturnCode() + " " + req.getReply().getReturnMessage() + ": " + msg);
                    }
                    newState.setState(DOWN).setDescription(msg);
                } else if (msg.equals("Connection timed out")) {
                    if (info.getReportedState().getState().oneOf("ui")) {
                        msg = "Connection error: Timeout";
                        eventLog.addNodeOnlyEvent(NodeEvent.forBaseline(info, prefix + msg, NodeEvent.Type.REPORTED, currentTime), Level.INFO);
                    } else {
                        if (log.isLoggable(Level.FINE))
                            log.log(Level.FINE, "Failed to talk to node " + info + ": " + req.getReply().getReturnCode() + " " + req.getReply().getReturnMessage() + ": " + msg);
                    }
                } else {
                    msg = "Connection error: " + reason;
                    if (info.getReportedState().getState().oneOf("ui")) {
                        eventLog.addNodeOnlyEvent(NodeEvent.forBaseline(info, prefix + msg, NodeEvent.Type.REPORTED, currentTime), Level.WARNING);
                    } else if (!info.getReportedState().hasDescription() || !info.getReportedState().getDescription().equals(msg)) {
                        if (log.isLoggable(Level.FINE))
                            log.log(Level.FINE, "Failed to talk to node " + info + ": " + req.getReply().getReturnCode() + " " + req.getReply().getReturnMessage() + ": " + msg);
                    }
                    newState.setDescription(msg);
                }
            } else {
                String msg = "Connection error: Unexpected error with no reason set. Assuming it is a network issue: " +
                        req.getReply().getReturnCode() + ": " + req.getReply().getReturnMessage();

                if (info.getReportedState().getState().oneOf("ui")) {
                    eventLog.addNodeOnlyEvent(NodeEvent.forBaseline(info, prefix + msg, NodeEvent.Type.REPORTED, currentTime), Level.WARNING);
                } else if (!info.getReportedState().hasDescription() || !info.getReportedState().getDescription().equals(msg)) {
                    log.log(Level.FINE, () -> "Failed to talk to node " + info + ": " + req.getReply().getReturnCode() + " " + req.getReply().getReturnMessage() + ": " + msg);
                }
                newState.setDescription(msg);
            }
        } else if (req.getReply().getReturnCode() == Communicator.TRANSIENT_ERROR) {
            return null;
        } else if (req.getReply().getReturnCode() == ErrorCode.NO_SUCH_METHOD) {
            String msg = "no such RPC method error";
            if (info.getReportedState().getState().oneOf("ui")) {
                eventLog.addNodeOnlyEvent(NodeEvent.forBaseline(info, prefix + msg, NodeEvent.Type.REPORTED, currentTime), Level.WARNING);
            } else if (!info.getReportedState().hasDescription() || !info.getReportedState().getDescription().equals(msg)) {
                log.log(Level.FINE, () -> "Failed to talk to node " + info + ": " + req.getReply().getReturnCode() + " " + req.getReply().getReturnMessage() + ": " + msg);
            }
            newState.setState(DOWN).setDescription(msg + ": get node state");
        } else if (req.getReply().getReturnCode() == 75004) {
            String msg = "Node refused to answer RPC request and is likely stopping: " + req.getReply().getReturnMessage();
                // The node is shutting down and is not accepting requests from anyone
            if (info.getReportedState().getState().equals(STOPPING)) {
                log.log(Level.FINE, () -> "Failed to get node state from " + info + " because it is still shutting down.");
            } else {
                if (info.getReportedState().getState().oneOf("ui")) {
                    eventLog.addNodeOnlyEvent(NodeEvent.forBaseline(info, prefix + msg, NodeEvent.Type.REPORTED, currentTime), Level.INFO);
                } else if (!info.getReportedState().hasDescription() || !info.getReportedState().getDescription().equals(msg)) {
                    log.log(Level.FINE, () -> "Failed to talk to node " + info + ": " + req.getReply().getReturnCode() + " " + req.getReply().getReturnMessage() + ": " + msg);
                }
            }
            newState.setState(STOPPING).setDescription(msg);
        } else {
            String msg = "Got unexpected error, assumed to be node issue " + req.getReply().getReturnCode() + ": " + req.getReply().getReturnMessage();
            if (info.getReportedState().getState().oneOf("ui")) {
                eventLog.addNodeOnlyEvent(NodeEvent.forBaseline(info, prefix + msg, NodeEvent.Type.REPORTED, currentTime), Level.WARNING);
            } else if (!info.getReportedState().hasDescription() || !info.getReportedState().getDescription().equals(msg)) {
                log.log(Level.FINE, () -> "Failed to talk to node " + info + ": " + req.getReply().getReturnCode() + " " + req.getReply().getReturnMessage() + ": " + msg);
            }
            newState.setState(DOWN).setDescription(msg);
        }
        return newState;
    }
Reads replies to get node state requests and create events.
clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/NodeStateGatherer.java