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


Java InitialPositionInStream.valueOf方法代码示例

本文整理汇总了Java中com.amazonaws.services.kinesis.clientlibrary.lib.worker.InitialPositionInStream.valueOf方法的典型用法代码示例。如果您正苦于以下问题:Java InitialPositionInStream.valueOf方法的具体用法?Java InitialPositionInStream.valueOf怎么用?Java InitialPositionInStream.valueOf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.amazonaws.services.kinesis.clientlibrary.lib.worker.InitialPositionInStream的用法示例。


在下文中一共展示了InitialPositionInStream.valueOf方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: KinesisEventConsumer

import com.amazonaws.services.kinesis.clientlibrary.lib.worker.InitialPositionInStream; //导入方法依赖的package包/类
public KinesisEventConsumer(String propertiesFile, String streamName, String appName, String initialPosition) {
    KinesisProducerConfiguration config = KinesisProducerConfiguration.fromPropertiesFile(propertiesFile);

    InitialPositionInStream position = InitialPositionInStream.valueOf(initialPosition);
    
    KinesisClientLibConfiguration clientConfig = new KinesisClientLibConfiguration(appName, streamName,
            new DefaultAWSCredentialsProviderChain(), appName)
                    .withRegionName(config.getRegion())
                    .withInitialPositionInStream(position);
    
    this.builder = new Worker.Builder().recordProcessorFactory(this).config(clientConfig);
}
 
开发者ID:monetate,项目名称:koupler,代码行数:13,代码来源:KinesisEventConsumer.java

示例2: loadProperties

import com.amazonaws.services.kinesis.clientlibrary.lib.worker.InitialPositionInStream; //导入方法依赖的package包/类
/**
 * @param propertiesFile
 * @throws IOException Thrown when we run into issues reading properties
 */
private static void loadProperties(String propertiesFile) throws IOException {
    FileInputStream inputStream = new FileInputStream(propertiesFile);
    Properties properties = new Properties();
    try {
        properties.load(inputStream);
    } finally {
        inputStream.close();
    }
    
    String appNameOverride = properties.getProperty(ConfigKeys.APPLICATION_NAME_KEY);
    if (appNameOverride != null) {
        applicationName = appNameOverride;
    }
    LOG.info("Using application name " + applicationName);
    
    String streamNameOverride = properties.getProperty(ConfigKeys.STREAM_NAME_KEY);
    if (streamNameOverride != null) {
        streamName = streamNameOverride;
    }
    LOG.info("Using stream name " + streamName);
    
    String kinesisEndpointOverride = properties.getProperty(ConfigKeys.KINESIS_ENDPOINT_KEY);
    if (kinesisEndpointOverride != null) {
        kinesisEndpoint = kinesisEndpointOverride;
    }
    String initialPositionOverride = properties.getProperty(ConfigKeys.INITIAL_POSITION_IN_STREAM_KEY);
    if (initialPositionOverride != null) {
         initialPositionInStream = InitialPositionInStream.valueOf(initialPositionOverride);
    }
     LOG.info("Using initial position " + initialPositionInStream.toString() + " (if a checkpoint is not found).");
}
 
开发者ID:dselman,项目名称:tweetamo,代码行数:36,代码来源:TweetamoServer.java

示例3: configure

import com.amazonaws.services.kinesis.clientlibrary.lib.worker.InitialPositionInStream; //导入方法依赖的package包/类
public void configure() throws Exception {
    if (!isConfigured) {
        validateConfig();

        try {
            String userAgent = "AWSKinesisManagedConsumer/" + this.version;

            if (this.positionInStream != null) {
                streamPosition = InitialPositionInStream.valueOf(this.positionInStream);
            } else {
                streamPosition = InitialPositionInStream.LATEST;
            }

            // append the environment name to the application name
            if (environmentName != null) {
                appName = String.format("%s-%s", appName, environmentName);
            }

            // ensure the JVM will refresh the cached IP values of AWS
            // resources
            // (e.g. service endpoints).
            java.security.Security.setProperty("networkaddress.cache.ttl", "60");

            String workerId = NetworkInterface.getNetworkInterfaces() + ":" + UUID.randomUUID();
            LOG.info("Using Worker ID: " + workerId);

            // obtain credentials using the default provider chain or the
            // credentials provider supplied
            AWSCredentialsProvider credentialsProvider = this.credentialsProvider == null ? new DefaultAWSCredentialsProviderChain()
                    : this.credentialsProvider;

            LOG.info("Using credentials with Access Key ID: "
                    + credentialsProvider.getCredentials().getAWSAccessKeyId());

            config = new KinesisClientLibConfiguration(appName, streamName,
                    credentialsProvider, workerId).withInitialPositionInStream(streamPosition).withKinesisEndpoint(
                    kinesisEndpoint);

            config.getKinesisClientConfiguration().setUserAgent(userAgent);

            if (regionName != null) {
                Region region = Region.getRegion(Regions.fromName(regionName));
                config.withRegionName(region.getName());
            }

            if (this.maxRecords != -1)
                config.withMaxRecords(maxRecords);

            if (this.positionInStream != null)
                config.withInitialPositionInStream(InitialPositionInStream.valueOf(this.positionInStream));

            LOG.info(String.format(
                    "Amazon Kinesis Managed Client prepared for %s on %s in %s (%s) using %s Max Records",
                    config.getApplicationName(), config.getStreamName(),
                    config.getRegionName(), config.getWorkerIdentifier(),
                    config.getMaxRecords()));

            isConfigured = true;
        } catch (Exception e) {
            throw new InvalidConfigurationException(e);
        }
    }
}
 
开发者ID:awslabs,项目名称:aws-kinesis-beanstalk-workers,代码行数:64,代码来源:ManagedConsumer.java

示例4: configure

import com.amazonaws.services.kinesis.clientlibrary.lib.worker.InitialPositionInStream; //导入方法依赖的package包/类
public void configure() throws Exception {
	if (!isConfigured) {
		validateConfig();

		if (this.positionInStream != null) {
			streamPosition = InitialPositionInStream
					.valueOf(this.positionInStream);
		} else {
			streamPosition = InitialPositionInStream.LATEST;
		}

		// append the environment name to the application name
		if (environmentName != null) {
			appName = String.format("%s-%s", appName, environmentName);
		}

		// ensure the JVM will refresh the cached IP values of AWS resources
		// (e.g. service endpoints).
		java.security.Security
				.setProperty("networkaddress.cache.ttl", "60");

		String workerId = NetworkInterface.getNetworkInterfaces() + ":"
				+ UUID.randomUUID();
		LOG.info("Using Worker ID: " + workerId);

		// obtain credentials using the default provider chain or the
		// credentials provider supplied
		AWSCredentialsProvider credentialsProvider = this.credentialsProvider == null ? new DefaultAWSCredentialsProviderChain()
				: this.credentialsProvider;

		LOG.info("Using credentials with Access Key ID: "
				+ credentialsProvider.getCredentials().getAWSAccessKeyId());

		config = new KinesisClientLibConfiguration(appName, streamName,
				credentialsProvider, workerId).withInitialPositionInStream(
				streamPosition).withKinesisEndpoint(kinesisEndpoint);

		config.getKinesisClientConfiguration().setUserAgent(
				StreamAggregator.AWSApplication);

		if (regionName != null) {
			Region region = Region.getRegion(Regions.fromName(regionName));
			config.withRegionName(region.getName());
		}

		if (maxRecords != -1)
			config.withMaxRecords(maxRecords);

		// initialise the Aggregators
		aggGroup = buildAggregatorsFromConfig();

		LOG.info(String
				.format("Amazon Kinesis Aggregators Managed Client prepared for %s on %s in %s (%s) using %s Max Records",
						config.getApplicationName(),
						config.getStreamName(), config.getRegionName(),
						config.getWorkerIdentifier(),
						config.getMaxRecords()));

		isConfigured = true;
	}
}
 
开发者ID:awslabs,项目名称:amazon-kinesis-aggregators,代码行数:62,代码来源:AggregatorConsumer.java

示例5: loadProperties

import com.amazonaws.services.kinesis.clientlibrary.lib.worker.InitialPositionInStream; //导入方法依赖的package包/类
/**
 * @param propertiesFile
 * @throws IOException Thrown when we run into issues reading properties
 */
private static void loadProperties(String propertiesFile) throws IOException {
    FileInputStream inputStream = new FileInputStream(propertiesFile);
    Properties properties = new Properties();
    try {
        properties.load(inputStream);
    } finally {
        inputStream.close();
    }

    String appNameOverride = properties.getProperty(ConfigKeys.APPLICATION_NAME_KEY);
    if (appNameOverride != null) {
        applicationName = appNameOverride;
    }
    LOG.info("Using application name " + applicationName);

    String streamNameOverride = properties.getProperty(ConfigKeys.STREAM_NAME_KEY);
    if (streamNameOverride != null) {
        streamName = streamNameOverride;
    }
    LOG.info("Using stream name " + streamName);

    String kinesisEndpointOverride = properties.getProperty(ConfigKeys.KINESIS_ENDPOINT_KEY);
    if (kinesisEndpointOverride != null) {
        kinesisEndpoint = kinesisEndpointOverride;
    }
    LOG.info("Using Kinesis endpoint " + kinesisEndpoint);
    
    String initialPositionOverride = properties.getProperty(ConfigKeys.INITIAL_POSITION_IN_STREAM_KEY);
    if (initialPositionOverride != null) {
         initialPositionInStream = InitialPositionInStream.valueOf(initialPositionOverride);
    }
    LOG.info("Using initial position " + initialPositionInStream.toString() + " (if a checkpoint is not found).");
    
    String redisEndpointOverride = properties.getProperty(ConfigKeys.REDIS_ENDPOINT);
    if (redisEndpointOverride != null) {
        redisEndpoint = redisEndpointOverride;
    }
    LOG.info("Using Redis endpoint " + redisEndpoint);
    
    String redisPortOverride = properties.getProperty(ConfigKeys.REDIS_PORT);
    if (redisPortOverride != null) {
    	try {
    		redisPort = Integer.parseInt(redisPortOverride);
    	} catch(Exception e) {
    		
    	}
    }
    LOG.info("Using Redis port " + redisPort);
     
}
 
开发者ID:awslabs,项目名称:aws-big-data-blog,代码行数:55,代码来源:KinesisApplication.java


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