private IndexSearcherWrapper loadFlsDlsIndexSearcherWrapper(final IndexService indexService, final ComplianceIndexingOperationListener ciol, final ComplianceConfig complianceConfig) { try { IndexSearcherWrapper flsdlsWrapper = (IndexSearcherWrapper) dlsFlsConstructor .newInstance(indexService, settings, Objects.requireNonNull(adminDns), Objects.requireNonNull(cs), Objects.requireNonNull(auditLog), Objects.requireNonNull(ciol), Objects.requireNonNull(complianceConfig)); if(log.isDebugEnabled()) { log.debug("FLS/DLS enabled for index {}", indexService.index().getName()); } return flsdlsWrapper; } catch(Exception ex) { throw new RuntimeException("Failed to enable FLS/DLS", ex); } }
public SearchGuardIndexSearcherWrapper(final IndexService indexService, final Settings settings, final AdminDNs adminDNs) { index = indexService.index(); threadContext = indexService.getThreadPool().getThreadContext(); this.searchguardIndex = settings.get(ConfigConstants.SEARCHGUARD_CONFIG_INDEX_NAME, ConfigConstants.SG_DEFAULT_CONFIG_INDEX); this.adminDns = adminDNs; }
Map<Index, List<IndexShardStats>> statsByShard(final IndicesService indicesService, final CommonStatsFlags flags) { final Map<Index, List<IndexShardStats>> statsByShard = new HashMap<>(); for (final IndexService indexService : indicesService) { for (final IndexShard indexShard : indexService) { try { final IndexShardStats indexShardStats = indicesService.indexShardStats(indicesService, indexShard, flags); if (indexShardStats == null) { continue; } if (statsByShard.containsKey(indexService.index()) == false) { statsByShard.put(indexService.index(), arrayAsArrayList(indexShardStats)); } else { statsByShard.get(indexService.index()).add(indexShardStats); } } catch (IllegalIndexShardStateException | AlreadyClosedException e) { // we can safely ignore illegal state on ones that are closing for example logger.trace(() -> new ParameterizedMessage("{} ignoring shard stats", indexShard.shardId()), e); } } } return statsByShard; }
@Override public synchronized void removeShard(int shardId, String reason) { final ShardId sId = new ShardId(index(), shardId); final IndexShard indexShard; if (shards.containsKey(shardId) == false) { return; } logger.debug("[{}] closing... (reason: [{}])", shardId, reason); HashMap<Integer, IndexShard> newShards = new HashMap<>(shards); indexShard = newShards.remove(shardId); shards = unmodifiableMap(newShards); closeShard(reason, sId, indexShard, indexShard.store(), indexShard.getIndexEventListener()); logger.debug("[{}] closed (reason: [{}])", shardId, reason); }
@Override protected void doStop() { ExecutorService indicesStopExecutor = Executors.newFixedThreadPool(5, EsExecutors.daemonThreadFactory(settings, "indices_shutdown")); // Copy indices because we modify it asynchronously in the body of the loop final Set<Index> indices = this.indices.values().stream().map(s -> s.index()).collect(Collectors.toSet()); final CountDownLatch latch = new CountDownLatch(indices.size()); for (final Index index : indices) { indicesStopExecutor.execute(() -> { try { removeIndex(index, IndexRemovalReason.NO_LONGER_ASSIGNED, "shutdown"); } finally { latch.countDown(); } }); } try { if (latch.await(shardsClosedTimeout.seconds(), TimeUnit.SECONDS) == false) { logger.warn("Not all shards are closed yet, waited {}sec - stopping service", shardsClosedTimeout.seconds()); } } catch (InterruptedException e) { // ignore } finally { indicesStopExecutor.shutdown(); } }
/** * Return the shard with the provided id, or throw an exception if it doesn't exist. */ public IndexShard getShard(int shardId) { IndexShard indexShard = getShardOrNull(shardId); if (indexShard == null) { throw new ShardNotFoundException(new ShardId(index(), shardId)); } return indexShard; }
logger.debug("{} closed... (reason [{}][{}])", index, reason, extraInfo); final IndexSettings indexSettings = indexService.getIndexSettings(); listener.afterIndexRemoved(indexService.index(), indexSettings, reason); if (reason == IndexRemovalReason.DELETED) { deleteIndexStore(extraInfo, indexService.index(), indexSettings);
createdIndex = dummyIndexService.index();
private boolean refreshIndexMapping(IndexService indexService, IndexMetaData.Builder builder) { boolean dirty = false; String index = indexService.index().getName(); try { List<String> updatedTypes = new ArrayList<>(); for (DocumentMapper mapper : indexService.mapperService().docMappers(true)) { final String type = mapper.type(); if (!mapper.mappingSource().equals(builder.mapping(type).source())) { updatedTypes.add(type); } } // if a single type is not up-to-date, re-send everything if (updatedTypes.isEmpty() == false) { logger.warn("[{}] re-syncing mappings with cluster state because of types [{}]", index, updatedTypes); dirty = true; for (DocumentMapper mapper : indexService.mapperService().docMappers(true)) { builder.putMapping(new MappingMetaData(mapper)); } } } catch (Exception e) { logger.warn(() -> new ParameterizedMessage("[{}] failed to refresh-mapping in cluster state", index), e); } return dirty; }
createdIndex = indexService.index();
@Override public synchronized void removeShard(int shardId, String reason) { final ShardId sId = new ShardId(index(), shardId); final IndexShard indexShard; if (shards.containsKey(shardId) == false) { return; } logger.debug("[{}] closing... (reason: [{}])", shardId, reason); HashMap<Integer, IndexShard> newShards = new HashMap<>(shards); indexShard = newShards.remove(shardId); shards = unmodifiableMap(newShards); closeShard(reason, sId, indexShard, indexShard.store(), indexShard.getIndexEventListener()); logger.debug("[{}] closed (reason: [{}])", shardId, reason); }
@Override public synchronized void removeShard(int shardId, String reason) { final ShardId sId = new ShardId(index(), shardId); final IndexShard indexShard; if (shards.containsKey(shardId) == false) { return; } logger.debug("[{}] closing... (reason: [{}])", shardId, reason); HashMap<Integer, IndexShard> newShards = new HashMap<>(shards); indexShard = newShards.remove(shardId); shards = unmodifiableMap(newShards); closeShard(reason, sId, indexShard, indexShard.store(), indexShard.getIndexEventListener()); logger.debug("[{}] closed (reason: [{}])", shardId, reason); }
@Override public synchronized void removeShard(int shardId, String reason) { final ShardId sId = new ShardId(index(), shardId); final IndexShard indexShard; if (shards.containsKey(shardId) == false) { return; } logger.debug("[{}] closing... (reason: [{}])", shardId, reason); HashMap<Integer, IndexShard> newShards = new HashMap<>(shards); indexShard = newShards.remove(shardId); shards = unmodifiableMap(newShards); closeShard(reason, sId, indexShard, indexShard.store(), indexShard.getIndexEventListener()); logger.debug("[{}] closed (reason: [{}])", shardId, reason); }
public SearchGuardIndexSearcherWrapper(final IndexService indexService, final Settings settings, final AdminDNs adminDNs) { index = indexService.index(); threadContext = indexService.getThreadPool().getThreadContext(); this.searchguardIndex = settings.get(ConfigConstants.SEARCHGUARD_CONFIG_INDEX_NAME, ConfigConstants.SG_DEFAULT_CONFIG_INDEX); this.adminDns = adminDNs; }
public void beforeIndexClosed(IndexService indexService) { for (Listener listener : listeners) { try { listener.beforeIndexClosed(indexService); } catch (Throwable t) { logger.warn("[{}] failed to invoke before index closed callback", t, indexService.index().name()); throw t; } } }
public void afterIndexCreated(IndexService indexService) { for (Listener listener : listeners) { try { listener.afterIndexCreated(indexService); } catch (Throwable t) { logger.warn("[{}] failed to invoke after index created callback", t, indexService.index().name()); throw t; } } }
public void beforeIndexDeleted(IndexService indexService) { for (Listener listener : listeners) { try { listener.beforeIndexDeleted(indexService); } catch (Throwable t) { logger.warn("[{}] failed to invoke before index deleted callback", t, indexService.index().name()); throw t; } } }
/** * Return the shard with the provided id, or throw an exception if it doesn't exist. */ public IndexShard getShard(int shardId) { IndexShard indexShard = getShardOrNull(shardId); if (indexShard == null) { throw new ShardNotFoundException(new ShardId(index(), shardId)); } return indexShard; }
/** * Return the shard with the provided id, or throw an exception if it doesn't exist. */ public IndexShard getShard(int shardId) { IndexShard indexShard = getShardOrNull(shardId); if (indexShard == null) { throw new ShardNotFoundException(new ShardId(index(), shardId)); } return indexShard; }
/** * Return the shard with the provided id, or throw an exception if it doesn't exist. */ public IndexShard getShard(int shardId) { IndexShard indexShard = getShardOrNull(shardId); if (indexShard == null) { throw new ShardNotFoundException(new ShardId(index(), shardId)); } return indexShard; }