try {
System.out.println(args[0]);
CommandLineParser parser = new PosixParser();
CommandLine line = parser.parse(options, args);
if (line.hasOption("cassandrahostip")) {
CountandraUtils.setCassandraHostIp(line
.getOptionValue("cassandrahostip"));
if (line.hasOption("consistencylevel")) {
if (line.hasOption("replicationfactor")) {
CassandraStorage.setGlobalParams(
line.getOptionValue("cassandrahostip"),
line.getOptionValue("consistencylevel"));
CassandraDB.setGlobalParams(
line.getOptionValue("cassandrahostip"),
line.getOptionValue("replicationfactor"));
} else {
CassandraStorage.setGlobalParams(
line.getOptionValue("cassandrahostip"),
line.getOptionValue("consistencylevel"));
CassandraDB.setGlobalParams(line
.getOptionValue("cassandrahostip"));
}
}
else { // no consistency level -- assumed to be ONE
if (line.hasOption("replicationfactor")) {
CassandraStorage.setGlobalParams(line
.getOptionValue("cassandrahostip"));
CassandraDB.setGlobalParams(
line.getOptionValue("cassandrahostip"),
line.getOptionValue("replicationfactor"));
} else {
CassandraStorage.setGlobalParams(line
.getOptionValue("cassandrahostip"));
CassandraDB.setGlobalParams(line
.getOptionValue("cassandrahostip"));
}
}
} else {
CassandraStorage.setGlobalParams(cassandraServerForClient);
CassandraDB.setGlobalParams(cassandraServerForClient);
}
if (line.hasOption("s")) {
System.out.println("Starting Cassandra");
// cassandra server
CassandraUtils.startupCassandraServer();
}
if (line.hasOption("i")) {
System.out.print("Checking if Cassandra is initialized");
CassandraDB csdb = new CassandraDB();
while (!csdb.isCassandraUp()) {
System.out.print(".");
}
System.out.println(".");
System.out.println("Initializing Basic structures");
CountandraUtils.initBasicDataStructures();
System.out.println("Initialized Basic structures");
}
if (line.hasOption("h")) {
if (line.hasOption("httpserverport")) {
httpPort = Integer.parseInt(line
.getOptionValue("httpserverport"));
}
NettyUtils.startupNettyServer(httpPort);
System.out.println("Started Http Server");
}
if (line.hasOption("k")) {
KafkaUtils.startupKafkaConsumer();
System.out.println("Started Kafka Consumer");
}
// Unit Tests
if (line.hasOption("t")) {
try {
Thread.sleep(30000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();