Java Code Examples for org.apache.hadoop.hdfs.server.protocol.DatanodeProtocol#DNA_UNCACHE

The following examples show how to use org.apache.hadoop.hdfs.server.protocol.DatanodeProtocol#DNA_UNCACHE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PBHelper.java    From hadoop with Apache License 2.0 6 votes vote down vote up
public static BlockIdCommandProto convert(BlockIdCommand cmd) {
  BlockIdCommandProto.Builder builder = BlockIdCommandProto.newBuilder()
      .setBlockPoolId(cmd.getBlockPoolId());
  switch (cmd.getAction()) {
  case DatanodeProtocol.DNA_CACHE:
    builder.setAction(BlockIdCommandProto.Action.CACHE);
    break;
  case DatanodeProtocol.DNA_UNCACHE:
    builder.setAction(BlockIdCommandProto.Action.UNCACHE);
    break;
  default:
    throw new AssertionError("Invalid action");
  }
  long[] blockIds = cmd.getBlockIds();
  for (int i = 0; i < blockIds.length; i++) {
    builder.addBlockIds(blockIds[i]);
  }
  return builder.build();
}
 
Example 2
Source File: PBHelper.java    From hadoop with Apache License 2.0 6 votes vote down vote up
public static BlockIdCommand convert(BlockIdCommandProto blkIdCmd) {
  int numBlockIds = blkIdCmd.getBlockIdsCount();
  long blockIds[] = new long[numBlockIds];
  for (int i = 0; i < numBlockIds; i++) {
    blockIds[i] = blkIdCmd.getBlockIds(i);
  }
  int action = DatanodeProtocol.DNA_UNKNOWN;
  switch (blkIdCmd.getAction()) {
  case CACHE:
    action = DatanodeProtocol.DNA_CACHE;
    break;
  case UNCACHE:
    action = DatanodeProtocol.DNA_UNCACHE;
    break;
  default:
    throw new AssertionError("Unknown action type: " + blkIdCmd.getAction());
  }
  return new BlockIdCommand(action, blkIdCmd.getBlockPoolId(), blockIds);
}
 
Example 3
Source File: PBHelper.java    From big-c with Apache License 2.0 6 votes vote down vote up
public static BlockIdCommandProto convert(BlockIdCommand cmd) {
  BlockIdCommandProto.Builder builder = BlockIdCommandProto.newBuilder()
      .setBlockPoolId(cmd.getBlockPoolId());
  switch (cmd.getAction()) {
  case DatanodeProtocol.DNA_CACHE:
    builder.setAction(BlockIdCommandProto.Action.CACHE);
    break;
  case DatanodeProtocol.DNA_UNCACHE:
    builder.setAction(BlockIdCommandProto.Action.UNCACHE);
    break;
  default:
    throw new AssertionError("Invalid action");
  }
  long[] blockIds = cmd.getBlockIds();
  for (int i = 0; i < blockIds.length; i++) {
    builder.addBlockIds(blockIds[i]);
  }
  return builder.build();
}
 
Example 4
Source File: PBHelper.java    From big-c with Apache License 2.0 6 votes vote down vote up
public static BlockIdCommand convert(BlockIdCommandProto blkIdCmd) {
  int numBlockIds = blkIdCmd.getBlockIdsCount();
  long blockIds[] = new long[numBlockIds];
  for (int i = 0; i < numBlockIds; i++) {
    blockIds[i] = blkIdCmd.getBlockIds(i);
  }
  int action = DatanodeProtocol.DNA_UNKNOWN;
  switch (blkIdCmd.getAction()) {
  case CACHE:
    action = DatanodeProtocol.DNA_CACHE;
    break;
  case UNCACHE:
    action = DatanodeProtocol.DNA_UNCACHE;
    break;
  default:
    throw new AssertionError("Unknown action type: " + blkIdCmd.getAction());
  }
  return new BlockIdCommand(action, blkIdCmd.getBlockPoolId(), blockIds);
}
 
Example 5
Source File: PBHelper.java    From hadoop with Apache License 2.0 4 votes vote down vote up
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();
}
 
Example 6
Source File: PBHelper.java    From big-c with Apache License 2.0 4 votes vote down vote up
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();
}