@Override public String toString() { return "ReportedBlockInfo [block=" + block + ", dn=" + storageInfo.getDatanodeDescriptor() + ", reportedState=" + reportedState + "]"; } }
/** @return the node of the second replica */ private static DatanodeDescriptor secondNode(Node localMachine, List<DatanodeStorageInfo> results) { // find the second replica for(DatanodeStorageInfo nextStorage : results) { DatanodeDescriptor nextNode = nextStorage.getDatanodeDescriptor(); if (nextNode != localMachine) { return nextNode; } } return null; }
static DatanodeDescriptor[] toDatanodeDescriptors( DatanodeStorageInfo[] storages) { DatanodeDescriptor[] datanodes = new DatanodeDescriptor[storages.length]; for (int i = 0; i < storages.length; ++i) { datanodes[i] = storages[i].getDatanodeDescriptor(); } return datanodes; }
static DatanodeInfo[] toDatanodeInfos(List<DatanodeStorageInfo> storages) { final DatanodeInfo[] datanodes = new DatanodeInfo[storages.size()]; for(int i = 0; i < storages.size(); i++) { datanodes[i] = storages.get(i).getDatanodeDescriptor(); } return datanodes; }
protected <T> DatanodeInfo getDatanodeInfo(T datanode) { Preconditions.checkArgument( datanode instanceof DatanodeInfo || datanode instanceof DatanodeStorageInfo, "class " + datanode.getClass().getName() + " not allowed"); if (datanode instanceof DatanodeInfo) { return ((DatanodeInfo)datanode); } else { return ((DatanodeStorageInfo)datanode).getDatanodeDescriptor(); } }
public void appendUCPartsConcise(StringBuilder sb) { sb.append("replicas="); int i = 0; for (ReplicaUnderConstruction r : replicas) { sb.append(r.getExpectedStorageLocation().getDatanodeDescriptor()); if (++i < replicas.length) { sb.append(", "); } } } }
/** * Is data-node the replica belongs to alive. */ boolean isAlive() { return expectedLocation.getDatanodeDescriptor().isAlive(); }
/** * Queue the given reported block for later processing in the * standby node. @see PendingDataNodeMessages. * @param reason a textual reason to report in the debug logs */ private void queueReportedBlock(DatanodeStorageInfo storageInfo, Block block, ReplicaState reportedState, String reason) { assert shouldPostponeBlocksFromFuture; LOG.debug("Queueing reported block {} in state {}" + " from datanode {} for later processing because {}.", block, reportedState, storageInfo.getDatanodeDescriptor(), reason); pendingDNMessages.enqueueReportedBlock(storageInfo, block, reportedState); }
private boolean isNodeChosen( List<DatanodeStorageInfo> results, DatanodeDescriptor favoredNode) { boolean chosenNode = false; for (int j = 0; j < results.size(); j++) { if (results.get(j).getDatanodeDescriptor().equals(favoredNode)) { chosenNode = true; break; } } return chosenNode; }
public DatanodeDescriptor getDatanode(int index) { DatanodeStorageInfo storage = getStorageInfo(index); return storage == null ? null : storage.getDatanodeDescriptor(); }
private String getUpgradeDomain(DatanodeStorageInfo storage) { return getUpgradeDomainWithDefaultValue(storage.getDatanodeDescriptor()); }
DatanodeDescriptor chooseRandom(DatanodeStorageInfo... excludedStorages) { Set<String> excludedNodes = new HashSet<>(); if (excludedStorages != null) { for (int i = 0; i < excludedStorages.length; i++) { DatanodeDescriptor dn = excludedStorages[i].getDatanodeDescriptor(); String uuid = dn.getDatanodeUuid(); excludedNodes.add(uuid); } } return choose(null, excludedNodes); }
/** Increment the number of blocks scheduled for each given storage */ public static void incrementBlocksScheduled(DatanodeStorageInfo... storages) { for (DatanodeStorageInfo s : storages) { s.getDatanodeDescriptor().incrementBlocksScheduled(s.getStorageType()); } }
/** * Decrement the number of blocks scheduled for each given storage. This will * be called during abandon block or delete of UC block. */ public static void decrementBlocksScheduled(DatanodeStorageInfo... storages) { for (DatanodeStorageInfo s : storages) { s.getDatanodeDescriptor().decrementBlocksScheduled(s.getStorageType()); } }
private void removeStaleReplicas(List<ReplicaUnderConstruction> staleReplicas, BlockInfo block) { for (ReplicaUnderConstruction r : staleReplicas) { removeStoredBlock(block, r.getExpectedStorageLocation().getDatanodeDescriptor()); NameNode.blockStateChangeLog .debug("BLOCK* Removing stale replica {}" + " of {}", r, Block.toString(r)); } } /**
/** * Get the associated {@link DatanodeDescriptor} for the storage. * If the storage is of type PROVIDED, one of the nodes that reported * PROVIDED storage are returned. If not, this is equivalent to * {@code storage.getDatanodeDescriptor()}. * @param storage * @return the associated {@link DatanodeDescriptor}. */ private DatanodeDescriptor getDatanodeDescriptorFromStorage( DatanodeStorageInfo storage) { if (storage.getStorageType() == StorageType.PROVIDED) { return providedStorageMap.chooseProvidedDatanode(); } return storage.getDatanodeDescriptor(); }
private enum NodeNotChosenReason { NOT_IN_SERVICE("the node is not in service"), NODE_STALE("the node is stale"), NODE_TOO_BUSY("the node is too busy"), TOO_MANY_NODES_ON_RACK("the rack has too many chosen nodes"), NOT_ENOUGH_STORAGE_SPACE("not enough storage space to place the block"); private final String text; NodeNotChosenReason(final String logText) { text = logText; } private String getText() { return text; } }
public void removeBlockFromMap(BlockInfo block) { for(DatanodeStorageInfo info : blocksMap.getStorages(block)) { excessRedundancyMap.remove(info.getDatanodeDescriptor(), block); } blocksMap.removeBlock(block); // If block is removed from blocksMap remove it from corruptReplicasMap corruptReplicas.removeFromCorruptReplicasMap(block); }
void addStoredBlockUnderConstruction(StatefulBlockInfo ucBlock, DatanodeStorageInfo storageInfo) throws IOException { BlockInfo block = ucBlock.storedBlock; block.getUnderConstructionFeature().addReplicaIfNotPresent( storageInfo, ucBlock.reportedBlock, ucBlock.reportedState); // Add replica if appropriate. If the replica was previously corrupt // but now okay, it might need to be updated. if (ucBlock.reportedState == ReplicaState.FINALIZED && ( block.findStorageInfo(storageInfo) < 0) || corruptReplicas .isReplicaCorrupt(block, storageInfo.getDatanodeDescriptor())) { addStoredBlock(block, ucBlock.reportedBlock, storageInfo, null, true); } }
private void processQueuedMessages(Iterable<ReportedBlockInfo> rbis) throws IOException { for (ReportedBlockInfo rbi : rbis) { LOG.debug("Processing previouly queued message {}", rbi); if (rbi.getReportedState() == null) { // This is a DELETE_BLOCK request DatanodeStorageInfo storageInfo = rbi.getStorageInfo(); removeStoredBlock(getStoredBlock(rbi.getBlock()), storageInfo.getDatanodeDescriptor()); } else { processAndHandleReportedBlock(rbi.getStorageInfo(), rbi.getBlock(), rbi.getReportedState(), null); } } }