public void updateIndexer(final IndexerDefinition indexer, String lock) throws InterruptedException, KeeperException,
IndexerNotFoundException, IndexerConcurrentModificationException, ZkLockException, IndexerUpdateException,
IndexerValidityException {
if (!ZkLock.ownsLock(zk, lock)) {
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);
}