コード例 #1
0
 private void sendHbMsg() {
   List values = JStormUtils.mk_list(uptime.uptime());
   if (spoutOutputCollector != null) {
     spoutOutputCollector.emit(Common.TOPOLOGY_MASTER_HB_STREAM_ID, values);
   } else if (boltOutputCollector != null) {
     boltOutputCollector.emit(Common.TOPOLOGY_MASTER_HB_STREAM_ID, values);
   } else {
     LOG.warn("Failed to send hearbeat msg. OutputCollector has not been initialized!");
   }
 }
コード例 #2
0
  @Override
  public void run() {
    try {
      updateObject();

      if (object == null) {
        LOG.info("Timer " + name + " 's object is null ");
        return;
      }

      if (intervalCheck.check()) {
        checkExecuteThreadHb();
      }

      if (componentId.equals(Common.TOPOLOGY_MASTER_COMPONENT_ID)) {
        Values values = new Values(uptime.uptime());
        TupleExt tuple =
            new TupleImplExt(sysTopologyCtx, values, taskId, Common.TOPOLOGY_MASTER_HB_STREAM_ID);
        queue.publish(tuple);
      } else {
        // Send task heartbeat to topology master
        sendHbMsg();
      }

      // Send message used to monitor execute thread
      TimerEvent event = new TimerEvent(opCode, object);
      boolean ret = controlQueue.offer(event);
      if (ret) LOG.debug("Offer task HB event to controlQueue, taskId=" + taskId);
      else LOG.debug("Failed to offer task HB event to controlQueue, taskId=" + taskId);
    } catch (Exception e) {
      LOG.warn("Failed to publish timer event to " + name, e);
      return;
    }

    LOG.debug(" Trigger timer event to " + name);
  }