List of usage examples for com.amazonaws.services.kinesis.model DescribeStreamRequest setLimit
public void setLimit(Integer limit)
The maximum number of shards to return in a single call.
From source file:whgHelper.java
License:Open Source License
private static void waitForStreamToBecomeAvailable(AmazonKinesisClient kinesis, String myStreamName) throws InterruptedException { System.out.printf("Waiting for %s to become ACTIVE...\n", myStreamName); long startTime = System.currentTimeMillis(); long endTime = startTime + TimeUnit.MINUTES.toMillis(10); while (System.currentTimeMillis() < endTime) { Thread.sleep(TimeUnit.SECONDS.toMillis(20)); try {//from w ww . ja v a2 s .c om DescribeStreamRequest describeStreamRequest = new DescribeStreamRequest(); describeStreamRequest.setStreamName(myStreamName); // ask for no more than 10 shards at a time -- this is an optional parameter describeStreamRequest.setLimit(10); DescribeStreamResult describeStreamResponse = kinesis.describeStream(describeStreamRequest); String streamStatus = describeStreamResponse.getStreamDescription().getStreamStatus(); System.out.printf("\t- current state: %s\n", streamStatus); if ("ACTIVE".equals(streamStatus)) { return; } } catch (ResourceNotFoundException ex) { // ResourceNotFound means the stream doesn't exist yet, // so ignore this error and just keep polling. } catch (AmazonServiceException ase) { throw ase; } } throw new RuntimeException(String.format("Stream %s never became active", myStreamName)); }
From source file:AmazonKinesisSample.java
License:Open Source License
private static void waitForStreamToBecomeAvailable(String myStreamName) { System.out.println("Waiting for " + myStreamName + " to become ACTIVE..."); long startTime = System.currentTimeMillis(); long endTime = startTime + (10 * 60 * 1000); while (System.currentTimeMillis() < endTime) { try {//from w w w . j av a 2 s.c om Thread.sleep(1000 * 20); } catch (InterruptedException e) { // Ignore interruption (doesn't impact stream creation) } try { DescribeStreamRequest describeStreamRequest = new DescribeStreamRequest(); describeStreamRequest.setStreamName(myStreamName); // ask for no more than 10 shards at a time -- this is an optional parameter describeStreamRequest.setLimit(10); DescribeStreamResult describeStreamResponse = kinesisClient.describeStream(describeStreamRequest); String streamStatus = describeStreamResponse.getStreamDescription().getStreamStatus(); System.out.println(" - current state: " + streamStatus); if (streamStatus.equals("ACTIVE")) { return; } } catch (AmazonServiceException ase) { if (ase.getErrorCode().equalsIgnoreCase("ResourceNotFoundException") == false) { throw ase; } throw new RuntimeException("Stream " + myStreamName + " never went active"); } } }
From source file:kinesisAlertAnalysis.java
License:Open Source License
private static void waitForStreamToBecomeAvailable(String myStreamName) throws InterruptedException { System.out.printf("Waiting for %s to become ACTIVE...\n", myStreamName); long startTime = System.currentTimeMillis(); long endTime = startTime + TimeUnit.MINUTES.toMillis(10); while (System.currentTimeMillis() < endTime) { Thread.sleep(TimeUnit.SECONDS.toMillis(20)); try {/*from w w w . j av a2s . com*/ DescribeStreamRequest describeStreamRequest = new DescribeStreamRequest(); describeStreamRequest.setStreamName(myStreamName); // ask for no more than 10 shards at a time -- this is an optional parameter describeStreamRequest.setLimit(10); DescribeStreamResult describeStreamResponse = kinesis.describeStream(describeStreamRequest); String streamStatus = describeStreamResponse.getStreamDescription().getStreamStatus(); System.out.printf("\t- current state: %s\n", streamStatus); if ("ACTIVE".equals(streamStatus)) { return; } } catch (ResourceNotFoundException ex) { // ResourceNotFound means the stream doesn't exist yet, // so ignore this error and just keep polling. } catch (AmazonServiceException ase) { throw ase; } } throw new RuntimeException(String.format("Stream %s never became active", myStreamName)); }
From source file:com.boundary.aws.kinesis.Sample.java
License:Open Source License
private static void waitForStreamToBecomeAvailable(String myStreamName) { System.out.println("Waiting for " + myStreamName + " to become ACTIVE..."); long startTime = System.currentTimeMillis(); long endTime = startTime + (10 * 60 * 1000); while (System.currentTimeMillis() < endTime) { try {/*w w w . ja v a2s.c o m*/ Thread.sleep(1000 * 20); } catch (InterruptedException e) { // Ignore interruption (doesn't impact stream creation) } try { DescribeStreamRequest describeStreamRequest = new DescribeStreamRequest(); describeStreamRequest.setStreamName(myStreamName); // ask for no more than 10 shards at a time -- this is an // optional parameter describeStreamRequest.setLimit(10); DescribeStreamResult describeStreamResponse = kinesisClient.describeStream(describeStreamRequest); String streamStatus = describeStreamResponse.getStreamDescription().getStreamStatus(); System.out.println(" - current state: " + streamStatus); if (streamStatus.equals("ACTIVE")) { return; } } catch (AmazonServiceException ase) { if (ase.getErrorCode().equalsIgnoreCase("ResourceNotFoundException") == false) { throw ase; } throw new RuntimeException("Stream " + myStreamName + " never went active"); } } }
From source file:com.xujinpeng.kinesis.AmazonKinesisRecordProducer.java
License:Open Source License
private void waitForStreamToBecomeAvailable(String myStreamName) throws InterruptedException { System.out.printf("Waiting for %s to become ACTIVE...\n", myStreamName); long startTime = System.currentTimeMillis(); long endTime = startTime + TimeUnit.MINUTES.toMillis(10); while (System.currentTimeMillis() < endTime) { Thread.sleep(TimeUnit.SECONDS.toMillis(20)); try {/*from ww w . j a v a 2 s . co m*/ DescribeStreamRequest describeStreamRequest = new DescribeStreamRequest(); describeStreamRequest.setStreamName(myStreamName); // ask for no more than 10 shards at a time -- this is an optional parameter describeStreamRequest.setLimit(10); DescribeStreamResult describeStreamResponse = kinesis.describeStream(describeStreamRequest); String streamStatus = describeStreamResponse.getStreamDescription().getStreamStatus(); System.out.printf("\t- current state: %s\n", streamStatus); if ("ACTIVE".equals(streamStatus)) { return; } } catch (ResourceNotFoundException ex) { // ResourceNotFound means the stream doesn't exist yet, // so ignore this error and just keep polling. } catch (AmazonServiceException ase) { throw ase; } } throw new RuntimeException(String.format("Stream %s never became active", myStreamName)); }
From source file:org.selman.tweetamo.TweetamoClient.java
License:Apache License
private static void waitForStreamToBecomeAvailable(String myStreamName) throws InterruptedException { LOG.info("Waiting for " + myStreamName + " to become ACTIVE..."); long startTime = System.currentTimeMillis(); long endTime = startTime + TimeUnit.MINUTES.toMillis(5); while (System.currentTimeMillis() < endTime) { Thread.sleep(TimeUnit.SECONDS.toMillis(5)); DescribeStreamRequest describeStreamRequest = new DescribeStreamRequest(); describeStreamRequest.setStreamName(myStreamName); describeStreamRequest.setLimit(10); DescribeStreamResult describeStreamResponse = kinesisClient.describeStream(describeStreamRequest); String streamStatus = describeStreamResponse.getStreamDescription().getStreamStatus(); if ("ACTIVE".equals(streamStatus)) { return; }//www . j av a2 s . c o m } }