Search in sources :

Example 1 with ActionInfoComparator

use of org.smartdata.common.actions.ActionInfoComparator in project SSM by Intel-bigdata.

the class CommandExecutor method listNewCreatedActions.

public List<ActionInfo> listNewCreatedActions(int maxNumActions) throws IOException {
    ArrayList<ActionInfo> actionInfos = new ArrayList<>();
    boolean flag = true;
    for (Command cmd : commandPool.getcommands()) {
        long cmdId = cmd.getId();
        for (SmartAction smartAction : cmd.getActions()) {
            ActionStatus status = smartAction.getActionStatus();
            actionInfos.add(new ActionInfo(status.getId(), cmdId, smartAction.getName(), smartAction.getArguments(), status.getResultPrintStream().toString(), status.getLogPrintStream().toString(), status.isSuccessful(), status.getStartTime(), status.isSuccessful(), status.getRunningTime(), status.getPercentage()));
        }
    }
    // Sort and get top maxNumActions
    Collections.sort(actionInfos, new ActionInfoComparator());
    if (maxNumActions >= actionInfos.size()) {
        return actionInfos;
    } else {
        return actionInfos.subList(0, maxNumActions);
    }
}
Also used : ActionInfoComparator(org.smartdata.common.actions.ActionInfoComparator) ArrayList(java.util.ArrayList) SmartAction(org.smartdata.actions.SmartAction) ActionInfo(org.smartdata.common.actions.ActionInfo) ActionStatus(org.smartdata.actions.ActionStatus)

Aggregations

ArrayList (java.util.ArrayList)1 ActionStatus (org.smartdata.actions.ActionStatus)1 SmartAction (org.smartdata.actions.SmartAction)1 ActionInfo (org.smartdata.common.actions.ActionInfo)1 ActionInfoComparator (org.smartdata.common.actions.ActionInfoComparator)1