本文整理汇总了Java中com.amazonaws.services.kinesis.model.Record.getPartitionKey方法的典型用法代码示例。如果您正苦于以下问题:Java Record.getPartitionKey方法的具体用法?Java Record.getPartitionKey怎么用?Java Record.getPartitionKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.amazonaws.services.kinesis.model.Record
的用法示例。
在下文中一共展示了Record.getPartitionKey方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: KinesisWrapper
import com.amazonaws.services.kinesis.model.Record; //导入方法依赖的package包/类
private KinesisWrapper(final InternalEvent internal) {
KinesisEventRecord eventRecord = ((KinesisInternalEvent) internal).getRecord();
Record record = eventRecord.getKinesis();
this.partitionKey = record.getPartitionKey();
this.sequenceNumber = record.getSequenceNumber();
this.eventSource = eventRecord.getEventSource();
this.sourceArn = eventRecord.getEventSourceARN();
this.functionName = internal.getCtx().getFunctionName();
this.functionVersion = internal.getCtx().getFunctionVersion();
this.processingTime = System.currentTimeMillis();
this.arrivalTime = record.getApproximateArrivalTimestamp().getTime();
this.timestamp = internal.getEventTime();
this.processingDelay = processingTime - timestamp;
if (internal.getEventObj() != null) {
this.payload = internal.getEventObj().getPayload();
} else {
this.payload = null;
}
}
示例2: processRecord
import com.amazonaws.services.kinesis.model.Record; //导入方法依赖的package包/类
@Override
protected void processRecord(Record record)
{
String partitionKey = record.getPartitionKey();
ByteBuffer data = record.getData();
logger.info("partitionKey={} ", partitionKey);
byte[] dataBytes = new byte[data.remaining()];
data.get(dataBytes, 0, dataBytes.length);
long key = Long.valueOf(partitionKey);
TestPOJO expected = new TestPOJO(key);
TestPOJO read = (TestPOJO)fieldValueGenerator.deserializeObject(dataBytes);
if (!read.outputFieldsEquals(expected)) {
logger.error("read is not same as expected. read={}, expected={}", read, expected);
Assert.assertTrue(false);
} else {
logger.info("read is same as expected. read={}, expected={}", read, expected);
}
}
示例3: processRecordsWithRetries
import com.amazonaws.services.kinesis.model.Record; //导入方法依赖的package包/类
private void processRecordsWithRetries(List<Record> records) throws Exception {
for (Record record : records) {
int tryCount = 0;
boolean processedOk = false;
while (tryCount < NUM_RETRIES) {
try {
try {
processSingleRecord(record);
processedOk = true;
} catch (Throwable t) {
System.out.println("Caught throwable " + t + " while processing record " + record);
// exponential backoff
Thread.sleep(new Double(Math.pow(2, tryCount) * BACKOFF_TIME_IN_MILLIS).longValue());
}
} catch (InterruptedException e) {
throw e;
}
}
if (!processedOk) {
throw new Exception("Unable to process record " + record.getPartitionKey() + " after " + NUM_RETRIES);
}
}
}
示例4: translate
import com.amazonaws.services.kinesis.model.Record; //导入方法依赖的package包/类
private IncomingMessageEnvelope translate(SystemStreamPartition ssp, Record record) {
String shardId = processors.get(ssp).getShardId();
byte[] payload = new byte[record.getData().remaining()];
metrics.updateMetrics(ssp.getStream(), record);
record.getData().get(payload);
KinesisSystemConsumerOffset offset = new KinesisSystemConsumerOffset(shardId, record.getSequenceNumber());
return new KinesisIncomingMessageEnvelope(ssp, offset.toString(), record.getPartitionKey(),
payload, shardId, record.getSequenceNumber(), record.getApproximateArrivalTimestamp());
}
示例5: createMessage
import com.amazonaws.services.kinesis.model.Record; //导入方法依赖的package包/类
@Override
public KeyedMessage<String, String> createMessage(Record record, String topic) {
String data = new String(record.getData().array(), Charset.forName("UTF-8"));
return new KeyedMessage<String, String>(topic, record.getPartitionKey(), data);
}
示例6: nextRow
import com.amazonaws.services.kinesis.model.Record; //导入方法依赖的package包/类
/** Working from the internal list, advance to the next row and decode it. */
private boolean nextRow()
{
Record currentRecord = listIterator.next();
String partitionKey = currentRecord.getPartitionKey();
log.debug("Reading record with partition key %s", partitionKey);
byte[] messageData = EMPTY_BYTE_ARRAY;
ByteBuffer message = currentRecord.getData();
if (message != null) {
messageData = new byte[message.remaining()];
message.get(messageData);
}
totalBytes += messageData.length;
totalMessages++;
log.debug("Fetching %d bytes from current record. %d messages read so far", messageData.length, totalMessages);
Set<KinesisFieldValueProvider> fieldValueProviders = new HashSet<>();
// Note: older version of SDK used in Presto doesn't support getApproximateArrivalTimestamp so can't get message timestamp!
fieldValueProviders.addAll(globalInternalFieldValueProviders);
fieldValueProviders.add(KinesisInternalFieldDescription.SEGMENT_COUNT_FIELD.forLongValue(totalMessages));
fieldValueProviders.add(KinesisInternalFieldDescription.SHARD_SEQUENCE_ID_FIELD.forByteValue(currentRecord.getSequenceNumber().getBytes()));
fieldValueProviders.add(KinesisInternalFieldDescription.MESSAGE_FIELD.forByteValue(messageData));
fieldValueProviders.add(KinesisInternalFieldDescription.MESSAGE_LENGTH_FIELD.forLongValue(messageData.length));
fieldValueProviders.add(KinesisInternalFieldDescription.MESSAGE_TIMESTAMP.forLongValue(currentRecord.getApproximateArrivalTimestamp().getTime()));
fieldValueProviders.add(KinesisInternalFieldDescription.MESSAGE_VALID_FIELD.forBooleanValue(messageDecoder.decodeRow(messageData, fieldValueProviders, columnHandles, messageFieldDecoders)));
fieldValueProviders.add(KinesisInternalFieldDescription.PARTITION_KEY_FIELD.forByteValue(partitionKey.getBytes()));
this.fieldValueProviders = new KinesisFieldValueProvider[columnHandles.size()];
for (int i = 0; i < columnHandles.size(); i++) {
for (KinesisFieldValueProvider fieldValueProvider : fieldValueProviders) {
if (fieldValueProvider.accept(columnHandles.get(i))) {
this.fieldValueProviders[i] = fieldValueProvider;
break;
}
}
}
lastReadSeqNo = currentRecord.getSequenceNumber();
if (checkpointEnabled) {
kinesisShardCheckpointer.checkpointIfTimeUp(lastReadSeqNo);
}
return true;
}
示例7: InputEvent
import com.amazonaws.services.kinesis.model.Record; //导入方法依赖的package包/类
public InputEvent(Record record) {
this.sequenceNumber = record.getSequenceNumber();
this.partitionKey = record.getPartitionKey();
this.data = record.getData().array();
}