Search in sources :

Example 36 with CmdletInfo

use of org.smartdata.model.CmdletInfo in project SSM by Intel-bigdata.

the class MetaStore method getActions.

public List<ActionInfo> getActions(long rid, long start, long offset) throws MetaStoreException {
    long mark = 0;
    long count = 0;
    List<CmdletInfo> cmdletInfos = cmdletDao.getByRid(rid);
    List<ActionInfo> totalActions = new ArrayList<>();
    for (CmdletInfo cmdletInfo : cmdletInfos) {
        List<Long> aids = cmdletInfo.getAids();
        if (mark + aids.size() >= start + 1) {
            long gap;
            gap = start - mark;
            for (Long aid : aids) {
                if (gap > 0) {
                    gap--;
                    mark++;
                    continue;
                }
                if (count < offset) {
                    ActionInfo actionInfo = getActionById(aid);
                    totalActions.add(actionInfo);
                    count++;
                    mark++;
                } else {
                    return totalActions;
                }
            }
        } else {
            mark += aids.size();
        }
    }
    return totalActions;
}
Also used : ArrayList(java.util.ArrayList) ActionInfo(org.smartdata.model.ActionInfo) CmdletInfo(org.smartdata.model.CmdletInfo)

Example 37 with CmdletInfo

use of org.smartdata.model.CmdletInfo in project SSM by Intel-bigdata.

the class MetaStore method listMoveRules.

public List<DetailedRuleInfo> listMoveRules() throws MetaStoreException {
    List<RuleInfo> ruleInfos = getRuleInfo();
    List<DetailedRuleInfo> detailedRuleInfos = new ArrayList<>();
    for (RuleInfo ruleInfo : ruleInfos) {
        int lastIndex = ruleInfo.getRuleText().lastIndexOf("|");
        String lastPart = ruleInfo.getRuleText().substring(lastIndex + 1);
        if (lastPart.contains("sync")) {
            continue;
        } else if (lastPart.contains("allssd") || lastPart.contains("onessd") || lastPart.contains("archive") || lastPart.contains("alldisk") || lastPart.contains("onedisk") || lastPart.contains("ramdisk")) {
            DetailedRuleInfo detailedRuleInfo = new DetailedRuleInfo(ruleInfo);
            // Add mover progress
            List<CmdletInfo> cmdletInfos = cmdletDao.getByRid(ruleInfo.getId());
            int currPos = 0;
            for (CmdletInfo cmdletInfo : cmdletInfos) {
                if (cmdletInfo.getState().getValue() <= 4) {
                    break;
                }
                currPos += 1;
            }
            int countRunning = 0;
            for (CmdletInfo cmdletInfo : cmdletInfos) {
                if (cmdletInfo.getState().getValue() <= 4) {
                    countRunning++;
                }
            }
            detailedRuleInfo.setBaseProgress(cmdletInfos.size() - currPos);
            detailedRuleInfo.setRunningProgress(countRunning);
            if (detailedRuleInfo.getState() != RuleState.DELETED) {
                detailedRuleInfos.add(detailedRuleInfo);
            }
        }
    }
    return detailedRuleInfos;
}
Also used : DetailedRuleInfo(org.smartdata.model.DetailedRuleInfo) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) DetailedRuleInfo(org.smartdata.model.DetailedRuleInfo) RuleInfo(org.smartdata.model.RuleInfo) CmdletInfo(org.smartdata.model.CmdletInfo)

Aggregations

CmdletInfo (org.smartdata.model.CmdletInfo)37 Test (org.junit.Test)18 ActionInfo (org.smartdata.model.ActionInfo)16 ArrayList (java.util.ArrayList)11 IOException (java.io.IOException)6 AtomicLong (java.util.concurrent.atomic.AtomicLong)5 HashMap (java.util.HashMap)4 MetaStore (org.smartdata.metastore.MetaStore)3 CmdletDescriptor (org.smartdata.model.CmdletDescriptor)3 CmdletState (org.smartdata.model.CmdletState)3 RuleInfo (org.smartdata.model.RuleInfo)3 CmdletStatus (org.smartdata.protocol.message.CmdletStatus)3 ServiceException (com.google.protobuf.ServiceException)2 ParseException (java.text.ParseException)2 SmartAdmin (org.smartdata.admin.SmartAdmin)2 QueueFullException (org.smartdata.exception.QueueFullException)2 MetaStoreException (org.smartdata.metastore.MetaStoreException)2 FileInfo (org.smartdata.model.FileInfo)2 CmdletInfoProto (org.smartdata.protocol.AdminServerProto.CmdletInfoProto)2 ActionStatus (org.smartdata.protocol.message.ActionStatus)2