use of org.smartdata.model.ActionInfo in project SSM by Intel-bigdata.
the class CmdletManager method submitCmdlet.
public long submitCmdlet(CmdletDescriptor cmdletDescriptor) throws IOException {
// with the same rule id and cmdlet string, return -1.
if (tracker.contains(cmdletDescriptor)) {
LOG.debug("Refuse to repeatedly submit Cmdlet for {}", cmdletDescriptor);
return -1;
}
if (LOG.isDebugEnabled()) {
LOG.debug(String.format("Received Cmdlet -> [ %s ]", cmdletDescriptor.getCmdletString()));
}
if (maxNumPendingCmdlets <= pendingCmdlet.size() + schedulingCmdlet.size()) {
throw new QueueFullException("Pending cmdlets exceeds value specified by key '" + SmartConfKeys.SMART_CMDLET_MAX_NUM_PENDING_KEY + "' = " + maxNumPendingCmdlets);
}
long submitTime = System.currentTimeMillis();
CmdletInfo cmdletInfo = new CmdletInfo(maxCmdletId.getAndIncrement(), cmdletDescriptor.getRuleId(), CmdletState.PENDING, cmdletDescriptor.getCmdletString(), submitTime, submitTime, submitTime + cmdletDescriptor.getDeferIntervalMs());
List<ActionInfo> actionInfos = createActionInfos(cmdletDescriptor, cmdletInfo.getCid());
// Check action names
checkActionNames(cmdletDescriptor);
// Check if action path is in whitelist
if (WhitelistHelper.isEnabled(getContext().getConf())) {
if (!WhitelistHelper.isCmdletInWhitelist(cmdletDescriptor)) {
throw new IOException("This path is not in the whitelist.");
}
}
// Let Scheduler check actioninfo onsubmit and add them to cmdletinfo
checkActionsOnSubmit(cmdletInfo, actionInfos);
// Insert cmdletinfo and actionInfos to metastore and cache.
syncCmdAction(cmdletInfo, actionInfos);
// Track in the submission portal. For cmdlets recovered from DB
// (see #recover), they will be not be tracked.
tracker.track(cmdletInfo.getCid(), cmdletDescriptor);
return cmdletInfo.getCid();
}
use of org.smartdata.model.ActionInfo in project SSM by Intel-bigdata.
the class CmdletManager method listActions.
public ActionGroup listActions(long pageIndex, long numPerPage, List<String> orderBy, List<Boolean> isDesc) throws IOException, MetaStoreException {
if (pageIndex == Long.parseLong("0")) {
if (tmpActions.totalNumOfActions != 0) {
return tmpActions;
} else {
pageIndex = 1;
}
}
List<ActionInfo> infos = metaStore.listPageAction((pageIndex - 1) * numPerPage, numPerPage, orderBy, isDesc);
for (ActionInfo info : infos) {
ActionInfo memInfo = idToActions.get(info.getActionId());
if (memInfo != null) {
info.setCreateTime(memInfo.getCreateTime());
info.setProgress(memInfo.getProgress());
}
}
tmpActions = new ActionGroup(infos, metaStore.getCountOfAllAction());
return tmpActions;
}
use of org.smartdata.model.ActionInfo in project SSM by Intel-bigdata.
the class CmdletManager method cmdletFinishedInternal.
private void cmdletFinishedInternal(CmdletInfo cmdletInfo, boolean success) throws IOException {
numCmdletsFinished.incrementAndGet();
ActionInfo actionInfo;
for (Long aid : cmdletInfo.getAids()) {
actionInfo = idToActions.get(aid);
synchronized (actionInfo) {
// Set all action as finished
actionInfo.setProgress(1.0F);
actionInfo.setFinished(true);
actionInfo.setCreateTime(cmdletInfo.getStateChangedTime());
actionInfo.setFinishTime(cmdletInfo.getStateChangedTime());
actionInfo.setExecHost(ActiveServerInfo.getInstance().getId());
actionInfo.setSuccessful(success);
}
}
}
use of org.smartdata.model.ActionInfo in project SSM by Intel-bigdata.
the class CmdletManager method updateCmdletExecHost.
public void updateCmdletExecHost(long cmdletId, String host) throws IOException {
CmdletInfo cmdlet = getCmdletInfo(cmdletId);
if (cmdlet == null) {
return;
}
ActionInfo action;
for (long id : cmdlet.getAids()) {
action = getActionInfo(id);
if (action != null) {
action.setExecHost(host);
}
}
}
use of org.smartdata.model.ActionInfo in project SSM by Intel-bigdata.
the class AdminProtocolClientSideTranslator method listActionInfoOfLastActions.
@Override
public List<ActionInfo> listActionInfoOfLastActions(int maxNumActions) throws IOException {
ListActionInfoOfLastActionsRequestProto req = ListActionInfoOfLastActionsRequestProto.newBuilder().setMaxNumActions(maxNumActions).build();
try {
List<ActionInfoProto> protoslist = rpcProxy.listActionInfoOfLastActions(null, req).getActionInfoListList();
if (protoslist == null) {
return new ArrayList<>();
}
List<ActionInfo> list = new ArrayList<>();
for (ActionInfoProto infoProto : protoslist) {
list.add(ProtoBufferHelper.convert(infoProto));
}
return list;
} catch (ServiceException e) {
throw ProtoBufferHelper.getRemoteException(e);
}
}
Aggregations