this.logReadLock.unlock();
}
}
public synchronized TransactionSnapshot getSnapshot() throws IOException {
TransactionSnapshot snapshot = null;
if (!isRunning() && !isStopping()) {
return null;
}
long now = System.currentTimeMillis();
// avoid duplicate snapshots at same timestamp
if (now == lastSnapshotTime || (currentLog != null && now == currentLog.getTimestamp())) {
try {
TimeUnit.MILLISECONDS.sleep(1);
} catch (InterruptedException ie) { }
}
// copy in memory state
snapshot = getCurrentState();
LOG.info("Starting snapshot of transaction state with timestamp {}", snapshot.getTimestamp());
LOG.info("Returning snapshot of state: " + snapshot);
return snapshot;
}