Github user itaifrenkel commented on a diff in the pull request:
https://github.com/apache/storm/pull/286#discussion_r18741096
--- Diff: storm-core/src/jvm/backtype/storm/spout/ShellSpout.java ---
@@ -189,9 +205,52 @@ private void handleLog(ShellMsg shellMsg) {
@Override
public void activate() {
+ LOG.info("Start checking heartbeat...");
+ // prevent timer to check heartbeat based on last thing before
activate
+ setHeartbeat();
+ heartBeatTimer.scheduleAtFixedRate(new
SpoutHeartbeatTimerTask(this), 1000, 1 * 1000);
}
@Override
public void deactivate() {
+ heartBeatTimer.cancel();
+ }
+
+ private void setHeartbeat() {
+ lastHeartbeatTimestamp.set(System.currentTimeMillis());
+ }
+
+ private long getLastHeartbeat() {
+ return lastHeartbeatTimestamp.get();
+ }
+
+ private void die(Throwable exception) {
+ heartBeatTimer.cancel();
+
+ LOG.error("Halting process: ShellSpout died.", exception);
+ _collector.reportError(exception);
+ System.exit(11);
}
+
+ private class SpoutHeartbeatTimerTask extends TimerTask {
+ private ShellSpout spout;
+
+ public SpoutHeartbeatTimerTask(ShellSpout spout) {
+ this.spout = spout;
+ }
+
+ @Override
+ public void run() {
+ long currentTimeMillis = System.currentTimeMillis();
+ long lastHeartbeat = getLastHeartbeat();
+
+ LOG.debug("current time : " + currentTimeMillis + ", last
heartbeat : " + lastHeartbeat
--- End diff --
whe doing debug logging try to refrain from using +. Either surraound with
isDebugLevel() or use "current time :{}, last heartbeat : {} ....
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---