Improve segmented journal actor metrics
[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 package org.opendaylight.controller.dummy.datastore;
9
10 import akka.actor.Props;
11 import akka.actor.UntypedAbstractActor;
12
13 public class DummyShardManager extends UntypedAbstractActor {
14     public DummyShardManager(final Configuration configuration, final String memberName, final String[] shardNames,
15             final String type) {
16         new DummyShardsCreator(configuration, getContext(), memberName, shardNames, type).create();
17     }
18
19     @Override
20     public void onReceive(final Object message) {
21
22     }
23
24     public static Props props(final Configuration configuration, final String memberName, final String[] shardNames,
25             final String type) {
26         return Props.create(DummyShardManager.class, configuration, memberName, shardNames, type);
27     }
28
29     private static class DummyShardsCreator {
30         private final Configuration configuration;
31         private final ActorContext actorSystem;
32         private final String memberName;
33         private final String[] shardNames;
34         private final String type;
35
36         DummyShardsCreator(final Configuration configuration, final ActorContext actorSystem, final String memberName,
37                 final String[] shardNames, final String type) {
38             this.configuration = configuration;
39             this.actorSystem = actorSystem;
40             this.memberName = memberName;
41             this.shardNames = shardNames;
42             this.type = type;
43         }
44
45         void create() {
46             for (String shardName : shardNames) {
47                 String shardId = memberName + "-shard-" + shardName + "-" + type;
48                 actorSystem.actorOf(DummyShard.props(configuration, shardId), shardId);
49             }
50         }
51     }
52 }