@Override protected void handle(DownloadImageMsg msg) { ImageInventory inv = msg.getImageInventory(); DownloadImageReply reply = new DownloadImageReply(); reply.setMd5sum(Platform.getUuid()); reply.setInstallPath(Utils.getPathUtil().join(self.getUrl(), inv.getName())); reply.setSize(100); reply.setActualSize(100L); reply.setFormat("simulator"); bus.reply(msg, reply); }
@Override public void fail(ErrorCode errorCode) { reply.setError(errorCode); bus.reply(msg, reply); } });
@Override public void success(DownloadResult res) { reply.setInstallPath(installPath); reply.setSize(res.size); reply.setActualSize(res.actualSize); reply.setMd5sum(res.md5sum); reply.setFormat(res.format); bus.reply(msg, reply); }
@Override @Transactional protected void handle(final DownloadImageMsg msg) { final DownloadImageReply reply = new DownloadImageReply(); final ImageInventory iinv = msg.getImageInventory(); final String installPath = PathUtil.join(getSelf().getUrl(), BackupStoragePathMaker.makeImageInstallPath(iinv)); String sql = "update ImageBackupStorageRefVO set installPath = :installPath " + "where backupStorageUuid = :bsUuid and imageUuid = :imageUuid"; Query q = dbf.getEntityManager().createQuery(sql); q.setParameter("installPath", installPath); q.setParameter("bsUuid", msg.getBackupStorageUuid()); q.setParameter("imageUuid", msg.getImageInventory().getUuid()); q.executeUpdate(); download(iinv.getUrl(), installPath, iinv.getUuid(), new ReturnValueCompletion<DownloadResult>(msg) { @Override public void success(DownloadResult res) { reply.setInstallPath(installPath); reply.setSize(res.size); reply.setActualSize(res.actualSize); reply.setMd5sum(res.md5sum); reply.setFormat(res.format); bus.reply(msg, reply); } @Override public void fail(ErrorCode errorCode) { reply.setError(errorCode); bus.reply(msg, reply); } }); }
q.executeUpdate(); final DownloadImageReply reply = new DownloadImageReply(); httpCall(DOWNLOAD_IMAGE_PATH, cmd, DownloadRsp.class, new ReturnValueCompletion<DownloadRsp>(msg) { @Override
@Override public void success(DownloadRsp ret) { reply.setInstallPath(cmd.installPath); reply.setSize(ret.size); // current fusionstor has no way to get the actual size // if we cannot get the actual size from HTTP, use the virtual size long asize = ret.actualSize == null ? ret.size : ret.actualSize; reply.setActualSize(asize); reply.setMd5sum("not calculated"); bus.reply(msg, reply); } });
.update(); final DownloadImageReply reply = new DownloadImageReply(); HttpCaller<DownloadRsp> caller = new HttpCaller<>(DOWNLOAD_IMAGE_PATH, cmd, DownloadRsp.class, new ReturnValueCompletion<DownloadRsp>(msg) { @Override
@Override public void fail(ErrorCode err) { reply.setError(err); bus.reply(msg, reply); }
@Override public void success(DownloadRsp ret) { if (cmd.getUrl().startsWith("upload://")) { reply.setInstallPath(ret.getUploadPath()); } else { reply.setInstallPath(cmd.installPath); } reply.setSize(ret.size); // current ceph has no way to get the actual size // if we cannot get the actual size from HTTP, use the virtual size long asize = ret.actualSize == null ? ret.size : ret.actualSize; reply.setActualSize(asize); reply.setMd5sum("not calculated"); reply.setFormat(ret.format); bus.reply(msg, reply); } });
@Override public void fail(ErrorCode err) { reply.setError(err); bus.reply(msg, reply); }