예제 #1
0
 public static void put_xor(RotatingMap<Tuple, Long> pending, Tuple key, Long id) {
   // synchronized (pending) {
   Long curr = pending.get(key);
   if (curr == null) {
     curr = Long.valueOf(0);
   }
   pending.put(key, JStormUtils.bit_xor(curr, id));
   // }
 }
예제 #2
0
  @Override
  public void onEvent(Object event, long sequence, boolean endOfBatch) throws Exception {

    if (event == null) {
      return;
    }

    boltExeTimer.start();

    try {

      if (event instanceof RotatingMapTrigger.Tick) {
        // don't check the timetick name to improve performance

        Map<Tuple, Long> timeoutMap = tuple_start_times.rotate();

        if (ackerNum > 0) {
          // only when acker is enable
          for (Entry<Tuple, Long> entry : timeoutMap.entrySet()) {
            Tuple input = entry.getKey();
            task_stats.bolt_failed_tuple(input.getSourceComponent(), input.getSourceStreamId());
          }
        }

        return;
      }

      Tuple tuple = (Tuple) event;

      task_stats.recv_tuple(tuple.getSourceComponent(), tuple.getSourceStreamId());

      tuple_start_times.put(tuple, System.currentTimeMillis());

      try {
        bolt.execute(tuple);
      } catch (Throwable e) {
        error = e;
        LOG.error("bolt execute error ", e);
        report_error.report(e);
      }

      if (ackerNum == 0) {
        // only when acker is disable
        // get tuple process latency
        Long start_time = (Long) tuple_start_times.remove(tuple);
        if (start_time != null) {
          Long delta = TimeUtils.time_delta_ms(start_time);
          task_stats.bolt_acked_tuple(tuple.getSourceComponent(), tuple.getSourceStreamId(), delta);
        }
      }
    } finally {
      boltExeTimer.stop();
    }
  }