List of usage examples for com.amazonaws.services.kinesis AmazonKinesisClient listStreams
@Override
public ListStreamsResult listStreams(String exclusiveStartStreamName)
From source file:whgHelper.java
License:Open Source License
public static List<String> getStreams(AmazonKinesisClient kinesis) { // List all of my streams. ListStreamsRequest listStreamsRequest = new ListStreamsRequest(); listStreamsRequest.setLimit(10);// w w w .java2 s . co m ListStreamsResult listStreamsResult = kinesis.listStreams(listStreamsRequest); List<String> streamNames = listStreamsResult.getStreamNames(); while (listStreamsResult.isHasMoreStreams()) { if (streamNames.size() > 0) { listStreamsRequest.setExclusiveStartStreamName(streamNames.get(streamNames.size() - 1)); } listStreamsResult = kinesis.listStreams(listStreamsRequest); streamNames.addAll(listStreamsResult.getStreamNames()); } // Print all of my streams. System.out.println("Helper: List of my streams: "); for (int i = 0; i < streamNames.size(); i++) { System.out.println("\t- " + streamNames.get(i)); } return streamNames; }
From source file:com.amazon.services.awsrum.utils.KinesisUtils.java
License:Open Source License
/** * Gets a list of all Kinesis streams//from w ww.j a v a 2s. c o m * * @param kinesisClient * The {@link AmazonKinesisClient} with Kinesis read privileges * @return list of Kinesis streams */ public static List<String> listAllStreams(AmazonKinesisClient kinesisClient) { ListStreamsRequest listStreamsRequest = new ListStreamsRequest(); listStreamsRequest.setLimit(10); ListStreamsResult listStreamsResult = kinesisClient.listStreams(listStreamsRequest); List<String> streamNames = listStreamsResult.getStreamNames(); while (listStreamsResult.isHasMoreStreams()) { if (streamNames.size() > 0) { listStreamsRequest.setExclusiveStartStreamName(streamNames.get(streamNames.size() - 1)); } listStreamsResult = kinesisClient.listStreams(listStreamsRequest); streamNames.addAll(listStreamsResult.getStreamNames()); } return streamNames; }
From source file:dbtucker.connect.kinesis.KinesisSourceConnector.java
License:Apache License
@Override public void start(Map<String, String> map) { config = new KinesisSourceConnectorConfig(map); streamShards = new HashMap<>(); List<String> streamNames; final Set<String> ignoredStreams = new HashSet<>(); final Set<String> consumedStreams = new HashSet<>(); final AmazonKinesisClient client = new AmazonKinesisClient(); client.configureRegion(config.getRegionId()); ListStreamsResult listResult;/*from www. java 2s .co m*/ ListStreamsRequest lsr = new ListStreamsRequest(); lsr.setLimit(32); String lastEvaluatedStreamName = null; do { lsr.setExclusiveStartStreamName(lastEvaluatedStreamName); listResult = client.listStreams(lsr); streamNames = listResult.getStreamNames(); for (String streamName : streamNames) { if (config.getStreamsPrefix() == null) { if ((config.getStreamsBlacklist() == null || config.getStreamsBlacklist().contains(streamName)) && (config.getStreamsWhitelist() == null || !config.getStreamsWhitelist().contains(streamName))) { ignoredStreams.add(streamName); continue; } } else { if (streamName.startsWith(config.getStreamsPrefix())) { if (config.getStreamsBlacklist() != null && config.getStreamsBlacklist().contains(streamName)) { ignoredStreams.add(streamName); continue; } } else { ignoredStreams.add(streamName); continue; } } final DescribeStreamResult streamDesc = client.describeStream(streamName); if (streamDesc.getStreamDescription().getStreamStatus().equals(StreamStatus.DELETING.toString())) { log.warn("Stream '{}' is being deleted and cannot be consumed", streamName); ignoredStreams.add(streamName); continue; } for (Shard shard : streamDesc.getStreamDescription().getShards()) { streamShards.put(shard, streamDesc); } consumedStreams.add(streamName); } if (streamNames.size() > 0) { lastEvaluatedStreamName = streamNames.get(streamNames.size() - 1); } } while (listResult.getHasMoreStreams()); log.info("Streams to ingest: {}", consumedStreams); log.info("Streams to ignore: {}", ignoredStreams); client.shutdown(); if (consumedStreams.isEmpty()) { throw new ConnectException("No matching Kinesis Streams found. Exiting connector"); } }
From source file:org.rakam.aws.kinesis.KinesisUtils.java
License:Open Source License
/** * Gets a list of all Amazon Kinesis streams * //from w w w. ja v a 2 s.c om * @param kinesisClient * The {@link com.amazonaws.services.kinesis.AmazonKinesisClient} with Amazon Kinesis read privileges * @return list of Amazon Kinesis streams */ public static List<String> listAllStreams(AmazonKinesisClient kinesisClient) { ListStreamsRequest listStreamsRequest = new ListStreamsRequest(); listStreamsRequest.setLimit(10); ListStreamsResult listStreamsResult = kinesisClient.listStreams(listStreamsRequest); List<String> streamNames = listStreamsResult.getStreamNames(); while (listStreamsResult.isHasMoreStreams()) { if (!streamNames.isEmpty()) { listStreamsRequest.setExclusiveStartStreamName(streamNames.get(streamNames.size() - 1)); } listStreamsResult = kinesisClient.listStreams(listStreamsRequest); streamNames.addAll(listStreamsResult.getStreamNames()); } return streamNames; }