Java Code Examples for org.apache.hadoop.hdfs.server.namenode.FSImageSerialization#readString()
The following examples show how to use
org.apache.hadoop.hdfs.server.namenode.FSImageSerialization#readString() .
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 | 5 votes |
private String readINodePath(DataInputStream in, String parentName) throws IOException { String pathName = FSImageSerialization.readString(in); if (parentName != null) { // local name pathName = "/" + pathName; if (!"/".equals(parentName)) { // children of non-root directory pathName = parentName + pathName; } } return pathName; }
Example 2
Source File: ImageLoaderCurrent.java From big-c with Apache License 2.0 | 5 votes |
private String readINodePath(DataInputStream in, String parentName) throws IOException { String pathName = FSImageSerialization.readString(in); if (parentName != null) { // local name pathName = "/" + pathName; if (!"/".equals(parentName)) { // children of non-root directory pathName = parentName + pathName; } } return pathName; }
Example 3
Source File: ImageLoaderCurrent.java From RDFS with Apache License 2.0 | 5 votes |
private int processDirectory(DataInputStream in, ImageVisitor v, boolean skipBlocks) throws IOException { String parentName = FSImageSerialization.readString(in); int numChildren = in.readInt(); for (int i=0; i<numChildren; i++) { processINode(in, v, skipBlocks, parentName); } return numChildren; }
Example 4
Source File: ImageLoaderCurrent.java From RDFS with Apache License 2.0 | 5 votes |
/** * 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 5
Source File: ImageLoaderCurrent.java From hadoop with Apache License 2.0 | 4 votes |
/** * 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 6
Source File: ImageLoaderCurrent.java From hadoop with Apache License 2.0 | 4 votes |
private int processDirectory(DataInputStream in, ImageVisitor v, boolean skipBlocks) throws IOException { String parentName = FSImageSerialization.readString(in); return processChildren(in, v, skipBlocks, parentName); }
Example 7
Source File: ImageLoaderCurrent.java From hadoop with Apache License 2.0 | 4 votes |
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(); }
Example 8
Source File: ImageLoaderCurrent.java From big-c with Apache License 2.0 | 4 votes |
/** * 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 9
Source File: ImageLoaderCurrent.java From big-c with Apache License 2.0 | 4 votes |
private int processDirectory(DataInputStream in, ImageVisitor v, boolean skipBlocks) throws IOException { String parentName = FSImageSerialization.readString(in); return processChildren(in, v, skipBlocks, parentName); }
Example 10
Source File: ImageLoaderCurrent.java From big-c with Apache License 2.0 | 4 votes |
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(); }
Example 11
Source File: ImageLoaderCurrent.java From RDFS with Apache License 2.0 | 4 votes |
/** * 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 }