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


Java IRecordProcessorCheckpointer.checkpoint方法代码示例

本文整理汇总了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);
	}
}
 
开发者ID:awslabs,项目名称:aws-kinesis-beanstalk-workers,代码行数:19,代码来源:MyRecordProcessor.java

示例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());
        }
    }
}
 
开发者ID:capside,项目名称:aws-kinesis-zombies,代码行数:26,代码来源:ZombieRecordProcessor.java

示例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;
}
 
开发者ID:SumoLogic,项目名称:sumologic-kinesis-connector,代码行数:25,代码来源:KinesisConnectorRecordProcessor.java

示例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);
	}
}
 
开发者ID:awslabs,项目名称:amazon-kinesis-aggregators,代码行数:25,代码来源:AggregatorProcessor.java

示例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);
    }
}
 
开发者ID:InformaticaCorp,项目名称:Surf,代码行数:18,代码来源:RecordProcessor.java

示例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();
}
 
开发者ID:capside,项目名称:aws-kinesis-zombies,代码行数:9,代码来源:ZombieRecordProcessor.java

示例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);
    }
}
 
开发者ID:lenards,项目名称:spark-cstar-canaries,代码行数:8,代码来源:EventRecordProcessor.java

示例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);
  }
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:15,代码来源:StreamSetsRecordProcessor.java

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

}
 
开发者ID:awslabs,项目名称:aws-dynamodb-examples,代码行数:29,代码来源:StreamsRecordProcessor.java

示例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();
        }
    }
}
 
开发者ID:awslabs,项目名称:aws-dynamodb-examples,代码行数:12,代码来源:StreamsRecordProcessor.java


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