Search in sources :

Example 1 with QueueFullException

use of org.smartdata.exception.QueueFullException in project SSM by Intel-bigdata.

the class RuleExecutor method submitCmdlets.

private int submitCmdlets(RuleInfo ruleInfo, List<String> files) {
    long ruleId = ruleInfo.getId();
    if (files == null || files.size() == 0 || ruleManager.getCmdletManager() == null) {
        return 0;
    }
    int nSubmitted = 0;
    List<RuleExecutorPlugin> plugins = RuleExecutorPluginManager.getPlugins();
    String template = tr.getCmdDescriptor().toCmdletString();
    for (String file : files) {
        if (!exited) {
            try {
                CmdletDescriptor cmd = new CmdletDescriptor(template, ruleId);
                cmd.setCmdletParameter(CmdletDescriptor.HDFS_FILE_PATH, file);
                for (RuleExecutorPlugin plugin : plugins) {
                    cmd = plugin.preSubmitCmdletDescriptor(ruleInfo, tr, cmd);
                }
                long cid = ruleManager.getCmdletManager().submitCmdlet(cmd);
                // Not really submitted if cid is -1.
                if (cid != -1) {
                    nSubmitted++;
                }
            } catch (QueueFullException e) {
                break;
            } catch (IOException e) {
                // it's common here, ignore this and continue submit
                LOG.debug("Failed to submit cmdlet for file: " + file, e);
            } catch (ParseException e) {
                LOG.error("Failed to submit cmdlet for file: " + file, e);
            }
        } else {
            break;
        }
    }
    return nSubmitted;
}
Also used : CmdletDescriptor(org.smartdata.model.CmdletDescriptor) QueueFullException(org.smartdata.exception.QueueFullException) RuleExecutorPlugin(org.smartdata.model.rule.RuleExecutorPlugin) IOException(java.io.IOException) ParseException(java.text.ParseException)

Example 2 with QueueFullException

use of org.smartdata.exception.QueueFullException 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();
}
Also used : QueueFullException(org.smartdata.exception.QueueFullException) ActionInfo(org.smartdata.model.ActionInfo) IOException(java.io.IOException) CmdletInfo(org.smartdata.model.CmdletInfo)

Aggregations

IOException (java.io.IOException)2 QueueFullException (org.smartdata.exception.QueueFullException)2 ParseException (java.text.ParseException)1 ActionInfo (org.smartdata.model.ActionInfo)1 CmdletDescriptor (org.smartdata.model.CmdletDescriptor)1 CmdletInfo (org.smartdata.model.CmdletInfo)1 RuleExecutorPlugin (org.smartdata.model.rule.RuleExecutorPlugin)1