Skip to content

Commit

Permalink
HDDS-11822. Register subcommands in OzoneShell (apache#7513)
Browse files Browse the repository at this point in the history
  • Loading branch information
adoroszlai authored Dec 2, 2024
1 parent e6bd3f5 commit db36e39
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@

import org.apache.hadoop.hdds.cli.HddsVersionProvider;
import org.apache.hadoop.hdds.tracing.TracingUtil;
import org.apache.hadoop.ozone.shell.bucket.BucketCommands;
import org.apache.hadoop.ozone.shell.keys.KeyCommands;
import org.apache.hadoop.ozone.shell.prefix.PrefixCommands;
import org.apache.hadoop.ozone.shell.snapshot.SnapshotCommands;
import org.apache.hadoop.ozone.shell.tenant.TenantUserCommands;
import org.apache.hadoop.ozone.shell.token.TokenCommands;
import org.apache.hadoop.ozone.shell.volume.VolumeCommands;

import picocli.CommandLine.Command;

Expand All @@ -27,14 +34,19 @@
*/
@Command(name = "ozone sh",
description = "Shell for Ozone object store",
subcommands = {
BucketCommands.class,
KeyCommands.class,
PrefixCommands.class,
SnapshotCommands.class,
TenantUserCommands.class,
TokenCommands.class,
VolumeCommands.class,
},
versionProvider = HddsVersionProvider.class,
mixinStandardHelpOptions = true)
public class OzoneShell extends Shell {

public OzoneShell() {
super(OzoneShell.class);
}

/**
* Main for the ozShell Command handling.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,9 @@
import org.apache.hadoop.hdds.cli.GenericParentCommand;
import org.apache.hadoop.hdds.cli.HddsVersionProvider;
import org.apache.hadoop.hdds.cli.MissingSubcommandException;
import org.apache.hadoop.hdds.cli.SubcommandWithParent;
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
import org.apache.hadoop.ozone.shell.OzoneShell;
import org.apache.hadoop.ozone.shell.Shell;

import org.kohsuke.MetaInfServices;
import picocli.CommandLine.Command;
import picocli.CommandLine.ParentCommand;

Expand All @@ -55,9 +52,7 @@
},
mixinStandardHelpOptions = true,
versionProvider = HddsVersionProvider.class)
@MetaInfServices(SubcommandWithParent.class)
public class BucketCommands implements GenericParentCommand, Callable<Void>,
SubcommandWithParent {
public class BucketCommands implements GenericParentCommand, Callable<Void> {

@ParentCommand
private Shell shell;
Expand All @@ -77,9 +72,4 @@ public boolean isVerbose() {
public OzoneConfiguration createOzoneConfiguration() {
return shell.createOzoneConfiguration();
}

@Override
public Class<?> getParentType() {
return OzoneShell.class;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,9 @@
import org.apache.hadoop.hdds.cli.GenericParentCommand;
import org.apache.hadoop.hdds.cli.HddsVersionProvider;
import org.apache.hadoop.hdds.cli.MissingSubcommandException;
import org.apache.hadoop.hdds.cli.SubcommandWithParent;
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
import org.apache.hadoop.ozone.shell.OzoneShell;
import org.apache.hadoop.ozone.shell.Shell;

import org.kohsuke.MetaInfServices;
import picocli.CommandLine.Command;
import picocli.CommandLine.ParentCommand;

Expand All @@ -55,9 +52,8 @@
},
mixinStandardHelpOptions = true,
versionProvider = HddsVersionProvider.class)
@MetaInfServices(SubcommandWithParent.class)
public class KeyCommands
implements GenericParentCommand, Callable<Void>, SubcommandWithParent {
implements GenericParentCommand, Callable<Void> {

@ParentCommand
private Shell shell;
Expand All @@ -77,9 +73,4 @@ public boolean isVerbose() {
public OzoneConfiguration createOzoneConfiguration() {
return shell.createOzoneConfiguration();
}

@Override
public Class<?> getParentType() {
return OzoneShell.class;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,9 @@
import org.apache.hadoop.hdds.cli.GenericParentCommand;
import org.apache.hadoop.hdds.cli.HddsVersionProvider;
import org.apache.hadoop.hdds.cli.MissingSubcommandException;
import org.apache.hadoop.hdds.cli.SubcommandWithParent;
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
import org.apache.hadoop.ozone.shell.OzoneShell;
import org.apache.hadoop.ozone.shell.Shell;

import org.kohsuke.MetaInfServices;
import picocli.CommandLine.Command;
import picocli.CommandLine.ParentCommand;

Expand All @@ -45,9 +42,7 @@
},
mixinStandardHelpOptions = true,
versionProvider = HddsVersionProvider.class)
@MetaInfServices(SubcommandWithParent.class)
public class PrefixCommands implements GenericParentCommand, Callable<Void>,
SubcommandWithParent {
public class PrefixCommands implements GenericParentCommand, Callable<Void> {

@ParentCommand
private Shell shell;
Expand All @@ -67,9 +62,4 @@ public boolean isVerbose() {
public OzoneConfiguration createOzoneConfiguration() {
return shell.createOzoneConfiguration();
}

@Override
public Class<?> getParentType() {
return OzoneShell.class;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,9 @@
import org.apache.hadoop.hdds.cli.GenericParentCommand;
import org.apache.hadoop.hdds.cli.HddsVersionProvider;
import org.apache.hadoop.hdds.cli.MissingSubcommandException;
import org.apache.hadoop.hdds.cli.SubcommandWithParent;
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
import org.apache.hadoop.ozone.shell.OzoneShell;
import org.apache.hadoop.ozone.shell.Shell;

import org.kohsuke.MetaInfServices;
import picocli.CommandLine.Command;
import picocli.CommandLine.ParentCommand;

Expand All @@ -48,9 +45,7 @@
},
mixinStandardHelpOptions = true,
versionProvider = HddsVersionProvider.class)
@MetaInfServices(SubcommandWithParent.class)
public class SnapshotCommands implements GenericParentCommand, Callable<Void>,
SubcommandWithParent {
public class SnapshotCommands implements GenericParentCommand, Callable<Void> {

@ParentCommand
private Shell shell;
Expand All @@ -70,9 +65,4 @@ public boolean isVerbose() {
public OzoneConfiguration createOzoneConfiguration() {
return shell.createOzoneConfiguration();
}

@Override
public Class<?> getParentType() {
return OzoneShell.class;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,8 @@
import org.apache.hadoop.hdds.cli.GenericParentCommand;
import org.apache.hadoop.hdds.cli.HddsVersionProvider;
import org.apache.hadoop.hdds.cli.MissingSubcommandException;
import org.apache.hadoop.hdds.cli.SubcommandWithParent;
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
import org.apache.hadoop.ozone.shell.OzoneShell;
import org.apache.hadoop.ozone.shell.Shell;
import org.kohsuke.MetaInfServices;
import picocli.CommandLine;

import java.util.concurrent.Callable;
Expand All @@ -46,9 +43,8 @@
},
mixinStandardHelpOptions = true,
versionProvider = HddsVersionProvider.class)
@MetaInfServices(SubcommandWithParent.class)
public class TenantUserCommands implements
GenericParentCommand, Callable<Void>, SubcommandWithParent {
GenericParentCommand, Callable<Void> {

@CommandLine.ParentCommand
private Shell shell;
Expand All @@ -68,9 +64,4 @@ public boolean isVerbose() {
public OzoneConfiguration createOzoneConfiguration() {
return shell.createOzoneConfiguration();
}

@Override
public Class<?> getParentType() {
return OzoneShell.class;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,9 @@
import org.apache.hadoop.hdds.cli.GenericParentCommand;
import org.apache.hadoop.hdds.cli.HddsVersionProvider;
import org.apache.hadoop.hdds.cli.MissingSubcommandException;
import org.apache.hadoop.hdds.cli.SubcommandWithParent;
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
import org.apache.hadoop.ozone.shell.OzoneShell;
import org.apache.hadoop.ozone.shell.Shell;

import org.kohsuke.MetaInfServices;
import picocli.CommandLine.Command;
import picocli.CommandLine.ParentCommand;

Expand All @@ -45,9 +42,8 @@
},
mixinStandardHelpOptions = true,
versionProvider = HddsVersionProvider.class)
@MetaInfServices(SubcommandWithParent.class)
public class TokenCommands
implements GenericParentCommand, Callable<Void>, SubcommandWithParent {
implements GenericParentCommand, Callable<Void> {

@ParentCommand
private Shell shell;
Expand All @@ -67,9 +63,4 @@ public boolean isVerbose() {
public OzoneConfiguration createOzoneConfiguration() {
return shell.createOzoneConfiguration();
}

@Override
public Class<?> getParentType() {
return OzoneShell.class;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,9 @@
import org.apache.hadoop.hdds.cli.GenericParentCommand;
import org.apache.hadoop.hdds.cli.HddsVersionProvider;
import org.apache.hadoop.hdds.cli.MissingSubcommandException;
import org.apache.hadoop.hdds.cli.SubcommandWithParent;
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
import org.apache.hadoop.ozone.shell.OzoneShell;
import org.apache.hadoop.ozone.shell.Shell;

import org.kohsuke.MetaInfServices;
import picocli.CommandLine.Command;
import picocli.CommandLine.ParentCommand;

Expand All @@ -53,9 +50,7 @@
},
mixinStandardHelpOptions = true,
versionProvider = HddsVersionProvider.class)
@MetaInfServices(SubcommandWithParent.class)
public class VolumeCommands implements GenericParentCommand, Callable<Void>,
SubcommandWithParent {
public class VolumeCommands implements GenericParentCommand, Callable<Void> {

@ParentCommand
private Shell shell;
Expand All @@ -75,9 +70,4 @@ public boolean isVerbose() {
public OzoneConfiguration createOzoneConfiguration() {
return shell.createOzoneConfiguration();
}

@Override
public Class<?> getParentType() {
return OzoneShell.class;
}
}

0 comments on commit db36e39

Please sign in to comment.