Leader should always apply modifications as local
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / test / java / org / opendaylight / controller / cluster / datastore / TestDistributedDataStore.java
1 /*
2  * Copyright (c) 2019 PANTHEON.tech, s.r.o. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.controller.cluster.datastore;
9
10 import akka.actor.ActorSystem;
11 import org.opendaylight.controller.cluster.access.concepts.ClientIdentifier;
12 import org.opendaylight.controller.cluster.datastore.config.Configuration;
13 import org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot;
14 import org.opendaylight.controller.cluster.datastore.shardmanager.AbstractShardManagerCreator;
15 import org.opendaylight.controller.cluster.datastore.shardmanager.TestShardManager;
16 import org.opendaylight.controller.cluster.datastore.utils.ActorUtils;
17
18 public class TestDistributedDataStore extends DistributedDataStore implements LocalShardStore {
19
20     public TestDistributedDataStore(final ActorSystem actorSystem, final ClusterWrapper cluster,
21                                     final Configuration configuration,
22                                     final DatastoreContextFactory datastoreContextFactory,
23                                     final DatastoreSnapshot restoreFromSnapshot) {
24         super(actorSystem, cluster, configuration, datastoreContextFactory, restoreFromSnapshot);
25     }
26
27     TestDistributedDataStore(final ActorUtils actorUtils, final ClientIdentifier identifier) {
28         super(actorUtils, identifier);
29     }
30
31     @Override
32     protected AbstractShardManagerCreator<?> getShardManagerCreator() {
33         return new TestShardManager.TestShardManagerCreator();
34     }
35
36     @Override
37     public TestShardManager.GetLocalShardsReply getLocalShards() {
38         TestShardManager.GetLocalShardsReply reply =
39             (TestShardManager.GetLocalShardsReply) getActorUtils()
40                 .executeOperation(getActorUtils().getShardManager(), TestShardManager.GetLocalShards.INSTANCE);
41
42         return reply;
43     }
44 }