public CompletableFuture < Boolean > reindexWorkspace ( final boolean dropExisting , int nThreads ) throws IllegalStateException { // checks if ( handler == null || handler . getIndexerIoModeHandler ( ) == null || changesFilter == null ) { throw new IllegalStateException ( "Index might have not been initialized yet." ) ; } if ( handler . getIndexerIoModeHandler ( ) . getMode ( ) != IndexerIoMode . READ_WRITE ) { throw new IllegalStateException ( "Index is not in READ_WRITE mode and reindexing can't be launched. Please start reindexing on coordinator node." ) ; } if ( isSuspended . get ( ) || ! handler . isOnline ( ) ) { throw new IllegalStateException ( "Can't start reindexing while index is " + ( ( isSuspended . get ( ) ) ? "SUSPENDED." : "already OFFLINE (it means that reindexing is in progress)." ) + "." ) ; } LOG . info ( "Starting hot reindexing on the " + handler . getContext ( ) . getRepositoryName ( ) + "/" + handler . getContext ( ) . getContainer ( ) . getWorkspaceName ( ) + ", with" + ( dropExisting ? "" : "out" ) + " dropping the existing indexes." ) ; // starting new thread, releasing JMX call ExecutorService executorService = Executors . newSingleThreadExecutor ( runnable -> new Thread ( runnable , "HotReindexing-" + handler . getContext ( ) . getRepositoryName ( ) + "-" + handler . getContext ( ) . getContainer ( ) . getWorkspaceName ( ) ) ) ; CompletableFuture < Boolean > reindexFuture = CompletableFuture . supplyAsync ( ( ) -> doReindexing ( dropExisting , nThreads ) , executorService ) ; reindexFuture . thenRun ( ( ) -> executorService . shutdown ( ) ) ; return reindexFuture ; }
Perform hot reindexing of the workspace