protected BackupStorageInventory getSelfInventory() { return BackupStorageInventory.valueOf(self); }
public static List<BackupStorageInventory> valueOf(Collection<BackupStorageVO> vos) { List<BackupStorageInventory> invs = new ArrayList<BackupStorageInventory>(vos.size()); for (BackupStorageVO vo : vos) { invs.add(BackupStorageInventory.valueOf(vo)); } return invs; }
void afterAttach(BackupStorageVO vo, final String zoneUuid) { final BackupStorageInventory inv = BackupStorageInventory.valueOf(vo); CollectionUtils.safeForEach(attachExts, new ForEachFunction<BackupStorageAttachExtensionPoint>() { @Override public void run(BackupStorageAttachExtensionPoint arg) { arg.afterAttachBackupStorage(inv, zoneUuid); } }); }
void afterDetach(BackupStorageVO vo, final String zoneUuid) { final BackupStorageInventory inv = BackupStorageInventory.valueOf(vo); CollectionUtils.safeForEach(detachExts, new ForEachFunction<BackupStorageDetachExtensionPoint>() { @Override public void run(BackupStorageDetachExtensionPoint arg) { arg.afterDetachBackupStorage(inv, zoneUuid); } }); }
void beforeAttach(BackupStorageVO vo, final String zoneUuid) { final BackupStorageInventory inv = BackupStorageInventory.valueOf(vo); CollectionUtils.safeForEach(attachExts, new ForEachFunction<BackupStorageAttachExtensionPoint>() { @Override public void run(BackupStorageAttachExtensionPoint arg) { arg.beforeAttachBackupStorage(inv, zoneUuid); } }); }
@Override public BackupStorageInventory reload(String uuid) { BackupStorageVO vo = dbf.findByUuid(uuid, BackupStorageVO.class); return BackupStorageInventory.valueOf(vo); }
void failToDetach(BackupStorageVO vo, final String zoneUuid) { final BackupStorageInventory inv = BackupStorageInventory.valueOf(vo); CollectionUtils.safeForEach(detachExts, new ForEachFunction<BackupStorageDetachExtensionPoint>() { @Override public void run(BackupStorageDetachExtensionPoint arg) { arg.afterDetachBackupStorage(inv, zoneUuid); } }); }
void afterChange(BackupStorageVO vo, final BackupStorageStateEvent evt, final BackupStorageState preState) { final BackupStorageInventory inv = BackupStorageInventory.valueOf(vo); CollectionUtils.safeForEach(changeExts, new ForEachFunction<BackupStorageChangeStateExtensionPoint>() { @Override public void run(BackupStorageChangeStateExtensionPoint arg) { arg.afterChangeSecondaryStorageState(inv, evt, preState); } }); }
void failToAttach(BackupStorageVO vo, final String zoneUuid) { final BackupStorageInventory inv = BackupStorageInventory.valueOf(vo); CollectionUtils.safeForEach(attachExts, new ForEachFunction<BackupStorageAttachExtensionPoint>() { @Override public void run(BackupStorageAttachExtensionPoint arg) { arg.failToAttachBackupStorage(inv, zoneUuid); } }); }
void beforeDetach(BackupStorageVO vo, final String zoneUuid) { final BackupStorageInventory inv = BackupStorageInventory.valueOf(vo); CollectionUtils.safeForEach(detachExts, new ForEachFunction<BackupStorageDetachExtensionPoint>() { @Override public void run(BackupStorageDetachExtensionPoint arg) { arg.beforeDetachBackupStorage(inv, zoneUuid); } }); }
private BackupStorageMediator getBackupStorageMediator(String bsUuid) { BackupStorageVO bsvo = dbf.findByUuid(bsUuid, BackupStorageVO.class); BackupStorageMediator mediator = backupStorageMediators.get(bsvo.getType()); if (mediator == null) { throw new CloudRuntimeException(String.format("cannot find BackupStorageMediator for type[%s]", bsvo.getType())); } mediator.backupStorage = BackupStorageInventory.valueOf(bsvo); return mediator; }
private BackupStorageMediator getBackupStorageMediator(String bsUuid) { BackupStorageVO bsvo = dbf.findByUuid(bsUuid, BackupStorageVO.class); BackupStorageMediator mediator = backupStorageMediators.get(bsvo.getType()); if (mediator == null) { throw new CloudRuntimeException(String.format("cannot find BackupStorageMediator for type[%s]", bsvo.getType())); } mediator.backupStorage = BackupStorageInventory.valueOf(bsvo); return mediator; }
String preAttach(BackupStorageVO vo, String zoneUuid) { BackupStorageInventory inv = BackupStorageInventory.valueOf(vo); for (BackupStorageAttachExtensionPoint extp : attachExts) { try { String reason = extp.preAttachBackupStorage(inv, zoneUuid); if (reason != null) { logger.debug(String.format("%s refused to attach backup storage[uuid:%s] because %s", extp.getClass().getName(), inv.getUuid(), reason)); return reason; } } catch (Exception e) { logger.warn("Exception happened when calling preAttach of BackupStorageAttachExtensionPoint", e); } } return null; }
void preDetach(BackupStorageVO vo, String zoneUuid) throws BackupStorageException { BackupStorageInventory inv = BackupStorageInventory.valueOf(vo); for (BackupStorageDetachExtensionPoint extp : detachExts) { try { extp.preDetachBackupStorage(inv, zoneUuid); } catch (BackupStorageException be) { logger.debug(String.format("%s refused to detach backup storage[uuid:%s] because %s", extp.getClass().getName(), inv.getUuid(), be.getMessage())); throw be; } catch (Exception e) { logger.warn("Exception happened when calling preDetach of BackupStorageDetachExtensionPoint", e); } } }
void beforeChange(BackupStorageVO vo, final BackupStorageStateEvent evt) { final BackupStorageInventory inv = BackupStorageInventory.valueOf(vo); final BackupStorageState next = AbstractBackupStorage.getNextState(vo.getState(), evt); CollectionUtils.safeForEach(changeExts, new ForEachFunction<BackupStorageChangeStateExtensionPoint>() { @Override public void run(BackupStorageChangeStateExtensionPoint arg) { arg.beforeChangeSecondaryStorageState(inv, evt, next); } }); }
private void handle(APIListBackupStorageMsg msg) { List<BackupStorageVO> vos = dl.listByApiMessage(msg, BackupStorageVO.class); List<BackupStorageInventory> invs = BackupStorageInventory.valueOf(vos); APIListBackupStorageReply reply = new APIListBackupStorageReply(); reply.setInventories(invs); bus.reply(msg, reply); }
void preChange(BackupStorageVO vo, BackupStorageStateEvent evt) throws BackupStorageException { BackupStorageState next = AbstractBackupStorage.getNextState(vo.getState(), evt); BackupStorageInventory inv = BackupStorageInventory.valueOf(vo); for (BackupStorageChangeStateExtensionPoint extp : changeExts) { try { extp.preChangeSecondaryStorageState(inv, evt, next); } catch(BackupStorageException be) { logger.debug(String.format("%s refused to change backup storage[uuid:%s] state from %s to %s because %s", extp.getClass().getCanonicalName(), vo.getUuid(), vo.getState(), next, be.getMessage())); throw be; } catch (Exception e) { logger.warn("Exception happened when calling preChangeBackupStorageState of BackupStorageChangeStateExtensionPoint", e); } } }
@Override public BackupStorageInventory createBackupStorage(BackupStorageVO vo, APIAddBackupStorageMsg msg) { APIAddSimulatorBackupStorageMsg smsg = (APIAddSimulatorBackupStorageMsg) msg; vo.setTotalCapacity(smsg.getTotalCapacity()); vo.setAvailableCapacity(smsg.getAvailableCapacity()); vo = dbf.persistAndRefresh(vo); return BackupStorageInventory.valueOf(vo); }
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); }
@Override public void handle(PrimaryStorageInventory inv, UploadBitsToBackupStorageMsg msg, final ReturnValueCompletion<UploadBitsToBackupStorageReply> completion) { BackupStorageVO bs = dbf.findByUuid(msg.getBackupStorageUuid(), BackupStorageVO.class); NfsPrimaryToBackupStorageMediator m = nfsFactory.getPrimaryToBackupStorageMediator(BackupStorageType.valueOf(bs.getType()), HypervisorType.valueOf(msg.getHypervisorType())); m.uploadBits(msg.getImageUuid(), inv, BackupStorageInventory.valueOf(bs), msg.getBackupStorageInstallPath(), msg.getPrimaryStorageInstallPath(), new ReturnValueCompletion<String>(completion) { @Override public void success(String installPath) { UploadBitsToBackupStorageReply reply = new UploadBitsToBackupStorageReply(); reply.setBackupStorageInstallPath(installPath); completion.success(reply); } @Override public void fail(ErrorCode errorCode) { completion.fail(errorCode); } }); }