use of com.emc.object.s3.bean.DeleteMarker in project ecs-dashboard by carone1.
the class ElasticS3ObjectDAO method insert.
/**
* {@inheritDoc}
*/
@Override
public void insert(ListVersionsResult listVersionsResult, String namespace, String bucketName, Date collectionTime) {
if (listVersionsResult == null || listVersionsResult.getVersions() == null || listVersionsResult.getVersions().isEmpty()) {
// nothing to insert
return;
}
BulkRequestBuilder requestBuilder = elasticClient.prepareBulk();
// Generate JSON for object version info
for (AbstractVersion abstractVersion : listVersionsResult.getVersions()) {
if (abstractVersion instanceof Version) {
XContentBuilder s3ObjectVersionBuilder = toJsonFormat((Version) abstractVersion, namespace, bucketName, collectionTime);
IndexRequestBuilder request = elasticClient.prepareIndex().setIndex(s3ObjectVersionIndexDayName).setType(S3_OBJECT_VERSION_INDEX_TYPE).setSource(s3ObjectVersionBuilder);
requestBuilder.add(request);
} else if (abstractVersion instanceof DeleteMarker) {
XContentBuilder s3ObjectVersionBuilder = toJsonFormat((DeleteMarker) abstractVersion, namespace, bucketName, collectionTime);
IndexRequestBuilder request = elasticClient.prepareIndex().setIndex(s3ObjectVersionIndexDayName).setType(S3_OBJECT_VERSION_INDEX_TYPE).setSource(s3ObjectVersionBuilder);
requestBuilder.add(request);
}
}
BulkResponse bulkResponse = requestBuilder.execute().actionGet();
int items = bulkResponse.getItems().length;
LOGGER.info("Took " + bulkResponse.getTookInMillis() + " ms to index [" + items + "] items in Elasticsearch " + "index: " + s3ObjectVersionIndexDayName + " index type: " + S3_OBJECT_VERSION_INDEX_TYPE);
if (bulkResponse.hasFailures()) {
LOGGER.error("Failure(s) occured while items in Elasticsearch " + "index: " + s3ObjectVersionIndexDayName + " index type: " + S3_OBJECT_VERSION_INDEX_TYPE);
}
}
Aggregations