com.amazonaws.services.kinesis.model.Record.getPartitionKey()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(12.4k)|赞(0)|评价(0)|浏览(107)

本文整理了Java中com.amazonaws.services.kinesis.model.Record.getPartitionKey方法的一些代码示例,展示了Record.getPartitionKey的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Record.getPartitionKey方法的具体详情如下:
包路径:com.amazonaws.services.kinesis.model.Record
类名称:Record
方法名:getPartitionKey

Record.getPartitionKey介绍

[英]Identifies which shard in the stream the data record is assigned to.
[中]标识数据记录分配给流中的哪个碎片。

代码示例

代码示例来源:origin: aws/aws-sdk-java

@Override
public int hashCode() {
  final int prime = 31;
  int hashCode = 1;
  hashCode = prime * hashCode + ((getSequenceNumber() == null) ? 0 : getSequenceNumber().hashCode());
  hashCode = prime * hashCode + ((getApproximateArrivalTimestamp() == null) ? 0 : getApproximateArrivalTimestamp().hashCode());
  hashCode = prime * hashCode + ((getData() == null) ? 0 : getData().hashCode());
  hashCode = prime * hashCode + ((getPartitionKey() == null) ? 0 : getPartitionKey().hashCode());
  hashCode = prime * hashCode + ((getEncryptionType() == null) ? 0 : getEncryptionType().hashCode());
  return hashCode;
}

代码示例来源:origin: aws/aws-sdk-java

/**
 * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be
 * redacted from this string using a placeholder value.
 *
 * @return A string representation of this object.
 *
 * @see java.lang.Object#toString()
 */
@Override
public String toString() {
  StringBuilder sb = new StringBuilder();
  sb.append("{");
  if (getSequenceNumber() != null)
    sb.append("SequenceNumber: ").append(getSequenceNumber()).append(",");
  if (getApproximateArrivalTimestamp() != null)
    sb.append("ApproximateArrivalTimestamp: ").append(getApproximateArrivalTimestamp()).append(",");
  if (getData() != null)
    sb.append("Data: ").append(getData()).append(",");
  if (getPartitionKey() != null)
    sb.append("PartitionKey: ").append(getPartitionKey()).append(",");
  if (getEncryptionType() != null)
    sb.append("EncryptionType: ").append(getEncryptionType());
  sb.append("}");
  return sb.toString();
}

代码示例来源:origin: aws/aws-sdk-java

if (other.getData() != null && other.getData().equals(this.getData()) == false)
  return false;
if (other.getPartitionKey() == null ^ this.getPartitionKey() == null)
  return false;
if (other.getPartitionKey() != null && other.getPartitionKey().equals(this.getPartitionKey()) == false)
  return false;
if (other.getEncryptionType() == null ^ this.getEncryptionType() == null)

代码示例来源:origin: aws/aws-sdk-java

/**
 * Marshall the given parameter object.
 */
public void marshall(Record record, ProtocolMarshaller protocolMarshaller) {
  if (record == null) {
    throw new SdkClientException("Invalid argument passed to marshall(...)");
  }
  try {
    protocolMarshaller.marshall(record.getSequenceNumber(), SEQUENCENUMBER_BINDING);
    protocolMarshaller.marshall(record.getApproximateArrivalTimestamp(), APPROXIMATEARRIVALTIMESTAMP_BINDING);
    protocolMarshaller.marshall(record.getData(), DATA_BINDING);
    protocolMarshaller.marshall(record.getPartitionKey(), PARTITIONKEY_BINDING);
    protocolMarshaller.marshall(record.getEncryptionType(), ENCRYPTIONTYPE_BINDING);
  } catch (Exception e) {
    throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
  }
}

代码示例来源:origin: aws-amplify/aws-sdk-android

@Override
public int hashCode() {
  final int prime = 31;
  int hashCode = 1;
  hashCode = prime * hashCode
      + ((getSequenceNumber() == null) ? 0 : getSequenceNumber().hashCode());
  hashCode = prime
      * hashCode
      + ((getApproximateArrivalTimestamp() == null) ? 0
          : getApproximateArrivalTimestamp().hashCode());
  hashCode = prime * hashCode + ((getData() == null) ? 0 : getData().hashCode());
  hashCode = prime * hashCode
      + ((getPartitionKey() == null) ? 0 : getPartitionKey().hashCode());
  hashCode = prime * hashCode
      + ((getEncryptionType() == null) ? 0 : getEncryptionType().hashCode());
  return hashCode;
}

代码示例来源:origin: aws-amplify/aws-sdk-android

/**
 * Returns a string representation of this object; useful for testing and
 * debugging.
 *
 * @return A string representation of this object.
 * @see java.lang.Object#toString()
 */
@Override
public String toString() {
  StringBuilder sb = new StringBuilder();
  sb.append("{");
  if (getSequenceNumber() != null)
    sb.append("SequenceNumber: " + getSequenceNumber() + ",");
  if (getApproximateArrivalTimestamp() != null)
    sb.append("ApproximateArrivalTimestamp: " + getApproximateArrivalTimestamp() + ",");
  if (getData() != null)
    sb.append("Data: " + getData() + ",");
  if (getPartitionKey() != null)
    sb.append("PartitionKey: " + getPartitionKey() + ",");
  if (getEncryptionType() != null)
    sb.append("EncryptionType: " + getEncryptionType());
  sb.append("}");
  return sb.toString();
}

代码示例来源:origin: aws-amplify/aws-sdk-android

if (other.getData() != null && other.getData().equals(this.getData()) == false)
  return false;
if (other.getPartitionKey() == null ^ this.getPartitionKey() == null)
  return false;
if (other.getPartitionKey() != null
    && other.getPartitionKey().equals(this.getPartitionKey()) == false)
  return false;
if (other.getEncryptionType() == null ^ this.getEncryptionType() == null)

代码示例来源:origin: aws-amplify/aws-sdk-android

public void marshall(Record record, AwsJsonWriter jsonWriter) throws Exception {
  jsonWriter.beginObject();
  if (record.getSequenceNumber() != null) {
    String sequenceNumber = record.getSequenceNumber();
    jsonWriter.name("SequenceNumber");
    jsonWriter.value(sequenceNumber);
  }
  if (record.getApproximateArrivalTimestamp() != null) {
    java.util.Date approximateArrivalTimestamp = record.getApproximateArrivalTimestamp();
    jsonWriter.name("ApproximateArrivalTimestamp");
    jsonWriter.value(approximateArrivalTimestamp);
  }
  if (record.getData() != null) {
    java.nio.ByteBuffer data = record.getData();
    jsonWriter.name("Data");
    jsonWriter.value(data);
  }
  if (record.getPartitionKey() != null) {
    String partitionKey = record.getPartitionKey();
    jsonWriter.name("PartitionKey");
    jsonWriter.value(partitionKey);
  }
  if (record.getEncryptionType() != null) {
    String encryptionType = record.getEncryptionType();
    jsonWriter.name("EncryptionType");
    jsonWriter.value(encryptionType);
  }
  jsonWriter.endObject();
}

代码示例来源:origin: amazon-archives/kinesis-storm-spout

@Override
public List<Object> deserialize(Record record) {
  final List<Object> l = new ArrayList<>();
  l.add(record.getPartitionKey());
  l.add(record);
  return l;
}

代码示例来源:origin: awslabs/amazon-kinesis-aggregators

public InputEvent(Record record) {
  this.sequenceNumber = record.getSequenceNumber();
  this.partitionKey = record.getPartitionKey();
  this.data = record.getData().array();
}

代码示例来源:origin: hortonworks/streamline

@Override
  public List<Object> getTuple(Record record) {
    CharsetDecoder decoder = Charset.forName("UTF-8").newDecoder();
    List<Object> tuple = new ArrayList<>();
    tuple.add(record.getPartitionKey());
    tuple.add(record.getSequenceNumber());
    try {
      String data = decoder.decode(record.getData()).toString();
      tuple.add(data);
    } catch (CharacterCodingException e) {
      e.printStackTrace();
      LOG.warn("Exception occured. Emitting tuple with empty string data", e);
      tuple.add("");
    }
    return tuple;
  }
}

代码示例来源:origin: amazon-archives/kinesis-storm-spout

Record recordToRetry() {
  Record recordToRetry = null;
  String sequenceNumber = retryQueue.peek();
  if (sequenceNumber != null) {
    RecordNode node = seqNumToRecordInfoMap.get(sequenceNumber);
    if (node != null) {
      recordToRetry = node.getRecord();
      if (LOG.isInfoEnabled()) {
        LOG.info("Retrying record with partition key " + recordToRetry.getPartitionKey() + " sequence number "
            + recordToRetry.getSequenceNumber() + ". Retry attempt " + (node.getRetryCount() + 1));
      }
    }
  }
  return recordToRetry;
}

代码示例来源:origin: apache/samza

public void updateMetrics(String stream, Record record) {
  eventReadRates.get(stream).inc();
  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);
 }
}

代码示例来源:origin: com.amazonaws/aws-java-sdk-kinesis

@Override
public int hashCode() {
  final int prime = 31;
  int hashCode = 1;
  hashCode = prime * hashCode + ((getSequenceNumber() == null) ? 0 : getSequenceNumber().hashCode());
  hashCode = prime * hashCode + ((getApproximateArrivalTimestamp() == null) ? 0 : getApproximateArrivalTimestamp().hashCode());
  hashCode = prime * hashCode + ((getData() == null) ? 0 : getData().hashCode());
  hashCode = prime * hashCode + ((getPartitionKey() == null) ? 0 : getPartitionKey().hashCode());
  hashCode = prime * hashCode + ((getEncryptionType() == null) ? 0 : getEncryptionType().hashCode());
  return hashCode;
}

代码示例来源:origin: com.amazonaws/amazon-kinesis-client

/**
 * Convenience constructor.
 *
 * @param record The record that this message will represent.
 */
public JsonFriendlyRecord(Record record) {
  this.data = record.getData() == null ? null : record.getData().array();
  this.partitionKey = record.getPartitionKey();
  this.sequenceNumber = record.getSequenceNumber();
  this.approximateArrivalTimestamp = record.getApproximateArrivalTimestamp();
  if (record instanceof UserRecord) {
    this.subSequenceNumber = ((UserRecord) record).getSubSequenceNumber();
  } else {
    this.subSequenceNumber = null;
  }
}

代码示例来源:origin: amazon-archives/kinesis-storm-spout

/**
 * Creates a copy of the record so we don't get interference from bolts that execute in the same JVM.
 * We invoke ByteBuffer.duplicate() so the ByteBuffer state is decoupled.
 * 
 * @param record Kinesis record
 * @return Copied record.
 */
private Record copyRecord(Record record) {
  Record duplicate = new Record();
  duplicate.setPartitionKey(record.getPartitionKey());
  duplicate.setSequenceNumber(record.getSequenceNumber());
  duplicate.setData(record.getData().duplicate());
  return duplicate;
}

代码示例来源:origin: apache/samza

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());
}

代码示例来源:origin: com.amazonaws/aws-java-sdk-kinesis

/**
 * Marshall the given parameter object.
 */
public void marshall(Record record, ProtocolMarshaller protocolMarshaller) {
  if (record == null) {
    throw new SdkClientException("Invalid argument passed to marshall(...)");
  }
  try {
    protocolMarshaller.marshall(record.getSequenceNumber(), SEQUENCENUMBER_BINDING);
    protocolMarshaller.marshall(record.getApproximateArrivalTimestamp(), APPROXIMATEARRIVALTIMESTAMP_BINDING);
    protocolMarshaller.marshall(record.getData(), DATA_BINDING);
    protocolMarshaller.marshall(record.getPartitionKey(), PARTITIONKEY_BINDING);
    protocolMarshaller.marshall(record.getEncryptionType(), ENCRYPTIONTYPE_BINDING);
  } catch (Exception e) {
    throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
  }
}

代码示例来源:origin: Nextdoor/bender

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 {
  this.payload = null;
 }
}

代码示例来源:origin: apache/samza

private void verifyRecords(List<IncomingMessageEnvelope> outputRecords, List<Record> inputRecords, String shardId) {
 Iterator outputRecordsIter = outputRecords.iterator();
 inputRecords.forEach(record -> {
   IncomingMessageEnvelope envelope = (IncomingMessageEnvelope) outputRecordsIter.next();
   String outputKey = (String) envelope.getKey();
   KinesisIncomingMessageEnvelope kinesisMessageEnvelope = (KinesisIncomingMessageEnvelope) envelope;
   Assert.assertEquals(outputKey, record.getPartitionKey());
   Assert.assertEquals(kinesisMessageEnvelope.getSequenceNumber(), record.getSequenceNumber());
   Assert.assertEquals(kinesisMessageEnvelope.getApproximateArrivalTimestamp(),
     record.getApproximateArrivalTimestamp());
   Assert.assertEquals(kinesisMessageEnvelope.getShardId(), shardId);
   ByteBuffer outputData = ByteBuffer.wrap((byte[]) kinesisMessageEnvelope.getMessage());
   record.getData().rewind();
   Assert.assertTrue(outputData.equals(record.getData()));
   verifyOffset(envelope.getOffset(), record, shardId);
  });
}

相关文章