@Override public void enable() throws DurableDataLogException { Exceptions.checkNotClosed(this.closed.get(), this); synchronized (this.lock) { Preconditions.checkState(this.writeLedger == null, "BookKeeperLog is already initialized; cannot re-enable."); assert this.logMetadata == null : "writeLedger == null but logMetadata != null"; // Load existing metadata. Inexistent metadata means the BookKeeperLog has never been accessed, and therefore // enabled by default. LogMetadata metadata = loadMetadata(); Preconditions.checkState(metadata != null && !metadata.isEnabled(), "BookKeeperLog is already enabled."); metadata = metadata.asEnabled(); persistMetadata(metadata, false); log.info("{}: Enabled (Epoch = {}, UpdateVersion = {}).", this.traceObjectId, metadata.getEpoch(), metadata.getUpdateVersion()); } }