public void loadConfig(FlumeConfigData cfg) throws IOException,
RuntimeException, FlumeSpecException {
// got a newer configuration
LOG.debug("Attempt to load config " + cfg);
EventSink newSnk = null;
EventSource newSrc = null;
try {
String errMsg = null;
if (cfg.sinkConfig == null || cfg.sinkConfig.length() == 0) {
errMsg = this.getName() + " - empty sink";
}
if (cfg.sourceConfig == null || cfg.sourceConfig.length() == 0) {
errMsg = this.getName() + " - empty source";
}
if (errMsg != null) {
LOG.info(errMsg);
return; // Do nothing.
}
// TODO (jon) ERROR isn't quite right here -- the connection is in ERROR
// but the previous connection is ok. Need to just add states to the
// connections, and have each node maintain a list of connections.
newSnk = FlumeBuilder.buildSink(ctx, cfg.sinkConfig);
if (newSnk == null) {
LOG.error("failed to create sink config: " + cfg.sinkConfig);
state.state = NodeState.ERROR;
return;
}
newSrc = FlumeBuilder.buildSource(ctx, cfg.sourceConfig);
if (newSrc == null) {
newSnk.close(); // close the open sink.
LOG.error("failed to create sink config: " + cfg.sourceConfig);
state.state = NodeState.ERROR;
return;
}