public static DatanodeCommand convert(DatanodeCommandProto proto) { switch (proto.getCmdType()) { case BalancerBandwidthCommand: return PBHelper.convert(proto.getBalancerCmd()); case BlockCommand: return PBHelper.convert(proto.getBlkCmd()); case BlockRecoveryCommand: return PBHelper.convert(proto.getRecoveryCmd()); case FinalizeCommand: return PBHelper.convert(proto.getFinalizeCmd()); case KeyUpdateCommand: return PBHelper.convert(proto.getKeyUpdateCmd()); case RegisterCommand: return REG_CMD; case BlockIdCommand: return PBHelper.convert(proto.getBlkIdCmd()); default: return null; } }
public static DatanodeCommand convert(DatanodeCommandProto proto) { switch (proto.getCmdType()) { case BalancerBandwidthCommand: return PBHelper.convert(proto.getBalancerCmd()); case BlockCommand: return PBHelper.convert(proto.getBlkCmd()); case BlockRecoveryCommand: return PBHelper.convert(proto.getRecoveryCmd()); case FinalizeCommand: return PBHelper.convert(proto.getFinalizeCmd()); case KeyUpdateCommand: return PBHelper.convert(proto.getKeyUpdateCmd()); case RegisterCommand: return REG_CMD; case BlockIdCommand: return PBHelper.convert(proto.getBlkIdCmd()); case BlockECRecoveryCommand: return PBHelper.convert(proto.getBlkECRecoveryCmd()); default: return null; } }
public static DatanodeCommand convert(DatanodeCommandProto proto) { switch (proto.getCmdType()) { case BalancerBandwidthCommand: return PBHelper.convert(proto.getBalancerCmd()); case BlockCommand: return PBHelper.convert(proto.getBlkCmd()); case BlockRecoveryCommand: return PBHelper.convert(proto.getRecoveryCmd()); case FinalizeCommand: return PBHelper.convert(proto.getFinalizeCmd()); case KeyUpdateCommand: return PBHelper.convert(proto.getKeyUpdateCmd()); case RegisterCommand: return REG_CMD; } return null; }
void addKeyUpdateCommand(final List<DatanodeCommand> cmds, final DatanodeDescriptor nodeinfo) { // check access key update if (isBlockTokenEnabled() && nodeinfo.needKeyUpdate) { cmds.add(new KeyUpdateCommand(blockTokenSecretManager.exportKeys())); nodeinfo.needKeyUpdate = false; } }
void addKeyUpdateCommand(final List<DatanodeCommand> cmds, final DatanodeDescriptor nodeinfo) { // check access key update if (isBlockTokenEnabled() && nodeinfo.needKeyUpdate()) { cmds.add(new KeyUpdateCommand(blockTokenSecretManager.exportKeys())); nodeinfo.setNeedKeyUpdate(false); } }
private boolean processCommandFromStandby(DatanodeCommand cmd, BPServiceActor actor) throws IOException { if (cmd == null) return true; switch(cmd.getAction()) { case DatanodeProtocol.DNA_REGISTER: // namenode requested a registration - at start or if NN lost contact LOG.info("DatanodeCommand action from standby: DNA_REGISTER"); actor.reRegister(); break; 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: LOG.warn("Got a command from standby NN - ignoring command:" + cmd.getAction()); break; default: LOG.warn("Unknown DatanodeCommand action: " + cmd.getAction()); } return true; }
void addKeyUpdateCommand(final List<DatanodeCommand> cmds, final DatanodeDescriptor nodeinfo) throws IOException { // check access key update if (isBlockTokenEnabled() && nodeinfo.needKeyUpdate) { cmds.add(new KeyUpdateCommand(blockTokenSecretManager.exportKeys())); nodeinfo.needKeyUpdate = false; } }
public static KeyUpdateCommandProto convert(KeyUpdateCommand cmd) { return KeyUpdateCommandProto.newBuilder() .setKeys(PBHelper.convert(cmd.getExportedKeys())).build(); }
public static DatanodeCommandProto convert(DatanodeCommand datanodeCommand) { DatanodeCommandProto.Builder builder = DatanodeCommandProto.newBuilder(); if (datanodeCommand == null) { return builder.setCmdType(DatanodeCommandProto.Type.NullDatanodeCommand) .build(); } switch (datanodeCommand.getAction()) { case DatanodeProtocol.DNA_BALANCERBANDWIDTHUPDATE: builder.setCmdType(DatanodeCommandProto.Type.BalancerBandwidthCommand) .setBalancerCmd( PBHelper.convert((BalancerBandwidthCommand) datanodeCommand)); break; case DatanodeProtocol.DNA_ACCESSKEYUPDATE: builder .setCmdType(DatanodeCommandProto.Type.KeyUpdateCommand) .setKeyUpdateCmd(PBHelper.convert((KeyUpdateCommand) datanodeCommand)); break; case DatanodeProtocol.DNA_RECOVERBLOCK: builder.setCmdType(DatanodeCommandProto.Type.BlockRecoveryCommand) .setRecoveryCmd( PBHelper.convert((BlockRecoveryCommand) datanodeCommand)); break; case DatanodeProtocol.DNA_FINALIZE: builder.setCmdType(DatanodeCommandProto.Type.FinalizeCommand) .setFinalizeCmd(PBHelper.convert((FinalizeCommand) datanodeCommand)); break; case DatanodeProtocol.DNA_REGISTER: builder.setCmdType(DatanodeCommandProto.Type.RegisterCommand) .setRegisterCmd(REG_CMD_PROTO); break; case DatanodeProtocol.DNA_TRANSFER: case DatanodeProtocol.DNA_INVALIDATE: case DatanodeProtocol.DNA_SHUTDOWN: builder.setCmdType(DatanodeCommandProto.Type.BlockCommand). setBlkCmd(PBHelper.convert((BlockCommand) datanodeCommand)); break; case DatanodeProtocol.DNA_CACHE: case DatanodeProtocol.DNA_UNCACHE: builder.setCmdType(DatanodeCommandProto.Type.BlockIdCommand). setBlkIdCmd(PBHelper.convert((BlockIdCommand) datanodeCommand)); break; case DatanodeProtocol.DNA_UNKNOWN: //Not expected default: builder.setCmdType(DatanodeCommandProto.Type.NullDatanodeCommand); } return builder.build(); }
public static KeyUpdateCommand convert(KeyUpdateCommandProto keyUpdateCmd) { return new KeyUpdateCommand(PBHelper.convert(keyUpdateCmd.getKeys())); }
public static KeyUpdateCommandProto convert(KeyUpdateCommand cmd) { return KeyUpdateCommandProto.newBuilder() .setKeys(convert(cmd.getExportedKeys())).build(); }
public static DatanodeCommandProto convert(DatanodeCommand datanodeCommand) { DatanodeCommandProto.Builder builder = DatanodeCommandProto.newBuilder(); if (datanodeCommand == null) { return builder.setCmdType(DatanodeCommandProto.Type.NullDatanodeCommand) .build(); } switch (datanodeCommand.getAction()) { case DatanodeProtocol.DNA_BALANCERBANDWIDTHUPDATE: builder.setCmdType(DatanodeCommandProto.Type.BalancerBandwidthCommand) .setBalancerCmd( PBHelper.convert((BalancerBandwidthCommand) datanodeCommand)); break; case DatanodeProtocol.DNA_ACCESSKEYUPDATE: builder .setCmdType(DatanodeCommandProto.Type.KeyUpdateCommand) .setKeyUpdateCmd(PBHelper.convert((KeyUpdateCommand) datanodeCommand)); break; case DatanodeProtocol.DNA_RECOVERBLOCK: builder.setCmdType(DatanodeCommandProto.Type.BlockRecoveryCommand) .setRecoveryCmd( PBHelper.convert((BlockRecoveryCommand) datanodeCommand)); break; case DatanodeProtocol.DNA_FINALIZE: builder.setCmdType(DatanodeCommandProto.Type.FinalizeCommand) .setFinalizeCmd(PBHelper.convert((FinalizeCommand) datanodeCommand)); break; case DatanodeProtocol.DNA_REGISTER: builder.setCmdType(DatanodeCommandProto.Type.RegisterCommand) .setRegisterCmd(REG_CMD_PROTO); break; case DatanodeProtocol.DNA_TRANSFER: case DatanodeProtocol.DNA_INVALIDATE: case DatanodeProtocol.DNA_SHUTDOWN: builder.setCmdType(DatanodeCommandProto.Type.BlockCommand). setBlkCmd(PBHelper.convert((BlockCommand) datanodeCommand)); break; case DatanodeProtocol.DNA_CACHE: case DatanodeProtocol.DNA_UNCACHE: builder.setCmdType(DatanodeCommandProto.Type.BlockIdCommand). setBlkIdCmd(PBHelper.convert((BlockIdCommand) datanodeCommand)); break; case DatanodeProtocol.DNA_ERASURE_CODING_RECOVERY: builder.setCmdType(DatanodeCommandProto.Type.BlockECRecoveryCommand) .setBlkECRecoveryCmd( convert((BlockECRecoveryCommand) datanodeCommand)); break; case DatanodeProtocol.DNA_UNKNOWN: //Not expected default: builder.setCmdType(DatanodeCommandProto.Type.NullDatanodeCommand); } return builder.build(); }
public static KeyUpdateCommand convert(KeyUpdateCommandProto keyUpdateCmd) { return new KeyUpdateCommand(convert(keyUpdateCmd.getKeys())); }
public static DatanodeCommandProto convert(DatanodeCommand datanodeCommand) { DatanodeCommandProto.Builder builder = DatanodeCommandProto.newBuilder(); if (datanodeCommand == null) { return builder.setCmdType(DatanodeCommandProto.Type.NullDatanodeCommand) .build(); } switch (datanodeCommand.getAction()) { case DatanodeProtocol.DNA_BALANCERBANDWIDTHUPDATE: builder.setCmdType(DatanodeCommandProto.Type.BalancerBandwidthCommand) .setBalancerCmd( PBHelper.convert((BalancerBandwidthCommand) datanodeCommand)); break; case DatanodeProtocol.DNA_ACCESSKEYUPDATE: builder .setCmdType(DatanodeCommandProto.Type.KeyUpdateCommand) .setKeyUpdateCmd(PBHelper.convert((KeyUpdateCommand) datanodeCommand)); break; case DatanodeProtocol.DNA_RECOVERBLOCK: builder.setCmdType(DatanodeCommandProto.Type.BlockRecoveryCommand) .setRecoveryCmd( PBHelper.convert((BlockRecoveryCommand) datanodeCommand)); break; case DatanodeProtocol.DNA_FINALIZE: builder.setCmdType(DatanodeCommandProto.Type.FinalizeCommand) .setFinalizeCmd(PBHelper.convert((FinalizeCommand) datanodeCommand)); break; case DatanodeProtocol.DNA_REGISTER: builder.setCmdType(DatanodeCommandProto.Type.RegisterCommand) .setRegisterCmd(REG_CMD_PROTO); break; case DatanodeProtocol.DNA_TRANSFER: case DatanodeProtocol.DNA_INVALIDATE: case DatanodeProtocol.DNA_SHUTDOWN: builder.setCmdType(DatanodeCommandProto.Type.BlockCommand).setBlkCmd( PBHelper.convert((BlockCommand) datanodeCommand)); break; case DatanodeProtocol.DNA_UNKNOWN: //Not expected default: builder.setCmdType(DatanodeCommandProto.Type.NullDatanodeCommand); } return builder.build(); }