forked from opensearch-project/OpenSearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Bharathwaj G <[email protected]>
- Loading branch information
1 parent
bd0105c
commit 6ceaf61
Showing
5 changed files
with
60 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
server/src/main/java/org/opensearch/action/search/SearchUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* 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.action.search; | ||
|
||
import org.opensearch.action.StepListener; | ||
import org.opensearch.cluster.ClusterState; | ||
import org.opensearch.cluster.node.DiscoveryNode; | ||
|
||
import java.util.Set; | ||
import java.util.function.BiFunction; | ||
|
||
/** | ||
* Helper class for common search functions | ||
*/ | ||
public class SearchUtils { | ||
|
||
public SearchUtils() {} | ||
|
||
/** | ||
* Get connection lookup listener for list of clusters passed | ||
*/ | ||
public static StepListener<BiFunction<String, String, DiscoveryNode>> getConnectionLookupListener( | ||
SearchTransportService searchTransportService, | ||
ClusterState state, | ||
Set<String> clusters | ||
) { | ||
final StepListener<BiFunction<String, String, DiscoveryNode>> lookupListener = new StepListener<>(); | ||
|
||
if (clusters.isEmpty()) { | ||
lookupListener.onResponse((cluster, nodeId) -> state.getNodes().get(nodeId)); | ||
} else { | ||
searchTransportService.getRemoteClusterService().collectNodes(clusters, lookupListener); | ||
} | ||
return lookupListener; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters