use of org.opensearch.search.asynchronous.context.state.AsynchronousSearchStateMachineClosedException in project asynchronous-search by opensearch-project.
the class AsynchronousSearchPostProcessor method processSearchFailure.
public AsynchronousSearchResponse processSearchFailure(Exception exception, AsynchronousSearchContextId asynchronousSearchContextId) {
final Optional<AsynchronousSearchActiveContext> asynchronousSearchContextOptional = asynchronousSearchActiveStore.getContext(asynchronousSearchContextId);
try {
if (asynchronousSearchContextOptional.isPresent()) {
AsynchronousSearchActiveContext asynchronousSearchContext = asynchronousSearchContextOptional.get();
asynchronousSearchStateMachine.trigger(new SearchFailureEvent(asynchronousSearchContext, exception));
handlePersist(asynchronousSearchContext);
return asynchronousSearchContext.getAsynchronousSearchResponse();
}
// Best effort to return the response.
return new AsynchronousSearchResponse(AsynchronousSearchState.FAILED, -1L, -1L, null, ExceptionsHelper.convertToOpenSearchException(exception));
} catch (AsynchronousSearchStateMachineClosedException ex) {
// Best effort to return the response.
return new AsynchronousSearchResponse(AsynchronousSearchState.FAILED, -1L, -1L, null, ExceptionsHelper.convertToOpenSearchException(exception));
}
}
use of org.opensearch.search.asynchronous.context.state.AsynchronousSearchStateMachineClosedException in project asynchronous-search by opensearch-project.
the class AsynchronousSearchPostProcessor method processSearchResponse.
public AsynchronousSearchResponse processSearchResponse(SearchResponse searchResponse, AsynchronousSearchContextId asynchronousSearchContextId) {
final Optional<AsynchronousSearchActiveContext> asynchronousSearchContextOptional = asynchronousSearchActiveStore.getContext(asynchronousSearchContextId);
try {
if (asynchronousSearchContextOptional.isPresent()) {
AsynchronousSearchActiveContext asynchronousSearchContext = asynchronousSearchContextOptional.get();
asynchronousSearchStateMachine.trigger(new SearchSuccessfulEvent(asynchronousSearchContext, searchResponse));
handlePersist(asynchronousSearchContext);
return asynchronousSearchContext.getAsynchronousSearchResponse();
}
// Best effort to return the response.
return new AsynchronousSearchResponse(AsynchronousSearchState.SUCCEEDED, -1L, -1L, searchResponse, null);
} catch (AsynchronousSearchStateMachineClosedException ex) {
// Best effort to return the response.
return new AsynchronousSearchResponse(AsynchronousSearchState.SUCCEEDED, -1L, -1L, searchResponse, null);
}
}
Aggregations