keith-turner commented on code in PR #5187: URL: https://github.com/apache/accumulo/pull/5187#discussion_r1909064640
########## core/src/main/java/org/apache/accumulo/core/client/admin/TabletMergeability.java: ########## @@ -0,0 +1,90 @@ +/* + * 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.io.Serializable; +import java.time.Duration; +import java.util.Objects; + +import com.google.common.base.Preconditions; + +public class TabletMergeability implements Serializable { Review Comment: Need `@since` tags in javadoc since this class is in a public API package. ########## core/src/main/java/org/apache/accumulo/core/client/admin/TabletMergeability.java: ########## @@ -0,0 +1,90 @@ +/* + * 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.io.Serializable; +import java.time.Duration; +import java.util.Objects; + +import com.google.common.base.Preconditions; + +public class TabletMergeability implements Serializable { + private static final long serialVersionUID = 1L; + + public static final TabletMergeability NEVER = new TabletMergeability(Duration.ofNanos(-1)); + public static final TabletMergeability NOW = new TabletMergeability(Duration.ZERO); + + private final Duration delay; + + private TabletMergeability(Duration delay) { + this.delay = Objects.requireNonNull(delay); + } + + public boolean isNever() { + return this.delay.isNegative(); + } + + public boolean isNow() { + return this.delay.isZero(); + } + + public boolean isFuture() { Review Comment: Feel free to ignore this suggestion. Was thinking this name went better w/ the getDelay() method. ```suggestion public boolean isDelayed() { ``` ########## core/src/main/java/org/apache/accumulo/core/client/admin/TabletMergeability.java: ########## @@ -0,0 +1,90 @@ +/* + * 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.io.Serializable; +import java.time.Duration; +import java.util.Objects; + +import com.google.common.base.Preconditions; + +public class TabletMergeability implements Serializable { + private static final long serialVersionUID = 1L; + + public static final TabletMergeability NEVER = new TabletMergeability(Duration.ofNanos(-1)); + public static final TabletMergeability NOW = new TabletMergeability(Duration.ZERO); + + private final Duration delay; + + private TabletMergeability(Duration delay) { + this.delay = Objects.requireNonNull(delay); + } + + public boolean isNever() { + return this.delay.isNegative(); + } + + public boolean isNow() { + return this.delay.isZero(); + } + + public boolean isFuture() { + return delay.toNanos() > 0; + } + + public Duration getDelay() { + return delay; + } + + @Override + public boolean equals(Object o) { + if (o == null || getClass() != o.getClass()) { + return false; + } + TabletMergeability that = (TabletMergeability) o; + return Objects.equals(delay, that.delay); + } + + @Override + public int hashCode() { + return Objects.hashCode(delay); + } + + @Override + public String toString() { + if (isNow()) { + return "TabletMergeability=NOW"; + } else if (isNever()) { + return "TabletMergeability=NEVER"; + } + return "TabletMergeability=AFTER:" + delay.toNanos(); + } + + public static TabletMergeability from(Duration delay) { + Preconditions.checkArgument(delay.toNanos() >= -1, + "Duration of delay must be -1, 0, or a positive offset."); + return new TabletMergeability(delay); + } Review Comment: This method needs javadoc outlining the acceptable input values for duration. Since this is a public API class wondering if the following would be better instead, however those methods would still need javadoc. Could make those constants private if adding these also, thinking the methods give a bit more flexibility to change. ```suggestion public static TabletMergeability now(){ return NOW: } public static TabletMergeability never(){ return NEVER: } ``` ########## core/src/main/java/org/apache/accumulo/core/client/admin/TabletMergeability.java: ########## @@ -0,0 +1,90 @@ +/* + * 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.io.Serializable; +import java.time.Duration; +import java.util.Objects; + +import com.google.common.base.Preconditions; + +public class TabletMergeability implements Serializable { + private static final long serialVersionUID = 1L; + + public static final TabletMergeability NEVER = new TabletMergeability(Duration.ofNanos(-1)); + public static final TabletMergeability NOW = new TabletMergeability(Duration.ZERO); + + private final Duration delay; + + private TabletMergeability(Duration delay) { + this.delay = Objects.requireNonNull(delay); + } + + public boolean isNever() { + return this.delay.isNegative(); + } + + public boolean isNow() { + return this.delay.isZero(); + } + + public boolean isFuture() { + return delay.toNanos() > 0; + } + + public Duration getDelay() { + return delay; Review Comment: Could do the following to give more flexibility w/ changing how now and never are represented, would need add javadoc if doing so. ```suggestion public Duration getDelay() { Preconditions.checkstate(isDelayed()); return delay; ``` ########## core/src/main/java/org/apache/accumulo/core/client/admin/TabletMergeability.java: ########## @@ -0,0 +1,86 @@ +/* + * 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.io.Serializable; +import java.time.Duration; +import java.util.Objects; + +import com.google.common.base.Preconditions; + +public class TabletMergeability implements Serializable { + private static final long serialVersionUID = 1L; + + public static final TabletMergeability NEVER = new TabletMergeability(Duration.ofNanos(-1)); + public static final TabletMergeability NOW = new TabletMergeability(Duration.ofNanos(0)); + + private final Duration delay; + + private TabletMergeability(Duration delay) { + this.delay = Objects.requireNonNull(delay); + } + + public boolean isNever() { + return this.delay.isNegative(); + } + + public boolean isNow() { + return this.delay.isZero(); + } + + public Duration getDelay() { + return delay; + } + + @Override + public boolean equals(Object o) { + if (o == null || getClass() != o.getClass()) { + return false; + } + TabletMergeability that = (TabletMergeability) o; + return Objects.equals(delay, that.delay); + } + + @Override + public int hashCode() { + return Objects.hashCode(delay); + } + + @Override + public String toString() { + if (isNow()) { + return "TabletMergeability=NOW"; + } else if (isNever()) { + return "TabletMergeability=NEVER"; + } + return "TabletMergeability=AFTER:" + delay.toNanos(); Review Comment: Could convert to ms and include the unit at the end of the string. -- 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]
