public void doUpgrade() throws IOException { this.status = (short)100; DataNode datanode = getDatanode(); datanode.getNSNamenode(datanode.getAllNamespaces()[0]).processUpgradeCommand( new UpgradeCommand(UpgradeCommand.UC_ACTION_REPORT_STATUS, getVersion(), getUpgradeStatus())); }
synchronized public UpgradeCommand processUpgradeCommand( UpgradeCommand command) throws IOException { switch(command.getAction()) { case UpgradeCommand.UC_ACTION_REPORT_STATUS: this.status += command.getCurrentStatus()/8; // 4 reports needed break; default: this.status++; } return null; }
synchronized UpgradeCommand processUpgradeCommand(UpgradeCommand command ) throws IOException { NameNode.LOG.debug("\n Distributed upgrade for NameNode version " + getUpgradeVersion() + " to current LV " + FSConstants.LAYOUT_VERSION + " is processing upgrade command: " + command.getAction() + " status = " + getUpgradeStatus() + "%"); if(currentUpgrades == null) { NameNode.LOG.info("Ignoring upgrade command: " + command.getAction() + " version " + command.getVersion() + ". No distributed upgrades are currently running on the NameNode"); return null; } UpgradeObjectNamenode curUO = (UpgradeObjectNamenode)currentUpgrades.first(); if(command.getVersion() != curUO.getVersion()) throw new IncorrectVersionException(command.getVersion(), "UpgradeCommand", curUO.getVersion()); UpgradeCommand reply = curUO.processUpgradeCommand(command); if(curUO.getUpgradeStatus() < 100) { return reply; } // current upgrade is done curUO.completeUpgrade(); NameNode.LOG.info("\n Distributed upgrade for NameNode version " + curUO.getVersion() + " to current LV " + FSConstants.LAYOUT_VERSION + " is complete."); // proceede with the next one currentUpgrades.remove(curUO); if(currentUpgrades.isEmpty()) { // all upgrades are done completeUpgrade(); } else { // start next upgrade curUO = (UpgradeObjectNamenode)currentUpgrades.first(); this.broadcastCommand = curUO.startUpgrade(); } return reply; }
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.getDatanodeInfo() + " version " + getUpgradeVersion() + " to current LV " + FSConstants.LAYOUT_VERSION + " cannot be started. " + "The upgrade object is not defined."); }
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."); }
synchronized UpgradeCommand processUpgradeCommand(UpgradeCommand command ) throws IOException { if(NameNode.LOG.isDebugEnabled()) { NameNode.LOG.debug("\n Distributed upgrade for NameNode version " + getUpgradeVersion() + " to current LV " + FSConstants.LAYOUT_VERSION + " is processing upgrade command: " + command.getAction() + " status = " + getUpgradeStatus() + "%"); } if(currentUpgrades == null) { NameNode.LOG.info("Ignoring upgrade command: " + command.getAction() + " version " + command.getVersion() + ". No distributed upgrades are currently running on the NameNode"); return null; } UpgradeObjectNamenode curUO = (UpgradeObjectNamenode)currentUpgrades.first(); if(command.getVersion() != curUO.getVersion()) throw new IncorrectVersionException(command.getVersion(), "UpgradeCommand", curUO.getVersion()); UpgradeCommand reply = curUO.processUpgradeCommand(command); if(curUO.getUpgradeStatus() < 100) { return reply; } // current upgrade is done curUO.completeUpgrade(); NameNode.LOG.info("\n Distributed upgrade for NameNode version " + curUO.getVersion() + " to current LV " + FSConstants.LAYOUT_VERSION + " is complete."); // proceede with the next one currentUpgrades.remove(curUO); if(currentUpgrades.isEmpty()) { // all upgrades are done completeUpgrade(); } else { // start next upgrade curUO = (UpgradeObjectNamenode)currentUpgrades.first(); this.broadcastCommand = curUO.startUpgrade(); } return reply; }
public UpgradeCommand startUpgrade() throws IOException { return null; }
public UpgradeCommand completeUpgrade() throws IOException { return null; }
public void processUpgradeCommand(UpgradeCommand comm) throws IOException { assert upgradeManager != null : "DataNode.upgradeManager is null."; upgradeManager.processUpgradeCommand(comm); }
public UpgradeCommand processUpgradeCommand(UpgradeCommand comm) throws IOException { return namesystem.processDistributedUpgradeCommand(comm); }
/** */ public UpgradeCommand startUpgrade() throws IOException { // broadcast that data-nodes must start the upgrade return new UpgradeCommand(UpgradeCommand.UC_ACTION_START_UPGRADE, getVersion(), (short)0); }
UpgradeCommand processDistributedUpgradeCommand(UpgradeCommand comm) throws IOException { return upgradeManager.processUpgradeCommand(comm); }
UpgradeCommand getDistributedUpgradeCommand() throws IOException { return upgradeManager.getBroadcastCommand(); }
/** * * @param cmd * @return true if further processing may be required or false otherwise. * @throws IOException */ private boolean processCommand(DatanodeCommand cmd, long processStartTime) throws IOException { if (cmd == null) return true; final BlockCommand bcmd = cmd instanceof BlockCommand? (BlockCommand)cmd: null; boolean retValue = true; long startTime = System.currentTimeMillis(); switch(cmd.getAction()) { case DatanodeProtocol.DNA_TRANSFER: // Send a copy of a block to another datanode transferBlocks(namespaceId, bcmd.getBlocks(), bcmd.getTargets()); myMetrics.blocksReplicated.inc(bcmd.getBlocks().length); break; case DatanodeProtocol.DNA_INVALIDATE: // // Some local block(s) are obsolete and can be // safely garbage-collected. // Block toDelete[] = bcmd.getBlocks(); try { if (blockScanner != null) { blockScanner.deleteBlocks(namespaceId, toDelete); } data.invalidate(namespaceId, toDelete); } catch(IOException e) { checkDiskError(); throw e; } myMetrics.blocksRemoved.inc(toDelete.length); break; case DatanodeProtocol.DNA_SHUTDOWN: // shut down the data node shouldServiceRun = false; retValue = false; break; case DatanodeProtocol.DNA_REGISTER: // namenode requested a registration - at start or if NN lost contact LOG.info("DatanodeCommand action: DNA_REGISTER"); if (shouldRun) { register(); firstBlockReportSent = false; } break; case DatanodeProtocol.DNA_FINALIZE: storage.finalizedUpgrade(namespaceId); break; case UpgradeCommand.UC_ACTION_START_UPGRADE: // start distributed upgrade here processDistributedUpgradeCommand((UpgradeCommand)cmd); break; case DatanodeProtocol.DNA_RECOVERBLOCK: recoverBlocks(namespaceId, bcmd.getBlocks(), bcmd.getTargets(), processStartTime); break; case DatanodeProtocol.DNA_RAIDTASK: processRaidTaskCommand((RaidTaskCommand) cmd); break; default: LOG.warn("Unknown DatanodeCommand action: " + cmd.getAction()); } long endTime = System.currentTimeMillis(); if (endTime - startTime > 1000) { LOG.info("processCommand() took " + (endTime - startTime) + " msec to process command " + cmd.getAction() + " from " + nnAddr); } else if (LOG.isDebugEnabled()) { LOG.debug("processCommand() took " + (endTime - startTime) + " msec to process command " + cmd.getAction() + " from " + nnAddr); } return retValue; }
private void processDistributedUpgradeCommand(UpgradeCommand comm ) throws IOException { assert upgradeManager != null : "DataNode.upgradeManager is null."; upgradeManager.processUpgradeCommand(comm); }
public synchronized UpgradeCommand getBroadcastCommand() { return this.broadcastCommand; }
public void doUpgrade() throws IOException { this.status = (short)100; getDatanode().namenode.processUpgradeCommand( new UpgradeCommand(UpgradeCommand.UC_ACTION_REPORT_STATUS, getVersion(), getUpgradeStatus())); }