Skip to content

Commit 98d6b78

Browse files
committed
fixed management of hosts marked for deletion (DE-723, #384)
1 parent 2a09dfa commit 98d6b78

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

Diff for: core/src/main/java/com/arangodb/internal/net/FallbackHostHandler.java

+3
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ public FallbackHostHandler(final HostResolver resolver) {
5050
@Override
5151
public Host get(final HostHandle hostHandle, AccessType accessType) {
5252
checkNext(hostHandle, accessType);
53+
if (current.isMarkforDeletion()) {
54+
fail(new ArangoDBException("Host marked for deletion"));
55+
}
5356
return current;
5457
}
5558

Diff for: core/src/main/java/com/arangodb/internal/net/RandomHostHandler.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public RandomHostHandler(final HostResolver resolver, final HostHandler fallback
4545

4646
@Override
4747
public Host get(final HostHandle hostHandle, AccessType accessType) {
48-
if (current == null) {
48+
if (current == null || current.isMarkforDeletion()) {
4949
hosts = resolver.getHosts();
5050
current = getRandomHost();
5151
}

Diff for: resilience-tests/src/test/java/resilience/connection/AcquireHostListTest.java

+15-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class AcquireHostListTest extends ClusterTest {
2020
@EnumSource(Protocol.class)
2121
void acquireHostList(Protocol protocol) {
2222
ArangoDB adb = new ArangoDB.Builder()
23-
.host("172.28.0.1", 8529)
23+
.host("127.0.0.1", 8529)
2424
.password("test")
2525
.acquireHostList(true)
2626
.protocol(protocol)
@@ -39,5 +39,19 @@ void acquireHostList(Protocol protocol) {
3939
assertThat(retrievedIds).containsExactlyInAnyOrderElementsOf(serverIds);
4040
}
4141

42+
@ParameterizedTest(name = "{index}")
43+
@EnumSource(LoadBalancingStrategy.class)
44+
void acquireHostListWithLoadBalancingStrategy(LoadBalancingStrategy lb) {
45+
ArangoDB adb = new ArangoDB.Builder()
46+
.host("127.0.0.1", 8529)
47+
.password("test")
48+
.acquireHostList(true)
49+
.loadBalancingStrategy(lb)
50+
.build();
51+
52+
adb.getVersion();
53+
adb.getVersion();
54+
adb.getVersion();
55+
}
4256

4357
}

0 commit comments

Comments
 (0)