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


Java IRecordProcessorCheckpointer类代码示例

本文整理汇总了Java中com.amazonaws.services.kinesis.clientlibrary.interfaces.IRecordProcessorCheckpointer的典型用法代码示例。如果您正苦于以下问题:Java IRecordProcessorCheckpointer类的具体用法?Java IRecordProcessorCheckpointer怎么用?Java IRecordProcessorCheckpointer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


IRecordProcessorCheckpointer类属于com.amazonaws.services.kinesis.clientlibrary.interfaces包,在下文中一共展示了IRecordProcessorCheckpointer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: shutdown

import com.amazonaws.services.kinesis.clientlibrary.interfaces.IRecordProcessorCheckpointer; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void shutdown(IRecordProcessorCheckpointer checkpointer,
		ShutdownReason reason) {
	LOG.info("Shutting down record processor for shard: " + kinesisShardId);

	// Important to checkpoint after reaching end of shard, so we can start
	// processing data from child shards.
	if (reason == ShutdownReason.TERMINATE) {
		try {
			checkpoint(checkpointer);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
 
开发者ID:awslabs,项目名称:aws-kinesis-beanstalk-workers,代码行数:19,代码来源:ManagedClientProcessor.java

示例3: 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

示例4: generateRecords

import com.amazonaws.services.kinesis.clientlibrary.interfaces.IRecordProcessorCheckpointer; //导入依赖的package包/类
static Map<KinesisRecordProcessor, List<Record>> generateRecords(int numRecordsPerShard,
    List<KinesisRecordProcessor> processors) throws ShutdownException, InvalidStateException {
  Map<KinesisRecordProcessor, List<Record>> processorRecordMap = new HashMap<>();
  processors.forEach(processor -> {
      try {
        // Create records and call process records
        IRecordProcessorCheckpointer checkpointer = Mockito.mock(IRecordProcessorCheckpointer.class);
        doNothing().when(checkpointer).checkpoint(anyString());
        doNothing().when(checkpointer).checkpoint();
        ProcessRecordsInput processRecordsInput = Mockito.mock(ProcessRecordsInput.class);
        when(processRecordsInput.getCheckpointer()).thenReturn(checkpointer);
        when(processRecordsInput.getMillisBehindLatest()).thenReturn(1000L);
        List<Record> inputRecords = createRecords(numRecordsPerShard);
        processorRecordMap.put(processor, inputRecords);
        when(processRecordsInput.getRecords()).thenReturn(inputRecords);
        processor.processRecords(processRecordsInput);
      } catch (ShutdownException | InvalidStateException ex) {
        throw new RuntimeException(ex);
      }
    });
  return processorRecordMap;
}
 
开发者ID:apache,项目名称:samza,代码行数:23,代码来源:TestKinesisRecordProcessor.java

示例5: 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

示例6: processRecords

import com.amazonaws.services.kinesis.clientlibrary.interfaces.IRecordProcessorCheckpointer; //导入依赖的package包/类
@Override
public void processRecords(List<Record> arg0, IRecordProcessorCheckpointer arg1) {
	counter += arg0.size();
	if (counter > target) {
		System.out.println("Received : " + counter + " records");
		target += target;
	}
	Record rec;
	for(int i = 0; i < arg0.size(); i++) {
		rec = arg0.get(i);
		try {
			verifyRecord(rec.getData());
		} 
		catch (JSONException | UnsupportedEncodingException e) {
			e.printStackTrace();
		}
	}
}
 
开发者ID:tyagihas,项目名称:awsbigdata,代码行数:19,代码来源:Processor.java

示例7: 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

示例8: 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

示例9: processRecords

import com.amazonaws.services.kinesis.clientlibrary.interfaces.IRecordProcessorCheckpointer; //导入依赖的package包/类
@Override
public void processRecords(List<Record> records, IRecordProcessorCheckpointer checkpointer) {
    records.forEach(record -> {
        byte[] bytes = new byte[record.getData().remaining()];
        record.getData().get(bytes);
        System.out.write(bytes, 0, bytes.length);
        System.out.println();
    });
}
 
开发者ID:trulia,项目名称:stail,代码行数:10,代码来源:RawRecordProcessor.java

示例10: processRecords

import com.amazonaws.services.kinesis.clientlibrary.interfaces.IRecordProcessorCheckpointer; //导入依赖的package包/类
@Override
public void processRecords(List<Record> records, IRecordProcessorCheckpointer checkpointer) {
    records.forEach(record -> {
        try {
            byte[] bytes = new byte[record.getData().remaining()];
            record.getData().get(bytes);
            System.out.println(mapper.writeValueAsString(mapper.readTree(bytes)));
        } catch (IOException e) {
            logger.error("", e);
        }
    });
}
 
开发者ID:trulia,项目名称:stail,代码行数:13,代码来源:JSONRecordProcessor.java

示例11: 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

示例12: processRecords

import com.amazonaws.services.kinesis.clientlibrary.interfaces.IRecordProcessorCheckpointer; //导入依赖的package包/类
@Override
public void processRecords(List<Record> records, IRecordProcessorCheckpointer iRecordProcessorCheckpointer) {
    try {
        logger.info("Start processing records");

        processRecordsWithRetries(records);

        if (System.currentTimeMillis() > nextCheckpointTimeInMillis) {
            checkpoint(iRecordProcessorCheckpointer);
            nextCheckpointTimeInMillis = System.currentTimeMillis() + CHECKPOINT_INTERVAL_MILLIS;
        }
    } catch (InvalidProtocolBufferException exc) {
        logger.error(exc);
    }
}
 
开发者ID:SaschaMoellering,项目名称:ingestion-service,代码行数:16,代码来源:RecordProcessor.java

示例13: shutdown

import com.amazonaws.services.kinesis.clientlibrary.interfaces.IRecordProcessorCheckpointer; //导入依赖的package包/类
@Override
public void shutdown(IRecordProcessorCheckpointer iRecordProcessorCheckpointer, ShutdownReason shutdownReason) {

    if (producer != null) {
        producer.close();
    }

    logger.info("Shutting down record processor for shard: " + shardId);
    // Important to checkpoint after reaching end of shard, so we can start processing data from child shards.
    if (shutdownReason == ShutdownReason.TERMINATE) {
        checkpoint(iRecordProcessorCheckpointer);
    }
}
 
开发者ID:SaschaMoellering,项目名称:ingestion-service,代码行数:14,代码来源:RecordProcessor.java

示例14: processRecords

import com.amazonaws.services.kinesis.clientlibrary.interfaces.IRecordProcessorCheckpointer; //导入依赖的package包/类
@Override
public void processRecords(List<Record> records,
                           IRecordProcessorCheckpointer checkpointer) {
    if (!receiver.isStopped()) {
        // this processor works in tandem with the Spark Streaming receiver
        handleRecords(records);
        checkpointIfNeeded(checkpointer);
    }
}
 
开发者ID:lenards,项目名称:spark-cstar-canaries,代码行数:10,代码来源:EventRecordProcessor.java

示例15: shutdown

import com.amazonaws.services.kinesis.clientlibrary.interfaces.IRecordProcessorCheckpointer; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void shutdown(IRecordProcessorCheckpointer checkpointer, ShutdownReason reason) {
    // Important to checkpoint after reaching end of shard,
    // so we can start processing data from child shards.
    if (reason == ShutdownReason.TERMINATE) {
        performCheckpoint(checkpointer);
    }
}
 
开发者ID:lenards,项目名称:spark-cstar-canaries,代码行数:12,代码来源:EventRecordProcessor.java


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