Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

- Add warmup phase to wait for lag to catch up in pull-based ingestion before serving ([#20526](https://github.com/opensearch-project/OpenSearch/pull/20526))
- Add a new static method to IndicesOptions API to expose `STRICT_EXPAND_OPEN_HIDDEN_FORBID_CLOSED` index option ([#20980](https://github.com/opensearch-project/OpenSearch/pull/20980))
- Add skeleton structure for tiered-storage module ([#21017](https://github.com/opensearch-project/OpenSearch/pull/21017))


### Changed
- Make telemetry `Tags` immutable ([#20788](https://github.com/opensearch-project/OpenSearch/pull/20788))
Expand Down
16 changes: 16 additions & 0 deletions modules/tiered-storage/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* 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.
*
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

opensearchplugin {
description = 'Module for tiered storage and writable warm index support'
classname = 'org.opensearch.storage.TieredStoragePlugin'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* 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.storage;

import org.opensearch.common.SetOnce;
import org.opensearch.common.settings.Setting;
import org.opensearch.plugins.ActionPlugin;
import org.opensearch.plugins.IndexStorePlugin;
import org.opensearch.plugins.Plugin;
import org.opensearch.plugins.TelemetryAwarePlugin;
import org.opensearch.storage.common.tiering.TieringUtils;
import org.opensearch.storage.metrics.TierActionMetrics;
import org.opensearch.storage.prefetch.TieredStoragePrefetchSettings;
import org.opensearch.threadpool.ThreadPool;

import java.util.List;
import java.util.stream.Stream;

import static org.opensearch.storage.slowlogs.TieredStorageSearchSlowLog.TIERED_STORAGE_SEARCH_SLOWLOG_SETTINGS;

/**
* Plugin to support writable warm index and other related features.
* Registers settings, actions, REST handlers, directory factories, and search operation listeners.
*
* getDirectoryFactories, getCompositeDirectoryFactories, getSettings, getExecutorBuilders,
* getActions, getRestHandlers, createComponents, onIndexModule, and createGuiceModules
* will be added in the implementation PR.
*/
public class TieredStoragePlugin extends Plugin implements IndexStorePlugin, ActionPlugin, TelemetryAwarePlugin {

/**
* Index type for optimised downloads on hot indices.
*/
public static final String HOT_BLOCK_EAGER_FETCH_INDEX_TYPE = "hot_block_eager_fetch";
/** Composite index type for tiered storage. */
public static final String TIERED_COMPOSITE_INDEX_TYPE = "tiered-storage";
private static final String REMOTE_DOWNLOAD = "remote_download";

private final SetOnce<ThreadPool> threadpool = new SetOnce<>();
private TieredStoragePrefetchSettings tieredStoragePrefetchSettings;
private TierActionMetrics tierActionMetrics;

/** Constructs a new TieredStoragePlugin. */
public TieredStoragePlugin() {}

private final List<Setting<?>> tieredStorageSettings = Stream.concat(
Stream.of(
TieringUtils.H2W_MAX_CONCURRENT_TIEIRNG_REQUESTS,
TieringUtils.W2H_MAX_CONCURRENT_TIEIRNG_REQUESTS,
TieringUtils.JVM_USAGE_TIERING_THRESHOLD_PERCENT,
TieringUtils.FILECACHE_ACTIVE_USAGE_TIERING_THRESHOLD_PERCENT,
TieredStoragePrefetchSettings.READ_AHEAD_BLOCK_COUNT,
TieredStoragePrefetchSettings.STORED_FIELDS_PREFETCH_ENABLED_SETTING
),
TIERED_STORAGE_SEARCH_SLOWLOG_SETTINGS.stream()
).toList();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* 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.storage.action.tiering;

import org.opensearch.action.ActionType;
import org.opensearch.action.support.clustermanager.AcknowledgedResponse;

/**
* Action for cancelling ongoing tiering operations.
* This action can be used to cancel both hot-to-warm and warm-to-hot migrations
* when shards get stuck in RUNNING_SHARD_RELOCATION state.
*/
public class CancelTieringAction extends ActionType<AcknowledgedResponse> {

/** Singleton instance. */
public static final CancelTieringAction INSTANCE = new CancelTieringAction();
/** Action name for cancel tiering. */
public static final String NAME = "indices:admin/_tier/cancel";

private CancelTieringAction() {
super(NAME, AcknowledgedResponse::new);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* 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.storage.action.tiering;

import org.opensearch.action.ActionRequestValidationException;
import org.opensearch.action.support.clustermanager.AcknowledgedRequest;
import org.opensearch.core.common.io.stream.StreamInput;

import java.io.IOException;

/**
* Request to cancel an ongoing tiering operation for an index.
* This request contains the index name and necessary parameters to safely
* cancel migrations that may be stuck in RUNNING_SHARD_RELOCATION state.
*
* Serialization (writeTo, StreamInput constructor), validation, equals/hashCode, and toString
* will be added in the implementation PR.
*/
public class CancelTieringRequest extends AcknowledgedRequest<CancelTieringRequest> {

private String index;

/** Default constructor. */
public CancelTieringRequest() {
super();
}

/**
* Constructs a request from a stream.
* @param in the stream input
* @throws IOException if an I/O error occurs
*/
public CancelTieringRequest(StreamInput in) throws IOException {
super(in);
throw new UnsupportedOperationException("Not yet implemented");
}

/**
* Constructs a request for the given index.
* @param index the index name
*/
public CancelTieringRequest(final String index) {
super();
this.index = index;
}

@Override
public ActionRequestValidationException validate() {
throw new UnsupportedOperationException("Not yet implemented");
}

/** Returns the index name. */
public String getIndex() {
return index;
}

/**
* Sets the index name.
* @param index the index name
*/
public void setIndex(String index) {
this.index = index;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* 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.storage.action.tiering;

import org.opensearch.action.ActionType;
import org.opensearch.action.support.clustermanager.AcknowledgedResponse;

/**
* Action type for moving indices from hot to warm tier in OpenSearch's tiered storage.
*/
public class HotToWarmTierAction extends ActionType<AcknowledgedResponse> {

/**
* Singleton instance of the HotToWarmTierAction.
*/
public static final HotToWarmTierAction INSTANCE = new HotToWarmTierAction();
/**
* Action name for hot to warm tier operations.
*/
public static final String NAME = "indices:admin/_tier/hot_to_warm";

private HotToWarmTierAction() {
super(NAME, AcknowledgedResponse::new);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* 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.storage.action.tiering;

import org.opensearch.action.ActionRequestValidationException;
import org.opensearch.action.support.clustermanager.AcknowledgedRequest;
import org.opensearch.core.common.io.stream.StreamInput;
import org.opensearch.storage.common.tiering.TieringUtils.Tier;

import java.io.IOException;

/**
* Represents a request to move indices between different storage tiers.
* This class handles the validation and serialization of tiering requests.
*
* Serialization (writeTo, StreamInput constructor), validation, equals/hashCode
* will be added in the implementation PR.
*/
public class IndexTieringRequest extends AcknowledgedRequest<IndexTieringRequest> {

private final String indexName;
private final Tier targetTier;

/**
* Constructs a new tiering request from a stream.
* @param in the stream input
* @throws IOException if an I/O error occurs
*/
public IndexTieringRequest(StreamInput in) throws IOException {
super(in);
throw new UnsupportedOperationException("Not yet implemented");
}

/**
* Constructs a new tiering request.
* @param targetTier the target tier
* @param indexName the index name
*/
public IndexTieringRequest(final String targetTier, final String indexName) {
this.targetTier = Tier.fromString(targetTier);
this.indexName = indexName;
}

@Override
public ActionRequestValidationException validate() {
throw new UnsupportedOperationException("Not yet implemented");
}

/** Returns the target tier. */
public Tier tier() {
return targetTier;
}

/** Returns the index name. */
public String getIndex() {
return indexName;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* 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.storage.action.tiering;

import org.opensearch.rest.BaseRestHandler;
import org.opensearch.rest.RestRequest;
import org.opensearch.transport.client.node.NodeClient;

import java.util.List;

import static java.util.Collections.singletonList;
import static org.opensearch.rest.RestRequest.Method.POST;

/**
* Base REST handler for tiering operations.
* prepareRequest and validateIndices will be added in the implementation PR.
*/
public abstract class RestBaseTierAction extends BaseRestHandler {

/** The target tier for this action. */
protected final String targetTier;

/**
* Constructs a RestBaseTierAction for the given target tier.
* @param targetTier the target tier
*/
protected RestBaseTierAction(String targetTier) {
this.targetTier = targetTier;
}

@Override
public List<Route> routes() {
return singletonList(new Route(POST, "/{index}/_tier/" + targetTier));
}

@Override
public RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) {
throw new UnsupportedOperationException("Not yet implemented");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* 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.storage.action.tiering;

import org.opensearch.rest.BaseRestHandler;
import org.opensearch.rest.RestRequest;
import org.opensearch.transport.client.node.NodeClient;

import java.util.List;

import static java.util.Collections.singletonList;
import static org.opensearch.rest.RestRequest.Method.POST;

/**
* REST handler for cancelling ongoing tiering operations.
* This handler provides an endpoint to cancel migrations that may be stuck
* in RUNNING_SHARD_RELOCATION state, allowing manual recovery.
*
* validateIndices and full prepareRequest logic will be added in the implementation PR.
*/
public class RestCancelTierAction extends BaseRestHandler {

/** Constructs a new RestCancelTierAction. */
public RestCancelTierAction() {}

@Override
public String getName() {
return "cancel_tier_action";
}

@Override
public List<Route> routes() {
return singletonList(new Route(POST, "/_tier/_cancel/{index}"));
}

@Override
protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) {
throw new UnsupportedOperationException("Not yet implemented");
}
}
Loading
Loading