throw new IndexerUpdateException("You are not owner of the indexer's lock, the lock path is: " + lock);
}
assertValid(indexer);
IndexerDefinition currentIndexer = getFreshIndexer(indexer.getName());
if (currentIndexer.getLifecycleState() == LifecycleState.DELETE_REQUESTED ||
currentIndexer.getLifecycleState() == LifecycleState.DELETING) {
throw new IndexerUpdateException("An indexer in state " + indexer.getLifecycleState() + " cannot be modified.");
}
if (indexer.getBatchIndexingState() == BatchIndexingState.BUILD_REQUESTED &&
currentIndexer.getBatchIndexingState() != BatchIndexingState.INACTIVE &&
currentIndexer.getBatchIndexingState() != BatchIndexingState.BUILD_REQUESTED) {
throw new IndexerUpdateException("Cannot move batch indexing state from " + currentIndexer.getBatchIndexingState() +
" to " + indexer.getBatchIndexingState());
}
if (currentIndexer.getLifecycleState() == LifecycleState.DELETE_REQUESTED) {
throw new IndexerUpdateException("An indexer in the state " + LifecycleState.DELETE_REQUESTED +
" cannot be updated.");
}
if (!Objects.equal(currentIndexer.getActiveBatchBuildInfo(), indexer.getActiveBatchBuildInfo())) {
throw new IndexerUpdateException("The active batch build info cannot be modified by users.");
}
if (!Objects.equal(currentIndexer.getLastBatchBuildInfo(), indexer.getLastBatchBuildInfo())) {
throw new IndexerUpdateException("The last batch build info cannot be modified by users.");
}
updateIndexerInternal(indexer);