Package io.tarantool.driver.core.space
Class RetryingTarantoolSpace<T extends Packable,R extends Collection<T>>
- java.lang.Object
-
- io.tarantool.driver.core.space.RetryingTarantoolSpace<T,R>
-
- Type Parameters:
T- target tuple typeR- target tuple collection type
- All Implemented Interfaces:
TarantoolSpaceOperations<T,R>
public class RetryingTarantoolSpace<T extends Packable,R extends Collection<T>> extends Object implements TarantoolSpaceOperations<T,R>
Wrapper forTarantoolSpaceOperationsinstances which adds request retry policy to each operation
-
-
Constructor Summary
Constructors Constructor Description RetryingTarantoolSpace(TarantoolSpaceOperations<T,R> spaceOperations, RequestRetryPolicyFactory retryPolicyFactory, Executor executor)Basic constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TarantoolCursor<T>cursor(Conditions conditions)Same asTarantoolSpaceOperations.cursor(Conditions, int)but uses the default batch size.TarantoolCursor<T>cursor(Conditions conditions, int batchSize)Cursor is an iterator-like object that is able to scroll through results of a query.CompletableFuture<R>delete(Conditions conditions)Delete a tuple.TarantoolSpaceMetadatagetMetadata()Get metadata associated with this spaceCompletableFuture<R>insert(T tuple)Inserts tuple into the space, if no tuple with same unique keys exists.CompletableFuture<R>replace(T tuple)Insert a tuple into the space or replace an existing one.CompletableFuture<R>select(Conditions conditions)Select tuples matching the specified query with options.CompletableFuture<Void>truncate()Truncate space if space would be found.CompletableFuture<R>update(Conditions conditions, TupleOperations operations)Update a tuple.CompletableFuture<R>update(Conditions conditions, T tuple)Update a tuple.CompletableFuture<R>upsert(Conditions conditions, T tuple, TupleOperations operations)Update tuple if it would be found elsewhere try to insert tuple.
-
-
-
Constructor Detail
-
RetryingTarantoolSpace
public RetryingTarantoolSpace(TarantoolSpaceOperations<T,R> spaceOperations, RequestRetryPolicyFactory retryPolicyFactory, Executor executor)
Basic constructor- Parameters:
spaceOperations-TarantoolSpaceOperationsinstance which operations will be wrappedretryPolicyFactory- request retrying policy factoryexecutor- executor service for retry callbacks
-
-
Method Detail
-
delete
public CompletableFuture<R> delete(Conditions conditions) throws TarantoolClientException
Description copied from interface:TarantoolSpaceOperationsDelete a tuple. Only a single primary index value condition is supported.- Specified by:
deletein interfaceTarantoolSpaceOperations<T extends Packable,R extends Collection<T>>- Parameters:
conditions- query with options- Returns:
- a future that will contain removed tuple once completed
- Throws:
TarantoolClientException- in case if the request failed
-
insert
public CompletableFuture<R> insert(T tuple) throws TarantoolClientException
Description copied from interface:TarantoolSpaceOperationsInserts tuple into the space, if no tuple with same unique keys exists. Otherwise throw duplicate key error.- Specified by:
insertin interfaceTarantoolSpaceOperations<T extends Packable,R extends Collection<T>>- Parameters:
tuple- new data- Returns:
- a future that will contain all corresponding tuples once completed
- Throws:
TarantoolClientException- in case if request failed
-
replace
public CompletableFuture<R> replace(T tuple) throws TarantoolClientException
Description copied from interface:TarantoolSpaceOperationsInsert a tuple into the space or replace an existing one.- Specified by:
replacein interfaceTarantoolSpaceOperations<T extends Packable,R extends Collection<T>>- Parameters:
tuple- new data- Returns:
- a future that will contain all corresponding tuples once completed
- Throws:
TarantoolClientException- in case if request failed
-
select
public CompletableFuture<R> select(Conditions conditions) throws TarantoolClientException
Description copied from interface:TarantoolSpaceOperationsSelect tuples matching the specified query with options.- Specified by:
selectin interfaceTarantoolSpaceOperations<T extends Packable,R extends Collection<T>>- Parameters:
conditions- query with options- Returns:
- a future that will contain all corresponding tuples once completed
- Throws:
TarantoolClientException- in case if the request failed
-
update
public CompletableFuture<R> update(Conditions conditions, T tuple)
Description copied from interface:TarantoolSpaceOperationsUpdate a tuple. Only a single primary index value condition is supported.- Specified by:
updatein interfaceTarantoolSpaceOperations<T extends Packable,R extends Collection<T>>- Parameters:
conditions- query with optionstuple- tuple with new field values- Returns:
- a future that will contain corresponding tuple once completed
-
update
public CompletableFuture<R> update(Conditions conditions, TupleOperations operations)
Description copied from interface:TarantoolSpaceOperationsUpdate a tuple. Only a single primary index value condition is supported.- Specified by:
updatein interfaceTarantoolSpaceOperations<T extends Packable,R extends Collection<T>>- Parameters:
conditions- query with optionsoperations- the list update operations- Returns:
- a future that will contain corresponding tuple once completed
-
upsert
public CompletableFuture<R> upsert(Conditions conditions, T tuple, TupleOperations operations)
Description copied from interface:TarantoolSpaceOperationsUpdate tuple if it would be found elsewhere try to insert tuple. Only a single primary index value condition is supported.- Specified by:
upsertin interfaceTarantoolSpaceOperations<T extends Packable,R extends Collection<T>>- Parameters:
conditions- query with optionstuple- new data that will be insert if tuple will be not foundoperations- the list of update operations to be performed if the tuple exists- Returns:
- a future that will empty list
-
truncate
public CompletableFuture<Void> truncate() throws TarantoolClientException
Description copied from interface:TarantoolSpaceOperationsTruncate space if space would be found. Otherwise, throw space not found error.- Specified by:
truncatein interfaceTarantoolSpaceOperations<T extends Packable,R extends Collection<T>>- Returns:
- a future that will contain void.
- Throws:
TarantoolClientException- in case if request failed
-
getMetadata
public TarantoolSpaceMetadata getMetadata()
Description copied from interface:TarantoolSpaceOperationsGet metadata associated with this space- Specified by:
getMetadatain interfaceTarantoolSpaceOperations<T extends Packable,R extends Collection<T>>- Returns:
- space metadata
-
cursor
public TarantoolCursor<T> cursor(Conditions conditions, int batchSize)
Description copied from interface:TarantoolSpaceOperationsCursor is an iterator-like object that is able to scroll through results of a query. Unlike a single cursor loads new tuples dynamically issuing requests to server. Select will fetch tuples matching the specified query. Each request to server will fetch no more than 'batch size' tuples.- Specified by:
cursorin interfaceTarantoolSpaceOperations<T extends Packable,R extends Collection<T>>- Parameters:
conditions- query with optionsbatchSize- size of a batch of single client request- Returns:
- cursor that can iterate through all corresponding tuples
-
cursor
public TarantoolCursor<T> cursor(Conditions conditions)
Description copied from interface:TarantoolSpaceOperationsSame asTarantoolSpaceOperations.cursor(Conditions, int)but uses the default batch size.- Specified by:
cursorin interfaceTarantoolSpaceOperations<T extends Packable,R extends Collection<T>>- Parameters:
conditions- query with options- Returns:
- cursor that can iterate through all corresponding tuples
-
-