@Override protected void syncPhysicalCapacity(ReturnValueCompletion<PhysicalCapacityUsage> completion) { PhysicalCapacityUsage usage = new PhysicalCapacityUsage(); usage.availablePhysicalSize = self.getCapacity().getAvailablePhysicalCapacity(); usage.totalPhysicalSize = self.getCapacity().getTotalPhysicalCapacity(); completion.success(usage); }
if (vo.getCapacity().getAvailableCapacity() >= requiredSize) { res.add(vo);
@Override public void run(FlowTrigger trigger, Map data) { PrimaryStorageAllocationSpec spec = (PrimaryStorageAllocationSpec) data.get(AllocatorParams.SPEC); List<PrimaryStorageVO> candidates = (List<PrimaryStorageVO>) data.get(AllocatorParams.CANDIDATES); DebugUtils.Assert(candidates != null && !candidates.isEmpty(), "PrimaryStorageReservedCapacityAllocatorFlow cannot be the first element in allocator chain"); long reservedCapacity = SizeUtils.sizeStringToBytes(PrimaryStorageGlobalConfig.RESERVED_CAPACITY.value()); List<PrimaryStorageVO> ret = new ArrayList<PrimaryStorageVO>(candidates.size()); for (PrimaryStorageVO vo : candidates) { if (vo.getCapacity().getAvailableCapacity() - psRatioMgr.calculateByRatio(vo.getUuid(), spec.getSize()) >= reservedCapacity) { ret.add(vo); } } if (ret.isEmpty()) { throw new OperationFailureException(operr("after subtracting reserved capacity[%s], there is no primary storage having required size[%s bytes]", PrimaryStorageGlobalConfig.RESERVED_CAPACITY.value(), spec.getSize())); } data.put(AllocatorParams.CANDIDATES, ret); trigger.next(); } }
protected PrimaryStorageInventory(PrimaryStorageVO vo) { setZoneUuid(vo.getZoneUuid()); setCreateDate(vo.getCreateDate()); setDescription(vo.getDescription()); setLastOpDate(vo.getLastOpDate()); setName(vo.getName()); setState(vo.getState().toString()); setType(vo.getType()); setUrl(vo.getUrl()); setUuid(vo.getUuid()); setMountPath(vo.getMountPath()); setStatus(vo.getStatus().toString()); attachedClusterUuids = new ArrayList<String>(vo.getAttachedClusterRefs().size()); for (PrimaryStorageClusterRefVO ref : vo.getAttachedClusterRefs()) { attachedClusterUuids.add(ref.getClusterUuid()); } if (vo.getCapacity() != null) { setTotalCapacity(vo.getCapacity().getTotalCapacity()); setAvailableCapacity(vo.getCapacity().getAvailableCapacity()); setTotalPhysicalCapacity(vo.getCapacity().getTotalPhysicalCapacity()); setAvailablePhysicalCapacity(vo.getCapacity().getAvailablePhysicalCapacity()); setSystemUsedCapacity(vo.getCapacity().getSystemUsedCapacity()); } }
for (PrimaryStorageVO vo : vos) { if (ratioMgr.calculatePrimaryStorageAvailableCapacityByRatio(vo.getUuid(), vo.getCapacity().getAvailableCapacity()) > spec.getSize()) { res.add(vo);