本文整理汇总了Java中com.amazonaws.services.kinesis.clientlibrary.interfaces.IRecordProcessorCheckpointer.checkpoint方法的典型用法代码示例。如果您正苦于以下问题:Java IRecordProcessorCheckpointer.checkpoint方法的具体用法?Java IRecordProcessorCheckpointer.checkpoint怎么用?Java IRecordProcessorCheckpointer.checkpoint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.amazonaws.services.kinesis.clientlibrary.interfaces.IRecordProcessorCheckpointer
的用法示例。
在下文中一共展示了IRecordProcessorCheckpointer.checkpoint方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processRecords
import com.amazonaws.services.kinesis.clientlibrary.interfaces.IRecordProcessorCheckpointer; //导入方法依赖的package包/类
@Override
public void processRecords(List<Record> records,
IRecordProcessorCheckpointer checkpointer) {
LOG.info(String.format("Received %s Records", records.size()));
// add a call to your business logic here!
//
// myLinkedClasses.doSomething(records)
//
//
try {
checkpointer.checkpoint();
} catch (KinesisClientLibDependencyException | InvalidStateException
| ThrottlingException | ShutdownException e) {
e.printStackTrace();
super.shutdown(checkpointer, ShutdownReason.ZOMBIE);
}
}
示例2: processRecords
import com.amazonaws.services.kinesis.clientlibrary.interfaces.IRecordProcessorCheckpointer; //导入方法依赖的package包/类
@SneakyThrows
@Override
public void processRecords(ProcessRecordsInput processRecordsInput) {
List<Record> records = processRecordsInput.getRecords();
// Used to update the last processed record
IRecordProcessorCheckpointer checkpointer = processRecordsInput.getCheckpointer();
log.info("Recovering records from kinesis.");
for (Record r : records) {
try {
int len = r.getData().remaining();
byte[] buffer = new byte[len];
r.getData().get(buffer);
String json = new String(buffer, "UTF-8");
ZombieLecture lecture = mapper.readValue(json, ZombieLecture.class);
this.processZombieLecture(lecture);
log.debug(processedRecords++ + ": " + json);
if (processedRecords % 1000 == 999) {
// Uncomment next line to keep track of the processed lectures.
checkpointer.checkpoint();
}
} catch (UnsupportedEncodingException | MessagingException ex) {
log.warn(ex.getMessage());
}
}
}
示例3: shutdown
import com.amazonaws.services.kinesis.clientlibrary.interfaces.IRecordProcessorCheckpointer; //导入方法依赖的package包/类
@Override
public void shutdown(IRecordProcessorCheckpointer checkpointer, ShutdownReason reason) {
LOG.info("Shutting down record processor with shardId: " + shardId + " with reason " + reason);
if (isShutdown) {
LOG.warn("Record processor for shardId: " + shardId + " has been shutdown multiple times.");
return;
}
switch (reason) {
case TERMINATE:
emit(checkpointer, transformToOutput(buffer.getRecords()));
try {
checkpointer.checkpoint();
} catch (KinesisClientLibDependencyException | InvalidStateException | ThrottlingException | ShutdownException e) {
LOG.error(e);
}
break;
case ZOMBIE:
break;
default:
throw new IllegalStateException("invalid shutdown reason");
}
emitter.shutdown();
isShutdown = true;
}
示例4: processRecords
import com.amazonaws.services.kinesis.clientlibrary.interfaces.IRecordProcessorCheckpointer; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void processRecords(List<Record> records,
IRecordProcessorCheckpointer checkpointer) {
LOG.info("Aggregating " + records.size()
+ " records for Kinesis Shard " + kinesisShardId);
try {
// run data into the aggregator
agg.aggregate(records);
// checkpoint the aggregator and kcl
agg.checkpoint();
checkpointer.checkpoint(records.get(records.size() - 1));
LOG.debug("Kinesis Checkpoint for Shard " + kinesisShardId
+ " Complete");
} catch (Exception e) {
e.printStackTrace();
LOG.error(e);
shutdown(checkpointer, ShutdownReason.ZOMBIE);
}
}
示例5: processRecords
import com.amazonaws.services.kinesis.clientlibrary.interfaces.IRecordProcessorCheckpointer; //导入方法依赖的package包/类
@Override
public void processRecords(List<Record> list, IRecordProcessorCheckpointer irpc) {
_logger.info("Processing {} records", list.size());
for(Record r: list){
String data = new String(r.getData().array());
long seq = _buffer.next();
KinesisEvent evt = _buffer.get(seq);
evt.setData(data);
_buffer.publish(seq);
}
try{
irpc.checkpoint();
}
catch(InvalidStateException | KinesisClientLibDependencyException | ShutdownException | ThrottlingException ex){
_logger.warn("Exception while checkpointing", ex);
}
}
示例6: shutdown
import com.amazonaws.services.kinesis.clientlibrary.interfaces.IRecordProcessorCheckpointer; //导入方法依赖的package包/类
@Override
@SneakyThrows
public void shutdown(ShutdownInput shutdownInput) {
IRecordProcessorCheckpointer checkpointer = shutdownInput.getCheckpointer();
ShutdownReason reason = shutdownInput.getShutdownReason();
log.info("Finalizado trabajo: {}.", reason);
checkpointer.checkpoint();
}
示例7: performCheckpoint
import com.amazonaws.services.kinesis.clientlibrary.interfaces.IRecordProcessorCheckpointer; //导入方法依赖的package包/类
private void performCheckpoint(IRecordProcessorCheckpointer checkpointer) {
try {
checkpointer.checkpoint();
} catch (Exception ex) {
System.out.println("Sky is falling! Why? " + ex);
}
}
示例8: processRecords
import com.amazonaws.services.kinesis.clientlibrary.interfaces.IRecordProcessorCheckpointer; //导入方法依赖的package包/类
@Override
public void processRecords(List<Record> records, IRecordProcessorCheckpointer checkpointer) {
for (Record record : records) {
producer.send(messageFactory.createMessage(record, topic));
if(++checkpointCounter % checkpointFrequency == 0) {
try {
checkpointer.checkpoint();
} catch(Exception e) {
e.printStackTrace();
}
}
}
}
开发者ID:gnethercutt,项目名称:dynamodb-streams-kafka,代码行数:16,代码来源:KafkaForwardingStreamsRecordProcessor.java
示例9: shutdown
import com.amazonaws.services.kinesis.clientlibrary.interfaces.IRecordProcessorCheckpointer; //导入方法依赖的package包/类
@Override
public void shutdown(IRecordProcessorCheckpointer checkpointer, ShutdownReason reason) {
if(reason == ShutdownReason.TERMINATE) {
try {
checkpointer.checkpoint();
} catch (Exception e) {
e.printStackTrace();
}
}
}
开发者ID:gnethercutt,项目名称:dynamodb-streams-kafka,代码行数:11,代码来源:KafkaForwardingStreamsRecordProcessor.java
示例10: finishBatch
import com.amazonaws.services.kinesis.clientlibrary.interfaces.IRecordProcessorCheckpointer; //导入方法依赖的package包/类
private void finishBatch(IRecordProcessorCheckpointer checkpointer, Record checkpointRecord) {
try {
if (!context.processBatch(batchContext, shardId, KinesisUtil.createKinesisRecordId(shardId, checkpointRecord))) {
throw Throwables.propagate(new StageException(Errors.KINESIS_04));
}
// Checkpoint iff batch processing succeeded
checkpointer.checkpoint(checkpointRecord);
if (LOG.isDebugEnabled()) {
LOG.debug("Checkpointed batch at record {}", checkpointRecord.toString());
}
} catch (InvalidStateException | ShutdownException e) {
LOG.error("Error checkpointing batch: {}", e.toString(), e);
}
}
示例11: processRecords
import com.amazonaws.services.kinesis.clientlibrary.interfaces.IRecordProcessorCheckpointer; //导入方法依赖的package包/类
@Override
public void processRecords(List<Record> records,
IRecordProcessorCheckpointer checkpointer) {
for(Record record : records) {
String data = new String(record.getData().array(), Charset.forName("UTF-8"));
System.out.println(data);
if(record instanceof RecordAdapter) {
com.amazonaws.services.dynamodbv2.model.Record streamRecord = ((RecordAdapter) record).getInternalObject();
switch(streamRecord.getEventName()) {
case "INSERT" : case "MODIFY" :
StreamsAdapterDemoHelper.putItem(dynamoDBClient, tableName, streamRecord.getDynamodb().getNewImage());
break;
case "REMOVE" :
StreamsAdapterDemoHelper.deleteItem(dynamoDBClient, tableName, streamRecord.getDynamodb().getKeys().get("Id").getN());
}
}
checkpointCounter += 1;
if(checkpointCounter % 10 == 0) {
try {
checkpointer.checkpoint();
} catch(Exception e) {
e.printStackTrace();
}
}
}
}
示例12: shutdown
import com.amazonaws.services.kinesis.clientlibrary.interfaces.IRecordProcessorCheckpointer; //导入方法依赖的package包/类
@Override
public void shutdown(IRecordProcessorCheckpointer checkpointer,
ShutdownReason reason) {
if(reason == ShutdownReason.TERMINATE) {
try {
checkpointer.checkpoint();
} catch (Exception e) {
e.printStackTrace();
}
}
}