/** * Finish the visitor */ @Override public void close(Throwable error) throws IOException { elfos.setReadyToFlush(); elfos.flushAndSync(true); elfos.close(); }
/** * Tests EditLogFileOutputStream doesn't throw NullPointerException on being * closed twice. */ public void testEditLogFileOutputStreamCloses() throws IOException, NullPointerException { // Testing EditLogFileOutputStream doesn't throw NullPointerException on // being closed twice File testEdits = new File(System.getProperty("test.build.data", "/tmp"), "editLogStream.dat"); try { EditLogFileOutputStream editLogStream = new EditLogFileOutputStream( testEdits, 0); editLogStream.close(); // Closing an twice should not throw a NullPointerException editLogStream.close(); } finally { // Cleanup the editLogStream.dat file we created testEdits.delete(); } // Successfully tested EditLogFileOutputStream doesn't throw // NullPointerException on being closed twice }
/** * Finish the visitor */ @Override public void close(Throwable error) throws IOException { elfos.setReadyToFlush(); elfos.flushAndSync(true); elfos.close(); }
/** * Finish the visitor */ @Override public void close(Throwable error) throws IOException { elfos.setReadyToFlush(); elfos.flushAndSync(true); elfos.close(); }
/** * 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); }
/** * Tests EditLogFileOutputStream doesn't throw NullPointerException on * close/close sequence. See HDFS-2011. */ @Test public void testEditLogFileOutputStreamCloseClose() throws IOException { // close after a close should result in an IOE EditLogFileOutputStream editLogStream = new EditLogFileOutputStream(conf, TEST_EDITS, 0); editLogStream.close(); try { editLogStream.close(); } catch (IOException ioe) { String msg = StringUtils.stringifyException(ioe); assertTrue(msg, msg.contains("Trying to use aborted output stream")); } }
/** * Tests EditLogFileOutputStream doesn't throw NullPointerException on * close/abort sequence. See HDFS-2011. */ @Test public void testEditLogFileOutputStreamCloseAbort() throws IOException { // abort after a close should just ignore EditLogFileOutputStream editLogStream = new EditLogFileOutputStream(conf, TEST_EDITS, 0); editLogStream.close(); editLogStream.abort(); }
stream.close();
elfos.setReadyToFlush(); elfos.flushAndSync(true); elfos.close(); elfos = null; elfis = new EditLogFileInputStream(TEST_LOG_NAME);
} finally { if (elos != null) elos.close();