X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2FShardTransactionActorFactory.java;h=74c75dc2542b1e5b31370786874e74cfd1dc72bf;hb=583f30d1c7a8199b401c9393745c62fe27b5ced8;hp=0ba36640a8f6368451478d0f28451a2c7a437db4;hpb=925cb4a228d0fda99c7bfeb432eb25285a223887;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardTransactionActorFactory.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardTransactionActorFactory.java index 0ba36640a8..74c75dc254 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardTransactionActorFactory.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardTransactionActorFactory.java @@ -10,6 +10,7 @@ package org.opendaylight.controller.cluster.datastore; import akka.actor.ActorRef; import akka.actor.UntypedActorContext; import com.google.common.base.Preconditions; +import java.util.concurrent.atomic.AtomicLong; import org.opendaylight.controller.cluster.access.concepts.ClientIdentifier; import org.opendaylight.controller.cluster.access.concepts.FrontendIdentifier; import org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifier; @@ -22,6 +23,7 @@ import org.opendaylight.controller.cluster.datastore.jmx.mbeans.shard.ShardStats * @author Thomas Pantelis */ class ShardTransactionActorFactory { + private static final AtomicLong ACTOR_NAME_COUNTER = new AtomicLong(); private final ShardDataTree dataTree; private final DatastoreContext datastoreContext; @@ -29,31 +31,35 @@ class ShardTransactionActorFactory { private final ShardStats shardMBean; private final UntypedActorContext actorContext; private final ActorRef shardActor; + private final String shardName; ShardTransactionActorFactory(ShardDataTree dataTree, DatastoreContext datastoreContext, - String txnDispatcherPath, ActorRef shardActor, UntypedActorContext actorContext, ShardStats shardMBean) { + String txnDispatcherPath, ActorRef shardActor, UntypedActorContext actorContext, ShardStats shardMBean, + String shardName) { this.dataTree = Preconditions.checkNotNull(dataTree); - this.datastoreContext = datastoreContext; - this.txnDispatcherPath = txnDispatcherPath; - this.shardMBean = shardMBean; - this.actorContext = actorContext; - this.shardActor = shardActor; + this.datastoreContext = Preconditions.checkNotNull(datastoreContext); + this.txnDispatcherPath = Preconditions.checkNotNull(txnDispatcherPath); + this.shardMBean = Preconditions.checkNotNull(shardMBean); + this.actorContext = Preconditions.checkNotNull(actorContext); + this.shardActor = Preconditions.checkNotNull(shardActor); + this.shardName = Preconditions.checkNotNull(shardName); } - private static String actorNameFor(final TransactionIdentifier txId) { + private 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(':'); + sb.append(shardName).append('-') + .append(frontendId.getMemberName().getName()).append(':') + .append(frontendId.getClientType().getName()).append('@') + .append(clientId.getGeneration()).append(':'); if (historyId.getHistoryId() != 0) { sb.append(historyId.getHistoryId()).append('-'); } - return sb.append(txId.getTransactionId()).toString(); + return sb.append(txId.getTransactionId()).append('_').append(ACTOR_NAME_COUNTER.incrementAndGet()).toString(); } ActorRef newShardTransaction(TransactionType type, TransactionIdentifier transactionID) {