sodonnel commented on code in PR #11199: URL: https://github.com/apache/ozone/pull/11199#discussion_r4006141816
########## hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/container/ContainerReplicaChecksumMismatch.java: ########## @@ -0,0 +1,68 @@ +/* + * 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.hadoop.hdds.scm.container; + +import java.util.Collection; +import java.util.Objects; +import java.util.function.Function; +import java.util.function.ToLongFunction; + +/** + * Detects different data checksums reported for the same container replica + * sequence ID. + */ +public final class ContainerReplicaChecksumMismatch { + + private ContainerReplicaChecksumMismatch() { + } + + /** + * Returns true when replicas with the same sequence ID report different + * non-zero data checksums. If any replica has not reported a sequence ID or + * checksum yet, no comparison is made. + */ + public static <T> boolean hasMismatch(Collection<T> replicas, + Function<T, Long> sequenceId, ToLongFunction<T> dataChecksum) { Review Comment: When does this need to return a generic type and why do we need to pass in two functions (sequenceId and dataChecksum) which are just methods on the replicas? Seems like unnecessary indirection. I also think this entire class could go away and this could just be a method (perhaps private) in the new handler class? -- 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]
