Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

### Bugfixes
- Fix lack of closing when greeting fails ([#379](https://github.com/tarantool/cartridge-java/pull/379))
- Get rid of double executor in retrying ([#382](https://github.com/tarantool/cartridge-java/pull/382))

## [0.11.1] - 2023-04-24

### Bugfixes
- Fix hasMetadata logic

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -440,8 +440,12 @@ private <S> CompletableFuture<S> wrapOperation(Supplier<CompletableFuture<S>> op

private TarantoolSpaceOperations<T, R> getTarantoolSpaceOperationsRetrying(
Supplier<TarantoolSpaceOperations<T, R>> spaceSupplier) {
CompletableFuture<TarantoolSpaceOperations<T, R>> wrapperForSync = new CompletableFuture<>();
try {
return wrapOperation(() -> CompletableFuture.supplyAsync(spaceSupplier, executor)).get();
return wrapOperation(() -> {
wrapperForSync.complete(spaceSupplier.get());
return wrapperForSync;
}).get();
} catch (InterruptedException e) {
throw new CompletionException(e);
} catch (ExecutionException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,4 +164,12 @@ public void passingArrayOfArraysWithNestedMaps(TarantoolSetup plan, Blackhole bh
bh.consume(plan.tarantoolClient.call(
"empty_function", plan.arraysWithNestedMaps).join());
}

@Benchmark
@Fork(1)
@BenchmarkMode(Mode.Throughput)
public void spaceCall(TarantoolSetup plan, Blackhole bh) {
bh.consume(plan.retryingTarantoolClient.space(
"test_space"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class TarantoolSetup {
.withLogConsumer(new Slf4jLogConsumer(log));

TarantoolClient<TarantoolTuple, TarantoolResult<TarantoolTuple>> tarantoolClient;
TarantoolClient<TarantoolTuple, TarantoolResult<TarantoolTuple>> retryingTarantoolClient;
MessagePackMapper defaultMapper;
CallResultMapper<TarantoolResult<TarantoolTuple>, SingleValueCallResult<TarantoolResult<TarantoolTuple>>>
resultMapper;
Expand All @@ -49,6 +50,9 @@ private void initClient() {
.withCredentials(tarantoolContainer.getUsername(), tarantoolContainer.getPassword())
.build();

retryingTarantoolClient
= TarantoolClientFactory.configureClient(tarantoolClient).withRetryingByNumberOfAttempts(3).build();
Copy link

@vasilevichra vasilevichra May 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Such a long name. Why not withRetry(3) or withAttempt(42) or withMaxTries(99)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, maybe we should rename it. Could you create a ticket for it?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a builder. We can make it hierarchical, but with plain structure as it is now such a long name is necessary because it specifies two options in one time: that we have a retry mechanism enabled and that we specify number of attempts as its parameter.


TarantoolTupleResultMapperFactory tarantoolTupleResultMapperFactory =
TarantoolTupleResultMapperFactoryImpl.getInstance();

Expand Down