/** * Ensures that the given cluster alias is connected. If the cluster is connected this operation * will invoke the listener immediately. */ void ensureConnected(String clusterAlias, ActionListener<Void> listener) { getRemoteClusterConnection(clusterAlias).ensureConnected(listener); }
/** * Fetches all shards for the search request from this remote connection. This is used to later run the search on the remote end. */ public void fetchSearchShards(ClusterSearchShardsRequest searchRequest, ActionListener<ClusterSearchShardsResponse> listener) { final ActionListener<ClusterSearchShardsResponse> searchShardsListener; final Consumer<Exception> onConnectFailure; if (skipUnavailable) { onConnectFailure = (exception) -> listener.onResponse(ClusterSearchShardsResponse.EMPTY); searchShardsListener = ActionListener.wrap(listener::onResponse, (e) -> listener.onResponse(ClusterSearchShardsResponse.EMPTY)); } else { onConnectFailure = listener::onFailure; searchShardsListener = listener; } // in case we have no connected nodes we try to connect and if we fail we either notify the listener or not depending on // the skip_unavailable setting ensureConnected(ActionListener.wrap((x) -> fetchShardsInternal(searchRequest, searchShardsListener), onConnectFailure)); }
/** * Ensures that the given cluster alias is connected. If the cluster is connected this operation * will invoke the listener immediately. */ public void ensureConnected(String clusterAlias, ActionListener<Void> listener) { RemoteClusterConnection remoteClusterConnection = remoteClusters.get(clusterAlias); if (remoteClusterConnection == null) { throw new IllegalArgumentException("no such remote cluster: " + clusterAlias); } remoteClusterConnection.ensureConnected(listener); }
ensureConnected(ActionListener.wrap((x) -> runnable.run(), listener::onFailure)); } catch (Exception ex) { listener.onFailure(ex);
/** * Ensures that the given cluster alias is connected. If the cluster is connected this operation * will invoke the listener immediately. */ public void ensureConnected(String clusterAlias, ActionListener<Void> listener) { RemoteClusterConnection remoteClusterConnection = remoteClusters.get(clusterAlias); if (remoteClusterConnection == null) { throw new IllegalArgumentException("no such remote cluster: " + clusterAlias); } remoteClusterConnection.ensureConnected(listener); }
/** * Ensures that the given cluster alias is connected. If the cluster is connected this operation * will invoke the listener immediately. */ public void ensureConnected(String clusterAlias, ActionListener<Void> listener) { RemoteClusterConnection remoteClusterConnection = remoteClusters.get(clusterAlias); if (remoteClusterConnection == null) { throw new IllegalArgumentException("no such remote cluster: " + clusterAlias); } remoteClusterConnection.ensureConnected(listener); }
/** * Fetches all shards for the search request from this remote connection. This is used to later run the search on the remote end. */ public void fetchSearchShards(ClusterSearchShardsRequest searchRequest, ActionListener<ClusterSearchShardsResponse> listener) { if (connectedNodes.size() == 0) { // just in case if we are not connected for some reason we try to connect and if we fail we have to notify the listener // this will cause some back pressure on the search end and eventually will cause rejections but that's fine // we can't proceed with a search on a cluster level. // in the future we might want to just skip the remote nodes in such a case but that can already be implemented on the caller // end since they provide the listener. ensureConnected(ActionListener.wrap((x) -> fetchShardsInternal(searchRequest, listener), listener::onFailure)); } else { fetchShardsInternal(searchRequest, listener); } }
/** * Fetches all shards for the search request from this remote connection. This is used to later run the search on the remote end. */ public void fetchSearchShards(ClusterSearchShardsRequest searchRequest, ActionListener<ClusterSearchShardsResponse> listener) { final ActionListener<ClusterSearchShardsResponse> searchShardsListener; final Consumer<Exception> onConnectFailure; if (skipUnavailable) { onConnectFailure = (exception) -> listener.onResponse(ClusterSearchShardsResponse.EMPTY); searchShardsListener = ActionListener.wrap(listener::onResponse, (e) -> listener.onResponse(ClusterSearchShardsResponse.EMPTY)); } else { onConnectFailure = listener::onFailure; searchShardsListener = listener; } // in case we have no connected nodes we try to connect and if we fail we either notify the listener or not depending on // the skip_unavailable setting ensureConnected(ActionListener.wrap((x) -> fetchShardsInternal(searchRequest, searchShardsListener), onConnectFailure)); }
ensureConnected(ActionListener.wrap((x) -> runnable.run(), listener::onFailure)); } catch (Exception ex) { listener.onFailure(ex);