model.unlockIndexer(lock, ignoreMissing);
model.unlockIndexer(lock, ignoreMissing);
indexerModel.unlockIndexer(lock);
indexerModel.unlockIndexer(lock);
private void unassignSubscription(String indexerName) { try { String lock = indexerModel.lockIndexer(indexerName); try { // Read current situation of record and assure it is still actual IndexerDefinition indexer = indexerModel.getFreshIndexer(indexerName); if (needsSubscriptionIdUnassigned(indexer)) { sepModel.removeSubscription(indexer.getSubscriptionId()); log.info("Deleted queue subscription for indexer " + indexerName); indexer = new IndexerDefinitionBuilder().startFrom(indexer).subscriptionId(null).build(); indexerModel.updateIndexerInternal(indexer); } } finally { indexerModel.unlockIndexer(lock); } } catch (Throwable t) { log.error("Error trying to delete the subscription for indexer " + indexerName, t); } }
private void unassignSubscription(String indexerName) { try { String lock = indexerModel.lockIndexer(indexerName); try { // Read current situation of record and assure it is still actual IndexerDefinition indexer = indexerModel.getFreshIndexer(indexerName); if (needsSubscriptionIdUnassigned(indexer)) { sepModel.removeSubscription(indexer.getSubscriptionId()); log.info("Deleted queue subscription for indexer " + indexerName); indexer = new IndexerDefinitionBuilder().startFrom(indexer).subscriptionId(null).build(); indexerModel.updateIndexerInternal(indexer); } } finally { indexerModel.unlockIndexer(lock); } } catch (Throwable t) { log.error("Error trying to delete the subscription for indexer " + indexerName, t); } }
@Override public void jobStarted(String jobId, String trackingUrl) { try { // Lock internal bypasses the index-in-delete-state check, which does not matter (and might cause // failure) in our case. String lock = indexerModel.lockIndexerInternal(indexerName, false); try { IndexerDefinition definition = indexerModel.getFreshIndexer(indexerName); BatchBuildInfo batchBuildInfo = new BatchBuildInfo(definition.getActiveBatchBuildInfo()).withJob(jobId, trackingUrl); IndexerDefinition updatedDefinition = new IndexerDefinitionBuilder().startFrom(definition) .activeBatchBuildInfo(batchBuildInfo) .build(); indexerModel.updateIndexerInternal(updatedDefinition); log.info("Updated indexer batch build state for indexer " + indexerName); } finally { indexerModel.unlockIndexer(lock, true); } } catch (Exception e) { log.error("failed to update indexer batch build state for indexer " + indexerName); } } }
@Override public void jobStarted(String jobId, String trackingUrl) { try { // Lock internal bypasses the index-in-delete-state check, which does not matter (and might cause // failure) in our case. String lock = indexerModel.lockIndexerInternal(indexerName, false); try { IndexerDefinition definition = indexerModel.getFreshIndexer(indexerName); BatchBuildInfo batchBuildInfo = new BatchBuildInfo(definition.getActiveBatchBuildInfo()).withJob(jobId, trackingUrl); IndexerDefinition updatedDefinition = new IndexerDefinitionBuilder().startFrom(definition) .activeBatchBuildInfo(batchBuildInfo) .build(); indexerModel.updateIndexerInternal(updatedDefinition); log.info("Updated indexer batch build state for indexer " + indexerName); } finally { indexerModel.unlockIndexer(lock, true); } } catch (Exception e) { log.error("failed to update indexer batch build state for indexer " + indexerName); } } }
model.unlockIndexer(lock, ignoreMissing);
private void assignSubscription(String indexerName) { try { String lock = indexerModel.lockIndexer(indexerName); try { // Read current situation of record and assure it is still actual IndexerDefinition indexer = indexerModel.getFreshIndexer(indexerName); if (needsSubscriptionIdAssigned(indexer)) { // We assume we are the only process which creates subscriptions which begin with the // prefix "Indexer:". This way we are sure there are no naming conflicts or conflicts // due to concurrent operations (e.g. someone deleting this subscription right after we // created it). String subscriptionId = subscriptionId(indexer.getName()); sepModel.addSubscription(subscriptionId); indexer = new IndexerDefinitionBuilder().startFrom(indexer).subscriptionId(subscriptionId).build(); indexerModel.updateIndexerInternal(indexer); log.info("Assigned subscription ID '" + subscriptionId + "' to indexer '" + indexerName + "'"); } } finally { indexerModel.unlockIndexer(lock); } } catch (Throwable t) { log.error("Error trying to assign a subscription to index " + indexerName, t); } }
indexerModel.unlockIndexer(lock, true);
indexerModel.unlockIndexer(lock, true);
public void run(OptionSet options) throws Exception { super.run(options); String indexName = nameOption.value(options); if (!options.has("http")) { if (!model.hasIndexer(indexName)) { throw new CliException("Indexer does not exist: " + indexName); } IndexerDefinition newIndexer = null; String lock = model.lockIndexer(indexName); try { IndexerDefinition indexer = model.getFreshIndexer(indexName); IndexerDefinitionBuilder builder = buildIndexerDefinition(options, indexer); newIndexer = builder.build(); if (newIndexer.equals(indexer)) { System.out.println("Index already matches the specified settings, did not update it."); } else { model.updateIndexer(newIndexer, lock); System.out.println("Index updated: " + indexName); } } finally { // In case we requested deletion of an index, it might be that the lock is already removed // by the time we get here as part of the index deletion. boolean ignoreMissing = newIndexer != null && newIndexer.getLifecycleState() == LifecycleState.DELETE_REQUESTED; model.unlockIndexer(lock, ignoreMissing); } } else { updateIndexerHttp(options, indexName); } }
indexerModel.unlockIndexer(lock);
model.unlockIndexer(lock, ignoreMissing);