Skip to content

Commit

Permalink
Applied formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
sahil buddharaju committed Jun 23, 2023
1 parent 85024eb commit 54950bd
Show file tree
Hide file tree
Showing 16 changed files with 159 additions and 93 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@
*/
public final class CoordinatorStats {


public SearchCoordinatorStats searchCoordinatorStats;
public CoordinatorStats () {

public CoordinatorStats() {
searchCoordinatorStats = new SearchCoordinatorStats();
}

public SearchCoordinatorStats getSearchCoordinatorStats() {
return searchCoordinatorStats;
}

public void setSearchCoordinatorStats(SearchCoordinatorStats searchCoordinatorStats) {
this.searchCoordinatorStats = searchCoordinatorStats;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
import org.opensearch.common.lease.Releasables;
import org.opensearch.common.util.concurrent.AbstractRunnable;
import org.opensearch.common.util.concurrent.AtomicArray;
import org.opensearch.index.reindex.ScrollableHitSource;
import org.opensearch.index.shard.ShardId;
import org.opensearch.search.SearchPhaseResult;
import org.opensearch.search.SearchShardTarget;
Expand Down Expand Up @@ -179,7 +178,7 @@ abstract class AbstractSearchAsyncAction<Result extends SearchPhaseResult> exten

}

public void setSearchListenerList (List<SearchRequestOperationsListener> searchListenersList) {
public void setSearchListenerList(List<SearchRequestOperationsListener> searchListenersList) {
this.searchListenersList = searchListenersList;
this.searchRequestOperationsListener = new SearchRequestOperationsListener.CompositeListener(this.searchListenersList, logger);
}
Expand Down Expand Up @@ -454,7 +453,8 @@ public void onPhaseEnd(SearchPhaseContext searchPhaseContext) {
searchRequestOperationsListener.onExpandSearchPhaseEnd(searchPhaseContext, tookTimeInMillis);
}
}
public void onPhaseStart (SearchPhase phase, SearchPhaseContext searchPhaseContext) {

public void onPhaseStart(SearchPhase phase, SearchPhaseContext searchPhaseContext) {
setCurrentPhase(phase);
phase.setStartTimeInNanos(System.nanoTime());
if (searchRequestOperationsListener == null) {
Expand Down Expand Up @@ -642,8 +642,14 @@ private void successfulShardExecution(SearchShardIterator shardsIt) {
}
}

public SearchPhase getCurrentPhase() { return currentPhase; }
public void setCurrentPhase(SearchPhase phase) { currentPhase = phase; }
public SearchPhase getCurrentPhase() {
return currentPhase;
}

public void setCurrentPhase(SearchPhase phase) {
currentPhase = phase;
}

@Override
public final int getNumShards() {
return results.getNumShards();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,64 +27,77 @@ public final class SearchCoordinatorStats implements SearchRequestOperationsList
// private volatile Map<String, StatsHolder> groupStats = emptyMap();

@Inject
public SearchCoordinatorStats () { }
public SearchCoordinatorStats() {}

public long getDFSPreQueryMetric() {
return totalStats.dfsPreQueryMetric.sum();
}

public long getDFSPreQueryCurrent() {
return totalStats.dfsPreQueryCurrent.count();
}

public long getDFSPreQueryTotal() {
return totalStats.dfsPreQueryTotal.count();
}

public long getCanMatchMetric() {
return totalStats.canMatchMetric.sum();
}

public long getCanMatchCurrent() {
return totalStats.canMatchCurrent.count();
}

public long getCanMatchTotal() {
return totalStats.canMatchTotal.count();
}

public long getQueryMetric() {
return totalStats.queryMetric.sum();
}

public long getQueryCurrent() {
return totalStats.queryCurrent.count();
}

public long getQueryTotal() {
return totalStats.queryTotal.count();
}

public long getFetchMetric() {
return totalStats.fetchMetric.sum();
}

public long getFetchCurrent() {
return totalStats.fetchCurrent.count();
}

public long getFetchTotal() {
return totalStats.fetchTotal.count();
}

public long getExpandSearchMetric() {
return totalStats.expandSearchMetric.sum();
}

public long getExpandSearchCurrent() {
return totalStats.expandSearchCurrent.count();
}

public long getExpandSearchTotal() {
return totalStats.expandSearchTotal.count();
}


private void computeStats(SearchPhaseContext searchPhaseContext, Consumer<StatsHolder> consumer) {
consumer.accept(totalStats);
}

@Override
public void onDFSPreQueryPhaseStart(SearchPhaseContext context) {
computeStats(context, statsHolder -> {
statsHolder.dfsPreQueryCurrent.inc();
});
computeStats(context, statsHolder -> { statsHolder.dfsPreQueryCurrent.inc(); });
}

@Override
public void onDFSPreQueryPhaseEnd(SearchPhaseContext context, long tookTime) {
computeStats(context, statsHolder -> {
Expand All @@ -93,16 +106,17 @@ public void onDFSPreQueryPhaseEnd(SearchPhaseContext context, long tookTime) {
totalStats.dfsPreQueryMetric.inc(tookTime);
});
}

@Override
public void onDFSPreQueryPhaseFailure(SearchPhaseContext context) {
return;
}

@Override
public void onCanMatchPhaseStart(SearchPhaseContext context) {
computeStats(context, statsHolder -> {
statsHolder.canMatchCurrent.inc();
});
computeStats(context, statsHolder -> { statsHolder.canMatchCurrent.inc(); });
}

@Override
public void onCanMatchPhaseEnd(SearchPhaseContext context, long tookTime) {
computeStats(context, statsHolder -> {
Expand All @@ -111,17 +125,17 @@ public void onCanMatchPhaseEnd(SearchPhaseContext context, long tookTime) {
totalStats.canMatchMetric.inc(tookTime);
});
}

@Override
public void onCanMatchPhaseFailure(SearchPhaseContext context) {
return;
}

@Override
public void onQueryPhaseStart(SearchPhaseContext context) {
computeStats(context, statsHolder -> {
statsHolder.queryCurrent.inc();
});
computeStats(context, statsHolder -> { statsHolder.queryCurrent.inc(); });
}

@Override
public void onQueryPhaseEnd(SearchPhaseContext context, long tookTime) {
computeStats(context, statsHolder -> {
Expand All @@ -130,16 +144,17 @@ public void onQueryPhaseEnd(SearchPhaseContext context, long tookTime) {
totalStats.queryMetric.inc(tookTime);
});
}

@Override
public void onQueryPhaseFailure(SearchPhaseContext context) {
return;
}

@Override
public void onFetchPhaseStart(SearchPhaseContext context) {
computeStats(context, statsHolder -> {
totalStats.fetchCurrent.inc();
});
computeStats(context, statsHolder -> { totalStats.fetchCurrent.inc(); });
}

@Override
public void onFetchPhaseEnd(SearchPhaseContext context, long tookTime) {
computeStats(context, statsHolder -> {
Expand All @@ -148,16 +163,17 @@ public void onFetchPhaseEnd(SearchPhaseContext context, long tookTime) {
totalStats.fetchMetric.inc(tookTime);
});
}

@Override
public void onFetchPhaseFailure(SearchPhaseContext context) {
return;
}

@Override
public void onExpandSearchPhaseStart(SearchPhaseContext context) {
computeStats(context, statsHolder -> {
totalStats.expandSearchCurrent.inc();
});
computeStats(context, statsHolder -> { totalStats.expandSearchCurrent.inc(); });
}

@Override
public void onExpandSearchPhaseEnd(SearchPhaseContext context, long tookTime) {
computeStats(context, statsHolder -> {
Expand All @@ -166,6 +182,7 @@ public void onExpandSearchPhaseEnd(SearchPhaseContext context, long tookTime) {
totalStats.expandSearchMetric.inc(tookTime);
});
}

@Override
public void onExpandSearchPhaseFailure(SearchPhaseContext context) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
package org.opensearch.action.search;

import org.opensearch.common.CheckedRunnable;
import org.opensearch.common.Nullable;

import java.io.IOException;
import java.util.Objects;
Expand All @@ -45,15 +44,19 @@
abstract class SearchPhase implements CheckedRunnable<IOException> {
private final String name;
private long startTime;

protected SearchPhase(String name) {
this.name = Objects.requireNonNull(name, "name must not be null");
}

public void setStartTimeInNanos(long startTime) {
this.startTime = startTime;
}

public long getStartTime() {
return startTime;
}

/**
* Returns the phases name.
*/
Expand Down
Loading

0 comments on commit 54950bd

Please sign in to comment.