本文整理汇总了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);
}
}
}
示例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);
}
}
示例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);
}
}
示例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);
}