org.apache.hadoop.hdfs.tools.offlineImageViewer.ImageVisitor.ImageElement Java Examples

The following examples show how to use org.apache.hadoop.hdfs.tools.offlineImageViewer.ImageVisitor.ImageElement. 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 6 votes vote down vote up
/**
 * Process CacheManager state from the fsimage.
 */
private void processCacheManagerState(DataInputStream in, ImageVisitor v)
    throws IOException {
  v.visit(ImageElement.CACHE_NEXT_ENTRY_ID, in.readLong());
  final int numPools = in.readInt();
  for (int i=0; i<numPools; i++) {
    v.visit(ImageElement.CACHE_POOL_NAME, Text.readString(in));
    processCachePoolPermission(in, v);
    v.visit(ImageElement.CACHE_POOL_WEIGHT, in.readInt());
  }
  final int numEntries = in.readInt();
  for (int i=0; i<numEntries; i++) {
    v.visit(ImageElement.CACHE_ENTRY_PATH, Text.readString(in));
    v.visit(ImageElement.CACHE_ENTRY_REPLICATION, in.readShort());
    v.visit(ImageElement.CACHE_ENTRY_POOL_NAME, Text.readString(in));
  }
}
 
Example #2
Source File: ImageLoaderCurrent.java    From big-c with Apache License 2.0 6 votes vote down vote up
/**
 * Process the INode records stored in the fsimage.
 *
 * @param in Datastream to process
 * @param v Visitor to walk over INodes
 * @param numInodes Number of INodes stored in file
 * @param skipBlocks Process all the blocks within the INode?
 * @param supportSnapshot Whether or not the imageVersion supports snapshot
 * @throws VisitException
 * @throws IOException
 */
private void processINodes(DataInputStream in, ImageVisitor v,
    long numInodes, boolean skipBlocks, boolean supportSnapshot)
    throws IOException {
  v.visitEnclosingElement(ImageElement.INODES,
      ImageElement.NUM_INODES, numInodes);
  
  if (NameNodeLayoutVersion.supports(Feature.FSIMAGE_NAME_OPTIMIZATION, imageVersion)) {
    if (!supportSnapshot) {
      processLocalNameINodes(in, v, numInodes, skipBlocks);
    } else {
      processLocalNameINodesWithSnapshot(in, v, skipBlocks);
    }
  } else { // full path name
    processFullNameINodes(in, v, numInodes, skipBlocks);
  }

  
  v.leaveEnclosingElement(); // INodes
}
 
Example #3
Source File: ImageLoaderCurrent.java    From big-c with Apache License 2.0 6 votes vote down vote up
/**
 * Process CacheManager state from the fsimage.
 */
private void processCacheManagerState(DataInputStream in, ImageVisitor v)
    throws IOException {
  v.visit(ImageElement.CACHE_NEXT_ENTRY_ID, in.readLong());
  final int numPools = in.readInt();
  for (int i=0; i<numPools; i++) {
    v.visit(ImageElement.CACHE_POOL_NAME, Text.readString(in));
    processCachePoolPermission(in, v);
    v.visit(ImageElement.CACHE_POOL_WEIGHT, in.readInt());
  }
  final int numEntries = in.readInt();
  for (int i=0; i<numEntries; i++) {
    v.visit(ImageElement.CACHE_ENTRY_PATH, Text.readString(in));
    v.visit(ImageElement.CACHE_ENTRY_REPLICATION, in.readShort());
    v.visit(ImageElement.CACHE_ENTRY_POOL_NAME, Text.readString(in));
  }
}
 
Example #4
Source File: ImageLoaderCurrent.java    From hadoop with Apache License 2.0 6 votes vote down vote up
private void processFileDiff(DataInputStream in, ImageVisitor v,
    String currentINodeName) throws IOException {
  int snapshotId = in.readInt();
  v.visitEnclosingElement(ImageElement.SNAPSHOT_FILE_DIFF,
      ImageElement.SNAPSHOT_DIFF_SNAPSHOTID, snapshotId);
  v.visit(ImageElement.SNAPSHOT_FILE_SIZE, in.readLong());
  if (in.readBoolean()) {
    v.visitEnclosingElement(ImageElement.SNAPSHOT_INODE_FILE_ATTRIBUTES);
    if (NameNodeLayoutVersion.supports(Feature.OPTIMIZE_SNAPSHOT_INODES, imageVersion)) {
      processINodeFileAttributes(in, v, currentINodeName);
    } else {
      processINode(in, v, true, currentINodeName, true);
    }
    v.leaveEnclosingElement();
  }
  v.leaveEnclosingElement();
}
 
Example #5
Source File: ImageLoaderCurrent.java    From hadoop with Apache License 2.0 6 votes vote down vote up
/**
 * Process the INode records stored in the fsimage.
 *
 * @param in Datastream to process
 * @param v Visitor to walk over INodes
 * @param numInodes Number of INodes stored in file
 * @param skipBlocks Process all the blocks within the INode?
 * @param supportSnapshot Whether or not the imageVersion supports snapshot
 * @throws VisitException
 * @throws IOException
 */
private void processINodes(DataInputStream in, ImageVisitor v,
    long numInodes, boolean skipBlocks, boolean supportSnapshot)
    throws IOException {
  v.visitEnclosingElement(ImageElement.INODES,
      ImageElement.NUM_INODES, numInodes);
  
  if (NameNodeLayoutVersion.supports(Feature.FSIMAGE_NAME_OPTIMIZATION, imageVersion)) {
    if (!supportSnapshot) {
      processLocalNameINodes(in, v, numInodes, skipBlocks);
    } else {
      processLocalNameINodesWithSnapshot(in, v, skipBlocks);
    }
  } else { // full path name
    processFullNameINodes(in, v, numInodes, skipBlocks);
  }

  
  v.leaveEnclosingElement(); // INodes
}
 
Example #6
Source File: ImageLoaderCurrent.java    From hadoop with Apache License 2.0 6 votes vote down vote up
/**
 * Process snapshots of a snapshottable directory
 */
private void processSnapshots(DataInputStream in, ImageVisitor v,
    String rootName) throws IOException {
  final int numSnapshots = in.readInt();
  if (numSnapshots >= 0) {
    v.visitEnclosingElement(ImageElement.SNAPSHOTS,
        ImageElement.NUM_SNAPSHOTS, numSnapshots);
    for (int i = 0; i < numSnapshots; i++) {
      // process snapshot
      v.visitEnclosingElement(ImageElement.SNAPSHOT);
      v.visit(ImageElement.SNAPSHOT_ID, in.readInt());
      v.leaveEnclosingElement();
    }
    v.visit(ImageElement.SNAPSHOT_QUOTA, in.readInt());
    v.leaveEnclosingElement();
  }
}
 
Example #7
Source File: ImageLoaderCurrent.java    From big-c with Apache License 2.0 6 votes vote down vote up
private void processFileDiff(DataInputStream in, ImageVisitor v,
    String currentINodeName) throws IOException {
  int snapshotId = in.readInt();
  v.visitEnclosingElement(ImageElement.SNAPSHOT_FILE_DIFF,
      ImageElement.SNAPSHOT_DIFF_SNAPSHOTID, snapshotId);
  v.visit(ImageElement.SNAPSHOT_FILE_SIZE, in.readLong());
  if (in.readBoolean()) {
    v.visitEnclosingElement(ImageElement.SNAPSHOT_INODE_FILE_ATTRIBUTES);
    if (NameNodeLayoutVersion.supports(Feature.OPTIMIZE_SNAPSHOT_INODES, imageVersion)) {
      processINodeFileAttributes(in, v, currentINodeName);
    } else {
      processINode(in, v, true, currentINodeName, true);
    }
    v.leaveEnclosingElement();
  }
  v.leaveEnclosingElement();
}
 
Example #8
Source File: ImageLoaderCurrent.java    From big-c with Apache License 2.0 6 votes vote down vote up
/**
 * Process snapshots of a snapshottable directory
 */
private void processSnapshots(DataInputStream in, ImageVisitor v,
    String rootName) throws IOException {
  final int numSnapshots = in.readInt();
  if (numSnapshots >= 0) {
    v.visitEnclosingElement(ImageElement.SNAPSHOTS,
        ImageElement.NUM_SNAPSHOTS, numSnapshots);
    for (int i = 0; i < numSnapshots; i++) {
      // process snapshot
      v.visitEnclosingElement(ImageElement.SNAPSHOT);
      v.visit(ImageElement.SNAPSHOT_ID, in.readInt());
      v.leaveEnclosingElement();
    }
    v.visit(ImageElement.SNAPSHOT_QUOTA, in.readInt());
    v.leaveEnclosingElement();
  }
}
 
Example #9
Source File: ImageLoaderCurrent.java    From big-c with Apache License 2.0 5 votes vote down vote up
private void processINodeFileAttributes(DataInputStream in, ImageVisitor v,
    String parentName) throws IOException {
  final String pathName = readINodePath(in, parentName);
  v.visit(ImageElement.INODE_PATH, pathName);
  processPermission(in, v);
  v.visit(ImageElement.MODIFICATION_TIME, formatDate(in.readLong()));
  if(NameNodeLayoutVersion.supports(Feature.FILE_ACCESS_TIME, imageVersion)) {
    v.visit(ImageElement.ACCESS_TIME, formatDate(in.readLong()));
  }

  v.visit(ImageElement.REPLICATION, in.readShort());
  v.visit(ImageElement.BLOCK_SIZE, in.readLong());
}
 
Example #10
Source File: ImageLoaderCurrent.java    From big-c with Apache License 2.0 5 votes vote down vote up
/**
 * Extract CachePool permissions stored in the fsimage file.
 *
 * @param in Datastream to process
 * @param v Visitor to walk over inodes
 */
private void processCachePoolPermission(DataInputStream in, ImageVisitor v)
    throws IOException {
  v.visitEnclosingElement(ImageElement.PERMISSIONS);
  v.visit(ImageElement.CACHE_POOL_OWNER_NAME, Text.readString(in));
  v.visit(ImageElement.CACHE_POOL_GROUP_NAME, Text.readString(in));
  FsPermission fsp = new FsPermission(in.readShort());
  v.visit(ImageElement.CACHE_POOL_PERMISSION_STRING, fsp.toString());
  v.leaveEnclosingElement(); // Permissions
}
 
Example #11
Source File: ImageLoaderCurrent.java    From big-c with Apache License 2.0 5 votes vote down vote up
private void processSnapshot(DataInputStream in, ImageVisitor v)
    throws IOException {
  v.visitEnclosingElement(ImageElement.SNAPSHOT);
  v.visit(ImageElement.SNAPSHOT_ID, in.readInt());
  // process root of snapshot
  v.visitEnclosingElement(ImageElement.SNAPSHOT_ROOT);
  processINode(in, v, true, "", false);
  v.leaveEnclosingElement();
  v.leaveEnclosingElement();
}
 
Example #12
Source File: ImageLoaderCurrent.java    From big-c with Apache License 2.0 5 votes vote down vote up
private void processDirectoryDiffList(DataInputStream in, ImageVisitor v,
    String currentINodeName) throws IOException {
  final int numDirDiff = in.readInt();
  if (numDirDiff >= 0) {
    v.visitEnclosingElement(ImageElement.SNAPSHOT_DIR_DIFFS,
        ImageElement.NUM_SNAPSHOT_DIR_DIFF, numDirDiff);
    for (int i = 0; i < numDirDiff; i++) {
      // process directory diffs in reverse chronological oder
      processDirectoryDiff(in, v, currentINodeName); 
    }
    v.leaveEnclosingElement();
  }
}
 
Example #13
Source File: ImageLoaderCurrent.java    From big-c with Apache License 2.0 5 votes vote down vote up
private void processINodeDirectoryAttributes(DataInputStream in, ImageVisitor v,
    String parentName) throws IOException {
  final String pathName = readINodePath(in, parentName);
  v.visit(ImageElement.INODE_PATH, pathName);
  processPermission(in, v);
  v.visit(ImageElement.MODIFICATION_TIME, formatDate(in.readLong()));

  v.visit(ImageElement.NS_QUOTA, in.readLong());
  v.visit(ImageElement.DS_QUOTA, in.readLong());
}
 
Example #14
Source File: ImageLoaderCurrent.java    From big-c with Apache License 2.0 5 votes vote down vote up
/**
 * Process the blocks section of the fsimage.
 *
 * @param in Datastream to process
 * @param v Visitor to walk over inodes
 * @param skipBlocks Walk over each block?
 */
private void processBlocks(DataInputStream in, ImageVisitor v,
    int numBlocks, boolean skipBlocks) throws IOException {
  v.visitEnclosingElement(ImageElement.BLOCKS,
                          ImageElement.NUM_BLOCKS, numBlocks);
  
  // directory or symlink or reference node, no blocks to process    
  if(numBlocks < 0) { 
    v.leaveEnclosingElement(); // Blocks
    return;
  }
  
  if(skipBlocks) {
    int bytesToSkip = ((Long.SIZE * 3 /* fields */) / 8 /*bits*/) * numBlocks;
    if(in.skipBytes(bytesToSkip) != bytesToSkip)
      throw new IOException("Error skipping over blocks");
    
  } else {
    for(int j = 0; j < numBlocks; j++) {
      v.visitEnclosingElement(ImageElement.BLOCK);
      v.visit(ImageElement.BLOCK_ID, in.readLong());
      v.visit(ImageElement.NUM_BYTES, in.readLong());
      v.visit(ImageElement.GENERATION_STAMP, in.readLong());
      v.leaveEnclosingElement(); // Block
    }
  }
  v.leaveEnclosingElement(); // Blocks
}
 
Example #15
Source File: ImageLoaderCurrent.java    From big-c with Apache License 2.0 5 votes vote down vote up
private void processFileDiffList(DataInputStream in, ImageVisitor v,
    String currentINodeName) throws IOException {
  final int size = in.readInt();
  if (size >= 0) {
    v.visitEnclosingElement(ImageElement.SNAPSHOT_FILE_DIFFS,
        ImageElement.NUM_SNAPSHOT_FILE_DIFF, size);
    for (int i = 0; i < size; i++) {
      processFileDiff(in, v, currentINodeName);
    }
    v.leaveEnclosingElement();
  }
}
 
Example #16
Source File: TestDelimitedImageVisitor.java    From RDFS with Apache License 2.0 5 votes vote down vote up
private void build(DelimitedImageVisitor div, ImageElement elem, String val, 
                   StringBuilder sb, boolean includeDelim) throws IOException {
  div.visit(elem, val);
  sb.append(val);
  
  if(includeDelim)
    sb.append(delim);
}
 
Example #17
Source File: ImageLoaderCurrent.java    From RDFS with Apache License 2.0 5 votes vote down vote up
/**
 * Process the blocks section of the fsimage.
 *
 * @param in Datastream to process
 * @param v Visitor to walk over inodes
 * @param skipBlocks Walk over each block?
 */
private void processBlocks(DataInputStream in, ImageVisitor v,
    int numBlocks, boolean skipBlocks) throws IOException {
  v.visitEnclosingElement(ImageElement.BLOCKS,
                          ImageElement.NUM_BLOCKS, numBlocks);
  
  // directory or symlink, no blocks to process    
  if(numBlocks == -1 || numBlocks == -2) { 
    v.leaveEnclosingElement(); // Blocks
    return;
  }
  
  if(skipBlocks) {
    int bytesToSkip = ((Long.SIZE * 3 /* fields */) / 8 /*bits*/) * numBlocks;
    if(in.skipBytes(bytesToSkip) != bytesToSkip)
      throw new IOException("Error skipping over blocks");
    
  } else {
    for(int j = 0; j < numBlocks; j++) {
      v.visitEnclosingElement(ImageElement.BLOCK);
      v.visit(ImageElement.BLOCK_ID, in.readLong());
      v.visit(ImageElement.NUM_BYTES, in.readLong());
      v.visit(ImageElement.GENERATION_STAMP, in.readLong());
      v.leaveEnclosingElement(); // Block
    }
  }
  v.leaveEnclosingElement(); // Blocks
}
 
Example #18
Source File: ImageLoaderCurrent.java    From RDFS with Apache License 2.0 5 votes vote down vote up
/**
 * Extract the INode permissions stored in the fsimage file.
 *
 * @param in Datastream to process
 * @param v Visitor to walk over inodes
 */
private void processPermission(DataInputStream in, ImageVisitor v)
    throws IOException {
  v.visitEnclosingElement(ImageElement.PERMISSIONS);
  v.visit(ImageElement.USER_NAME, Text.readString(in));
  v.visit(ImageElement.GROUP_NAME, Text.readString(in));
  FsPermission fsp = new FsPermission(in.readShort());
  v.visit(ImageElement.PERMISSION_STRING, fsp.toString());
  v.leaveEnclosingElement(); // Permissions
}
 
Example #19
Source File: ImageLoaderCurrent.java    From RDFS with Apache License 2.0 5 votes vote down vote up
/**
 * Process the INode records stored in the fsimage.
 *
 * @param in Datastream to process
 * @param v Visitor to walk over INodes
 * @param numInodes Number of INodes stored in file
 * @param skipBlocks Process all the blocks within the INode?
 * @throws VisitException
 * @throws IOException
 */
private void processINodes(DataInputStream in, ImageVisitor v,
    long numInodes, boolean skipBlocks) throws IOException {
  v.visitEnclosingElement(ImageElement.INODES,
      ImageElement.NUM_INODES, numInodes);
  
  if (LayoutVersion.supports(Feature.FSIMAGE_NAME_OPTIMIZATION, imageVersion)) {
    processLocalNameINodes(in, v, numInodes, skipBlocks);
  } else { // full path name
    processFullNameINodes(in, v, numInodes, skipBlocks);
  }

  
  v.leaveEnclosingElement(); // INodes
}
 
Example #20
Source File: ImageLoaderCurrent.java    From RDFS with Apache License 2.0 5 votes vote down vote up
/**
  * Process an INode
  * 
  * @param in image stream
  * @param v visitor
  * @param skipBlocks skip blocks or not
  * @param parentName the name of its parent node
  * @throws IOException
  */
private void processINode(DataInputStream in, ImageVisitor v,
    boolean skipBlocks, String parentName) throws IOException {
  v.visitEnclosingElement(ImageElement.INODE);
  String pathName = FSImageSerialization.readString(in);
  if (parentName != null) {  // local name
    pathName = "/" + pathName;
    if (!"/".equals(parentName)) { // children of non-root directory
      pathName = parentName + pathName;
    }
  }

  v.visit(ImageElement.INODE_PATH, pathName);
  v.visit(ImageElement.REPLICATION, in.readShort());
  v.visit(ImageElement.MODIFICATION_TIME, formatDate(in.readLong()));
  if(LayoutVersion.supports(Feature.FILE_ACCESS_TIME, imageVersion))
    v.visit(ImageElement.ACCESS_TIME, formatDate(in.readLong()));
  v.visit(ImageElement.BLOCK_SIZE, in.readLong());
  int numBlocks = in.readInt();

  processBlocks(in, v, numBlocks, skipBlocks);

  // File or directory
  if (numBlocks > 0 || numBlocks == -1) {
    v.visit(ImageElement.NS_QUOTA, numBlocks == -1 ? in.readLong() : -1);
    if (LayoutVersion.supports(Feature.DISKSPACE_QUOTA, imageVersion))
      v.visit(ImageElement.DS_QUOTA, numBlocks == -1 ? in.readLong() : -1);
  }
  if (numBlocks == -2) {
    v.visit(ImageElement.SYMLINK, Text.readString(in));
  }

  processPermission(in, v);
  v.leaveEnclosingElement(); // INode
}
 
Example #21
Source File: ImageLoaderCurrent.java    From hadoop with Apache License 2.0 5 votes vote down vote up
private void processFileDiffList(DataInputStream in, ImageVisitor v,
    String currentINodeName) throws IOException {
  final int size = in.readInt();
  if (size >= 0) {
    v.visitEnclosingElement(ImageElement.SNAPSHOT_FILE_DIFFS,
        ImageElement.NUM_SNAPSHOT_FILE_DIFF, size);
    for (int i = 0; i < size; i++) {
      processFileDiff(in, v, currentINodeName);
    }
    v.leaveEnclosingElement();
  }
}
 
Example #22
Source File: ImageLoaderCurrent.java    From hadoop with Apache License 2.0 5 votes vote down vote up
private void processINodeFileAttributes(DataInputStream in, ImageVisitor v,
    String parentName) throws IOException {
  final String pathName = readINodePath(in, parentName);
  v.visit(ImageElement.INODE_PATH, pathName);
  processPermission(in, v);
  v.visit(ImageElement.MODIFICATION_TIME, formatDate(in.readLong()));
  if(NameNodeLayoutVersion.supports(Feature.FILE_ACCESS_TIME, imageVersion)) {
    v.visit(ImageElement.ACCESS_TIME, formatDate(in.readLong()));
  }

  v.visit(ImageElement.REPLICATION, in.readShort());
  v.visit(ImageElement.BLOCK_SIZE, in.readLong());
}
 
Example #23
Source File: ImageLoaderCurrent.java    From hadoop with Apache License 2.0 5 votes vote down vote up
/**
 * Process the blocks section of the fsimage.
 *
 * @param in Datastream to process
 * @param v Visitor to walk over inodes
 * @param skipBlocks Walk over each block?
 */
private void processBlocks(DataInputStream in, ImageVisitor v,
    int numBlocks, boolean skipBlocks) throws IOException {
  v.visitEnclosingElement(ImageElement.BLOCKS,
                          ImageElement.NUM_BLOCKS, numBlocks);
  
  // directory or symlink or reference node, no blocks to process    
  if(numBlocks < 0) { 
    v.leaveEnclosingElement(); // Blocks
    return;
  }
  
  if(skipBlocks) {
    int bytesToSkip = ((Long.SIZE * 3 /* fields */) / 8 /*bits*/) * numBlocks;
    if(in.skipBytes(bytesToSkip) != bytesToSkip)
      throw new IOException("Error skipping over blocks");
    
  } else {
    for(int j = 0; j < numBlocks; j++) {
      v.visitEnclosingElement(ImageElement.BLOCK);
      v.visit(ImageElement.BLOCK_ID, in.readLong());
      v.visit(ImageElement.NUM_BYTES, in.readLong());
      v.visit(ImageElement.GENERATION_STAMP, in.readLong());
      v.leaveEnclosingElement(); // Block
    }
  }
  v.leaveEnclosingElement(); // Blocks
}
 
Example #24
Source File: ImageLoaderCurrent.java    From hadoop with Apache License 2.0 5 votes vote down vote up
/**
 * Extract the INode permissions stored in the fsimage file.
 *
 * @param in Datastream to process
 * @param v Visitor to walk over inodes
 */
private void processPermission(DataInputStream in, ImageVisitor v)
    throws IOException {
  v.visitEnclosingElement(ImageElement.PERMISSIONS);
  v.visit(ImageElement.USER_NAME, Text.readString(in));
  v.visit(ImageElement.GROUP_NAME, Text.readString(in));
  FsPermission fsp = new FsPermission(in.readShort());
  v.visit(ImageElement.PERMISSION_STRING, fsp.toString());
  v.leaveEnclosingElement(); // Permissions
}
 
Example #25
Source File: ImageLoaderCurrent.java    From hadoop with Apache License 2.0 5 votes vote down vote up
private void processINodeDirectoryAttributes(DataInputStream in, ImageVisitor v,
    String parentName) throws IOException {
  final String pathName = readINodePath(in, parentName);
  v.visit(ImageElement.INODE_PATH, pathName);
  processPermission(in, v);
  v.visit(ImageElement.MODIFICATION_TIME, formatDate(in.readLong()));

  v.visit(ImageElement.NS_QUOTA, in.readLong());
  v.visit(ImageElement.DS_QUOTA, in.readLong());
}
 
Example #26
Source File: ImageLoaderCurrent.java    From big-c with Apache License 2.0 5 votes vote down vote up
/**
 * Extract the INode permissions stored in the fsimage file.
 *
 * @param in Datastream to process
 * @param v Visitor to walk over inodes
 */
private void processPermission(DataInputStream in, ImageVisitor v)
    throws IOException {
  v.visitEnclosingElement(ImageElement.PERMISSIONS);
  v.visit(ImageElement.USER_NAME, Text.readString(in));
  v.visit(ImageElement.GROUP_NAME, Text.readString(in));
  FsPermission fsp = new FsPermission(in.readShort());
  v.visit(ImageElement.PERMISSION_STRING, fsp.toString());
  v.leaveEnclosingElement(); // Permissions
}
 
Example #27
Source File: ImageLoaderCurrent.java    From hadoop with Apache License 2.0 5 votes vote down vote up
private void processDirectoryDiffList(DataInputStream in, ImageVisitor v,
    String currentINodeName) throws IOException {
  final int numDirDiff = in.readInt();
  if (numDirDiff >= 0) {
    v.visitEnclosingElement(ImageElement.SNAPSHOT_DIR_DIFFS,
        ImageElement.NUM_SNAPSHOT_DIR_DIFF, numDirDiff);
    for (int i = 0; i < numDirDiff; i++) {
      // process directory diffs in reverse chronological oder
      processDirectoryDiff(in, v, currentINodeName); 
    }
    v.leaveEnclosingElement();
  }
}
 
Example #28
Source File: ImageLoaderCurrent.java    From hadoop with Apache License 2.0 5 votes vote down vote up
private void processSnapshot(DataInputStream in, ImageVisitor v)
    throws IOException {
  v.visitEnclosingElement(ImageElement.SNAPSHOT);
  v.visit(ImageElement.SNAPSHOT_ID, in.readInt());
  // process root of snapshot
  v.visitEnclosingElement(ImageElement.SNAPSHOT_ROOT);
  processINode(in, v, true, "", false);
  v.leaveEnclosingElement();
  v.leaveEnclosingElement();
}
 
Example #29
Source File: ImageLoaderCurrent.java    From hadoop with Apache License 2.0 5 votes vote down vote up
/**
 * Extract CachePool permissions stored in the fsimage file.
 *
 * @param in Datastream to process
 * @param v Visitor to walk over inodes
 */
private void processCachePoolPermission(DataInputStream in, ImageVisitor v)
    throws IOException {
  v.visitEnclosingElement(ImageElement.PERMISSIONS);
  v.visit(ImageElement.CACHE_POOL_OWNER_NAME, Text.readString(in));
  v.visit(ImageElement.CACHE_POOL_GROUP_NAME, Text.readString(in));
  FsPermission fsp = new FsPermission(in.readShort());
  v.visit(ImageElement.CACHE_POOL_PERMISSION_STRING, fsp.toString());
  v.leaveEnclosingElement(); // Permissions
}
 
Example #30
Source File: ImageLoaderCurrent.java    From hadoop with Apache License 2.0 4 votes vote down vote up
private void processDirectoryDiff(DataInputStream in, ImageVisitor v,
    String currentINodeName) throws IOException {
  v.visitEnclosingElement(ImageElement.SNAPSHOT_DIR_DIFF);
  int snapshotId = in.readInt();
  v.visit(ImageElement.SNAPSHOT_DIFF_SNAPSHOTID, snapshotId);
  v.visit(ImageElement.SNAPSHOT_DIR_DIFF_CHILDREN_SIZE, in.readInt());
  
  // process snapshotINode
  boolean useRoot = in.readBoolean();
  if (!useRoot) {
    if (in.readBoolean()) {
      v.visitEnclosingElement(ImageElement.SNAPSHOT_INODE_DIRECTORY_ATTRIBUTES);
      if (NameNodeLayoutVersion.supports(Feature.OPTIMIZE_SNAPSHOT_INODES, imageVersion)) {
        processINodeDirectoryAttributes(in, v, currentINodeName);
      } else {
        processINode(in, v, true, currentINodeName, true);
      }
      v.leaveEnclosingElement();
    }
  }
  
  // process createdList
  int createdSize = in.readInt();
  v.visitEnclosingElement(ImageElement.SNAPSHOT_DIR_DIFF_CREATEDLIST,
      ImageElement.SNAPSHOT_DIR_DIFF_CREATEDLIST_SIZE, createdSize);
  for (int i = 0; i < createdSize; i++) {
    String createdNode = FSImageSerialization.readString(in);
    v.visit(ImageElement.SNAPSHOT_DIR_DIFF_CREATED_INODE, createdNode);
  }
  v.leaveEnclosingElement();
  
  // process deletedList
  int deletedSize = in.readInt();
  v.visitEnclosingElement(ImageElement.SNAPSHOT_DIR_DIFF_DELETEDLIST,
      ImageElement.SNAPSHOT_DIR_DIFF_DELETEDLIST_SIZE, deletedSize);
  for (int i = 0; i < deletedSize; i++) {
    v.visitEnclosingElement(ImageElement.SNAPSHOT_DIR_DIFF_DELETED_INODE);
    processINode(in, v, false, currentINodeName, true);
    v.leaveEnclosingElement();
  }
  v.leaveEnclosingElement();
  v.leaveEnclosingElement();
}