X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2FLocalFrontendHistory.java;h=8e32c76ba794679dc3cdd84004946f1b57087ade;hp=cd0cc30a09738e49915939cd967a0dc04df472c4;hb=de64c6bbf2d5aeb51f4036f9dd606a9bf6f71afb;hpb=5cb0787412ab63a3aa5dcc044511e1ce569662cf diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/LocalFrontendHistory.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/LocalFrontendHistory.java index cd0cc30a09..8e32c76ba7 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/LocalFrontendHistory.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/LocalFrontendHistory.java @@ -8,10 +8,10 @@ package org.opendaylight.controller.cluster.datastore; import com.google.common.base.Preconditions; -import com.google.common.base.Ticker; import org.opendaylight.controller.cluster.access.commands.DeadTransactionException; import org.opendaylight.controller.cluster.access.commands.LocalHistorySuccess; import org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifier; +import org.opendaylight.controller.cluster.access.concepts.RequestEnvelope; import org.opendaylight.controller.cluster.access.concepts.RequestException; import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification; @@ -25,20 +25,17 @@ import org.slf4j.LoggerFactory; * @author Robert Varga */ final class LocalFrontendHistory extends AbstractFrontendHistory { - private enum State { - OPEN, - CLOSED, - } - private static final Logger LOG = LoggerFactory.getLogger(LocalFrontendHistory.class); private final ShardDataTreeTransactionChain chain; + private final ShardDataTree tree; private Long lastSeenTransaction; - private State state = State.OPEN; - LocalFrontendHistory(final String persistenceId, final Ticker ticker, final ShardDataTreeTransactionChain chain) { - super(persistenceId, ticker); + LocalFrontendHistory(final String persistenceId, final ShardDataTree tree, + final ShardDataTreeTransactionChain chain) { + super(persistenceId, tree.ticker()); + this.tree = Preconditions.checkNotNull(tree); this.chain = Preconditions.checkNotNull(chain); } @@ -74,20 +71,19 @@ final class LocalFrontendHistory extends AbstractFrontendHistory { return chain.createReadyCohort(id, mod); } - LocalHistorySuccess destroy(final long sequence, final long now) throws RequestException { - if (state != State.CLOSED) { - LOG.debug("{}: closing history {}", persistenceId(), getIdentifier()); - - // FIXME: add any finalization as needed - state = State.CLOSED; - } - - // FIXME: record a DESTROY tombstone in the journal - return new LocalHistorySuccess(getIdentifier(), sequence); + void destroy(final long sequence, final RequestEnvelope envelope, final long now) + throws RequestException { + LOG.debug("{}: closing history {}", persistenceId(), getIdentifier()); + tree.closeTransactionChain(getIdentifier(), () -> { + envelope.sendSuccess(new LocalHistorySuccess(getIdentifier(), sequence), readTime() - now); + }); } - boolean isDestroyed() { - return state == State.CLOSED; + void purge(final long sequence, final RequestEnvelope envelope, final long now) { + LOG.debug("{}: purging history {}", persistenceId(), getIdentifier()); + tree.purgeTransactionChain(getIdentifier(), () -> { + envelope.sendSuccess(new LocalHistorySuccess(getIdentifier(), sequence), readTime() - now); + }); } private void checkDeadTransaction(final TransactionIdentifier id) throws RequestException {