You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by GitBox <gi...@apache.org> on 2019/07/18 04:49:12 UTC

[GitHub] [accumulo] ctubbsii commented on a change in pull request #1276: Refactor how constraint violations are handled

ctubbsii commented on a change in pull request #1276: Refactor how constraint violations are handled
URL: https://github.com/apache/accumulo/pull/1276#discussion_r304732471
 
 

 ##########
 File path: server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/TabletMutationPrepAttempt.java
 ##########
 @@ -0,0 +1,124 @@
+/*
+ * 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.accumulo.tserver.tablet;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.accumulo.core.constraints.Violations;
+import org.apache.accumulo.core.data.Mutation;
+
+public class TabletMutationPrepAttempt {
+
+  private final Violations violations = new Violations();
+
+  private CommitSession commitSession;
+  private List<Mutation> violators;
+  private List<Mutation> nonViolators;
+  private boolean attemptedTabletPrep;
+
+  /**
+   * Return true if an attempt was made to update the writes in progress for the tablet and to
+   * retrieve the commit session from the tablet's memory, or false otherwise.
+   */
+  public boolean attemptedTabletPrep() {
+    return attemptedTabletPrep;
+  }
+
+  /**
+   * Return true if this attempt has a non-null commit session. If null, it indicates that either
+   * there was never an attempt made to get the commit session from the tablet's memory, or that
+   * either the tablet has a closed state or the tablet's memory is unavailable.
+   */
+  public boolean hasCommitSession() {
+    return commitSession != null;
+  }
+
+  /**
+   * Retrieve the commit session. Possibly null.
+   */
+  public CommitSession getCommitSession() {
+    return commitSession;
+  }
+
+  /**
+   * Retrieve the constraint violations found across the mutations. Never null.
+   */
+  public Violations getViolations() {
+    return violations;
+  }
+
+  /**
+   * Return true if at least one constraint violation was found, or false otherwise.
+   */
+  public boolean hasViolations() {
+    return !violations.isEmpty();
+  }
+
+  /**
+   * Return the list of mutations that violated a constraint. Either null or a non-empty list.
 
 Review comment:
   Nice javadocs. Some of the null-ness of these methods are inconsistent. Some are never null but could be empty, and some are null or non-empty lists. I understand this is residual from some of the previous implementation being refactored into here, but I wonder if there's room for improvement now that this encapsulating class exists.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services