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%2FShardManager.java;h=c9b7c07e9a3a44d1b0c64425122e53a5b3199543;hb=758e3e3b16e73298221a78872149814baf735c7d;hp=3396eb556456116005459540c66a78119ca64767;hpb=3d7027237aa124800753b9438ec625b73000a0d9;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardManager.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardManager.java index 3396eb5564..c9b7c07e9a 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardManager.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardManager.java @@ -17,7 +17,9 @@ import akka.actor.SupervisorStrategy; import akka.cluster.ClusterEvent; import akka.japi.Creator; import akka.japi.Function; + import com.google.common.base.Preconditions; + import org.opendaylight.controller.cluster.datastore.identifiers.ShardIdentifier; import org.opendaylight.controller.cluster.datastore.identifiers.ShardManagerIdentifier; import org.opendaylight.controller.cluster.datastore.jmx.mbeans.shardmanager.ShardManagerInfo; @@ -30,7 +32,6 @@ import org.opendaylight.controller.cluster.datastore.messages.PeerAddressResolve import org.opendaylight.controller.cluster.datastore.messages.PrimaryFound; import org.opendaylight.controller.cluster.datastore.messages.PrimaryNotFound; import org.opendaylight.controller.cluster.datastore.messages.UpdateSchemaContext; -import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStoreConfigProperties; import scala.concurrent.duration.Duration; @@ -70,19 +71,19 @@ public class ShardManager extends AbstractUntypedActor { private ShardManagerInfoMBean mBean; - private final InMemoryDOMDataStoreConfigProperties dataStoreProperties; + private final ShardContext shardContext; /** * @param type defines the kind of data that goes into shards created by this shard manager. Examples of type would be * configuration or operational */ private ShardManager(String type, ClusterWrapper cluster, Configuration configuration, - InMemoryDOMDataStoreConfigProperties dataStoreProperties) { + ShardContext shardContext) { this.type = Preconditions.checkNotNull(type, "type should not be null"); this.cluster = Preconditions.checkNotNull(cluster, "cluster should not be null"); this.configuration = Preconditions.checkNotNull(configuration, "configuration should not be null"); - this.dataStoreProperties = dataStoreProperties; + this.shardContext = shardContext; // Subscribe this actor to cluster member events cluster.subscribeToMemberEvents(getSelf()); @@ -95,22 +96,15 @@ public class ShardManager extends AbstractUntypedActor { public static Props props(final String type, final ClusterWrapper cluster, final Configuration configuration, - final InMemoryDOMDataStoreConfigProperties dataStoreProperties) { + final ShardContext shardContext) { Preconditions.checkNotNull(type, "type should not be null"); Preconditions.checkNotNull(cluster, "cluster should not be null"); Preconditions.checkNotNull(configuration, "configuration should not be null"); - return Props.create(new Creator() { - - @Override - public ShardManager create() throws Exception { - return new ShardManager(type, cluster, configuration, dataStoreProperties); - } - }); + return Props.create(new ShardManagerCreator(type, cluster, configuration, shardContext)); } - @Override public void handleReceive(Object message) throws Exception { if (message.getClass().equals(FindPrimary.SERIALIZABLE_CLASS)) { @@ -250,7 +244,7 @@ public class ShardManager extends AbstractUntypedActor { ShardIdentifier shardId = getShardIdentifier(memberName, shardName); Map peerAddresses = getPeerAddresses(shardName); ActorRef actor = getContext() - .actorOf(Shard.props(shardId, peerAddresses, dataStoreProperties), + .actorOf(Shard.props(shardId, peerAddresses, shardContext), shardId.toString()); localShardActorNames.add(shardId.toString()); localShards.put(shardName, new ShardInformation(shardName, actor, peerAddresses)); @@ -295,7 +289,12 @@ public class ShardManager extends AbstractUntypedActor { new Function() { @Override public SupervisorStrategy.Directive apply(Throwable t) { - LOG.warning("Supervisor Strategy of resume applied {}",t); + StringBuilder sb = new StringBuilder(); + for(StackTraceElement element : t.getStackTrace()) { + sb.append("\n\tat ") + .append(element.toString()); + } + LOG.warning("Supervisor Strategy of resume applied {}",sb.toString()); return SupervisorStrategy.resume(); } } @@ -346,6 +345,28 @@ public class ShardManager extends AbstractUntypedActor { } } } + + private static class ShardManagerCreator implements Creator { + private static final long serialVersionUID = 1L; + + final String type; + final ClusterWrapper cluster; + final Configuration configuration; + final ShardContext shardContext; + + ShardManagerCreator(String type, ClusterWrapper cluster, + Configuration configuration, ShardContext shardContext) { + this.type = type; + this.cluster = cluster; + this.configuration = configuration; + this.shardContext = shardContext; + } + + @Override + public ShardManager create() throws Exception { + return new ShardManager(type, cluster, configuration, shardContext); + } + } }