dombizita commented on a change in pull request #2987: URL: https://github.com/apache/ozone/pull/2987#discussion_r791792598
########## 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: Thanks, I didn't think it through, that the original configuration can have the checksum verification turned off. Changed the code, so whether the configuration is set to check or not the checksum, I will have two clients, one with checksum verification and one without. -- 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]
