public boolean isRegistered() { return isAlive() && !forceRegistration; }
/** * Is data-node the replica belongs to alive. */ boolean isAlive() { return expectedLocation.getDatanodeDescriptor().isAlive(); }
/** * Will return true for all Datanodes which have a non-null software * version and are considered alive (by {@link DatanodeDescriptor#isAlive()}), * indicating the node has not yet been removed. Use {@code isAlive} * rather than {@link DatanodeManager#isDatanodeDead(DatanodeDescriptor)} * to ensure that the version is decremented even if the datanode * hasn't issued a heartbeat recently. * * @param node The datanode in question * @return True iff its version count should be decremented */ private boolean shouldCountVersion(DatanodeDescriptor node) { return node.getSoftwareVersion() != null && node.isAlive(); }
synchronized void removeDatanode(DatanodeDescriptor node) { if (node.isAlive()) { stats.subtract(node); datanodes.remove(node); node.setAlive(false); } }
synchronized void startDecommission(final DatanodeDescriptor node) { if (!node.isAlive()) { LOG.info("Dead node {} is decommissioned immediately.", node); node.setDecommissioned(); } else { stats.subtract(node); node.startDecommission(); stats.add(node); } }
synchronized void register(final DatanodeDescriptor d) { if (!d.isAlive()) { addDatanode(d); //update its timestamp d.updateHeartbeatState(StorageReport.EMPTY_ARRAY, 0L, 0L, 0, 0, null); stats.add(d); } }
/** * Returns whether a node can be safely decommissioned or in maintenance * based on its liveness. Dead nodes cannot always be safely decommissioned * or in maintenance. */ boolean isNodeHealthyForDecommissionOrMaintenance(DatanodeDescriptor node) { if (!node.checkBlockReportReceived()) { LOG.info("Node {} hasn't sent its first block report.", node); return false; } if (node.isAlive()) { return true; } updateState(); if (pendingReconstructionBlocksCount == 0 && lowRedundancyBlocksCount == 0) { LOG.info("Node {} is dead and there are no low redundancy" + " blocks or blocks pending reconstruction. Safe to decommission or", " put in maintenance.", node); return true; } LOG.warn("Node {} is dead " + "while in {}. Cannot be safely " + "decommissioned or be in maintenance since there is risk of reduced " + "data durability or data loss. Either restart the failed node or " + "force decommissioning or maintenance by removing, calling " + "refreshNodes, then re-adding to the excludes or host config files.", node, node.getAdminState()); return false; }
/** * Stop decommissioning the specified datanode. * @param node */ @VisibleForTesting public void stopDecommission(DatanodeDescriptor node) { if (node.isDecommissionInProgress() || node.isDecommissioned()) { // Update DN stats maintained by HeartbeatManager hbManager.stopDecommission(node); // extra redundancy blocks will be detected and processed when // the dead node comes back and send in its full block report. if (node.isAlive()) { blockManager.processExtraRedundancyBlocksOnInService(node); } // Remove from tracking in DatanodeAdminManager pendingNodes.remove(node); outOfServiceNodeBlocks.remove(node); } else { LOG.trace("stopDecommission: Node {} in {}, nothing to do.", node, node.getAdminState()); } }
private List<Integer> findLeavingServiceSources() { List<Integer> srcIndices = new ArrayList<>(); for (int i = 0; i < getSrcNodes().length; i++) { if (getSrcNodes()[i].isDecommissionInProgress() || (getSrcNodes()[i].isEnteringMaintenance() && getSrcNodes()[i].isAlive())) { srcIndices.add(i); } } return srcIndices; } }
if (!node.isAlive()) {
synchronized void startMaintenance(final DatanodeDescriptor node) { if (!node.isAlive()) { LOG.info("Dead node {} is put in maintenance state immediately.", node); node.setInMaintenance(); } else { stats.subtract(node); if (node.isDecommissioned()) { LOG.info("Decommissioned node " + node + " is put in maintenance state" + " immediately."); node.setInMaintenance(); } else if (blockManager.getMinReplicationToBeInMaintenance() == 0) { LOG.info("MinReplicationToBeInMaintenance is set to zero. " + node + " is put in maintenance state" + " immediately."); node.setInMaintenance(); } else { node.startMaintenance(); } stats.add(node); } }
s = StoredReplicaState.DECOMMISSIONED; } else if (node.isMaintenance()) { if (node.isInMaintenance() || !node.isAlive()) { s = StoredReplicaState.MAINTENANCE_NOT_FOR_READ; } else {
|| (d.isEnteringMaintenance() && !d.isAlive())) { continue;