public class TransactionContextImpl extends AbstractTransactionContext {
private static final Logger LOG = LoggerFactory.getLogger(TransactionContextImpl.class);
- private final String transactionChainId;
private final ActorContext actorContext;
private final ActorSelection actor;
private final boolean isTxActorLocal;
private int totalBatchedModificationsSent;
protected TransactionContextImpl(ActorSelection actor, TransactionIdentifier identifier,
- String transactionChainId, ActorContext actorContext, boolean isTxActorLocal,
+ ActorContext actorContext, boolean isTxActorLocal,
short remoteTransactionVersion, OperationCompleter operationCompleter) {
super(identifier);
this.actor = actor;
- this.transactionChainId = transactionChainId;
this.actorContext = actorContext;
this.isTxActorLocal = isTxActorLocal;
this.remoteTransactionVersion = remoteTransactionVersion;
}
private BatchedModifications newBatchedModifications() {
- return new BatchedModifications(getIdentifier().toString(), remoteTransactionVersion, transactionChainId);
+ return new BatchedModifications(getIdentifier().toString(), remoteTransactionVersion, getIdentifier().getChainId());
}
private void batchModification(Modification modification) {
private final TransactionType transactionType;
final ActorContext actorContext;
- private final String transactionChainId;
private final SchemaContext schemaContext;
private TransactionState state = TransactionState.OPEN;
}
public TransactionProxy(ActorContext actorContext, TransactionType transactionType, String transactionChainId) {
- super(createIdentifier(actorContext));
+ super(createIdentifier(actorContext, transactionChainId));
this.actorContext = Preconditions.checkNotNull(actorContext,
"actorContext should not be null");
this.transactionType = Preconditions.checkNotNull(transactionType,
"transactionType should not be null");
this.schemaContext = Preconditions.checkNotNull(actorContext.getSchemaContext(),
"schemaContext should not be null");
- this.transactionChainId = transactionChainId;
LOG.debug("Created txn {} of type {} on chain {}", getIdentifier(), transactionType, transactionChainId);
}
- private static TransactionIdentifier createIdentifier(ActorContext actorContext) {
+ private static TransactionIdentifier createIdentifier(ActorContext actorContext, String transactionChainId) {
String memberName = actorContext.getCurrentMemberName();
if (memberName == null) {
memberName = "UNKNOWN-MEMBER";
}
- return new TransactionIdentifier(memberName, counter.getAndIncrement());
+ return TransactionIdentifier.create(memberName, counter.getAndIncrement(), transactionChainId);
}
@VisibleForTesting
TransactionFutureCallback txFutureCallback = txFutureCallbackMap.values().iterator().next();
LOG.debug("Tx {} Readying transaction for shard {} on chain {}", getIdentifier(),
- txFutureCallback.getShardName(), transactionChainId);
+ txFutureCallback.getShardName(), getTransactionChainId());
final OperationCallback.Reference operationCallbackRef =
new OperationCallback.Reference(OperationCallback.NO_OP_CALLBACK);
for(TransactionFutureCallback txFutureCallback : txFutureCallbackMap.values()) {
LOG.debug("Tx {} Readying transaction for shard {} on chain {}", getIdentifier(),
- txFutureCallback.getShardName(), transactionChainId);
+ txFutureCallback.getShardName(), getTransactionChainId());
final TransactionContext transactionContext = txFutureCallback.getTransactionContext();
final Future<ActorSelection> future;
}
String getTransactionChainId() {
- return transactionChainId;
+ return getIdentifier().getChainId();
}
protected ActorContext getActorContext() {
if(remoteTransactionVersion < DataStoreVersions.LITHIUM_VERSION) {
return new PreLithiumTransactionContextImpl(transactionPath, transactionActor, getIdentifier(),
- transactionChainId, actorContext, isTxActorLocal, remoteTransactionVersion,
+ actorContext, isTxActorLocal, remoteTransactionVersion,
operationCompleter);
} else {
- return new TransactionContextImpl(transactionActor, getIdentifier(), transactionChainId,
+ return new TransactionContextImpl(transactionActor, getIdentifier(),
actorContext, isTxActorLocal, remoteTransactionVersion, operationCompleter);
}
}
private final String transactionPath;
public PreLithiumTransactionContextImpl(String transactionPath, ActorSelection actor, TransactionIdentifier identifier,
- String transactionChainId, ActorContext actorContext, boolean isTxActorLocal,
+ ActorContext actorContext, boolean isTxActorLocal,
short remoteTransactionVersion, OperationCompleter operationCompleter) {
- super(actor, identifier, transactionChainId, actorContext, isTxActorLocal,
- remoteTransactionVersion, operationCompleter);
+ super(actor, identifier, actorContext, isTxActorLocal, remoteTransactionVersion, operationCompleter);
this.transactionPath = transactionPath;
}
--- /dev/null
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.cluster.datastore.identifiers;
+
+import com.google.common.base.Preconditions;
+
+/**
+ * A TransactionIdentifier which is tied to a backend transaction chain.
+ */
+public class ChainedTransactionIdentifier extends TransactionIdentifier {
+ private final String chainId;
+
+ public ChainedTransactionIdentifier(final String memberName, final long counter, final String chainId) {
+ super(memberName, counter);
+ this.chainId = Preconditions.checkNotNull(chainId);
+ }
+
+ @Override
+ public String getChainId() {
+ return chainId;
+ }
+}