Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
Signed-off-by: sahil buddharaju <[email protected]>
  • Loading branch information
sahil buddharaju committed Jul 31, 2023
1 parent 7771429 commit cefc8bd
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,8 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeOptionalWriteable(recoveryStats);
}

// We are adding request stats with a separate setter method since SearchStats was tightly coupled with Shard Search Stats, and all nodes won't share the same response in requestStats
// We are adding request stats with a separate setter method since SearchStats was tightly coupled with Shard Search Stats, and all
// nodes won't share the same response in requestStats
public void addRequestStats(RequestStats requestStats) {
if (requestStats.getSearchRequestStats() != null && this.search != null) {
search.setSearchRequestStats(requestStats.getSearchRequestStats());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,66 +191,87 @@ abstract class AbstractSearchAsyncAction<Result extends SearchPhaseResult> exten
}

private void instantiateStartMap() {
searchPhaseStartTrackingMap.put(SearchPhaseName.DFS_PRE_QUERY.getName(), () -> searchRequestOperationsListener.onDFSPreQueryPhaseStart(this));
searchPhaseStartTrackingMap.put(SearchPhaseName.CAN_MATCH.getName(), () -> searchRequestOperationsListener.onCanMatchPhaseStart(this));
searchPhaseStartTrackingMap.put(
SearchPhaseName.DFS_PRE_QUERY.getName(),
() -> searchRequestOperationsListener.onDFSPreQueryPhaseStart(this)
);
searchPhaseStartTrackingMap.put(
SearchPhaseName.CAN_MATCH.getName(),
() -> searchRequestOperationsListener.onCanMatchPhaseStart(this)
);
searchPhaseStartTrackingMap.put(SearchPhaseName.FETCH.getName(), () -> searchRequestOperationsListener.onQueryPhaseStart(this));
searchPhaseStartTrackingMap.put(SearchPhaseName.QUERY.getName(), () -> searchRequestOperationsListener.onQueryPhaseStart(this));
searchPhaseStartTrackingMap.put(SearchPhaseName.FETCH.getName(), () -> searchRequestOperationsListener.onFetchPhaseStart(this));
searchPhaseStartTrackingMap.put(SearchPhaseName.EXPAND.getName(), () -> searchRequestOperationsListener.onExpandSearchPhaseStart(this));
searchPhaseStartTrackingMap.put(
SearchPhaseName.EXPAND.getName(),
() -> searchRequestOperationsListener.onExpandSearchPhaseStart(this)
);
}

private void instantiateEndMap() {
searchPhaseEndTrackingMap.put(
SearchPhaseName.DFS_PRE_QUERY.getName(),
() -> searchRequestOperationsListener.onDFSPreQueryPhaseEnd(
this,
TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - this.getCurrentPhase().getStartTime())
)
SearchPhaseName.DFS_PRE_QUERY.getName(),
() -> searchRequestOperationsListener.onDFSPreQueryPhaseEnd(
this,
TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - this.getCurrentPhase().getStartTime())
)
);
searchPhaseEndTrackingMap.put(
SearchPhaseName.CAN_MATCH.getName(),
() -> searchRequestOperationsListener.onCanMatchPhaseEnd(
this,
TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - this.getCurrentPhase().getStartTime())
)
SearchPhaseName.CAN_MATCH.getName(),
() -> searchRequestOperationsListener.onCanMatchPhaseEnd(
this,
TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - this.getCurrentPhase().getStartTime())
)
);
searchPhaseEndTrackingMap.put(
SearchPhaseName.DFS_QUERY.getName(),
() -> searchRequestOperationsListener.onQueryPhaseEnd(
this,
TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - this.getCurrentPhase().getStartTime())
)
SearchPhaseName.DFS_QUERY.getName(),
() -> searchRequestOperationsListener.onQueryPhaseEnd(
this,
TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - this.getCurrentPhase().getStartTime())
)
);
searchPhaseEndTrackingMap.put(
SearchPhaseName.QUERY.getName(),
() -> searchRequestOperationsListener.onQueryPhaseEnd(
this,
TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - this.getCurrentPhase().getStartTime())
)
SearchPhaseName.QUERY.getName(),
() -> searchRequestOperationsListener.onQueryPhaseEnd(
this,
TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - this.getCurrentPhase().getStartTime())
)
);
searchPhaseEndTrackingMap.put(
SearchPhaseName.FETCH.getName(),
() -> searchRequestOperationsListener.onFetchPhaseEnd(
this,
TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - this.getCurrentPhase().getStartTime())
)
SearchPhaseName.FETCH.getName(),
() -> searchRequestOperationsListener.onFetchPhaseEnd(
this,
TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - this.getCurrentPhase().getStartTime())
)
);
searchPhaseEndTrackingMap.put(
SearchPhaseName.EXPAND.getName(),
() -> searchRequestOperationsListener.onExpandSearchPhaseEnd(
this,
TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - this.getCurrentPhase().getStartTime())
)
SearchPhaseName.EXPAND.getName(),
() -> searchRequestOperationsListener.onExpandSearchPhaseEnd(
this,
TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - this.getCurrentPhase().getStartTime())
)
);
}

private void instantiateFailMap () {
searchPhaseFailureTrackingMap.put(SearchPhaseName.DFS_PRE_QUERY.getName(), () -> searchRequestOperationsListener.onDFSPreQueryPhaseFailure(this));
searchPhaseFailureTrackingMap.put(SearchPhaseName.CAN_MATCH.getName(), () -> searchRequestOperationsListener.onCanMatchPhaseFailure(this));
searchPhaseFailureTrackingMap.put(SearchPhaseName.DFS_QUERY.getName(), () -> searchRequestOperationsListener.onQueryPhaseFailure(this));
private void instantiateFailMap() {
searchPhaseFailureTrackingMap.put(
SearchPhaseName.DFS_PRE_QUERY.getName(),
() -> searchRequestOperationsListener.onDFSPreQueryPhaseFailure(this)
);
searchPhaseFailureTrackingMap.put(
SearchPhaseName.CAN_MATCH.getName(),
() -> searchRequestOperationsListener.onCanMatchPhaseFailure(this)
);
searchPhaseFailureTrackingMap.put(
SearchPhaseName.DFS_QUERY.getName(),
() -> searchRequestOperationsListener.onQueryPhaseFailure(this)
);
searchPhaseFailureTrackingMap.put(SearchPhaseName.QUERY.getName(), () -> searchRequestOperationsListener.onQueryPhaseFailure(this));
searchPhaseFailureTrackingMap.put(SearchPhaseName.FETCH.getName(), () -> searchRequestOperationsListener.onFetchPhaseFailure(this));
searchPhaseFailureTrackingMap.put(SearchPhaseName.EXPAND.getName(), () -> searchRequestOperationsListener.onExpandSearchPhaseFailure(this));
searchPhaseFailureTrackingMap.put(
SearchPhaseName.EXPAND.getName(),
() -> searchRequestOperationsListener.onExpandSearchPhaseFailure(this)
);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.BiFunction;
Expand Down Expand Up @@ -639,7 +638,7 @@ public void testDFSQuerySearchRequestListeners() throws InterruptedException {
final List<SearchRequestOperationsListener> requestOperationListeners = new ArrayList<>(List.of(testListener));

SearchDfsQueryThenFetchAsyncAction searchDfsQueryThenFetchAsyncAction = createSearchDfsQueryThenFetchAsyncAction(
requestOperationListeners
requestOperationListeners
);
long delay = (int) Math.floor(Math.random() * (5 - 1 + 1) + 1);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public void onExpandSearchPhaseEnd(SearchPhaseContext context, long tookTime) {
for (int i = 0; i < totalListeners; i++) {
requestOperationListeners.add(testListener);
}

SearchRequestOperationsListener compositeListener = new SearchRequestOperationsListener.CompositeListener(
requestOperationListeners,
logger
Expand Down

0 comments on commit cefc8bd

Please sign in to comment.