Skip to content

Commit 573a1ae

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 0ee7b30 commit 573a1ae

24 files changed

+803
-837
lines changed

Diff for: README.md

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

122122
```java
123-
protected void complete(long code, CompletableFuture<?> q);
123+
protected void complete(TarantoolPacket packet, TarantoolOp<?> future);
124124
```
125125

126126
## Spring NamedParameterJdbcTemplate usage example
127127

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

131140
```java
132141
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
*/
@@ -48,4 +50,9 @@ public class TarantoolClientConfig {
4850
public long initTimeoutMillis = 60 * 1000L;
4951
public long writeTimeoutMillis = 60 * 1000L;
5052

53+
/**
54+
* Operation expiration period.
55+
*/
56+
public int operationExpiryTimeMillis = DEFAULT_OPERATION_EXPIRY_TIME_MILLIS;
57+
5158
}

0 commit comments

Comments
 (0)