use of org.smartdata.model.CmdletInfo in project SSM by Intel-bigdata.
the class CmdletManager method dropRuleCmdlets.
/**
* Drop all unfinished cmdlets.
*
* @param ruleId
* @throws IOException
*/
public void dropRuleCmdlets(long ruleId) throws IOException {
List<Long> cids = new ArrayList<>();
for (CmdletInfo info : idToCmdlets.values()) {
if (info.getRid() == ruleId && !CmdletState.isTerminalState(info.getState())) {
cids.add(info.getCid());
}
}
batchDeleteCmdlet(cids);
}
use of org.smartdata.model.CmdletInfo 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.CmdletInfo 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.CmdletInfo in project SSM by Intel-bigdata.
the class ServerProtocolsServerSideTranslator method listCmdletInfo.
@Override
public ListCmdletInfoResponseProto listCmdletInfo(RpcController controller, ListCmdletInfoRequestProto req) throws ServiceException {
try {
List<CmdletInfo> list = server.listCmdletInfo(req.getRuleID(), CmdletState.fromValue(req.getCmdletState()));
if (list == null) {
return ListCmdletInfoResponseProto.newBuilder().build();
}
List<CmdletInfoProto> protoList = new ArrayList<>();
for (CmdletInfo info : list) {
protoList.add(ProtoBufferHelper.convert(info));
}
return ListCmdletInfoResponseProto.newBuilder().addAllCmdletInfos(protoList).build();
} catch (IOException e) {
throw new ServiceException(e);
}
}
use of org.smartdata.model.CmdletInfo in project SSM by Intel-bigdata.
the class TestActionRpc method testActionProgress.
@Test
public void testActionProgress() throws Exception {
waitTillSSMExitSafeMode();
SmartAdmin admin = new SmartAdmin(smartContext.getConf());
long cmdId = admin.submitCmdlet("sleep -ms 6000");
try {
CmdletInfo cinfo = admin.getCmdletInfo(cmdId);
long actId = cinfo.getAids().get(0);
ActionInfo actionInfo;
while (true) {
actionInfo = admin.getActionInfo(actId);
if (actionInfo.isFinished()) {
Assert.fail("No intermediate progress observed.");
}
if (actionInfo.getProgress() > 0 && actionInfo.getProgress() < 1.0) {
return;
}
Thread.sleep(500);
}
} finally {
admin.close();
}
}
Aggregations