keith-turner commented on code in PR #5284:
URL: https://github.com/apache/accumulo/pull/5284#discussion_r1930848240


##########
core/src/main/java/org/apache/accumulo/core/client/admin/TabletMergeabilityInfo.java:
##########
@@ -0,0 +1,112 @@
+/*
+ * 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
+ *
+ *   https://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.core.client.admin;
+
+import java.time.Duration;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.function.Supplier;
+
+import org.apache.accumulo.core.clientImpl.TabletMergeabilityUtil;
+
+import com.google.common.base.Preconditions;
+
+/**
+ * @since 4.0.0
+ */
+public class TabletMergeabilityInfo {
+
+  private final TabletMergeability tabletMergeability;
+  private final Optional<Duration> insertionTime;
+  private final Supplier<Duration> currentTime;
+
+  public TabletMergeabilityInfo(TabletMergeability tabletMergeability,
+      Optional<Duration> insertionTime, Supplier<Duration> currentTime) {
+    this.tabletMergeability = Objects.requireNonNull(tabletMergeability);
+    this.insertionTime = Objects.requireNonNull(insertionTime);
+    this.currentTime = Objects.requireNonNull(currentTime);
+    // This makes sure that insertionTime is set if TabletMergeability has a 
delay, and is empty
+    // if TabletMergeability is NEVER
+    Preconditions.checkArgument(tabletMergeability.isNever() == 
insertionTime.isEmpty(),
+        "insertionTime must not be empty if and only if TabletMergeability 
delay is >= 0");
+  }
+
+  /**
+   * @return the TabletMergeability
+   */
+  public TabletMergeability getTabletMergeability() {
+    return tabletMergeability;
+  }
+
+  /**
+   * Returns the time of the Manager when the TabletMergeability was set on 
the tablet. This will be
+   * empty if TabletMergeability is set to never
+   *
+   * @return the insertion time is set or else empty
+   */
+  public Optional<Duration> getInsertionTime() {
+    return insertionTime;
+  }
+
+  /**
+   * Returns the current time of the Manager
+   *
+   * @return the current time
+   */
+  public Duration getCurrentTime() {
+    return currentTime.get();
+  }

Review Comment:
   The scenario is based on changes happening during the scan plus the memoized 
supplier.  Something like the following could happen.
   
     1. Thread_1 starts reading tablet info objects
     2. Thread_1 reads TabletMergeabilityInfo for tablet_X.  This causes the 
memoized current steady time supplier to be set to 5.
     3. Thread_2 updates TabletMergeability for table_Y.  It sets the insertion 
steady time for the update to 7.
     4.  Thread_1 reads TabletMergeabilityInfo for tablet_Y.  To compute 
elapsed it does 5-7=-2.



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

Reply via email to