Skip to content

Commit

Permalink
[apache#768] feat(cli): Cli method for blacklist update
Browse files Browse the repository at this point in the history
  • Loading branch information
beryllw committed Jun 7, 2023
1 parent c274b37 commit d201d97
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
15 changes: 8 additions & 7 deletions cli/src/main/java/org/apache/uniffle/cli/UniffleCLI.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class UniffleCLI extends AbstractCustomCommandLine {
private final Option checkerClass;
private final Option coordServer;
private final Option coordPort;
private final Option refreshAccessCli;
private final Option refreshCheckerCli;
private final Option help;
protected UniffleRestClient client;

Expand All @@ -48,21 +48,22 @@ public UniffleCLI(String shortPrefix, String longPrefix) {
true, "This is an client cli command that will print args.");
uniffleAdminCli = new Option(shortPrefix + "a", longPrefix + "admin",
true, "This is an admin command that will print args.");
refreshAccessCli = new Option(shortPrefix + "rc", longPrefix + "refreshChecker",
refreshCheckerCli = new Option(shortPrefix + "rc", longPrefix + "refreshChecker",
false, "This is an admin command that will refresh access checker.");
checkerClass = new Option(shortPrefix + "cc", longPrefix + "checkerClass",
true, "This is the checker class that will be refreshed.");
help = new Option(shortPrefix + "h", longPrefix + "help",
false, "Help for the Uniffle CLI.");
coordServer = new Option(shortPrefix + "s", longPrefix + "host",
true, "This is coordinator server host.");
coordPort = new Option(shortPrefix + "p", longPrefix + "port",
true, "This is coordinator server port.");
help = new Option(shortPrefix + "h", longPrefix + "help",
false, "Help for the Uniffle CLI.");
allOptions.addOption(uniffleClientCli);
allOptions.addOption(uniffleAdminCli);
allOptions.addOption(refreshCheckerCli);
allOptions.addOption(checkerClass);
allOptions.addOption(coordServer);
allOptions.addOption(coordPort);
allOptions.addOption(refreshAccessCli);
allOptions.addOption(help);
}

Expand Down Expand Up @@ -98,7 +99,7 @@ public int run(String[] args) throws UniffleCliArgsException {
client = UniffleRestClient.builder(hostUrl).build();
}

if (cmd.hasOption(refreshAccessCli.getOpt())) {
if (cmd.hasOption(refreshCheckerCli.getOpt())) {
String checker = cmd.getOptionValue(checkerClass.getOpt());
LOG.info("uniffle-admin-cli : refresh access checker {}!", checker);
refreshAccessChecker(checker);
Expand All @@ -120,7 +121,7 @@ private String refreshAccessChecker(String checker) throws UniffleCliArgsExcepti
public void addRunOptions(Options baseOptions) {
baseOptions.addOption(uniffleClientCli);
baseOptions.addOption(uniffleAdminCli);
baseOptions.addOption(refreshAccessCli);
baseOptions.addOption(refreshCheckerCli);
baseOptions.addOption(checkerClass);
baseOptions.addOption(coordServer);
baseOptions.addOption(coordPort);
Expand Down
14 changes: 11 additions & 3 deletions cli/src/test/java/org/apache/uniffle/cli/UniffleTestCLI.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,19 @@ public void testHelp() throws UniffleCliArgsException, IOException {
assertEquals(0, uniffleCLI.run(args1));
oldOutPrintStream.println(dataOut);
assertTrue(dataOut.toString().contains(
"-a,--admin <arg> This is an admin command that will print args."));
"-a,--admin <arg> This is an admin command that will print args."));
assertTrue(dataOut.toString().contains(
"-c,--cli <arg> This is an client cli command that will print args."));
"-c,--cli <arg> This is an client cli command that will print args."));
assertTrue(dataOut.toString().contains(
"-h,--help Help for the Uniffle CLI."));
"-h,--help Help for the Uniffle CLI."));
assertTrue(dataOut.toString().contains(
"-cc,--checkerClass <arg> This is the checker class that will be refreshed."));
assertTrue(dataOut.toString().contains(
"-rc,--refreshChecker This is an admin command that will refresh access checker."));
assertTrue(dataOut.toString().contains(
"-s,--host <arg> This is coordinator server host."));
assertTrue(dataOut.toString().contains(
"-p,--port <arg> This is coordinator server port."));

System.setOut(oldOutPrintStream);
System.setErr(oldErrPrintStream);
Expand Down

0 comments on commit d201d97

Please sign in to comment.