Java 类org.apache.hadoop.hdfs.server.namenode.FSImage.NameNodeDirType 实例源码

项目:hadoop-on-lustre    文件:TestStorageRestore.java   
/**
 * test
 */
public void printStorages(FSImage fs) {
  LOG.info("current storages and corresoponding sizes:");
  for (Iterator<StorageDirectory> it = fs.dirIterator(); it.hasNext();) {
    StorageDirectory sd = it.next();

    if (sd.getStorageDirType().isOfType(NameNodeDirType.IMAGE)) {
      File imf = FSImage.getImageFile(sd, NameNodeFile.IMAGE);
      LOG.info("  image file " + imf.getAbsolutePath() + "; len = "
          + imf.length());
    }
    if (sd.getStorageDirType().isOfType(NameNodeDirType.EDITS)) {
      File edf = FSImage.getImageFile(sd, NameNodeFile.EDITS);
      LOG.info("  edits file " + edf.getAbsolutePath() + "; len = "
          + edf.length());
    }
  }
}
项目:hadoop-on-lustre    文件:TestStartup.java   
/**
 * verify that edits log and fsimage are in different directories and of a correct size
 */
private void verifyDifferentDirs(FSImage img, long expectedImgSize, long expectedEditsSize) {
  StorageDirectory sd =null;
  for (Iterator<StorageDirectory> it = img.dirIterator(); it.hasNext();) {
    sd = it.next();

    if(sd.getStorageDirType().isOfType(NameNodeDirType.IMAGE)) {
      File imf = FSImage.getImageFile(sd, NameNodeFile.IMAGE);
      LOG.info("--image file " + imf.getAbsolutePath() + "; len = " + imf.length() + "; expected = " + expectedImgSize);
      assertEquals(expectedImgSize, imf.length());  
    } else if(sd.getStorageDirType().isOfType(NameNodeDirType.EDITS)) {
      File edf = FSImage.getImageFile(sd, NameNodeFile.EDITS);
      LOG.info("-- edits file " + edf.getAbsolutePath() + "; len = " + edf.length()  + "; expected = " + expectedEditsSize);
      assertEquals(expectedEditsSize, edf.length());    
    } else {
      fail("Image/Edits directories are not different");
    }
  }

}
项目:hadoop-on-lustre    文件:FSEditLog.java   
/**
 * Create empty edit log files.
 * Initialize the output stream for logging.
 * 
 * @throws IOException
 */
public synchronized void open() throws IOException {
  numTransactions = totalTimeTransactions = numTransactionsBatchedInSync = 0;
  if (editStreams == null) {
    editStreams = new ArrayList<EditLogOutputStream>();
  }
  Iterator<StorageDirectory> it = fsimage.dirIterator(NameNodeDirType.EDITS); 
  while (it.hasNext()) {
    StorageDirectory sd = it.next();
    File eFile = getEditFile(sd);
    try {
      EditLogOutputStream eStream = new EditLogFileOutputStream(eFile);
      editStreams.add(eStream);
    } catch (IOException ioe) {
      fsimage.updateRemovedDirs(sd, ioe);
      it.remove();
    }
  }
  exitIfNoStreams();
}
项目:hadoop-on-lustre    文件:FSEditLog.java   
/**
 * Remove all edits streams for the given storage directory.
 */
synchronized void removeEditsForStorageDir(StorageDirectory sd) {
  exitIfStreamsNotSet();

  if (!sd.getStorageDirType().isOfType(NameNodeDirType.EDITS)) {
    return;
  }
  for (int idx = 0; idx < editStreams.size(); idx++) {
    File parentDir = getStorageDirForStream(idx);
    if (parentDir.getAbsolutePath().equals(
          sd.getRoot().getAbsolutePath())) {
      editStreams.remove(idx);
      idx--;
    }
  }
  exitIfNoStreams();
}
项目:cumulus    文件:SecondaryNameNode.java   
/**
 * Merge image and edits, and verify consistency with the signature.
 */
private void doMerge(CheckpointSignature sig) throws IOException {
  getEditLog().open();
  StorageDirectory sdName = null;
  StorageDirectory sdEdits = null;
  Iterator<StorageDirectory> it = null;
  it = dirIterator(NameNodeDirType.IMAGE);
  if (it.hasNext())
    sdName = it.next();
  it = dirIterator(NameNodeDirType.EDITS);
  if (it.hasNext())
    sdEdits = it.next();
  if ((sdName == null) || (sdEdits == null))
    throw new IOException("Could not locate checkpoint directories");
  this.layoutVersion = -1; // to avoid assert in loadFSImage()
  loadFSImage(FSImage.getImageFile(sdName, NameNodeFile.IMAGE));
  loadFSEdits(sdEdits);
  sig.validateStorageInfo(this);
  saveNamespace(false);
}
项目:cumulus    文件:FSEditLog.java   
/**
 * Closes the current edit log and opens edits.new. 
 */
synchronized void rollEditLog() throws IOException {
  waitForSyncToFinish();
  Iterator<StorageDirectory> it = fsimage.dirIterator(NameNodeDirType.EDITS);
  if(!it.hasNext()) 
    return;
  //
  // If edits.new already exists in some directory, verify it
  // exists in all directories.
  //
  boolean alreadyExists = existsNew(it.next());
  while(it.hasNext()) {
    StorageDirectory sd = it.next();
    if(alreadyExists != existsNew(sd))
      throw new IOException(getEditNewFile(sd) 
            + "should " + (alreadyExists ? "" : "not ") + "exist.");
  }
  if(alreadyExists)
    return; // nothing to do, edits.new exists!

  // check if any of failed storage is now available and put it back
  fsimage.attemptRestoreRemovedStorage();

  divertFileStreams(
      Storage.STORAGE_DIR_CURRENT + "/" + NameNodeFile.EDITS_NEW.getName());
}
项目:cumulus    文件:TestStorageRestore.java   
/**
 * test
 */
public void printStorages(FSImage fs) {
  LOG.info("current storages and corresoponding sizes:");
  for(Iterator<StorageDirectory> it = fs.dirIterator(); it.hasNext(); ) {
    StorageDirectory sd = it.next();

    if(sd.getStorageDirType().isOfType(NameNodeDirType.IMAGE)) {
      File imf = FSImage.getImageFile(sd, NameNodeFile.IMAGE);
      LOG.info("  image file " + imf.getAbsolutePath() + "; len = " + imf.length());  
    }
    if(sd.getStorageDirType().isOfType(NameNodeDirType.EDITS)) {
      File edf = FSImage.getImageFile(sd, NameNodeFile.EDITS);
      LOG.info("  edits file " + edf.getAbsolutePath() + "; len = " + edf.length()); 
    }
  }
}
项目:cumulus    文件:TestStartup.java   
/**
 * verify that edits log and fsimage are in different directories and of a correct size
 */
private void verifyDifferentDirs(FSImage img, long expectedImgSize, long expectedEditsSize) {
  StorageDirectory sd =null;
  for (Iterator<StorageDirectory> it = img.dirIterator(); it.hasNext();) {
    sd = it.next();

    if(sd.getStorageDirType().isOfType(NameNodeDirType.IMAGE)) {
      File imf = FSImage.getImageFile(sd, NameNodeFile.IMAGE);
      LOG.info("--image file " + imf.getAbsolutePath() + "; len = " + imf.length() + "; expected = " + expectedImgSize);
      assertEquals(expectedImgSize, imf.length());  
    } else if(sd.getStorageDirType().isOfType(NameNodeDirType.EDITS)) {
      File edf = FSImage.getImageFile(sd, NameNodeFile.EDITS);
      LOG.info("-- edits file " + edf.getAbsolutePath() + "; len = " + edf.length()  + "; expected = " + expectedEditsSize);
      assertEquals(expectedEditsSize, edf.length());    
    } else {
      fail("Image/Edits directories are not different");
    }
  }

}
项目:RDFS    文件:TestStorageRestore.java   
/**
 * test
 */
public void printStorages(FSImage fs) {
  LOG.info("current storages and corresoponding sizes:");
  for(Iterator<StorageDirectory> it = fs.dirIterator(); it.hasNext(); ) {
    StorageDirectory sd = it.next();

    if(sd.getStorageDirType().isOfType(NameNodeDirType.IMAGE)) {
      File imf = FSImage.getImageFile(sd, NameNodeFile.IMAGE);
      LOG.info("  image file " + imf.getAbsolutePath() + "; len = " + imf.length());  
    }
    if(sd.getStorageDirType().isOfType(NameNodeDirType.EDITS)) {
      File edf = FSImage.getImageFile(sd, NameNodeFile.EDITS);
      LOG.info("  edits file " + edf.getAbsolutePath() + "; len = " + edf.length()); 
    }
  }
}
项目:RDFS    文件:TestStartup.java   
/**
 * verify that edits log and fsimage are in different directories and of a correct size
 */
private void verifyDifferentDirs(FSImage img, long expectedImgSize, long expectedEditsSize) {
  StorageDirectory sd =null;
  for (Iterator<StorageDirectory> it = img.dirIterator(); it.hasNext();) {
    sd = it.next();

    if(sd.getStorageDirType().isOfType(NameNodeDirType.IMAGE)) {
      File imf = FSImage.getImageFile(sd, NameNodeFile.IMAGE);
      LOG.info("--image file " + imf.getAbsolutePath() + "; len = " + imf.length() + "; expected = " + expectedImgSize);
      assertEquals(expectedImgSize, imf.length());  
    } else if(sd.getStorageDirType().isOfType(NameNodeDirType.EDITS)) {
      File edf = FSImage.getImageFile(sd, NameNodeFile.EDITS);
      LOG.info("-- edits file " + edf.getAbsolutePath() + "; len = " + edf.length()  + "; expected = " + expectedEditsSize);
      assertEquals(expectedEditsSize, edf.length());    
    } else {
      fail("Image/Edits directories are not different");
    }
  }

}
项目:RDFS    文件:FSEditLog.java   
/**
 * Create empty edit log files.
 * Initialize the output stream for logging.
 * 
 * @throws IOException
 */
public synchronized void open() throws IOException {
  if (syncer == null) {
    syncer = new SyncThread();
    syncThread = new Thread(syncer);
    syncThread.start();
  }
  numTransactions = totalTimeTransactions = numTransactionsBatchedInSync = 0;
  if (editStreams == null)
    editStreams = new ArrayList<EditLogOutputStream>();
  for (Iterator<StorageDirectory> it = 
         fsimage.dirIterator(NameNodeDirType.EDITS); it.hasNext();) {
    StorageDirectory sd = it.next();
    File eFile = getEditFile(sd);
    try {
      EditLogOutputStream eStream = new EditLogFileOutputStream(eFile, metrics);
      editStreams.add(eStream);
    } catch (IOException e) {
      FSNamesystem.LOG.warn("Unable to open edit log file " + eFile);
      // Remove the directory from list of storage directories
      fsimage.removedStorageDirs.add(sd);
      it.remove();
    }
  }
}
项目:RDFS    文件:FSEditLog.java   
/**
  * If there is an IO Error on any log operations on storage directory,
  * remove any stream associated with that directory 
  */
 synchronized void processIOError(StorageDirectory sd) {
   // Try to remove stream only if one should exist
   if (!sd.getStorageDirType().isOfType(NameNodeDirType.EDITS))
     return;
   if (editStreams == null || editStreams.size() <= 1) {
     FSNamesystem.LOG.fatal(
         "Fatal Error : All storage directories are inaccessible."); 
     Runtime.getRuntime().exit(-1);
   }
   for (int idx = 0; idx < editStreams.size(); idx++) {
     File parentStorageDir = ((EditLogFileOutputStream)editStreams
                                      .get(idx)).getFile()
                                      .getParentFile().getParentFile();
     if (parentStorageDir.getName().equals(sd.getRoot().getName()))
       editStreams.remove(idx);
}
 }
项目:hadoop-0.20    文件:TestStartup.java   
/**
 * verify that edits log and fsimage are in different directories and of a correct size
 */
private void verifyDifferentDirs(FSImage img, long expectedImgSize, long expectedEditsSize) {
  StorageDirectory sd =null;
  for (Iterator<StorageDirectory> it = img.dirIterator(); it.hasNext();) {
    sd = it.next();

    if(sd.getStorageDirType().isOfType(NameNodeDirType.IMAGE)) {
      File imf = FSImage.getImageFile(sd, NameNodeFile.IMAGE);
      LOG.info("--image file " + imf.getAbsolutePath() + "; len = " + imf.length() + "; expected = " + expectedImgSize);
      assertEquals(expectedImgSize, imf.length());  
    } else if(sd.getStorageDirType().isOfType(NameNodeDirType.EDITS)) {
      File edf = FSImage.getImageFile(sd, NameNodeFile.EDITS);
      LOG.info("-- edits file " + edf.getAbsolutePath() + "; len = " + edf.length()  + "; expected = " + expectedEditsSize);
      assertEquals(expectedEditsSize, edf.length());    
    } else {
      fail("Image/Edits directories are not different");
    }
  }

}
项目:hadoop-0.20    文件:FSEditLog.java   
/**
 * Create empty edit log files.
 * Initialize the output stream for logging.
 * 
 * @throws IOException
 */
public synchronized void open() throws IOException {
  numTransactions = totalTimeTransactions = numTransactionsBatchedInSync = 0;
  if (editStreams == null)
    editStreams = new ArrayList<EditLogOutputStream>();
  for (Iterator<StorageDirectory> it = 
         fsimage.dirIterator(NameNodeDirType.EDITS); it.hasNext();) {
    StorageDirectory sd = it.next();
    File eFile = getEditFile(sd);
    try {
      EditLogOutputStream eStream = new EditLogFileOutputStream(eFile);
      editStreams.add(eStream);
    } catch (IOException e) {
      FSNamesystem.LOG.warn("Unable to open edit log file " + eFile);
      // Remove the directory from list of storage directories
      it.remove();
    }
  }
}
项目:hadoop-0.20    文件:FSEditLog.java   
/**
  * If there is an IO Error on any log operations on storage directory,
  * remove any stream associated with that directory 
  */
 synchronized void processIOError(StorageDirectory sd) {
   // Try to remove stream only if one should exist
   if (!sd.getStorageDirType().isOfType(NameNodeDirType.EDITS))
     return;
   if (editStreams == null || editStreams.size() <= 1) {
     FSNamesystem.LOG.fatal(
         "Fatal Error : All storage directories are inaccessible."); 
     Runtime.getRuntime().exit(-1);
   }
   for (int idx = 0; idx < editStreams.size(); idx++) {
     File parentStorageDir = ((EditLogFileOutputStream)editStreams
                                      .get(idx)).getFile()
                                      .getParentFile().getParentFile();
     if (parentStorageDir.getName().equals(sd.getRoot().getName()))
       editStreams.remove(idx);
}
 }
项目:hortonworks-extension    文件:TestStorageRestore.java   
/**
 * test
 */
public void printStorages(FSImage fs) {
  LOG.info("current storages and corresoponding sizes:");
  for (Iterator<StorageDirectory> it = fs.dirIterator(); it.hasNext();) {
    StorageDirectory sd = it.next();

    if (sd.getStorageDirType().isOfType(NameNodeDirType.IMAGE)) {
      File imf = FSImage.getImageFile(sd, NameNodeFile.IMAGE);
      LOG.info("  image file " + imf.getAbsolutePath() + "; len = "
          + imf.length());
    }
    if (sd.getStorageDirType().isOfType(NameNodeDirType.EDITS)) {
      File edf = FSImage.getImageFile(sd, NameNodeFile.EDITS);
      LOG.info("  edits file " + edf.getAbsolutePath() + "; len = "
          + edf.length());
    }
  }
}
项目:hortonworks-extension    文件:TestStartup.java   
/**
 * verify that edits log and fsimage are in different directories and of a correct size
 */
private void verifyDifferentDirs(FSImage img, long expectedImgSize, long expectedEditsSize) {
  StorageDirectory sd =null;
  for (Iterator<StorageDirectory> it = img.dirIterator(); it.hasNext();) {
    sd = it.next();

    if(sd.getStorageDirType().isOfType(NameNodeDirType.IMAGE)) {
      File imf = FSImage.getImageFile(sd, NameNodeFile.IMAGE);
      LOG.info("--image file " + imf.getAbsolutePath() + "; len = " + imf.length() + "; expected = " + expectedImgSize);
      assertEquals(expectedImgSize, imf.length());  
    } else if(sd.getStorageDirType().isOfType(NameNodeDirType.EDITS)) {
      File edf = FSImage.getImageFile(sd, NameNodeFile.EDITS);
      LOG.info("-- edits file " + edf.getAbsolutePath() + "; len = " + edf.length()  + "; expected = " + expectedEditsSize);
      assertEquals(expectedEditsSize, edf.length());    
    } else {
      fail("Image/Edits directories are not different");
    }
  }

}
项目:hortonworks-extension    文件:FSEditLog.java   
/**
 * Create empty edit log files.
 * Initialize the output stream for logging.
 * 
 * @throws IOException
 */
public synchronized void open() throws IOException {
  numTransactions = totalTimeTransactions = numTransactionsBatchedInSync = 0;
  if (editStreams == null) {
    editStreams = new ArrayList<EditLogOutputStream>();
  }
  Iterator<StorageDirectory> it = fsimage.dirIterator(NameNodeDirType.EDITS); 
  while (it.hasNext()) {
    StorageDirectory sd = it.next();
    File eFile = getEditFile(sd);
    try {
      EditLogOutputStream eStream = new EditLogFileOutputStream(eFile);
      editStreams.add(eStream);
    } catch (IOException ioe) {
      fsimage.updateRemovedDirs(sd, ioe);
      it.remove();
    }
  }
  exitIfNoStreams();
}
项目:hortonworks-extension    文件:FSEditLog.java   
/**
 * Remove all edits streams for the given storage directory.
 */
synchronized void removeEditsForStorageDir(StorageDirectory sd) {
  exitIfStreamsNotSet();

  if (!sd.getStorageDirType().isOfType(NameNodeDirType.EDITS)) {
    return;
  }
  for (int idx = 0; idx < editStreams.size(); idx++) {
    File parentDir = getStorageDirForStream(idx);
    if (parentDir.getAbsolutePath().equals(
          sd.getRoot().getAbsolutePath())) {
      editStreams.remove(idx);
      idx--;
    }
  }
  exitIfNoStreams();
}
项目:hortonworks-extension    文件:TestStorageRestore.java   
/**
 * test
 */
public void printStorages(FSImage fs) {
  LOG.info("current storages and corresoponding sizes:");
  for (Iterator<StorageDirectory> it = fs.dirIterator(); it.hasNext();) {
    StorageDirectory sd = it.next();

    if (sd.getStorageDirType().isOfType(NameNodeDirType.IMAGE)) {
      File imf = FSImage.getImageFile(sd, NameNodeFile.IMAGE);
      LOG.info("  image file " + imf.getAbsolutePath() + "; len = "
          + imf.length());
    }
    if (sd.getStorageDirType().isOfType(NameNodeDirType.EDITS)) {
      File edf = FSImage.getImageFile(sd, NameNodeFile.EDITS);
      LOG.info("  edits file " + edf.getAbsolutePath() + "; len = "
          + edf.length());
    }
  }
}
项目:hortonworks-extension    文件:TestStartup.java   
/**
 * verify that edits log and fsimage are in different directories and of a correct size
 */
private void verifyDifferentDirs(FSImage img, long expectedImgSize, long expectedEditsSize) {
  StorageDirectory sd =null;
  for (Iterator<StorageDirectory> it = img.dirIterator(); it.hasNext();) {
    sd = it.next();

    if(sd.getStorageDirType().isOfType(NameNodeDirType.IMAGE)) {
      File imf = FSImage.getImageFile(sd, NameNodeFile.IMAGE);
      LOG.info("--image file " + imf.getAbsolutePath() + "; len = " + imf.length() + "; expected = " + expectedImgSize);
      assertEquals(expectedImgSize, imf.length());  
    } else if(sd.getStorageDirType().isOfType(NameNodeDirType.EDITS)) {
      File edf = FSImage.getImageFile(sd, NameNodeFile.EDITS);
      LOG.info("-- edits file " + edf.getAbsolutePath() + "; len = " + edf.length()  + "; expected = " + expectedEditsSize);
      assertEquals(expectedEditsSize, edf.length());    
    } else {
      fail("Image/Edits directories are not different");
    }
  }

}
项目:hortonworks-extension    文件:FSEditLog.java   
/**
 * Create empty edit log files.
 * Initialize the output stream for logging.
 * 
 * @throws IOException
 */
public synchronized void open() throws IOException {
  numTransactions = totalTimeTransactions = numTransactionsBatchedInSync = 0;
  if (editStreams == null) {
    editStreams = new ArrayList<EditLogOutputStream>();
  }
  Iterator<StorageDirectory> it = fsimage.dirIterator(NameNodeDirType.EDITS); 
  while (it.hasNext()) {
    StorageDirectory sd = it.next();
    File eFile = getEditFile(sd);
    try {
      EditLogOutputStream eStream = new EditLogFileOutputStream(eFile);
      editStreams.add(eStream);
    } catch (IOException ioe) {
      fsimage.updateRemovedDirs(sd, ioe);
      it.remove();
    }
  }
  exitIfNoStreams();
}
项目:hortonworks-extension    文件:FSEditLog.java   
/**
 * Remove all edits streams for the given storage directory.
 */
synchronized void removeEditsForStorageDir(StorageDirectory sd) {
  exitIfStreamsNotSet();

  if (!sd.getStorageDirType().isOfType(NameNodeDirType.EDITS)) {
    return;
  }
  for (int idx = 0; idx < editStreams.size(); idx++) {
    File parentDir = getStorageDirForStream(idx);
    if (parentDir.getAbsolutePath().equals(
          sd.getRoot().getAbsolutePath())) {
      editStreams.remove(idx);
      idx--;
    }
  }
  exitIfNoStreams();
}
项目:hadoop-gpu    文件:TestStartup.java   
/**
 * verify that edits log and fsimage are in different directories and of a correct size
 */
private void verifyDifferentDirs(FSImage img, long expectedImgSize, long expectedEditsSize) {
  StorageDirectory sd =null;
  for (Iterator<StorageDirectory> it = img.dirIterator(); it.hasNext();) {
    sd = it.next();

    if(sd.getStorageDirType().isOfType(NameNodeDirType.IMAGE)) {
      File imf = FSImage.getImageFile(sd, NameNodeFile.IMAGE);
      LOG.info("--image file " + imf.getAbsolutePath() + "; len = " + imf.length() + "; expected = " + expectedImgSize);
      assertEquals(expectedImgSize, imf.length());  
    } else if(sd.getStorageDirType().isOfType(NameNodeDirType.EDITS)) {
      File edf = FSImage.getImageFile(sd, NameNodeFile.EDITS);
      LOG.info("-- edits file " + edf.getAbsolutePath() + "; len = " + edf.length()  + "; expected = " + expectedEditsSize);
      assertEquals(expectedEditsSize, edf.length());    
    } else {
      fail("Image/Edits directories are not different");
    }
  }

}
项目:hadoop-gpu    文件:FSEditLog.java   
/**
 * Create empty edit log files.
 * Initialize the output stream for logging.
 * 
 * @throws IOException
 */
public synchronized void open() throws IOException {
  numTransactions = totalTimeTransactions = numTransactionsBatchedInSync = 0;
  if (editStreams == null)
    editStreams = new ArrayList<EditLogOutputStream>();
  for (Iterator<StorageDirectory> it = 
         fsimage.dirIterator(NameNodeDirType.EDITS); it.hasNext();) {
    StorageDirectory sd = it.next();
    File eFile = getEditFile(sd);
    try {
      EditLogOutputStream eStream = new EditLogFileOutputStream(eFile);
      editStreams.add(eStream);
    } catch (IOException e) {
      FSNamesystem.LOG.warn("Unable to open edit log file " + eFile);
      // Remove the directory from list of storage directories
      it.remove();
    }
  }
}
项目:hadoop-gpu    文件:FSEditLog.java   
/**
  * If there is an IO Error on any log operations on storage directory,
  * remove any stream associated with that directory 
  */
 synchronized void processIOError(StorageDirectory sd) {
   // Try to remove stream only if one should exist
   if (!sd.getStorageDirType().isOfType(NameNodeDirType.EDITS))
     return;
   if (editStreams == null || editStreams.size() <= 1) {
     FSNamesystem.LOG.fatal(
         "Fatal Error : All storage directories are inaccessible."); 
     Runtime.getRuntime().exit(-1);
   }
   for (int idx = 0; idx < editStreams.size(); idx++) {
     File parentStorageDir = ((EditLogFileOutputStream)editStreams
                                      .get(idx)).getFile()
                                      .getParentFile().getParentFile();
     if (parentStorageDir.getName().equals(sd.getRoot().getName()))
       editStreams.remove(idx);
}
 }
项目:hadoop-on-lustre    文件:FSEditLog.java   
private int getNumStorageDirs() {
 int numStorageDirs = 0;
 Iterator<StorageDirectory> it = fsimage.dirIterator(NameNodeDirType.EDITS);
 while (it.hasNext()) {
   numStorageDirs++;
   it.next();
 }
 return numStorageDirs;
}
项目:hadoop-on-lustre    文件:FSEditLog.java   
/**
 * check if ANY edits.new log exists
 */
boolean existsNew() throws IOException {
  Iterator<StorageDirectory> it = fsimage.dirIterator(NameNodeDirType.EDITS);
  while (it.hasNext()) {
    if (getEditNewFile(it.next()).exists()) { 
      return true;
    }
  }
  return false;
}
项目:hadoop-on-lustre    文件:FSEditLog.java   
/**
 * Removes the old edit log and renamed edits.new as edits.
 * Reopens the edits file.
 */
synchronized void purgeEditLog() throws IOException {
  //
  // If edits.new does not exists, then return error.
  //
  if (!existsNew()) {
    throw new IOException("Attempt to purge edit log " +
                          "but edits.new does not exist.");
  }
  close();

  //
  // Delete edits and rename edits.new to edits.
  //
  Iterator<StorageDirectory> it = fsimage.dirIterator(NameNodeDirType.EDITS);
  while (it.hasNext()) {
    StorageDirectory sd = it.next();
    if (!getEditNewFile(sd).renameTo(getEditFile(sd))) {
      //
      // renameTo() fails on Windows if the destination
      // file exists.
      //
      getEditFile(sd).delete();
      if (!getEditNewFile(sd).renameTo(getEditFile(sd))) {
        sd.unlock();
        removeEditsForStorageDir(sd);
        fsimage.updateRemovedDirs(sd);
        it.remove();
      }
    }
  }
  //
  // Reopen all the edits logs.
  //
  open();
}
项目:hadoop-on-lustre    文件:FSEditLog.java   
/**
 * Return the name of the edit file
 */
synchronized File getFsEditName() throws IOException {
  StorageDirectory sd = null;
  for (Iterator<StorageDirectory> it = 
         fsimage.dirIterator(NameNodeDirType.EDITS); it.hasNext();)
    sd = it.next();
  return getEditFile(sd);
}
项目:hadoop-on-lustre    文件:FSEditLog.java   
/**
 * Returns the timestamp of the edit log
 */
synchronized long getFsEditTime() {
  Iterator<StorageDirectory> it = fsimage.dirIterator(NameNodeDirType.EDITS);
  if(it.hasNext())
    return getEditFile(it.next()).lastModified();
  return 0;
}
项目:cumulus    文件:FSEditLog.java   
/**
 * Create empty edit log files.
 * Initialize the output stream for logging.
 * 
 * @throws IOException
 */
synchronized void open() throws IOException {
  numTransactions = totalTimeTransactions = numTransactionsBatchedInSync = 0;
  if (editStreams == null)
    editStreams = new ArrayList<EditLogOutputStream>();

  ArrayList<StorageDirectory> al = null;
  for (Iterator<StorageDirectory> it = 
         fsimage.dirIterator(NameNodeDirType.EDITS); it.hasNext();) {
    StorageDirectory sd = it.next();
    File eFile = getEditFile(sd);
    try {
      addNewEditLogStream(eFile);
    } catch (IOException e) {
      LOG.warn("Unable to open edit log file " + eFile);
      // Remove the directory from list of storage directories
      if(al == null) al = new ArrayList<StorageDirectory>(1);
      al.add(sd);
    }
  }

  if(al != null) fsimage.processIOError(al, false);

  // If there was an error in every storage dir, each one will have
  // been removed from the list of storage directories.
  if (fsimage.getNumStorageDirs(NameNodeDirType.EDITS) == 0) {
    throw new IOException(
        "Failed to initialize edits log in any storage directory.");
  }
}
项目:cumulus    文件:FSEditLog.java   
/**
 * Return the name of the edit file
 */
synchronized File getFsEditName() {
  StorageDirectory sd = null;   
  for (Iterator<StorageDirectory> it = 
    fsimage.dirIterator(NameNodeDirType.EDITS); it.hasNext();) {
    sd = it.next();   
    if(sd.getRoot().canRead())
      return getEditFile(sd);
  }
  return null;
}
项目:cumulus    文件:FSEditLog.java   
/**
 * Returns the timestamp of the edit log
 */
synchronized long getFsEditTime() {
  Iterator<StorageDirectory> it = fsimage.dirIterator(NameNodeDirType.EDITS);
  if(it.hasNext())
    return getEditFile(it.next()).lastModified();
  return 0;
}
项目:cumulus    文件:TestEditLogRace.java   
private void verifyEditLogs(FSNamesystem namesystem, FSImage fsimage)
  throws IOException {
  // Verify that we can read in all the transactions that we have written.
  // If there were any corruptions, it is likely that the reading in
  // of these transactions will throw an exception.
  for (Iterator<StorageDirectory> it = 
         fsimage.dirIterator(NameNodeDirType.EDITS); it.hasNext();) {
    File editFile = FSImage.getImageFile(it.next(), NameNodeFile.EDITS);
    System.out.println("Verifying file: " + editFile);
    int numEdits = new FSEditLogLoader(namesystem).loadFSEdits(
      new EditLogFileInputStream(editFile));
    System.out.println("Number of edits: " + numEdits);
  }
}
项目:RDFS    文件:FSEditLog.java   
private int getNumStorageDirs() {
int numStorageDirs = 0;
for (Iterator<StorageDirectory> it = 
      fsimage.dirIterator(NameNodeDirType.EDITS); it.hasNext(); it.next())
  numStorageDirs++;
   return numStorageDirs;
 }
项目:RDFS    文件:FSEditLog.java   
/**
 * check if ANY edits.new log exists
 */
boolean existsNew() throws IOException {
  for (Iterator<StorageDirectory> it = 
         fsimage.dirIterator(NameNodeDirType.EDITS); it.hasNext();) {
    if (getEditNewFile(it.next()).exists()) { 
      return true;
    }
  }
  return false;
}
项目:RDFS    文件:FSEditLog.java   
/**
 * Removes the old edit log and renamed edits.new as edits.
 * Reopens the edits file.
 */
synchronized void purgeEditLog() throws IOException {
  //
  // If edits.new does not exists, then return error.
  //
  if (!existsNew()) {
    throw new IOException("Attempt to purge edit log " +
                          "but edits.new does not exist.");
  }
  close();

  //
  // Delete edits and rename edits.new to edits.
  //
  for (Iterator<StorageDirectory> it = 
         fsimage.dirIterator(NameNodeDirType.EDITS); it.hasNext();) {
    StorageDirectory sd = it.next();

    if (!getEditNewFile(sd).renameTo(getEditFile(sd))) {
      //
      // renameTo() fails on Windows if the destination
      // file exists.
      //
      getEditFile(sd).delete();
      if (!getEditNewFile(sd).renameTo(getEditFile(sd))) {
        // Should we also remove from edits
        NameNode.LOG.warn("purgeEditLog: removing failed storage " + sd.getRoot().getPath());
        fsimage.removedStorageDirs.add(sd);
        it.remove(); 
      }
    }
  }
  //
  // Reopen all the edits logs.
  //
  open();
}
项目:RDFS    文件:FSEditLog.java   
/**
 * Return the name of the edit file
 */
synchronized File getFsEditName() throws IOException {
  StorageDirectory sd = null;
  for (Iterator<StorageDirectory> it = 
      fsimage.dirIterator(NameNodeDirType.EDITS); it.hasNext();) {
    sd = it.next();
    File fsEdit = getEditFile(sd);
    if (sd.getRoot().canRead() && fsEdit.exists()) {
      return fsEdit;
    }
  }
  return null;
}
项目:RDFS    文件:FSEditLog.java   
/**
 * Return the name of the edit.new file
 */
synchronized File getFsEditNewName() throws IOException {
  StorageDirectory sd = null;
  for (Iterator<StorageDirectory> it = 
      fsimage.dirIterator(NameNodeDirType.EDITS); it.hasNext();) {
    sd = it.next();
    File fsEdit = getEditNewFile(sd);
    if (sd.getRoot().canRead() && fsEdit.exists()) {
      return fsEdit;
    }
  }
  return null;
}