use of org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest in project crate by crate.
the class DecommissioningService method decommission.
private void decommission() {
// fail on new requests so that clients don't use this node anymore
sqlOperations.disable();
/*
* setting this setting will cause the {@link DecommissionAllocationDecider} to prevent allocations onto this node
*
* nodeIds are part of the key to prevent conflicts if other nodes are being decommissioned in parallel
*/
Settings settings = Settings.builder().put(DECOMMISSION_PREFIX + clusterService.localNode().getId(), true).build();
updateSettingsAction.execute(new ClusterUpdateSettingsRequest().transientSettings(settings), new ActionListener<ClusterUpdateSettingsResponse>() {
@Override
public void onResponse(ClusterUpdateSettingsResponse clusterUpdateSettingsResponse) {
// changing settings triggers AllocationService.reroute -> shards will be relocated
// NOTE: it waits for ALL relocating shards, not just those that involve THIS node.
ClusterHealthRequest request = new ClusterHealthRequest().waitForRelocatingShards(0).waitForEvents(Priority.LANGUID).timeout(gracefulStopTimeout);
if (dataAvailability == DataAvailability.FULL) {
request = request.waitForGreenStatus();
} else {
request = request.waitForYellowStatus();
}
final long startTime = System.nanoTime();
healthAction.execute(request, new ActionListener<ClusterHealthResponse>() {
@Override
public void onResponse(ClusterHealthResponse clusterHealthResponse) {
exitIfNoActiveRequests(startTime);
}
@Override
public void onFailure(Throwable e) {
forceStopOrAbort(e);
}
});
}
@Override
public void onFailure(Throwable e) {
logger.error("Couldn't set settings. Graceful shutdown failed", e);
}
});
}
use of org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest in project crate by crate.
the class ESClusterUpdateSettingsTask method execute.
@Override
public void execute(BatchConsumer consumer, Row parameters) {
ClusterUpdateSettingsRequest request = buildESUpdateClusterSettingRequest(buildSettingsFrom(plan.persistentSettings(), parameters), buildSettingsFrom(plan.transientSettings(), parameters));
OneRowActionListener<ClusterUpdateSettingsResponse> actionListener = new OneRowActionListener<>(consumer, TO_ONE_ROW);
transport.execute(request, actionListener);
}
use of org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest in project crate by crate.
the class DecommissioningService method clusterSetDecommissionNodeSetting.
private CompletableFuture<ClusterUpdateSettingsResponse> clusterSetDecommissionNodeSetting() {
if (dataAvailability == DataAvailability.NONE) {
return CompletableFuture.completedFuture(null);
}
/*
* setting this setting will cause the {@link DecommissionAllocationDecider} to prevent allocations onto this node
*
* nodeIds are part of the key to prevent conflicts if other nodes are being decommissioned in parallel
*/
Settings settings = Settings.builder().put(DECOMMISSION_PREFIX + clusterService.localNode().getId(), true).build();
FutureActionListener<ClusterUpdateSettingsResponse, ClusterUpdateSettingsResponse> settingsResponseFutureListener = FutureActionListener.newInstance();
updateSettingsAction.execute(new ClusterUpdateSettingsRequest().transientSettings(settings), settingsResponseFutureListener);
return settingsResponseFutureListener;
}
use of org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest in project crate by crate.
the class ResetSettingsPlan 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);
Settings settings = buildSettingsFrom(resetAnalyzedStatement.settingsToRemove(), eval);
ClusterUpdateSettingsRequest request = new ClusterUpdateSettingsRequest().persistentSettings(settings).transientSettings(settings);
OneRowActionListener<ClusterUpdateSettingsResponse> actionListener = new OneRowActionListener<>(consumer, r -> r.isAcknowledged() ? new Row1(1L) : new Row1(0L));
dependencies.transportActionProvider().transportClusterUpdateSettingsAction().execute(request, actionListener);
}
use of org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest in project crate by crate.
the class CreateAnalyzerAnalyzerTest method testCreateAnalyzerSimple.
@Test
public void testCreateAnalyzerSimple() throws Exception {
ClusterUpdateSettingsRequest request = analyze("CREATE ANALYZER a1 (TOKENIZER lowercase)");
assertThat(extractAnalyzerSettings("a1", request.persistentSettings()), allOf(hasEntry("index.analysis.analyzer.a1.tokenizer", "lowercase"), hasEntry("index.analysis.analyzer.a1.type", "custom")));
}
Aggregations