Java 类org.apache.hadoop.hdfs.server.protocol.CheckpointCommand 实例源码

项目:hadoop    文件:FSImage.java   
/**
 * Start checkpoint.
 * <p>
 * If backup storage contains image that is newer than or incompatible with 
 * what the active name-node has, then the backup node should shutdown.<br>
 * If the backup image is older than the active one then it should 
 * be discarded and downloaded from the active node.<br>
 * If the images are the same then the backup image will be used as current.
 * 
 * @param bnReg the backup node registration.
 * @param nnReg this (active) name-node registration.
 * @return {@link NamenodeCommand} if backup node should shutdown or
 * {@link CheckpointCommand} prescribing what backup node should 
 *         do with its image.
 * @throws IOException
 */
NamenodeCommand startCheckpoint(NamenodeRegistration bnReg, // backup node
                                NamenodeRegistration nnReg) // active name-node
throws IOException {
  LOG.info("Start checkpoint at txid " + getEditLog().getLastWrittenTxId());
  String msg = null;
  // Verify that checkpoint is allowed
  if(bnReg.getNamespaceID() != storage.getNamespaceID())
    msg = "Name node " + bnReg.getAddress()
          + " has incompatible namespace id: " + bnReg.getNamespaceID()
          + " expected: " + storage.getNamespaceID();
  else if(bnReg.isRole(NamenodeRole.NAMENODE))
    msg = "Name node " + bnReg.getAddress()
          + " role " + bnReg.getRole() + ": checkpoint is not allowed.";
  else if(bnReg.getLayoutVersion() < storage.getLayoutVersion()
      || (bnReg.getLayoutVersion() == storage.getLayoutVersion()
          && bnReg.getCTime() > storage.getCTime()))
    // remote node has newer image age
    msg = "Name node " + bnReg.getAddress()
          + " has newer image layout version: LV = " +bnReg.getLayoutVersion()
          + " cTime = " + bnReg.getCTime()
          + ". Current version: LV = " + storage.getLayoutVersion()
          + " cTime = " + storage.getCTime();
  if(msg != null) {
    LOG.error(msg);
    return new NamenodeCommand(NamenodeProtocol.ACT_SHUTDOWN);
  }
  boolean needToReturnImg = true;
  if(storage.getNumStorageDirs(NameNodeDirType.IMAGE) == 0)
    // do not return image if there are no image directories
    needToReturnImg = false;
  CheckpointSignature sig = rollEditLog();
  return new CheckpointCommand(sig, needToReturnImg);
}
项目:hadoop    文件:PBHelper.java   
public static NamenodeCommandProto convert(NamenodeCommand cmd) {
  if (cmd instanceof CheckpointCommand) {
    return NamenodeCommandProto.newBuilder().setAction(cmd.getAction())
        .setType(NamenodeCommandProto.Type.CheckPointCommand)
        .setCheckpointCmd(convert((CheckpointCommand) cmd)).build();
  }
  return NamenodeCommandProto.newBuilder()
      .setType(NamenodeCommandProto.Type.NamenodeCommand)
      .setAction(cmd.getAction()).build();
}
项目:hadoop    文件:PBHelper.java   
public static NamenodeCommand convert(NamenodeCommandProto cmd) {
  if (cmd == null) return null;
  switch (cmd.getType()) {
  case CheckPointCommand:
    CheckpointCommandProto chkPt = cmd.getCheckpointCmd();
    return new CheckpointCommand(PBHelper.convert(chkPt.getSignature()),
        chkPt.getNeedToReturnImage());
  default:
    return new NamenodeCommand(cmd.getAction());
  }
}
项目:aliyun-oss-hadoop-fs    文件:FSImage.java   
/**
 * Start checkpoint.
 * <p>
 * If backup storage contains image that is newer than or incompatible with 
 * what the active name-node has, then the backup node should shutdown.<br>
 * If the backup image is older than the active one then it should 
 * be discarded and downloaded from the active node.<br>
 * If the images are the same then the backup image will be used as current.
 * 
 * @param bnReg the backup node registration.
 * @param nnReg this (active) name-node registration.
 * @return {@link NamenodeCommand} if backup node should shutdown or
 * {@link CheckpointCommand} prescribing what backup node should 
 *         do with its image.
 * @throws IOException
 */
NamenodeCommand startCheckpoint(NamenodeRegistration bnReg, // backup node
                                NamenodeRegistration nnReg,
                                int layoutVersion) // active name-node
throws IOException {
  LOG.info("Start checkpoint at txid " + getEditLog().getLastWrittenTxId());
  String msg = null;
  // Verify that checkpoint is allowed
  if(bnReg.getNamespaceID() != storage.getNamespaceID())
    msg = "Name node " + bnReg.getAddress()
          + " has incompatible namespace id: " + bnReg.getNamespaceID()
          + " expected: " + storage.getNamespaceID();
  else if(bnReg.isRole(NamenodeRole.NAMENODE))
    msg = "Name node " + bnReg.getAddress()
          + " role " + bnReg.getRole() + ": checkpoint is not allowed.";
  else if(bnReg.getLayoutVersion() < storage.getLayoutVersion()
      || (bnReg.getLayoutVersion() == storage.getLayoutVersion()
          && bnReg.getCTime() > storage.getCTime()))
    // remote node has newer image age
    msg = "Name node " + bnReg.getAddress()
          + " has newer image layout version: LV = " +bnReg.getLayoutVersion()
          + " cTime = " + bnReg.getCTime()
          + ". Current version: LV = " + storage.getLayoutVersion()
          + " cTime = " + storage.getCTime();
  if(msg != null) {
    LOG.error(msg);
    return new NamenodeCommand(NamenodeProtocol.ACT_SHUTDOWN);
  }
  boolean needToReturnImg = true;
  if(storage.getNumStorageDirs(NameNodeDirType.IMAGE) == 0)
    // do not return image if there are no image directories
    needToReturnImg = false;
  CheckpointSignature sig = rollEditLog(layoutVersion);
  return new CheckpointCommand(sig, needToReturnImg);
}
项目:aliyun-oss-hadoop-fs    文件:PBHelper.java   
public static NamenodeCommandProto convert(NamenodeCommand cmd) {
  if (cmd instanceof CheckpointCommand) {
    return NamenodeCommandProto.newBuilder().setAction(cmd.getAction())
        .setType(NamenodeCommandProto.Type.CheckPointCommand)
        .setCheckpointCmd(convert((CheckpointCommand) cmd)).build();
  }
  return NamenodeCommandProto.newBuilder()
      .setType(NamenodeCommandProto.Type.NamenodeCommand)
      .setAction(cmd.getAction()).build();
}
项目:aliyun-oss-hadoop-fs    文件:PBHelper.java   
public static NamenodeCommand convert(NamenodeCommandProto cmd) {
  if (cmd == null) return null;
  switch (cmd.getType()) {
  case CheckPointCommand:
    CheckpointCommandProto chkPt = cmd.getCheckpointCmd();
    return new CheckpointCommand(PBHelper.convert(chkPt.getSignature()),
        chkPt.getNeedToReturnImage());
  default:
    return new NamenodeCommand(cmd.getAction());
  }
}
项目:big-c    文件:FSImage.java   
/**
 * Start checkpoint.
 * <p>
 * If backup storage contains image that is newer than or incompatible with 
 * what the active name-node has, then the backup node should shutdown.<br>
 * If the backup image is older than the active one then it should 
 * be discarded and downloaded from the active node.<br>
 * If the images are the same then the backup image will be used as current.
 * 
 * @param bnReg the backup node registration.
 * @param nnReg this (active) name-node registration.
 * @return {@link NamenodeCommand} if backup node should shutdown or
 * {@link CheckpointCommand} prescribing what backup node should 
 *         do with its image.
 * @throws IOException
 */
NamenodeCommand startCheckpoint(NamenodeRegistration bnReg, // backup node
                                NamenodeRegistration nnReg) // active name-node
throws IOException {
  LOG.info("Start checkpoint at txid " + getEditLog().getLastWrittenTxId());
  String msg = null;
  // Verify that checkpoint is allowed
  if(bnReg.getNamespaceID() != storage.getNamespaceID())
    msg = "Name node " + bnReg.getAddress()
          + " has incompatible namespace id: " + bnReg.getNamespaceID()
          + " expected: " + storage.getNamespaceID();
  else if(bnReg.isRole(NamenodeRole.NAMENODE))
    msg = "Name node " + bnReg.getAddress()
          + " role " + bnReg.getRole() + ": checkpoint is not allowed.";
  else if(bnReg.getLayoutVersion() < storage.getLayoutVersion()
      || (bnReg.getLayoutVersion() == storage.getLayoutVersion()
          && bnReg.getCTime() > storage.getCTime()))
    // remote node has newer image age
    msg = "Name node " + bnReg.getAddress()
          + " has newer image layout version: LV = " +bnReg.getLayoutVersion()
          + " cTime = " + bnReg.getCTime()
          + ". Current version: LV = " + storage.getLayoutVersion()
          + " cTime = " + storage.getCTime();
  if(msg != null) {
    LOG.error(msg);
    return new NamenodeCommand(NamenodeProtocol.ACT_SHUTDOWN);
  }
  boolean needToReturnImg = true;
  if(storage.getNumStorageDirs(NameNodeDirType.IMAGE) == 0)
    // do not return image if there are no image directories
    needToReturnImg = false;
  CheckpointSignature sig = rollEditLog();
  return new CheckpointCommand(sig, needToReturnImg);
}
项目:big-c    文件:PBHelper.java   
public static NamenodeCommandProto convert(NamenodeCommand cmd) {
  if (cmd instanceof CheckpointCommand) {
    return NamenodeCommandProto.newBuilder().setAction(cmd.getAction())
        .setType(NamenodeCommandProto.Type.CheckPointCommand)
        .setCheckpointCmd(convert((CheckpointCommand) cmd)).build();
  }
  return NamenodeCommandProto.newBuilder()
      .setType(NamenodeCommandProto.Type.NamenodeCommand)
      .setAction(cmd.getAction()).build();
}
项目:big-c    文件:PBHelper.java   
public static NamenodeCommand convert(NamenodeCommandProto cmd) {
  if (cmd == null) return null;
  switch (cmd.getType()) {
  case CheckPointCommand:
    CheckpointCommandProto chkPt = cmd.getCheckpointCmd();
    return new CheckpointCommand(PBHelper.convert(chkPt.getSignature()),
        chkPt.getNeedToReturnImage());
  default:
    return new NamenodeCommand(cmd.getAction());
  }
}
项目:hadoop-2.6.0-cdh5.4.3    文件:FSImage.java   
/**
 * Start checkpoint.
 * <p>
 * If backup storage contains image that is newer than or incompatible with 
 * what the active name-node has, then the backup node should shutdown.<br>
 * If the backup image is older than the active one then it should 
 * be discarded and downloaded from the active node.<br>
 * If the images are the same then the backup image will be used as current.
 * 
 * @param bnReg the backup node registration.
 * @param nnReg this (active) name-node registration.
 * @return {@link NamenodeCommand} if backup node should shutdown or
 * {@link CheckpointCommand} prescribing what backup node should 
 *         do with its image.
 * @throws IOException
 */
NamenodeCommand startCheckpoint(NamenodeRegistration bnReg, // backup node
                                NamenodeRegistration nnReg) // active name-node
throws IOException {
  LOG.info("Start checkpoint at txid " + getEditLog().getLastWrittenTxId());
  String msg = null;
  // Verify that checkpoint is allowed
  if(bnReg.getNamespaceID() != storage.getNamespaceID())
    msg = "Name node " + bnReg.getAddress()
          + " has incompatible namespace id: " + bnReg.getNamespaceID()
          + " expected: " + storage.getNamespaceID();
  else if(bnReg.isRole(NamenodeRole.NAMENODE))
    msg = "Name node " + bnReg.getAddress()
          + " role " + bnReg.getRole() + ": checkpoint is not allowed.";
  else if(bnReg.getLayoutVersion() < storage.getLayoutVersion()
      || (bnReg.getLayoutVersion() == storage.getLayoutVersion()
          && bnReg.getCTime() > storage.getCTime()))
    // remote node has newer image age
    msg = "Name node " + bnReg.getAddress()
          + " has newer image layout version: LV = " +bnReg.getLayoutVersion()
          + " cTime = " + bnReg.getCTime()
          + ". Current version: LV = " + storage.getLayoutVersion()
          + " cTime = " + storage.getCTime();
  if(msg != null) {
    LOG.error(msg);
    return new NamenodeCommand(NamenodeProtocol.ACT_SHUTDOWN);
  }
  boolean needToReturnImg = true;
  if(storage.getNumStorageDirs(NameNodeDirType.IMAGE) == 0)
    // do not return image if there are no image directories
    needToReturnImg = false;
  CheckpointSignature sig = rollEditLog();
  return new CheckpointCommand(sig, needToReturnImg);
}
项目:hadoop-2.6.0-cdh5.4.3    文件:PBHelper.java   
public static NamenodeCommandProto convert(NamenodeCommand cmd) {
  if (cmd instanceof CheckpointCommand) {
    return NamenodeCommandProto.newBuilder().setAction(cmd.getAction())
        .setType(NamenodeCommandProto.Type.CheckPointCommand)
        .setCheckpointCmd(convert((CheckpointCommand) cmd)).build();
  }
  return NamenodeCommandProto.newBuilder()
      .setType(NamenodeCommandProto.Type.NamenodeCommand)
      .setAction(cmd.getAction()).build();
}
项目:hadoop-2.6.0-cdh5.4.3    文件:PBHelper.java   
public static NamenodeCommand convert(NamenodeCommandProto cmd) {
  if (cmd == null) return null;
  switch (cmd.getType()) {
  case CheckPointCommand:
    CheckpointCommandProto chkPt = cmd.getCheckpointCmd();
    return new CheckpointCommand(PBHelper.convert(chkPt.getSignature()),
        chkPt.getNeedToReturnImage());
  default:
    return new NamenodeCommand(cmd.getAction());
  }
}
项目:hadoop-plus    文件:FSImage.java   
/**
 * Start checkpoint.
 * <p>
 * If backup storage contains image that is newer than or incompatible with 
 * what the active name-node has, then the backup node should shutdown.<br>
 * If the backup image is older than the active one then it should 
 * be discarded and downloaded from the active node.<br>
 * If the images are the same then the backup image will be used as current.
 * 
 * @param bnReg the backup node registration.
 * @param nnReg this (active) name-node registration.
 * @return {@link NamenodeCommand} if backup node should shutdown or
 * {@link CheckpointCommand} prescribing what backup node should 
 *         do with its image.
 * @throws IOException
 */
NamenodeCommand startCheckpoint(NamenodeRegistration bnReg, // backup node
                                NamenodeRegistration nnReg) // active name-node
throws IOException {
  LOG.info("Start checkpoint at txid " + getEditLog().getLastWrittenTxId());
  String msg = null;
  // Verify that checkpoint is allowed
  if(bnReg.getNamespaceID() != storage.getNamespaceID())
    msg = "Name node " + bnReg.getAddress()
          + " has incompatible namespace id: " + bnReg.getNamespaceID()
          + " expected: " + storage.getNamespaceID();
  else if(bnReg.isRole(NamenodeRole.NAMENODE))
    msg = "Name node " + bnReg.getAddress()
          + " role " + bnReg.getRole() + ": checkpoint is not allowed.";
  else if(bnReg.getLayoutVersion() < storage.getLayoutVersion()
      || (bnReg.getLayoutVersion() == storage.getLayoutVersion()
          && bnReg.getCTime() > storage.getCTime()))
    // remote node has newer image age
    msg = "Name node " + bnReg.getAddress()
          + " has newer image layout version: LV = " +bnReg.getLayoutVersion()
          + " cTime = " + bnReg.getCTime()
          + ". Current version: LV = " + storage.getLayoutVersion()
          + " cTime = " + storage.getCTime();
  if(msg != null) {
    LOG.error(msg);
    return new NamenodeCommand(NamenodeProtocol.ACT_SHUTDOWN);
  }
  boolean needToReturnImg = true;
  if(storage.getNumStorageDirs(NameNodeDirType.IMAGE) == 0)
    // do not return image if there are no image directories
    needToReturnImg = false;
  CheckpointSignature sig = rollEditLog();
  return new CheckpointCommand(sig, needToReturnImg);
}
项目:hadoop-plus    文件:PBHelper.java   
public static NamenodeCommandProto convert(NamenodeCommand cmd) {
  if (cmd instanceof CheckpointCommand) {
    return NamenodeCommandProto.newBuilder().setAction(cmd.getAction())
        .setType(NamenodeCommandProto.Type.CheckPointCommand)
        .setCheckpointCmd(convert((CheckpointCommand) cmd)).build();
  }
  return NamenodeCommandProto.newBuilder()
      .setType(NamenodeCommandProto.Type.NamenodeCommand)
      .setAction(cmd.getAction()).build();
}
项目:hadoop-plus    文件:PBHelper.java   
public static NamenodeCommand convert(NamenodeCommandProto cmd) {
  if (cmd == null) return null;
  switch (cmd.getType()) {
  case CheckPointCommand:
    CheckpointCommandProto chkPt = cmd.getCheckpointCmd();
    return new CheckpointCommand(PBHelper.convert(chkPt.getSignature()),
        chkPt.getNeedToReturnImage());
  default:
    return new NamenodeCommand(cmd.getAction());
  }
}
项目:FlexMap    文件:FSImage.java   
/**
 * Start checkpoint.
 * <p>
 * If backup storage contains image that is newer than or incompatible with 
 * what the active name-node has, then the backup node should shutdown.<br>
 * If the backup image is older than the active one then it should 
 * be discarded and downloaded from the active node.<br>
 * If the images are the same then the backup image will be used as current.
 * 
 * @param bnReg the backup node registration.
 * @param nnReg this (active) name-node registration.
 * @return {@link NamenodeCommand} if backup node should shutdown or
 * {@link CheckpointCommand} prescribing what backup node should 
 *         do with its image.
 * @throws IOException
 */
NamenodeCommand startCheckpoint(NamenodeRegistration bnReg, // backup node
                                NamenodeRegistration nnReg) // active name-node
throws IOException {
  LOG.info("Start checkpoint at txid " + getEditLog().getLastWrittenTxId());
  String msg = null;
  // Verify that checkpoint is allowed
  if(bnReg.getNamespaceID() != storage.getNamespaceID())
    msg = "Name node " + bnReg.getAddress()
          + " has incompatible namespace id: " + bnReg.getNamespaceID()
          + " expected: " + storage.getNamespaceID();
  else if(bnReg.isRole(NamenodeRole.NAMENODE))
    msg = "Name node " + bnReg.getAddress()
          + " role " + bnReg.getRole() + ": checkpoint is not allowed.";
  else if(bnReg.getLayoutVersion() < storage.getLayoutVersion()
      || (bnReg.getLayoutVersion() == storage.getLayoutVersion()
          && bnReg.getCTime() > storage.getCTime()))
    // remote node has newer image age
    msg = "Name node " + bnReg.getAddress()
          + " has newer image layout version: LV = " +bnReg.getLayoutVersion()
          + " cTime = " + bnReg.getCTime()
          + ". Current version: LV = " + storage.getLayoutVersion()
          + " cTime = " + storage.getCTime();
  if(msg != null) {
    LOG.error(msg);
    return new NamenodeCommand(NamenodeProtocol.ACT_SHUTDOWN);
  }
  boolean needToReturnImg = true;
  if(storage.getNumStorageDirs(NameNodeDirType.IMAGE) == 0)
    // do not return image if there are no image directories
    needToReturnImg = false;
  CheckpointSignature sig = rollEditLog();
  return new CheckpointCommand(sig, needToReturnImg);
}
项目:FlexMap    文件:PBHelper.java   
public static NamenodeCommandProto convert(NamenodeCommand cmd) {
  if (cmd instanceof CheckpointCommand) {
    return NamenodeCommandProto.newBuilder().setAction(cmd.getAction())
        .setType(NamenodeCommandProto.Type.CheckPointCommand)
        .setCheckpointCmd(convert((CheckpointCommand) cmd)).build();
  }
  return NamenodeCommandProto.newBuilder()
      .setType(NamenodeCommandProto.Type.NamenodeCommand)
      .setAction(cmd.getAction()).build();
}
项目:FlexMap    文件:PBHelper.java   
public static NamenodeCommand convert(NamenodeCommandProto cmd) {
  if (cmd == null) return null;
  switch (cmd.getType()) {
  case CheckPointCommand:
    CheckpointCommandProto chkPt = cmd.getCheckpointCmd();
    return new CheckpointCommand(PBHelper.convert(chkPt.getSignature()),
        chkPt.getNeedToReturnImage());
  default:
    return new NamenodeCommand(cmd.getAction());
  }
}
项目:hadoop-TCP    文件:FSImage.java   
/**
 * Start checkpoint.
 * <p>
 * If backup storage contains image that is newer than or incompatible with 
 * what the active name-node has, then the backup node should shutdown.<br>
 * If the backup image is older than the active one then it should 
 * be discarded and downloaded from the active node.<br>
 * If the images are the same then the backup image will be used as current.
 * 
 * @param bnReg the backup node registration.
 * @param nnReg this (active) name-node registration.
 * @return {@link NamenodeCommand} if backup node should shutdown or
 * {@link CheckpointCommand} prescribing what backup node should 
 *         do with its image.
 * @throws IOException
 */
NamenodeCommand startCheckpoint(NamenodeRegistration bnReg, // backup node
                                NamenodeRegistration nnReg) // active name-node
throws IOException {
  LOG.info("Start checkpoint at txid " + getEditLog().getLastWrittenTxId());
  String msg = null;
  // Verify that checkpoint is allowed
  if(bnReg.getNamespaceID() != storage.getNamespaceID())
    msg = "Name node " + bnReg.getAddress()
          + " has incompatible namespace id: " + bnReg.getNamespaceID()
          + " expected: " + storage.getNamespaceID();
  else if(bnReg.isRole(NamenodeRole.NAMENODE))
    msg = "Name node " + bnReg.getAddress()
          + " role " + bnReg.getRole() + ": checkpoint is not allowed.";
  else if(bnReg.getLayoutVersion() < storage.getLayoutVersion()
      || (bnReg.getLayoutVersion() == storage.getLayoutVersion()
          && bnReg.getCTime() > storage.getCTime()))
    // remote node has newer image age
    msg = "Name node " + bnReg.getAddress()
          + " has newer image layout version: LV = " +bnReg.getLayoutVersion()
          + " cTime = " + bnReg.getCTime()
          + ". Current version: LV = " + storage.getLayoutVersion()
          + " cTime = " + storage.getCTime();
  if(msg != null) {
    LOG.error(msg);
    return new NamenodeCommand(NamenodeProtocol.ACT_SHUTDOWN);
  }
  boolean needToReturnImg = true;
  if(storage.getNumStorageDirs(NameNodeDirType.IMAGE) == 0)
    // do not return image if there are no image directories
    needToReturnImg = false;
  CheckpointSignature sig = rollEditLog();
  return new CheckpointCommand(sig, needToReturnImg);
}
项目:hadoop-TCP    文件:PBHelper.java   
public static NamenodeCommandProto convert(NamenodeCommand cmd) {
  if (cmd instanceof CheckpointCommand) {
    return NamenodeCommandProto.newBuilder().setAction(cmd.getAction())
        .setType(NamenodeCommandProto.Type.CheckPointCommand)
        .setCheckpointCmd(convert((CheckpointCommand) cmd)).build();
  }
  return NamenodeCommandProto.newBuilder()
      .setType(NamenodeCommandProto.Type.NamenodeCommand)
      .setAction(cmd.getAction()).build();
}
项目:hadoop-TCP    文件:PBHelper.java   
public static NamenodeCommand convert(NamenodeCommandProto cmd) {
  if (cmd == null) return null;
  switch (cmd.getType()) {
  case CheckPointCommand:
    CheckpointCommandProto chkPt = cmd.getCheckpointCmd();
    return new CheckpointCommand(PBHelper.convert(chkPt.getSignature()),
        chkPt.getNeedToReturnImage());
  default:
    return new NamenodeCommand(cmd.getAction());
  }
}
项目:hardfs    文件:FSImage.java   
/**
 * Start checkpoint.
 * <p>
 * If backup storage contains image that is newer than or incompatible with 
 * what the active name-node has, then the backup node should shutdown.<br>
 * If the backup image is older than the active one then it should 
 * be discarded and downloaded from the active node.<br>
 * If the images are the same then the backup image will be used as current.
 * 
 * @param bnReg the backup node registration.
 * @param nnReg this (active) name-node registration.
 * @return {@link NamenodeCommand} if backup node should shutdown or
 * {@link CheckpointCommand} prescribing what backup node should 
 *         do with its image.
 * @throws IOException
 */
NamenodeCommand startCheckpoint(NamenodeRegistration bnReg, // backup node
                                NamenodeRegistration nnReg) // active name-node
throws IOException {
  LOG.info("Start checkpoint at txid " + getEditLog().getLastWrittenTxId());
  String msg = null;
  // Verify that checkpoint is allowed
  if(bnReg.getNamespaceID() != storage.getNamespaceID())
    msg = "Name node " + bnReg.getAddress()
          + " has incompatible namespace id: " + bnReg.getNamespaceID()
          + " expected: " + storage.getNamespaceID();
  else if(bnReg.isRole(NamenodeRole.NAMENODE))
    msg = "Name node " + bnReg.getAddress()
          + " role " + bnReg.getRole() + ": checkpoint is not allowed.";
  else if(bnReg.getLayoutVersion() < storage.getLayoutVersion()
      || (bnReg.getLayoutVersion() == storage.getLayoutVersion()
          && bnReg.getCTime() > storage.getCTime()))
    // remote node has newer image age
    msg = "Name node " + bnReg.getAddress()
          + " has newer image layout version: LV = " +bnReg.getLayoutVersion()
          + " cTime = " + bnReg.getCTime()
          + ". Current version: LV = " + storage.getLayoutVersion()
          + " cTime = " + storage.getCTime();
  if(msg != null) {
    LOG.error(msg);
    return new NamenodeCommand(NamenodeProtocol.ACT_SHUTDOWN);
  }
  boolean needToReturnImg = true;
  if(storage.getNumStorageDirs(NameNodeDirType.IMAGE) == 0)
    // do not return image if there are no image directories
    needToReturnImg = false;
  CheckpointSignature sig = rollEditLog();
  return new CheckpointCommand(sig, needToReturnImg);
}
项目:hardfs    文件:PBHelper.java   
public static NamenodeCommandProto convert(NamenodeCommand cmd) {
  if (cmd instanceof CheckpointCommand) {
    return NamenodeCommandProto.newBuilder().setAction(cmd.getAction())
        .setType(NamenodeCommandProto.Type.CheckPointCommand)
        .setCheckpointCmd(convert((CheckpointCommand) cmd)).build();
  }
  return NamenodeCommandProto.newBuilder()
      .setType(NamenodeCommandProto.Type.NamenodeCommand)
      .setAction(cmd.getAction()).build();
}
项目:hardfs    文件:PBHelper.java   
public static NamenodeCommand convert(NamenodeCommandProto cmd) {
  if (cmd == null) return null;
  switch (cmd.getType()) {
  case CheckPointCommand:
    CheckpointCommandProto chkPt = cmd.getCheckpointCmd();
    return new CheckpointCommand(PBHelper.convert(chkPt.getSignature()),
        chkPt.getNeedToReturnImage());
  default:
    return new NamenodeCommand(cmd.getAction());
  }
}
项目:hadoop-on-lustre2    文件:FSImage.java   
/**
 * Start checkpoint.
 * <p>
 * If backup storage contains image that is newer than or incompatible with 
 * what the active name-node has, then the backup node should shutdown.<br>
 * If the backup image is older than the active one then it should 
 * be discarded and downloaded from the active node.<br>
 * If the images are the same then the backup image will be used as current.
 * 
 * @param bnReg the backup node registration.
 * @param nnReg this (active) name-node registration.
 * @return {@link NamenodeCommand} if backup node should shutdown or
 * {@link CheckpointCommand} prescribing what backup node should 
 *         do with its image.
 * @throws IOException
 */
NamenodeCommand startCheckpoint(NamenodeRegistration bnReg, // backup node
                                NamenodeRegistration nnReg) // active name-node
throws IOException {
  LOG.info("Start checkpoint at txid " + getEditLog().getLastWrittenTxId());
  String msg = null;
  // Verify that checkpoint is allowed
  if(bnReg.getNamespaceID() != storage.getNamespaceID())
    msg = "Name node " + bnReg.getAddress()
          + " has incompatible namespace id: " + bnReg.getNamespaceID()
          + " expected: " + storage.getNamespaceID();
  else if(bnReg.isRole(NamenodeRole.NAMENODE))
    msg = "Name node " + bnReg.getAddress()
          + " role " + bnReg.getRole() + ": checkpoint is not allowed.";
  else if(bnReg.getLayoutVersion() < storage.getLayoutVersion()
      || (bnReg.getLayoutVersion() == storage.getLayoutVersion()
          && bnReg.getCTime() > storage.getCTime()))
    // remote node has newer image age
    msg = "Name node " + bnReg.getAddress()
          + " has newer image layout version: LV = " +bnReg.getLayoutVersion()
          + " cTime = " + bnReg.getCTime()
          + ". Current version: LV = " + storage.getLayoutVersion()
          + " cTime = " + storage.getCTime();
  if(msg != null) {
    LOG.error(msg);
    return new NamenodeCommand(NamenodeProtocol.ACT_SHUTDOWN);
  }
  boolean needToReturnImg = true;
  if(storage.getNumStorageDirs(NameNodeDirType.IMAGE) == 0)
    // do not return image if there are no image directories
    needToReturnImg = false;
  CheckpointSignature sig = rollEditLog();
  return new CheckpointCommand(sig, needToReturnImg);
}
项目:hadoop-on-lustre2    文件:PBHelper.java   
public static NamenodeCommandProto convert(NamenodeCommand cmd) {
  if (cmd instanceof CheckpointCommand) {
    return NamenodeCommandProto.newBuilder().setAction(cmd.getAction())
        .setType(NamenodeCommandProto.Type.CheckPointCommand)
        .setCheckpointCmd(convert((CheckpointCommand) cmd)).build();
  }
  return NamenodeCommandProto.newBuilder()
      .setType(NamenodeCommandProto.Type.NamenodeCommand)
      .setAction(cmd.getAction()).build();
}
项目:hadoop-on-lustre2    文件:PBHelper.java   
public static NamenodeCommand convert(NamenodeCommandProto cmd) {
  if (cmd == null) return null;
  switch (cmd.getType()) {
  case CheckPointCommand:
    CheckpointCommandProto chkPt = cmd.getCheckpointCmd();
    return new CheckpointCommand(PBHelper.convert(chkPt.getSignature()),
        chkPt.getNeedToReturnImage());
  default:
    return new NamenodeCommand(cmd.getAction());
  }
}
项目:hadoop    文件:PBHelper.java   
public static CheckpointCommandProto convert(CheckpointCommand cmd) {
  return CheckpointCommandProto.newBuilder()
      .setSignature(convert(cmd.getSignature()))
      .setNeedToReturnImage(cmd.needToReturnImage()).build();
}
项目:aliyun-oss-hadoop-fs    文件:PBHelper.java   
public static CheckpointCommandProto convert(CheckpointCommand cmd) {
  return CheckpointCommandProto.newBuilder()
      .setSignature(convert(cmd.getSignature()))
      .setNeedToReturnImage(cmd.needToReturnImage()).build();
}
项目:big-c    文件:PBHelper.java   
public static CheckpointCommandProto convert(CheckpointCommand cmd) {
  return CheckpointCommandProto.newBuilder()
      .setSignature(convert(cmd.getSignature()))
      .setNeedToReturnImage(cmd.needToReturnImage()).build();
}
项目:hadoop-2.6.0-cdh5.4.3    文件:PBHelper.java   
public static CheckpointCommandProto convert(CheckpointCommand cmd) {
  return CheckpointCommandProto.newBuilder()
      .setSignature(convert(cmd.getSignature()))
      .setNeedToReturnImage(cmd.needToReturnImage()).build();
}
项目:hadoop-plus    文件:PBHelper.java   
public static CheckpointCommandProto convert(CheckpointCommand cmd) {
  return CheckpointCommandProto.newBuilder()
      .setSignature(convert(cmd.getSignature()))
      .setNeedToReturnImage(cmd.needToReturnImage()).build();
}
项目:FlexMap    文件:PBHelper.java   
public static CheckpointCommandProto convert(CheckpointCommand cmd) {
  return CheckpointCommandProto.newBuilder()
      .setSignature(convert(cmd.getSignature()))
      .setNeedToReturnImage(cmd.needToReturnImage()).build();
}
项目:hadoop-TCP    文件:PBHelper.java   
public static CheckpointCommandProto convert(CheckpointCommand cmd) {
  return CheckpointCommandProto.newBuilder()
      .setSignature(convert(cmd.getSignature()))
      .setNeedToReturnImage(cmd.needToReturnImage()).build();
}
项目:hardfs    文件:PBHelper.java   
public static CheckpointCommandProto convert(CheckpointCommand cmd) {
  return CheckpointCommandProto.newBuilder()
      .setSignature(convert(cmd.getSignature()))
      .setNeedToReturnImage(cmd.needToReturnImage()).build();
}
项目:hadoop-on-lustre2    文件:PBHelper.java   
public static CheckpointCommandProto convert(CheckpointCommand cmd) {
  return CheckpointCommandProto.newBuilder()
      .setSignature(convert(cmd.getSignature()))
      .setNeedToReturnImage(cmd.needToReturnImage()).build();
}
项目:cumulus    文件:FSImage.java   
/**
 * Start checkpoint.
 * <p>
 * If backup storage contains image that is newer than or incompatible with 
 * what the active name-node has, then the backup node should shutdown.<br>
 * If the backup image is older than the active one then it should 
 * be discarded and downloaded from the active node.<br>
 * If the images are the same then the backup image will be used as current.
 * 
 * @param bnReg the backup node registration.
 * @param nnReg this (active) name-node registration.
 * @return {@link NamenodeCommand} if backup node should shutdown or
 * {@link CheckpointCommand} prescribing what backup node should 
 *         do with its image.
 * @throws IOException
 */
NamenodeCommand startCheckpoint(NamenodeRegistration bnReg, // backup node
                                NamenodeRegistration nnReg) // active name-node
throws IOException {
  String msg = null;
  // Verify that checkpoint is allowed
  if(bnReg.getNamespaceID() != this.getNamespaceID())
    msg = "Name node " + bnReg.getAddress()
          + " has incompatible namespace id: " + bnReg.getNamespaceID()
          + " expected: " + getNamespaceID();
  else if(bnReg.isRole(NamenodeRole.ACTIVE))
    msg = "Name node " + bnReg.getAddress()
          + " role " + bnReg.getRole() + ": checkpoint is not allowed.";
  else if(bnReg.getLayoutVersion() < this.getLayoutVersion()
      || (bnReg.getLayoutVersion() == this.getLayoutVersion()
          && bnReg.getCTime() > this.getCTime())
      || (bnReg.getLayoutVersion() == this.getLayoutVersion()
          && bnReg.getCTime() == this.getCTime()
          && bnReg.getCheckpointTime() > this.checkpointTime))
    // remote node has newer image age
    msg = "Name node " + bnReg.getAddress()
          + " has newer image layout version: LV = " +bnReg.getLayoutVersion()
          + " cTime = " + bnReg.getCTime()
          + " checkpointTime = " + bnReg.getCheckpointTime()
          + ". Current version: LV = " + getLayoutVersion()
          + " cTime = " + getCTime()
          + " checkpointTime = " + checkpointTime;
  if(msg != null) {
    LOG.error(msg);
    return new NamenodeCommand(NamenodeProtocol.ACT_SHUTDOWN);
  }
  boolean isImgObsolete = true;
  if(bnReg.getLayoutVersion() == this.getLayoutVersion()
      && bnReg.getCTime() == this.getCTime()
      && bnReg.getCheckpointTime() == this.checkpointTime)
    isImgObsolete = false;
  boolean needToReturnImg = true;
  if(getNumStorageDirs(NameNodeDirType.IMAGE) == 0)
    // do not return image if there are no image directories
    needToReturnImg = false;
  CheckpointSignature sig = rollEditLog();
  getEditLog().logJSpoolStart(bnReg, nnReg);
  return new CheckpointCommand(sig, isImgObsolete, needToReturnImg);
}