*/
package org.opendaylight.controller.cluster.datastore;
-import com.google.common.base.Preconditions;
-import javax.annotation.Nonnull;
-import org.opendaylight.controller.cluster.datastore.identifiers.TransactionIdentifier;
+import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
abstract class AbstractTransactionContext implements TransactionContext {
private static final Logger LOG = LoggerFactory.getLogger(AbstractTransactionContext.class);
- private final OperationLimiter limiter;
+ private final TransactionIdentifier transactionIdentifier;
private long modificationCount = 0;
- private boolean handoffComplete;
+ private boolean handOffComplete;
+ private final short transactionVersion;
- protected AbstractTransactionContext(final OperationLimiter limiter) {
- this.limiter = Preconditions.checkNotNull(limiter);
+ protected AbstractTransactionContext(TransactionIdentifier transactionIdentifier) {
+ this(transactionIdentifier, DataStoreVersions.CURRENT_VERSION);
+ }
+
+ protected AbstractTransactionContext(TransactionIdentifier transactionIdentifier, short transactionVersion) {
+ // FIXME: requireNonNull()?
+ this.transactionIdentifier = transactionIdentifier;
+ this.transactionVersion = transactionVersion;
}
/**
*
* @return Transaction identifier.
*/
- @Nonnull protected final TransactionIdentifier getIdentifier() {
- return limiter.getIdentifier();
- }
-
- /**
- * Return the operation limiter associated with this context.
- * @return Operation limiter.
- */
- @Nonnull protected final OperationLimiter getLimiter() {
- return limiter;
+ // FIXME: does this imply Identifiable?
+ protected final @NonNull TransactionIdentifier getIdentifier() {
+ return transactionIdentifier;
}
- /**
- * Indicate whether all operations have been handed off by the {@link TransactionContextWrapper}.
- *
- * @return True if this context is responsible for throttling.
- */
- protected final boolean isOperationHandoffComplete() {
- return handoffComplete;
+ protected final void incrementModificationCount() {
+ modificationCount++;
}
- /**
- * Acquire operation from the limiter if the handoff has completed. If
- * the handoff is still ongoing, this method does nothing.
- */
- protected final void acquireOperation() {
- if (handoffComplete) {
- limiter.acquire();
- }
+ protected final void logModificationCount() {
+ LOG.debug("Total modifications on Tx {} = [ {} ]", getIdentifier(), modificationCount);
}
- /**
- * Acquire operation from the limiter if the handoff has NOT completed. If
- * the handoff has completed, this method does nothing.
- */
- protected final void releaseOperation() {
- if (!handoffComplete) {
- limiter.release();
- }
+ @Override
+ public final void operationHandOffComplete() {
+ handOffComplete = true;
}
- protected final void incrementModificationCount() {
- modificationCount++;
+ protected boolean isOperationHandOffComplete() {
+ return handOffComplete;
}
- protected final void logModificationCount() {
- LOG.debug("Total modifications on Tx {} = [ {} ]", getIdentifier(), modificationCount);
+ @Override
+ public boolean usesOperationLimiting() {
+ return false;
}
@Override
- public final void operationHandoffComplete() {
- handoffComplete = true;
+ public short getTransactionVersion() {
+ return transactionVersion;
}
}