Java Code Examples for org.apache.hadoop.hdfs.server.namenode.FSImageSerialization#readBytes()

The following examples show how to use org.apache.hadoop.hdfs.server.namenode.FSImageSerialization#readBytes() . 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: ImageLoaderCurrent.java    From hadoop with Apache License 2.0 4 votes vote down vote up
/**
 * Process the INodes under construction section of the fsimage.
 *
 * @param in DataInputStream to process
 * @param v Visitor to walk over inodes
 * @param skipBlocks Walk over each block?
 */
private void processINodesUC(DataInputStream in, ImageVisitor v,
    boolean skipBlocks) throws IOException {
  int numINUC = in.readInt();

  v.visitEnclosingElement(ImageElement.INODES_UNDER_CONSTRUCTION,
                         ImageElement.NUM_INODES_UNDER_CONSTRUCTION, numINUC);

  for(int i = 0; i < numINUC; i++) {
    v.visitEnclosingElement(ImageElement.INODE_UNDER_CONSTRUCTION);
    byte [] name = FSImageSerialization.readBytes(in);
    String n = new String(name, "UTF8");
    v.visit(ImageElement.INODE_PATH, n);
    
    if (NameNodeLayoutVersion.supports(Feature.ADD_INODE_ID, imageVersion)) {
      long inodeId = in.readLong();
      v.visit(ImageElement.INODE_ID, inodeId);
    }
    
    v.visit(ImageElement.REPLICATION, in.readShort());
    v.visit(ImageElement.MODIFICATION_TIME, formatDate(in.readLong()));

    v.visit(ImageElement.PREFERRED_BLOCK_SIZE, in.readLong());
    int numBlocks = in.readInt();
    processBlocks(in, v, numBlocks, skipBlocks);

    processPermission(in, v);
    v.visit(ImageElement.CLIENT_NAME, FSImageSerialization.readString(in));
    v.visit(ImageElement.CLIENT_MACHINE, FSImageSerialization.readString(in));

    // Skip over the datanode descriptors, which are still stored in the
    // file but are not used by the datanode or loaded into memory
    int numLocs = in.readInt();
    for(int j = 0; j < numLocs; j++) {
      in.readShort();
      in.readLong();
      in.readLong();
      in.readLong();
      in.readInt();
      FSImageSerialization.readString(in);
      FSImageSerialization.readString(in);
      WritableUtils.readEnum(in, AdminStates.class);
    }

    v.leaveEnclosingElement(); // INodeUnderConstruction
  }

  v.leaveEnclosingElement(); // INodesUnderConstruction
}
 
Example 2
Source File: ImageLoaderCurrent.java    From big-c with Apache License 2.0 4 votes vote down vote up
/**
 * Process the INodes under construction section of the fsimage.
 *
 * @param in DataInputStream to process
 * @param v Visitor to walk over inodes
 * @param skipBlocks Walk over each block?
 */
private void processINodesUC(DataInputStream in, ImageVisitor v,
    boolean skipBlocks) throws IOException {
  int numINUC = in.readInt();

  v.visitEnclosingElement(ImageElement.INODES_UNDER_CONSTRUCTION,
                         ImageElement.NUM_INODES_UNDER_CONSTRUCTION, numINUC);

  for(int i = 0; i < numINUC; i++) {
    v.visitEnclosingElement(ImageElement.INODE_UNDER_CONSTRUCTION);
    byte [] name = FSImageSerialization.readBytes(in);
    String n = new String(name, "UTF8");
    v.visit(ImageElement.INODE_PATH, n);
    
    if (NameNodeLayoutVersion.supports(Feature.ADD_INODE_ID, imageVersion)) {
      long inodeId = in.readLong();
      v.visit(ImageElement.INODE_ID, inodeId);
    }
    
    v.visit(ImageElement.REPLICATION, in.readShort());
    v.visit(ImageElement.MODIFICATION_TIME, formatDate(in.readLong()));

    v.visit(ImageElement.PREFERRED_BLOCK_SIZE, in.readLong());
    int numBlocks = in.readInt();
    processBlocks(in, v, numBlocks, skipBlocks);

    processPermission(in, v);
    v.visit(ImageElement.CLIENT_NAME, FSImageSerialization.readString(in));
    v.visit(ImageElement.CLIENT_MACHINE, FSImageSerialization.readString(in));

    // Skip over the datanode descriptors, which are still stored in the
    // file but are not used by the datanode or loaded into memory
    int numLocs = in.readInt();
    for(int j = 0; j < numLocs; j++) {
      in.readShort();
      in.readLong();
      in.readLong();
      in.readLong();
      in.readInt();
      FSImageSerialization.readString(in);
      FSImageSerialization.readString(in);
      WritableUtils.readEnum(in, AdminStates.class);
    }

    v.leaveEnclosingElement(); // INodeUnderConstruction
  }

  v.leaveEnclosingElement(); // INodesUnderConstruction
}
 
Example 3
Source File: ImageLoaderCurrent.java    From RDFS with Apache License 2.0 4 votes vote down vote up
/**
 * Process the INodes under construction section of the fsimage.
 *
 * @param in DataInputStream to process
 * @param v Visitor to walk over inodes
 * @param skipBlocks Walk over each block?
 */
private void processINodesUC(DataInputStream in, ImageVisitor v,
    boolean skipBlocks) throws IOException {
  int numINUC = in.readInt();

  v.visitEnclosingElement(ImageElement.INODES_UNDER_CONSTRUCTION,
                         ImageElement.NUM_INODES_UNDER_CONSTRUCTION, numINUC);

  for(int i = 0; i < numINUC; i++) {
    v.visitEnclosingElement(ImageElement.INODE_UNDER_CONSTRUCTION);
    byte [] name = FSImageSerialization.readBytes(in);
    String n = new String(name, "UTF8");
    v.visit(ImageElement.INODE_PATH, n);
    v.visit(ImageElement.REPLICATION, in.readShort());
    v.visit(ImageElement.MODIFICATION_TIME, formatDate(in.readLong()));

    v.visit(ImageElement.PREFERRED_BLOCK_SIZE, in.readLong());
    int numBlocks = in.readInt();
    processBlocks(in, v, numBlocks, skipBlocks);

    processPermission(in, v);
    v.visit(ImageElement.CLIENT_NAME, FSImageSerialization.readString(in));
    v.visit(ImageElement.CLIENT_MACHINE, FSImageSerialization.readString(in));

    // Skip over the datanode descriptors, which are still stored in the
    // file but are not used by the datanode or loaded into memory
    int numLocs = in.readInt();
    for(int j = 0; j < numLocs; j++) {
      in.readShort();
      in.readLong();
      in.readLong();
      in.readLong();
      in.readInt();
      FSImageSerialization.readString(in);
      FSImageSerialization.readString(in);
      WritableUtils.readEnum(in, AdminStates.class);
    }

    v.leaveEnclosingElement(); // INodeUnderConstruction
  }

  v.leaveEnclosingElement(); // INodesUnderConstruction
}