当前位置: 首页>>代码示例>>Java>>正文


Java TaskCoordinator.commit方法代码示例

本文整理汇总了Java中org.apache.samza.task.TaskCoordinator.commit方法的典型用法代码示例。如果您正苦于以下问题:Java TaskCoordinator.commit方法的具体用法?Java TaskCoordinator.commit怎么用?Java TaskCoordinator.commit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.samza.task.TaskCoordinator的用法示例。


在下文中一共展示了TaskCoordinator.commit方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: aggregateEndOfStream

import org.apache.samza.task.TaskCoordinator; //导入方法依赖的package包/类
/**
 * Aggregate {@link EndOfStreamMessage} from each ssp of the stream.
 * Invoke onEndOfStream() if the stream reaches the end.
 * @param eos {@link EndOfStreamMessage} object
 * @param ssp system stream partition
 * @param collector message collector
 * @param coordinator task coordinator
 */
public final void aggregateEndOfStream(EndOfStreamMessage eos, SystemStreamPartition ssp, MessageCollector collector,
    TaskCoordinator coordinator) {
  LOG.info("Received end-of-stream message from task {} in {}", eos.getTaskName(), ssp);
  eosStates.update(eos, ssp);

  SystemStream stream = ssp.getSystemStream();
  if (eosStates.isEndOfStream(stream)) {
    LOG.info("Input {} reaches the end for task {}", stream.toString(), taskName.getTaskName());
    onEndOfStream(collector, coordinator);

    if (eosStates.allEndOfStream()) {
      // all inputs have been end-of-stream, shut down the task
      LOG.info("All input streams have reached the end for task {}", taskName.getTaskName());
      coordinator.commit(TaskCoordinator.RequestScope.CURRENT_TASK);
      coordinator.shutdown(TaskCoordinator.RequestScope.CURRENT_TASK);
    }
  }
}
 
开发者ID:apache,项目名称:samza,代码行数:27,代码来源:OperatorImpl.java

示例2: process

import org.apache.samza.task.TaskCoordinator; //导入方法依赖的package包/类
@Override
public void process(IncomingMessageEnvelope envelope, MessageCollector collector, TaskCoordinator coordinator) {
  if (envelope.getSystemStreamPartition().getStream().equals("epoch")) {
    int newEpoch = Integer.parseInt((String) envelope.getMessage());
    logger.info("New epoch in message - " + newEpoch);

    Integer epoch = getInt(EPOCH);
    if (epoch == null || newEpoch == epoch)
      return;
    if (newEpoch < epoch)
      throw new IllegalArgumentException("Got new epoch " + newEpoch + " which is less than current epoch " + epoch);
    
    // it's a new era, reset current epoch and count
    logger.info("Epoch: " + newEpoch);
    this.state.put(EPOCH, Integer.toString(newEpoch));
    this.state.put(COUNT, "0");
    coordinator.commit(RequestScope.ALL_TASKS_IN_CONTAINER);
  }
}
 
开发者ID:apache,项目名称:samza,代码行数:20,代码来源:Emitter.java

示例3: process

import org.apache.samza.task.TaskCoordinator; //导入方法依赖的package包/类
public void process(IncomingMessageEnvelope envelope, MessageCollector collector, TaskCoordinator coordinator) {
  store.put((String) envelope.getMessage(), (String) envelope.getMessage());
  count++;
  if (count % LOG_INTERVAL == 0) {
    double ellapsedSecs = (System.currentTimeMillis() - start) / 1000.0;
    System.out.println(String.format("Throughput = %.2f messages/sec.", count / ellapsedSecs));
    start = System.currentTimeMillis();
    count = 0;
    coordinator.commit(RequestScope.ALL_TASKS_IN_CONTAINER);
  }
}
 
开发者ID:apache,项目名称:samza,代码行数:12,代码来源:StatePerfTestTask.java

示例4: process

import org.apache.samza.task.TaskCoordinator; //导入方法依赖的package包/类
public void process(IncomingMessageEnvelope envelope, MessageCollector collector, TaskCoordinator coordinator) {
  System.out.println("Adding " + envelope.getMessage() + " => " + envelope.getMessage() + " to the store.");
  store.put((String) envelope.getMessage(), (String) envelope.getMessage());
  coordinator.commit(RequestScope.ALL_TASKS_IN_CONTAINER);
}
 
开发者ID:apache,项目名称:samza,代码行数:6,代码来源:SimpleStatefulTask.java


注:本文中的org.apache.samza.task.TaskCoordinator.commit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。