Search in sources :

Example 1 with DetailedRuleInfo

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

the class MetaStore method listSyncRules.

public List<DetailedRuleInfo> listSyncRules() throws MetaStoreException {
    List<RuleInfo> ruleInfos = getRuleInfo();
    List<DetailedRuleInfo> detailedRuleInfos = new ArrayList<>();
    for (RuleInfo ruleInfo : ruleInfos) {
        if (ruleInfo.getState() == RuleState.DELETED) {
            continue;
        }
        int lastIndex = ruleInfo.getRuleText().lastIndexOf("|");
        String lastPart = ruleInfo.getRuleText().substring(lastIndex + 1);
        if (lastPart.contains("sync")) {
            DetailedRuleInfo detailedRuleInfo = new DetailedRuleInfo(ruleInfo);
            // Add sync progress
            BackUpInfo backUpInfo = getBackUpInfo(ruleInfo.getId());
            // Get total matched files
            if (backUpInfo != null) {
                detailedRuleInfo.setBaseProgress(getFilesByPrefix(backUpInfo.getSrc()).size());
                long count = fileDiffDao.getPendingDiff(backUpInfo.getSrc()).size();
                count += fileDiffDao.getByState(backUpInfo.getSrc(), FileDiffState.RUNNING).size();
                if (count > detailedRuleInfo.baseProgress) {
                    count = detailedRuleInfo.baseProgress;
                }
                detailedRuleInfo.setRunningProgress(count);
            } else {
                detailedRuleInfo.setBaseProgress(0);
                detailedRuleInfo.setRunningProgress(0);
            }
            if (detailedRuleInfo.getState() != RuleState.DELETED) {
                detailedRuleInfos.add(detailedRuleInfo);
            }
        }
    }
    return detailedRuleInfos;
}
Also used : DetailedRuleInfo(org.smartdata.model.DetailedRuleInfo) BackUpInfo(org.smartdata.model.BackUpInfo) ArrayList(java.util.ArrayList) DetailedRuleInfo(org.smartdata.model.DetailedRuleInfo) RuleInfo(org.smartdata.model.RuleInfo)

Example 2 with DetailedRuleInfo

use of org.smartdata.model.DetailedRuleInfo 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

ArrayList (java.util.ArrayList)2 DetailedRuleInfo (org.smartdata.model.DetailedRuleInfo)2 RuleInfo (org.smartdata.model.RuleInfo)2 List (java.util.List)1 BackUpInfo (org.smartdata.model.BackUpInfo)1 CmdletInfo (org.smartdata.model.CmdletInfo)1