protected void prepare( Map stormConf, final TopologyContext context, final IOutputCollector collector) { _rand = new Random(); _collector = collector; _context = context; heartbeatTimeoutMills = getHeartbeatTimeoutMillis(stormConf); _process = new NuShellProcess(_command, this, this); // subprocesses must send their pid first thing Number subpid = _process.launch(stormConf, context); LOG.info("Launched subprocess with pid " + subpid); this.pid = subpid.longValue(); /** * randomizing the initial delay would prevent all shell bolts from heartbeating at the same * time frame */ int initialDelayMillis = random.nextInt(4000) + 1000; BoltHeartbeatTimerTask task = new BoltHeartbeatTimerTask(this); heartBeatExecutorService.scheduleAtFixedRate( task, initialDelayMillis, getHeartbeatPeriodMillis(stormConf), TimeUnit.MILLISECONDS); }