Fix checkstyle violations in /sal-connector-api and sal-dummy-distributed-datastore
[controller.git] / opendaylight / md-sal / sal-dummy-distributed-datastore / src / main / java / org / opendaylight / controller / dummy / datastore / DummyShardManager.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. 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
9 package org.opendaylight.controller.dummy.datastore;
10
11 import akka.actor.ActorContext;
12 import akka.actor.Props;
13 import akka.actor.UntypedActor;
14 import akka.japi.Creator;
15
16 public class DummyShardManager extends UntypedActor {
17     public DummyShardManager(Configuration configuration, String memberName, String[] shardNames,
18             String type) throws Exception {
19         new DummyShardsCreator(configuration, context(), memberName, shardNames, type).create();
20     }
21
22     @Override
23     public void onReceive(Object message) throws Exception {
24
25     }
26
27     public static Props props(Configuration configuration, String memberName, String[] shardNames, String type) {
28         return Props.create(new DummyShardManagerCreator(configuration, memberName, shardNames, type));
29     }
30
31     private static class DummyShardManagerCreator implements Creator<DummyShardManager> {
32
33         private final Configuration configuration;
34         private final String memberName;
35         private final String[] shardNames;
36         private final String type;
37
38         DummyShardManagerCreator(Configuration configuration, String memberName, String[] shardNames, String type) {
39             this.configuration = configuration;
40             this.memberName = memberName;
41             this.shardNames = shardNames;
42             this.type = type;
43         }
44
45         @Override
46         public DummyShardManager create() throws Exception {
47             return new DummyShardManager(configuration, memberName, shardNames, type);
48         }
49     }
50
51     private static class DummyShardsCreator {
52         private final Configuration configuration;
53         private final ActorContext actorSystem;
54         private final String memberName;
55         private final String[] shardNames;
56         private final String type;
57
58         DummyShardsCreator(Configuration configuration, ActorContext actorSystem, String memberName,
59                 String[] shardNames, String type) {
60             this.configuration = configuration;
61             this.actorSystem = actorSystem;
62             this.memberName = memberName;
63             this.shardNames = shardNames;
64             this.type = type;
65         }
66
67         void create() {
68             for (String shardName : shardNames) {
69                 String shardId = memberName + "-shard-" + shardName + "-" + type;
70                 actorSystem.actorOf(DummyShard.props(configuration, shardId), shardId);
71             }
72         }
73     }
74 }