cshannon commented on code in PR #5284:
URL: https://github.com/apache/accumulo/pull/5284#discussion_r1929858703


##########
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:
   I added this method as I think having the elapsed time makes a lot of sense 
(I called getElapsed()) and I think the negative check is fine as a just in 
case to prevent issues, but I'm not sure it would actually happen in practice. 
The current time should be after the insertion time if the tablet existed and 
was in metadata when the user called getTabletInformation() so I'm not sure in 
what scenario it would actually be possible for the insertion time to be after 
the current time.



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