software.amazon.awssdk.services.kinesis.model.CreateStreamRequest Java Examples

The following examples show how to use software.amazon.awssdk.services.kinesis.model.CreateStreamRequest. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: IntegrationTestBase.java    From aws-sdk-java-v2 with Apache License 2.0 6 votes vote down vote up
protected static void createKinesisStream() {
    kinesis = KinesisClient.builder().credentialsProvider(CREDENTIALS_PROVIDER_CHAIN).region(Region.US_WEST_2).build();

    kinesis.createStream(CreateStreamRequest.builder().streamName(KINESIS_STREAM_NAME).shardCount(1).build());

    StreamDescription description = kinesis.describeStream(DescribeStreamRequest.builder().streamName(KINESIS_STREAM_NAME).build())
            .streamDescription();
    streamArn = description.streamARN();

    // Wait till stream is active (less than a minute)
    Instant start = Instant.now();
    while (StreamStatus.ACTIVE != description.streamStatus()) {
        if (Duration.between(start, Instant.now()).toMillis() > MAX_WAIT_TIME.toMillis()) {
            throw new RuntimeException("Timed out waiting for stream to become active");
        }
        try {
            Thread.sleep(5000);
        } catch (InterruptedException ignored) {
            // Ignored or expected.
        }

        description = kinesis.describeStream(DescribeStreamRequest.builder().streamName(KINESIS_STREAM_NAME).build())
                .streamDescription();
    }
}
 
Example #2
Source File: ShardSyncTaskIntegrationTest.java    From amazon-kinesis-client with Apache License 2.0 6 votes vote down vote up
@BeforeClass
    public static void setUpBeforeClass() throws Exception {
//        ClientAsyncHttpConfiguration configuration = ClientAsyncHttpConfiguration.builder().httpClientFactory(
//                NettySdkHttpClientFactory.builder().trustAllCertificates(true).maxConnectionsPerEndpoint(10).build())
//                .build();
//        kinesisClient = KinesisAsyncClient.builder().asyncHttpConfiguration(configuration)
//                .endpointOverride(new URI("https://aws-kinesis-alpha.corp.amazon.com")).region(Region.US_EAST_1)
//                .build();
//
        try {
            CreateStreamRequest req = CreateStreamRequest.builder().streamName(STREAM_NAME).shardCount(1).build();
            kinesisClient.createStream(req);
        } catch (KinesisException ase) {
            ase.printStackTrace();
        }
        StreamStatus status;
//        do {
//            status = StreamStatus.fromValue(kinesisClient.describeStreamSummary(
//                    DescribeStreamSummaryRequest.builder().streamName(STREAM_NAME).build()).get()
//                    .streamDescriptionSummary().streamStatusString());
//        } while (status != StreamStatus.ACTIVE);
//
    }
 
Example #3
Source File: CreateDataStream.java    From aws-doc-sdk-examples with Apache License 2.0 5 votes vote down vote up
public static void createStream(KinesisClient kinesisClient, String streamName) {

        try {
            CreateStreamRequest streamReq = CreateStreamRequest.builder()
                    .streamName(streamName)
                    .shardCount(1)
                    .build();

            kinesisClient.createStream(streamReq);
        } catch (KinesisException e) {
            System.err.println(e.getMessage());
            System.exit(1);
        }
        System.out.println("Done");
    }
 
Example #4
Source File: KinesisIntegrationTests.java    From aws-sdk-java-v2 with Apache License 2.0 4 votes vote down vote up
@Test
public void testKinesisOperations() throws Exception {
    String streamName = "java-test-stream-" + System.currentTimeMillis();
    boolean created = false;

    try {

        // Create a stream with one shard.
        System.out.println("Creating Stream...");
        client.createStream(CreateStreamRequest.builder().streamName(streamName).shardCount(1).build());
        System.out.println("  OK");
        created = true;

        // Verify that it shows up in a list call.
        findStreamInList(streamName);

        // Wait for it to become ACTIVE.
        System.out.println("Waiting for stream to become active...");
        List<Shard> shards = waitForStream(streamName);
        System.out.println("  OK");

        Assert.assertEquals(1, shards.size());
        Shard shard = shards.get(0);

        // Just to be really sure in case of eventual consistency...
        Thread.sleep(5000);

        testPuts(streamName, shard);

        // Wait a bit to make sure the records propagate.
        Thread.sleep(5000);

        System.out.println("Reading...");
        testGets(streamName, shard);
        System.out.println("  OK");

    } finally {
        if (created) {
            client.deleteStream(DeleteStreamRequest.builder().streamName(streamName).build());
        }
    }
}