コード例 #1
0
  private void nextTuple() {
    List<PartitionManager> managers = _coordinator.getMyManagedPartitions();
    for (int i = 0; i < managers.size(); i++) {
      try {
        // in case the number of managers decreased
        _currPartitionIndex = _currPartitionIndex % managers.size();
        EmitState state = managers.get(_currPartitionIndex).next(messageContexts);
        if (state != EmitState.EMITTED_MORE_LEFT) {
          _currPartitionIndex = (_currPartitionIndex + 1) % managers.size();
        }
        if (state != EmitState.NO_EMITTED) {
          break;
        }
      } catch (FailedFetchException e) {
        LOG.warn("Fetch failed", e);
        _coordinator.refresh();
      }
    }

    long now = System.currentTimeMillis();
    if ((now - _lastUpdateMs) > _consumerConfig.stateUpdateIntervalMs) {
      commit();
    }
  }
コード例 #2
0
 private void commit() {
   _lastUpdateMs = System.currentTimeMillis();
   for (PartitionManager manager : _coordinator.getMyManagedPartitions()) {
     manager.commit();
   }
 }