use of Vdc.VdcDetail in project ecs-dashboard by carone1.
the class ElasticVdcDetailDAO method insert.
@Override
public void insert(VdcDetails vdcDetails, Date collectionTime) {
if (vdcDetails == null || vdcDetails.getVdcDetails() == null || vdcDetails.getVdcDetails().isEmpty()) {
return;
}
BulkRequestBuilder requestBuilder = elasticClient.prepareBulk();
// Generate JSON for object buckets info
for (VdcDetail vdcDetail : vdcDetails.getVdcDetails()) {
XContentBuilder objectBucketBuilder = toJsonFormat(vdcDetail, collectionTime);
IndexRequestBuilder request = elasticClient.prepareIndex().setIndex(vdcIndexDayName).setType(VDC_INDEX_TYPE).setSource(objectBucketBuilder);
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: " + vdcIndexDayName + " index type: " + VDC_INDEX_TYPE);
if (bulkResponse.hasFailures()) {
LOGGER.error("Failures occured while items in ElasticSearch " + "index: " + vdcIndexDayName + " index type: " + VDC_INDEX_TYPE);
}
}
Aggregations