Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion hadoop-hdds/docs/content/feature/ErasureCoding.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ The default value of java.library.path depends on the OS and Java version. For e
You can check if ISA-L is accessible to Ozone by running the following command:

```shell
ozone checknative
ozone debug checknative
```


9 changes: 2 additions & 7 deletions hadoop-ozone/dist/src/shell/ozone/ozone
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ function ozone_usage
ozone_add_subcommand "admin" client "Ozone admin tool"
ozone_add_subcommand "debug" client "Ozone debug tool"
ozone_add_subcommand "repair" client "Ozone repair tool"
ozone_add_subcommand "checknative" client "checks if native libraries are loaded"
ozone_add_subcommand "ratis" client "Ozone ratis tool"

ozone_generate_usage "${OZONE_SHELL_EXECNAME}" false
Expand Down Expand Up @@ -224,10 +223,6 @@ function ozonecmd_case
OZONE_DEBUG_OPTS="${OZONE_DEBUG_OPTS} ${RATIS_OPTS} ${OZONE_MODULE_ACCESS_ARGS}"
OZONE_RUN_ARTIFACT_NAME="ozone-tools"
;;
checknative)
OZONE_CLASSNAME=org.apache.hadoop.ozone.shell.checknative.CheckNative
OZONE_RUN_ARTIFACT_NAME="ozone-tools"
;;
ratis)
OZONE_CLASSNAME=org.apache.hadoop.ozone.shell.OzoneRatis
OZONE_RUN_ARTIFACT_NAME="ozone-tools"
Expand Down Expand Up @@ -305,8 +300,8 @@ fi

OZONE_SUBCMD=$1

if [[ "$OZONE_SUBCMD" == "auditparser" ]]; then
echo "warning: 'ozone auditparser' is deprecated, use 'ozone debug auditparser' instead."
if [[ "$OZONE_SUBCMD" == "auditparser" ]] || [[ "$OZONE_SUBCMD" == "checknative" ]]; then
echo "warning: 'ozone $OZONE_SUBCMD' is deprecated, use 'ozone debug $OZONE_SUBCMD' instead."
OZONE_SUBCMD="debug"
else
shift
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,27 @@
* limitations under the License.
*/

package org.apache.hadoop.ozone.shell.checknative;
package org.apache.hadoop.ozone.debug;

import static org.apache.hadoop.hdds.utils.NativeConstants.ROCKS_TOOLS_NATIVE_LIBRARY_NAME;

import java.util.Collections;
import java.util.concurrent.Callable;
import org.apache.hadoop.hdds.cli.GenericCli;
import org.apache.hadoop.hdds.cli.AbstractSubcommand;
import org.apache.hadoop.hdds.cli.DebugSubcommand;
import org.apache.hadoop.hdds.utils.NativeLibraryLoader;
import org.apache.hadoop.hdds.utils.db.managed.ManagedRocksObjectUtils;
import org.apache.hadoop.io.erasurecode.ErasureCodeNative;
import org.kohsuke.MetaInfServices;
import picocli.CommandLine;

/**
* CLI command to check if native libraries are loaded.
*/
@CommandLine.Command(name = "ozone checknative",
@CommandLine.Command(name = "checknative",
description = "Checks if native libraries are loaded")
public class CheckNative extends GenericCli implements Callable<Void> {

public static void main(String[] argv) {
new CheckNative().run(argv);
}
@MetaInfServices(DebugSubcommand.class)
public class CheckNative extends AbstractSubcommand implements Callable<Void>, DebugSubcommand {

@Override
public Void call() throws Exception {
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* 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;

import static org.apache.hadoop.hdds.utils.NativeConstants.ROCKS_TOOLS_NATIVE_LIBRARY_NAME;
import static org.assertj.core.api.Assertions.assertThat;

import org.apache.hadoop.hdds.utils.IOUtils;
import org.apache.ozone.test.GenericTestUtils;
import org.apache.ozone.test.tag.Native;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

/**
* Tests for {@link CheckNative}.
*/
class TestCheckNative {

private GenericTestUtils.PrintStreamCapturer out;

@BeforeEach
void init() {
out = GenericTestUtils.captureOut();
}

@Test
void testCheckNativeNotLoaded() {
executeCheckNative();
assertOutput(false);
}

@Native(ROCKS_TOOLS_NATIVE_LIBRARY_NAME)
@Test
void testCheckNativeRocksToolsLoaded() {
executeCheckNative();
assertOutput(true);
}

private void assertOutput(boolean expectedRocksNative) {
// trims multiple spaces
String stdOut = out.get()
.replaceAll(" +", " ");
assertThat(stdOut)
.contains("Native library checking:")
.contains("hadoop: false")
.contains("ISA-L: false")
.contains("rocks-tools: " + expectedRocksNative);
}

@AfterEach
void setUp() {
IOUtils.closeQuietly(out);
}

private static void executeCheckNative() {
new OzoneDebug().getCmd().execute("checknative");
}
}