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


Java IncomingMessageEnvelope.getKey方法代码示例

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


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

示例1: readNext

import org.apache.samza.system.IncomingMessageEnvelope; //导入方法依赖的package包/类
public IncomingMessageEnvelope readNext() {
  if (!hasNext()) {
    LOG.warn("Attempting to read more data when there aren't any. ssp=" + systemStreamPartition);
    return null;
  }
  // record the next offset before we read, so when the read fails and we reconnect,
  // we seek to the same offset that we try below
  curSingleFileOffset = curReader.nextOffset();
  IncomingMessageEnvelope messageEnvelope = curReader.readNext();
  // Copy everything except for the offset. Turn the single-file style offset into a multi-file one
  return new IncomingMessageEnvelope(messageEnvelope.getSystemStreamPartition(), getCurOffset(),
    messageEnvelope.getKey(), messageEnvelope.getMessage(), messageEnvelope.getSize());
}
 
开发者ID:apache,项目名称:samza,代码行数:14,代码来源:MultiFileHdfsReader.java

示例2: process

import org.apache.samza.system.IncomingMessageEnvelope; //导入方法依赖的package包/类
@Override
public void process(IncomingMessageEnvelope envelope, MessageCollector collector, TaskCoordinator coordinator) {
  String key = (String) envelope.getKey();
  String value = (String) envelope.getMessage();
  String[] pieces = value.split("-");
  int epoch = Integer.parseInt(pieces[0]);

  int partition = Integer.parseInt(pieces[1].split(" ")[1]);
  Partitions partitions = loadPartitions(epoch, key);
  logger.info("Joiner got epoch = " + epoch + ", partition = " + partition + ", parts = " + partitions);
  if (partitions.epoch < epoch) {
    // we are in a new era
    if (partitions.partitions.size() != expected)
      throw new IllegalArgumentException("Should have " + expected + " partitions when new epoch starts.");
    logger.info("Reseting epoch to " + epoch);
    this.store.delete(key);
    partitions.epoch = epoch;
    partitions.partitions.clear();
    partitions.partitions.add(partition);
  } else if (partitions.epoch > epoch) {
    logger.info("Ignoring message for epoch " + epoch);
  } else {
    partitions.partitions.add(partition);
    if (partitions.partitions.size() == expected) {
      logger.info("Completed: " + key + " -> " + Integer.toString(epoch));
      collector.send(new OutgoingMessageEnvelope(new SystemStream("kafka", "completed-keys"), key, Integer.toString(epoch)));
    }
  }
  this.store.put(key, partitions.toString());
  logger.info("Join store in Task " + this.taskName + " " + key + " -> " + partitions.toString());
}
 
开发者ID:apache,项目名称:samza,代码行数:32,代码来源:Joiner.java

示例3: process

import org.apache.samza.system.IncomingMessageEnvelope; //导入方法依赖的package包/类
@Override
public void process(IncomingMessageEnvelope envelope, MessageCollector collector, TaskCoordinator coordinator) {
  String key = (String) envelope.getKey();
  String epoch = (String) envelope.getMessage();
  logger.info("Got key=" + key + ", epoch = " + epoch + " in checker...");
  checkEpoch(epoch);
  this.store.put(key, epoch);
}
 
开发者ID:apache,项目名称:samza,代码行数:9,代码来源:Checker.java

示例4: process

import org.apache.samza.system.IncomingMessageEnvelope; //导入方法依赖的package包/类
@Override
public void process(IncomingMessageEnvelope incomingMessageEnvelope, MessageCollector messageCollector,
    TaskCoordinator taskCoordinator)
    throws Exception {

  Object message = incomingMessageEnvelope.getMessage();

  String key = new String((byte[]) incomingMessageEnvelope.getKey());
  Integer val = Integer.valueOf((String) message);

  LOG.info("Stream processor " + processorId + ";key=" + key + ";offset=" + incomingMessageEnvelope.getOffset()
      + "; totalRcvd=" + processedMessageCount + ";val=" + val + "; ssp=" + incomingMessageEnvelope
      .getSystemStreamPartition());

  // inject a failure
  if (val >= BAD_MESSAGE_KEY && processorId.equals(processorIdToFail)) {
    LOG.info("process method failing for msg=" + message);
    throw new Exception("Processing in the processor " + processorId + " failed ");
  }

  messageCollector.send(new OutgoingMessageEnvelope(new SystemStream(outputSystem, outputTopic), message));
  processedMessageCount++;

  synchronized (endLatch) {
    if (Integer.valueOf(key) < BAD_MESSAGE_KEY) {
      endLatch.countDown();
    }
  }
}
 
开发者ID:apache,项目名称:samza,代码行数:30,代码来源:TestZkStreamProcessorBase.java

示例5: process

import org.apache.samza.system.IncomingMessageEnvelope; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void process(IncomingMessageEnvelope envelope, MessageCollector collector, TaskCoordinator taskCoordinator) throws Exception {
    String key = (String) envelope.getKey();
    Integer value = (Integer) envelope.getMessage();
    Integer newValue = value * 10;
    collector.send(new OutgoingMessageEnvelope(outputStream, key, newValue));
}
 
开发者ID:theduderog,项目名称:hello-samza-confluent,代码行数:9,代码来源:TestProcessTask.java

示例6: process

import org.apache.samza.system.IncomingMessageEnvelope; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void process(IncomingMessageEnvelope envelope, MessageCollector collector, TaskCoordinator taskCoordinator) throws Exception {
    String key = (String) envelope.getKey();
    Integer value = (Integer) envelope.getMessage();
    counterList.add(new AbstractMap.SimpleEntry<String, Integer>(key, value));
}
 
开发者ID:theduderog,项目名称:hello-samza-confluent,代码行数:8,代码来源:TestWindowTask.java


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