/** * 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); } }
/** * If there is an IO Error on any log operations, remove that * directory from the list of directories. * If no more directories remain, then exit. */ synchronized void processIOError(int index) { if (editStreams == null || editStreams.size() <= 1) { FSNamesystem.LOG.fatal( "Fatal Error : All storage directories are inaccessible."); Runtime.getRuntime().exit(-1); } assert(index < getNumStorageDirs()); assert(getNumStorageDirs() == editStreams.size()); EditLogFileOutputStream eStream = (EditLogFileOutputStream)editStreams.get(index); File parentStorageDir = ((EditLogFileOutputStream)editStreams .get(index)).getFile() .getParentFile().getParentFile(); try { eStream.close(); } catch (Exception e) {} editStreams.remove(index); // // Invoke the ioerror routine of the fsimage // fsimage.processIOError(parentStorageDir); }
static void flushAndCheckLength(EditLogFileOutputStream elos, long expectedLength) throws IOException { elos.setReadyToFlush(); elos.flushAndSync(true); assertEquals(expectedLength, elos.getFile().length()); }