/** * Adds or updates the given index to the internal cache. */ private void refreshIndexer(final String indexerName, List<IndexerModelEvent> events) throws InterruptedException, KeeperException { try { IndexerDefinition indexer = loadIndexer(indexerName, true); IndexerDefinition oldIndexer = indexers.get(indexerName); if (oldIndexer != null && oldIndexer.getOccVersion() == indexer.getOccVersion()) { // nothing changed } else { final boolean isNew = oldIndexer == null; indexers.put(indexerName, indexer); events.add(new IndexerModelEvent(isNew ? INDEXER_ADDED : INDEXER_UPDATED, indexerName)); } } catch (IndexerNotFoundException e) { Object oldIndexer = indexers.remove(indexerName); if (oldIndexer != null) { events.add(new IndexerModelEvent(INDEXER_DELETED, indexerName)); } } } }
/** * Adds or updates the given index to the internal cache. */ private void refreshIndexer(final String indexerName, List<IndexerModelEvent> events) throws InterruptedException, KeeperException { try { IndexerDefinition indexer = loadIndexer(indexerName, true); IndexerDefinition oldIndexer = indexers.get(indexerName); if (oldIndexer != null && oldIndexer.getOccVersion() == indexer.getOccVersion()) { // nothing changed } else { final boolean isNew = oldIndexer == null; indexers.put(indexerName, indexer); events.add(new IndexerModelEvent(isNew ? INDEXER_ADDED : INDEXER_UPDATED, indexerName)); } } catch (IndexerNotFoundException e) { Object oldIndexer = indexers.remove(indexerName); if (oldIndexer != null) { events.add(new IndexerModelEvent(INDEXER_DELETED, indexerName)); } } } }
@Override public Stat execute() throws KeeperException, InterruptedException { return zk.setData(indexerCollectionPathSlash + indexer.getName(), newData, indexer.getOccVersion()); } });
@Override public Stat execute() throws KeeperException, InterruptedException { return zk.setData(indexerCollectionPathSlash + indexer.getName(), newData, indexer.getOccVersion()); } });
/** * Get a single index configuration (as stored in zookeeper). */ @GET @Path("{name}/config") @Produces("application/json") public Response getConfig(@PathParam("name") String name) throws IndexerNotFoundException, IOException { IndexerDefinition index = getModel().getIndexer(name); ObjectMapper m = new ObjectMapper(); ObjectNode json = m.createObjectNode(); json.put("occVersion", index.getOccVersion()); json.put("config", new String(index.getConfiguration(), Charsets.UTF_8)); return Response.ok(m.writeValueAsString(json), new MediaType("application", "json")).build(); }
/** * Get a single index configuration (as stored in zookeeper). */ @GET @Path("{name}/config") @Produces("application/json") public Response getConfig(@PathParam("name") String name) throws IndexerNotFoundException, IOException { IndexerDefinition index = getModel().getIndexer(name); ObjectMapper m = new ObjectMapper(); ObjectNode json = m.createObjectNode(); json.put("occVersion", index.getOccVersion()); json.put("config", new String(index.getConfiguration(), Charsets.UTF_8)); return Response.ok(m.writeValueAsString(json), new MediaType("application", "json")).build(); }
private void restartIndexer(IndexerDefinition indexerDef) { IndexerHandle handle = indexers.get(indexerDef.getName()); if (handle.indexerDef.getOccVersion() >= indexerDef.getOccVersion()) { return; } boolean relevantChanges = !Arrays.equals(handle.indexerDef.getConfiguration(), indexerDef.getConfiguration()) || Objects.equal(handle.indexerDef.getConnectionType(), indexerDef.getConnectionType()) || !Objects.equal(handle.indexerDef.getConnectionParams(), indexerDef.getConnectionParams()); if (!relevantChanges) { return; } if (stopIndexer(indexerDef.getName())) { startIndexer(indexerDef); } }
private void restartIndexer(IndexerDefinition indexerDef) { IndexerHandle handle = indexers.get(indexerDef.getName()); if (handle.indexerDef.getOccVersion() >= indexerDef.getOccVersion()) { return; } boolean relevantChanges = !Arrays.equals(handle.indexerDef.getConfiguration(), indexerDef.getConfiguration()) || Objects.equal(handle.indexerDef.getConnectionType(), indexerDef.getConnectionType()) || !Objects.equal(handle.indexerDef.getConnectionParams(), indexerDef.getConnectionParams()); if (!relevantChanges) { return; } if (stopIndexer(indexerDef.getName())) { startIndexer(indexerDef); } }
public IndexerDefinitionBuilder startFrom(IndexerDefinition existingDefinition) { this.name = existingDefinition.getName(); this.lifecycleState = existingDefinition.getLifecycleState(); this.batchIndexingState = existingDefinition.getBatchIndexingState(); this.incrementalIndexingState = existingDefinition.getIncrementalIndexingState(); this.subscriptionId = existingDefinition.getSubscriptionId(); this.configuration = existingDefinition.getConfiguration(); this.indexerComponentFactory = existingDefinition.getIndexerComponentFactory(); this.connectionType = existingDefinition.getConnectionType(); this.connectionParams = existingDefinition.getConnectionParams(); this.defaultBatchIndexCliArguments = existingDefinition.getDefaultBatchIndexCliArguments(); this.batchIndexCliArguments = existingDefinition.getBatchIndexCliArguments(); this.lastBatchBuildInfo = existingDefinition.getLastBatchBuildInfo(); this.activeBatchBuildInfo = existingDefinition.getActiveBatchBuildInfo(); this.subscriptionTimestamp = existingDefinition.getSubscriptionTimestamp(); this.occVersion = existingDefinition.getOccVersion(); return this; }
public IndexerDefinitionBuilder startFrom(IndexerDefinition existingDefinition) { this.name = existingDefinition.getName(); this.lifecycleState = existingDefinition.getLifecycleState(); this.batchIndexingState = existingDefinition.getBatchIndexingState(); this.incrementalIndexingState = existingDefinition.getIncrementalIndexingState(); this.subscriptionId = existingDefinition.getSubscriptionId(); this.configuration = existingDefinition.getConfiguration(); this.indexerComponentFactory = existingDefinition.getIndexerComponentFactory(); this.connectionType = existingDefinition.getConnectionType(); this.connectionParams = existingDefinition.getConnectionParams(); this.defaultBatchIndexCliArguments = existingDefinition.getDefaultBatchIndexCliArguments(); this.batchIndexCliArguments = existingDefinition.getBatchIndexCliArguments(); this.lastBatchBuildInfo = existingDefinition.getLastBatchBuildInfo(); this.activeBatchBuildInfo = existingDefinition.getActiveBatchBuildInfo(); this.subscriptionTimestamp = existingDefinition.getSubscriptionTimestamp(); this.occVersion = existingDefinition.getOccVersion(); return this; }
node.put("incrementalIndexingState", indexer.getIncrementalIndexingState().toString()); node.put("occVersion", indexer.getOccVersion());
node.put("incrementalIndexingState", indexer.getIncrementalIndexingState().toString()); node.put("occVersion", indexer.getOccVersion());