コード例 #1
0
ファイル: FSDirectory.java プロジェクト: bruthe/hadoop-0.1r
  /** Save the contents of the FS image */
  void saveFSImage(File fullimage, File edits) throws IOException {
    File curFile = new File(fullimage, FS_IMAGE);
    File newFile = new File(fullimage, NEW_FS_IMAGE);
    File oldFile = new File(fullimage, OLD_FS_IMAGE);

    //
    // Write out data
    //
    DataOutputStream out =
        new DataOutputStream(new BufferedOutputStream(new FileOutputStream(newFile)));
    try {
      out.writeInt(rootDir.numItemsInTree() - 1);
      rootDir.saveImage("", out);
    } finally {
      out.close();
    }

    //
    // Atomic move sequence
    //
    // 1.  Move cur to old
    curFile.renameTo(oldFile);

    // 2.  Move new to cur
    newFile.renameTo(curFile);

    // 3.  Remove pending-edits file (it's been integrated with newFile)
    edits.delete();

    // 4.  Delete old
    oldFile.delete();
  }
コード例 #2
0
ファイル: FSDirectory.java プロジェクト: bruthe/hadoop-0.1r
 void saveImage(String parentPrefix, DataOutputStream out) throws IOException {
   String fullName = "";
   if (parent != null) {
     fullName = parentPrefix + "/" + name;
     new UTF8(fullName).write(out);
     if (blocks == null) {
       out.writeInt(0);
     } else {
       out.writeInt(blocks.length);
       for (int i = 0; i < blocks.length; i++) {
         blocks[i].write(out);
       }
     }
   }
   for (Iterator it = children.values().iterator(); it.hasNext(); ) {
     INode child = (INode) it.next();
     child.saveImage(fullName, out);
   }
 }
コード例 #3
0
ファイル: FSDirectory.java プロジェクト: bruthe/hadoop-0.1r
 /** Write an operation to the edit log */
 void logEdit(byte op, Writable w1, Writable w2) {
   synchronized (editlog) {
     try {
       editlog.write(op);
       if (w1 != null) {
         w1.write(editlog);
       }
       if (w2 != null) {
         w2.write(editlog);
       }
     } catch (IOException ie) {
     }
   }
 }
コード例 #4
0
ファイル: FSDirectory.java プロジェクト: bruthe/hadoop-0.1r
 /** Shutdown the filestore */
 public void close() throws IOException {
   editlog.close();
 }