Skip to content

Commit d38c098

Browse files
committed
Replace TConnection with TClientImpl in JDBC
Replace obsolete TarantoolConnection with TarantoolClient to have an ability to perform async operations. Update SQLDriver URL parameters. Add init and operation timeouts. Remove socket timeout and replace socket provider with socket channel provider options (according to TarantoolConnection-to-TarantoolClient transfer written above). Add operation timeout capability to TarantoolClientImpl. It also affects the cluster client which no more needs its own expirable operations. Add basic support for SQLStatement (setQueryTimeout) to execute requests with timeout using new TarantoolClient operation timeout. Remove deprecated JDBCBridge. SQLConnection accepted the responsibility for producing raw SQL results. Update README doc with respect to JDBC driver options changes. Closes: #163 Follows on: #75, #155
1 parent 3e6b15c commit d38c098

33 files changed

+1289
-954
lines changed

Diff for: README.md

+12-3
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,22 @@ Feel free to override any method of `TarantoolClientImpl`. For example, to hook
126126
all the results, you could override this:
127127

128128
```java
129-
protected void complete(long code, CompletableFuture<?> q);
129+
protected void complete(TarantoolPacket packet, TarantoolOp<?> future);
130130
```
131131

132132
## Spring NamedParameterJdbcTemplate usage example
133133

134-
To configure sockets you should implements SQLSocketProvider and add socketProvider=abc.xyz.MySocketProvider to connect url.
135-
For example tarantool://localhost:3301?user=test&password=test&socketProvider=abc.xyz.MySocketProvider
134+
The JDBC driver uses `TarantoolClient` implementation to provide a communication with server.
135+
To configure socket channel provider you should implements SocketChannelProvider and add
136+
`socketChannelProvider=abc.xyz.MySocketChannelProvider` to connect url.
137+
138+
For example:
139+
140+
```
141+
tarantool://localhost:3301?user=test&password=test&socketProvider=abc.xyz.MySocketProvider
142+
```
143+
144+
Here is an example how you can use the driver covered by Spring `DriverManagerDataSource`:
136145

137146
```java
138147
NamedParameterJdbcTemplate template = new NamedParameterJdbcTemplate(new DriverManagerDataSource("tarantool://localhost:3301?user=test&password=test"));

Diff for: src/main/java/org/tarantool/JDBCBridge.java

-85
This file was deleted.

Diff for: src/main/java/org/tarantool/SqlProtoUtils.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99

1010
public abstract class SqlProtoUtils {
1111
public static List<Map<String, Object>> readSqlResult(TarantoolPacket pack) {
12-
List<List<?>> data = (List<List<?>>) pack.getBody().get(Key.DATA.getId());
12+
List<List<Object>> data = getSQLData(pack);
13+
List<SQLMetaData> metaData = getSQLMetadata(pack);
1314

1415
List<Map<String, Object>> values = new ArrayList<>(data.size());
15-
List<SQLMetaData> metaData = getSQLMetadata(pack);
1616
for (List row : data) {
1717
LinkedHashMap<String, Object> value = new LinkedHashMap<>();
1818
for (int i = 0; i < row.size(); i++) {

Diff for: src/main/java/org/tarantool/TarantoolBase.java

+1-5
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@
1111

1212
public abstract class TarantoolBase<Result> extends AbstractTarantoolOps<Integer, List<?>, Object, Result> {
1313
protected String serverVersion;
14-
15-
/**
16-
* Connection state.
17-
*/
1814
protected MsgPackLite msgPackLite = MsgPackLite.INSTANCE;
1915
protected AtomicLong syncId = new AtomicLong();
2016
protected int initialRequestSize = 4096;
@@ -25,7 +21,7 @@ public TarantoolBase() {
2521
public TarantoolBase(String username, String password, Socket socket) {
2622
super();
2723
try {
28-
TarantoolGreeting greeting = ProtoUtils.connect(socket, username, password);
24+
TarantoolGreeting greeting = ProtoUtils.connect(socket, username, password, msgPackLite);
2925
this.serverVersion = greeting.getServerVersion();
3026
} catch (IOException e) {
3127
throw new CommunicationException("Couldn't connect to tarantool", e);

Diff for: src/main/java/org/tarantool/TarantoolClient.java

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ public interface TarantoolClient {
2323

2424
boolean isAlive();
2525

26+
boolean isClosed();
27+
2628
void waitAlive() throws InterruptedException;
2729

2830
boolean waitAlive(long timeout, TimeUnit unit) throws InterruptedException;

Diff for: src/main/java/org/tarantool/TarantoolClientConfig.java

+7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
public class TarantoolClientConfig {
44

5+
public static final int DEFAULT_OPERATION_EXPIRY_TIME_MILLIS = 1000;
6+
57
/**
68
* Auth-related data.
79
*/
@@ -67,4 +69,9 @@ public class TarantoolClientConfig {
6769
*/
6870
public int retryCount = 3;
6971

72+
/**
73+
* Operation expiration period.
74+
*/
75+
public int operationExpiryTimeMillis = DEFAULT_OPERATION_EXPIRY_TIME_MILLIS;
76+
7077
}

0 commit comments

Comments
 (0)