Skip to content
Permalink
Browse files
Search operation with explicit specification of operation timeout (DI…
…RAPI-378).
  • Loading branch information
semancik committed Aug 6, 2021
1 parent c2fd0a0 commit ae44076689fc9791c671c5742a9b1e9be1d74a9e
Showing 1 changed file with 27 additions and 5 deletions.
@@ -2400,23 +2400,45 @@ public SearchCursor search( SearchRequest searchRequest ) throws LdapException
if ( searchRequest == null )
{
String msg = I18n.err( I18n.ERR_04130_CANNOT_PROCESS_NULL_SEARCH_REQ );

if ( LOG.isDebugEnabled() )
{
LOG.debug( msg );
}

throw new IllegalArgumentException( msg );
}
long localSearchTimeout = getTimeout( readOperationTimeout, searchRequest.getTimeLimit() );
return search( searchRequest, localSearchTimeout );
}

SearchFuture searchFuture = searchAsync( searchRequest );
/**
* Search operation with explicit specification of operation timeout.
* This is very useful for special-purpose search operations, such as connection liveliness test.
* In that case we want to make a very quick search with a very short timeout.
* We do not want to use the default search timeout in this case, as that is likely to be in order of seconds.
* That is too long for quick connection check.
* searchRequest.timeLimit is not going to work either, as it has very rough granularity (seconds).
*/
public SearchCursor search( SearchRequest searchRequest, long localSearchTimeout ) throws LdapException
{
if ( searchRequest == null )
{
String msg = I18n.err( I18n.ERR_04130_CANNOT_PROCESS_NULL_SEARCH_REQ );

long localSearchTimeout = getTimeout( readOperationTimeout, searchRequest.getTimeLimit() );
if ( LOG.isDebugEnabled() )
{
LOG.debug( msg );
}

throw new IllegalArgumentException( msg );
}

SearchFuture searchFuture = searchAsync( searchRequest );

return new SearchCursorImpl( searchFuture, localSearchTimeout, TimeUnit.MILLISECONDS );
}


//------------------------ The LDAP operations ------------------------//
// Unbind operations //
//---------------------------------------------------------------------//

0 comments on commit ae44076

Please sign in to comment.