MCPcopy
hub / github.com/Alluxio/alluxio / ListCommand

Class ListCommand

shell/src/main/java/alluxio/cli/job/command/ListCommand.java:34–86  ·  view source on GitHub ↗

Lists the job ids in the history.

Source from the content-addressed store, hash-verified

32 * Lists the job ids in the history.
33 */
34@ThreadSafe
35@PublicApi
36public final class ListCommand extends AbstractFileSystemCommand {
37 private static final Logger LOG = LoggerFactory.getLogger(ListCommand.class);
38
39 /**
40 * Creates the job list command.
41 *
42 * @param fsContext the Alluxio filesystem client
43 */
44 public ListCommand(FileSystemContext fsContext) {
45 super(fsContext);
46 }
47
48 @Override
49 public String getCommandName() {
50 return "ls";
51 }
52
53 @Override
54 public void validateArgs(CommandLine cl) throws InvalidArgumentException {
55 CommandUtils.checkNumOfArgsEquals(this, cl, 0);
56 }
57
58 @Override
59 public int run(CommandLine cl) {
60 try (CloseableResource<JobMasterClient> client = JobContext
61 .create(mFsContext.getClusterConf(), mFsContext.getClientContext().getUserState())
62 .acquireMasterClientResource()) {
63 List<JobInfo> jobInfos = client.get().listDetailed();
64 for (JobInfo jobInfo : jobInfos) {
65 System.out.println(String.format("%-15s %-10s %-10s", jobInfo.getId(), jobInfo.getName(),
66 jobInfo.getStatus()));
67 }
68 } catch (Exception e) {
69 LOG.error("Failed to list the jobs ", e);
70 System.out.println("Failed to list the jobs");
71 return -1;
72 }
73 return 0;
74 }
75
76 @Override
77 public String getUsage() {
78 return "ls";
79 }
80
81 @Override
82 public String getDescription() {
83 return "Prints the IDs of the most recent jobs, running and finished,"
84 + " in the history up to the capacity set in alluxio.job.master.job.capacity";
85 }
86}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected