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