Search in sources :

Example 11 with ImageTransfer

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;
}
Also used : ImageTransfer(org.ovirt.engine.core.common.businessentities.storage.ImageTransfer) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) TransferImageStatusParameters(org.ovirt.engine.core.common.action.TransferImageStatusParameters)

Example 12 with ImageTransfer

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));
        }
    }
}
Also used : ImageTransfer(org.ovirt.engine.core.common.businessentities.storage.ImageTransfer) TransferImageStatusParameters(org.ovirt.engine.core.common.action.TransferImageStatusParameters)

Example 13 with ImageTransfer

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;
}
Also used : ImageTransfer(org.ovirt.engine.core.common.businessentities.storage.ImageTransfer) Date(java.util.Date)

Example 14 with 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());
}
Also used : ImageTransfer(org.ovirt.engine.core.common.businessentities.storage.ImageTransfer) Test(org.junit.Test)

Example 15 with ImageTransfer

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);
}
Also used : ImageTransfer(org.ovirt.engine.core.common.businessentities.storage.ImageTransfer) Guid(org.ovirt.engine.core.compat.Guid) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Aggregations

ImageTransfer (org.ovirt.engine.core.common.businessentities.storage.ImageTransfer)22 TransferImageStatusParameters (org.ovirt.engine.core.common.action.TransferImageStatusParameters)9 Date (java.util.Date)3 Disk (org.ovirt.engine.core.common.businessentities.storage.Disk)3 Guid (org.ovirt.engine.core.compat.Guid)3 ArrayList (java.util.ArrayList)2 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)2 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)2 AsyncQuery (org.ovirt.engine.ui.frontend.AsyncQuery)2 Scheduler (com.google.gwt.core.client.Scheduler)1 Style (com.google.gwt.dom.client.Style)1 Frame (com.google.gwt.user.client.ui.Frame)1 RootPanel (com.google.gwt.user.client.ui.RootPanel)1 List (java.util.List)1 Predicate (java.util.function.Predicate)1 Logger (java.util.logging.Logger)1 Test (org.junit.Test)1 AuditLogType (org.ovirt.engine.core.common.AuditLogType)1 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)1 ActionType (org.ovirt.engine.core.common.action.ActionType)1