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


Java AmazonKinesis类代码示例

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


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

示例1: getShards

import com.amazonaws.services.kinesis.AmazonKinesis; //导入依赖的package包/类
private static List<Shard> getShards(AmazonKinesis client, String stream) {
    DescribeStreamRequest describeStreamRequest = new DescribeStreamRequest();
    describeStreamRequest.setStreamName(stream);
    List<Shard> shards = new ArrayList<>();
    String exclusiveStartShardId = null;
    do {
        describeStreamRequest.setExclusiveStartShardId(exclusiveStartShardId);
        DescribeStreamResult describeStreamResult = client.describeStream(describeStreamRequest);
        shards.addAll(describeStreamResult.getStreamDescription().getShards());
        if (describeStreamResult.getStreamDescription().getHasMoreShards() && shards.size() > 0) {
            exclusiveStartShardId = shards.get(shards.size() - 1).getShardId();
        } else {
            exclusiveStartShardId = null;
        }
    } while (exclusiveStartShardId != null);

    return shards;
}
 
开发者ID:trulia,项目名称:stail,代码行数:19,代码来源:Stail.java

示例2: testProvisionProducerSuccessfulWithExistingStream

import com.amazonaws.services.kinesis.AmazonKinesis; //导入依赖的package包/类
@Test
public void testProvisionProducerSuccessfulWithExistingStream() {
	AmazonKinesis amazonKinesisMock = mock(AmazonKinesis.class);
	KinesisBinderConfigurationProperties binderProperties = new KinesisBinderConfigurationProperties();
	KinesisStreamProvisioner provisioner = new KinesisStreamProvisioner(amazonKinesisMock, binderProperties);
	ExtendedProducerProperties<KinesisProducerProperties> extendedProducerProperties =
			new ExtendedProducerProperties<>(new KinesisProducerProperties());
	String name = "test-stream";

	DescribeStreamResult describeStreamResult = describeStreamResultWithShards(
			Collections.singletonList(new Shard()));

	when(amazonKinesisMock.describeStream(any(DescribeStreamRequest.class)))
			.thenReturn(describeStreamResult);

	ProducerDestination destination = provisioner.provisionProducerDestination(name, extendedProducerProperties);

	verify(amazonKinesisMock)
			.describeStream(any(DescribeStreamRequest.class));

	assertThat(destination.getName()).isEqualTo(name);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream-binder-aws-kinesis,代码行数:23,代码来源:KinesisStreamProvisionerTests.java

示例3: testProvisionConsumerSuccessfulWithExistingStream

import com.amazonaws.services.kinesis.AmazonKinesis; //导入依赖的package包/类
@Test
public void testProvisionConsumerSuccessfulWithExistingStream() {
	AmazonKinesis amazonKinesisMock = mock(AmazonKinesis.class);
	KinesisBinderConfigurationProperties binderProperties = new KinesisBinderConfigurationProperties();
	KinesisStreamProvisioner provisioner = new KinesisStreamProvisioner(amazonKinesisMock, binderProperties);

	ExtendedConsumerProperties<KinesisConsumerProperties> extendedConsumerProperties =
			new ExtendedConsumerProperties<>(new KinesisConsumerProperties());

	String name = "test-stream";
	String group = "test-group";

	DescribeStreamResult describeStreamResult =
			describeStreamResultWithShards(Collections.singletonList(new Shard()));

	when(amazonKinesisMock.describeStream(any(DescribeStreamRequest.class)))
			.thenReturn(describeStreamResult);

	ConsumerDestination destination =
			provisioner.provisionConsumerDestination(name, group, extendedConsumerProperties);

	verify(amazonKinesisMock)
			.describeStream(any(DescribeStreamRequest.class));

	assertThat(destination.getName()).isEqualTo(name);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream-binder-aws-kinesis,代码行数:27,代码来源:KinesisStreamProvisionerTests.java

示例4: before

import com.amazonaws.services.kinesis.AmazonKinesis; //导入依赖的package包/类
@BeforeEach
public void before() {
  this.sourceTaskContext = mock(SourceTaskContext.class);
  this.offsetStorageReader = mock(OffsetStorageReader.class);
  when(this.sourceTaskContext.offsetStorageReader()).thenReturn(this.offsetStorageReader);
  this.task = new KinesisSourceTask();
  this.task.initialize(this.sourceTaskContext);
  this.kinesisClient = mock(AmazonKinesis.class);
  this.task.time = mock(Time.class);
  this.task.kinesisClientFactory = mock(KinesisClientFactory.class);
  when(this.task.kinesisClientFactory.create(any())).thenReturn(this.kinesisClient);

  this.settings = TestData.settings();
  this.config = new KinesisSourceConnectorConfig(this.settings);

}
 
开发者ID:jcustenborder,项目名称:kafka-connect-kinesis,代码行数:17,代码来源:KinesisSourceTaskTest.java

示例5: KinesisStreamFactory

import com.amazonaws.services.kinesis.AmazonKinesis; //导入依赖的package包/类
KinesisStreamFactory(Builder builder) {
  this.stream = builder.stream;
  this.app = builder.app;
  this.regionName = builder.awsRegion;
  this.endpoint = builder.awsEndpoint != null ?
      builder.awsEndpoint :
      Region.getRegion(Regions.fromName(regionName))
          .getServiceEndpoint(AmazonKinesis.ENDPOINT_PREFIX);

  this.checkpointInterval = builder.checkpointInterval;
  this.initialPositionInStream = builder.initialPositionInStream;
  this.storageLevel = builder.storageLevel;

  this.awsAccessKeyId = builder.awsAccessKeyId;
  this.awsSecretKey = builder.awsSecretKey;
}
 
开发者ID:openzipkin,项目名称:zipkin-aws,代码行数:17,代码来源:KinesisStreamFactory.java

示例6: getKinesisClient

import com.amazonaws.services.kinesis.AmazonKinesis; //导入依赖的package包/类
@Override
public AmazonKinesis getKinesisClient() {
  return new AmazonKinesisMock(transform(shardedData,
      new Function<List<TestData>, List<Record>>() {

        @Override
        public List<Record> apply(@Nullable List<TestData> testDatas) {
          return transform(testDatas, new Function<TestData, Record>() {

            @Override
            public Record apply(@Nullable TestData testData) {
              return testData.convertToRecord();
            }
          });
        }
      }), numberOfRecordsPerGet);

}
 
开发者ID:apache,项目名称:beam,代码行数:19,代码来源:AmazonKinesisMock.java

示例7: createKinesisClient

import com.amazonaws.services.kinesis.AmazonKinesis; //导入依赖的package包/类
/**
 * Creates an AmazonKinesis client.
 * @param configProps configuration properties containing the access key, secret key, and region
 * @return a new AmazonKinesis client
 */
public static AmazonKinesis createKinesisClient(Properties configProps) {
	// set a Flink-specific user agent
	ClientConfiguration awsClientConfig = new ClientConfigurationFactory().getConfig()
			.withUserAgentPrefix(String.format(USER_AGENT_FORMAT,
													EnvironmentInformation.getVersion(),
													EnvironmentInformation.getRevisionInformation().commitId));

	// utilize automatic refreshment of credentials by directly passing the AWSCredentialsProvider
	AmazonKinesisClientBuilder builder = AmazonKinesisClientBuilder.standard()
			.withCredentials(AWSUtil.getCredentialsProvider(configProps))
			.withClientConfiguration(awsClientConfig)
			.withRegion(Regions.fromName(configProps.getProperty(AWSConfigConstants.AWS_REGION)));

	if (configProps.containsKey(AWSConfigConstants.AWS_ENDPOINT)) {
		// Set signingRegion as null, to facilitate mocking Kinesis for local tests
		builder.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(
												configProps.getProperty(AWSConfigConstants.AWS_ENDPOINT),
												null));
	}
	return builder.build();
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:27,代码来源:AWSUtil.java

示例8: main

import com.amazonaws.services.kinesis.AmazonKinesis; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    verify(args);
    String stream = args[0];
    Region region = RegionUtils.getRegion(args[1]);

    AWSCredentials credentials = getCreds();
    AmazonKinesis client = new AmazonKinesisClient(credentials, CLIENT_CONF);
    client.setRegion(region);
    checkStream(client.describeStream(stream));

    System.out.println("Let's start putting records!");
    Random rnd = new Random(System.currentTimeMillis());
    for (;;) {
        putEventRecord(client, stream);
        Thread.sleep(rnd.nextInt(500) + 650);
    }
}
 
开发者ID:lenards,项目名称:spark-cstar-canaries,代码行数:18,代码来源:Producer.java

示例9: scanKinesis

import com.amazonaws.services.kinesis.AmazonKinesis; //导入依赖的package包/类
/**
 * Collect data for Kinesis.
 *
 * @param stats
 *            current statistics object.
 * @param account
 *            currently used credentials object.
 * @param region
 *            currently used aws region.
 */
public static void scanKinesis(AwsStats stats, AwsAccount account, Regions region) {
	LOG.debug("Scan for Kinesis in region " + region.getName() + " in account " + account.getAccountId());

	try {
		AmazonKinesis kinesis = new AmazonKinesisClient(account.getCredentials());
		kinesis.setRegion(Region.getRegion(region));

		List<String> list = kinesis.listStreams().getStreamNames();

		int totalItems = list.size();
		for (String streamName : list) {
			stats.add(new AwsResource(streamName, account.getAccountId(), AwsResourceType.Kinesis, region));
		}

		LOG.info(totalItems + " Kinesis streams in region " + region.getName() + " in account " + account.getAccountId());
	} catch (AmazonServiceException ase) {
		LOG.error("Exception of Kinesis: " + ase.getMessage());
	}
}
 
开发者ID:janloeffler,项目名称:aws-utilization-monitor,代码行数:30,代码来源:AwsScan.java

示例10: getPreviewRecords

import com.amazonaws.services.kinesis.AmazonKinesis; //导入依赖的package包/类
public static List<com.amazonaws.services.kinesis.model.Record> getPreviewRecords(
    ClientConfiguration awsClientConfig,
    KinesisConfigBean conf,
    int maxBatchSize,
    GetShardIteratorRequest getShardIteratorRequest
) throws StageException {
  AmazonKinesis kinesisClient = getKinesisClient(awsClientConfig, conf);

  GetShardIteratorResult getShardIteratorResult = kinesisClient.getShardIterator(getShardIteratorRequest);
  String shardIterator = getShardIteratorResult.getShardIterator();

  GetRecordsRequest getRecordsRequest = new GetRecordsRequest();
  getRecordsRequest.setShardIterator(shardIterator);
  getRecordsRequest.setLimit(maxBatchSize);

  GetRecordsResult getRecordsResult = kinesisClient.getRecords(getRecordsRequest);
  return getRecordsResult.getRecords();
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:19,代码来源:KinesisUtil.java

示例11: run

import com.amazonaws.services.kinesis.AmazonKinesis; //导入依赖的package包/类
private void run(final int events, final OutputFormat format,
		final String streamName, final String region) throws Exception {
	AmazonKinesis kinesisClient = new AmazonKinesisClient(
			new DefaultAWSCredentialsProviderChain());
	kinesisClient.setRegion(Region.getRegion(Regions.fromName(region)));
	int count = 0;
	SensorReading r = null;
	do {
		r = nextSensorReading(format);

		try {
			PutRecordRequest req = new PutRecordRequest()
					.withPartitionKey("" + rand.nextLong())
					.withStreamName(streamName)
					.withData(ByteBuffer.wrap(r.toString().getBytes()));
			kinesisClient.putRecord(req);
		} catch (ProvisionedThroughputExceededException e) {
			Thread.sleep(BACKOFF);
		}

		System.out.println(r);
		count++;
	} while (count < events);
}
 
开发者ID:awslabs,项目名称:amazon-kinesis-aggregators,代码行数:25,代码来源:SensorReadingProducer.java

示例12: getShardIterator

import com.amazonaws.services.kinesis.AmazonKinesis; //导入依赖的package包/类
private static String getShardIterator(AmazonKinesis client, String stream, Shard shard, String start) {
    GetShardIteratorRequest getShardIteratorRequest = new GetShardIteratorRequest();
    getShardIteratorRequest.setStreamName(stream);
    getShardIteratorRequest.setShardId(shard.getShardId());

    if (!Strings.isNullOrEmpty(start)) {
        getShardIteratorRequest.setShardIteratorType(ShardIteratorType.AT_TIMESTAMP);
        getShardIteratorRequest.setTimestamp(new Date(System.currentTimeMillis() - Duration.parse(start).toMillis()));
    } else {
        getShardIteratorRequest.setShardIteratorType(ShardIteratorType.LATEST);
    }

    GetShardIteratorResult getShardIteratorResult = client.getShardIterator(getShardIteratorRequest);
    return getShardIteratorResult.getShardIterator();
}
 
开发者ID:trulia,项目名称:stail,代码行数:16,代码来源:Stail.java

示例13: getShardIteratorAtSequenceNumber

import com.amazonaws.services.kinesis.AmazonKinesis; //导入依赖的package包/类
private static String getShardIteratorAtSequenceNumber(AmazonKinesis client, String stream, Shard shard, String sequenceNumber) {
    GetShardIteratorRequest getShardIteratorRequest = new GetShardIteratorRequest();
    getShardIteratorRequest.setStreamName(stream);
    getShardIteratorRequest.setShardId(shard.getShardId());

    getShardIteratorRequest.setShardIteratorType(ShardIteratorType.AT_SEQUENCE_NUMBER);
    getShardIteratorRequest.setStartingSequenceNumber(sequenceNumber);

    GetShardIteratorResult getShardIteratorResult = client.getShardIterator(getShardIteratorRequest);
    return getShardIteratorResult.getShardIterator();
}
 
开发者ID:trulia,项目名称:stail,代码行数:12,代码来源:Stail.java

示例14: getOldestShardIterator

import com.amazonaws.services.kinesis.AmazonKinesis; //导入依赖的package包/类
private static String getOldestShardIterator(AmazonKinesis client, String stream, Shard shard) {
    GetShardIteratorRequest getShardIteratorRequest = new GetShardIteratorRequest();
    getShardIteratorRequest.setStreamName(stream);
    getShardIteratorRequest.setShardId(shard.getShardId());
    getShardIteratorRequest.setShardIteratorType(ShardIteratorType.TRIM_HORIZON);

    GetShardIteratorResult getShardIteratorResult = client.getShardIterator(getShardIteratorRequest);
    return getShardIteratorResult.getShardIterator();
}
 
开发者ID:trulia,项目名称:stail,代码行数:10,代码来源:Stail.java

示例15: createAWSClient

import com.amazonaws.services.kinesis.AmazonKinesis; //导入依赖的package包/类
@Override
protected void createAWSClient()
{
    client = tryClientFactory(config.clientFactoryMethod, AmazonKinesis.class, true);
    if ((client == null) && (config.clientEndpoint == null))
    {
        client = tryClientFactory("com.amazonaws.services.kinesis.AmazonKinesisClientBuilder.defaultClient", AmazonKinesis.class, false);
    }
    if (client == null)
    {
        LogLog.debug(getClass().getSimpleName() + ": creating service client via constructor");
        client = tryConfigureEndpointOrRegion(new AmazonKinesisClient(), config.clientEndpoint);
    }
}
 
开发者ID:kdgregory,项目名称:log4j-aws-appenders,代码行数:15,代码来源:KinesisLogWriter.java


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