@SuppressWarnings("resource") // log closed during postCleanup LifecycleTransaction(Tracker tracker, OperationType operationType, Iterable<SSTableReader> readers) { this(tracker, new LogTransaction(operationType, tracker), readers); }
@Override protected Throwable doPostCleanup(Throwable accumulate) { log.close(); return unmarkCompacting(marked, accumulate); }
protected Throwable doAbort(Throwable accumulate) { return complete(Throwables.perform(accumulate, txnFile::abort)); }
try (LogTransaction txnLogs = new LogTransaction(operationType, this)) try txnLogs.finish(); if (!removed.isEmpty()) accumulate = release(selfRefs(removed), accumulate); accumulate = notifySSTablesChanged(removed, Collections.<SSTableReader>emptySet(), txnLogs.type(), accumulate);
/** * point of no return: commit all changes, but leave all readers marked as compacting */ public Throwable doCommit(Throwable accumulate) { assert staged.isEmpty() : "must be no actions introduced between prepareToCommit and a commit"; if (logger.isTraceEnabled()) logger.trace("Committing transaction over {} staged: {}, logged: {}", originals, staged, logged); // accumulate must be null if we have been used correctly, so fail immediately if it is not maybeFail(accumulate); // transaction log commit failure means we must abort; safe commit is not possible maybeFail(log.commit(null)); // this is now the point of no return; we cannot safely rollback, so we ignore exceptions until we're done // we restore state by obsoleting our obsolete files, releasing our references to them, and updating our size // and notification status for the obsolete and new files accumulate = markObsolete(obsoletions, accumulate); accumulate = tracker.updateSizeTracking(logged.obsolete, logged.update, accumulate); accumulate = release(selfRefs(logged.obsolete), accumulate); accumulate = tracker.notifySSTablesChanged(originals, logged.update, log.type(), accumulate); return accumulate; }
void delete() { LogTransaction.delete(file); syncDirectory(); }
public UUID opId() { return log.id(); }
public OperationType opType() { return log.type(); }
try (LogTransaction txnLogs = new LogTransaction(operationType, this)) try txnLogs.finish(); if (!removed.isEmpty())
static Throwable prepareForObsoletion(Iterable<SSTableReader> readers, LogTransaction txnLogs, List<LogTransaction.Obsoletion> obsoletions, Throwable accumulate) { Map<SSTable, LogRecord> logRecords = txnLogs.makeRemoveRecords(readers); for (SSTableReader reader : readers) { try { obsoletions.add(new LogTransaction.Obsoletion(reader, txnLogs.obsoleted(reader, logRecords.get(reader)))); } catch (Throwable t) { accumulate = Throwables.merge(accumulate, t); } } return accumulate; }
/** * point of no return: commit all changes, but leave all readers marked as compacting */ public Throwable doCommit(Throwable accumulate) { assert staged.isEmpty() : "must be no actions introduced between prepareToCommit and a commit"; if (logger.isTraceEnabled()) logger.trace("Committing transaction over {} staged: {}, logged: {}", originals, staged, logged); // accumulate must be null if we have been used correctly, so fail immediately if it is not maybeFail(accumulate); // transaction log commit failure means we must abort; safe commit is not possible maybeFail(log.commit(null)); // this is now the point of no return; we cannot safely rollback, so we ignore exceptions until we're done // we restore state by obsoleting our obsolete files, releasing our references to them, and updating our size // and notification status for the obsolete and new files accumulate = markObsolete(obsoletions, accumulate); accumulate = tracker.updateSizeTracking(logged.obsolete, logged.update, accumulate); accumulate = release(selfRefs(logged.obsolete), accumulate); //accumulate = tracker.notifySSTablesChanged(originals, logged.update, log.type(), accumulate); return accumulate; }
/** * helper method for tests, creates the remove records per sstable */ @VisibleForTesting SSTableTidier obsoleted(SSTableReader sstable) { return obsoleted(sstable, LogRecord.make(Type.REMOVE, sstable)); }
try (LogTransaction txnLogs = new LogTransaction(operationType, this)) try txnLogs.finish(); if (!removed.isEmpty()) accumulate = release(selfRefs(removed), accumulate); accumulate = notifySSTablesChanged(removed, Collections.<SSTableReader>emptySet(), txnLogs.type(), accumulate);
/** * point of no return: commit all changes, but leave all readers marked as compacting */ public Throwable doCommit(Throwable accumulate) { assert staged.isEmpty() : "must be no actions introduced between prepareToCommit and a commit"; if (logger.isTraceEnabled()) logger.trace("Committing transaction over {} staged: {}, logged: {}", originals, staged, logged); // accumulate must be null if we have been used correctly, so fail immediately if it is not maybeFail(accumulate); // transaction log commit failure means we must abort; safe commit is not possible maybeFail(log.commit(null)); // this is now the point of no return; we cannot safely rollback, so we ignore exceptions until we're done // we restore state by obsoleting our obsolete files, releasing our references to them, and updating our size // and notification status for the obsolete and new files accumulate = markObsolete(obsoletions, accumulate); accumulate = tracker.updateSizeTracking(logged.obsolete, logged.update, accumulate); accumulate = release(selfRefs(logged.obsolete), accumulate); accumulate = tracker.notifySSTablesChanged(originals, logged.update, log.type(), accumulate); return accumulate; }
void delete() { LogTransaction.delete(file); syncDirectory(); }
public UUID opId() { return log.id(); }
public OperationType opType() { return log.type(); }
static Throwable prepareForObsoletion(Iterable<SSTableReader> readers, LogTransaction txnLogs, List<LogTransaction.Obsoletion> obsoletions, Throwable accumulate) { Map<SSTable, LogRecord> logRecords = txnLogs.makeRemoveRecords(readers); for (SSTableReader reader : readers) { try { obsoletions.add(new LogTransaction.Obsoletion(reader, txnLogs.obsoleted(reader, logRecords.get(reader)))); } catch (Throwable t) { accumulate = Throwables.merge(accumulate, t); } } return accumulate; }