use of org.ovirt.engine.core.common.businessentities.storage.ImageTransfer in project ovirt-engine by oVirt.
the class TransferImageCommand method updateTransferStatusWithTicketInformation.
private ImageTransfer updateTransferStatusWithTicketInformation(ImageTransfer oldImageTransfer, ImageTicketInformation ticketInfo) {
if (!Objects.equals(oldImageTransfer.getActive(), ticketInfo.isActive()) || !Objects.equals(oldImageTransfer.getBytesSent(), ticketInfo.getTransferred())) {
// At least one of the status fields (bytesSent or active) should be updated.
ImageTransfer updatesFromTicket = new ImageTransfer();
updatesFromTicket.setBytesSent(ticketInfo.getTransferred());
updatesFromTicket.setActive(ticketInfo.isActive());
ActionReturnValue returnValue = runInternalAction(ActionType.TransferImageStatus, new TransferImageStatusParameters(getCommandId(), updatesFromTicket));
if (returnValue == null || !returnValue.getSucceeded()) {
log.debug("Failed to update transfer status.");
return oldImageTransfer;
}
return returnValue.getActionReturnValue();
}
return oldImageTransfer;
}
use of org.ovirt.engine.core.common.businessentities.storage.ImageTransfer in project ovirt-engine by oVirt.
the class TransferImageCommand method finalizeDownloadIfNecessary.
private void finalizeDownloadIfNecessary(final StateContext context, ImageTransfer upToDateImageTransfer) {
if (upToDateImageTransfer.getBytesTotal() != 0 && // Frontend flow (REST API should close the connection on its own).
getParameters().getTransferSize() == upToDateImageTransfer.getBytesSent() && !upToDateImageTransfer.getActive()) {
// to decrease the chances that the few last packets are still on the way to the client.
if (!context.entity.getActive()) {
// The entity from the previous COCO iteration.
// This is the second COCO iteration that the transfer is inactive.
ImageTransfer statusUpdate = new ImageTransfer();
statusUpdate.setPhase(ImageTransferPhase.FINALIZING_SUCCESS);
runInternalAction(ActionType.TransferImageStatus, new TransferImageStatusParameters(getCommandId(), statusUpdate));
}
}
}
use of org.ovirt.engine.core.common.businessentities.storage.ImageTransfer in project ovirt-engine by oVirt.
the class ImageTransferDaoTest method generateNewEntity.
@Override
protected ImageTransfer generateNewEntity() {
ImageTransfer imageTransfer = new ImageTransfer(Guid.newGuid());
imageTransfer.setCommandType(ActionType.TransferDiskImage);
imageTransfer.setPhase(ImageTransferPhase.TRANSFERRING);
imageTransfer.setType(TransferType.Upload);
imageTransfer.setActive(true);
imageTransfer.setLastUpdated(new Date());
imageTransfer.setVdsId(FixturesTool.HOST_ID);
imageTransfer.setDiskId(FixturesTool.DISK_ID);
imageTransfer.setBytesSent(0L);
imageTransfer.setBytesTotal(SizeConverter.BYTES_IN_GB);
return imageTransfer;
}
use of org.ovirt.engine.core.common.businessentities.storage.ImageTransfer in project ovirt-engine by oVirt.
the class ImageTransferDaoTest method testGetByDiskId.
@Test
public void testGetByDiskId() {
ImageTransfer imageTransfer = dao.getByDiskId(FixturesTool.DISK_ID);
assertNotNull(imageTransfer);
assertEquals(FixturesTool.DISK_ID, imageTransfer.getDiskId());
}
use of org.ovirt.engine.core.common.businessentities.storage.ImageTransfer in project ovirt-engine by oVirt.
the class TransferImageCommand method handleImageIsReadyForTransfer.
protected void handleImageIsReadyForTransfer() {
DiskImage image = getDiskImage();
Guid domainId = image.getStorageIds().get(0);
getParameters().setStorageDomainId(domainId);
getParameters().setDestinationImageId(image.getImageId());
// ovirt-imageio-daemon must know the boundaries of the target image for writing permissions.
getParameters().setTransferSize(getTransferSize(image, domainId));
persistCommand(getParameters().getParentCommand(), true);
setImage(image);
setStorageDomainId(domainId);
log.info("Successfully added {} for image transfer command '{}'", getTransferDescription(), getCommandId());
// ImageGroup is empty when downloading a disk snapshot
if (!Guid.isNullOrEmpty(getParameters().getImageGroupID())) {
ImageTransfer updates = new ImageTransfer();
updates.setDiskId(getParameters().getImageGroupID());
updateEntity(updates);
}
// The image will remain locked until the transfer command has completed.
lockImage();
startImageTransferSession();
log.info("Returning from proceedCommandExecution after starting transfer session" + " for image transfer command '{}'", getCommandId());
resetPeriodicPauseLogTime(0);
}
Aggregations