public void restore(boolean writeMode, Long manifestIdDefault) { List<CmsCIRelation> watchedBys; long counter = 0; long restoredMonitors = 0; if (manifestIdDefault == null) { watchedBys = cmProcessor.getCIRelationsNsLikeNakedNoAttrs("/", "manifest.WatchedBy", null, null, null); } else { watchedBys = cmManager.getFromCIRelations(manifestIdDefault, "manifest.WatchedBy", null); } long startTime = System.currentTimeMillis(); Map<Long, List<CmsCIRelation>> monitors = watchedBys.stream().collect(Collectors.groupingBy(CmsCIRelation::getFromCiId)); for (Long manifestId : monitors.keySet()) { counter++; List<CmsCIRelation> realizedAsRels = cmManager.getFromCIRelations(manifestId, "base.RealizedAs", null); if (realizedAsRels.isEmpty()) continue; Set<Long> cmsBomCiIds = realizedAsRels.stream().map(CmsCIRelation::getToCiId).collect(Collectors.toSet()); restoreRealizedAsMapping(manifestId, cmsBomCiIds, writeMode); boolean isFirstBom = true; for (CmsCIRelation relation : realizedAsRels) { restoreManifestMapping(manifestId, relation.getToCiId(), writeMode); if (isFirstBom) { for (CmsCIRelation rel : monitors.get(manifestId)) { if (rel.getToCi() == null) { rel.setToCi(cmProcessor.getCiById(rel.getToCiId())); } if (restoreMonitor(manifestId, relation.getToCiId(), rel.getToCi(), writeMode)) { restoredMonitors++; } } } isFirstBom = false; } if (counter % 100 == 0) { logger.info( "Time to process " + counter + " - " + (System.currentTimeMillis() - startTime) + " ms!"); } } logger.info(">>>>>>>>>>> Monitor restored " + restoredMonitors + ";"); logger.info( ">>>>>>>>>>> Monitor restoration is done!!!" + counter + " - " + (System.currentTimeMillis() - startTime) + " ms!"); }
public DesignCIManifestRfcTouple call() { String oldThreadName = Thread.currentThread().getName(); try { Thread.currentThread().setName(getProcessingThreadName(oldThreadName, env.getCiId())); ManifestRfcContainer manifestPlatformRfcs = manifestRfcProcessor.processPlatform( platRelation.getToCi(), env, nsPath, userId, availMode); DesignCIManifestRfcTouple touple = new DesignCIManifestRfcTouple(platRelation.getToCi().getCiId(), manifestPlatformRfcs); return touple; } finally { countDownLatch.countDown(); Thread.currentThread().setName(oldThreadName); } }
private long checkPlatformPackCompliance( List<CmsCIRelation> designPlatRels, CmsCI env, String nsPath, String userId) { List<CmsCIRelation> manifestPlatRels = cmProcessor.getFromCIRelations( env.getCiId(), MANIFEST_COMPOSED_OF, null, MANIFEST_PLATFORM); Map<String, String> manifestPlatPacks = new HashMap<String, String>(manifestPlatRels.size()); for (CmsCIRelation manifestRel : manifestPlatRels) { CmsCI plat = manifestRel.getToCi(); String key = plat.getCiName() + ":" + plat.getAttribute("major_version").getDjValue(); String value = plat.getAttribute("source").getDjValue() + ":" + plat.getAttribute("pack").getDjValue() + ":" + plat.getAttribute("version").getDjValue(); manifestPlatPacks.put(key, value); } long newReleaseId = 0; for (CmsCIRelation designRel : designPlatRels) { CmsCI dPlat = designRel.getToCi(); String key = dPlat.getCiName() + ":" + dPlat.getAttribute("major_version").getDjValue(); String value = dPlat.getAttribute("source").getDjValue() + ":" + dPlat.getAttribute("pack").getDjValue() + ":" + dPlat.getAttribute("version").getDjValue(); if (manifestPlatPacks.containsKey(key) && !value.equals(manifestPlatPacks.get(key))) { String platNsPath = nsPath + "/" + dPlat.getCiName() + "/" + dPlat.getAttribute("major_version").getDfValue(); List<CmsRfcCI> mPlats = cmRfcMrgProcessor.getDfDjCi(platNsPath, MANIFEST_PLATFORM, dPlat.getCiName(), "dj"); if (mPlats.size() > 0) { newReleaseId = manifestRfcProcessor.deleteManifestPlatform(mPlats.get(0), userId); } } } return newReleaseId; }