T - as TokenC - as Container Typepublic interface TokenContainerService<T extends Token<T>,C extends TokenContainer<T>>
| Modifier and Type | Method and Description |
|---|---|
List<T> |
add(C tokenContainer,
List<T> tokens,
Consumer<T> consumer,
TokenEvent<T> tokenEvent) |
C |
getAssignedContainer(T token)
For a
Token get the container |
default Integer |
getMaxResultSize()
To ensure no overload of systems, the maximum # of tokens that can be fetched for any type of request
for container.
|
List<TokenPosition<T>> |
getPositions(List<T> tokens,
Collection states)
|
QStatesStrategy |
getQStatesStrategy()
A lot of the Service API internally depend on Token states/status
|
Number |
getSequence(C tokenContainer,
T token)
Get the index of a
Token ready To be served within its container |
Class<C> |
getType()
Type of
TokenContainer this service represents |
default boolean |
hasNext(C tokenContainer)
If there are any tokens pending that are in
#getReadyToBeProcessed(TokenContainer, Token). |
void |
init()
Load/Refresh any state for the token management service
|
void |
linkTokens(C tokenContainer,
List<T> tokens)
Re-Q / Move the tokens
|
Collection<T> |
lookup(C tokenContainer,
Query<T> query)
Lookup using custom query defined in a proxy Object
in tokens that are
#getReadyToBeProcessed(TokenContainer, Token). |
List<T> |
lookupById(C tokenContainer,
Object identifier)
Lookup token(s) in a token container, using any of the following identifiers.
|
void |
lookupBySequence(C tokenContainer,
Map<Number,T> indexMap)
UPDATE a Map with multiple tokens by lookup-sequence number
in tokens that are
#getReadyToBeProcessed(TokenContainer, Token). |
T |
lookupBySequence(C tokenContainer,
Number sequence)
Lookup a token in a Container by sequence number
in tokens that are
#getReadyToBeProcessed(TokenContainer, Token). |
int |
move(C tokenContainer,
List<T> tokens,
T tokenAfter)
Deprecated.
There can be many ways to move / prioritize tokens this implementation will not be supported in the future.
Each service will define its own moving strategy, and from that we may infer a common Move strategy in the future. For now
rely on
update(TokenContainer, List, TokenEvent) and the Token itself will contain details of where its being moved. |
T |
poll(C tokenContainer)
Poll then next token READY to be served.
|
List<T> |
poll(C tokenContainer,
Integer size)
An optimized Poll with N number of Tokens in one go.
|
List<T> |
poll(C tokenContainer,
Integer size,
T lastToken)
|
T |
poll(C tokenContainer,
T lastToken)
Based on Last Token return next
Token in TokenContainer.This is for fail safe to ensure if a Token is lost in network errors, then the server knows last point of rollback. |
List<T> |
remove(C tokenContainer,
List<T> tokens,
Consumer<T> consumer,
TokenEvent<T> tokenEvent)
Remove the association of the tokenContainer from the
Token |
T |
save(T token)
An innocent save method
|
Number |
size(C tokenContainer)
# of tokens Tokens that are in the
TokenContainer. |
List<T> |
update(C tokenContainer,
List<T> tokens,
TokenEvent<T> tokenEvent)
Update
Tokens passed from an API which is untrusted. |
<S extends FlowStatus> |
updateStatus(C tokenContainer,
List tokens,
S status,
TokenEvent<T> tokenEvent)
Update collection of tokens with status
|
<S extends FlowStatus> |
updateStatus(List tokens,
S status,
TokenEvent<T> tokenEvent)
Update collection of tokens with status
|
List<T> lookupById(C tokenContainer, Object identifier)
List is supported. For all practical purposes this will be a single result.tokenContainer - as TokenContainer type identifier - as name String, Id LongList of void lookupBySequence(C tokenContainer, Map<Number,T> indexMap)
#getReadyToBeProcessed(TokenContainer, Token).tokenContainer - as container type indexMap - the Map to update where key is sequence number (or or above), and value is Token to be inserted.T lookupBySequence(C tokenContainer, Number sequence)
#getReadyToBeProcessed(TokenContainer, Token).tokenContainer - as container type sequence - as NumberNumber getSequence(C tokenContainer, T token)
Token ready To be served within its container tokenContainer - as container type token - as TokenNumber. null if in a ready stateBatch.getSequence(Token),
getPositions(List, Collection)List<TokenPosition<T>> getPositions(List<T> tokens, Collection states)
tokenContainerType - as TokenContainer Class type tokens - as List of Token type states - as Token StatesNumber. null if in a ready stateBatch.getSequence(Token),
getSequence(TokenContainer, Token)Collection<T> lookup(C tokenContainer, Query<T> query)
#getReadyToBeProcessed(TokenContainer, Token).T poll(C tokenContainer)
QStatesStrategy.getReadyToBeProcessed()tokenContainer - as container type Token within the container. null if none#getReadyToBeProcessed(TokenContainer),
QStatesStrategyT poll(C tokenContainer, T lastToken)
Token in TokenContainer.tokenContainer - as TokenContainer type lastToken - as Token type Token type List<T> poll(C tokenContainer, Integer size)
tokenContainer - as TokenContainer type number - as IntegerList of Token of type List<T> poll(C tokenContainer, Integer size, T lastToken)
Tokens (of size), in Shift.tokenContainer - as TokenContainer type lastToken - List of Token of type List<T> add(C tokenContainer, List<T> tokens, Consumer<T> consumer, TokenEvent<T> tokenEvent) throws TokenGenerationException
tokenContainer - as container type tokens - as List of Tokensconsumer - as Consumer to apply an anonymous function at runtime over the Token elements iterated; after they are added. nullable truetokenEvent - as TokenEventList of Tokens that were addedTokenGenerationExceptionList<T> remove(C tokenContainer, List<T> tokens, Consumer<T> consumer, TokenEvent<T> tokenEvent)
Token@Deprecated int move(C tokenContainer, List<T> tokens, T tokenAfter)
update(TokenContainer, List, TokenEvent) and the Token itself will contain details of where its being moved.tokenContainer - as TokenContainer type tokens - as List of TokenstokenAfter. - @nullable true. If Null the move will occur after the last token within the containervoid linkTokens(C tokenContainer, List<T> tokens)
tokenContainer - as TokenContainer type tokens - as List of Tokens<S extends FlowStatus> List<T> updateStatus(List tokens, S status, TokenEvent<T> tokenEvent)
<S extends FlowStatus> List<T> updateStatus(C tokenContainer, List tokens, S status, TokenEvent<T> tokenEvent)
tokenContainer - as TokenContainer type tokens - as List of tokens of type Token or Ids. If null then will apply Status to all tokens in containerstatus - as StatustokenEvent - as TokenEventList of tokens affectedList<T> update(C tokenContainer, List<T> tokens, TokenEvent<T> tokenEvent) throws PartialTransactionException
Tokens passed from an API which is untrusted.
tokenContainer - type tokens - as List of TokenstokenEvent - as TokenEventList of tokens affected. The returned copy will be the same as what is persisted post update (not input; incase input output List are different)PartialTransactionExceptionNumber size(C tokenContainer)
TokenContainer.
If the container is a finite state container then it will be the actual size of it, else
if a stream then the count of tokens in #getReadyToBeProcessed(TokenContainer, Token).
This is an idempotent operation.tokenContainer - as TokenContainer type QStatesStrategy getQStatesStrategy()
QStatesStrategyC getAssignedContainer(T token)
Token get the containertoken - as TokenClass<C> getType()
TokenContainer this service representsTokenContainer typedefault boolean hasNext(C tokenContainer)
#getReadyToBeProcessed(TokenContainer, Token).
This is an idempotent operation.tokenContainer - as TokenContainer type default Integer getMaxResultSize()
void init()
Copyright © 2018. All rights reserved.