Skip to content

Commit

Permalink
Remove config timeout as parameter in crud client
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtDu committed Mar 16, 2023
1 parent 415aa88 commit 4d106ef
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 34 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

## [Unreleased]
- Remove config request timeout as default parameter in crud client
- Close public access to TarantoolResult*Impl ([#326](https://github.com/tarantool/cartridge-java/issues/326))
- Add deep copy instead of shallow copy in default message pack mapper

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,7 @@ public ProxyTarantoolSpace(

@Override
public CompletableFuture<R> delete(Conditions conditions) throws TarantoolClientException {
return delete(conditions, rowsMetadataTupleResultMapper(), ProxyDeleteOptions.create()
.withTimeout(config.getRequestTimeout())
);
return delete(conditions, rowsMetadataTupleResultMapper(), ProxyDeleteOptions.create());
}

@Override
Expand Down Expand Up @@ -113,9 +111,7 @@ private CompletableFuture<R> delete(

@Override
public CompletableFuture<R> insert(T tuple) throws TarantoolClientException {
return insert(tuple, rowsMetadataTupleResultMapper(), ProxyInsertOptions.create()
.withTimeout(config.getRequestTimeout())
);
return insert(tuple, rowsMetadataTupleResultMapper(), ProxyInsertOptions.create());
}

@Override
Expand Down Expand Up @@ -147,7 +143,6 @@ private CompletableFuture<R> insert(
@Override
public CompletableFuture<R> insertMany(Collection<T> tuples) {
return insertMany(tuples, rowsMetadataTupleResultMapper(), ProxyInsertManyOptions.create()
.withTimeout(config.getRequestTimeout())
.withStopOnError(true)
.withRollbackOnError(true)
);
Expand Down Expand Up @@ -182,9 +177,7 @@ private CompletableFuture<R> insertMany(

@Override
public CompletableFuture<R> replace(T tuple) throws TarantoolClientException {
return replace(tuple, rowsMetadataTupleResultMapper(), ProxyReplaceOptions.create()
.withTimeout(config.getRequestTimeout())
);
return replace(tuple, rowsMetadataTupleResultMapper(), ProxyReplaceOptions.create());
}

@Override
Expand Down Expand Up @@ -216,7 +209,6 @@ private CompletableFuture<R> replace(
@Override
public CompletableFuture<R> replaceMany(Collection<T> tuples) throws TarantoolClientException {
return replaceMany(tuples, rowsMetadataTupleResultMapper(), ProxyReplaceManyOptions.create()
.withTimeout(config.getRequestTimeout())
.withStopOnError(true)
.withRollbackOnError(true)
);
Expand Down Expand Up @@ -250,9 +242,7 @@ private CompletableFuture<R> replaceMany(

@Override
public CompletableFuture<R> select(Conditions conditions) throws TarantoolClientException {
return select(conditions, rowsMetadataTupleResultMapper(), ProxySelectOptions.create()
.withTimeout(config.getRequestTimeout())
);
return select(conditions, rowsMetadataTupleResultMapper(), ProxySelectOptions.create());
}

@Override
Expand All @@ -275,7 +265,6 @@ private CompletableFuture<R> select(
.withSpaceName(spaceName)
.withFunctionName(operationsMapping.getSelectFunctionName())
.withConditions(conditions)
.withOptions(options)
.withArgumentsMapper(config.getMessagePackMapper())
.withResultMapper(resultMapper)
.withOptions(options)
Expand All @@ -288,7 +277,6 @@ private CompletableFuture<R> select(
public CompletableFuture<R> update(Conditions conditions, T tuple) {
return update(conditions, makeOperationsFromTuple(tuple), rowsMetadataTupleResultMapper(),
ProxyUpdateOptions.create()
.withTimeout(config.getRequestTimeout())
);
}

Expand All @@ -310,9 +298,7 @@ public CompletableFuture<R> update(Conditions conditions, T tuple, UpdateOptions

@Override
public CompletableFuture<R> update(Conditions conditions, TupleOperations operations) {
return update(conditions, operations, rowsMetadataTupleResultMapper(), ProxyUpdateOptions.create()
.withTimeout(config.getRequestTimeout())
);
return update(conditions, operations, rowsMetadataTupleResultMapper(), ProxyUpdateOptions.create());
}

@Override
Expand Down Expand Up @@ -346,9 +332,7 @@ private CompletableFuture<R> update(

@Override
public CompletableFuture<R> upsert(Conditions conditions, T tuple, TupleOperations operations) {
return upsert(conditions, tuple, operations, rowsMetadataTupleResultMapper(), ProxyUpsertOptions.create()
.withTimeout(config.getRequestTimeout())
);
return upsert(conditions, tuple, operations, rowsMetadataTupleResultMapper(), ProxyUpsertOptions.create());
}

@Override
Expand Down Expand Up @@ -389,9 +373,6 @@ public CompletableFuture<Void> truncate() throws TarantoolClientException {
.withClient(client)
.withSpaceName(spaceName)
.withFunctionName(operationsMapping.getTruncateFunctionName())
.withOptions(ProxyTruncateOptions.create()
.withTimeout(config.getRequestTimeout())
)
.build()
);
} catch (TarantoolClientException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.util.List;
import java.util.concurrent.ExecutionException;

import static org.junit.Assert.assertNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;

Expand Down Expand Up @@ -87,7 +88,11 @@ public void withTimeout() throws ExecutionException, InterruptedException {
Conditions conditions = Conditions.equals(PK_FIELD_NAME, 1);
profileSpace.delete(conditions).get();
List<?> crudDeleteOpts = client.eval("return crud_delete_opts").get();
assertEquals(requestConfigTimeout, ((HashMap) crudDeleteOpts.get(0)).get("timeout"));
assertNull(((HashMap) crudDeleteOpts.get(0)).get("timeout"));

profileSpace.delete(conditions, ProxyDeleteOptions.create()).get();
crudDeleteOpts = client.eval("return crud_delete_opts").get();
assertNull(((HashMap) crudDeleteOpts.get(0)).get("timeout"));

// with option timeout
profileSpace.delete(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import io.tarantool.driver.api.space.TarantoolSpaceOperations;
import io.tarantool.driver.api.space.options.InsertManyOptions;
import io.tarantool.driver.api.space.options.proxy.ProxyInsertManyOptions;
import io.tarantool.driver.api.space.options.proxy.ProxyReplaceManyOptions;
import io.tarantool.driver.api.tuple.DefaultTarantoolTupleFactory;
import io.tarantool.driver.api.tuple.TarantoolTuple;
import io.tarantool.driver.api.tuple.TarantoolTupleFactory;
Expand All @@ -25,6 +26,7 @@
import java.util.List;
import java.util.concurrent.ExecutionException;

import static org.junit.Assert.assertNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;

Expand Down Expand Up @@ -123,13 +125,21 @@ public void withTimeout() throws ExecutionException, InterruptedException {
// with config timeout
profileSpace.insertMany(tarantoolTuples).get();
List<?> crudInsertManyOpts = client.eval("return crud_insert_many_opts").get();
assertEquals(requestConfigTimeout, ((HashMap) crudInsertManyOpts.get(0)).get("timeout"));
assertNull(((HashMap) crudInsertManyOpts.get(0)).get("timeout"));

// with option timeout
tarantoolTuples = Arrays.asList(
tupleFactory.create(3, null, "FIO", 50, 100),
tupleFactory.create(4, null, "KEK", 75, 125)
);
profileSpace.insertMany(tarantoolTuples, ProxyInsertManyOptions.create()).get();
crudInsertManyOpts = client.eval("return crud_insert_many_opts").get();
assertNull(((HashMap) crudInsertManyOpts.get(0)).get("timeout"));

// with option timeout
tarantoolTuples = Arrays.asList(
tupleFactory.create(5, null, "FIO", 50, 100),
tupleFactory.create(6, null, "KEK", 75, 125)
);

profileSpace.insertMany(
tarantoolTuples,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import io.tarantool.driver.api.space.options.InsertOptions;
import io.tarantool.driver.api.space.options.SelectOptions;
import io.tarantool.driver.api.space.options.proxy.ProxyInsertOptions;
import io.tarantool.driver.api.space.options.proxy.ProxyReplaceManyOptions;
import io.tarantool.driver.api.space.options.proxy.ProxySelectOptions;
import io.tarantool.driver.api.tuple.DefaultTarantoolTupleFactory;
import io.tarantool.driver.api.tuple.TarantoolTuple;
Expand All @@ -29,6 +30,7 @@
import java.util.List;
import java.util.concurrent.ExecutionException;

import static org.junit.Assert.assertNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
Expand Down Expand Up @@ -92,7 +94,12 @@ public void withTimeout() throws ExecutionException, InterruptedException {
// with config timeout
profileSpace.insert(tarantoolTuple).get();
List<?> crudInsertOpts = client.eval("return crud_insert_opts").get();
assertEquals(requestConfigTimeout, ((HashMap) crudInsertOpts.get(0)).get("timeout"));
assertNull(((HashMap) crudInsertOpts.get(0)).get("timeout"));

profileSpace.delete(Conditions.equals(PK_FIELD_NAME, 1)).get();
profileSpace.insert(tarantoolTuple, ProxyInsertOptions.create()).get();
crudInsertOpts = client.eval("return crud_insert_opts").get();
assertNull(((HashMap) crudInsertOpts.get(0)).get("timeout"));

// with option timeout
profileSpace.delete(Conditions.equals(PK_FIELD_NAME, 1)).get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.util.List;
import java.util.concurrent.ExecutionException;

import static org.junit.Assert.assertNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;

Expand Down Expand Up @@ -115,7 +116,11 @@ public void withTimeout() throws ExecutionException, InterruptedException {
// with config timeout
profileSpace.replaceMany(tarantoolTuples).get();
List<?> crudReplaceManyOpts = client.eval("return crud_replace_many_opts").get();
assertEquals(requestConfigTimeout, ((HashMap) crudReplaceManyOpts.get(0)).get("timeout"));
assertNull(((HashMap) crudReplaceManyOpts.get(0)).get("timeout"));

profileSpace.replaceMany(tarantoolTuples, ProxyReplaceManyOptions.create()).get();
crudReplaceManyOpts = client.eval("return crud_replace_many_opts").get();
assertNull(((HashMap) crudReplaceManyOpts.get(0)).get("timeout"));

// with option timeout
profileSpace.replaceMany(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.List;
import java.util.concurrent.ExecutionException;

import static org.junit.Assert.assertNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;

Expand Down Expand Up @@ -87,7 +88,14 @@ public void withTimeout() throws ExecutionException, InterruptedException {
// with config timeout
profileSpace.replace(tarantoolTuple).get();
List<?> crudReplaceOpts = client.eval("return crud_replace_opts").get();
assertEquals(requestConfigTimeout, ((HashMap) crudReplaceOpts.get(0)).get("timeout"));
assertNull(((HashMap) crudReplaceOpts.get(0)).get("timeout"));

profileSpace.replace(
tarantoolTuple,
ProxyReplaceOptions.create()
).get();
crudReplaceOpts = client.eval("return crud_replace_opts").get();
assertNull(((HashMap) crudReplaceOpts.get(0)).get("timeout"));

// with option timeout
profileSpace.replace(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,14 @@ public void withTimeout() throws ExecutionException, InterruptedException {
// with config timeout
profileSpace.select(Conditions.any()).get();
List<?> crudSelectOpts = client.eval("return crud_select_opts").get();
assertEquals(requestConfigTimeout, ((HashMap) crudSelectOpts.get(0)).get("timeout"));
assertNull(((HashMap) crudSelectOpts.get(0)).get("timeout"));

profileSpace.select(
Conditions.any(),
ProxySelectOptions.create()
).get();
crudSelectOpts = client.eval("return crud_select_opts").get();
assertNull(((HashMap) crudSelectOpts.get(0)).get("timeout"));

// with option timeout
profileSpace.select(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@ public void withTimeout() throws ExecutionException, InterruptedException {
// with config timeout
profileSpace.update(conditions, tarantoolTuple).get();
List<?> crudUpdateOpts = client.eval("return crud_update_opts").get();
assertEquals(requestConfigTimeout, ((HashMap) crudUpdateOpts.get(0)).get("timeout"));
assertNull(((HashMap) crudUpdateOpts.get(0)).get("timeout"));

profileSpace.update(conditions, tarantoolTuple, ProxyUpdateOptions.create()).get();
crudUpdateOpts = client.eval("return crud_update_opts").get();
assertNull(((HashMap) crudUpdateOpts.get(0)).get("timeout"));

// with option timeout
profileSpace.update(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,12 @@ public void withTimeout() throws ExecutionException, InterruptedException {
// with config timeout
profileSpace.upsert(conditions, tarantoolTuple, TupleOperations.set("age", 50)).get();
List<?> crudUpsertOpts = client.eval("return crud_upsert_opts").get();
assertEquals(requestConfigTimeout, ((HashMap) crudUpsertOpts.get(0)).get("timeout"));
assertNull(((HashMap) crudUpsertOpts.get(0)).get("timeout"));

profileSpace.upsert(conditions, tarantoolTuple, TupleOperations.set("age", 50),
ProxyUpsertOptions.create()).get();
crudUpsertOpts = client.eval("return crud_upsert_opts").get();
assertNull(((HashMap) crudUpsertOpts.get(0)).get("timeout"));

// with option timeout
profileSpace.upsert(
Expand Down

0 comments on commit 4d106ef

Please sign in to comment.