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
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@
### API changes

- Add "mode" option for crud select operation ([#107](https://github.com/tarantool/cartridge-java/issues/107))
- Change using of proxy client parameters (mode, rollback_on_error, stop_on_error) with enum classes([#419](https://github.com/tarantool/cartridge-java/issues/419))
- Change using of proxy client parameters (mode, rollback_on_error, stop_on_error) with enum classes ([#419](https://github.com/tarantool/cartridge-java/issues/419))

### Bugfixes

- Fix Instant converter to parse 8 bytes datetime ([#408](https://github.com/tarantool/cartridge-java/issues/408))

### Internal changes

- Change using of option names with the String type in the internal API to using with the ProxyOption enum class ([#420](https://github.com/tarantool/cartridge-java/issues/420))

## [0.12.1] - 2023-08-04

### Bugfixes
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package io.tarantool.driver.api.space.options;

import java.util.HashMap;
import java.util.Map;
import io.tarantool.driver.api.space.options.enums.crud.ProxyOption;

import java.util.EnumMap;
import java.util.Optional;

/**
Expand All @@ -12,15 +13,15 @@
*/
public abstract class BaseOptions implements Options {

private final Map<String, Object> resultMap = new HashMap<>();
private final EnumMap<ProxyOption, Object> resultMap = new EnumMap<>(ProxyOption.class);

/**
* Add an option value.
*
* @param option option name
* @param value option value
*/
public void addOption(String option, Object value) {
public void addOption(ProxyOption option, Object value) {
resultMap.put(option, value);
}

Expand All @@ -31,7 +32,7 @@ public void addOption(String option, Object value) {
* @param optionClass option value type
*/
@SuppressWarnings("unchecked")
public <T> Optional<T> getOption(String option, Class<T> optionClass) {
public <T> Optional<T> getOption(ProxyOption option, Class<T> optionClass) {
return Optional.ofNullable((T) resultMap.get(option));
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.tarantool.driver.api.space.options;

import io.tarantool.driver.api.space.options.enums.crud.ProxyOption;

import java.util.Optional;

/**
Expand All @@ -10,8 +12,6 @@
public interface OperationWithBucketIdOptions<T extends OperationWithBucketIdOptions<T>>
extends Options, Self<T> {

String BUCKET_ID = "bucket_id";

/**
* Specifies bucket id for an operation to perform it on storage with this bucket. It may be useful
* if a non-default sharding function is used or in other specific cases.
Expand All @@ -26,7 +26,7 @@ public interface OperationWithBucketIdOptions<T extends OperationWithBucketIdOpt
* @see <a href="https://github.com/tarantool/crud">crud</a>
*/
default T withBucketId(Integer bucketId) {
addOption(BUCKET_ID, bucketId);
addOption(ProxyOption.BUCKET_ID, bucketId);
return self();
}

Expand All @@ -36,6 +36,6 @@ default T withBucketId(Integer bucketId) {
* @return bucket id
*/
default Optional<Integer> getBucketId() {
return getOption(BUCKET_ID, Integer.class);
return getOption(ProxyOption.BUCKET_ID, Integer.class);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.tarantool.driver.api.space.options;

import io.tarantool.driver.api.space.options.enums.crud.ProxyOption;

import java.util.List;
import java.util.Optional;

Expand All @@ -11,8 +13,6 @@
public interface OperationWithFieldsOptions<T extends OperationWithFieldsOptions<T>>
extends Options, Self<T> {

String FIELDS = "fields";

/**
* Specifies list of fields names for getting only a subset of fields.
* By default, all fields are returned.
Expand All @@ -21,7 +21,7 @@ public interface OperationWithFieldsOptions<T extends OperationWithFieldsOptions
* @return this options instance
*/
default T withFields(List<String> fields) {
addOption(FIELDS, fields);
addOption(ProxyOption.FIELDS, fields);
return self();
}

Expand All @@ -31,6 +31,6 @@ default T withFields(List<String> fields) {
* @return list of fields string names
*/
default Optional<List> getFields() {
return getOption(FIELDS, List.class);
return getOption(ProxyOption.FIELDS, List.class);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.tarantool.driver.api.space.options;

import io.tarantool.driver.api.space.options.enums.crud.Mode;
import io.tarantool.driver.api.space.options.enums.crud.ProxyOption;

import java.util.Optional;

Expand All @@ -19,7 +20,7 @@ public interface OperationWithModeOptions<T extends OperationWithModeOptions<T>>
* @return this options instance.
*/
default T withMode(Mode mode) {
addOption(Mode.NAME, mode.value());
addOption(ProxyOption.MODE, mode.value());
return self();
}

Expand All @@ -29,7 +30,7 @@ default T withMode(Mode mode) {
* @return mode.
*/
default Optional<Mode> getMode() {
return getOption(Mode.NAME, Mode.class);
return getOption(ProxyOption.MODE, Mode.class);
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.tarantool.driver.api.space.options;


import io.tarantool.driver.api.space.options.enums.crud.ProxyOption;
import io.tarantool.driver.api.space.options.enums.crud.RollbackOnError;

import java.util.Optional;
Expand All @@ -12,6 +13,7 @@
*/
public interface OperationWithRollbackOnErrorOptions<T extends OperationWithRollbackOnErrorOptions<T>>
extends Options, Self<T> {

/**
* Specifies whether to not save any changes in the space if any tuple replace operation
* is unsuccesful. Default value is <code>true</code>.
Expand All @@ -20,7 +22,7 @@ public interface OperationWithRollbackOnErrorOptions<T extends OperationWithRoll
* @return this options instance
*/
default T withRollbackOnError(RollbackOnError rollbackOnError) {
addOption(RollbackOnError.NAME, rollbackOnError.value());
addOption(ProxyOption.ROLLBACK_ON_ERROR, rollbackOnError.value());
return self();
}

Expand All @@ -31,6 +33,6 @@ default T withRollbackOnError(RollbackOnError rollbackOnError) {
* @return true, if the operation should rollback on error
*/
default Optional<Boolean> getRollbackOnError() {
return getOption(RollbackOnError.NAME, Boolean.class);
return getOption(ProxyOption.ROLLBACK_ON_ERROR, Boolean.class);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.tarantool.driver.api.space.options;

import io.tarantool.driver.api.space.options.enums.crud.ProxyOption;
import io.tarantool.driver.api.space.options.enums.crud.StopOnError;

import java.util.Optional;
Expand All @@ -20,7 +21,7 @@ public interface OperationWithStopOnErrorOptions<T extends OperationWithStopOnEr
* @return this options instance
*/
default T withStopOnError(StopOnError stopOnError) {
addOption(StopOnError.NAME, stopOnError.value());
addOption(ProxyOption.STOP_ON_ERROR, stopOnError.value());
return self();
}

Expand All @@ -31,6 +32,6 @@ default T withStopOnError(StopOnError stopOnError) {
* @return true, if the operation should stop on error
*/
default Optional<Boolean> getStopOnError() {
return getOption(StopOnError.NAME, Boolean.class);
return getOption(ProxyOption.STOP_ON_ERROR, Boolean.class);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.tarantool.driver.api.space.options;

import io.tarantool.driver.api.space.options.enums.crud.ProxyOption;

import java.util.Optional;

/**
Expand All @@ -9,8 +11,6 @@
*/
public interface OperationWithTimeoutOptions<T extends OperationWithTimeoutOptions<T>> extends Options, Self<T> {

String TIMEOUT = "timeout";

/**
* Specifies timeout for waiting for a server response for the operation.
* Configured request timeout for that client will be used by default.
Expand All @@ -22,7 +22,7 @@ default T withTimeout(int timeout) {
if (timeout <= 0) {
throw new IllegalArgumentException("Timeout should be greater than 0");
}
addOption(TIMEOUT, timeout);
addOption(ProxyOption.TIMEOUT, timeout);
return self();
}

Expand All @@ -32,6 +32,6 @@ default T withTimeout(int timeout) {
* @return timeout, in milliseconds.
*/
default Optional<Integer> getTimeout() {
return getOption(TIMEOUT, Integer.class);
return getOption(ProxyOption.TIMEOUT, Integer.class);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.tarantool.driver.api.space.options;

import io.tarantool.driver.api.space.options.enums.crud.ProxyOption;

import java.util.Optional;

/**
Expand All @@ -16,7 +18,7 @@ public interface Options {
* @param option name of option
* @param value value of option
*/
void addOption(String option, Object value);
void addOption(ProxyOption option, Object value);

/**
* Return option value by name.
Expand All @@ -26,5 +28,5 @@ public interface Options {
* @param <T> option value type
* @return option value
*/
<T> Optional<T> getOption(String option, Class<T> optionClass);
<T> Optional<T> getOption(ProxyOption option, Class<T> optionClass);
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ public enum Mode {
WRITE("write"),
READ("read");

public static final String NAME = "mode";
private final String value;

Mode(String value) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package io.tarantool.driver.api.space.options.enums.crud;

/**
* General enumeration class representing the names of CRUD options.
*
* @author <a href="https://github.com/nickkkccc">Belonogov Nikolay</a>
*/
public enum ProxyOption {

MODE("mode"),

ROLLBACK_ON_ERROR("rollback_on_error"),

STOP_ON_ERROR("stop_on_error"),

TIMEOUT("timeout"),

FIELDS("fields"),

BUCKET_ID("bucket_id"),

BATCH_SIZE("batch_size"),

AFTER("after"),

FIRST("first");

private final String name;

ProxyOption(String name) {
this.name = name;
}

@Override
public String toString() {
return this.name;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ public enum RollbackOnError {

FALSE(false);

public static final String NAME = "rollback_on_error";
private final boolean value;

RollbackOnError(boolean value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ public enum StopOnError {

FALSE(false);

public static final String NAME = "stop_on_error";
private final boolean value;

StopOnError(boolean value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import io.tarantool.driver.api.space.options.BaseOptions;
import io.tarantool.driver.api.space.options.SelectOptions;
import io.tarantool.driver.api.space.options.enums.crud.ProxyOption;

import java.util.Optional;

Expand All @@ -13,8 +14,6 @@
*/
public final class ProxySelectOptions extends BaseOptions implements SelectOptions<ProxySelectOptions> {

public static final String BATCH_SIZE = "batch_size";

private ProxySelectOptions() {
}

Expand All @@ -37,7 +36,7 @@ public ProxySelectOptions withBatchSize(int batchSize) {
if (batchSize <= 0) {
throw new IllegalArgumentException("Batch size should be greater than 0");
}
addOption(BATCH_SIZE, batchSize);
addOption(ProxyOption.BATCH_SIZE, batchSize);
return self();
}

Expand All @@ -48,6 +47,6 @@ public ProxySelectOptions self() {

@Override
public Optional<Integer> getBatchSize() {
return getOption(BATCH_SIZE, Integer.class);
return getOption(ProxyOption.BATCH_SIZE, Integer.class);
}
}
Loading