@@ -422,7 +422,7 @@ void executeRequest(
422
422
resolvedIndices .getLocalIndices (),
423
423
resolvedIndices .getRemoteClusterIndices (),
424
424
true ,
425
- remoteClusterService :: isSkipUnavailable
425
+ ( clusterAlias ) -> remoteClusterService . shouldSkipOnFailure ( clusterAlias , rewritten . allowPartialSearchResults ())
426
426
);
427
427
if (resolvedIndices .getLocalIndices () == null ) {
428
428
// Notify the progress listener that a CCS with minimize_roundtrips is happening remote-only (no local shards)
@@ -458,7 +458,7 @@ void executeRequest(
458
458
resolvedIndices .getLocalIndices (),
459
459
resolvedIndices .getRemoteClusterIndices (),
460
460
false ,
461
- remoteClusterService :: isSkipUnavailable
461
+ ( clusterAlias ) -> remoteClusterService . shouldSkipOnFailure ( clusterAlias , rewritten . allowPartialSearchResults ())
462
462
);
463
463
464
464
// TODO: pass parentTaskId
@@ -697,7 +697,7 @@ static void ccsRemoteReduce(
697
697
// and we directly perform final reduction in the remote cluster
698
698
Map .Entry <String , OriginalIndices > entry = resolvedIndices .getRemoteClusterIndices ().entrySet ().iterator ().next ();
699
699
String clusterAlias = entry .getKey ();
700
- boolean skipUnavailable = remoteClusterService .isSkipUnavailable (clusterAlias );
700
+ boolean shouldSkipOnFailure = remoteClusterService .shouldSkipOnFailure (clusterAlias , searchRequest . allowPartialSearchResults () );
701
701
OriginalIndices indices = entry .getValue ();
702
702
SearchRequest ccsSearchRequest = SearchRequest .subSearchRequest (
703
703
parentTaskId ,
@@ -713,7 +713,7 @@ static void ccsRemoteReduce(
713
713
@ Override
714
714
public void onResponse (SearchResponse searchResponse ) {
715
715
// overwrite the existing cluster entry with the updated one
716
- ccsClusterInfoUpdate (searchResponse , clusters , clusterAlias , skipUnavailable );
716
+ ccsClusterInfoUpdate (searchResponse , clusters , clusterAlias , shouldSkipOnFailure );
717
717
Map <String , SearchProfileShardResult > profileResults = searchResponse .getProfileResults ();
718
718
SearchProfileResults profile = profileResults == null || profileResults .isEmpty ()
719
719
? null
@@ -744,9 +744,9 @@ public void onResponse(SearchResponse searchResponse) {
744
744
@ Override
745
745
public void onFailure (Exception e ) {
746
746
ShardSearchFailure failure = new ShardSearchFailure (e );
747
- logCCSError (failure , clusterAlias , skipUnavailable );
748
- ccsClusterInfoUpdate (failure , clusters , clusterAlias , skipUnavailable );
749
- if (skipUnavailable ) {
747
+ logCCSError (failure , clusterAlias , shouldSkipOnFailure );
748
+ ccsClusterInfoUpdate (failure , clusters , clusterAlias , shouldSkipOnFailure );
749
+ if (shouldSkipOnFailure ) {
750
750
ActionListener .respondAndRelease (listener , SearchResponse .empty (timeProvider ::buildTookInMillis , clusters ));
751
751
} else {
752
752
listener .onFailure (wrapRemoteClusterFailure (clusterAlias , e ));
@@ -768,7 +768,7 @@ public void onFailure(Exception e) {
768
768
769
769
remoteClusterService .maybeEnsureConnectedAndGetConnection (
770
770
clusterAlias ,
771
- shouldEstablishConnection (forceConnectTimeoutSecs , skipUnavailable ),
771
+ shouldEstablishConnection (forceConnectTimeoutSecs , shouldSkipOnFailure ),
772
772
connectionListener
773
773
);
774
774
} else {
@@ -785,7 +785,10 @@ public void onFailure(Exception e) {
785
785
final CountDown countDown = new CountDown (totalClusters );
786
786
for (Map .Entry <String , OriginalIndices > entry : resolvedIndices .getRemoteClusterIndices ().entrySet ()) {
787
787
String clusterAlias = entry .getKey ();
788
- boolean skipUnavailable = remoteClusterService .isSkipUnavailable (clusterAlias );
788
+ boolean shouldSkipOnFailure = remoteClusterService .shouldSkipOnFailure (
789
+ clusterAlias ,
790
+ searchRequest .allowPartialSearchResults ()
791
+ );
789
792
OriginalIndices indices = entry .getValue ();
790
793
SearchRequest ccsSearchRequest = SearchRequest .subSearchRequest (
791
794
parentTaskId ,
@@ -797,7 +800,7 @@ public void onFailure(Exception e) {
797
800
);
798
801
ActionListener <SearchResponse > ccsListener = createCCSListener (
799
802
clusterAlias ,
800
- skipUnavailable ,
803
+ shouldSkipOnFailure ,
801
804
countDown ,
802
805
exceptions ,
803
806
searchResponseMerger ,
@@ -826,7 +829,7 @@ public void onFailure(Exception e) {
826
829
827
830
remoteClusterService .maybeEnsureConnectedAndGetConnection (
828
831
clusterAlias ,
829
- shouldEstablishConnection (forceConnectTimeoutSecs , skipUnavailable ),
832
+ shouldEstablishConnection (forceConnectTimeoutSecs , shouldSkipOnFailure ),
830
833
connectionListener
831
834
);
832
835
}
@@ -903,10 +906,10 @@ static void collectSearchShards(
903
906
final AtomicReference <Exception > exceptions = new AtomicReference <>();
904
907
for (Map .Entry <String , OriginalIndices > entry : remoteIndicesByCluster .entrySet ()) {
905
908
final String clusterAlias = entry .getKey ();
906
- boolean skipUnavailable = remoteClusterService .isSkipUnavailable (clusterAlias );
909
+ boolean shouldSkipOnFailure = remoteClusterService .shouldSkipOnFailure (clusterAlias , allowPartialResults );
907
910
CCSActionListener <SearchShardsResponse , Map <String , SearchShardsResponse >> singleListener = new CCSActionListener <>(
908
911
clusterAlias ,
909
- skipUnavailable ,
912
+ shouldSkipOnFailure ,
910
913
responsesCountDown ,
911
914
exceptions ,
912
915
clusters ,
@@ -975,7 +978,7 @@ Map<String, SearchShardsResponse> createFinalResponse() {
975
978
976
979
remoteClusterService .maybeEnsureConnectedAndGetConnection (
977
980
clusterAlias ,
978
- shouldEstablishConnection (forceConnectTimeoutSecs , skipUnavailable ),
981
+ shouldEstablishConnection (forceConnectTimeoutSecs , shouldSkipOnFailure ),
979
982
connectionListener
980
983
);
981
984
}
@@ -986,7 +989,7 @@ Map<String, SearchShardsResponse> createFinalResponse() {
986
989
*/
987
990
private static ActionListener <SearchResponse > createCCSListener (
988
991
String clusterAlias ,
989
- boolean skipUnavailable ,
992
+ boolean shouldSkipOnFailure ,
990
993
CountDown countDown ,
991
994
AtomicReference <Exception > exceptions ,
992
995
SearchResponseMerger searchResponseMerger ,
@@ -996,15 +999,15 @@ private static ActionListener<SearchResponse> createCCSListener(
996
999
) {
997
1000
return new CCSActionListener <>(
998
1001
clusterAlias ,
999
- skipUnavailable ,
1002
+ shouldSkipOnFailure ,
1000
1003
countDown ,
1001
1004
exceptions ,
1002
1005
clusters ,
1003
1006
ActionListener .releaseAfter (originalListener , searchResponseMerger )
1004
1007
) {
1005
1008
@ Override
1006
1009
void innerOnResponse (SearchResponse searchResponse ) {
1007
- ccsClusterInfoUpdate (searchResponse , clusters , clusterAlias , skipUnavailable );
1010
+ ccsClusterInfoUpdate (searchResponse , clusters , clusterAlias , shouldSkipOnFailure );
1008
1011
searchResponseMerger .add (searchResponse );
1009
1012
progressListener .notifyClusterResponseMinimizeRoundtrips (clusterAlias , searchResponse );
1010
1013
}
@@ -1029,11 +1032,11 @@ static void ccsClusterInfoUpdate(
1029
1032
ShardSearchFailure failure ,
1030
1033
SearchResponse .Clusters clusters ,
1031
1034
String clusterAlias ,
1032
- boolean skipUnavailable
1035
+ boolean shouldSkipOnFailure
1033
1036
) {
1034
1037
clusters .swapCluster (clusterAlias , (k , v ) -> {
1035
1038
SearchResponse .Cluster .Status status ;
1036
- if (skipUnavailable ) {
1039
+ if (shouldSkipOnFailure ) {
1037
1040
status = SearchResponse .Cluster .Status .SKIPPED ;
1038
1041
} else {
1039
1042
status = SearchResponse .Cluster .Status .FAILED ;
@@ -1056,7 +1059,7 @@ private static void ccsClusterInfoUpdate(
1056
1059
SearchResponse searchResponse ,
1057
1060
SearchResponse .Clusters clusters ,
1058
1061
String clusterAlias ,
1059
- boolean skipUnavailable
1062
+ boolean shouldSkipOnFailure
1060
1063
) {
1061
1064
/*
1062
1065
* Cluster Status logic:
@@ -1070,7 +1073,7 @@ private static void ccsClusterInfoUpdate(
1070
1073
SearchResponse .Cluster .Status status ;
1071
1074
int totalShards = searchResponse .getTotalShards ();
1072
1075
if (totalShards > 0 && searchResponse .getFailedShards () >= totalShards ) {
1073
- if (skipUnavailable ) {
1076
+ if (shouldSkipOnFailure ) {
1074
1077
status = SearchResponse .Cluster .Status .SKIPPED ;
1075
1078
} else {
1076
1079
status = SearchResponse .Cluster .Status .FAILED ;
@@ -1762,7 +1765,7 @@ private static void failIfOverShardCountLimit(ClusterService clusterService, int
1762
1765
*/
1763
1766
abstract static class CCSActionListener <Response , FinalResponse > implements ActionListener <Response > {
1764
1767
protected final String clusterAlias ;
1765
- protected final boolean skipUnavailable ;
1768
+ protected final boolean skipOnFailure ;
1766
1769
private final CountDown countDown ;
1767
1770
private final AtomicReference <Exception > exceptions ;
1768
1771
protected final SearchResponse .Clusters clusters ;
@@ -1773,14 +1776,14 @@ abstract static class CCSActionListener<Response, FinalResponse> implements Acti
1773
1776
*/
1774
1777
CCSActionListener (
1775
1778
String clusterAlias ,
1776
- boolean skipUnavailable ,
1779
+ boolean skipOnFailure ,
1777
1780
CountDown countDown ,
1778
1781
AtomicReference <Exception > exceptions ,
1779
1782
SearchResponse .Clusters clusters ,
1780
1783
ActionListener <FinalResponse > originalListener
1781
1784
) {
1782
1785
this .clusterAlias = clusterAlias ;
1783
- this .skipUnavailable = skipUnavailable ;
1786
+ this .skipOnFailure = skipOnFailure ;
1784
1787
this .countDown = countDown ;
1785
1788
this .exceptions = exceptions ;
1786
1789
this .clusters = clusters ;
@@ -1801,9 +1804,9 @@ public final void onResponse(Response response) {
1801
1804
@ Override
1802
1805
public final void onFailure (Exception e ) {
1803
1806
ShardSearchFailure f = new ShardSearchFailure (e );
1804
- logCCSError (f , clusterAlias , skipUnavailable );
1807
+ logCCSError (f , clusterAlias , skipOnFailure );
1805
1808
SearchResponse .Cluster cluster = clusters .getCluster (clusterAlias );
1806
- if (skipUnavailable && ExceptionsHelper .isTaskCancelledException (e ) == false ) {
1809
+ if (skipOnFailure && ExceptionsHelper .isTaskCancelledException (e ) == false ) {
1807
1810
if (cluster != null ) {
1808
1811
ccsClusterInfoUpdate (f , clusters , clusterAlias , true );
1809
1812
}
@@ -1859,9 +1862,9 @@ protected void releaseResponse(FinalResponse response) {}
1859
1862
* causes of shard failures.
1860
1863
* @param f ShardSearchFailure to log
1861
1864
* @param clusterAlias cluster on which the failure occurred
1862
- * @param skipUnavailable the skip_unavailable setting of the cluster with the search error
1865
+ * @param shouldSkipOnFailure the skip_unavailable setting of the cluster with the search error
1863
1866
*/
1864
- private static void logCCSError (ShardSearchFailure f , String clusterAlias , boolean skipUnavailable ) {
1867
+ private static void logCCSError (ShardSearchFailure f , String clusterAlias , boolean shouldSkipOnFailure ) {
1865
1868
String errorInfo ;
1866
1869
try {
1867
1870
errorInfo = Strings .toString (f .toXContent (XContentFactory .jsonBuilder (), ToXContent .EMPTY_PARAMS ));
@@ -1872,7 +1875,7 @@ private static void logCCSError(ShardSearchFailure f, String clusterAlias, boole
1872
1875
logger .debug (
1873
1876
"CCS remote cluster failure. Cluster [{}]. skip_unavailable: [{}]. Error: {}" ,
1874
1877
clusterAlias ,
1875
- skipUnavailable ,
1878
+ shouldSkipOnFailure ,
1876
1879
errorInfo
1877
1880
);
1878
1881
}
0 commit comments