fapifta commented on a change in pull request #2987: URL: https://github.com/apache/ozone/pull/2987#discussion_r791705233
########## File path: hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/ReadReplicas.java ########## @@ -0,0 +1,218 @@ +/** + * 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 + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * 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.ozone.debug; + +import com.google.gson.*; +import org.apache.hadoop.hdds.cli.SubcommandWithParent; +import org.apache.hadoop.hdds.client.BlockID; +import org.apache.hadoop.hdds.conf.OzoneConfiguration; +import org.apache.hadoop.hdds.protocol.DatanodeDetails; +import org.apache.hadoop.hdds.scm.OzoneClientConfig; +import org.apache.hadoop.ozone.client.OzoneClient; +import org.apache.hadoop.ozone.client.OzoneClientException; +import org.apache.hadoop.ozone.client.OzoneKeyDetails; +import org.apache.hadoop.ozone.client.io.OzoneInputStream; +import org.apache.hadoop.ozone.client.protocol.ClientProtocol; +import org.apache.hadoop.ozone.client.rpc.RpcClient; +import org.apache.hadoop.ozone.common.OzoneChecksumException; +import org.apache.hadoop.ozone.om.helpers.OmKeyLocationInfo; +import org.apache.hadoop.ozone.shell.OzoneAddress; +import org.apache.hadoop.ozone.shell.keys.KeyHandler; +import org.apache.ratis.thirdparty.io.grpc.StatusRuntimeException; +import org.jetbrains.annotations.NotNull; +import org.kohsuke.MetaInfServices; +import picocli.CommandLine; + +import java.io.File; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.StandardCopyOption; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Map; + +/** + * Class that downloads every replica for all the blocks associated with a + * given key. It also generates a manifest file with information about the + * downloaded replicas. + */ [email protected](name = "read-replicas", + description = "Reads every replica for all the blocks associated with a " + + "given key.") +@MetaInfServices(SubcommandWithParent.class) +public class ReadReplicas extends KeyHandler implements SubcommandWithParent { + + private ClientProtocol clientProtocol; + private ClientProtocol clientProtocolWithoutChecksum; + + @Override + public Class<?> getParentType() { + return OzoneDebug.class; + } + + @Override + protected void execute(OzoneClient client, OzoneAddress address) + throws IOException, OzoneClientException { + + clientProtocol = client.getObjectStore().getClientProxy(); + + OzoneConfiguration configuration = new OzoneConfiguration(); + OzoneClientConfig clientConfig = configuration + .getObject(OzoneClientConfig.class); + clientConfig.setChecksumVerify(false); + configuration.setFromObject(clientConfig); + clientProtocolWithoutChecksum = new RpcClient(configuration, null); Review comment: Simplification of the code is done, and great, but the other problem I mentioned have been remained. This code will not give you any error status if in the original configuration that comes from the getConf() method is already has the checksum verification set to false. Note that this means that the first client we use does not check checksum failures, and then we create a second client that is meant to read data from blocks with checksum failures, but we will not detect any checksum failures with the first client, as checksum verification is turned off there as well. Ultimately we would like to get the checksum errors, so if the original config turns off checksum verification, then we need a client set to verify the checksum, and use that for initial reads here I guess, so that we still detect checksum errors, and still we can download the data with the client which is set to skip the checksum validation. -- 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]
