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%2FShardTransactionFactory.java;h=ecfd2aa50d8375ac3cc184eaf1e55a383bc85df5;hp=3a92062e7f86972d55fe7f230c655898d0f0acfb;hb=23472d531aca7f695082a3d57719894bfa34d0ac;hpb=2727bea09c83646b6cbd2ef9672d0b7f6cf3b22f diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardTransactionFactory.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardTransactionFactory.java index 3a92062e7f..ecfd2aa50d 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardTransactionFactory.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardTransactionFactory.java @@ -7,10 +7,13 @@ */ package org.opendaylight.controller.cluster.datastore; -import com.google.common.base.Preconditions; import akka.actor.ActorRef; import akka.actor.UntypedActorContext; -import org.opendaylight.controller.cluster.datastore.identifiers.ShardTransactionIdentifier; +import com.google.common.base.Preconditions; +import org.opendaylight.controller.cluster.access.concepts.ClientIdentifier; +import org.opendaylight.controller.cluster.access.concepts.FrontendIdentifier; +import org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifier; +import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier; import org.opendaylight.controller.cluster.datastore.jmx.mbeans.shard.ShardStats; /** @@ -37,23 +40,42 @@ class ShardTransactionActorFactory { this.shardActor = shardActor; } - ActorRef newShardTransaction(TransactionProxy.TransactionType type, ShardTransactionIdentifier transactionID, - String transactionChainID, short clientVersion) { + private static String actorNameFor(final TransactionIdentifier txId) { + final LocalHistoryIdentifier historyId = txId.getHistoryId(); + final ClientIdentifier clientId = historyId.getClientId(); + final FrontendIdentifier frontendId = clientId.getFrontendId(); + + final StringBuilder sb = new StringBuilder("shard-"); + sb.append(frontendId.getMemberName().getName()).append(':'); + sb.append(frontendId.getClientType().getName()).append('@'); + sb.append(clientId.getGeneration()).append(':'); + if (historyId.getHistoryId() != 0) { + sb.append(historyId.getHistoryId()).append('-'); + } + + return sb.append(txId.getTransactionId()).toString(); + } + + ActorRef newShardTransaction(TransactionType type, TransactionIdentifier transactionID) { final AbstractShardDataTreeTransaction transaction; switch (type) { case READ_ONLY: - transaction = dataTree.newReadOnlyTransaction(transactionID.toString(), transactionChainID); + transaction = dataTree.newReadOnlyTransaction(transactionID); + shardMBean.incrementReadOnlyTransactionCount(); break; case READ_WRITE: + transaction = dataTree.newReadWriteTransaction(transactionID); + shardMBean.incrementReadWriteTransactionCount(); + break; case WRITE_ONLY: - transaction = dataTree.newReadWriteTransaction(transactionID.toString(), transactionChainID); + transaction = dataTree.newReadWriteTransaction(transactionID); + shardMBean.incrementWriteOnlyTransactionCount(); break; default: throw new IllegalArgumentException("Unsupported transaction type " + type); } - return actorContext.actorOf(ShardTransaction.props(type, transaction, shardActor, datastoreContext, shardMBean, - transactionID.getRemoteTransactionId(), clientVersion).withDispatcher(txnDispatcherPath), - transactionID.toString()); + return actorContext.actorOf(ShardTransaction.props(type, transaction, shardActor, datastoreContext, shardMBean) + .withDispatcher(txnDispatcherPath), actorNameFor(transactionID)); } }