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