Package org.opensearch.gateway.remote
Class RemoteClusterStateService
java.lang.Object
org.opensearch.gateway.remote.RemoteClusterStateService
- All Implemented Interfaces:
Closeable
,AutoCloseable
A Service which provides APIs to upload and download cluster metadata from remote store.
- Opensearch.internal:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Validation mode for cluster state checksum. -
Field Summary
Modifier and TypeFieldDescriptionControls the fixed prefix for the cluster state path on remote store.static final org.opensearch.core.xcontent.ToXContent.Params
Used to specify if cluster state metadata should be published to remote storestatic final String
Gates the functionality of remote publication.static final org.opensearch.common.unit.TimeValue
static final Setting
<org.opensearch.common.unit.TimeValue> -
Constructor Summary
ConstructorDescriptionRemoteClusterStateService
(String nodeId, Supplier<RepositoriesService> repositoriesService, Settings settings, ClusterService clusterService, LongSupplier relativeTimeNanosSupplier, ThreadPool threadPool, List<IndexMetadataUploadListener> indexMetadataUploadListeners, org.opensearch.core.common.io.stream.NamedWriteableRegistry namedWriteableRegistry) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
void
void
getClusterMetadataManifestByFileName
(String clusterUUID, String fileName) getClusterStateForManifest
(String clusterName, ClusterMetadataManifest manifest, String localNodeId, boolean includeEphemeral) getClusterStateUsingDiff
(ClusterMetadataManifest manifest, ClusterState previousState, String localNodeId) getLastKnownUUIDFromRemote
(String clusterName) Fetch the previous cluster UUIDs from remote state store and return the most recent valid cluster UUIDgetLatestClusterMetadataManifest
(String clusterName, String clusterUUID) Fetch latest ClusterMetadataManifest from remote state storegetLatestClusterState
(String clusterName, String clusterUUID, boolean includeEphemeral) Fetch latest ClusterState from remote, including global metadata, index metadata and cluster state versionboolean
markLastStateAsCommitted
(ClusterState clusterState, ClusterMetadataManifest previousManifest, boolean commitVotingConfig) void
setRemoteStateReadTimeout
(org.opensearch.common.unit.TimeValue remoteStateReadTimeout) void
start()
writeFullMetadata
(ClusterState clusterState, String previousClusterUUID, int codecVersion) This method uploads entire cluster state metadata to the configured blob store.writeIncrementalMetadata
(ClusterState previousClusterState, ClusterState clusterState, ClusterMetadataManifest previousManifest) This method uploads the diff between the previous cluster state and the current cluster state.void
-
Field Details
-
REMOTE_PUBLICATION_SETTING_KEY
Gates the functionality of remote publication.- See Also:
-
REMOTE_PUBLICATION_SETTING
-
REMOTE_CLUSTER_STATE_ENABLED_SETTING
Used to specify if cluster state metadata should be published to remote store -
REMOTE_STATE_READ_TIMEOUT_DEFAULT
public static final org.opensearch.common.unit.TimeValue REMOTE_STATE_READ_TIMEOUT_DEFAULT -
REMOTE_STATE_READ_TIMEOUT_SETTING
-
REMOTE_CLUSTER_STATE_CHECKSUM_VALIDATION_MODE_SETTING
public static final Setting<RemoteClusterStateService.RemoteClusterStateValidationMode> REMOTE_CLUSTER_STATE_CHECKSUM_VALIDATION_MODE_SETTING -
CLUSTER_REMOTE_STORE_STATE_PATH_PREFIX
Controls the fixed prefix for the cluster state path on remote store. -
FORMAT_PARAMS
public static final org.opensearch.core.xcontent.ToXContent.Params FORMAT_PARAMS
-
-
Constructor Details
-
RemoteClusterStateService
public RemoteClusterStateService(String nodeId, Supplier<RepositoriesService> repositoriesService, Settings settings, ClusterService clusterService, LongSupplier relativeTimeNanosSupplier, ThreadPool threadPool, List<IndexMetadataUploadListener> indexMetadataUploadListeners, org.opensearch.core.common.io.stream.NamedWriteableRegistry namedWriteableRegistry)
-
-
Method Details
-
writeFullMetadata
@Nullable public RemoteClusterStateManifestInfo writeFullMetadata(ClusterState clusterState, String previousClusterUUID, int codecVersion) throws IOException This method uploads entire cluster state metadata to the configured blob store. For now only index metadata upload is supported. This method should be invoked by the elected cluster manager when the remote cluster state is enabled.- Returns:
- A manifest object which contains the details of uploaded entity metadata.
- Throws:
IOException
-
writeIncrementalMetadata
public RemoteClusterStateManifestInfo writeIncrementalMetadata(ClusterState previousClusterState, ClusterState clusterState, ClusterMetadataManifest previousManifest) throws IOException This method uploads the diff between the previous cluster state and the current cluster state. The previous manifest file is needed to create the new manifest. The new manifest file is created by using the unchanged metadata from the previous manifest and the new metadata changes from the current cluster state.- Returns:
RemoteClusterStateManifestInfo
object containing uploaded manifest detail- Throws:
IOException
-
getRemoteManifestManager
-
getCleanupManager
-
markLastStateAsCommitted
@Nullable public RemoteClusterStateManifestInfo markLastStateAsCommitted(ClusterState clusterState, ClusterMetadataManifest previousManifest, boolean commitVotingConfig) throws IOException - Throws:
IOException
-
getLatestClusterMetadataManifest
public Optional<ClusterMetadataManifest> getLatestClusterMetadataManifest(String clusterName, String clusterUUID) Fetch latest ClusterMetadataManifest from remote state store- Parameters:
clusterName
- name of the clusterclusterUUID
- uuid of cluster state to refer to in remote- Returns:
- ClusterMetadataManifest
-
getClusterMetadataManifestByFileName
public ClusterMetadataManifest getClusterMetadataManifestByFileName(String clusterUUID, String fileName) -
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
start
public void start() -
getLatestClusterState
public ClusterState getLatestClusterState(String clusterName, String clusterUUID, boolean includeEphemeral) throws IOException Fetch latest ClusterState from remote, including global metadata, index metadata and cluster state version- Parameters:
clusterName
- name of the clusterclusterUUID
- uuid of cluster state to refer to in remote- Returns:
IndexMetadata
- Throws:
IOException
-
getClusterStateForManifest
public ClusterState getClusterStateForManifest(String clusterName, ClusterMetadataManifest manifest, String localNodeId, boolean includeEphemeral) throws IOException - Throws:
IOException
-
getClusterStateUsingDiff
public ClusterState getClusterStateUsingDiff(ClusterMetadataManifest manifest, ClusterState previousState, String localNodeId) -
getLastKnownUUIDFromRemote
Fetch the previous cluster UUIDs from remote state store and return the most recent valid cluster UUID- Parameters:
clusterName
- The cluster name for which previous cluster UUID is to be fetched- Returns:
- Last valid cluster UUID
-
isRemotePublicationEnabled
public boolean isRemotePublicationEnabled() -
setRemoteStateReadTimeout
public void setRemoteStateReadTimeout(org.opensearch.common.unit.TimeValue remoteStateReadTimeout) -
writeMetadataFailed
public void writeMetadataFailed() -
getRemoteStateStats
-
getUploadStats
-
getFullDownloadStats
-
getDiffDownloadStats
-
fullDownloadFailed
public void fullDownloadFailed() -
diffDownloadFailed
public void diffDownloadFailed()
-