Skip to content

Commit

Permalink
implement Callable
Browse files Browse the repository at this point in the history
  • Loading branch information
adoroszlai committed Jan 6, 2025
1 parent 49834c8 commit 1939975
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicBoolean;

Expand Down Expand Up @@ -97,7 +98,7 @@
hidden = true, description = "Start the datanode for ozone",
versionProvider = HddsVersionProvider.class,
mixinStandardHelpOptions = true)
public class HddsDatanodeService extends GenericCli implements Runnable, ServicePlugin {
public class HddsDatanodeService extends GenericCli implements Callable<Void>, ServicePlugin {

private static final Logger LOG = LoggerFactory.getLogger(
HddsDatanodeService.class);
Expand Down Expand Up @@ -171,7 +172,7 @@ public static Logger getLogger() {
}

@Override
public void run() {
public Void call() throws Exception {
OzoneConfiguration configuration = getOzoneConf();
if (printBanner) {
HddsServerUtil.startupShutdownMessage(HddsVersionInfo.HDDS_VERSION_INFO,
Expand All @@ -186,6 +187,7 @@ public void run() {
LOG.error("Error during stop Ozone Datanode.", e);
}
}, DEFAULT_SHUTDOWN_HOOK_PRIORITY);
return null;
}

public void setConfiguration(OzoneConfiguration configuration) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@

import java.io.IOException;
import java.net.InetSocketAddress;
import java.util.concurrent.Callable;
import java.util.concurrent.atomic.AtomicBoolean;

import static org.apache.hadoop.hdds.ratis.RatisHelper.newJvmPauseMonitor;
Expand All @@ -70,7 +71,7 @@
/**
* Recon server main class that stops and starts recon services.
*/
public class ReconServer extends GenericCli implements Runnable {
public class ReconServer extends GenericCli implements Callable<Void> {

private static final Logger LOG = LoggerFactory.getLogger(ReconServer.class);
private Injector injector;
Expand All @@ -97,7 +98,7 @@ public static void main(String[] args) {
}

@Override
public void run() {
public Void call() throws Exception {
String[] originalArgs = getCmd().getParseResult().originalArgs()
.toArray(new String[0]);

Expand Down Expand Up @@ -194,6 +195,7 @@ public void run() {
LOG.error("Error during stop Recon server", e);
}
}, DEFAULT_SHUTDOWN_HOOK_PRIORITY);
return null;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import picocli.CommandLine;

import java.util.Collections;
import java.util.concurrent.Callable;

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

Expand All @@ -33,14 +34,14 @@
*/
@CommandLine.Command(name = "ozone checknative",
description = "Checks if native libraries are loaded")
public class CheckNative extends GenericCli implements Runnable {
public class CheckNative extends GenericCli implements Callable<Void> {

public static void main(String[] argv) {
new CheckNative().run(argv);
}

@Override
public void run() {
public Void call() throws Exception {
boolean nativeHadoopLoaded = org.apache.hadoop.util.NativeCodeLoader.isNativeCodeLoaded();
String hadoopLibraryName = "";
String isalDetail = "";
Expand Down Expand Up @@ -70,5 +71,6 @@ public void run() {
rocksToolsDetail = NativeLibraryLoader.getJniLibraryFileName();
}
System.out.printf("rocks-tools: %b %s%n", nativeRocksToolsLoaded, rocksToolsDetail);
return null;
}
}

0 comments on commit 1939975

Please sign in to comment.