belliottsmith commented on code in PR #257:
URL: https://github.com/apache/cassandra-accord/pull/257#discussion_r2505503388


##########
accord-core/src/main/java/accord/local/durability/DurabilityLevel.java:
##########
@@ -0,0 +1,140 @@
+/*
+ * 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 accord.local.durability;
+
+import java.util.Objects;
+import javax.annotation.Nullable;
+
+import accord.local.Node;
+import accord.local.durability.DurabilityService.SyncLocal;
+import accord.local.durability.DurabilityService.SyncRemote;
+import accord.utils.SortedArrays.SortedArrayList;
+
+import static accord.local.durability.DurabilityService.SyncLocal.NoLocal;
+import static accord.local.durability.DurabilityService.SyncRemote.NoRemote;
+
+public class DurabilityLevel
+{
+    public static final DurabilityLevel NONE = new DurabilityLevel(NoLocal, 
NoRemote, null, null);
+
+    public final SyncLocal local;
+    public final SyncRemote remote;
+    public final @Nullable SortedArrayList<Node.Id> including;
+    public final @Nullable SortedArrayList<Node.Id> excluding;
+
+    public DurabilityLevel(SyncLocal local, SyncRemote remote, @Nullable 
SortedArrayList<Node.Id> including)
+    {
+        this(local, remote, including, null);
+    }
+
+    public DurabilityLevel(SyncLocal local, SyncRemote remote, @Nullable 
SortedArrayList<Node.Id> including, @Nullable SortedArrayList<Node.Id> 
excluding)
+    {
+        this.local = local;
+        this.remote = remote;
+        this.including = including;
+        this.excluding = excluding;
+    }
+
+    public boolean equals(Object that)
+    {
+        return that instanceof DurabilityLevel && equals((DurabilityLevel) 
that);
+    }
+
+    private boolean equals(DurabilityLevel that)
+    {
+        return this.local == that.local
+               && this.remote == that.remote
+               && Objects.equals(this.including, that.including)
+               && Objects.equals(this.excluding, that.excluding);
+    }
+
+    @Override
+    public String toString()
+    {
+        return "{" +
+               "local=" + local +
+               ", remote=" + remote +
+               ", including=" + including +
+               ", excluding=" + excluding +
+               '}';
+    }
+
+    public static DurabilityLevel min(DurabilityLevel a, DurabilityLevel b)
+    {
+        SyncLocal local = min(a.local, b.local);
+        SyncRemote remote = min(a.remote, b.remote);
+        SortedArrayList<Node.Id> including = union(a.including, b.including);

Review Comment:
   including/excluding are opposites, and we union both then subtract excluding 
from the combination of including. The reason to do it this way is we might 
contact different sets of nodes, so have included in one round but not another 
doesn't mean we haven't succeeded on that node. But if the round contacted the 
node but had no reply, it will be included in the `excluding` collection



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