arjunashok commented on code in PR #17:
URL:
https://github.com/apache/cassandra-analytics/pull/17#discussion_r1372139184
##########
cassandra-analytics-core/src/main/java/org/apache/cassandra/spark/bulkwriter/token/ConsistencyLevel.java:
##########
@@ -20,18 +20,43 @@
package org.apache.cassandra.spark.bulkwriter.token;
import java.util.Collection;
+import java.util.Collections;
+import java.util.Set;
+import java.util.stream.Collectors;
import com.google.common.base.Preconditions;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import org.apache.cassandra.spark.common.model.CassandraInstance;
import org.apache.cassandra.spark.data.ReplicationFactor;
public interface ConsistencyLevel
{
boolean isLocal();
- boolean checkConsistency(Collection<? extends CassandraInstance>
failedInsts, ReplicationFactor replicationFactor, String localDC);
+ Logger LOGGER = LoggerFactory.getLogger(ConsistencyLevel.class);
+
+ /**
+ * Checks if the consistency guarantees are maintained, given the failed,
blocked and replacing instances, consistency-level and the replication-factor.
+ * <pre>
+ * - QUORUM based consistency levels check for quorum using the
write-replica-set (instead of RF) as they include healthy and pending nodes.
+ * This is done to ensure that writes go to a quorum of healthy nodes
while accounting for potential failure in pending nodes becoming healthy.
+ * - ONE and TWO consistency guarantees are maintained by ensuring that
the failures leave us with at-least the corresponding healthy
+ * (and non-pending) nodes.
+ *
+ * For both the above cases, blocked instances are also considered as
failures while performing consistency checks.
+ * Write replicas are adjusted to exclude replacement nodes for
consistency checks, if we have replacement nodes that are not among the failed
instances.
+ * This is to ensure that we are writing to sufficient non-replacement
nodes as replacements can potentially fail leaving us with fewer nodes.
+ * </pre>
+ */
+ boolean checkConsistency(CassandraRing ring,
+ TokenRangeMapping<? extends CassandraInstance>
tokenRangeMapping,
Review Comment:
Fair point. The reason I pulled this in is because some of these values are
CL specific. For instance, we use local_dc for LOCAL_QUORUM and LOCAL_ONE.
Also, for multi-DC, we cycle through all DCs to find consistency failures.
What you're suggesting will require some specific checks up-front (before
`checkConsistency`) for the cases I mentioned, but it will isolate CL
functionality to some extent. Will update
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]