@Override public ReindexStatus getReindexStatus() { if (reindexAsync.getProcessHandle().isDone()) { throw new ZanataServiceException("Reindexing not in currently in progress", 404); } ReindexStatus status = new ReindexStatus(); status.setCurrentElementType(reindexAsync.getCurrentClassName()); status.setIndexedElements(reindexAsync.getProcessHandle().getCurrentProgress()); status.setTotalElements(reindexAsync.getProcessHandle().getMaxProgress()); // TODO This service is currently not being used // To re-add these properties, just implement TimedAsyncHandle // status.setTimeElapsed(reindexAsync.getProcessHandle().getElapsedTime()); // status.setTimeRemaining(reindexAsync.getProcessHandle().getEstimatedTimeRemaining()); return status; }
@Override public ReindexStatus startReindex( @QueryParam("purge") boolean purgeAll, @QueryParam("index") boolean indexAll, @QueryParam("optimize") boolean optimizeAll) { reindexAsync.setOptions(purgeAll, indexAll, optimizeAll); boolean startedReindex = false; if (reindexAsync.getProcessHandle().isDone()) { startedReindex = true; reindexAsync.startProcess(); } ReindexStatus status = this.getReindexStatus(); status.setStartedReindex(startedReindex); return status; }