String getName() { return dnRegistration.getName(); }
@Override public String toString() { return "DataNode{" + "data=" + data + ", localName='" + dnRegistration.getName() + "'" + ", storageID='" + dnRegistration.getStorageID() + "'" + ", xmitsInProgress=" + xmitsInProgress.get() + "}"; }
public synchronized DataNodeProperties stopDataNode(String name) { int i; for (i = 0; i < dataNodes.size(); i++) { DataNode dn = dataNodes.get(i).datanode; if (dn.dnRegistration.getName().equals(name)) { break; } } return stopDataNode(i); }
@Override public String toString() { return "DataNode{" + "data=" + data + ", localName='" + dnRegistration.getName() + "'" + ", storageID='" + dnRegistration.getStorageID() + "'" + ", xmitsInProgress=" + xmitsInProgress + "}"; }
public synchronized DataNodeProperties stopDataNode(int i) { if (i < 0 || i >= dataNodes.size()) { return null; } DataNodeProperties dnprop = dataNodes.remove(i); DataNode dn = dnprop.datanode; System.out.println("MiniDFSCluster Stopping DataNode " + dn.dnRegistration.getName() + " from a total of " + (dataNodes.size() + 1) + " datanodes."); dn.shutdown(); numDataNodes--; return dnprop; }
public synchronized void completeUpgrade() throws IOException { assert currentUpgrades != null : "UpgradeManagerDatanode.currentUpgrades is null."; UpgradeObjectDatanode curUO = (UpgradeObjectDatanode)currentUpgrades.first(); broadcastCommand = curUO.completeUpgrade(); upgradeState = false; currentUpgrades = null; upgradeDaemon = null; DataNode.LOG.info("\n Distributed upgrade for DataNode " + dataNode.dnRegistration.getName() + " version " + getUpgradeVersion() + " to current LV " + FSConstants.LAYOUT_VERSION + " is complete."); }
public void blockReceived(DatanodeRegistration nodeReg, Block blocks[], String delHints[]) throws IOException { verifyRequest(nodeReg); stateChangeLog.debug("*BLOCK* NameNode.blockReceived: " +"from "+nodeReg.getName()+" "+blocks.length+" blocks."); for (int i = 0; i < blocks.length; i++) { namesystem.blockReceived(nodeReg, blocks[i], delHints[i]); } }
/** */ public void errorReport(DatanodeRegistration nodeReg, int errorCode, String msg) throws IOException { // Log error message from datanode String dnName = (nodeReg == null ? "unknown DataNode" : nodeReg.getName()); LOG.info("Error report from " + dnName + ": " + msg); if (errorCode == DatanodeProtocol.NOTIFY) { return; } verifyRequest(nodeReg); if (errorCode == DatanodeProtocol.DISK_ERROR) { namesystem.removeDatanode(nodeReg); } }
/** */ public void errorReport(DatanodeRegistration nodeReg, int errorCode, String msg) throws IOException { // Log error message from datanode String dnName = (nodeReg == null ? "unknown DataNode" : nodeReg.getName()); LOG.info("Error report from " + dnName + ": " + msg); if (errorCode == DatanodeProtocol.NOTIFY) { return; } verifyRequest(nodeReg); if (errorCode == DatanodeProtocol.DISK_ERROR) { LOG.warn("Volume failed on " + dnName); } else if (errorCode == DatanodeProtocol.FATAL_DISK_ERROR) { namesystem.removeDatanode(nodeReg); } }
synchronized void initializeUpgrade(NamespaceInfo nsInfo) throws IOException { if( ! super.initializeUpgrade()) return; // distr upgrade is not needed DataNode.LOG.info("\n Distributed upgrade for DataNode " + dataNode.dnRegistration.getName() + " version " + getUpgradeVersion() + " to current LV " + FSConstants.LAYOUT_VERSION + " is initialized."); UpgradeObjectDatanode curUO = (UpgradeObjectDatanode)currentUpgrades.first(); curUO.setDatanode(dataNode); upgradeState = curUO.preUpgradeAction(nsInfo); // upgradeState is true if the data-node should start the upgrade itself }
synchronized void processUpgradeCommand(UpgradeCommand command ) throws IOException { assert command.getAction() == UpgradeCommand.UC_ACTION_START_UPGRADE : "Only start upgrade action can be processed at this time."; this.upgradeVersion = command.getVersion(); // Start distributed upgrade if(startUpgrade()) // upgrade started return; throw new IOException( "Distributed upgrade for DataNode " + dataNode.dnRegistration.getName() + " version " + getUpgradeVersion() + " to current LV " + FSConstants.LAYOUT_VERSION + " cannot be started. " + "The upgrade object is not defined."); }
/** * add new replica blocks to the Inode to target mapping * also add the Inode file to DataNodeDesc */ public void blocksBeingWrittenReport(DatanodeRegistration nodeReg, BlockReport blocks) throws IOException { verifyRequest(nodeReg); long[] blocksAsLong = blocks.getBlockReportInLongs(); BlockListAsLongs blist = new BlockListAsLongs(blocksAsLong); namesystem.processBlocksBeingWrittenReport(nodeReg, blist); stateChangeLog.info("*BLOCK* NameNode.blocksBeingWrittenReport: " +"from "+nodeReg.getName()+" "+blist.getNumberOfBlocks() +" blocks"); }
public void testDataNodeRedirect() throws Exception { if (hdfs.exists(TEST_FILE)) { hdfs.delete(TEST_FILE, true); } FSDataOutputStream out = hdfs.create(TEST_FILE, (short) 1); out.writeBytes("0123456789"); out.close(); BlockLocation[] locations = hdfs.getFileBlockLocations(TEST_FILE, 0, 10); String locationName = locations[0].getNames()[0]; URL u = hftpFs.getNamenodeFileURL(TEST_FILE); HttpURLConnection conn = (HttpURLConnection)u.openConnection(); conn.setFollowRedirects(true); conn.connect(); conn.getInputStream(); boolean checked = false; // Find the datanode that has the block according to locations // and check that the URL was redirected to this DN's info port for (DataNode node : cluster.getDataNodes()) { if (node.getDatanodeRegistration().getName().equals(locationName)) { checked = true; assertEquals(node.getDatanodeRegistration().getInfoPort(), conn.getURL().getPort()); } } assertTrue("The test never checked that location of " + "the block and hftp desitnation are the same", checked); } /**
public DatanodeCommand blockReport(DatanodeRegistration nodeReg, long[] blocks) throws IOException { verifyRequest(nodeReg); BlockListAsLongs blist = new BlockListAsLongs(blocks); stateChangeLog.debug("*BLOCK* NameNode.blockReport: " +"from "+nodeReg.getName()+" "+blist.getNumberOfBlocks() +" blocks"); namesystem.processReport(nodeReg, blist); if (getFSImage().isUpgradeFinalized()) return DatanodeCommand.FINALIZE; return null; }
protected Collection<Block> blockReportWithRetries( DatanodeRegistration nodeReg, BlockReport blocks) throws IOException { verifyRequest(nodeReg); myMetrics.numBlockReport.inc(); BlockListAsLongs blist = new BlockListAsLongs(blocks.getBlockReportInLongs()); stateChangeLog.debug("*BLOCK* NameNode.blockReport: " + "from " + nodeReg.getName() + " " + blist.getNumberOfBlocks() + " blocks"); return namesystem.processReport(nodeReg, blist); }
/** {@inheritDoc} */ public void updateBlock(Block oldblock, Block newblock, boolean finalize) throws IOException { LOG.info("oldblock=" + oldblock + "(length=" + oldblock.getNumBytes() + "), newblock=" + newblock + "(length=" + newblock.getNumBytes() + "), datanode=" + dnRegistration.getName()); data.updateBlock(oldblock, newblock); if (finalize) { data.finalizeBlock(newblock); myMetrics.blocksWritten.inc(); notifyNamenodeReceivedBlock(newblock, EMPTY_DEL_HINT); LOG.info("Received block " + newblock + " of size " + newblock.getNumBytes() + " as part of lease recovery."); } }
/** {@inheritDoc} */ public void updateBlock(Block oldblock, Block newblock, boolean finalize) throws IOException { LOG.info("oldblock=" + oldblock + "(length=" + oldblock.getNumBytes() + "), newblock=" + newblock + "(length=" + newblock.getNumBytes() + "), datanode=" + dnRegistration.getName()); data.updateBlock(oldblock, newblock); if (finalize) { data.finalizeBlockIfNeeded(newblock); myMetrics.incrBlocksWritten(); notifyNamenodeReceivedBlock(newblock, EMPTY_DEL_HINT); LOG.info("Received " + newblock + " of size " + newblock.getNumBytes() + " as part of lease recovery"); } }
@Override public DatanodeCommand blockReport(DatanodeRegistration nodeReg, long[] blocks) throws IOException { verifyRequest(nodeReg); myMetrics.numBlockReport.inc(); BlockListAsLongs blist = new BlockListAsLongs(blocks); if (stateChangeLog.isDebugEnabled()) { stateChangeLog.debug("*BLOCK* NameNode.blockReport: " +"from "+nodeReg.getName()+" "+blist.getNumberOfBlocks() +" blocks"); } namesystem.processReport(nodeReg, blist); if (getFSImage().isUpgradeFinalized()) return DatanodeCommand.FINALIZE; return null; }
/** * Checks if the node is not on the hosts list. If it is not, then * it will be ignored. If the node is in the hosts list, but is also * on the exclude list, then it will be decommissioned. * Returns FALSE if node is rejected for registration. * Returns TRUE if node is registered (including when it is on the * exclude list and is being decommissioned). */ private synchronized boolean verifyNodeRegistration(DatanodeRegistration nodeReg, String ipAddr) throws IOException { if (!inHostsList(nodeReg, ipAddr)) { return false; } if (inExcludedHostsList(nodeReg, ipAddr)) { DatanodeDescriptor node = getDatanode(nodeReg); if (node == null) { throw new IOException("verifyNodeRegistration: unknown datanode " + nodeReg.getName()); } if (!checkDecommissionStateInternal(node)) { startDecommission(node); } } return true; }
storage.writeAll(); LOG.info("New storage id " + dnRegistration.getStorageID() + " is assigned to data-node " + dnRegistration.getName());