public static List<PrimaryStorageInventory> valueOf(Collection<PrimaryStorageVO> vos) { List<PrimaryStorageInventory> invs = new ArrayList<PrimaryStorageInventory>(vos.size()); for (PrimaryStorageVO vo : vos) { invs.add(PrimaryStorageInventory.valueOf(vo)); } return invs; }
void afterChange(PrimaryStorageVO vo, final PrimaryStorageStateEvent evt, final PrimaryStorageState preState) { final PrimaryStorageInventory inv = PrimaryStorageInventory.valueOf(vo); CollectionUtils.safeForEach(changeExts, new ForEachFunction<PrimaryStorageChangeStateExtensionPoint>() { @Override public void run(PrimaryStorageChangeStateExtensionPoint arg) { arg.afterChangePrimaryStorageState(inv, evt, preState); } }); }
@Override public List<PrimaryStorageInventory> allocateAllCandidates(PrimaryStorageAllocationSpec spec) { List<PrimaryStorageVO> candidates = allocateAll(spec); Collections.shuffle(candidates); return PrimaryStorageInventory.valueOf(candidates); }
void afterAttach(PrimaryStorageVO vo, final String clusterUuid) { final PrimaryStorageInventory inv = PrimaryStorageInventory.valueOf(vo); CollectionUtils.safeForEach(attachExts, new ForEachFunction<PrimaryStorageAttachExtensionPoint>() { @Override public void run(PrimaryStorageAttachExtensionPoint arg) { arg.afterAttachPrimaryStorage(inv, clusterUuid); } }); }
void failToDetach(PrimaryStorageVO vo, final String clusterUuid) { final PrimaryStorageInventory inv = PrimaryStorageInventory.valueOf(vo); CollectionUtils.safeForEach(detachExts, new ForEachFunction<PrimaryStorageDetachExtensionPoint>() { @Override public void run(PrimaryStorageDetachExtensionPoint arg) { arg.failToDetachPrimaryStorage(inv, clusterUuid); } }); }
void afterDetach(PrimaryStorageVO vo, final String clusterUuid) { final PrimaryStorageInventory inv = PrimaryStorageInventory.valueOf(vo); CollectionUtils.safeForEach(detachExts, new ForEachFunction<PrimaryStorageDetachExtensionPoint>() { @Override public void run(PrimaryStorageDetachExtensionPoint arg) { arg.afterDetachPrimaryStorage(inv, clusterUuid); } }); }
@Override public PrimaryStorageInventory getInventory(String uuid) { PrimaryStorageVO vo = dbf.findByUuid(uuid, PrimaryStorageVO.class); return PrimaryStorageInventory.valueOf(vo); }
void beforeAttach(PrimaryStorageVO vo, final String clusterUuid) { final PrimaryStorageInventory inv = PrimaryStorageInventory.valueOf(vo); CollectionUtils.safeForEach(attachExts, new ForEachFunction<PrimaryStorageAttachExtensionPoint>() { @Override public void run(PrimaryStorageAttachExtensionPoint arg) { arg.beforeAttachPrimaryStorage(inv, clusterUuid); } }); }
void failToAttach(PrimaryStorageVO vo, final String clusterUuid) { final PrimaryStorageInventory inv = PrimaryStorageInventory.valueOf(vo); CollectionUtils.safeForEach(attachExts, new ForEachFunction<PrimaryStorageAttachExtensionPoint>() { @Override public void run(PrimaryStorageAttachExtensionPoint arg) { arg.failToAttachPrimaryStorage(inv, clusterUuid); } }); }
@Override public PrimaryStorageInventory getInventory(String uuid) { PrimaryStorageVO vo = dbf.findByUuid(uuid, PrimaryStorageVO.class); return PrimaryStorageInventory.valueOf(vo); }
@Transactional(readOnly = true) private PrimaryStorageInventory findSMPByHostUuid(String clusterUuid) { List<PrimaryStorageVO> ret = SQL.New("select pri from PrimaryStorageVO pri, PrimaryStorageClusterRefVO ref" + " where pri.uuid = ref.primaryStorageUuid" + " and ref.clusterUuid = :cuuid" + " and pri.type = :ptype", PrimaryStorageVO.class) .param("cuuid", clusterUuid) .param("ptype", SMPConstants.SMP_TYPE) .limit(1) .list(); return ret.isEmpty() ? null : PrimaryStorageInventory.valueOf(ret.get(0)); }
void beforeChange(PrimaryStorageVO vo, final PrimaryStorageStateEvent evt) { final PrimaryStorageInventory inv = PrimaryStorageInventory.valueOf(vo); final PrimaryStorageState next = AbstractPrimaryStorage.getNextState(vo.getState(), evt); CollectionUtils.safeForEach(changeExts, new ForEachFunction<PrimaryStorageChangeStateExtensionPoint>() { @Override public void run(PrimaryStorageChangeStateExtensionPoint arg) { arg.beforeChangePrimaryStorageState(inv, evt, next); } }); }
@Override public PrimaryStorageInventory createPrimaryStorage(PrimaryStorageVO vo, APIAddPrimaryStorageMsg msg) { vo.setMountPath(msg.getUrl()); vo = dbf.persistAndRefresh(vo); return PrimaryStorageInventory.valueOf(vo); }
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 PrimaryStorageInventory createPrimaryStorage(PrimaryStorageVO vo, APIAddPrimaryStorageMsg msg) { vo.setMountPath(vo.getUrl()); vo.setType(SMPConstants.SMP_TYPE); vo = dbf.persistAndRefresh(vo); return PrimaryStorageInventory.valueOf(vo); }
private void handle(APIListPrimaryStorageMsg msg) { List<PrimaryStorageVO> vos = dl.listByApiMessage(msg, PrimaryStorageVO.class); List<PrimaryStorageInventory> invs = PrimaryStorageInventory.valueOf(vos); APIListPrimaryStorageReply reply = new APIListPrimaryStorageReply(); reply.setInventories(invs); bus.reply(msg, reply); }
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())); }); }
@Override public void detachHook(String clusterUuid, Completion completion) { NfsPrimaryStorageBackend backend = getBackendByClusterUuid(clusterUuid); try { backend.detachFromCluster(PrimaryStorageInventory.valueOf(self), clusterUuid); completion.success(); } catch (NfsPrimaryStorageException e) { completion.fail(operr(e.getMessage())); } }
@Override public void success() { self.setUrl(msg.getUrl()); self = dbf.updateAndRefresh(self); for (UpdatePrimaryStorageExtensionPoint ext : pluginRgty.getExtensionList(UpdatePrimaryStorageExtensionPoint.class)){ ext.afterUpdatePrimaryStorage(PrimaryStorageInventory.valueOf(self)); } completion.success(self); }
private void handle(PrimaryStorageDeletionMsg msg) { PrimaryStorageInventory inv = PrimaryStorageInventory.valueOf(self); extpEmitter.beforeDelete(inv); deleteHook(); extpEmitter.afterDelete(inv); tracker.untrack(self.getUuid()); PrimaryStorageDeletionReply reply = new PrimaryStorageDeletionReply(); bus.reply(msg, reply); }