switch(cmd.getAction()) { case DatanodeProtocol.DNA_ACCESSKEYUPDATE: LOG.info("DatanodeCommand action from standby: DNA_ACCESSKEYUPDATE"); case DatanodeProtocol.DNA_UNCACHE: case DatanodeProtocol.DNA_ERASURE_CODING_RECONSTRUCTION: LOG.warn("Got a command from standby NN - ignoring command:" + cmd.getAction()); break; default: LOG.warn("Unknown DatanodeCommand action: " + cmd.getAction());
/** */ public void readFields(DataInput in) throws IOException { super.readFields(in); this.version = in.readInt(); this.upgradeStatus = in.readShort(); } }
/** */ public void write(DataOutput out) throws IOException { super.write(out); out.writeInt(this.version); out.writeShort(this.upgradeStatus); }
boolean processCommandFromActor(DatanodeCommand cmd, BPServiceActor actor) throws IOException { assert bpServices.contains(actor); if (cmd == null) { return true; } /* * Datanode Registration can be done asynchronously here. No need to hold * the lock. for more info refer HDFS-5014 */ if (DatanodeProtocol.DNA_REGISTER == cmd.getAction()) { // namenode requested a registration - at start or if NN lost contact // Just logging the claiming state is OK here instead of checking the // actor state by obtaining the lock LOG.info("DatanodeCommand action : DNA_REGISTER from " + actor.nnAddr + " with " + actor.state + " state"); actor.reRegister(); return false; } writeLock(); try { if (actor == bpServiceToActive) { return processCommandFromActive(cmd, actor); } else { return processCommandFromStandby(cmd, actor); } } finally { writeUnlock(); } }
/** */ public void write(DataOutput out) throws IOException { super.write(out); out.writeInt(this.version); out.writeShort(this.upgradeStatus); }
/** */ public void readFields(DataInput in) throws IOException { super.readFields(in); this.version = in.readInt(); this.upgradeStatus = in.readShort(); } }
public void write(DataOutput out) throws IOException { super.write(out); out.writeInt(blocks.length); for (int i = 0; i < blocks.length; i++) { blocks[i].write(out); } out.writeInt(targets.length); for (int i = 0; i < targets.length; i++) { out.writeInt(targets[i].length); for (int j = 0; j < targets[i].length; j++) { targets[i][j].write(out); } } }
public void readFields(DataInput in) throws IOException { super.readFields(in); this.blocks = new Block[in.readInt()]; for (int i = 0; i < blocks.length; i++) { blocks[i] = new Block(); blocks[i].readFields(in); } this.targets = new DatanodeInfo[in.readInt()][]; for (int i = 0; i < targets.length; i++) { this.targets[i] = new DatanodeInfo[in.readInt()]; for (int j = 0; j < targets[i].length; j++) { targets[i][j] = new DatanodeInfo(); targets[i][j].readFields(in); } } } }
/** * Send a heartbeat to the name-node. * Ignore reply commands. */ void sendHeartbeat() throws IOException { // register datanode DatanodeCommand[] cmds = nameNode.sendHeartbeat( dnRegistration, DF_CAPACITY, DF_USED, DF_CAPACITY - DF_USED, 0, 0, 0); if(cmds != null) { for (DatanodeCommand cmd : cmds ) { if(LOG.isDebugEnabled()) { LOG.debug("sendHeartbeat Name-node reply: " + cmd.getAction()); } } } }
public void write(DataOutput out) throws IOException { super.write(out); out.writeInt(blocks.length); for (int i = 0; i < blocks.length; i++) { blocks[i].write(out); } out.writeInt(targets.length); for (int i = 0; i < targets.length; i++) { out.writeInt(targets[i].length); for (int j = 0; j < targets[i].length; j++) { targets[i][j].write(out); } } }
public void readFields(DataInput in) throws IOException { super.readFields(in); this.blocks = new Block[in.readInt()]; for (int i = 0; i < blocks.length; i++) { blocks[i] = new Block(); blocks[i].readFields(in); } this.targets = new DatanodeInfo[in.readInt()][]; for (int i = 0; i < targets.length; i++) { this.targets[i] = new DatanodeInfo[in.readInt()]; for (int j = 0; j < targets[i].length; j++) { targets[i][j] = new DatanodeInfo(); targets[i][j].readFields(in); } } } }
/** * This method should handle commands from Standby namenode except * DNA_REGISTER which should be handled earlier itself. */ private boolean processCommandFromStandby(DatanodeCommand cmd, BPServiceActor actor) throws IOException { switch(cmd.getAction()) { case DatanodeProtocol.DNA_ACCESSKEYUPDATE: LOG.info("DatanodeCommand action from standby: DNA_ACCESSKEYUPDATE"); if (dn.isBlockTokenEnabled) { dn.blockPoolTokenSecretManager.addKeys( getBlockPoolId(), ((KeyUpdateCommand) cmd).getExportedKeys()); } break; case DatanodeProtocol.DNA_TRANSFER: case DatanodeProtocol.DNA_INVALIDATE: case DatanodeProtocol.DNA_SHUTDOWN: case DatanodeProtocol.DNA_FINALIZE: case DatanodeProtocol.DNA_RECOVERBLOCK: case DatanodeProtocol.DNA_BALANCERBANDWIDTHUPDATE: case DatanodeProtocol.DNA_CACHE: case DatanodeProtocol.DNA_UNCACHE: LOG.warn("Got a command from standby NN - ignoring command:" + cmd.getAction()); break; default: LOG.warn("Unknown DatanodeCommand action: " + cmd.getAction()); } return true; }
/** * This method should handle commands from Standby namenode except * DNA_REGISTER which should be handled earlier itself. */ private boolean processCommandFromStandby(DatanodeCommand cmd, BPServiceActor actor) throws IOException { switch(cmd.getAction()) { case DatanodeProtocol.DNA_ACCESSKEYUPDATE: LOG.info("DatanodeCommand action from standby: DNA_ACCESSKEYUPDATE"); if (dn.isBlockTokenEnabled) { dn.blockPoolTokenSecretManager.addKeys( getBlockPoolId(), ((KeyUpdateCommand) cmd).getExportedKeys()); } break; case DatanodeProtocol.DNA_TRANSFER: case DatanodeProtocol.DNA_INVALIDATE: case DatanodeProtocol.DNA_SHUTDOWN: case DatanodeProtocol.DNA_FINALIZE: case DatanodeProtocol.DNA_RECOVERBLOCK: case DatanodeProtocol.DNA_BALANCERBANDWIDTHUPDATE: case DatanodeProtocol.DNA_CACHE: case DatanodeProtocol.DNA_UNCACHE: LOG.warn("Got a command from standby NN - ignoring command:" + cmd.getAction()); break; default: LOG.warn("Unknown DatanodeCommand action: " + cmd.getAction()); } return true; }
.build(); switch (datanodeCommand.getAction()) { case DatanodeProtocol.DNA_BALANCERBANDWIDTHUPDATE: builder.setCmdType(DatanodeCommandProto.Type.BalancerBandwidthCommand)
boolean processCommandFromActor(DatanodeCommand cmd, BPServiceActor actor) throws IOException { assert bpServices.contains(actor); if (cmd == null) { return true; } /* * Datanode Registration can be done asynchronously here. No need to hold * the lock. for more info refer HDFS-5014 */ if (DatanodeProtocol.DNA_REGISTER == cmd.getAction()) { // namenode requested a registration - at start or if NN lost contact // Just logging the claiming state is OK here instead of checking the // actor state by obtaining the lock LOG.info("DatanodeCommand action : DNA_REGISTER from " + actor.nnAddr + " with " + actor.state + " state"); actor.reRegister(); return false; } writeLock(); try { if (actor == bpServiceToActive) { return processCommandFromActive(cmd, actor); } else { return processCommandFromStandby(cmd, actor); } } finally { writeUnlock(); } }
/** * Send a heartbeat to the name-node and replicate blocks if requested. */ @SuppressWarnings("unused") // keep it for future blockReceived benchmark int replicateBlocks() throws IOException { // register datanode DatanodeCommand[] cmds = nameNode.sendHeartbeat( dnRegistration, DF_CAPACITY, DF_USED, DF_CAPACITY - DF_USED, 0, 0, 0); if (cmds != null) { for (DatanodeCommand cmd : cmds) { if (cmd.getAction() == DatanodeProtocol.DNA_TRANSFER) { // Send a copy of a block to another datanode BlockCommand bcmd = (BlockCommand)cmd; return transferBlocks(bcmd.getBlocks(), bcmd.getTargets()); } } } return 0; }
long startTime = System.currentTimeMillis(); switch(cmd.getAction()) { case DatanodeProtocol.DNA_TRANSFER: break; default: LOG.warn("Unknown DatanodeCommand action: " + cmd.getAction()); + " 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);
/** * Send a heartbeat to the name-node. * Ignore reply commands. */ void sendHeartbeat() throws IOException { // register datanode // TODO:FEDERATION currently a single block pool is supported StorageReport[] rep = { new StorageReport(storage, false, DF_CAPACITY, DF_USED, DF_CAPACITY - DF_USED, DF_USED, 0L) }; DatanodeCommand[] cmds = dataNodeProto.sendHeartbeat(dnRegistration, rep, 0L, 0L, 0, 0, 0, null).getCommands(); if(cmds != null) { for (DatanodeCommand cmd : cmds ) { if(LOG.isDebugEnabled()) { LOG.debug("sendHeartbeat Name-node reply: " + cmd.getAction()); } } } }
boolean processCommandFromActor(DatanodeCommand cmd, BPServiceActor actor) throws IOException { assert bpServices.contains(actor); if (cmd == null) { return true; } /* * Datanode Registration can be done asynchronously here. No need to hold * the lock. for more info refer HDFS-5014 */ if (DatanodeProtocol.DNA_REGISTER == cmd.getAction()) { // namenode requested a registration - at start or if NN lost contact // Just logging the claiming state is OK here instead of checking the // actor state by obtaining the lock LOG.info("DatanodeCommand action : DNA_REGISTER from " + actor.nnAddr + " with " + actor.state + " state"); actor.reRegister(); return false; } writeLock(); try { if (actor == bpServiceToActive) { return processCommandFromActive(cmd, actor); } else { return processCommandFromStandby(cmd, actor); } } finally { writeUnlock(); } }