Package org.nuxeo.ecm.core.api
Class CursorService<C,O,R>
- java.lang.Object
-
- org.nuxeo.ecm.core.api.CursorService<C,O,R>
-
- Type Parameters:
C
- The cursor type.O
- The cursor item type.R
- The result type.
- Direct Known Subclasses:
MongoDBCursorService
public class CursorService<C,O,R> extends Object
A low level holder of DB cursors that manages cleaning on timeout.- Since:
- 9.1
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<String,CursorResult<C,O>>
cursorResults
protected Function<O,R>
extractor
-
Constructor Summary
Constructors Constructor Description CursorService(Function<O,R> extractor)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
checkForTimedOutScroll()
void
clear()
Clear and close all cursors owned by this service.protected boolean
isScrollTimedOut(String scrollId, CursorResult<C,O> cursorResult)
String
registerCursor(C cursor, int batchSize, int keepAliveSeconds)
Registers the inputCursorService
and generates a newscrollId
to associate with.String
registerCursor(String scrollId, C cursor, int batchSize, int keepAliveSeconds)
Registers the inputCursorService
associated to the inputscrollId
.String
registerCursorResult(String scrollId, CursorResult<C,O> cursorResult)
Registers the inputCursorResult
associated to the inputscrollId
.String
registerCursorResult(CursorResult<C,O> cursorResult)
Registers the inputCursorResult
and generates a newscrollId
to associate with.ScrollResult<R>
scroll(String scrollId)
boolean
unregisterCursor(String scrollId)
Unregisters cursor associated to the inputscrollId
.
-
-
-
Method Detail
-
checkForTimedOutScroll
public void checkForTimedOutScroll()
-
isScrollTimedOut
protected boolean isScrollTimedOut(String scrollId, CursorResult<C,O> cursorResult)
-
registerCursor
public String registerCursor(C cursor, int batchSize, int keepAliveSeconds)
Registers the inputCursorService
and generates a newscrollId
to associate with.- Returns:
- the scrollId associated to the cursor.
-
registerCursor
public String registerCursor(String scrollId, C cursor, int batchSize, int keepAliveSeconds)
Registers the inputCursorService
associated to the inputscrollId
.- Returns:
- the scrollId associated to the cursor.
-
registerCursorResult
public String registerCursorResult(CursorResult<C,O> cursorResult)
Registers the inputCursorResult
and generates a newscrollId
to associate with.- Returns:
- the scrollId associated to the cursor result.
-
registerCursorResult
public String registerCursorResult(String scrollId, CursorResult<C,O> cursorResult)
Registers the inputCursorResult
associated to the inputscrollId
.- Returns:
- the scrollId associated to the cursor result.
-
unregisterCursor
public boolean unregisterCursor(String scrollId)
Unregisters cursor associated to the inputscrollId
.- Parameters:
scrollId
- The scoll id ofCursorResult
to unregister- Returns:
- Whether or not the cursor was unregistered.
-
scroll
public ScrollResult<R> scroll(String scrollId)
- Returns:
- the next batch of cursor associated to the input
scrollId
-
clear
public void clear()
Clear and close all cursors owned by this service.
-
-