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