/** * Create a processor that writes to a given file * @param outputName Name of file to write output to */ public BinaryEditsVisitor(String outputName) throws IOException { this.elfos = new EditLogFileOutputStream(new Configuration(), new File(outputName), 0); elfos.create(NameNodeLayoutVersion.CURRENT_LAYOUT_VERSION); }
@Override synchronized public EditLogOutputStream startLogSegment(long txid, int layoutVersion) throws IOException { try { currentInProgress = NNStorage.getInProgressEditsFile(sd, txid); EditLogOutputStream stm = new EditLogFileOutputStream(conf, currentInProgress, outputBufferCapacity); stm.create(layoutVersion); return stm; } catch (IOException e) { LOG.warn("Unable to start log segment " + txid + " at " + currentInProgress + ": " + e.getLocalizedMessage()); errorReporter.reportErrorOnFile(currentInProgress); throw e; } }
/** * Create a processor that writes to a given file * @param outputName Name of file to write output to */ public BinaryEditsVisitor(String outputName) throws IOException { this.elfos = new EditLogFileOutputStream(new Configuration(), new File(outputName), 0); elfos.create(NameNodeLayoutVersion.CURRENT_LAYOUT_VERSION); }
/** * Create a processor that writes to a given file * @param outputName Name of file to write output to */ public BinaryEditsVisitor(String outputName) throws IOException { this.elfos = new EditLogFileOutputStream(new Configuration(), new File(outputName), 0); elfos.create(NameNodeLayoutVersion.CURRENT_LAYOUT_VERSION); }
public synchronized void createEditLogFile(File name) throws IOException { EditLogOutputStream eStream = new EditLogFileOutputStream(name, metrics); eStream.create(); eStream.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 }
/** * 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(); } } }
@Override synchronized public EditLogOutputStream startLogSegment(long txid, int layoutVersion) throws IOException { try { currentInProgress = NNStorage.getInProgressEditsFile(sd, txid); EditLogOutputStream stm = new EditLogFileOutputStream(conf, currentInProgress, outputBufferCapacity); stm.create(layoutVersion); return stm; } catch (IOException e) { LOG.warn("Unable to start log segment " + txid + " at " + currentInProgress + ": " + e.getLocalizedMessage()); errorReporter.reportErrorOnFile(currentInProgress); throw e; } }
@Override synchronized public EditLogOutputStream startLogSegment(long txid, int layoutVersion) throws IOException { try { currentInProgress = NNStorage.getInProgressEditsFile(sd, txid); EditLogOutputStream stm = new EditLogFileOutputStream(conf, currentInProgress, outputBufferCapacity); stm.create(layoutVersion); return stm; } catch (IOException e) { LOG.warn("Unable to start log segment " + txid + " at " + currentInProgress + ": " + e.getLocalizedMessage()); errorReporter.reportErrorOnFile(currentInProgress); throw e; } }
try { EditLogFileOutputStream eStream = new EditLogFileOutputStream(getEditNewFile(sd), metrics); eStream.create(); editStreams.add(eStream);
/** * 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(); }
/** * 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 being * abort/abort sequence. See HDFS-2011. */ @Test public void testEditLogFileOutputStreamAbortAbort() throws IOException { // abort after a close should just ignore EditLogFileOutputStream editLogStream = null; try { editLogStream = new EditLogFileOutputStream(conf, TEST_EDITS, 0); editLogStream.abort(); editLogStream.abort(); } finally { IOUtils.cleanup(null, editLogStream); } } }
EditLogFileInputStream elfis = null; try { elfos = new EditLogFileOutputStream(new Configuration(), TEST_LOG_NAME, 0); elfos.create(NameNodeLayoutVersion.CURRENT_LAYOUT_VERSION); elfos.writeRaw(garbage, 0, garbage.length);
NNStorage.getInProgressEditsFileName(3)); EditLogFileOutputStream stream = new EditLogFileOutputStream(conf, log, 1024); try { stream.create(NameNodeLayoutVersion.CURRENT_LAYOUT_VERSION);
EditLogFileInputStream elfis = null; try { elfos = new EditLogFileOutputStream(new Configuration(), TEST_LOG_NAME, 0); elfos.create(NameNodeLayoutVersion.CURRENT_LAYOUT_VERSION);
EditLogFileOutputStream elos = new EditLogFileOutputStream(conf, TEST_EDITS, 0); try {