forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Adding best_compression (elastic#49974) This commit adds a `codec` parameter to the ILM `forcemerge` action. When setting the codec to `best_compression` ILM will close the index, then update the codec setting, re-open the index, and finally perform a force merge. * Fix ForceMergeAction toSteps construction (elastic#51825) There was a duplicate force merge step and the test continued to fail. This commit clarifies the `toStep` method and changes the `assertBestCompression` method for better readability. Resolves elastic#51822 * Update version constants Co-authored-by: Sivagurunathan Velayutham <sivadeva.93@gmail.com>
- Loading branch information
1 parent
38ce428
commit 0be61a3
Showing
11 changed files
with
931 additions
and
31 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/CloseIndexStep.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.core.ilm; | ||
|
||
import org.elasticsearch.ElasticsearchException; | ||
import org.elasticsearch.action.ActionListener; | ||
import org.elasticsearch.action.admin.indices.close.CloseIndexRequest; | ||
import org.elasticsearch.client.Client; | ||
import org.elasticsearch.cluster.ClusterState; | ||
import org.elasticsearch.cluster.ClusterStateObserver; | ||
import org.elasticsearch.cluster.metadata.IndexMetaData; | ||
|
||
/** | ||
* Invokes a close step on a single index. | ||
*/ | ||
|
||
public class CloseIndexStep extends AsyncActionStep { | ||
public static final String NAME = "close-index"; | ||
|
||
CloseIndexStep(StepKey key, StepKey nextStepKey, Client client) { | ||
super(key, nextStepKey, client); | ||
} | ||
|
||
@Override | ||
public void performAction(IndexMetaData indexMetaData, ClusterState currentClusterState, | ||
ClusterStateObserver observer, Listener listener) { | ||
if (indexMetaData.getState() == IndexMetaData.State.OPEN) { | ||
CloseIndexRequest request = new CloseIndexRequest(indexMetaData.getIndex().getName()); | ||
getClient().admin().indices() | ||
.close(request, ActionListener.wrap(closeIndexResponse -> { | ||
if (closeIndexResponse.isAcknowledged() == false) { | ||
throw new ElasticsearchException("close index request failed to be acknowledged"); | ||
} | ||
listener.onResponse(true); | ||
}, listener::onFailure)); | ||
} | ||
else { | ||
listener.onResponse(true); | ||
} | ||
} | ||
|
||
@Override | ||
public boolean isRetryable() { | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/OpenIndexStep.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.core.ilm; | ||
|
||
import org.elasticsearch.ElasticsearchException; | ||
import org.elasticsearch.action.ActionListener; | ||
import org.elasticsearch.action.admin.indices.open.OpenIndexRequest; | ||
import org.elasticsearch.client.Client; | ||
import org.elasticsearch.cluster.ClusterState; | ||
import org.elasticsearch.cluster.ClusterStateObserver; | ||
import org.elasticsearch.cluster.metadata.IndexMetaData; | ||
|
||
/** | ||
* Invokes a open step on a single index. | ||
*/ | ||
|
||
final class OpenIndexStep extends AsyncActionStep { | ||
|
||
static final String NAME = "open-index"; | ||
|
||
OpenIndexStep(StepKey key, StepKey nextStepKey, Client client) { | ||
super(key, nextStepKey, client); | ||
} | ||
|
||
@Override | ||
public void performAction(IndexMetaData indexMetaData, ClusterState currentClusterState, | ||
ClusterStateObserver observer, Listener listener) { | ||
if (indexMetaData.getState() == IndexMetaData.State.CLOSE) { | ||
OpenIndexRequest request = new OpenIndexRequest(indexMetaData.getIndex().getName()); | ||
getClient().admin().indices() | ||
.open(request, | ||
ActionListener.wrap(openIndexResponse -> { | ||
if (openIndexResponse.isAcknowledged() == false) { | ||
throw new ElasticsearchException("open index request failed to be acknowledged"); | ||
} | ||
listener.onResponse(true); | ||
}, listener::onFailure)); | ||
|
||
} else { | ||
listener.onResponse(true); | ||
} | ||
} | ||
|
||
@Override | ||
public boolean isRetryable() { | ||
return true; | ||
} | ||
} |
Oops, something went wrong.