Skip to content

Commit

Permalink
HDDS-12056. Move ozone debug chunkinfo to ozone debug replicas chunk-…
Browse files Browse the repository at this point in the history
…info (#7702)
  • Loading branch information
sarvekshayr authored Jan 15, 2025
1 parent af36d73 commit 85e7521
Show file tree
Hide file tree
Showing 10 changed files with 75 additions and 24 deletions.
2 changes: 1 addition & 1 deletion hadoop-ozone/dist/src/main/compose/testlib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ execute_debug_tests() {

# get block locations for key
local chunkinfo="${key}-blocks-${prefix}"
docker-compose exec -T ${SCM} bash -c "ozone debug chunkinfo ${volume}/${bucket}/${key}" > "$chunkinfo"
docker-compose exec -T ${SCM} bash -c "ozone debug replicas chunk-info ${volume}/${bucket}/${key}" > "$chunkinfo"
local host="$(jq -r '.KeyLocations[0][0]["Datanode-HostName"]' ${chunkinfo})"
local container="${host%%.*}"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ private int runChunkInfoCommand(String volumeName, String bucketName,
Path.SEPARATOR + volumeName + Path.SEPARATOR + bucketName;
String[] args = new String[] {
getSetConfStringFromConf(OMConfigKeys.OZONE_OM_ADDRESS_KEY),
"chunkinfo", bucketPath + Path.SEPARATOR + keyName };
"replicas", "chunk-info", bucketPath + Path.SEPARATOR + keyName };

int exitCode = ozoneDebugShell.execute(args);
return exitCode;
Expand All @@ -218,7 +218,7 @@ private int runChunkInfoAndVerifyPaths(String volumeName, String bucketName,
Path.SEPARATOR + volumeName + Path.SEPARATOR + bucketName;
String[] args = new String[] {
getSetConfStringFromConf(OMConfigKeys.OZONE_OM_ADDRESS_KEY),
"chunkinfo", bucketPath + Path.SEPARATOR + keyName };
"replicas", "chunk-info", bucketPath + Path.SEPARATOR + keyName };
int exitCode = 1;
try (GenericTestUtils.SystemOutCapturer capture = new GenericTestUtils
.SystemOutCapturer()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* 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.ozone.debug.replicas;

import org.apache.hadoop.hdds.cli.DebugSubcommand;
import org.apache.hadoop.ozone.debug.replicas.chunk.ChunkKeyHandler;
import org.kohsuke.MetaInfServices;
import picocli.CommandLine;

/**
* Replicas debug related commands.
*/
@CommandLine.Command(
name = "replicas",
description = "Debug commands for replica-related issues, retrieving replica information from the OM and " +
"performing checks over the network against a running cluster.",
subcommands = {
ChunkKeyHandler.class
}
)
@MetaInfServices(DebugSubcommand.class)
public class ReplicasDebug implements DebugSubcommand {
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* limitations under the License.
*/

package org.apache.hadoop.ozone.debug.chunk;
package org.apache.hadoop.ozone.debug.replicas.chunk;
/**
* Class that gives datanode details on which the chunk is present.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* limitations under the License.
*/

package org.apache.hadoop.ozone.debug.chunk;
package org.apache.hadoop.ozone.debug.replicas.chunk;

/**
* Class that gives chunkDetails.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* limitations under the License.
*/

package org.apache.hadoop.ozone.debug.chunk;
package org.apache.hadoop.ozone.debug.replicas.chunk;

import java.io.File;
import java.io.IOException;
Expand All @@ -27,7 +27,6 @@

import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import org.apache.hadoop.hdds.cli.DebugSubcommand;
import org.apache.hadoop.hdds.client.ECReplicationConfig;
import org.apache.hadoop.hdds.client.StandaloneReplicationConfig;
import org.apache.hadoop.hdds.protocol.DatanodeDetails;
Expand All @@ -42,31 +41,22 @@
import org.apache.hadoop.ozone.OzoneConsts;
import org.apache.hadoop.ozone.client.OzoneClient;
import org.apache.hadoop.ozone.container.common.impl.ContainerLayoutVersion;
import org.apache.hadoop.ozone.debug.OzoneDebug;
import org.apache.hadoop.ozone.om.helpers.OmKeyArgs;
import org.apache.hadoop.ozone.om.helpers.OmKeyInfo;
import org.apache.hadoop.ozone.om.helpers.OmKeyLocationInfo;
import org.apache.hadoop.ozone.om.protocol.OzoneManagerProtocol;
import org.apache.hadoop.ozone.shell.OzoneAddress;
import org.apache.hadoop.ozone.shell.keys.KeyHandler;
import org.kohsuke.MetaInfServices;
import picocli.CommandLine;
import picocli.CommandLine.Command;

import static org.apache.hadoop.hdds.protocol.proto.HddsProtos.ReplicationFactor.ONE;

/**
* Class that gives chunk location given a specific key.
*/
@Command(name = "chunkinfo",
description = "returns chunk location"
+ " information about an existing key")
@MetaInfServices(DebugSubcommand.class)
public class ChunkKeyHandler extends KeyHandler implements
DebugSubcommand {

@CommandLine.ParentCommand
private OzoneDebug parent;
@Command(name = "chunk-info",
description = "Returns chunk location information about an existing key")
public class ChunkKeyHandler extends KeyHandler {

private String getChunkLocationPath(String containerLocation) {
return containerLocation + File.separator + OzoneConsts.STORAGE_DIR_CHUNKS;
Expand All @@ -75,7 +65,7 @@ private String getChunkLocationPath(String containerLocation) {
@Override
protected void execute(OzoneClient client, OzoneAddress address)
throws IOException {
try (ContainerOperationClient containerOperationClient = new ContainerOperationClient(parent.getOzoneConf());
try (ContainerOperationClient containerOperationClient = new ContainerOperationClient(getOzoneConf());
XceiverClientManager xceiverClientManager = containerOperationClient.getXceiverClientManager()) {
OzoneManagerProtocol ozoneManagerClient = client.getObjectStore().getClientProxy().getOzoneManagerClient();
address.ensureKeyAddress();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
package org.apache.hadoop.ozone.debug.chunk;
package org.apache.hadoop.ozone.debug.replicas.chunk;

/**
* The type of chunks of an Erasure Coded key.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* limitations under the License.
*/

package org.apache.hadoop.ozone.debug.chunk;
package org.apache.hadoop.ozone.debug.replicas.chunk;

import com.fasterxml.jackson.annotation.JsonInclude;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* 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.
*/

/**
* Command to debug replicas chunk information.
*/
package org.apache.hadoop.ozone.debug.replicas.chunk;
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
*/

/**
* Command to debug chunk information.
* Replicas debug related commands.
*/
package org.apache.hadoop.ozone.debug.chunk;
package org.apache.hadoop.ozone.debug.replicas;

0 comments on commit 85e7521

Please sign in to comment.