Search in sources :

Example 1 with IndexRequestContainer

use of com.epam.pipeline.elasticsearchagent.service.impl.IndexRequestContainer in project cloud-pipeline by epam.

the class S3Helper method listFiles.

private void listFiles(AmazonS3 client, String bucket) {
    ListObjectsV2Request req = new ListObjectsV2Request();
    req.setBucketName(bucket);
    req.setPrefix("");
    ListObjectsV2Result listing;
    try (IndexRequestContainer walker = new IndexRequestContainer(bulkRequestCreator, bulkInsertSize)) {
        do {
            listing = client.listObjectsV2(req);
            for (S3ObjectSummary s3ObjectSummary : listing.getObjectSummaries()) {
                DataStorageFile file = convertToStorageFile(s3ObjectSummary);
                if (file != null) {
                    if (enableTags) {
                        file.setTags(listObjectTags(client, bucket, s3ObjectSummary.getKey()));
                    }
                    walker.add(createIndexRequest(file));
                }
            }
            req.setContinuationToken(listing.getNextContinuationToken());
        } while (listing.isTruncated());
    }
}
Also used : DataStorageFile(com.epam.pipeline.entity.datastorage.DataStorageFile) ListObjectsV2Request(com.amazonaws.services.s3.model.ListObjectsV2Request) ListObjectsV2Result(com.amazonaws.services.s3.model.ListObjectsV2Result) IndexRequestContainer(com.epam.pipeline.elasticsearchagent.service.impl.IndexRequestContainer) S3ObjectSummary(com.amazonaws.services.s3.model.S3ObjectSummary)

Aggregations

ListObjectsV2Request (com.amazonaws.services.s3.model.ListObjectsV2Request)1 ListObjectsV2Result (com.amazonaws.services.s3.model.ListObjectsV2Result)1 S3ObjectSummary (com.amazonaws.services.s3.model.S3ObjectSummary)1 IndexRequestContainer (com.epam.pipeline.elasticsearchagent.service.impl.IndexRequestContainer)1 DataStorageFile (com.epam.pipeline.entity.datastorage.DataStorageFile)1