private void handle(final TakeSnapshotMsg msg) { final VolumeSnapshotInventory sp = msg.getStruct().getCurrent(); HypervisorBackend bkd = getHypervisorBackendByVolumeUuid(sp.getVolumeUuid()); bkd.handle(msg, new ReturnValueCompletion<TakeSnapshotReply>(msg) { @Override public void success(TakeSnapshotReply returnValue) { bus.reply(msg, returnValue); } @Override public void fail(ErrorCode errorCode) { TakeSnapshotReply reply = new TakeSnapshotReply(); reply.setError(errorCode); bus.reply(msg, reply); } }); }
@Transactional private VolumeSnapshotStruct newChain(VolumeSnapshotVO vo, boolean fullsnapshot) { VolumeSnapshotTreeVO chain = new VolumeSnapshotTreeVO(); chain.setCurrent(true); chain.setVolumeUuid(vo.getVolumeUuid()); chain.setUuid(Platform.getUuid()); chain = dbf.getEntityManager().merge(chain); logger.debug(String.format("created new volume snapshot tree[tree uuid:%s, volume uuid:%s, full snapshot uuid:%s]", chain.getUuid(), vo.getVolumeUuid(), vo.getUuid())); vo.setTreeUuid(chain.getUuid()); vo.setDistance(fullsnapshot ? 0 : 1); vo.setParentUuid(null); vo.setLatest(true); vo.setFullSnapshot(fullsnapshot); dbf.getEntityManager().persist(vo); dbf.getEntityManager().flush(); dbf.getEntityManager().refresh(vo); VolumeSnapshotStruct struct = new VolumeSnapshotStruct(); struct.setCurrent(VolumeSnapshotInventory.valueOf(vo)); struct.setFullSnapshot(fullsnapshot); return struct; }
dbf.getEntityManager().refresh(vo); VolumeSnapshotStruct struct = new VolumeSnapshotStruct(); struct.setParent(VolumeSnapshotInventory.valueOf(latest)); struct.setCurrent(VolumeSnapshotInventory.valueOf(vo)); return struct;
@Override void handle(final TakeSnapshotMsg msg, final String hostUuid, final ReturnValueCompletion<TakeSnapshotReply> completion) { final VolumeSnapshotInventory sp = msg.getStruct().getCurrent(); VolumeInventory vol = VolumeInventory.valueOf(dbf.findByUuid(sp.getVolumeUuid(), VolumeVO.class)); hmsg.setVmUuid(vol.getVmInstanceUuid()); hmsg.setVolume(vol); hmsg.setSnapshotName(msg.getStruct().getCurrent().getUuid()); hmsg.setFullSnapshot(msg.getStruct().isFullSnapshot()); String installPath = makeSnapshotInstallPath(vol, sp); hmsg.setInstallPath(installPath);
private void handle(final TakeSnapshotMsg msg) { final TakeSnapshotReply reply = new TakeSnapshotReply(); String volumeUuid = msg.getStruct().getCurrent().getVolumeUuid(); VolumeVO vol = dbf.findByUuid(volumeUuid, VolumeVO.class); hmsg.setVmUuid(vol.getVmInstanceUuid()); hmsg.setVolume(volInv); hmsg.setSnapshotName(msg.getStruct().getCurrent().getUuid()); hmsg.setFullSnapshot(msg.getStruct().isFullSnapshot()); final String installPath = NfsPrimaryStorageKvmHelper.makeKvmSnapshotInstallPath(getSelfInventory(), volInv, msg.getStruct().getCurrent()); hmsg.setInstallPath(installPath); bus.makeTargetServiceIdByResourceUuid(hmsg, HostConstant.SERVICE_ID, huuid);
@Override void handle(TakeSnapshotMsg msg, final ReturnValueCompletion<TakeSnapshotReply> completion) { final VolumeSnapshotInventory sp = msg.getStruct().getCurrent(); VolumeInventory vol = VolumeInventory.valueOf(dbf.findByUuid(sp.getVolumeUuid(), VolumeVO.class)); hmsg.setVmUuid(vol.getVmInstanceUuid()); hmsg.setVolume(vol); hmsg.setSnapshotName(msg.getStruct().getCurrent().getUuid()); hmsg.setFullSnapshot(msg.getStruct().isFullSnapshot()); String installPath = makeSnapshotInstallPath(vol, sp); hmsg.setInstallPath(installPath);
private void handle(final TakeSnapshotMsg msg) { final VolumeSnapshotInventory sp = msg.getStruct().getCurrent(); final String hostUuid = getHostUuidByResourceUuid(sp.getVolumeUuid()); LocalStorageHypervisorFactory f = getHypervisorBackendFactoryByHostUuid(hostUuid); LocalStorageHypervisorBackend bkd = f.getHypervisorBackend(self); bkd.handle(msg, hostUuid, new ReturnValueCompletion<TakeSnapshotReply>(msg) { @Override public void success(TakeSnapshotReply returnValue) { createResourceRefVO(sp.getUuid(), VolumeSnapshotVO.class.getSimpleName(), returnValue.getInventory().getSize(), hostUuid); bus.reply(msg, returnValue); } @Override public void fail(ErrorCode errorCode) { TakeSnapshotReply reply = new TakeSnapshotReply(); reply.setError(errorCode); bus.reply(msg, reply); } }); }
@Override public void afterTakeLiveSnapshotsOnVolumes(CreateVolumesSnapshotOverlayInnerMsg msg, TakeVolumesSnapshotOnKvmReply treply, Completion completion) { if (treply != null && !treply.isSuccess()) { completion.success(); return; } for (CreateVolumesSnapshotsJobStruct job : msg.getVolumeSnapshotJobs()) { if (!isLocalStorage(job.getPrimaryStorageUuid())) { continue; } LocalStorageResourceRefVO ref = new LocalStorageResourceRefVO(); ref.setPrimaryStorageUuid(job.getPrimaryStorageUuid()); ref.setResourceType(VolumeSnapshotVO.class.getSimpleName()); VmInstanceVO vmInstanceVO = Q.New(VmInstanceVO.class).eq(VmInstanceVO_.uuid, msg.getLockedVmInstanceUuids().get(0)).find(); ref.setHostUuid(vmInstanceVO.getHostUuid() != null ? vmInstanceVO.getHostUuid() : vmInstanceVO.getLastHostUuid()); ref.setCreateDate(job.getVolumeSnapshotStruct().getCurrent().getCreateDate()); ref.setLastOpDate(job.getVolumeSnapshotStruct().getCurrent().getLastOpDate()); ref.setResourceUuid(job.getVolumeSnapshotStruct().getCurrent().getUuid()); ref.setSize(treply.getSnapshotsResults().stream() .filter(r -> r.getVolumeUuid().equals(job.getVolumeUuid())) .findFirst().get().getSize()); dbf.persistAndRefresh(ref); } completion.success(); }
private void handle(final TakeSnapshotMsg msg) { final TakeSnapshotReply reply = new TakeSnapshotReply(); final VolumeSnapshotInventory sp = msg.getStruct().getCurrent(); SimpleQuery<VolumeVO> q = dbf.createQuery(VolumeVO.class); q.select(VolumeVO_.installPath);
private void handle(final TakeSnapshotMsg msg) { final TakeSnapshotReply reply = new TakeSnapshotReply(); final VolumeSnapshotInventory sp = msg.getStruct().getCurrent(); SimpleQuery<VolumeVO> q = dbf.createQuery(VolumeVO.class); q.select(VolumeVO_.installPath);
@Override public void run(MessageReply ret) { if (ret.isSuccess()) { TakeSnapshotOnHypervisorReply treply = (TakeSnapshotOnHypervisorReply) ret; VolumeSnapshotInventory inv = msg.getStruct().getCurrent(); inv.setSize(treply.getSize()); inv.setPrimaryStorageUuid(self.getUuid()); inv.setPrimaryStorageInstallPath(treply.getSnapshotInstallPath()); inv.setType(VolumeSnapshotConstant.HYPERVISOR_SNAPSHOT_TYPE.toString()); reply.setNewVolumeInstallPath(treply.getNewVolumeInstallPath()); reply.setInventory(inv); } else { reply.setError(ret.getError()); } bus.reply(msg, reply); } });