Skip to content

Commit c57c7b3

Browse files
author
mpv1989
committed
Add docs for shutdown (issue #189)
1 parent 00c9397 commit c57c7b3

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

docs/Drivers/Java/Reference/README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ The driver supports connection pooling for VelocyStream with a default of 1 and
8080
ArangoDB arangoDB = new ArangoDB.Builder().maxConnections(8).build();
8181
```
8282

83+
The driver does not explicitly release connections. To avoid exhaustion of resources when no connection is needed, you can clear the connection pool (close all connections to the server) or use [connection TTL](#connection-time-to-live).
84+
85+
```Java
86+
arangoDB.shutdown();
87+
```
88+
8389
## Fallback hosts
8490

8591
The driver supports configuring multiple hosts. The first host is used to open a connection to. When this host is not reachable the next host from the list is used. To use this feature just call the method `host(String, int)` multiple times.
@@ -116,7 +122,7 @@ The second load balancing strategy allows to pick a random host from the configu
116122
ArangoDB arangoDB = new ArangoDB.Builder().loadBalancingStrategy(LoadBalancingStrategy.ONE_RANDOM).acquireHostList(true).build();
117123
```
118124

119-
## Connection - time to live (TTL)
125+
## Connection time to live
120126

121127
Since version 4.4 the driver supports setting a TTL for connections managed by the internal connection pool. Setting a TTL helps when using load balancing strategy `ROUND_ROBIN`, because as soon as a coordinator goes down, every open connection to that host will be closed and opened again with another target coordinator. As long as the driver does not have to open new connections (all connections in the pool are used) it will use only the coordinators which never went down. To use the downed coordinator again, when it is running again, the connections in the connection pool have to be closed and opened again with the target host mentioned by the load balancing startegy. To achieve this you can manually call `ArangoDB.shutdown` in your client code or use the TTL for connection so that a downed coordinator (which is then brought up again) will be used again after a certain time.
122128

src/main/java/com/arangodb/ArangoDB.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,11 @@ protected ArangoExecutorSync executor() {
521521
return executor;
522522
}
523523

524+
/**
525+
* Releases all connections to the server and clear the connection pool.
526+
*
527+
* @throws ArangoDBException
528+
*/
524529
public void shutdown() throws ArangoDBException {
525530
try {
526531
executor.disconnect();

0 commit comments

Comments
 (0)