use of org.smartdata.actions.SmartAction in project SSM by Intel-bigdata.
the class Command method runActions.
public void runActions() {
for (SmartAction act : actions) {
currentActionIndex++;
if (act == null || !running) {
continue;
}
act.run();
// Run actions sequentially!
while (!act.getActionStatus().isFinished()) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
if (!running) {
break;
}
}
}
}
}
use of org.smartdata.actions.SmartAction in project SSM by Intel-bigdata.
the class CommandExecutor method getActionInfo.
public ActionInfo getActionInfo(long actionID) {
SmartAction smartAction = actionPool.get(actionID);
ActionStatus status = smartAction.getActionStatus();
return new ActionInfo(status.getId(), 0, smartAction.getName(), smartAction.getArguments(), status.getResultPrintStream().toString(), status.getLogPrintStream().toString(), status.isSuccessful(), status.getStartTime(), status.isSuccessful(), status.getRunningTime(), status.getPercentage());
}
use of org.smartdata.actions.SmartAction 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);
}
}
use of org.smartdata.actions.SmartAction in project SSM by Intel-bigdata.
the class CommandExecutor method createActionsFromParameters.
@VisibleForTesting
SmartAction[] createActionsFromParameters(CommandDescriptor commandDescriptor) throws IOException {
if (commandDescriptor == null) {
return null;
}
// commandDescriptor.();
List<SmartAction> actions = new ArrayList<>();
SmartAction current;
for (int index = 0; index < commandDescriptor.size(); index++) {
current = createAction(commandDescriptor.getActionName(index));
actionPool.put(current.getActionStatus().getId(), current);
if (current == null) {
LOG.error("New Action Instance from {} error!", commandDescriptor.getActionName(index));
}
current.setContext(smartContext);
current.init(commandDescriptor.getActionArgs(index));
actions.add(current);
}
return actions.toArray(new SmartAction[commandDescriptor.size()]);
}
use of org.smartdata.actions.SmartAction in project SSM by Intel-bigdata.
the class CommandExecutor method createAction.
private SmartAction createAction(String name) throws IOException {
SmartAction smartAction = actionRegistry.createAction(name);
smartAction.setContext(smartContext);
if (smartAction instanceof HdfsAction) {
((HdfsAction) smartAction).setDfsClient(new SmartDFSClient(ssm.getNamenodeURI(), smartContext.getConf(), getRpcServerAddress()));
}
smartAction.getActionStatus().setId(currentActionId);
currentActionId++;
return smartAction;
}
Aggregations