Github user ifesdjeen commented on a diff in the pull request:
https://github.com/apache/cassandra/pull/224#discussion_r197133145
--- Diff: src/java/org/apache/cassandra/service/StorageProxy.java ---
@@ -344,47 +343,43 @@ private static void recordCasContention(int
contentions)
casWriteMetrics.contention.update(contentions);
}
- private static Predicate<InetAddressAndPort> sameDCPredicateFor(final
String dc)
+ private static Predicate<Replica> sameDCPredicateFor(final String dc)
{
final IEndpointSnitch snitch =
DatabaseDescriptor.getEndpointSnitch();
- return new Predicate<InetAddressAndPort>()
- {
- public boolean apply(InetAddressAndPort host)
- {
- return dc.equals(snitch.getDatacenter(host));
- }
- };
+ return replica -> dc.equals(snitch.getDatacenter(replica));
}
private static PaxosParticipants getPaxosParticipants(TableMetadata
metadata, DecoratedKey key, ConsistencyLevel consistencyForPaxos) throws
UnavailableException
{
Token tk = key.getToken();
- List<InetAddressAndPort> naturalEndpoints =
StorageService.instance.getNaturalEndpoints(metadata.keyspace, tk);
- Collection<InetAddressAndPort> pendingEndpoints =
StorageService.instance.getTokenMetadata().pendingEndpointsFor(tk,
metadata.keyspace);
+ ReplicaList naturalReplicas =
StorageService.instance.getNaturalReplicas(metadata.keyspace, tk);
+ ReplicaList pendingReplicas = new
ReplicaList(StorageService.instance.getTokenMetadata().pendingEndpointsFor(tk,
metadata.keyspace));
if (consistencyForPaxos == ConsistencyLevel.LOCAL_SERIAL)
{
- // Restrict naturalEndpoints and pendingEndpoints to node in
the local DC only
+ // Restrict naturalReplicas and pendingReplicas to node in the
local DC only
String localDc =
DatabaseDescriptor.getEndpointSnitch().getDatacenter(FBUtilities.getBroadcastAddressAndPort());
- Predicate<InetAddressAndPort> isLocalDc =
sameDCPredicateFor(localDc);
- naturalEndpoints =
ImmutableList.copyOf(Iterables.filter(naturalEndpoints, isLocalDc));
- pendingEndpoints =
ImmutableList.copyOf(Iterables.filter(pendingEndpoints, isLocalDc));
+ Predicate<Replica> isLocalDc = sameDCPredicateFor(localDc);
+ naturalReplicas =
ReplicaList.immutableCopyOf(naturalReplicas.filter(isLocalDc));
--- End diff --
Do we need to make it immutable here, since we concat it later.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]