java.lang.Object
org.elasticsearch.transport.RemoteClusterAware
org.elasticsearch.transport.RemoteClusterService
- All Implemented Interfaces:
Closeable,AutoCloseable,IndicesExpressionGrouper,ReportingService<RemoteClusterServerInfo>,LinkedProjectConfigService.LinkedProjectConfigListener
public final class RemoteClusterService
extends RemoteClusterAware
implements Closeable, ReportingService<RemoteClusterServerInfo>, IndicesExpressionGrouper
Basic service for accessing remote clusters via gateway nodes
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumSpecifies how to behave when executing a request against a disconnected remote cluster.Nested classes/interfaces inherited from interface org.elasticsearch.node.ReportingService
ReportingService.Info -
Field Summary
FieldsFields inherited from class org.elasticsearch.transport.RemoteClusterAware
LOCAL_CLUSTER_GROUP_KEY, REMOTE_CLUSTER_INDEX_SEPARATOR, settings -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidcollectNodes(Set<String> clusters, ActionListener<BiFunction<String, String, DiscoveryNode>> listener) Collects all nodes of the given clusters and returns / passes a (clusterAlias, nodeId) toDiscoveryNodefunction on success.booleanvoidVerifies this node is configured to support linked project client operations.getConnection(String cluster) getConnection(DiscoveryNode node, String cluster) Returns a connection to the given node on the given remote clusterReturns the registered remote cluster names.getRemoteClusterClient(String clusterAlias, Executor responseExecutor, RemoteClusterService.DisconnectedStrategy disconnectedStrategy) Returns a client to the remote cluster if the given cluster alias exists.getRemoteClusterConnection(String cluster) groupIndices(Set<String> remoteClusterNames, IndicesOptions indicesOptions, String[] indices) If no indices are specified, then a Map with one entry for the local cluster with an empty index array is returned.groupIndices(Set<String> remoteClusterNames, IndicesOptions indicesOptions, String[] indices, boolean returnLocalAll) Group indices by cluster alias mapped to OriginalIndices for that cluster.groupIndices(IndicesOptions indicesOptions, String[] indices) groupIndices(IndicesOptions indicesOptions, String[] indices, boolean returnLocalAll) info()booleanisSkipUnavailable(String clusterAlias) Returns whether the cluster identified by the provided alias is configured to be skipped when unavailable.voidmaybeEnsureConnectedAndGetConnection(String clusterAlias, boolean ensureConnected, ActionListener<Transport.Connection> listener) UnlikegetConnection(String)this method might attempt to re-establish a remote connection if there is no connection available before returning a connection to the remote cluster.booleanshouldSkipOnFailure(String clusterAlias, Boolean allowPartialSearchResults) Signifies if an error can be skipped for the specified cluster based on skip_unavailable, or, allow_partial_search_results if in CPS-like environment.voidskipUnavailableChanged(ProjectId originProjectId, ProjectId linkedProjectId, String linkedProjectAlias, boolean skipUnavailable) Called when the boolean skip_unavailable setting has changed for a linked project configuration.voidCalled when a linked project configuration has been added or updated.voidupdateRemoteClusterCredentials(Supplier<Settings> settingsSupplier, ActionListener<Void> listener) Methods inherited from class org.elasticsearch.transport.RemoteClusterAware
buildRemoteIndexName, getNodeName, groupClusterIndices, isRemoteIndexName, parseClusterAlias, splitIndexName
-
Field Details
-
REMOTE_CLUSTER_HANDSHAKE_ACTION_NAME
- See Also:
-
-
Method Details
-
isRemoteClusterServerEnabled
public boolean isRemoteClusterServerEnabled() -
groupIndices
public Map<String,OriginalIndices> groupIndices(Set<String> remoteClusterNames, IndicesOptions indicesOptions, String[] indices, boolean returnLocalAll) Group indices by cluster alias mapped to OriginalIndices for that cluster.- Parameters:
remoteClusterNames- Set of configured remote cluster names.indicesOptions- IndicesOptions to clarify how the index expressions should be parsed/appliedindices- Multiple index expressions as string[].returnLocalAll- whether to support the _all functionality needed by _search (See https://github.com/elastic/elasticsearch/pull/33899). If true, and no indices are specified, then a Map with one entry for the local cluster with an empty index array is returned. If false, an empty map is returned when no indices are specified.- Returns:
- Map keyed by cluster alias having OriginalIndices as the map value parsed from the String[] indices argument
-
groupIndices
public Map<String,OriginalIndices> groupIndices(Set<String> remoteClusterNames, IndicesOptions indicesOptions, String[] indices) If no indices are specified, then a Map with one entry for the local cluster with an empty index array is returned. For details seegroupIndices(IndicesOptions indicesOptions, String[] indices, boolean returnLocalAll)- Parameters:
remoteClusterNames- Set of configured remote cluster names.indicesOptions- IndicesOptions to clarify how the index expressions should be parsed/appliedindices- Multiple index expressions as string[].- Returns:
- Map keyed by cluster alias having OriginalIndices as the map value parsed from the String[] indices argument
-
groupIndices
public Map<String,OriginalIndices> groupIndices(IndicesOptions indicesOptions, String[] indices, boolean returnLocalAll) Description copied from interface:IndicesExpressionGrouperSeegroupIndices(java.util.Set<java.lang.String>, org.elasticsearch.action.support.IndicesOptions, java.lang.String[], boolean)for details- Specified by:
groupIndicesin interfaceIndicesExpressionGrouper
-
groupIndices
-
getRegisteredRemoteClusterNames
Returns the registered remote cluster names. -
getConnection
Returns a connection to the given node on the given remote cluster- Throws:
IllegalArgumentException- if the remote cluster is unknown
-
crossProjectEnabled
public boolean crossProjectEnabled() -
shouldSkipOnFailure
Signifies if an error can be skipped for the specified cluster based on skip_unavailable, or, allow_partial_search_results if in CPS-like environment.- Parameters:
clusterAlias- Name of the clusterallowPartialSearchResults- If partial results can be served for the search request.- Returns:
- boolean
-
getConnection
-
maybeEnsureConnectedAndGetConnection
public void maybeEnsureConnectedAndGetConnection(String clusterAlias, boolean ensureConnected, ActionListener<Transport.Connection> listener) UnlikegetConnection(String)this method might attempt to re-establish a remote connection if there is no connection available before returning a connection to the remote cluster.- Parameters:
clusterAlias- the remote clusterensureConnected- whether requests should wait for a connection attempt when there isn't available connectionlistener- a listener that will be notified the connection or failure
-
getRemoteClusterConnection
-
updateRemoteClusterCredentials
public void updateRemoteClusterCredentials(Supplier<Settings> settingsSupplier, ActionListener<Void> listener) -
updateLinkedProject
Description copied from interface:LinkedProjectConfigService.LinkedProjectConfigListenerCalled when a linked project configuration has been added or updated.- Specified by:
updateLinkedProjectin interfaceLinkedProjectConfigService.LinkedProjectConfigListener- Parameters:
config- The updatedLinkedProjectConfig.
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
getRemoteConnectionInfos
-
info
- Specified by:
infoin interfaceReportingService<RemoteClusterServerInfo>
-
collectNodes
public void collectNodes(Set<String> clusters, ActionListener<BiFunction<String, String, DiscoveryNode>> listener) Collects all nodes of the given clusters and returns / passes a (clusterAlias, nodeId) toDiscoveryNodefunction on success. -
getRemoteClusterClient
public RemoteClusterClient getRemoteClusterClient(String clusterAlias, Executor responseExecutor, RemoteClusterService.DisconnectedStrategy disconnectedStrategy) Returns a client to the remote cluster if the given cluster alias exists.- Parameters:
clusterAlias- the cluster alias the remote cluster is registered underresponseExecutor- the executor to use to process the responsedisconnectedStrategy- how to handle the situation where the remote cluster is disconnected when executing a request- Throws:
IllegalArgumentException- if the given clusterAlias doesn't exist
-
ensureClientIsEnabled
public void ensureClientIsEnabled()Verifies this node is configured to support linked project client operations.- Throws:
IllegalArgumentException- If this node is not configured to support client operations.
-