Search in sources :

Example 21 with ClusterUpdateSettingsRequest

use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest in project crate by crate.

the class DropAnalyzerPlan method createRequest.

@VisibleForTesting
public static ClusterUpdateSettingsRequest createRequest(String analyzerName, FulltextAnalyzerResolver ftResolver) {
    Settings.Builder builder = Settings.builder();
    builder.putNull(ANALYZER.buildSettingName(analyzerName));
    Settings settings = ftResolver.getCustomAnalyzer(analyzerName);
    String tokenizerName = settings.get(ANALYZER.buildSettingChildName(analyzerName, TOKENIZER.getName()));
    if (tokenizerName != null && ftResolver.hasCustomThingy(tokenizerName, FulltextAnalyzerResolver.CustomType.TOKENIZER)) {
        builder.putNull(TOKENIZER.buildSettingName(tokenizerName));
    }
    for (String tokenFilterName : settings.getAsList(ANALYZER.buildSettingChildName(analyzerName, TOKEN_FILTER.getName()))) {
        if (ftResolver.hasCustomThingy(tokenFilterName, FulltextAnalyzerResolver.CustomType.TOKEN_FILTER)) {
            builder.putNull(TOKEN_FILTER.buildSettingName(tokenFilterName));
        }
    }
    for (String charFilterName : settings.getAsList(ANALYZER.buildSettingChildName(analyzerName, CHAR_FILTER.getName()))) {
        if (ftResolver.hasCustomThingy(charFilterName, FulltextAnalyzerResolver.CustomType.CHAR_FILTER)) {
            builder.putNull(CHAR_FILTER.buildSettingName(charFilterName));
        }
    }
    return new ClusterUpdateSettingsRequest().persistentSettings(builder.build());
}
Also used : Settings(org.elasticsearch.common.settings.Settings) ClusterUpdateSettingsRequest(org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest) VisibleForTesting(io.crate.common.annotations.VisibleForTesting)

Example 22 with ClusterUpdateSettingsRequest

use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest in project crate by crate.

the class UpdateSettingsPlan method executeOrFail.

@Override
public void executeOrFail(DependencyCarrier dependencies, PlannerContext plannerContext, RowConsumer consumer, Row params, SubQueryResults subQueryResults) {
    Function<? super Symbol, Object> eval = x -> SymbolEvaluator.evaluate(plannerContext.transactionContext(), plannerContext.nodeContext(), x, params, subQueryResults);
    ClusterUpdateSettingsRequest request = isPersistent ? new ClusterUpdateSettingsRequest().persistentSettings(buildSettingsFrom(settings, eval)) : new ClusterUpdateSettingsRequest().transientSettings(buildSettingsFrom(settings, eval));
    OneRowActionListener<ClusterUpdateSettingsResponse> actionListener = new OneRowActionListener<>(consumer, r -> r.isAcknowledged() ? new Row1(1L) : new Row1(0L));
    dependencies.transportActionProvider().transportClusterUpdateSettingsAction().execute(request, actionListener);
}
Also used : CrateSettings(io.crate.metadata.settings.CrateSettings) Collection(java.util.Collection) Function(java.util.function.Function) Lists2(io.crate.common.collections.Lists2) RowConsumer(io.crate.data.RowConsumer) DependencyCarrier(io.crate.planner.DependencyCarrier) Assignment(io.crate.sql.tree.Assignment) SymbolEvaluator(io.crate.analyze.SymbolEvaluator) ClusterUpdateSettingsRequest(org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest) Settings(org.elasticsearch.common.settings.Settings) Row(io.crate.data.Row) Symbol(io.crate.expression.symbol.Symbol) PlannerContext(io.crate.planner.PlannerContext) Plan(io.crate.planner.Plan) SubQueryResults(io.crate.planner.operators.SubQueryResults) ClusterUpdateSettingsResponse(org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse) VisibleForTesting(io.crate.common.annotations.VisibleForTesting) OneRowActionListener(io.crate.execution.support.OneRowActionListener) Row1(io.crate.data.Row1) Row1(io.crate.data.Row1) OneRowActionListener(io.crate.execution.support.OneRowActionListener) ClusterUpdateSettingsResponse(org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse) ClusterUpdateSettingsRequest(org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest)

Example 23 with ClusterUpdateSettingsRequest

use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest in project graylog2-server by Graylog2.

the class ClientES7 method putSetting.

@Override
public void putSetting(String setting, String value) {
    final ClusterUpdateSettingsRequest request = new ClusterUpdateSettingsRequest();
    request.persistentSettings(Settings.builder().put(setting, value));
    client.execute((c, requestOptions) -> c.cluster().putSettings(request, requestOptions), "Unable to update ES cluster setting: " + setting + "=" + value);
}
Also used : ClusterUpdateSettingsRequest(org.graylog.shaded.elasticsearch7.org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest)

Aggregations

ClusterUpdateSettingsRequest (org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest)22 Settings (org.elasticsearch.common.settings.Settings)10 CrateDummyClusterServiceUnitTest (io.crate.test.integration.CrateDummyClusterServiceUnitTest)9 Test (org.junit.Test)9 ClusterUpdateSettingsResponse (org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse)8 VisibleForTesting (io.crate.common.annotations.VisibleForTesting)6 Row (io.crate.data.Row)5 Row1 (io.crate.data.Row1)5 RowConsumer (io.crate.data.RowConsumer)5 OneRowActionListener (io.crate.execution.support.OneRowActionListener)5 DependencyCarrier (io.crate.planner.DependencyCarrier)5 Plan (io.crate.planner.Plan)5 PlannerContext (io.crate.planner.PlannerContext)5 SubQueryResults (io.crate.planner.operators.SubQueryResults)5 SymbolEvaluator (io.crate.analyze.SymbolEvaluator)4 Symbol (io.crate.expression.symbol.Symbol)4 Function (java.util.function.Function)4 FulltextAnalyzerResolver (io.crate.metadata.FulltextAnalyzerResolver)3 ANALYZER (io.crate.metadata.FulltextAnalyzerResolver.CustomType.ANALYZER)3 CHAR_FILTER (io.crate.metadata.FulltextAnalyzerResolver.CustomType.CHAR_FILTER)3