/** * call when a consistent batch of changes is ready to be made atomically visible * these will be exposed in the Tracker atomically, or an exception will be thrown; in this case * the transaction should be rolled back */ public void checkpoint() { maybeFail(checkpoint(null)); } private Throwable checkpoint(Throwable accumulate)
/** * call when a consistent batch of changes is ready to be made atomically visible * these will be exposed in the Tracker atomically, or an exception will be thrown; in this case * the transaction should be rolled back */ public void checkpoint() { maybeFail(checkpoint(null)); } private Throwable checkpoint(Throwable accumulate)
/** * call when a consistent batch of changes is ready to be made atomically visible * these will be exposed in the Tracker atomically, or an exception will be thrown; in this case * the transaction should be rolled back */ public void checkpoint() { maybeFail(checkpoint(null)); } private Throwable checkpoint(Throwable accumulate)
/** * call when a consistent batch of changes is ready to be made atomically visible * these will be exposed in the Tracker atomically, or an exception will be thrown; in this case * the transaction should be rolled back */ public void checkpoint() { maybeFail(checkpoint(null)); } private Throwable checkpoint(Throwable accumulate)
public void doPrepare() { // note for future: in anticompaction two different operations use the same Transaction, and both prepareToCommit() // separately: the second prepareToCommit is ignored as a "redundant" transition. since it is only a checkpoint // (and these happen anyway) this is fine but if more logic gets inserted here than is performed in a checkpoint, // it may break this use case, and care is needed checkpoint(); // prepare for compaction obsolete readers as long as they were part of the original set // since those that are not original are early readers that share the same desc with the finals maybeFail(prepareForObsoletion(filterIn(logged.obsolete, originals), log, obsoletions = new ArrayList<>(), null)); log.prepareToCommit(); }
public void doPrepare() { // note for future: in anticompaction two different operations use the same Transaction, and both prepareToCommit() // separately: the second prepareToCommit is ignored as a "redundant" transition. since it is only a checkpoint // (and these happen anyway) this is fine but if more logic gets inserted here than is performed in a checkpoint, // it may break this use case, and care is needed checkpoint(); // prepare for compaction obsolete readers as long as they were part of the original set // since those that are not original are early readers that share the same desc with the finals maybeFail(prepareForObsoletion(filterIn(logged.obsolete, originals), log, obsoletions = new ArrayList<>(), null)); log.prepareToCommit(); }
public void doPrepare() { // note for future: in anticompaction two different operations use the same Transaction, and both prepareToCommit() // separately: the second prepareToCommit is ignored as a "redundant" transition. since it is only a checkpoint // (and these happen anyway) this is fine but if more logic gets inserted here than is performed in a checkpoint, // it may break this use case, and care is needed checkpoint(); // prepare for compaction obsolete readers as long as they were part of the original set // since those that are not original are early readers that share the same desc with the finals maybeFail(prepareForObsoletion(filterIn(logged.obsolete, originals), log, obsoletions = new ArrayList<>(), null)); log.prepareToCommit(); }
protected void doPrepare() { switchWriter(null); if (throwEarly) throw new RuntimeException("exception thrown early in finish, for testing"); // No early open to finalize and replace for (SSTableWriter writer : writers) { assert writer.getFilePointer() > 0; writer.setRepairedAt(repairedAt).setOpenResult(true).prepareToCommit(); SSTableReader reader = writer.finished(); transaction.update(reader, false); preparedForCommit.add(reader); } transaction.checkpoint(); if (throwLate) throw new RuntimeException("exception thrown after all sstables finished, for testing"); if (!keepOriginals) transaction.obsoleteOriginals(); transaction.prepareToCommit(); }
protected void doPrepare() { switchWriter(null); if (throwEarly) throw new RuntimeException("exception thrown early in finish, for testing"); // No early open to finalize and replace for (SSTableWriter writer : writers) { assert writer.getFilePointer() > 0; writer.setRepairedAt(repairedAt).setOpenResult(true).prepareToCommit(); SSTableReader reader = writer.finished(); transaction.update(reader, false); preparedForCommit.add(reader); } transaction.checkpoint(); if (throwLate) throw new RuntimeException("exception thrown after all sstables finished, for testing"); if (!keepOriginals) transaction.obsoleteOriginals(); transaction.prepareToCommit(); }
protected void doPrepare() { switchWriter(null); if (throwEarly) throw new RuntimeException("exception thrown early in finish, for testing"); // No early open to finalize and replace for (SSTableWriter writer : writers) { assert writer.getFilePointer() > 0; writer.setRepairedAt(repairedAt).setOpenResult(true).prepareToCommit(); SSTableReader reader = writer.finished(); transaction.update(reader, false); preparedForCommit.add(reader); } transaction.checkpoint(); if (throwLate) throw new RuntimeException("exception thrown after all sstables finished, for testing"); if (!keepOriginals) transaction.obsoleteOriginals(); transaction.prepareToCommit(); }
public void switchWriter(SSTableWriter newWriter) { if (newWriter != null) writers.add(newWriter.setMaxDataAge(maxAge)); if (writer == null || writer.getFilePointer() == 0) { if (writer != null) { writer.abort(); transaction.untrackNew(writer); writers.remove(writer); } writer = newWriter; return; } if (preemptiveOpenInterval != Long.MAX_VALUE) { // we leave it as a tmp file, but we open it and add it to the Tracker SSTableReader reader = writer.setMaxDataAge(maxAge).openFinalEarly(); transaction.update(reader, false); moveStarts(reader, reader.last); transaction.checkpoint(); } currentlyOpenedEarlyAt = 0; writer = newWriter; }
public void switchWriter(SSTableWriter newWriter) { if (newWriter != null) writers.add(newWriter.setMaxDataAge(maxAge)); if (writer == null || writer.getFilePointer() == 0) { if (writer != null) { writer.abort(); transaction.untrackNew(writer); writers.remove(writer); } writer = newWriter; return; } if (preemptiveOpenInterval != Long.MAX_VALUE) { // we leave it as a tmp file, but we open it and add it to the Tracker SSTableReader reader = writer.setMaxDataAge(maxAge).openFinalEarly(); transaction.update(reader, false); moveStarts(reader, reader.last); transaction.checkpoint(); } currentlyOpenedEarlyAt = 0; writer = newWriter; }
public void switchWriter(SSTableWriter newWriter) { if (newWriter != null) writers.add(newWriter.setMaxDataAge(maxAge)); if (writer == null || writer.getFilePointer() == 0) { if (writer != null) { writer.abort(); transaction.untrackNew(writer); writers.remove(writer); } writer = newWriter; return; } if (preemptiveOpenInterval != Long.MAX_VALUE) { // we leave it as a tmp file, but we open it and add it to the Tracker SSTableReader reader = writer.setMaxDataAge(maxAge).openFinalEarly(); transaction.update(reader, false); moveStarts(reader, reader.last); transaction.checkpoint(); } currentlyOpenedEarlyAt = 0; writer = newWriter; }
private void maybeReopenEarly(DecoratedKey key) { if (writer.getFilePointer() - currentlyOpenedEarlyAt > preemptiveOpenInterval) { if (transaction.isOffline()) { for (SSTableReader reader : transaction.originals()) { RowIndexEntry index = reader.getPosition(key, SSTableReader.Operator.GE); NativeLibrary.trySkipCache(reader.getFilename(), 0, index == null ? 0 : index.position); } } else { SSTableReader reader = writer.setMaxDataAge(maxAge).openEarly(); if (reader != null) { transaction.update(reader, false); currentlyOpenedEarlyAt = writer.getFilePointer(); moveStarts(reader, reader.last); transaction.checkpoint(); } } } }
private void maybeReopenEarly(DecoratedKey key) { if (writer.getFilePointer() - currentlyOpenedEarlyAt > preemptiveOpenInterval) { if (transaction.isOffline()) { for (SSTableReader reader : transaction.originals()) { RowIndexEntry index = reader.getPosition(key, SSTableReader.Operator.GE); NativeLibrary.trySkipCache(reader.getFilename(), 0, index == null ? 0 : index.position); } } else { SSTableReader reader = writer.setMaxDataAge(maxAge).openEarly(); if (reader != null) { transaction.update(reader, false); currentlyOpenedEarlyAt = writer.getFilePointer(); moveStarts(reader, reader.last); transaction.checkpoint(); } } } }
private void maybeReopenEarly(DecoratedKey key) { if (writer.getFilePointer() - currentlyOpenedEarlyAt > preemptiveOpenInterval) { if (transaction.isOffline()) { for (SSTableReader reader : transaction.originals()) { RowIndexEntry index = reader.getPosition(key, SSTableReader.Operator.GE); NativeLibrary.trySkipCache(reader.getFilename(), 0, index == null ? 0 : index.position); } } else { SSTableReader reader = writer.setMaxDataAge(maxAge).openEarly(); if (reader != null) { transaction.update(reader, false); currentlyOpenedEarlyAt = writer.getFilePointer(); moveStarts(reader, reader.last); transaction.checkpoint(); } } } }