@ SuppressWarnings ( "unchecked" ) public < T > Sequence < T > runSimple ( final Query < T > query , final AuthenticationResult authenticationResult , @ Nullable final String remoteAddress ) { initialize ( query ) ; final Sequence < T > results ; try { final Access access = authorize ( authenticationResult ) ; if ( ! access . isAllowed ( ) ) { throw new ISE ( "Unauthorized" ) ; } final QueryLifecycle . QueryResponse queryResponse = execute ( ) ; results = queryResponse . getResults ( ) ; } catch ( Throwable e ) { emitLogsAndMetrics ( e , remoteAddress , - 1 ) ; throw e ; } return Sequences . wrap ( results , new SequenceWrapper ( ) { @ Override public void after ( final boolean isDone , final Throwable thrown ) { emitLogsAndMetrics ( thrown , remoteAddress , - 1 ) ; } } ) ; }
For callers where simplicity is desired over flexibility . This method does it all in one call . If the request is unauthorized an IllegalStateException will be thrown . Logs and metrics are emitted when the Sequence is either fully iterated or throws an exception .