@Override public ImageBackupStorageRefInventory call(ImageBackupStorageRefInventory arg) { return arg.getBackupStorageUuid().equals(self.getUuid()) ? arg : null; } });
@Transactional(readOnly = true) private boolean canDelete(String installPath) { String sql = "select count(c)" + " from ImageBackupStorageRefVO img, ImageCacheVO c" + " where img.imageUuid = c.imageUuid" + " and img.backupStorageUuid = :bsUuid" + " and img.installPath = :installPath"; TypedQuery<Long> q = dbf.getEntityManager().createQuery(sql, Long.class); q.setParameter("bsUuid", self.getUuid()); q.setParameter("installPath", installPath); return q.getSingleResult() == 0; }
@Override public ImageBackupStorageRefInventory call(ImageBackupStorageRefInventory arg) { return self.getUuid().equals(arg.getBackupStorageUuid()) ? arg : null; } });
@Transactional(readOnly = true) private boolean canDelete(String installPath) { String sql = "select count(c) from ImageBackupStorageRefVO img, ImageCacheVO c where img.imageUuid = c.imageUuid and img.backupStorageUuid = :bsUuid and img.installPath = :installPath"; TypedQuery<Long> q = dbf.getEntityManager().createQuery(sql, Long.class); q.setParameter("bsUuid", self.getUuid()); q.setParameter("installPath", installPath); return q.getSingleResult() == 0; }
@Override public ImageBackupStorageRefInventory call(ImageBackupStorageRefInventory arg) { return self.getUuid().equals(arg.getBackupStorageUuid()) ? arg : null; } });
@Override public void attachHook(String zoneUuid, Completion completion) { logger.debug(String.format("SimulatorBackupStorage[uuid:%s] attached", self.getUuid())); completion.success(); }
private void doScanImages() { try { List<ImageInventory> images = this.scanImages(); } catch (Exception e) { logger.warn(String.format("Unhandled exception happened while scanning backup storage[uuid:%s]", self.getUuid()), e); } }
@Override public BackupStorage getBackupStorage(BackupStorageVO vo) { FusionstorBackupStorageVO cvo = dbf.findByUuid(vo.getUuid(), FusionstorBackupStorageVO.class); return new FusionstorBackupStorageBase(cvo); }
@Override public BackupStorage getBackupStorage(BackupStorageVO vo) { CephBackupStorageVO cvo = dbf.findByUuid(vo.getUuid(), CephBackupStorageVO.class); return new CephBackupStorageBase(cvo); }
@Override public BackupStorage getBackupStorage(BackupStorageVO vo) { SftpBackupStorageVO lvo = dbf.findByUuid(vo.getUuid(), SftpBackupStorageVO.class); return new SftpBackupStorage(lvo); }
private void handle(final APIGetTrashOnBackupStorageMsg msg) { APIGetTrashOnBackupStorageReply reply = new APIGetTrashOnBackupStorageReply(); reply.getStorageTrashSpecs().addAll(trash.getTrashList(self.getUuid(), trashLists).values()); bus.reply(msg, reply); }
@Override public void success() { if (self.getStatus() == BackupStorageStatus.Disconnected) { logger.debug(String.format("Ping backup storage[uuid%s] success, but it is disconnected, reconnect it", self.getUuid())); reconnect(); } bus.reply(msg, reply); }
protected void updateCapacity(Long totalCapacity, Long availableCapacity) { if (totalCapacity == null || availableCapacity == null) { return; } BackupStorageVO vo = dbf.findByUuid(self.getUuid(), BackupStorageVO.class); vo.setTotalCapacity(totalCapacity); vo.setAvailableCapacity(availableCapacity); dbf.update(vo); }
@Transactional private void handle(ReturnBackupStorageMsg msg) { self = dbf.getEntityManager().find(BackupStorageVO.class, self.getUuid(), LockModeType.PESSIMISTIC_WRITE); long availSize = self.getAvailableCapacity() + msg.getSize(); if (availSize > self.getTotalCapacity()) { availSize = self.getTotalCapacity(); } self.setAvailableCapacity(availSize); dbf.getEntityManager().merge(self); bus.reply(msg, new ReturnBackupStorageReply()); }
private void checkResize() { if (originalCopy != null && capacityVO != null && originalCopy.getTotalCapacity() != 0 && originalCopy.getTotalCapacity() != capacityVO.getTotalCapacity()) { logger.debug(String.format("the capacity of backup storage[uuid:%s] changed from %s to %s, this indicates the backup storage is re-sized." + " We need to recalculate its capacity", capacityVO.getUuid(), originalCopy.getTotalCapacity(), capacityVO.getTotalCapacity())); // primary storage re-sized } }
private void handle(BackupStorageDeletionMsg msg) { BackupStorageInventory inv = BackupStorageInventory.valueOf(self); extpEmitter.beforeDelete(inv); deleteHook(); extpEmitter.afterDelete(inv); BackupStorageDeletionReply reply = new BackupStorageDeletionReply(); tracker.untrack(self.getUuid()); bus.reply(msg, reply); }
private void handle(APIRemoveMonFromCephBackupStorageMsg msg) { SimpleQuery<CephBackupStorageMonVO> q = dbf.createQuery(CephBackupStorageMonVO.class); q.add(CephBackupStorageMonVO_.hostname, Op.IN, msg.getMonHostnames()); q.add(CephBackupStorageMonVO_.backupStorageUuid, Op.EQ, self.getUuid()); List<CephBackupStorageMonVO> vos = q.list(); if (!vos.isEmpty()) { dbf.removeCollection(vos, CephBackupStorageMonVO.class); } APIRemoveMonFromCephBackupStorageEvent evt = new APIRemoveMonFromCephBackupStorageEvent(msg.getId()); evt.setInventory(CephBackupStorageInventory.valueOf(dbf.reload(getSelf()))); bus.publish(evt); }
private void handle(APIRemoveMonFromFusionstorBackupStorageMsg msg) { SimpleQuery<FusionstorBackupStorageMonVO> q = dbf.createQuery(FusionstorBackupStorageMonVO.class); q.add(FusionstorBackupStorageMonVO_.hostname, Op.IN, msg.getMonHostnames()); q.add(FusionstorBackupStorageMonVO_.backupStorageUuid, Op.EQ, self.getUuid()); List<FusionstorBackupStorageMonVO> vos = q.list(); if (!vos.isEmpty()) { dbf.removeCollection(vos, FusionstorBackupStorageMonVO.class); } APIRemoveMonFromFusionstorBackupStorageEvent evt = new APIRemoveMonFromFusionstorBackupStorageEvent(msg.getId()); evt.setInventory(FusionstorBackupStorageInventory.valueOf(dbf.reload(getSelf()))); bus.publish(evt); }