private List<String> getExtensionBSUuids(String psUuid) { List<String> psUuids = new ArrayList<>(); List<BackupStoragePrimaryStorageExtensionPoint> extenstions = pluginRgty.getExtensionList(BackupStoragePrimaryStorageExtensionPoint.class); extenstions.forEach(ext -> { List<String> tmp = ext.getBackupStorageSupportedPS(psUuid); if (tmp != null) { psUuids.addAll(tmp); } }); return psUuids; }
private void cleanUpImageCache(String psUuid) { PrimaryStorageVO ps = dbf.findByUuid(psUuid, PrimaryStorageVO.class); logger.info(String.format("cleanup image cache on PrimaryStorage [%s]", ps.getUuid())); List<BackupStoragePrimaryStorageExtensionPoint> extenstions = pluginRgty.getExtensionList(BackupStoragePrimaryStorageExtensionPoint.class); extenstions.forEach(ext -> { ext.cleanupPrimaryCacheForBS(PrimaryStorageInventory.valueOf(ps), null, new NopeCompletion()); }); }
@Override public void sort() { DebugUtils.Assert(candidates != null && !candidates.isEmpty(), "HostInventory cannot be none"); if (spec.getImage() == null || dbf.findByUuid(spec.getImage().getUuid(), ImageVO.class) == null) { prepareForNext(candidates); return; } List<String> bsUuids = Q.New(ImageBackupStorageRefVO.class).eq(ImageBackupStorageRefVO_.imageUuid, spec.getImage().getUuid()). select(ImageBackupStorageRefVO_.backupStorageUuid).listValues(); DebugUtils.Assert(bsUuids.size() > 0, String.format("imageUuid [%s] not in any BackupStorage", spec.getImage().getUuid())); //TODO: we suppose imageUuid is only in 1 bs, if it could be in 2 or more bss, then we should improve the bellow code BackupStorageInventory bs = BackupStorageInventory.valueOf(dbf.findByUuid(bsUuids.get(0), BackupStorageVO.class)); List<PriorityMap> priMap = new ArrayList<>(); for (BackupStoragePrimaryStorageExtensionPoint ext : pluginRgty.getExtensionList(BackupStoragePrimaryStorageExtensionPoint.class)) { priMap.addAll(formatPriority(ext.getPrimaryStoragePriorityMap(bs, spec.getImage()))); } priMap = priMap.stream() .sorted(Comparator.comparingInt(it -> it.priority)) .filter(distinctByKey(it -> it.PS)) .collect(Collectors.toList()); adjustCandidates(priMap); }
private void cleanUpImageCache(String psUuid) { PrimaryStorageVO ps = dbf.findByUuid(psUuid, PrimaryStorageVO.class); logger.info(String.format("cleanup image cache on PrimaryStorage [%s]", ps.getUuid())); List<String> hostUuids = SQL.New("select h.uuid from LocalStorageHostRefVO ref, HostVO h " + "where ref.hostUuid = h.uuid and ref.primaryStorageUuid = :ps and h.status = :status"). param("ps", psUuid).param("status", HostStatus.Connected).list(); List<BackupStoragePrimaryStorageExtensionPoint> extenstions = pluginRgty.getExtensionList(BackupStoragePrimaryStorageExtensionPoint.class); extenstions.forEach(ext -> { hostUuids.forEach(hostUuid -> ext.cleanupPrimaryCacheForBS(PrimaryStorageInventory.valueOf(ps), hostUuid, new NopeCompletion())); }); }