protected void applyOperatorsAndSend(List<String> tuple) {
    long timestamp = 0;
    if ((MyUtilities.isCustomTimestampMode(getConf())
            && getHierarchyPosition() == StormComponent.NEXT_TO_LAST_COMPONENT)
        || MyUtilities.isWindowTimestampMode(getConf())) timestamp = System.currentTimeMillis();

    tuple = _operatorChain.process(tuple, timestamp);

    if (tuple == null) return;

    _numSentTuples++;
    _pendingTuples++;
    printTuple(tuple);

    if (MyUtilities.isSending(getHierarchyPosition(), _aggBatchOutputMillis)) {
      int tuplekey = Integer.parseInt(tuple.get(_keyIndex));
      if (_frequentSet.contains(tuplekey))
        tupleSend(
            SynchronizedStormDataSourceInterface.SHUFFLE_GROUPING_STREAMID, tuple, null, timestamp);
      else tupleSend(tuple, null, timestamp);
    }

    if (MyUtilities.isPrintLatency(getHierarchyPosition(), getConf())) {
      printTupleLatency(_numSentTuples - 1, timestamp);
    }
  }
Esempio n. 2
0
  protected void applyOperatorsAndSend(
      Tuple stormTupleRcv, List<String> tuple, boolean isLastInBatch) {
    long timestamp = 0;
    if (MyUtilities.isCustomTimestampMode(getConf())
        || MyUtilities.isWindowTimestampMode(getConf()))
      timestamp = stormTupleRcv.getLongByField(StormComponent.TIMESTAMP);
    if (MyUtilities.isAggBatchOutputMode(_aggBatchOutputMillis))
      try {
        _semAgg.acquire();
      } catch (final InterruptedException ex) {
      }
    tuple = _operatorChain.process(tuple, timestamp);
    if (MyUtilities.isAggBatchOutputMode(_aggBatchOutputMillis)) _semAgg.release();

    if (tuple == null) {
      getCollector().ack(stormTupleRcv);
      return;
    }
    _numSentTuples++;
    printTuple(tuple);

    if (MyUtilities.isSending(getHierarchyPosition(), _aggBatchOutputMillis)
        || MyUtilities.isWindowTimestampMode(getConf())) {
      tupleSend(tuple, stormTupleRcv, timestamp);
    }
    if (MyUtilities.isPrintLatency(getHierarchyPosition(), getConf())) {
      if (MyUtilities.isManualBatchingMode(getConf())) {
        if (isLastInBatch) {
          timestamp = stormTupleRcv.getLongByField(StormComponent.TIMESTAMP); // getLong(2);
          printTupleLatency(_numSentTuples - 1, timestamp);
        }
      } else {
        timestamp = stormTupleRcv.getLongByField(StormComponent.TIMESTAMP); // getLong(3);
        printTupleLatency(_numSentTuples - 1, timestamp);
      }
    }
  }