@Override public void processRecords(ProcessRecordsInput processRecordsInput) { logger.info("processRecords"); processRecordsInput.getRecords().forEach(record -> { KinesisRecord kr = new KinesisRecord(); kr.record = record; Event<KinesisRecord> event = Event.wrap(kr); getEventBus().notify(kr, event); boolean cp = checkpointStrategy.call(record); if (cp) { try { if (logger.isDebugEnabled()) { logger.debug("checkpointing app {} for stream {} at {}", kinesisConfig.getApplicationName(), kinesisConfig.getStreamName(), record.getSequenceNumber()); } processRecordsInput.getCheckpointer().checkpoint(record); } catch (RuntimeException | InvalidStateException | ShutdownException e) { logger.error("problem with checkpoint", e); } } }); }
logger.info("appName : {}", kinesisConfig.getApplicationName()); logger.info("streamName: {}", kinesisConfig.getStreamName()); logger.info("regionName: {}", kinesisConfig.getRegionName());
/** * @param propertiesFile The location of the properties file. * @param classLoader A classloader, useful if trying to programmatically configure with the daemon, such as in a * unit test. * @param configurator A configurator to use. * @throws IOException Thrown when the properties file can't be accessed. * @throws IllegalArgumentException Thrown when the contents of the properties file are not as expected. */ public MultiLangDaemonConfig(String propertiesFile, ClassLoader classLoader, KinesisClientLibConfigurator configurator) throws IOException, IllegalArgumentException { Properties properties = loadProperties(classLoader, propertiesFile); if (!validateProperties(properties)) { throw new IllegalArgumentException( "Must provide an executable name in the properties file, " + "e.g. executableName = sampleapp.py"); } String executableName = properties.getProperty(PROP_EXECUTABLE_NAME); String processingLanguage = properties.getProperty(PROP_PROCESSING_LANGUAGE); ClientConfiguration clientConfig = buildClientConfig(properties); kinesisClientLibConfig = configurator.getConfiguration(properties).withKinesisClientConfig(clientConfig) .withCloudWatchClientConfig(clientConfig).withDynamoDBClientConfig(clientConfig); executorService = buildExecutorService(properties); recordProcessorFactory = new MultiLangRecordProcessorFactory(executableName, executorService, kinesisClientLibConfig); LOG.info("Running " + kinesisClientLibConfig.getApplicationName() + " to process stream " + kinesisClientLibConfig.getStreamName() + " with executable " + executableName); prepare(processingLanguage); }
config.getApplicationName(), config.getStreamName(), config.getRegionName(), config.getWorkerIdentifier(),
config.getApplicationName(), this.getNamespace());
/** * Given configuration, returns appropriate metrics factory. * * @param cloudWatchClient * Amazon CloudWatch client * @param config * KinesisClientLibConfiguration * @return Returns metrics factory based on the config. */ private static IMetricsFactory getMetricsFactory(AmazonCloudWatch cloudWatchClient, KinesisClientLibConfiguration config) { IMetricsFactory metricsFactory; if (config.getMetricsLevel() == MetricsLevel.NONE) { metricsFactory = new NullMetricsFactory(); } else { if (config.getRegionName() != null) { setField(cloudWatchClient, "region", cloudWatchClient::setRegion, RegionUtils.getRegion(config.getRegionName())); } metricsFactory = new WorkerCWMetricsFactory(cloudWatchClient, config.getApplicationName(), config.getMetricsBufferTimeMillis(), config.getMetricsMaxQueueSize(), config.getMetricsLevel(), config.getMetricsEnabledDimensions()); } return metricsFactory; }
KinesisClientLibConfiguration config, AmazonKinesis kinesisClient, AmazonDynamoDB dynamoDBClient, IMetricsFactory metricsFactory, ExecutorService execService) { this(config.getApplicationName(), new V1ToV2RecordProcessorFactoryAdapter(recordProcessorFactory), config, new StreamConfig(
return new Worker(config.getApplicationName(), recordProcessorFactory, config,