bdeggleston commented on code in PR #4708:
URL: https://github.com/apache/cassandra/pull/4708#discussion_r3431693238


##########
src/java/org/apache/cassandra/locator/CompositeTracker.java:
##########
@@ -0,0 +1,181 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.cassandra.locator;
+
+import java.util.Collection;
+import java.util.function.ToIntFunction;
+
+import org.apache.cassandra.exceptions.RequestFailureReason;
+
+/**
+ * Composite response tracker: broadcasts responses to all child trackers and 
succeeds when at least
+ * `blockFor` children are individually successful, or fails when `failures > 
count - blockFor`
+ *
+ * <ul>
+ *   <li>{@code blockFor == children.length} gives AND semantics (all must 
succeed)</li>
+ *   <li>{@code blockFor == quorum(children.length)} gives majority-quorum 
semantics</li>
+ * </ul>
+ */
+public class CompositeTracker implements ResponseTracker
+{
+    private final ResponseTracker[] children;
+    private final int blockFor;
+
+    public CompositeTracker(int blockFor, ResponseTracker... children)
+    {
+        if (children == null || children.length == 0)
+            throw new IllegalArgumentException("children cannot be null or 
empty");
+        if (blockFor < 1 || blockFor > children.length)
+            throw new IllegalArgumentException("blockFor must be between 1 and 
" + children.length);
+
+        this.children = children;
+        this.blockFor = blockFor;
+    }
+
+    public CompositeTracker(int blockFor, Collection<ResponseTracker> children)
+    {
+        this(blockFor, children.toArray(ResponseTracker[]::new));
+    }
+
+    public static int all(int count)

Review Comment:
   haha yeah, it did more in an earlier iteration of this, but's now obviously 
useless



-- 
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]

Reply via email to