}
private void doSnapshot(boolean closing) throws IOException {
long snapshotTime = 0L;
TransactionSnapshot snapshot = null;
TransactionLog oldLog = null;
try {
this.logWriteLock.lock();
try {
synchronized (this) {
snapshot = getSnapshot();
if (snapshot == null && !closing) {
return;
}
if (snapshot != null) {
snapshotTime = snapshot.getTimestamp();
}
// roll WAL
oldLog = currentLog;
if (!closing) {
currentLog = persistor.createLog(snapshot.getTimestamp());
}
}
// there may not be an existing log on startup
if (oldLog != null) {
oldLog.close();
}
} finally {
this.logWriteLock.unlock();
}