Search in sources :

Example 21 with ActionInfo

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);
}
Also used : HashMap(java.util.HashMap) ActionInfo(org.smartdata.model.ActionInfo) CmdletInfo(org.smartdata.model.CmdletInfo) Test(org.junit.Test)

Example 22 with ActionInfo

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;
    }
}
Also used : ActionScheduler(org.smartdata.model.action.ActionScheduler) ActionInfo(org.smartdata.model.ActionInfo)

Example 23 with ActionInfo

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);
    }
}
Also used : LaunchCmdlet(org.smartdata.protocol.message.LaunchCmdlet) ActionInfo(org.smartdata.model.ActionInfo)

Example 24 with ActionInfo

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);
}
Also used : LaunchAction(org.smartdata.model.LaunchAction) ArrayList(java.util.ArrayList) AtomicLong(java.util.concurrent.atomic.AtomicLong) LaunchCmdlet(org.smartdata.protocol.message.LaunchCmdlet) ActionInfo(org.smartdata.model.ActionInfo)

Example 25 with ActionInfo

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);
}
Also used : ActionInfo(org.smartdata.model.ActionInfo)

Aggregations

ActionInfo (org.smartdata.model.ActionInfo)48 Test (org.junit.Test)23 HashMap (java.util.HashMap)16 CmdletInfo (org.smartdata.model.CmdletInfo)16 ArrayList (java.util.ArrayList)12 IOException (java.io.IOException)7 AtomicLong (java.util.concurrent.atomic.AtomicLong)5 SmartAdmin (org.smartdata.admin.SmartAdmin)5 MetaStore (org.smartdata.metastore.MetaStore)5 Path (org.apache.hadoop.fs.Path)4 DistributedFileSystem (org.apache.hadoop.hdfs.DistributedFileSystem)4 MetaStoreException (org.smartdata.metastore.MetaStoreException)4 FileInfo (org.smartdata.model.FileInfo)4 CmdletDescriptor (org.smartdata.model.CmdletDescriptor)3 ActionScheduler (org.smartdata.model.action.ActionScheduler)3 ServiceException (com.google.protobuf.ServiceException)2 ParseException (java.text.ParseException)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 QueueFullException (org.smartdata.exception.QueueFullException)2 DetailedFileAction (org.smartdata.model.DetailedFileAction)2