use of org.smartdata.model.ActionInfo in project SSM by Intel-bigdata.
the class TestMetaStore method testdeleteKeepNewCmdlets.
@Test
public void testdeleteKeepNewCmdlets() throws Exception {
Map<String, String> args = new HashMap();
CmdletInfo command1 = new CmdletInfo(0, 78, CmdletState.CANCELLED, "test", 123L, 232444444L);
metaStore.insertCmdlet(command1);
CmdletInfo command2 = new CmdletInfo(1, 78, CmdletState.DONE, "tt", 128L, 232444994L);
metaStore.insertCmdlet(command2);
ActionInfo actionInfo = new ActionInfo(1, 0, "cache", args, "Test", "Test", true, 123213213L, true, 123123L, 100);
metaStore.insertAction(actionInfo);
ActionInfo actionInfo2 = new ActionInfo(2, 1, "cache", args, "Test", "Test", true, 123213213L, true, 123123L, 100);
metaStore.insertAction(actionInfo2);
ActionInfo actionInfo3 = new ActionInfo(3, 0, "cache", args, "Test", "Test", true, 123213213L, true, 123123L, 100);
metaStore.insertAction(actionInfo3);
metaStore.deleteKeepNewCmdlets(1);
Assert.assertTrue(metaStore.getCmdletById(0) == null);
Assert.assertTrue(metaStore.getActionById(1) == null);
Assert.assertTrue(metaStore.getActionById(2) != null);
}
use of org.smartdata.model.ActionInfo in project SSM by Intel-bigdata.
the class CmdletManager method postscheduleCmdletActions.
private void postscheduleCmdletActions(CmdletInfo cmdletInfo, List<Long> actions, ScheduleResult result, int lastAction, int lastScheduler) {
List<ActionScheduler> actSchedulers;
for (int aidx = lastAction; aidx >= 0; aidx--) {
ActionInfo info = idToActions.get(actions.get(aidx));
actSchedulers = schedulers.get(info.getActionName());
if (actSchedulers == null || actSchedulers.size() == 0) {
continue;
}
if (lastScheduler < 0) {
lastScheduler = actSchedulers.size() - 1;
}
for (int sidx = lastScheduler; sidx >= 0; sidx--) {
try {
actSchedulers.get(sidx).postSchedule(cmdletInfo, info, sidx, result);
} catch (Throwable t) {
info.setLog((info.getLog() == null ? "" : info.getLog()) + "\nPostSchedule exception: " + t);
}
}
lastScheduler = -1;
}
}
use of org.smartdata.model.ActionInfo in project SSM by Intel-bigdata.
the class CmdletManager method syncCmdAction.
/**
* Insert cmdletinfo and actions to metastore and cache.
*
* @param cmdletInfo
* @param actionInfos
* @throws IOException
*/
private void syncCmdAction(CmdletInfo cmdletInfo, List<ActionInfo> actionInfos) throws IOException {
LOG.debug("Cache cmd {}", cmdletInfo);
for (ActionInfo actionInfo : actionInfos) {
idToActions.put(actionInfo.getActionId(), actionInfo);
}
idToCmdlets.put(cmdletInfo.getCid(), cmdletInfo);
if (cmdletInfo.getState() == CmdletState.PENDING) {
numCmdletsGen.incrementAndGet();
cacheCmd.put(cmdletInfo.getCid(), cmdletInfo);
synchronized (pendingCmdlet) {
pendingCmdlet.add(cmdletInfo.getCid());
}
} else if (cmdletInfo.getState() == CmdletState.DISPATCHED) {
runningCmdlets.add(cmdletInfo.getCid());
LaunchCmdlet launchCmdlet = createLaunchCmdlet(cmdletInfo);
idToLaunchCmdlet.put(cmdletInfo.getCid(), launchCmdlet);
}
}
use of org.smartdata.model.ActionInfo 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.ActionInfo in project SSM by Intel-bigdata.
the class CmdletManager method onStatusUpdate.
private void onStatusUpdate(ActionStatus actionStatus) throws IOException, ActionException {
onActionStatusUpdate(actionStatus);
ActionInfo actionInfo = idToActions.get(actionStatus.getActionId());
inferCmdletStatus(actionInfo);
}
Aggregations