Merge "Cleanup root pom "name"."
[controller.git] / opendaylight / md-sal / sal-dummy-distributed-datastore / src / main / java / org / opendaylight / controller / dummy / datastore / Main.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.ActorSystem;
12 import com.typesafe.config.ConfigFactory;
13 import org.kohsuke.args4j.CmdLineParser;
14 import org.kohsuke.args4j.Option;
15
16 public class Main {
17     @Option(name="-member-name", usage="Sets the member name", required = true)
18     public String memberName;
19
20     @Option(name="-max-delay-millis", usage = "Sets the maximum delay that should be applied for any append entry. Only applies when cause-trouble is present.")
21     public int maxDelayInMillis = 500;
22
23     @Option(name="-cause-trouble", usage="If present turns on artificial failures")
24     public boolean causeTrouble = false;
25
26     @Option(name="-drop-replies", usage = "If present drops replies. Only applies when cause-trouble is present.")
27     public boolean dropReplies = false;
28
29     public void run(){
30         ActorSystem actorSystem = ActorSystem.create("opendaylight-cluster-data", ConfigFactory.load(memberName).getConfig("odl-cluster-data"));
31
32         Configuration configuration = new Configuration(maxDelayInMillis, dropReplies, causeTrouble);
33
34         actorSystem.actorOf(DummyShardManager.props(configuration, memberName, new String[] {"inventory", "default", "toaster", "topology"}, "operational"), "shardmanager-operational");
35         actorSystem.actorOf(DummyShardManager.props(configuration, memberName, new String[] {"inventory", "default", "toaster", "topology"}, "config"), "shardmanager-config");
36     }
37
38     @Override
39     public String toString() {
40         return "Main{" +
41                 "memberName='" + memberName + '\'' +
42                 ", maxDelayInMillis=" + maxDelayInMillis +
43                 ", causeTrouble=" + causeTrouble +
44                 ", dropReplies=" + dropReplies +
45                 '}';
46     }
47
48     public static void main(String[] args){
49         Main bean = new Main();
50         CmdLineParser parser = new CmdLineParser(bean);
51
52         try {
53             parser.parseArgument(args);
54             System.out.println(bean.toString());
55             bean.run();
56         } catch(Exception e){
57             System.err.println(e.getMessage());
58             parser.printUsage(System.err);
59         }
60     }
61
62 }