Skip to content

Commit

Permalink
Addressing comments to use CollectionUtils.isEmpty
Browse files Browse the repository at this point in the history
Signed-off-by: Sagar Upadhyaya <[email protected]>
  • Loading branch information
sgup432 committed Aug 29, 2023
1 parent fbb604a commit 8751cbd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.lessThanOrEqualTo;

@OpenSearchIntegTestCase.ClusterScope(scope = OpenSearchIntegTestCase.Scope.TEST, numDataNodes = 0, minNumDataNodes = 3)
public class SearchWeightedRoutingIT extends OpenSearchIntegTestCase {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import org.opensearch.common.util.concurrent.AtomicArray;
import org.opensearch.core.action.ActionListener;
import org.opensearch.core.action.ShardOperationFailedException;
import org.opensearch.core.common.util.CollectionUtils;
import org.opensearch.core.index.shard.ShardId;
import org.opensearch.search.SearchPhaseResult;
import org.opensearch.search.SearchShardTarget;
Expand Down Expand Up @@ -181,16 +182,16 @@ abstract class AbstractSearchAsyncAction<Result extends SearchPhaseResult> exten
this.indexRoutings = indexRoutings;
this.results = resultConsumer;
this.clusters = clusters;
if (searchListenersList != null && !(searchListenersList.isEmpty())) {
if (!CollectionUtils.isEmpty(searchListenersList)) {
this.searchListenersList = searchListenersList;
this.searchRequestOperationsListener = new SearchRequestOperationsListener.CompositeListener(this.searchListenersList, logger);
instantiateStartMap();
instantiateEndMap();
instantiateFailMap();
instantiateSearchPhaseStartMap();
instantiateSearchPhaseEndMap();
instantiateSearchPhaseFailMap();
}
}

private void instantiateStartMap() {
private void instantiateSearchPhaseStartMap() {
Map<String, Runnable> searchPhaseStartTrackingMapModifiable = new HashMap<String, Runnable>();
searchPhaseStartTrackingMapModifiable.put(
SearchPhaseName.DFS_PRE_QUERY.getName(),
Expand Down Expand Up @@ -219,7 +220,7 @@ private void instantiateStartMap() {
searchPhaseStartTrackingMap = Collections.unmodifiableMap(searchPhaseStartTrackingMapModifiable);
}

private void instantiateEndMap() {
private void instantiateSearchPhaseEndMap() {
Map<String, Runnable> searchPhaseEndTrackingMapModifiable = new HashMap<String, Runnable>();
searchPhaseEndTrackingMapModifiable.put(
SearchPhaseName.DFS_PRE_QUERY.getName(),
Expand Down Expand Up @@ -266,7 +267,7 @@ private void instantiateEndMap() {
searchPhaseEndTrackingMap = Collections.unmodifiableMap(searchPhaseEndTrackingMapModifiable);
}

private void instantiateFailMap() {
private void instantiateSearchPhaseFailMap() {
Map<String, Runnable> searchPhaseFailureTrackingMapModifiable = new HashMap<String, Runnable>();
searchPhaseFailureTrackingMapModifiable.put(
SearchPhaseName.DFS_PRE_QUERY.getName(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,21 @@

package org.opensearch.action.search;

import org.opensearch.Version;
import org.opensearch.action.OriginalIndices;
import org.opensearch.action.support.IndicesOptions;
import org.opensearch.cluster.ClusterState;
import org.opensearch.cluster.node.DiscoveryNode;
import org.opensearch.cluster.routing.GroupShardsIterator;
import org.opensearch.common.UUIDs;
import org.opensearch.core.common.breaker.CircuitBreaker;
import org.opensearch.core.common.breaker.NoopCircuitBreaker;
import org.opensearch.common.collect.Tuple;
import org.opensearch.common.util.concurrent.AtomicArray;
import org.opensearch.common.util.concurrent.OpenSearchExecutors;
import org.opensearch.common.util.set.Sets;
import org.opensearch.core.action.ActionListener;
import org.opensearch.core.common.Strings;
import org.opensearch.core.common.breaker.CircuitBreaker;
import org.opensearch.core.common.breaker.NoopCircuitBreaker;
import org.opensearch.core.index.Index;
import org.opensearch.core.index.shard.ShardId;
import org.opensearch.index.query.MatchAllQueryBuilder;
Expand All @@ -64,7 +65,6 @@
import org.opensearch.threadpool.TestThreadPool;
import org.opensearch.threadpool.ThreadPool;
import org.opensearch.transport.Transport;
import org.opensearch.Version;
import org.junit.After;
import org.junit.Before;

Expand Down

0 comments on commit 8751cbd

Please sign in to comment.