org.elasticsearch.common.settings.IndexScopedSettings Java Examples

The following examples show how to use org.elasticsearch.common.settings.IndexScopedSettings. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ZentityPlugin.java    From zentity with Apache License 2.0 6 votes vote down vote up
@Override
public List<RestHandler> getRestHandlers(
        Settings settings,
        RestController restController,
        ClusterSettings clusterSettings,
        IndexScopedSettings indexScopedSettings,
        SettingsFilter settingsFilter,
        IndexNameExpressionResolver indexNameExpressionResolver,
        Supplier<DiscoveryNodes> nodesInCluster) {
    List<RestHandler> handlers = new ArrayList<RestHandler>() {{
        new HomeAction(restController);
        new ModelsAction(restController);
        new ResolutionAction(restController);
        new SetupAction(restController);
    }};
    return handlers;
}
 
Example #2
Source File: AlterTableClusterStateExecutor.java    From crate with Apache License 2.0 6 votes vote down vote up
private static void validateSettings(String name,
                                     Settings settings,
                                     IndexScopedSettings indexScopedSettings,
                                     MetaDataCreateIndexService metaDataCreateIndexService) {
    List<String> validationErrors = new ArrayList<>();
    try {
        indexScopedSettings.validate(settings, true); // templates must be consistent with regards to dependencies
    } catch (IllegalArgumentException iae) {
        validationErrors.add(iae.getMessage());
        for (Throwable t : iae.getSuppressed()) {
            validationErrors.add(t.getMessage());
        }
    }
    List<String> indexSettingsValidation = metaDataCreateIndexService.getIndexSettingsValidationErrors(settings, true);
    validationErrors.addAll(indexSettingsValidation);
    if (!validationErrors.isEmpty()) {
        ValidationException validationException = new ValidationException();
        validationException.addValidationErrors(validationErrors);
        throw new InvalidIndexTemplateException(name, validationException.getMessage());
    }
}
 
Example #3
Source File: TransportAlterTableAction.java    From crate with Apache License 2.0 6 votes vote down vote up
@Inject
public TransportAlterTableAction(TransportService transportService,
                                 ClusterService clusterService,
                                 ThreadPool threadPool,
                                 IndexNameExpressionResolver indexNameExpressionResolver,
                                 MetaDataMappingService metaDataMappingService,
                                 IndicesService indicesService,
                                 AllocationService allocationService,
                                 IndexScopedSettings indexScopedSettings,
                                 MetaDataCreateIndexService metaDataCreateIndexService) {
    super(ACTION_NAME,
          transportService,
          clusterService,
          threadPool,
          indexNameExpressionResolver,
          AlterTableRequest::new,
          AcknowledgedResponse::new,
          AcknowledgedResponse::new,
          "alter-table");
    executor = new AlterTableClusterStateExecutor(metaDataMappingService,
                                                  indicesService,
                                                  allocationService,
                                                  indexScopedSettings,
                                                  indexNameExpressionResolver,
                                                  metaDataCreateIndexService);
}
 
Example #4
Source File: BundlePlugin.java    From elasticsearch-plugin-bundle with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public List<RestHandler> getRestHandlers(Settings settings,
                                         RestController restController,
                                         ClusterSettings clusterSettings,
                                         IndexScopedSettings indexScopedSettings,
                                         SettingsFilter settingsFilter,
                                         IndexNameExpressionResolver indexNameExpressionResolver,
                                         Supplier<DiscoveryNodes> nodesInCluster) {
    List<RestHandler> extra = new ArrayList<>();
    if (settings.getAsBoolean("plugins.xbib.isbnformat.enabled", true)) {
        extra.add(new RestISBNFormatterAction(settings, restController));
    }
    if (settings.getAsBoolean("plugins.xbib.langdetect.enabled", true)) {
        extra.add(new RestLangdetectAction(settings, restController));
    }
    return extra;
}
 
Example #5
Source File: MetaDataIndexUpgradeService.java    From crate with Apache License 2.0 6 votes vote down vote up
public MetaDataIndexUpgradeService(Settings settings,
                                   NamedXContentRegistry xContentRegistry,
                                   MapperRegistry mapperRegistry,
                                   IndexScopedSettings indexScopedSettings,
                                   Collection<UnaryOperator<IndexMetaData>> indexMetaDataUpgraders) {
    this.settings = settings;
    this.xContentRegistry = xContentRegistry;
    this.mapperRegistry = mapperRegistry;
    this.indexScopedSettings = indexScopedSettings;
    this.upgraders = indexMetaData -> {
        IndexMetaData newIndexMetaData = indexMetaData;
        for (UnaryOperator<IndexMetaData> upgrader : indexMetaDataUpgraders) {
            newIndexMetaData = upgrader.apply(newIndexMetaData);
        }
        return newIndexMetaData;
    };
}
 
Example #6
Source File: MetaDataCreateIndexService.java    From crate with Apache License 2.0 6 votes vote down vote up
public MetaDataCreateIndexService(
        final Settings settings,
        final ClusterService clusterService,
        final IndicesService indicesService,
        final AllocationService allocationService,
        final AliasValidator aliasValidator,
        final Environment env,
        final IndexScopedSettings indexScopedSettings,
        final ThreadPool threadPool,
        final NamedXContentRegistry xContentRegistry,
        final boolean forbidPrivateIndexSettings) {
    this.settings = settings;
    this.clusterService = clusterService;
    this.indicesService = indicesService;
    this.allocationService = allocationService;
    this.aliasValidator = aliasValidator;
    this.env = env;
    this.indexScopedSettings = indexScopedSettings;
    this.activeShardsObserver = new ActiveShardsObserver(clusterService, threadPool);
    this.xContentRegistry = xContentRegistry;
    this.forbidPrivateIndexSettings = forbidPrivateIndexSettings;
}
 
Example #7
Source File: OpenDistroSecuritySSLPlugin.java    From deprecated-security-ssl with Apache License 2.0 5 votes vote down vote up
@Override
public List<RestHandler> getRestHandlers(Settings settings, RestController restController, ClusterSettings clusterSettings,
        IndexScopedSettings indexScopedSettings, SettingsFilter settingsFilter,
        IndexNameExpressionResolver indexNameExpressionResolver, Supplier<DiscoveryNodes> nodesInCluster) {
    
    final List<RestHandler> handlers = new ArrayList<RestHandler>(1);
    
    if (!client) {
        handlers.add(new OpenDistroSecuritySSLInfoAction(settings, configPath, restController, odsks, Objects.requireNonNull(principalExtractor)));
    }
    
    return handlers;
}
 
Example #8
Source File: AlterTableClusterStateExecutorTest.java    From crate with Apache License 2.0 5 votes vote down vote up
@Test
public void testPrivateSettingsAreRemovedOnUpdateTemplate() throws IOException {
    IndexScopedSettings indexScopedSettings = new IndexScopedSettings(Settings.EMPTY, Collections.emptySet());

    RelationName relationName = new RelationName(Schemas.DOC_SCHEMA_NAME, "t1");
    String templateName = PartitionName.templateName(relationName.schema(), relationName.name());

    Settings settings = Settings.builder()
        .put(SETTING_CREATION_DATE, false)      // private, must be filtered out
        .put(SETTING_NUMBER_OF_SHARDS, 4)
        .build();
    IndexTemplateMetaData indexTemplateMetaData = IndexTemplateMetaData.builder(templateName)
        .patterns(Collections.singletonList("*"))
        .settings(settings)
        .build();

    ClusterState initialState = ClusterState.builder(ClusterState.EMPTY_STATE)
        .metaData(MetaData.builder().put(indexTemplateMetaData))
        .build();

    ClusterState result =
        AlterTableClusterStateExecutor.updateTemplate(initialState,
                                                      relationName,
                                                      settings,
                                                      Collections.emptyMap(),
                                                      (x, y) -> { },
                                                      indexScopedSettings);

    IndexTemplateMetaData template = result.getMetaData().getTemplates().get(templateName);
    assertThat(template.settings().keySet(), contains(SETTING_NUMBER_OF_SHARDS));
}
 
Example #9
Source File: IndexSettingsModule.java    From crate with Apache License 2.0 5 votes vote down vote up
public static IndexSettings newIndexSettings(final IndexMetaData indexMetaData, Setting<?>... setting) {
    Set<Setting<?>> settingSet = new HashSet<>(IndexScopedSettings.BUILT_IN_INDEX_SETTINGS);
    if (setting.length > 0) {
        settingSet.addAll(Arrays.asList(setting));
    }
    return new IndexSettings(indexMetaData, Settings.EMPTY, new IndexScopedSettings(Settings.EMPTY, settingSet));
}
 
Example #10
Source File: IndexSettingsModule.java    From crate with Apache License 2.0 5 votes vote down vote up
public static IndexSettings newIndexSettings(Index index, Settings settings, IndexScopedSettings indexScopedSettings) {
    Settings build = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)
            .put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 1)
            .put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1)
            .put(settings)
            .build();
    IndexMetaData metaData = IndexMetaData.builder(index.getName()).settings(build).build();
    return new IndexSettings(metaData, Settings.EMPTY, indexScopedSettings);
}
 
Example #11
Source File: IndexSettingsModule.java    From crate with Apache License 2.0 5 votes vote down vote up
public static IndexSettings newIndexSettings(Index index, Settings indexSetting, Settings nodeSettings, Setting<?>... setting) {
    Settings build = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)
        .put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 1)
        .put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1)
        .put(indexSetting)
        .build();
    IndexMetaData metaData = IndexMetaData.builder(index.getName()).settings(build).build();
    Set<Setting<?>> settingSet = new HashSet<>(IndexScopedSettings.BUILT_IN_INDEX_SETTINGS);
    if (setting.length > 0) {
        settingSet.addAll(Arrays.asList(setting));
    }
    return new IndexSettings(metaData, nodeSettings, new IndexScopedSettings(Settings.EMPTY, settingSet));
}
 
Example #12
Source File: AlterTableClusterStateExecutor.java    From crate with Apache License 2.0 5 votes vote down vote up
public AlterTableClusterStateExecutor(MetaDataMappingService metaDataMappingService,
                                      IndicesService indicesService,
                                      AllocationService allocationService,
                                      IndexScopedSettings indexScopedSettings,
                                      IndexNameExpressionResolver indexNameExpressionResolver,
                                      MetaDataCreateIndexService metaDataCreateIndexService) {
    this.metaDataMappingService = metaDataMappingService;
    this.indicesService = indicesService;
    this.indexScopedSettings = indexScopedSettings;
    this.allocationService = allocationService;
    this.indexNameExpressionResolver = indexNameExpressionResolver;
    this.metaDataCreateIndexService = metaDataCreateIndexService;
}
 
Example #13
Source File: TransportPutIndexTemplateAction.java    From crate with Apache License 2.0 5 votes vote down vote up
@Inject
public TransportPutIndexTemplateAction(TransportService transportService,
                                       ClusterService clusterService,
                                       ThreadPool threadPool,
                                       MetaDataIndexTemplateService indexTemplateService,
                                       IndexNameExpressionResolver indexNameExpressionResolver,
                                       IndexScopedSettings indexScopedSettings) {
    super(PutIndexTemplateAction.NAME, transportService, clusterService, threadPool, PutIndexTemplateRequest::new, indexNameExpressionResolver);
    this.indexTemplateService = indexTemplateService;
    this.indexScopedSettings = indexScopedSettings;
}
 
Example #14
Source File: MetaDataCreateIndexService.java    From crate with Apache License 2.0 5 votes vote down vote up
IndexCreationTask(Logger logger, AllocationService allocationService, CreateIndexClusterStateUpdateRequest request,
                  ActionListener<ClusterStateUpdateResponse> listener, IndicesService indicesService,
                  AliasValidator aliasValidator, NamedXContentRegistry xContentRegistry,
                  Settings settings, IndexValidator validator, IndexScopedSettings indexScopedSettings) {
    super(Priority.URGENT, request, listener);
    this.request = request;
    this.logger = logger;
    this.allocationService = allocationService;
    this.indicesService = indicesService;
    this.aliasValidator = aliasValidator;
    this.xContentRegistry = xContentRegistry;
    this.settings = settings;
    this.validator = validator;
    this.indexScopedSettings = indexScopedSettings;
}
 
Example #15
Source File: MetaDataIndexTemplateService.java    From crate with Apache License 2.0 5 votes vote down vote up
@Inject
public MetaDataIndexTemplateService(ClusterService clusterService,
                                    MetaDataCreateIndexService metaDataCreateIndexService,
                                    AliasValidator aliasValidator, IndicesService indicesService,
                                    IndexScopedSettings indexScopedSettings, NamedXContentRegistry xContentRegistry) {
    this.clusterService = clusterService;
    this.aliasValidator = aliasValidator;
    this.indicesService = indicesService;
    this.metaDataCreateIndexService = metaDataCreateIndexService;
    this.indexScopedSettings = indexScopedSettings;
    this.xContentRegistry = xContentRegistry;
}
 
Example #16
Source File: MetaDataUpdateSettingsService.java    From crate with Apache License 2.0 5 votes vote down vote up
@Inject
public MetaDataUpdateSettingsService(ClusterService clusterService, AllocationService allocationService,
                                     IndexScopedSettings indexScopedSettings, IndicesService indicesService, ThreadPool threadPool) {
    this.clusterService = clusterService;
    this.threadPool = threadPool;
    this.allocationService = allocationService;
    this.indexScopedSettings = indexScopedSettings;
    this.indicesService = indicesService;
}
 
Example #17
Source File: ClusteringPlugin.java    From elasticsearch-carrot2 with Apache License 2.0 5 votes vote down vote up
@Override
public List<RestHandler> getRestHandlers(Settings settings, RestController restController,
                                         ClusterSettings clusterSettings,
                                         IndexScopedSettings indexScopedSettings, SettingsFilter settingsFilter,
                                         IndexNameExpressionResolver indexNameExpressionResolver,
                                         Supplier<DiscoveryNodes> nodesInCluster) {
   return Arrays.asList(
       new ClusteringAction.RestClusteringAction(restController),
       new ListAlgorithmsAction.RestListAlgorithmsAction(restController));
}
 
Example #18
Source File: DataFormatPlugin.java    From elasticsearch-dataformat with Apache License 2.0 5 votes vote down vote up
@Override
public List<RestHandler> getRestHandlers(final Settings settings,
        final RestController restController, final ClusterSettings clusterSettings,
        final IndexScopedSettings indexScopedSettings,
        final SettingsFilter settingsFilter,
        final IndexNameExpressionResolver indexNameExpressionResolver,
        final Supplier<DiscoveryNodes> nodesInCluster) {
    return Arrays.asList(new RestDataAction(settings, restController));
}
 
Example #19
Source File: OpenShiftElasticSearchPlugin.java    From openshift-elasticsearch-plugin with Apache License 2.0 5 votes vote down vote up
@Override
public List<RestHandler> getRestHandlers(Settings settings, RestController restController,
        ClusterSettings clusterSettings, IndexScopedSettings indexScopedSettings, SettingsFilter settingsFilter,
        IndexNameExpressionResolver indexNameExpressionResolver, Supplier<DiscoveryNodes> nodesInCluster) {
    List<RestHandler> list = new ArrayList<>();
    list.addAll(sgPlugin.getRestHandlers(settings, restController, clusterSettings, indexScopedSettings,
            settingsFilter, indexNameExpressionResolver, nodesInCluster));
    return list;
}
 
Example #20
Source File: LtrQueryParserPlugin.java    From elasticsearch-learning-to-rank with Apache License 2.0 5 votes vote down vote up
@Override
public List<RestHandler> getRestHandlers(Settings settings, RestController restController,
                                         ClusterSettings clusterSettings, IndexScopedSettings indexScopedSettings,
                                         SettingsFilter settingsFilter, IndexNameExpressionResolver indexNameExpressionResolver,
                                         Supplier<DiscoveryNodes> nodesInCluster) {
    List<RestHandler> list = new ArrayList<>();
    RestSimpleFeatureStore.register(list, restController);
    list.add(new RestFeatureStoreCaches());
    list.add(new RestCreateModelFromSet());
    list.add(new RestAddFeatureToSet());
    return unmodifiableList(list);
}
 
Example #21
Source File: ElasticReportPlugin.java    From elasticsearch-report-engine with GNU General Public License v3.0 5 votes vote down vote up
@Override
public List<RestHandler> getRestHandlers(Settings settings,
    RestController restController, ClusterSettings clusterSettings,
    IndexScopedSettings indexScopedSettings,
    SettingsFilter settingsFilter,
    IndexNameExpressionResolver indexNameExpressionResolver,
    Supplier<DiscoveryNodes> nodesInCluster) {
  return Arrays.asList(new ReportGenerateRestAction(settings, restController));
}
 
Example #22
Source File: AppendLucenePlugin.java    From ES-Fastloader with Apache License 2.0 5 votes vote down vote up
@Override
public List<RestHandler> getRestHandlers(Settings settings,
                                         RestController restController,
                                         ClusterSettings clusterSettings,
                                         IndexScopedSettings indexScopedSettings,
                                         SettingsFilter settingsFilter,
                                         IndexNameExpressionResolver indexNameExpressionResolver,
                                         Supplier<DiscoveryNodes> nodesInCluster) {
    return Arrays.asList( new AppendLuceneRestHandler(settings, restController));
}
 
Example #23
Source File: IndexSettings.java    From crate with Apache License 2.0 4 votes vote down vote up
public IndexScopedSettings getScopedSettings() {
    return scopedSettings;
}
 
Example #24
Source File: IndexSettings.java    From crate with Apache License 2.0 4 votes vote down vote up
/**
 * Creates a new {@link IndexSettings} instance. The given node settings will be merged with the settings in the metadata
 * while index level settings will overwrite node settings.
 *
 * @param indexMetaData the index metadata this settings object is associated with
 * @param nodeSettings the nodes settings this index is allocated on.
 */
public IndexSettings(final IndexMetaData indexMetaData, final Settings nodeSettings, IndexScopedSettings indexScopedSettings) {
    scopedSettings = indexScopedSettings.copy(nodeSettings, indexMetaData);
    this.nodeSettings = nodeSettings;
    this.settings = Settings.builder().put(nodeSettings).put(indexMetaData.getSettings()).build();
    this.index = indexMetaData.getIndex();
    version = IndexMetaData.SETTING_INDEX_VERSION_CREATED.get(settings);
    logger = Loggers.getLogger(getClass(), index);
    nodeName = Node.NODE_NAME_SETTING.get(settings);
    this.indexMetaData = indexMetaData;
    numberOfShards = settings.getAsInt(IndexMetaData.SETTING_NUMBER_OF_SHARDS, null);

    this.defaultAllowUnmappedFields = scopedSettings.get(ALLOW_UNMAPPED);
    this.durability = scopedSettings.get(INDEX_TRANSLOG_DURABILITY_SETTING);
    defaultFields = scopedSettings.get(DEFAULT_FIELD_SETTING);
    syncInterval = INDEX_TRANSLOG_SYNC_INTERVAL_SETTING.get(settings);
    refreshInterval = scopedSettings.get(INDEX_REFRESH_INTERVAL_SETTING);
    flushThresholdSize = scopedSettings.get(INDEX_TRANSLOG_FLUSH_THRESHOLD_SIZE_SETTING);
    translogRetentionAge = scopedSettings.get(INDEX_TRANSLOG_RETENTION_AGE_SETTING);
    translogRetentionSize = scopedSettings.get(INDEX_TRANSLOG_RETENTION_SIZE_SETTING);
    generationThresholdSize = scopedSettings.get(INDEX_TRANSLOG_GENERATION_THRESHOLD_SIZE_SETTING);
    flushAfterMergeThresholdSize = scopedSettings.get(INDEX_FLUSH_AFTER_MERGE_THRESHOLD_SIZE_SETTING);
    mergeSchedulerConfig = new MergeSchedulerConfig(this);
    gcDeletesInMillis = scopedSettings.get(INDEX_GC_DELETES_SETTING).getMillis();
    softDeleteEnabled = version.onOrAfter(Version.ES_V_6_5_1) && scopedSettings.get(INDEX_SOFT_DELETES_SETTING);
    softDeleteRetentionOperations = scopedSettings.get(INDEX_SOFT_DELETES_RETENTION_OPERATIONS_SETTING);
    warmerEnabled = scopedSettings.get(INDEX_WARMER_ENABLED_SETTING);
    maxNgramDiff = scopedSettings.get(MAX_NGRAM_DIFF_SETTING);
    maxShingleDiff = scopedSettings.get(MAX_SHINGLE_DIFF_SETTING);
    maxRefreshListeners = scopedSettings.get(MAX_REFRESH_LISTENERS_PER_SHARD);
    this.mergePolicyConfig = new MergePolicyConfig(logger, this);
    singleType = INDEX_MAPPING_SINGLE_TYPE_SETTING.get(indexMetaData.getSettings()); // get this from metadata - it's not registered
    if (singleType == false) {
        throw new AssertionError(
            index.toString() + "multiple types are only allowed on pre 6.x indices but version is: [" + version + "]");
    }

    scopedSettings.addSettingsUpdateConsumer(MergePolicyConfig.INDEX_COMPOUND_FORMAT_SETTING, mergePolicyConfig::setNoCFSRatio);
    scopedSettings.addSettingsUpdateConsumer(MergePolicyConfig.INDEX_MERGE_POLICY_DELETES_PCT_ALLOWED_SETTING, mergePolicyConfig::setDeletesPctAllowed);
    scopedSettings.addSettingsUpdateConsumer(MergePolicyConfig.INDEX_MERGE_POLICY_EXPUNGE_DELETES_ALLOWED_SETTING, mergePolicyConfig::setExpungeDeletesAllowed);
    scopedSettings.addSettingsUpdateConsumer(MergePolicyConfig.INDEX_MERGE_POLICY_FLOOR_SEGMENT_SETTING, mergePolicyConfig::setFloorSegmentSetting);
    scopedSettings.addSettingsUpdateConsumer(MergePolicyConfig.INDEX_MERGE_POLICY_MAX_MERGE_AT_ONCE_SETTING, mergePolicyConfig::setMaxMergesAtOnce);
    scopedSettings.addSettingsUpdateConsumer(MergePolicyConfig.INDEX_MERGE_POLICY_MAX_MERGE_AT_ONCE_EXPLICIT_SETTING, mergePolicyConfig::setMaxMergesAtOnceExplicit);
    scopedSettings.addSettingsUpdateConsumer(MergePolicyConfig.INDEX_MERGE_POLICY_MAX_MERGED_SEGMENT_SETTING, mergePolicyConfig::setMaxMergedSegment);
    scopedSettings.addSettingsUpdateConsumer(MergePolicyConfig.INDEX_MERGE_POLICY_SEGMENTS_PER_TIER_SETTING, mergePolicyConfig::setSegmentsPerTier);

    scopedSettings.addSettingsUpdateConsumer(MergeSchedulerConfig.MAX_THREAD_COUNT_SETTING, MergeSchedulerConfig.MAX_MERGE_COUNT_SETTING,
        mergeSchedulerConfig::setMaxThreadAndMergeCount);
    scopedSettings.addSettingsUpdateConsumer(MergeSchedulerConfig.AUTO_THROTTLE_SETTING, mergeSchedulerConfig::setAutoThrottle);
    scopedSettings.addSettingsUpdateConsumer(INDEX_TRANSLOG_DURABILITY_SETTING, this::setTranslogDurability);
    scopedSettings.addSettingsUpdateConsumer(MAX_NGRAM_DIFF_SETTING, this::setMaxNgramDiff);
    scopedSettings.addSettingsUpdateConsumer(MAX_SHINGLE_DIFF_SETTING, this::setMaxShingleDiff);
    scopedSettings.addSettingsUpdateConsumer(INDEX_WARMER_ENABLED_SETTING, this::setEnableWarmer);
    scopedSettings.addSettingsUpdateConsumer(INDEX_GC_DELETES_SETTING, this::setGCDeletes);
    scopedSettings.addSettingsUpdateConsumer(INDEX_TRANSLOG_FLUSH_THRESHOLD_SIZE_SETTING, this::setTranslogFlushThresholdSize);
    scopedSettings.addSettingsUpdateConsumer(
        INDEX_FLUSH_AFTER_MERGE_THRESHOLD_SIZE_SETTING,
        this::setFlushAfterMergeThresholdSize);
    scopedSettings.addSettingsUpdateConsumer(
            INDEX_TRANSLOG_GENERATION_THRESHOLD_SIZE_SETTING,
            this::setGenerationThresholdSize);
    scopedSettings.addSettingsUpdateConsumer(INDEX_TRANSLOG_RETENTION_AGE_SETTING, this::setTranslogRetentionAge);
    scopedSettings.addSettingsUpdateConsumer(INDEX_TRANSLOG_RETENTION_SIZE_SETTING, this::setTranslogRetentionSize);
    scopedSettings.addSettingsUpdateConsumer(INDEX_REFRESH_INTERVAL_SETTING, this::setRefreshInterval);
    scopedSettings.addSettingsUpdateConsumer(MAX_REFRESH_LISTENERS_PER_SHARD, this::setMaxRefreshListeners);
    scopedSettings.addSettingsUpdateConsumer(DEFAULT_FIELD_SETTING, this::setDefaultFields);
    scopedSettings.addSettingsUpdateConsumer(INDEX_SOFT_DELETES_RETENTION_OPERATIONS_SETTING, this::setSoftDeleteRetentionOperations);
}
 
Example #25
Source File: IndicesService.java    From crate with Apache License 2.0 4 votes vote down vote up
public IndicesService(Settings settings,
                      PluginsService pluginsService,
                      NodeEnvironment nodeEnv,
                      NamedXContentRegistry xContentRegistry,
                      AnalysisRegistry analysisRegistry,
                      MapperRegistry mapperRegistry,
                      NamedWriteableRegistry namedWriteableRegistry,
                      ThreadPool threadPool,
                      IndexScopedSettings indexScopedSettings,
                      CircuitBreakerService circuitBreakerService,
                      BigArrays bigArrays,
                      Client client,
                      MetaStateService metaStateService,
                      Collection<Function<IndexSettings, Optional<EngineFactory>>> engineFactoryProviders,
                      Map<String, Function<IndexSettings, IndexStore>> indexStoreFactories) {
    this.settings = settings;
    this.threadPool = threadPool;
    this.pluginsService = pluginsService;
    this.nodeEnv = nodeEnv;
    this.xContentRegistry = xContentRegistry;
    this.shardsClosedTimeout = settings.getAsTime(INDICES_SHARDS_CLOSED_TIMEOUT, new TimeValue(1, TimeUnit.DAYS));
    this.analysisRegistry = analysisRegistry;
    this.indicesQueryCache = new IndicesQueryCache(settings);
    this.mapperRegistry = mapperRegistry;
    this.namedWriteableRegistry = namedWriteableRegistry;
    indexingMemoryController = new IndexingMemoryController(
        settings,
        threadPool,
        // ensure we pull an iter with new shards - flatten makes a copy
        () -> Iterables.flatten(this).iterator()
    );
    this.indexScopedSettings = indexScopedSettings;
    this.circuitBreakerService = circuitBreakerService;
    this.bigArrays = bigArrays;
    this.client = client;
    this.metaStateService = metaStateService;
    this.engineFactoryProviders = engineFactoryProviders;

    // do not allow any plugin-provided index store type to conflict with a built-in type
    for (final String indexStoreType : indexStoreFactories.keySet()) {
        if (IndexModule.isBuiltinType(indexStoreType)) {
            throw new IllegalStateException("registered index store type [" + indexStoreType + "] conflicts with a built-in type");
        }
    }

    this.indexStoreFactories = indexStoreFactories;
}
 
Example #26
Source File: MetaDataCreateIndexService.java    From crate with Apache License 2.0 4 votes vote down vote up
static void prepareResizeIndexSettings(
        final ClusterState currentState,
        final Set<String> mappingKeys,
        final Settings.Builder indexSettingsBuilder,
        final Index resizeSourceIndex,
        final String resizeIntoName,
        final ResizeType type,
        final boolean copySettings,
        final IndexScopedSettings indexScopedSettings) {
    final IndexMetaData sourceMetaData = currentState.metaData().index(resizeSourceIndex.getName());
    if (type == ResizeType.SHRINK) {
        final List<String> nodesToAllocateOn = validateShrinkIndex(currentState, resizeSourceIndex.getName(),
            mappingKeys, resizeIntoName, indexSettingsBuilder.build());
        indexSettingsBuilder
            // we use "i.r.a.initial_recovery" rather than "i.r.a.require|include" since we want the replica to allocate right away
            // once we are allocated.
            .put(IndexMetaData.INDEX_ROUTING_INITIAL_RECOVERY_GROUP_SETTING.getKey() + "_id",
                Strings.arrayToCommaDelimitedString(nodesToAllocateOn.toArray()))
            // we only try once and then give up with a shrink index
            .put("index.allocation.max_retries", 1)
            // we add the legacy way of specifying it here for BWC. We can remove this once it's backported to 6.x
            .put(IndexMetaData.INDEX_SHRINK_SOURCE_NAME.getKey(), resizeSourceIndex.getName())
            .put(IndexMetaData.INDEX_SHRINK_SOURCE_UUID.getKey(), resizeSourceIndex.getUUID());
    } else if (type == ResizeType.SPLIT) {
        validateSplitIndex(currentState, resizeSourceIndex.getName(), mappingKeys, resizeIntoName, indexSettingsBuilder.build());
    } else {
        throw new IllegalStateException("unknown resize type is " + type);
    }

    final Settings.Builder builder = Settings.builder();
    if (copySettings) {
        // copy all settings and non-copyable settings and settings that have already been set (e.g., from the request)
        for (final String key : sourceMetaData.getSettings().keySet()) {
            final Setting<?> setting = indexScopedSettings.get(key);
            if (setting == null) {
                assert indexScopedSettings.isPrivateSetting(key) : key;
            } else if (setting.getProperties().contains(Setting.Property.NotCopyableOnResize)) {
                continue;
            }
            // do not override settings that have already been set (for example, from the request)
            if (indexSettingsBuilder.keys().contains(key)) {
                continue;
            }
            builder.copy(key, sourceMetaData.getSettings());
        }
    } else {
        final Predicate<String> sourceSettingsPredicate =
            (s) -> (s.startsWith("index.similarity.") || s.startsWith("index.analysis.") || s.startsWith("index.sort.") ||
                    s.equals("index.mapping.single_type") || s.equals("index.soft_deletes.enabled"))
                    && indexSettingsBuilder.keys().contains(s) == false;
        builder.put(sourceMetaData.getSettings().filter(sourceSettingsPredicate));
    }

    indexSettingsBuilder
        .put(IndexMetaData.SETTING_INDEX_VERSION_CREATED.getKey(), sourceMetaData.getCreationVersion())
        .put(IndexMetaData.SETTING_VERSION_UPGRADED, sourceMetaData.getUpgradedVersion())
        .put(builder.build())
        .put(IndexMetaData.SETTING_ROUTING_PARTITION_SIZE, sourceMetaData.getRoutingPartitionSize())
        .put(IndexMetaData.INDEX_RESIZE_SOURCE_NAME.getKey(), resizeSourceIndex.getName())
        .put(IndexMetaData.INDEX_RESIZE_SOURCE_UUID.getKey(), resizeSourceIndex.getUUID());
}
 
Example #27
Source File: SqlPlug.java    From elasticsearch-sql with Apache License 2.0 4 votes vote down vote up
@Override
public List<RestHandler> getRestHandlers(Settings settings, RestController restController, ClusterSettings clusterSettings, IndexScopedSettings indexScopedSettings, SettingsFilter settingsFilter, IndexNameExpressionResolver indexNameExpressionResolver, Supplier<DiscoveryNodes> nodesInCluster) {
    return Collections.singletonList(new RestSqlAction());
}
 
Example #28
Source File: SqlPlugin.java    From elasticsearch-sql with MIT License 4 votes vote down vote up
@Override
public List<RestHandler> getRestHandlers(Settings settings, RestController restController, ClusterSettings clusterSettings, IndexScopedSettings indexScopedSettings, SettingsFilter settingsFilter, IndexNameExpressionResolver indexNameExpressionResolver, Supplier<DiscoveryNodes> nodesInCluster) {
    return Collections.singletonList(new RestSqlAction());
}
 
Example #29
Source File: AnomalyDetectorPlugin.java    From anomaly-detection with Apache License 2.0 4 votes vote down vote up
@Override
public List<RestHandler> getRestHandlers(
    Settings settings,
    RestController restController,
    ClusterSettings clusterSettings,
    IndexScopedSettings indexScopedSettings,
    SettingsFilter settingsFilter,
    IndexNameExpressionResolver indexNameExpressionResolver,
    Supplier<DiscoveryNodes> nodesInCluster
) {
    AnomalyResultHandler anomalyResultHandler = new AnomalyResultHandler(
        client,
        settings,
        clusterService,
        indexNameExpressionResolver,
        anomalyDetectionIndices,
        threadPool
    );
    AnomalyDetectorJobRunner jobRunner = AnomalyDetectorJobRunner.getJobRunnerInstance();
    jobRunner.setClient(client);
    jobRunner.setClientUtil(clientUtil);
    jobRunner.setThreadPool(threadPool);
    jobRunner.setAnomalyResultHandler(anomalyResultHandler);
    jobRunner.setSettings(settings);

    AnomalyDetectorProfileRunner profileRunner = new AnomalyDetectorProfileRunner(
        client,
        this.xContentRegistry,
        this.nodeFilter,
        indexNameExpressionResolver,
        clusterService,
        Calendar.getInstance(TimeZone.getTimeZone("UTC"))
    );
    RestGetAnomalyDetectorAction restGetAnomalyDetectorAction = new RestGetAnomalyDetectorAction(profileRunner);
    RestIndexAnomalyDetectorAction restIndexAnomalyDetectorAction = new RestIndexAnomalyDetectorAction(
        settings,
        clusterService,
        anomalyDetectionIndices
    );
    RestSearchAnomalyDetectorAction searchAnomalyDetectorAction = new RestSearchAnomalyDetectorAction();
    RestSearchAnomalyResultAction searchAnomalyResultAction = new RestSearchAnomalyResultAction();
    RestDeleteAnomalyDetectorAction deleteAnomalyDetectorAction = new RestDeleteAnomalyDetectorAction(clusterService);
    RestExecuteAnomalyDetectorAction executeAnomalyDetectorAction = new RestExecuteAnomalyDetectorAction(
        settings,
        clusterService,
        anomalyDetectorRunner
    );
    RestStatsAnomalyDetectorAction statsAnomalyDetectorAction = new RestStatsAnomalyDetectorAction(
        adStats,
        this.nodeFilter,
        this.clusterService
    );
    RestAnomalyDetectorJobAction anomalyDetectorJobAction = new RestAnomalyDetectorJobAction(
        settings,
        clusterService,
        anomalyDetectionIndices
    );

    return ImmutableList
        .of(
            restGetAnomalyDetectorAction,
            restIndexAnomalyDetectorAction,
            searchAnomalyDetectorAction,
            searchAnomalyResultAction,
            deleteAnomalyDetectorAction,
            executeAnomalyDetectorAction,
            anomalyDetectorJobAction,
            statsAnomalyDetectorAction
        );
}
 
Example #30
Source File: IndexSettings.java    From crate with Apache License 2.0 2 votes vote down vote up
/**
 * Compare the specified settings for equality.
 *
 * @param left  the left settings
 * @param right the right settings
 * @return true if the settings are the same, otherwise false
 */
public static boolean same(final Settings left, final Settings right) {
    return left.filter(IndexScopedSettings.INDEX_SETTINGS_KEY_PREDICATE)
            .equals(right.filter(IndexScopedSettings.INDEX_SETTINGS_KEY_PREDICATE));
}