new ElasticSearchDownloader(client, indexName, "_type:" + mapping.getTypeAlias(), factory),
elasticSearchSorter, iteratorFactory, workingDirectory);
long start = System.currentTimeMillis();
BulkIndexHelper h = new BulkIndexHelper().setMaxRunning(2);
h.setResponseHandler(new BulkIndexHelper.IResponseHandler() {
@Override
public void handle(String id, String type) {
if ("delete".equals(type)) {
onDelete(mapping.getTypeClass(), mapping.toId(id));
} else if ("index".equals(type)) {
onIndex(mapping.getTypeClass(), mapping.toId(id));
} else if ("create".equals(type)) {
onCreate(mapping.getTypeClass(), mapping.toId(id));
} else {
log.warn("unexpected operation type {}", type);
}
}
});
VerifierListener listener = new VerifierListener(client, indexName, context, mapping, h,
DEFAULT_BATCH_SIZE);
try {
verify(moduleStream, esStream, listener);
} finally {
/*
* TODO let IdAndVersionStreamVerifier do that as it does
* with streams
*/
listener.close();
}
try {
h.await();
long seconds = (System.currentTimeMillis() - start) / 1000;
// logging
StringBuilder logMsg = new StringBuilder("finished indexing of ").append(h.getSucceeded())
.append(" objects of type ").append(rebuildSession.getType().getName()).append(" in ")
.append(seconds).append(" seconds");
if (h.getFailed() > 0) {
logMsg.append(" (").append(h.getFailed()).append(" failed)");
log.warn(logMsg.toString());
} else {
log.info(logMsg.toString());
}