use of org.smartdata.model.LaunchAction in project SSM by Intel-bigdata.
the class CmdletManager method scheduleCmdletActions.
private ScheduleResult scheduleCmdletActions(CmdletInfo info, LaunchCmdlet launchCmdlet) {
List<Long> actIds = info.getAids();
int idx = 0;
int schIdx = 0;
ActionInfo actionInfo;
LaunchAction launchAction;
List<ActionScheduler> actSchedulers;
boolean skipped = false;
ScheduleResult scheduleResult = ScheduleResult.SUCCESS_NO_EXECUTION;
ScheduleResult resultTmp;
for (idx = 0; idx < actIds.size(); idx++) {
actionInfo = idToActions.get(actIds.get(idx));
launchAction = launchCmdlet.getLaunchActions().get(idx);
actSchedulers = schedulers.get(actionInfo.getActionName());
if (actSchedulers == null || actSchedulers.size() == 0) {
skipped = true;
continue;
}
for (schIdx = 0; schIdx < actSchedulers.size(); schIdx++) {
ActionScheduler s = actSchedulers.get(schIdx);
try {
resultTmp = s.onSchedule(info, actionInfo, launchCmdlet, launchAction, idx);
} catch (Throwable t) {
actionInfo.appendLogLine("\nOnSchedule exception: " + t);
resultTmp = ScheduleResult.FAIL;
}
if (resultTmp != ScheduleResult.SUCCESS && resultTmp != ScheduleResult.SUCCESS_NO_EXECUTION) {
scheduleResult = resultTmp;
} else {
if (scheduleResult == ScheduleResult.SUCCESS_NO_EXECUTION) {
scheduleResult = resultTmp;
}
}
if (scheduleResult != ScheduleResult.SUCCESS && scheduleResult != ScheduleResult.SUCCESS_NO_EXECUTION) {
break;
}
}
if (scheduleResult != ScheduleResult.SUCCESS && scheduleResult != ScheduleResult.SUCCESS_NO_EXECUTION) {
break;
}
}
if (scheduleResult == ScheduleResult.SUCCESS || scheduleResult == ScheduleResult.SUCCESS_NO_EXECUTION) {
idx--;
schIdx--;
if (skipped) {
scheduleResult = ScheduleResult.SUCCESS;
}
}
postscheduleCmdletActions(info, actIds, scheduleResult, idx, schIdx);
return scheduleResult;
}
use of org.smartdata.model.LaunchAction in project SSM by Intel-bigdata.
the class CmdletDispatcher method updateCmdActionStatus.
private void updateCmdActionStatus(LaunchCmdlet cmdlet, String host) {
if (cmdletManager != null) {
try {
cmdletManager.updateCmdletExecHost(cmdlet.getCmdletId(), host);
} catch (IOException e) {
// Ignore this
}
}
try {
LaunchAction action;
ActionStatus actionStatus;
for (int i = 0; i < cmdlet.getLaunchActions().size(); i++) {
action = cmdlet.getLaunchActions().get(i);
actionStatus = new ActionStatus(cmdlet.getCmdletId(), i == cmdlet.getLaunchActions().size() - 1, action.getActionId(), System.currentTimeMillis());
cmdletManager.onActionStatusUpdate(actionStatus);
}
CmdletStatus cmdletStatus = new CmdletStatus(cmdlet.getCmdletId(), System.currentTimeMillis(), CmdletState.DISPATCHED);
cmdletManager.onCmdletStatusUpdate(cmdletStatus);
} catch (IOException e) {
LOG.info("update status failed.", e);
} catch (ActionException e) {
LOG.info("update action status failed.", e);
}
}
use of org.smartdata.model.LaunchAction in project SSM by Intel-bigdata.
the class CmdletFactory method createCmdlet.
public Cmdlet createCmdlet(LaunchCmdlet launchCmdlet) throws ActionException {
List<SmartAction> actions = new ArrayList<>();
int idx = 0;
for (LaunchAction action : launchCmdlet.getLaunchActions()) {
idx++;
actions.add(createAction(launchCmdlet.getCmdletId(), idx == launchCmdlet.getLaunchActions().size(), action));
}
Cmdlet cmdlet = new Cmdlet(actions);
cmdlet.setId(launchCmdlet.getCmdletId());
return cmdlet;
}
use of org.smartdata.model.LaunchAction in project SSM by Intel-bigdata.
the class CmdletManager method createLaunchCmdlet.
private LaunchCmdlet createLaunchCmdlet(CmdletInfo cmdletInfo) {
if (cmdletInfo == null) {
return null;
}
Map<String, String> args;
List<LaunchAction> launchActions = new ArrayList<>();
for (Long aid : cmdletInfo.getAids()) {
if (idToActions.containsKey(aid)) {
ActionInfo toLaunch = idToActions.get(aid);
args = new HashMap<>();
args.putAll(toLaunch.getArgs());
launchActions.add(new LaunchAction(toLaunch.getActionId(), toLaunch.getActionName(), args));
}
}
return new LaunchCmdlet(cmdletInfo.getCid(), launchActions);
}
use of org.smartdata.model.LaunchAction in project SSM by Intel-bigdata.
the class TestCmdletFactory method testCreateAction.
@Test
public void testCreateAction() throws ActionException {
SmartContext smartContext = mock(SmartContext.class);
SmartConf conf = new SmartConf();
conf.set(DFS_NAMENODE_HTTP_ADDRESS_KEY, "http://0.0.0.0:8088");
conf.set(SmartConfKeys.SMART_DFS_NAMENODE_RPCSERVER_KEY, "hdfs://0.0.0.0:8089");
when(smartContext.getConf()).thenReturn(conf);
CmdletFactory cmdletFactory = new CmdletFactory(smartContext);
LaunchAction launchAction1 = new LaunchAction(10, "allssd", new HashMap<String, String>());
// SmartAction action = cmdletFactory.createAction(launchAction1);
// Assert.assertNotNull(action);
// Assert.assertEquals(10, action.getActionId());
//
// LaunchAction launchAction = new LaunchAction(10, "test", new HashMap<String, String>());
// expectedException.expect(ActionException.class);
// Assert.assertNull(cmdletFactory.createAction(launchAction));
}
Aggregations