package com.cloudera.flume.agent;
import java.io.IOException;
import java.util.concurrent.CountDownLatch;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private static final Logger LOG = LoggerFactory
.getLogger(FlumeNodeDaemon.class);
private static final FlumeNodeDaemon serviceInstance = new FlumeNodeDaemon();
private static FlumeNode node;
String cmd = "start";
if (args.length > 0) {
cmd = args[0];
}
if ("start".equals(cmd)) {
serviceInstance.start();
} else {
serviceInstance.stop();
}
}
private CountDownLatch done;
if (node != null) {
return;
}
done = new CountDownLatch(1);
try {
node = FlumeNode.setup(new String[0]);
} catch (IOException ioe) {
LOG.error("IOException setting up node!", ioe);
}
if (node == null) {
throw new RuntimeException("Failed to create node");
}
node.start();
try {
done.await();
} catch (InterruptedException e) {
LOG.error("Daemon was interrupted", e);
}
}
node.stop();
node = null;
done.countDown();
}
}