use of backtype.storm.multilang.ShellMsg in project jstorm by alibaba.
the class ShellSpout method querySubprocess.
private void querySubprocess() {
try {
_process.writeSpoutMsg(_spoutMsg);
while (true) {
ShellMsg shellMsg = _process.readShellMsg();
String command = shellMsg.getCommand();
if (command == null) {
throw new IllegalArgumentException("Command not found in spout message: " + shellMsg);
}
setHeartbeat();
if (command.equals("sync")) {
return;
} else if (command.equals("log")) {
handleLog(shellMsg);
} else if (command.equals("error")) {
handleError(shellMsg.getMsg());
} else if (command.equals("emit")) {
String stream = shellMsg.getStream();
Long task = shellMsg.getTask();
List<Object> tuple = shellMsg.getTuple();
Object messageId = shellMsg.getId();
if (task == 0) {
_collector.emit(stream, tuple, messageId, new ShellEmitCb(shellMsg));
} else {
_collector.emitDirect((int) task.longValue(), stream, tuple, messageId);
}
} else if (command.equals("metrics")) {
handleMetrics(shellMsg);
} else {
throw new RuntimeException("Unknown command received: " + command);
}
}
} catch (Exception e) {
String processInfo = _process.getProcessInfoString() + _process.getProcessTerminationInfoString();
throw new RuntimeException(processInfo, e);
}
}
use of backtype.storm.multilang.ShellMsg in project jstorm by alibaba.
the class ShellBolt method handleLog.
private void handleLog(ShellMsg shellMsg) {
String msg = shellMsg.getMsg();
msg = "ShellLog " + _process.getProcessInfoString() + " " + msg;
ShellMsg.ShellLogLevel logLevel = shellMsg.getLogLevel();
switch(logLevel) {
case TRACE:
LOG.trace(msg);
break;
case DEBUG:
LOG.debug(msg);
break;
case INFO:
LOG.info(msg);
break;
case WARN:
LOG.warn(msg);
break;
case ERROR:
LOG.error(msg);
_collector.reportError(new ReportedFailedException(msg));
break;
default:
LOG.info(msg);
break;
}
}
Aggregations