Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add service status as command option to admin command #4567

Merged
merged 6 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,9 @@ public void execute(final String[] args) {
JCommander cl = new JCommander(opts);
cl.setProgramName("accumulo admin");

ServiceStatusCmd.Opts serviceStatusCommandOpts = new ServiceStatusCmd.Opts();
cl.addCommand("serviceStatus", serviceStatusCommandOpts);

ChangeSecretCommand changeSecretCommand = new ChangeSecretCommand();
cl.addCommand("changeSecret", changeSecretCommand);

Expand Down Expand Up @@ -398,6 +401,8 @@ public void execute(final String[] args) {
tServerLocksOpts.delete);
} else if (cl.getParsedCommand().equals("fate")) {
executeFateOpsCommand(context, fateOpsCommand);
} else if (cl.getParsedCommand().equals("serviceStatus")) {
printServiceStatus(context, serviceStatusCommandOpts);
} else {
everything = cl.getParsedCommand().equals("stopAll");

Expand Down Expand Up @@ -425,6 +430,11 @@ public void execute(final String[] args) {
}
}

private static void printServiceStatus(ServerContext context, ServiceStatusCmd.Opts opts) {
ServiceStatusCmd ssc = new ServiceStatusCmd();
ssc.execute(context, opts);
}

private static int ping(ClientContext context, List<String> args) {

InstanceOperations io = context.instanceOperations();
Expand Down Expand Up @@ -590,21 +600,11 @@ static String qualifyWithZooKeeperSessionId(String zTServerRoot, ZooCache zooCac
private Map<String,String> siteConfig, systemConfig;
private List<String> localUsers;

@SuppressFBWarnings(value = "PATH_TRAVERSAL_IN",
justification = "code runs in same security context as user who provided input")
public void printConfig(ClientContext context, DumpConfigCommand opts) throws Exception {

File outputDirectory = null;
if (opts.directory != null) {
outputDirectory = new File(opts.directory);
if (!outputDirectory.isDirectory()) {
throw new IllegalArgumentException(
opts.directory + " does not exist on the local filesystem.");
}
if (!outputDirectory.canWrite()) {
throw new IllegalArgumentException(opts.directory + " is not writable");
}
}
@SuppressFBWarnings(value = "PATH_TRAVERSAL_IN",
justification = "app is run in same security context as user providing the filename")
File outputDirectory = getOutputDirectory(opts.directory);
defaultConfig = DefaultConfiguration.getInstance();
siteConfig = context.instanceOperations().getSiteConfiguration();
systemConfig = context.instanceOperations().getSystemConfiguration();
Expand Down Expand Up @@ -651,6 +651,22 @@ public void printConfig(ClientContext context, DumpConfigCommand opts) throws Ex
}
}

@SuppressFBWarnings(value = "PATH_TRAVERSAL_IN",
justification = "app is run in same security context as user providing the filename")
private static File getOutputDirectory(final String directory) {
File outputDirectory = null;
if (directory != null) {
outputDirectory = new File(directory);
if (!outputDirectory.isDirectory()) {
throw new IllegalArgumentException(directory + " does not exist on the local filesystem.");
}
if (!outputDirectory.canWrite()) {
throw new IllegalArgumentException(directory + " is not writable");
}
}
return outputDirectory;
}

private String getDefaultConfigValue(String key) {
if (key == null) {
return null;
Expand Down
Loading