List of usage examples for com.amazonaws.services.kinesis.model Record getApproximateArrivalTimestamp
public java.util.Date getApproximateArrivalTimestamp()
The approximate time that the record was inserted into the stream.
From source file:com.nextdoor.bender.wrapper.kinesis.KinesisWrapper.java
License:Apache License
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().getContext().getFunctionName(); this.functionVersion = internal.getCtx().getContext().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 {/*www . ja va 2s . c o m*/ this.payload = null; } }
From source file:org.apache.samza.system.kinesis.consumer.KinesisSystemConsumer.java
License:Apache License
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);/* w w w . j av a2 s. c om*/ KinesisSystemConsumerOffset offset = new KinesisSystemConsumerOffset(shardId, record.getSequenceNumber()); return new KinesisIncomingMessageEnvelope(ssp, offset.toString(), record.getPartitionKey(), payload, shardId, record.getSequenceNumber(), record.getApproximateArrivalTimestamp()); }
From source file:org.apache.samza.system.kinesis.metrics.KinesisSystemConsumerMetrics.java
License:Apache License
public void updateMetrics(String stream, Record record) { eventReadRates.get(stream).inc();//from w w w. j a v a2s. c o m aggEventReadRate.inc(); long recordSize = record.getData().array().length + record.getPartitionKey().length(); eventByteReadRates.get(stream).inc(recordSize); aggEventByteReadRate.inc(recordSize); long latencyMs = Duration.between(Instant.now(), record.getApproximateArrivalTimestamp().toInstant()) .toMillis(); readLatencies.get(stream).update(latencyMs); aggReadLatency.update(latencyMs); }
From source file:org.swiftshire.nifi.processors.kinesis.consumer.GetKinesisStream.java
License:Apache License
/** * Creates our collections of configuration attributes. * * @param processRecordsInput//from w w w .j a va 2 s . c o m * @param processedRecords * @param timestamp * @param record * @return */ protected Map<String, String> createAttributes(ProcessRecordsInput processRecordsInput, int processedRecords, long timestamp, Record record) { Map<String, String> attributes = new HashMap<>(); attributes.put(AWS_KINESIS_CONSUMER_RECORD_PARTITION_KEY, record.getPartitionKey()); attributes.put(AWS_KINESIS_CONSUMER_RECORD_SEQUENCE_NUMBER, record.getSequenceNumber()); attributes.put(AWS_KINESIS_CONSUMER_MILLIS_SECONDS_BEHIND, Long.toString(processRecordsInput.getMillisBehindLatest())); attributes.put(AWS_KINESIS_CONSUMER_RECORD_APPROX_ARRIVAL_TIMESTAMP, Long.toString(record.getApproximateArrivalTimestamp().getTime())); attributes.put(KINESIS_CONSUMER_RECORD_START_TIMESTAMP, Long.toString(timestamp)); attributes.put(KINESIS_CONSUMER_RECORD_NUMBER, Integer.toString(processedRecords)); return attributes; }