protected void exceptionIfImageSizeGreaterThanAvailableCapacity(String url) { if (CoreGlobalProperty.UNIT_TEST_ON) { return; } url = url.trim(); if (!url.startsWith("http") && !url.startsWith("https")) { return; } String len; try { HttpHeaders header = restf.getRESTTemplate().headForHeaders(URI.create(url)); len = header.getFirst("Content-Length"); } catch (Exception e) { throw new OperationFailureException(operr("cannot get image. The image url is %s. Exception is %s", url, e.toString())); } if (len == null) { return; } long size = Long.valueOf(len); if (size > self.getAvailableCapacity()) { throw new OperationFailureException(operr("the backup storage[uuid:%s, name:%s] has not enough capacity to download the image[%s]." + "Required size:%s, available size:%s", self.getUuid(), self.getName(), url, size, self.getAvailableCapacity())); } }
@Override public Void call() throws Exception { if (status == self.getStatus()) { completion.done(); return null; } changeStatus(status); logger.debug(String.format("backup storage[uuid:%s, name:%s] change status from %s to %s", self.getUuid(), self.getName(), self.getStatus(), status)); completion.done(); return null; } });
protected BackupStorageInventory(BackupStorageVO vo) { this.setCreateDate(vo.getCreateDate()); this.setDescription(vo.getDescription()); this.setLastOpDate(vo.getLastOpDate()); this.setName(vo.getName()); this.setState(vo.getState().toString()); this.setStatus(vo.getStatus().toString()); this.setTotalCapacity(vo.getTotalCapacity()); this.setAvailableCapacity(vo.getAvailableCapacity()); this.setType(vo.getType()); this.setUrl(vo.getUrl()); this.setUuid(vo.getUuid()); this.attachedZoneUuids = new ArrayList<String>(vo.getAttachedZoneRefs().size()); for (BackupStorageZoneRefVO ref : vo.getAttachedZoneRefs()) { if (!this.attachedZoneUuids.contains(ref.getZoneUuid())) { this.attachedZoneUuids.add(ref.getZoneUuid()); } } }
protected BackupStorageVO(BackupStorageVO vo) { this.setUuid(vo.getUuid()); this.setAttachedZoneRefs(vo.getAttachedZoneRefs()); this.setCreateDate(vo.getCreateDate()); this.setDescription(vo.getDescription()); this.setLastOpDate(vo.getLastOpDate()); this.setName(vo.getName()); this.setState(vo.getState()); this.setStatus(vo.getStatus()); this.setTotalCapacity(vo.getTotalCapacity()); this.setType(vo.getType()); this.setUrl(vo.getUrl()); this.setAvailableCapacity(vo.getAvailableCapacity()); }