F64116045 commented on code in PR #11199: URL: https://github.com/apache/ozone/pull/11199#discussion_r3985292230
########## hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/replication/health/DataChecksumMismatchCheckHandler.java: ########## @@ -0,0 +1,81 @@ +/* + * 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.replication.health; + +import static org.apache.hadoop.hdds.protocol.proto.HddsProtos.LifeCycleState.CLOSED; +import static org.apache.hadoop.hdds.protocol.proto.HddsProtos.ReplicationType.RATIS; +import static org.apache.hadoop.hdds.scm.container.ContainerHealthState.DATA_CHECKSUM_MISMATCH; +import static org.apache.hadoop.hdds.scm.container.ContainerReplicaChecksumMismatch.hasMismatch; + +import java.util.HashSet; +import java.util.Set; +import java.util.stream.Collectors; +import org.apache.hadoop.hdds.HddsUtils; +import org.apache.hadoop.hdds.scm.container.ContainerID; +import org.apache.hadoop.hdds.scm.container.ContainerInfo; +import org.apache.hadoop.hdds.scm.container.ContainerReplica; +import org.apache.hadoop.hdds.scm.container.replication.ContainerCheckRequest; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Detects replicas with the same BCSID and different data checksums. + */ +public class DataChecksumMismatchCheckHandler extends AbstractCheck { + + private static final Logger LOG = + LoggerFactory.getLogger(DataChecksumMismatchCheckHandler.class); + + private final Set<ContainerID> warnedMismatches = new HashSet<>(); + + @Override + public boolean handle(ContainerCheckRequest request) { + ContainerInfo container = request.getContainerInfo(); + Set<ContainerReplica> replicas = request.getContainerReplicas(); + boolean mismatch = container.getState() == CLOSED && + container.getReplicationType() == RATIS && + hasMismatch(replicas, ContainerReplica::getSequenceId, + ContainerReplica::getDataChecksum); + ContainerID containerID = container.containerID(); + if (!mismatch) { + if (!request.isReadOnly()) { + warnedMismatches.remove(containerID); + } + return false; + } + + request.getReport().incrementAndSampleAdditionalState( Review Comment: Read only request still record the mismatch in the report. only skip updating `warnedMismatches` and writing the warning log. -- 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]
