forked from opensearch-project/OpenSearch
-
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.
Add rest, transport layer changes for Hot to warm tiering - dedicated…
… setup Signed-off-by: Neetika Singhal <[email protected]>
- Loading branch information
1 parent
8ae728c
commit 5569b43
Showing
15 changed files
with
1,694 additions
and
1 deletion.
There are no files selected for viewing
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
26 changes: 26 additions & 0 deletions
26
server/src/main/java/org/opensearch/action/tiering/HotToWarmTieringAction.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,26 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.action.tiering; | ||
|
||
import org.opensearch.action.ActionType; | ||
|
||
/** | ||
* Tiering action to move indices from hot to warm | ||
* | ||
* @opensearch.experimental | ||
*/ | ||
public class HotToWarmTieringAction extends ActionType<HotToWarmTieringResponse> { | ||
|
||
public static final HotToWarmTieringAction INSTANCE = new HotToWarmTieringAction(); | ||
public static final String NAME = "indices:admin/tier/hot_to_warm"; | ||
|
||
public HotToWarmTieringAction() { | ||
super(NAME, HotToWarmTieringResponse::new); | ||
} | ||
} |
233 changes: 233 additions & 0 deletions
233
server/src/main/java/org/opensearch/action/tiering/HotToWarmTieringRequestContext.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,233 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.action.tiering; | ||
|
||
import org.opensearch.common.UUIDs; | ||
import org.opensearch.core.action.ActionListener; | ||
import org.opensearch.core.index.Index; | ||
|
||
import java.util.HashMap; | ||
import java.util.HashSet; | ||
import java.util.LinkedList; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Set; | ||
|
||
/** | ||
* Context class to hold indices to be tiered per request. It also holds | ||
* the listener per request to mark the request as complete once all | ||
* tiering operations are completed. | ||
* | ||
* @opensearch.experimental | ||
*/ | ||
|
||
public class HotToWarmTieringRequestContext { | ||
private Set<Index> concreteIndices; | ||
private Set<Index> acceptedIndices; | ||
private Map<String, String> rejectedIndices; | ||
private Set<String> notFoundIndices; | ||
private Set<Index> inProgressIndices; | ||
private Set<String> successfulIndices; | ||
private Map<String, String> failedIndices; | ||
private ActionListener<HotToWarmTieringResponse> actionListener; | ||
private TieringIndexRequest request; | ||
private String requestUuid; | ||
|
||
public HotToWarmTieringRequestContext() { | ||
this.acceptedIndices = new HashSet<>(); | ||
this.rejectedIndices = new HashMap<>(); | ||
this.notFoundIndices = new HashSet<>(); | ||
this.successfulIndices = new HashSet<>(); | ||
this.failedIndices = new HashMap<>(); | ||
this.inProgressIndices = new HashSet<>(); | ||
this.requestUuid = UUIDs.randomBase64UUID(); | ||
} | ||
|
||
public HotToWarmTieringRequestContext(ActionListener<HotToWarmTieringResponse> actionListener, TieringIndexRequest request) { | ||
this(); | ||
this.actionListener = actionListener; | ||
this.request = request; | ||
} | ||
|
||
public Set<Index> getConcreteIndices() { | ||
return concreteIndices; | ||
} | ||
|
||
public void setConcreteIndices(Set<Index> concreteIndices) { | ||
this.concreteIndices = concreteIndices; | ||
} | ||
|
||
public Set<Index> getAcceptedIndices() { | ||
return acceptedIndices; | ||
} | ||
|
||
public void setAcceptedIndices(Set<Index> acceptedIndices) { | ||
this.acceptedIndices = acceptedIndices; | ||
} | ||
|
||
public void setAcceptedAndInProgressIndices(Set<Index> acceptedIndices) { | ||
this.acceptedIndices = acceptedIndices; | ||
this.inProgressIndices.addAll(acceptedIndices); | ||
} | ||
|
||
public Map<String, String> getRejectedIndices() { | ||
return rejectedIndices; | ||
} | ||
|
||
public Set<String> getNotFoundIndices() { | ||
return notFoundIndices; | ||
} | ||
|
||
public void setNotFoundIndices(Set<String> notFoundIndices) { | ||
this.notFoundIndices = notFoundIndices; | ||
} | ||
|
||
public void setRejectedIndices(Map<String, String> rejectedIndices) { | ||
this.rejectedIndices = rejectedIndices; | ||
} | ||
|
||
public void addToNotFound(String indexName) { | ||
notFoundIndices.add(indexName); | ||
} | ||
|
||
/** | ||
* Method to move indices from success list to failed list with corresponding reasons to be sent in response | ||
* @param indicesToFail - sets of indices that failed validation with same reason | ||
* @param failureReason - reason for not accepting migration for this index | ||
*/ | ||
public void addToRejected(Set<String> indicesToFail, String failureReason) { | ||
for (String index : indicesToFail) { | ||
addToRejected(index, failureReason); | ||
} | ||
} | ||
|
||
/** | ||
* Method to move index from success list to failed list with corresponding reasons to be sent in response | ||
* @param indexName - indexName that failed validation | ||
* @param failureReason - reason for not accepting migration for this index | ||
*/ | ||
public void addToRejected(String indexName, String failureReason) { | ||
rejectedIndices.put(indexName, failureReason); | ||
} | ||
|
||
public void addToAccepted(Index index) { | ||
acceptedIndices.add(index); | ||
} | ||
|
||
public void addToAccepted(Set<Index> indices) { | ||
acceptedIndices.addAll(indices); | ||
} | ||
|
||
public Set<String> getSuccessfulIndices() { | ||
return successfulIndices; | ||
} | ||
|
||
public void setSuccessfulIndices(Set<String> successfulIndices) { | ||
this.successfulIndices = successfulIndices; | ||
} | ||
|
||
public void addToSuccessful(String index) { | ||
successfulIndices.add(index); | ||
} | ||
|
||
public Map<String, String> getFailedIndices() { | ||
return failedIndices; | ||
} | ||
|
||
public void setFailedIndices(Map<String, String> failedIndices) { | ||
this.failedIndices = failedIndices; | ||
} | ||
|
||
public void addToFailed(String index, String reason) { | ||
failedIndices.put(index, reason); | ||
} | ||
|
||
public ActionListener<HotToWarmTieringResponse> getListener() { | ||
return actionListener; | ||
} | ||
|
||
public void setActionListener(ActionListener<HotToWarmTieringResponse> actionListener) { | ||
this.actionListener = actionListener; | ||
} | ||
|
||
public TieringIndexRequest getRequest() { | ||
return request; | ||
} | ||
|
||
public void setRequest(TieringIndexRequest request) { | ||
this.request = request; | ||
} | ||
|
||
public String getRequestUuid() { | ||
return requestUuid; | ||
} | ||
|
||
public void setRequestUuid(String requestUuid) { | ||
this.requestUuid = requestUuid; | ||
} | ||
|
||
public Set<Index> getInProgressIndices() { | ||
return inProgressIndices; | ||
} | ||
|
||
public void setInProgressIndices(Set<Index> inProgressIndices) { | ||
this.inProgressIndices = inProgressIndices; | ||
} | ||
|
||
public void addToInProgress(Index index) { | ||
inProgressIndices.add(index); | ||
} | ||
|
||
public void removeFromInProgress(Index index) { | ||
inProgressIndices.remove(index); | ||
} | ||
|
||
public boolean isRequestProcessingComplete() { | ||
return inProgressIndices.isEmpty(); | ||
} | ||
|
||
public HotToWarmTieringResponse constructResponse() { | ||
final List<HotToWarmTieringResponse.IndexResult> indicesResult = new LinkedList<>(); | ||
for (Map.Entry<String, String> rejectedIndex : rejectedIndices.entrySet()) { | ||
indicesResult.add(new HotToWarmTieringResponse.IndexResult(rejectedIndex.getKey(), rejectedIndex.getValue())); | ||
} | ||
for (String index : notFoundIndices) { | ||
indicesResult.add(new HotToWarmTieringResponse.IndexResult(index, "Index not found")); | ||
} | ||
for (Map.Entry<String, String> failedIndex : failedIndices.entrySet()) { | ||
indicesResult.add(new HotToWarmTieringResponse.IndexResult(failedIndex.getKey(), failedIndex.getValue())); | ||
} | ||
return new HotToWarmTieringResponse(acceptedIndices.size() > 0, indicesResult); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "HotToWarmTieringRequestContext{" | ||
+ "acceptedIndices=" | ||
+ acceptedIndices | ||
+ ", rejectedIndices=" | ||
+ rejectedIndices | ||
+ ", notFoundIndices=" | ||
+ notFoundIndices | ||
+ ", inProgressIndices=" | ||
+ inProgressIndices | ||
+ ", successfulIndices=" | ||
+ successfulIndices | ||
+ ", failedIndices=" | ||
+ failedIndices | ||
+ ", actionListener=" | ||
+ actionListener | ||
+ ", request=" | ||
+ request | ||
+ ", requestUuid='" | ||
+ requestUuid | ||
+ '\'' | ||
+ '}'; | ||
} | ||
} |
Oops, something went wrong.