Skip to content

Commit

Permalink
Add rest, transport layer changes for Hot to warm tiering - dedicated…
Browse files Browse the repository at this point in the history
… setup

Signed-off-by: Neetika Singhal <[email protected]>
  • Loading branch information
neetikasinghal committed Jul 16, 2024
1 parent 8ae728c commit 5569b43
Show file tree
Hide file tree
Showing 15 changed files with 1,694 additions and 1 deletion.
9 changes: 9 additions & 0 deletions server/src/main/java/org/opensearch/action/ActionModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,9 @@
import org.opensearch.action.termvectors.TransportMultiTermVectorsAction;
import org.opensearch.action.termvectors.TransportShardMultiTermsVectorAction;
import org.opensearch.action.termvectors.TransportTermVectorsAction;
import org.opensearch.action.tiering.HotToWarmTieringAction;
import org.opensearch.action.tiering.RestWarmTieringAction;
import org.opensearch.action.tiering.TransportHotToWarmTieringAction;
import org.opensearch.action.update.TransportUpdateAction;
import org.opensearch.action.update.UpdateAction;
import org.opensearch.client.node.NodeClient;
Expand Down Expand Up @@ -634,6 +637,9 @@ public <Request extends ActionRequest, Response extends ActionResponse> void reg
actions.register(CreateSnapshotAction.INSTANCE, TransportCreateSnapshotAction.class);
actions.register(CloneSnapshotAction.INSTANCE, TransportCloneSnapshotAction.class);
actions.register(RestoreSnapshotAction.INSTANCE, TransportRestoreSnapshotAction.class);
if (FeatureFlags.isEnabled(FeatureFlags.TIERED_REMOTE_INDEX)) {
actions.register(HotToWarmTieringAction.INSTANCE, TransportHotToWarmTieringAction.class);
}
actions.register(SnapshotsStatusAction.INSTANCE, TransportSnapshotsStatusAction.class);

actions.register(ClusterAddWeightedRoutingAction.INSTANCE, TransportAddWeightedRoutingAction.class);
Expand Down Expand Up @@ -966,6 +972,9 @@ public void initRestHandlers(Supplier<DiscoveryNodes> nodesInCluster) {
registerHandler.accept(new RestNodeAttrsAction());
registerHandler.accept(new RestRepositoriesAction());
registerHandler.accept(new RestSnapshotAction());
if (FeatureFlags.isEnabled(FeatureFlags.TIERED_REMOTE_INDEX)) {
registerHandler.accept(new RestWarmTieringAction());
}
registerHandler.accept(new RestTemplatesAction());

// Point in time API
Expand Down
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);
}
}
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
+ '\''
+ '}';
}
}
Loading

0 comments on commit 5569b43

Please sign in to comment.