/** * Sets the {@link IndexWriter} this config is attached to. * * @throws AlreadySetException * if this config is already attached to a writer. */ IndexWriterConfig setIndexWriter(IndexWriter writer) { if (this.writer.get() != null) { throw new IllegalStateException("do not share IndexWriterConfig instances across IndexWriters"); } this.writer.set(writer); return this; }
/** * Sets the {@link XContentType} */ final void setXContentType(XContentType xContentType) { this.xContentType.set(xContentType); }
/** * Set the name of this node. */ static void setNodeName(String nodeName) { NODE_NAME.set(nodeName); }
/** * if this method is called the query context will throw exception if methods are accessed * that could yield different results across executions like {@link #getClient()} */ public final void freezeContext() { this.frozen.set(Boolean.TRUE); }
@Override public void onRejection(Exception e) { failure.set(e); }
void freeze() { freeze.set(true); }
/** Sets the offset gap of the analyzer. The default is defined * in the analyzer base class. * @see Analyzer#getOffsetGap(String) */ public Builder withOffsetGap(int offsetGap) { if (offsetGap < 0) { throw new IllegalArgumentException("offsetGap must be >= 0"); } this.offsetGap.set(offsetGap); return this; }
/** Sets the position increment gap of the analyzer. * The default is defined in the analyzer base class. * @see Analyzer#getPositionIncrementGap(String) */ public Builder withPositionIncrementGap(int posIncGap) { if (posIncGap < 0) { throw new IllegalArgumentException("posIncGap must be >= 0"); } this.posIncGap.set(posIncGap); return this; }
/** This match version is passed as default to all tokenizers or filters. It is used unless you * pass the parameter {code luceneMatchVersion} explicitly. It defaults to undefined, so the * underlying factory will (in most cases) use {@link Version#LATEST}. */ public Builder withDefaultMatchVersion(Version version) { Objects.requireNonNull(version, "version may not be null"); if (componentsAdded) { throw new IllegalStateException("You may only set the default match version before adding tokenizers, "+ "token filters, or char filters."); } this.defaultMatchVersion.set(version); return this; }
/** * Forces a certain query cache to use instead of the default one. If this is set * and query caching is not disabled with {@code index.queries.cache.enabled}, then * the given provider will be used. * NOTE: this can only be set once * * @see #INDEX_QUERY_CACHE_ENABLED_SETTING */ public void forceQueryCacheProvider(BiFunction<IndexSettings, IndicesQueryCache, QueryCache> queryCacheProvider) { ensureNotFrozen(); this.forceQueryCacheProvider.set(queryCacheProvider); }
/** * Sets a {@link org.elasticsearch.index.IndexModule.IndexSearcherWrapperFactory} that is called once the IndexService * is fully constructed. * Note: this method can only be called once per index. Multiple wrappers are not supported. */ public void setSearcherWrapper(IndexSearcherWrapperFactory indexSearcherWrapperFactory) { ensureNotFrozen(); this.indexSearcherWrapper.set(indexSearcherWrapperFactory); }
@Override public void onFailure(Exception e) { logger.warn(() -> new ParameterizedMessage("[{}][{}] failed to snapshot shard", shardId, snapshot), e); failure.set(e); }
/** Returns the fully qualified setting names contained in this settings object. */ public Set<String> keySet() { synchronized (keys) { if (keys.get() == null) { if (secureSettings == null) { keys.set(settings.keySet()); } else { Stream<String> stream = Stream.concat(settings.keySet().stream(), secureSettings.getSettingNames().stream()); // uniquify, since for legacy reasons the same setting name may exist in both keys.set(Collections.unmodifiableSet(stream.collect(Collectors.toSet()))); } } } return keys.get(); }
@Override public Set<String> getSettingNames() { synchronized (settingNames) { if (settingNames.get() == null) { Set<String> names = delegate.getSettingNames().stream() .filter(keyPredicate).map(removePrefix).collect(Collectors.toSet()); settingNames.set(Collections.unmodifiableSet(names)); } } return settingNames.get(); }
/** Constructs a new keystore with the given password. */ public static KeyStoreWrapper create() { KeyStoreWrapper wrapper = new KeyStoreWrapper(FORMAT_VERSION, false, null); wrapper.entries.set(new HashMap<>()); addBootstrapSeed(wrapper); return wrapper; }
/** Uses the given tokenizer. * @param name is used to look up the factory with {@link TokenizerFactory#forName(String, Map)}. * The list of possible names can be looked up with {@link TokenizerFactory#availableTokenizers()}. * @param params the map of parameters to be passed to factory. The map must be modifiable. */ public Builder withTokenizer(String name, Map<String,String> params) throws IOException { Objects.requireNonNull(name, "Tokenizer name may not be null"); tokenizer.set(applyResourceLoader(TokenizerFactory.forName(name, applyDefaultParams(params)))); componentsAdded = true; return this; }
/** Uses the given tokenizer. * @param factory class that is used to create the tokenizer. * @param params the map of parameters to be passed to factory. The map must be modifiable. */ public Builder withTokenizer(Class<? extends TokenizerFactory> factory, Map<String,String> params) throws IOException { Objects.requireNonNull(factory, "Tokenizer factory may not be null"); tokenizer.set(applyResourceLoader(newFactoryClassInstance(factory, applyDefaultParams(params)))); componentsAdded = true; return this; }
public Builder setSecureSettings(SecureSettings secureSettings) { if (secureSettings.isLoaded() == false) { throw new IllegalStateException("Secure settings must already be loaded"); } if (this.secureSettings.get() != null) { throw new IllegalArgumentException("Secure settings already set. Existing settings: " + this.secureSettings.get().getSettingNames() + ", new settings: " + secureSettings.getSettingNames()); } this.secureSettings.set(secureSettings); return this; }
@Override public DiscoveryNode apply(BoundTransportAddress boundTransportAddress) { localNode.set(DiscoveryNode.createLocal(settings, boundTransportAddress.publishAddress(), persistentNodeId)); return localNode.get(); }
/** * maintains single lazy instance of {@link BlobContainer} */ protected BlobContainer blobContainer() { assertSnapshotOrGenericThread(); BlobContainer blobContainer = this.blobContainer.get(); if (blobContainer == null) { synchronized (lock) { blobContainer = this.blobContainer.get(); if (blobContainer == null) { blobContainer = blobStore().blobContainer(basePath()); this.blobContainer.set(blobContainer); } } } return blobContainer; }