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


Java PutRecordsRequestEntry.setPartitionKey方法代码示例

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


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

示例1: generateRecords

import com.amazonaws.services.kinesis.model.PutRecordsRequestEntry; //导入方法依赖的package包/类
private void generateRecords()
{
  // Create dummy message
  int recordNo = 1;
  while (recordNo <= sendCount) {
    String dataStr = "Record_" + recordNo;
    PutRecordsRequestEntry putRecordsEntry = new PutRecordsRequestEntry();
    putRecordsEntry.setData(ByteBuffer.wrap(dataStr.getBytes()));
    putRecordsEntry.setPartitionKey(dataStr);
    putRecordsRequestEntryList.add(putRecordsEntry);
    if ( (putRecordsRequestEntryList.size() == batchSize) || (recordNo == sendCount )) {
      PutRecordsRequest putRecordsRequest = new PutRecordsRequest();
      putRecordsRequest.setStreamName(streamName);
      putRecordsRequest.setRecords(putRecordsRequestEntryList);
      client.putRecords(putRecordsRequest);
      putRecordsRequestEntryList.clear();
    }
    recordNo++;
  }
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:21,代码来源:KinesisTestProducer.java

示例2: createDummyMessages

import com.amazonaws.services.kinesis.model.PutRecordsRequestEntry; //导入方法依赖的package包/类
private void createDummyMessages(String streamName, int count)
        throws Exception
{
    PutRecordsRequest putRecordsRequest = new PutRecordsRequest();
    putRecordsRequest.setStreamName(streamName);
    List<PutRecordsRequestEntry> putRecordsRequestEntryList = new ArrayList<>();
    for (int i = 0; i < count; i++) {
        PutRecordsRequestEntry putRecordsRequestEntry = new PutRecordsRequestEntry();
        putRecordsRequestEntry.setData(ByteBuffer.wrap(UUID.randomUUID().toString().getBytes()));
        putRecordsRequestEntry.setPartitionKey(Long.toString(i));
        putRecordsRequestEntryList.add(putRecordsRequestEntry);
    }

    putRecordsRequest.setRecords(putRecordsRequestEntryList);
    mockClient.putRecords(putRecordsRequest);
}
 
开发者ID:qubole,项目名称:presto-kinesis,代码行数:17,代码来源:TestRecordAccess.java

示例3: createJsonMessages

import com.amazonaws.services.kinesis.model.PutRecordsRequestEntry; //导入方法依赖的package包/类
private void createJsonMessages(String streamName, int count, int idStart)
        throws Exception
{
    String jsonFormat = "{\"id\" : %d, \"name\" : \"%s\"}";
    PutRecordsRequest putRecordsRequest = new PutRecordsRequest();
    putRecordsRequest.setStreamName(streamName);
    List<PutRecordsRequestEntry> putRecordsRequestEntryList = new ArrayList<>();
    for (int i = 0; i < count; i++) {
        PutRecordsRequestEntry putRecordsRequestEntry = new PutRecordsRequestEntry();
        long id = idStart + i;
        String name = UUID.randomUUID().toString();
        String jsonVal = String.format(jsonFormat, id, name);

        // ? with StandardCharsets.UTF_8
        putRecordsRequestEntry.setData(ByteBuffer.wrap(jsonVal.getBytes()));
        putRecordsRequestEntry.setPartitionKey(Long.toString(id));
        putRecordsRequestEntryList.add(putRecordsRequestEntry);
    }

    putRecordsRequest.setRecords(putRecordsRequestEntryList);
    mockClient.putRecords(putRecordsRequest);
}
 
开发者ID:qubole,项目名称:presto-kinesis,代码行数:23,代码来源:TestRecordAccess.java

示例4: createMessages

import com.amazonaws.services.kinesis.model.PutRecordsRequestEntry; //导入方法依赖的package包/类
private void createMessages(String streamName, int count)
        throws Exception
{
    PutRecordsRequest putRecordsRequest = new PutRecordsRequest();
    putRecordsRequest.setStreamName(streamName);
    List<PutRecordsRequestEntry> putRecordsRequestEntryList = new ArrayList<>();
    for (int i = 0; i < count; i++) {
        PutRecordsRequestEntry putRecordsRequestEntry = new PutRecordsRequestEntry();
        putRecordsRequestEntry.setData(ByteBuffer.wrap(UUID.randomUUID().toString().getBytes()));
        putRecordsRequestEntry.setPartitionKey(Long.toString(i));
        putRecordsRequestEntryList.add(putRecordsRequestEntry);
    }

    putRecordsRequest.setRecords(putRecordsRequestEntryList);
    embeddedKinesisStream.getKinesisClient().putRecords(putRecordsRequest);
}
 
开发者ID:qubole,项目名称:presto-kinesis,代码行数:17,代码来源:TestMinimalFunctionality.java

示例5: addRecord

import com.amazonaws.services.kinesis.model.PutRecordsRequestEntry; //导入方法依赖的package包/类
private void addRecord(T tuple)
{
  try {
    Pair<String, V> keyValue = tupleToKeyValue(tuple);
    PutRecordsRequestEntry putRecordsEntry = new PutRecordsRequestEntry();
    putRecordsEntry.setData(ByteBuffer.wrap(getRecord(keyValue.second)));
    putRecordsEntry.setPartitionKey(keyValue.first);
    putRecordsRequestEntryList.add(putRecordsEntry);
  } catch (AmazonClientException e) {
    throw new RuntimeException(e);
  }
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:13,代码来源:AbstractKinesisOutputOperator.java

示例6: getBadRecord

import com.amazonaws.services.kinesis.model.PutRecordsRequestEntry; //导入方法依赖的package包/类
private static PutRecordsRequestEntry getBadRecord() {
  PutRecordsRequestEntry badRecord = new PutRecordsRequestEntry();
  badRecord.setData(ByteBuffer.wrap("{\"a\":1,\"b\":2,\"c\":2,".getBytes(Charsets.UTF_8)));
  badRecord.setPartitionKey(String.valueOf(0));
  return badRecord;
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:7,代码来源:KinesisSourceIT.java


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