-
Notifications
You must be signed in to change notification settings - Fork 15
Retry on hosts in different datacenters #5902
Conversation
Generate changelog in
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, pending tests
...b-cassandra/src/main/java/com/palantir/atlasdb/keyvalue/cassandra/pool/CassandraService.java
Outdated
Show resolved
Hide resolved
config.servers().accept(new CassandraServersConfigs.ThriftHostsExtractingVisitor()); | ||
config.servers().accept(new ThriftHostsExtractingVisitor()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
.mapKeys(EndpointDetails::getHost) | ||
.mapKeys(this::getAddressForHostThrowUnchecked) | ||
.map(EndpointDetails::getDatacenter) | ||
.collectToMap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please trace log this so we can more easily reason about it if needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
discussed offline: moved to once per iteration as opposed to once per interval, but added!
...b-cassandra/src/main/java/com/palantir/atlasdb/keyvalue/cassandra/pool/CassandraService.java
Show resolved
Hide resolved
public void selectsAnyHostIfAllDatacentersAlreadyTried() { | ||
ImmutableSet<InetSocketAddress> allHosts = ImmutableSet.of(HOST_1, HOST_2); | ||
CassandraService cassandra = clientPoolWithServers(allHosts); | ||
cassandra.overrideHostToDatacenterMapping(ImmutableMap.of(HOST_1, DC_1, HOST_2, DC_2)); | ||
Set<InetSocketAddress> suggestedHosts = IntStream.range(0, 1_000) | ||
.mapToObj(attempt -> cassandra.getRandomGoodHostForPredicate(address -> true, allHosts)) | ||
.flatMap(Optional::stream) | ||
.map(CassandraClientPoolingContainer::getHost) | ||
.collect(Collectors.toSet()); | ||
assertThat(suggestedHosts).containsExactlyInAnyOrderElementsOf(allHosts); | ||
} | ||
|
||
@Test | ||
public void selectsAnyHostIfNoDatacentersAlreadyTried() { | ||
ImmutableSet<InetSocketAddress> allHosts = ImmutableSet.of(HOST_1, HOST_2); | ||
CassandraService cassandra = clientPoolWithServers(allHosts); | ||
cassandra.overrideHostToDatacenterMapping(ImmutableMap.of(HOST_1, DC_1, HOST_2, DC_2)); | ||
Set<InetSocketAddress> suggestedHosts = IntStream.range(0, 1_000) | ||
.mapToObj(attempt -> cassandra.getRandomGoodHostForPredicate(address -> true, ImmutableSet.of())) | ||
.flatMap(Optional::stream) | ||
.map(CassandraClientPoolingContainer::getHost) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it'd be great if we could extract a common method here
|
||
@Test | ||
public void selectsHostMatchingPredicateEvenIfRelatedHostsAlreadyTried() { | ||
ImmutableSet<InetSocketAddress> allHosts = ImmutableSet.of(HOST_1, HOST_2, HOST_3); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't need this variable when we only use it once
|
||
@Test | ||
public void selectsHostsWithUnknownDatacenterMappingIfAllKnownDatacentersTried() { | ||
ImmutableSet<InetSocketAddress> allHosts = ImmutableSet.of(HOST_1, HOST_2, HOST_3); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
👍 |
Released 0.540.0 |
Goals (and why):
==COMMIT_MSG==
==COMMIT_MSG==
Implementation Description (bullets):
Testing (What was existing testing like? What have you done to improve it?):
Concerns (what feedback would you like?):
Where should we start reviewing?:
Priority (whenever / two weeks / yesterday):