use of com.emc.object.s3.request.ListVersionsRequest in project ecs-dashboard by carone1.
the class ListObjectsVersionsCollection method collectObjectVersions.
// =============================
// Public methods
// =============================
public void collectObjectVersions() {
// Verify if versioning is enabled on bucket
if (!getBucketVersioningConfiguration().equals(VersioningConfiguration.Status.Enabled)) {
logger.info("No object version collected from namespace: " + collectionConfig.getNamespace() + " bucket: " + objectBucket.getName() + " because versioning is disabled on bucket");
return;
}
// prepare request object
ListVersionsRequest listVersionsRequest = new ListVersionsRequest(objectBucket.getName());
listVersionsRequest.setMaxKeys(maxObjectPerRequest);
listVersionsRequest.setNamespace(collectionConfig.getNamespace());
long startTime = System.currentTimeMillis();
try {
// collect objects
ListVersionsResult listVersionsResult = collectionConfig.getS3JerseyClient().listVersions(listVersionsRequest);
long stopTime = System.currentTimeMillis();
Double elapsedTime = Double.valueOf(stopTime - startTime) / 1000;
if (listVersionsResult != null) {
Long collected = (long) listVersionsResult.getVersions().size();
this.collectionConfig.getObjectCount().getAndAdd(collected);
logger.info("Took: " + elapsedTime + " seconds to collect " + collected + " objects from namespace: " + collectionConfig.getNamespace() + " bucket: " + objectBucket.getName());
// add collected entries into datastore
if (collectionConfig.getObjectDAO() != null) {
collectionConfig.getObjectDAO().insert(listVersionsResult, collectionConfig.getNamespace(), objectBucket.getName(), collectionConfig.getCollectionTime());
}
// process extra pages of objects
while (listVersionsResult.isTruncated()) {
listVersionsRequest.setVersionIdMarker(listVersionsResult.getNextVersionIdMarker());
startTime = System.currentTimeMillis();
listVersionsResult = collectionConfig.getS3JerseyClient().listVersions(listVersionsRequest);
stopTime = System.currentTimeMillis();
elapsedTime = Double.valueOf(stopTime - startTime) / 1000;
collected = (long) listVersionsResult.getVersions().size();
collectionConfig.getObjectCount().getAndAdd(collected);
logger.info("Took: " + elapsedTime + " seconds to collect " + collected + " objects versions from namespace: " + collectionConfig.getNamespace() + " bucket: " + objectBucket.getName());
// add collected entries into datastore
if (collectionConfig.getObjectDAO() != null) {
collectionConfig.getObjectDAO().insert(listVersionsResult, collectionConfig.getNamespace(), objectBucket.getName(), collectionConfig.getCollectionTime());
}
}
}
} catch (Exception ex) {
logger.error("Error occur while listing object versions from namespace: " + collectionConfig.getNamespace() + " Bucket: " + objectBucket.getName() + " " + ex.getLocalizedMessage());
throw new RuntimeException(ex.getLocalizedMessage());
}
}
Aggregations