Java Code Examples for com.amazonaws.services.ec2.model.DescribeVolumesRequest#setNextToken()
The following examples show how to use
com.amazonaws.services.ec2.model.DescribeVolumesRequest#setNextToken() .
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: BaseTest.java From aws-mock with MIT License | 6 votes |
/** * Describe All Volume. * * @return Collection Volume */ protected final List<Volume> getVolumes() { List<Volume> volumes = null; DescribeVolumesRequest req = new DescribeVolumesRequest(); req.setMaxResults(20); DescribeVolumesResult result = amazonEC2Client.describeVolumes(req); if (result != null && !result.getVolumes().isEmpty()) { volumes = result.getVolumes(); log.info("Page Size : " + volumes.size()); } while(result.getNextToken() != null) { req.setNextToken(result.getNextToken()); result = amazonEC2Client.describeVolumes(req); if (result != null && !result.getVolumes().isEmpty()) { volumes = result.getVolumes(); log.info("Page Size : " + volumes.size()); } } return volumes; }
Example 2
Source File: EbsTableProvider.java From aws-athena-query-federation with Apache License 2.0 | 5 votes |
/** * Calls DescribeVolumes on the AWS EC2 Client returning all volumes that match the supplied predicate and attempting * to push down certain predicates (namely queries for specific volumes) to EC2. * * @See TableProvider */ @Override public void readWithConstraint(BlockSpiller spiller, ReadRecordsRequest recordsRequest, QueryStatusChecker queryStatusChecker) { boolean done = false; DescribeVolumesRequest request = new DescribeVolumesRequest(); ValueSet idConstraint = recordsRequest.getConstraints().getSummary().get("id"); if (idConstraint != null && idConstraint.isSingleValue()) { request.setVolumeIds(Collections.singletonList(idConstraint.getSingleValue().toString())); } while (!done) { DescribeVolumesResult response = ec2.describeVolumes(request); for (Volume volume : response.getVolumes()) { logger.info("readWithConstraint: {}", response); instanceToRow(volume, spiller); } request.setNextToken(response.getNextToken()); if (response.getNextToken() == null || !queryStatusChecker.isQueryRunning()) { done = true; } } }
Example 3
Source File: Ec2Utils.java From pacbot with Apache License 2.0 | 5 votes |
/** * Collect all volumes. * * @param ec2ServiceClient the ec 2 service client * @param region the region * @return the list */ public static List<Volume> collectAllVolumes(AmazonEC2 ec2ServiceClient,Region region){ DescribeVolumesRequest request = new DescribeVolumesRequest(); DescribeVolumesResult result; String nextToken; List<Volume> volumes=new ArrayList<Volume>(); do{ result = ec2ServiceClient.describeVolumes(request); volumes.addAll(result.getVolumes()); nextToken = result.getNextToken(); request.setNextToken(nextToken); }while(null!=nextToken); return volumes; }
Example 4
Source File: PacmanEc2Utils.java From pacbot with Apache License 2.0 | 5 votes |
/** * * @param ec2ServiceClient * @param request * @return */ public static List<Volume> collectAllVolumes(AmazonEC2 ec2ServiceClient, DescribeVolumesRequest request) { DescribeVolumesResult result; String nextToken; List<Volume> volumes = new ArrayList<>(); do { result = ec2ServiceClient.describeVolumes(request); volumes.addAll(result.getVolumes()); nextToken = result.getNextToken(); request.setNextToken(nextToken); } while (null != nextToken); return volumes; }