public void removeFile(final Path walArchiveDir) throws IOException { close(); boolean archived = false; if (walArchiveDir != null) { Path archivedFile = new Path(walArchiveDir, logFile.getName()); LOG.info("Archiving " + logFile + " to " + archivedFile); if (!fs.rename(logFile, archivedFile)) { LOG.warn("Failed archive of " + logFile + ", deleting"); } else { archived = true; } } if (!archived) { if (!fs.delete(logFile, false)) { LOG.warn("Failed delete of " + logFile); } } }
@Override public void stop(final boolean abort) { if (!setRunning(false)) { return; } LOG.info("Stopping the WAL Procedure Store, isAbort=" + abort + (isSyncAborted() ? " (self aborting)" : "")); sendStopSignal(); if (!isSyncAborted()) { try { while (syncThread.isAlive()) { sendStopSignal(); syncThread.join(250); } } catch (InterruptedException e) { LOG.warn("join interrupted", e); Thread.currentThread().interrupt(); } } // Close the writer closeCurrentLogStream(abort); // Close the old logs // they should be already closed, this is just in case the load fails // and we call start() and then stop() for (ProcedureWALFile log: logs) { log.close(); } logs.clear(); loading.set(true); }
log.close(); return log;
public void processProcedureWALFile(ProcedureWALFile log) throws IOException { log.open(); ProcedureWALHeader header = log.getHeader(); printHeader(header); FSDataInputStream stream = log.getStream(); try { boolean hasMore = true; while (hasMore) { ProcedureWALEntry entry = ProcedureWALFormat.readEntry(stream); if (entry == null) { out.println("No more entry, exiting with missing EOF"); hasMore = false; break; } switch (entry.getType()) { case PROCEDURE_WAL_EOF: hasMore = false; break; default: printEntry(entry); } } } catch (IOException e) { out.println("got an exception while reading the procedure WAL " + e.getMessage()); } finally { log.close(); } }
reader.read(log); } finally { log.close();
public void removeFile() throws IOException { close(); fs.delete(logFile, false); }
public void removeFile(final Path walArchiveDir) throws IOException { close(); boolean archived = false; if (walArchiveDir != null) { Path archivedFile = new Path(walArchiveDir, logFile.getName()); LOG.info("Archiving " + logFile + " to " + archivedFile); if (!fs.rename(logFile, archivedFile)) { LOG.warn("Failed archive of " + logFile + ", deleting"); } else { archived = true; } } if (!archived) { if (!fs.delete(logFile, false)) { LOG.warn("Failed delete of " + logFile); } } }
public void removeFile(final Path walArchiveDir) throws IOException { close(); boolean archived = false; if (walArchiveDir != null) { Path archivedFile = new Path(walArchiveDir, logFile.getName()); LOG.info("Archiving " + logFile + " to " + archivedFile); if (!fs.rename(logFile, archivedFile)) { LOG.warn("Failed archive of " + logFile + ", deleting"); } else { archived = true; } } if (!archived) { if (!fs.delete(logFile, false)) { LOG.warn("Failed delete of " + logFile); } } }
@Override public void stop(final boolean abort) { if (!setRunning(false)) { return; } LOG.info("Stopping the WAL Procedure Store, isAbort=" + abort + (isSyncAborted() ? " (self aborting)" : "")); sendStopSignal(); if (!isSyncAborted()) { try { while (syncThread.isAlive()) { sendStopSignal(); syncThread.join(250); } } catch (InterruptedException e) { LOG.warn("join interrupted", e); Thread.currentThread().interrupt(); } } // Close the writer closeCurrentLogStream(); // Close the old logs // they should be already closed, this is just in case the load fails // and we call start() and then stop() for (ProcedureWALFile log: logs) { log.close(); } logs.clear(); loading.set(true); }
@Override public void stop(final boolean abort) { if (!setRunning(false)) { return; } LOG.info("Stopping the WAL Procedure Store, isAbort=" + abort + (isSyncAborted() ? " (self aborting)" : "")); sendStopSignal(); if (!isSyncAborted()) { try { while (syncThread.isAlive()) { sendStopSignal(); syncThread.join(250); } } catch (InterruptedException e) { LOG.warn("join interrupted", e); Thread.currentThread().interrupt(); } } // Close the writer closeCurrentLogStream(abort); // Close the old logs // they should be already closed, this is just in case the load fails // and we call start() and then stop() for (ProcedureWALFile log: logs) { log.close(); } logs.clear(); loading.set(true); }
@Override public void stop(boolean abort) { if (!setRunning(false)) { return; } LOG.info("Stopping the WAL Procedure Store"); sendStopSignal(); if (!abort) { try { while (syncThread.isAlive()) { sendStopSignal(); syncThread.join(250); } } catch (InterruptedException e) { LOG.warn("join interrupted", e); Thread.currentThread().interrupt(); } } // Close the writer closeStream(); // Close the old logs // they should be already closed, this is just in case the load fails // and we call start() and then stop() for (ProcedureWALFile log: logs) { log.close(); } logs.clear(); }
log.close(); return log;
log.close(); return log;
public void processProcedureWALFile(ProcedureWALFile log) throws IOException { log.open(); ProcedureWALHeader header = log.getHeader(); printHeader(header); FSDataInputStream stream = log.getStream(); try { boolean hasMore = true; while (hasMore) { ProcedureWALEntry entry = ProcedureWALFormat.readEntry(stream); if (entry == null) { out.println("No more entry, exiting with missing EOF"); hasMore = false; break; } switch (entry.getType()) { case PROCEDURE_WAL_EOF: hasMore = false; break; default: printEntry(entry); } } } catch (IOException e) { out.println("got an exception while reading the procedure WAL " + e.getMessage()); } finally { log.close(); } }
public void processProcedureWALFile(ProcedureWALFile log) throws IOException { log.open(); ProcedureWALHeader header = log.getHeader(); printHeader(header); FSDataInputStream stream = log.getStream(); try { boolean hasMore = true; while (hasMore) { ProcedureWALEntry entry = ProcedureWALFormat.readEntry(stream); if (entry == null) { out.println("No more entry, exiting with missing EOF"); hasMore = false; break; } switch (entry.getType()) { case PROCEDURE_WAL_EOF: hasMore = false; break; default: printEntry(entry); } } } catch (IOException e) { out.println("got an exception while reading the procedure WAL " + e.getMessage()); } finally { log.close(); } }
public static void load(final Iterator<ProcedureWALFile> logs, final ProcedureStoreTracker tracker, final Loader loader) throws IOException { final ProcedureWALFormatReader reader = new ProcedureWALFormatReader(tracker, loader); tracker.setKeepDeletes(true); try { // Ignore the last log which is current active log. while (logs.hasNext()) { ProcedureWALFile log = logs.next(); log.open(); try { reader.read(log); } finally { log.close(); } } reader.finish(); // The tracker is now updated with all the procedures read from the logs tracker.setPartialFlag(false); tracker.resetUpdates(); } finally { tracker.setKeepDeletes(false); } }
public static void load(final Iterator<ProcedureWALFile> logs, final ProcedureStoreTracker tracker, final Loader loader) throws IOException { ProcedureWALFormatReader reader = new ProcedureWALFormatReader(tracker); tracker.setKeepDeletes(true); try { while (logs.hasNext()) { ProcedureWALFile log = logs.next(); log.open(); try { reader.read(log, loader); } finally { log.close(); } } reader.finalize(loader); // The tracker is now updated with all the procedures read from the logs tracker.setPartialFlag(false); tracker.resetUpdates(); } finally { tracker.setKeepDeletes(false); } }
reader.read(log); } finally { log.close();