Java Code Examples for org.apache.hadoop.hdfs.protocol.Block#write()

The following examples show how to use org.apache.hadoop.hdfs.protocol.Block#write() . 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: FSImageSerialization.java    From hadoop with Apache License 2.0 5 votes vote down vote up
private static void writeBlocks(final Block[] blocks,
    final DataOutput out) throws IOException {
  if (blocks == null) {
    out.writeInt(0);
  } else {
    out.writeInt(blocks.length);
    for (Block blk : blocks) {
      blk.write(out);
    }
  }
}
 
Example 2
Source File: FSImageSerialization.java    From big-c with Apache License 2.0 5 votes vote down vote up
private static void writeBlocks(final Block[] blocks,
    final DataOutput out) throws IOException {
  if (blocks == null) {
    out.writeInt(0);
  } else {
    out.writeInt(blocks.length);
    for (Block blk : blocks) {
      blk.write(out);
    }
  }
}
 
Example 3
Source File: FSImageSerialization.java    From RDFS with Apache License 2.0 5 votes vote down vote up
static void saveINode2Image(INode node,
                                    DataOutputStream out) throws IOException {
  byte[] name = node.getLocalNameBytes();
  out.writeShort(name.length);
  out.write(name);
  FsPermission filePerm = TL_DATA.get().FILE_PERM;
  if (!node.isDirectory()) {  // write file inode
    INodeFile fileINode = (INodeFile)node;
    out.writeShort(fileINode.getReplication());
    out.writeLong(fileINode.getModificationTime());
    out.writeLong(fileINode.getAccessTime());
    out.writeLong(fileINode.getPreferredBlockSize());
    Block[] blocks = fileINode.getBlocks();
    out.writeInt(blocks.length);
    for (Block blk : blocks)
      blk.write(out);
    filePerm.fromShort(fileINode.getFsPermissionShort());
    PermissionStatus.write(out, fileINode.getUserName(),
                           fileINode.getGroupName(),
                           filePerm);
  } else {   // write directory inode
    out.writeShort(0);  // replication
    out.writeLong(node.getModificationTime());
    out.writeLong(0);   // access time
    out.writeLong(0);   // preferred block size
    out.writeInt(-1);    // # of blocks
    out.writeLong(node.getNsQuota());
    out.writeLong(node.getDsQuota());
    filePerm.fromShort(node.getFsPermissionShort());
    PermissionStatus.write(out, node.getUserName(),
                           node.getGroupName(),
                           filePerm);
  }
}
 
Example 4
Source File: FSImage.java    From hadoop-gpu with Apache License 2.0 5 votes vote down vote up
private static void saveINode2Image(ByteBuffer name,
                                    INode node,
                                    DataOutputStream out) throws IOException {
  int nameLen = name.position();
  out.writeShort(nameLen);
  out.write(name.array(), name.arrayOffset(), nameLen);
  if (!node.isDirectory()) {  // write file inode
    INodeFile fileINode = (INodeFile)node;
    out.writeShort(fileINode.getReplication());
    out.writeLong(fileINode.getModificationTime());
    out.writeLong(fileINode.getAccessTime());
    out.writeLong(fileINode.getPreferredBlockSize());
    Block[] blocks = fileINode.getBlocks();
    out.writeInt(blocks.length);
    for (Block blk : blocks)
      blk.write(out);
    FILE_PERM.fromShort(fileINode.getFsPermissionShort());
    PermissionStatus.write(out, fileINode.getUserName(),
                           fileINode.getGroupName(),
                           FILE_PERM);
  } else {   // write directory inode
    out.writeShort(0);  // replication
    out.writeLong(node.getModificationTime());
    out.writeLong(0);   // access time
    out.writeLong(0);   // preferred block size
    out.writeInt(-1);    // # of blocks
    out.writeLong(node.getNsQuota());
    out.writeLong(node.getDsQuota());
    FILE_PERM.fromShort(node.getFsPermissionShort());
    PermissionStatus.write(out, node.getUserName(),
                           node.getGroupName(),
                           FILE_PERM);
  }
}