Class RemoteClusterStateService

java.lang.Object
org.opensearch.gateway.remote.RemoteClusterStateService
All Implemented Interfaces:
Closeable, AutoCloseable

public class RemoteClusterStateService extends Object implements Closeable
A Service which provides APIs to upload and download cluster metadata from remote store.
Opensearch.internal:
  • Field Details

    • REMOTE_PUBLICATION_SETTING_KEY

      public static final String REMOTE_PUBLICATION_SETTING_KEY
      Gates the functionality of remote publication.
      See Also:
    • REMOTE_PUBLICATION_SETTING

      public static final Setting<Boolean> REMOTE_PUBLICATION_SETTING
    • REMOTE_CLUSTER_STATE_ENABLED_SETTING

      public static final Setting<Boolean> 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

      public static final Setting<org.opensearch.common.unit.TimeValue> 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

      public static final Setting<String> 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

  • 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

      public RemoteManifestManager getRemoteManifestManager()
    • getCleanupManager

      public RemoteClusterStateCleanupManager 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 cluster
      clusterUUID - uuid of cluster state to refer to in remote
      Returns:
      ClusterMetadataManifest
    • getClusterMetadataManifestByFileName

      public ClusterMetadataManifest getClusterMetadataManifestByFileName(String clusterUUID, String fileName)
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      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 cluster
      clusterUUID - 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

      public String getLastKnownUUIDFromRemote(String clusterName)
      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

      public RemotePersistenceStats getRemoteStateStats()
    • getUploadStats

      public PersistedStateStats getUploadStats()
    • getFullDownloadStats

      public PersistedStateStats getFullDownloadStats()
    • getDiffDownloadStats

      public PersistedStateStats getDiffDownloadStats()
    • fullDownloadFailed

      public void fullDownloadFailed()
    • diffDownloadFailed

      public void diffDownloadFailed()