index.execute(new Esi4JOperation<Void>() {
@Override
public Void execute(Client client, String indexName, Esi4JOperation.OperationContext context) {
final TypeMapping mapping = context.findTypeMapping(rebuildSession.getType());
ModuleIdAndVersionStream moduleStream = new ModuleIdAndVersionStream(rebuildSession,
DEFAULT_BATCH_SIZE, mapping);
IdAndVersionFactory factory = new MappedObjectIdAndVersionFactory(mapping);
ElasticSearchSorter elasticSearchSorter = new ElasticSearchSorter(createSorter(factory));
IteratorFactory iteratorFactory = new IteratorFactory(factory);
String workingDirectory = SystemUtils.getJavaIoTmpDir().getAbsolutePath();
ElasticSearchIdAndVersionStream esStream = new ElasticSearchIdAndVersionStream(
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);
}
}
});