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

The following examples show how to use org.apache.hadoop.hdfs.tools.offlineImageViewer.ImageVisitor.ImageElement. These examples are extracted from open source projects. 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 Project: hadoop   Source File: ImageLoaderCurrent.java    License: 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 Project: hadoop   Source File: ImageLoaderCurrent.java    License: 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 Project: hadoop   Source File: ImageLoaderCurrent.java    License: 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 4
Source Project: hadoop   Source File: ImageLoaderCurrent.java    License: 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 Project: big-c   Source File: ImageLoaderCurrent.java    License: 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 6
Source Project: big-c   Source File: ImageLoaderCurrent.java    License: 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 7
Source Project: big-c   Source File: ImageLoaderCurrent.java    License: 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 8
Source Project: big-c   Source File: ImageLoaderCurrent.java    License: 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 9
Source Project: hadoop   Source File: ImageLoaderCurrent.java    License: 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 10
Source Project: hadoop   Source File: ImageLoaderCurrent.java    License: 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 11
Source Project: hadoop   Source File: ImageLoaderCurrent.java    License: 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 12
Source Project: hadoop   Source File: ImageLoaderCurrent.java    License: 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 13
Source Project: hadoop   Source File: ImageLoaderCurrent.java    License: 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 14
Source Project: hadoop   Source File: ImageLoaderCurrent.java    License: 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 15
Source Project: hadoop   Source File: ImageLoaderCurrent.java    License: 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 16
Source Project: hadoop   Source File: ImageLoaderCurrent.java    License: 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 17
Source Project: big-c   Source File: ImageLoaderCurrent.java    License: 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 18
Source Project: big-c   Source File: ImageLoaderCurrent.java    License: 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 Project: big-c   Source File: ImageLoaderCurrent.java    License: 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 20
Source Project: big-c   Source File: ImageLoaderCurrent.java    License: 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 21
Source Project: big-c   Source File: ImageLoaderCurrent.java    License: 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 22
Source Project: big-c   Source File: ImageLoaderCurrent.java    License: 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 23
Source Project: big-c   Source File: ImageLoaderCurrent.java    License: 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 24
Source Project: big-c   Source File: ImageLoaderCurrent.java    License: 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 25
Source Project: RDFS   Source File: TestDelimitedImageVisitor.java    License: 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 26
Source Project: RDFS   Source File: ImageLoaderCurrent.java    License: 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 27
Source Project: RDFS   Source File: ImageLoaderCurrent.java    License: 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 28
Source Project: RDFS   Source File: ImageLoaderCurrent.java    License: 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 29
Source Project: RDFS   Source File: ImageLoaderCurrent.java    License: 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 30
Source Project: hadoop   Source File: ImageLoaderCurrent.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Process the Delegation Token related section in fsimage.
 * 
 * @param in DataInputStream to process
 * @param v Visitor to walk over records
 */
private void processDelegationTokens(DataInputStream in, ImageVisitor v)
    throws IOException {
  v.visit(ImageElement.CURRENT_DELEGATION_KEY_ID, in.readInt());
  int numDKeys = in.readInt();
  v.visitEnclosingElement(ImageElement.DELEGATION_KEYS,
      ImageElement.NUM_DELEGATION_KEYS, numDKeys);
  for(int i =0; i < numDKeys; i++) {
    DelegationKey key = new DelegationKey();
    key.readFields(in);
    v.visit(ImageElement.DELEGATION_KEY, key.toString());
  }
  v.leaveEnclosingElement();
  v.visit(ImageElement.DELEGATION_TOKEN_SEQUENCE_NUMBER, in.readInt());
  int numDTokens = in.readInt();
  v.visitEnclosingElement(ImageElement.DELEGATION_TOKENS,
      ImageElement.NUM_DELEGATION_TOKENS, numDTokens);
  for(int i=0; i<numDTokens; i++){
    DelegationTokenIdentifier id = new  DelegationTokenIdentifier();
    id.readFields(in);
    long expiryTime = in.readLong();
    v.visitEnclosingElement(ImageElement.DELEGATION_TOKEN_IDENTIFIER);
    v.visit(ImageElement.DELEGATION_TOKEN_IDENTIFIER_KIND,
        id.getKind().toString());
    v.visit(ImageElement.DELEGATION_TOKEN_IDENTIFIER_SEQNO,
        id.getSequenceNumber());
    v.visit(ImageElement.DELEGATION_TOKEN_IDENTIFIER_OWNER,
        id.getOwner().toString());
    v.visit(ImageElement.DELEGATION_TOKEN_IDENTIFIER_RENEWER,
        id.getRenewer().toString());
    v.visit(ImageElement.DELEGATION_TOKEN_IDENTIFIER_REALUSER,
        id.getRealUser().toString());
    v.visit(ImageElement.DELEGATION_TOKEN_IDENTIFIER_ISSUE_DATE,
        id.getIssueDate());
    v.visit(ImageElement.DELEGATION_TOKEN_IDENTIFIER_MAX_DATE,
        id.getMaxDate());
    v.visit(ImageElement.DELEGATION_TOKEN_IDENTIFIER_EXPIRY_TIME,
        expiryTime);
    v.visit(ImageElement.DELEGATION_TOKEN_IDENTIFIER_MASTER_KEY_ID,
        id.getMasterKeyId());
    v.leaveEnclosingElement(); // DELEGATION_TOKEN_IDENTIFIER
  }
  v.leaveEnclosingElement(); // DELEGATION_TOKENS
}