Search in sources :

Example 16 with ImageTransfer

use of org.ovirt.engine.core.common.businessentities.storage.ImageTransfer in project ovirt-engine by oVirt.

the class TransferImageCommand method updateEntityPhase.

protected void updateEntityPhase(ImageTransferPhase phase) {
    ImageTransfer updates = new ImageTransfer(getCommandId());
    updates.setPhase(phase);
    updateEntity(updates);
}
Also used : ImageTransfer(org.ovirt.engine.core.common.businessentities.storage.ImageTransfer)

Example 17 with ImageTransfer

use of org.ovirt.engine.core.common.businessentities.storage.ImageTransfer in project ovirt-engine by oVirt.

the class TransferImageStatusCommand method executeCommand.

@Override
protected void executeCommand() {
    if (getParameters().getTransferImageCommandId() == null && getParameters().getDiskId() == null) {
        log.error("Invalid parameters: command or disk id must be specified");
        setSucceeded(false);
    }
    ImageTransfer entity;
    if (getParameters().getTransferImageCommandId() != null) {
        entity = imageTransferDao.get(getParameters().getTransferImageCommandId());
    } else {
        entity = imageTransferDao.getByDiskId(getParameters().getDiskId());
    }
    if (entity != null) {
        // Always update; this serves as a keepalive
        entity = imageTransferUpdater.updateEntity(getParameters().getUpdates(), entity.getId(), false);
    } else {
        // with phase "UNKNOWN" and the UI will know what to do.
        if (getParameters().getTransferImageCommandId() != null) {
            log.info("TransferImageStatus request for missing or removed entity, command id {}", getParameters().getTransferImageCommandId());
        } else {
            log.info("TransferImageStatus request for missing or removed entity, disk id {}", getParameters().getDiskId());
        }
        entity = new ImageTransfer();
        entity.setId(getParameters().getTransferImageCommandId());
        entity.setPhase(ImageTransferPhase.UNKNOWN);
        entity.setType(TransferType.Unknown);
        entity.setActive(false);
    }
    setSucceeded(true);
    getReturnValue().setActionReturnValue(entity);
}
Also used : ImageTransfer(org.ovirt.engine.core.common.businessentities.storage.ImageTransfer)

Example 18 with ImageTransfer

use of org.ovirt.engine.core.common.businessentities.storage.ImageTransfer in project ovirt-engine by oVirt.

the class ImageTransferUpdater method updateEntity.

public ImageTransfer updateEntity(ImageTransfer updates, Guid commandId, boolean clearResourceId) {
    // TODO this lock might not be enough; analyze possible concurrent calls
    EngineLock lock = getEntityUpdateLock(commandId);
    try {
        lockManager.acquireLockWait(lock);
        ImageTransfer entity = imageTransferDao.get(commandId);
        if (entity == null) {
            log.error("Attempt to update non-existent ImageTransfer entity");
            return null;
        }
        entity.setLastUpdated(new Date());
        if (updates != null) {
            if (updates.getId() != null) {
                entity.setId(updates.getId());
            }
            if (updates.getPhase() != null) {
                String disk = entity.getDiskId() != null ? String.format(" (image %s)", entity.getDiskId().toString()) : "";
                String message = entity.getMessage() != null ? String.format(" (message: '%s')", entity.getMessage()) : "";
                log.info("Updating image transfer {}{} phase to {}{}", commandId, disk, updates.getPhase(), message);
                entity.setPhase(updates.getPhase());
            }
            if (updates.getType() != null) {
                entity.setType(updates.getType());
            }
            if (updates.getActive() != null) {
                entity.setActive(updates.getActive());
            }
            if (updates.getMessage() != null) {
                entity.setMessage(updates.getMessage());
            }
            if (updates.getVdsId() != null) {
                entity.setVdsId(updates.getVdsId());
            }
            if (updates.getDiskId() != null) {
                entity.setDiskId(updates.getDiskId());
            }
            if (updates.getImagedTicketId() != null || clearResourceId) {
                entity.setImagedTicketId(updates.getImagedTicketId());
            }
            if (updates.getProxyUri() != null) {
                entity.setProxyUri(updates.getProxyUri());
            }
            if (updates.getDaemonUri() != null) {
                entity.setDaemonUri(updates.getDaemonUri());
            }
            if (updates.getSignedTicket() != null) {
                entity.setSignedTicket(updates.getSignedTicket());
            }
            if (updates.getBytesSent() != null) {
                entity.setBytesSent(updates.getBytesSent());
            }
            if (updates.getBytesTotal() != null) {
                entity.setBytesTotal(updates.getBytesTotal());
            }
        }
        imageTransferDao.update(entity);
        return entity;
    } finally {
        lockManager.releaseLock(lock);
    }
}
Also used : ImageTransfer(org.ovirt.engine.core.common.businessentities.storage.ImageTransfer) EngineLock(org.ovirt.engine.core.utils.lock.EngineLock) Date(java.util.Date)

Example 19 with ImageTransfer

use of org.ovirt.engine.core.common.businessentities.storage.ImageTransfer in project ovirt-engine by oVirt.

the class UploadImageHandler method initiateResumeUploadStartTransfer.

private void initiateResumeUploadStartTransfer(FrontendActionAsyncResult result) {
    if (result.getReturnValue() != null && result.getReturnValue().getSucceeded()) {
        ImageTransfer rv = result.getReturnValue().getActionReturnValue();
        setCommandId(rv.getId());
        setBytesSent(rv.getBytesSent());
        setBytesEndOffset(rv.getBytesTotal());
        startStatusPolling();
    } else {
        setProgressStr(messages.uploadImageFailedToResumeMessage(result.getReturnValue().getDescription()));
    }
}
Also used : ImageTransfer(org.ovirt.engine.core.common.businessentities.storage.ImageTransfer)

Example 20 with ImageTransfer

use of org.ovirt.engine.core.common.businessentities.storage.ImageTransfer in project ovirt-engine by oVirt.

the class UploadImageHandler method startStatusPolling.

private void startStatusPolling() {
    setContinuePolling(true);
    Scheduler.get().scheduleFixedDelay(() -> {
        // $NON-NLS-1$
        log.info("Polling for status");
        TransferImageStatusParameters statusParameters = new TransferImageStatusParameters(getCommandId());
        ImageTransfer updates = new ImageTransfer();
        updateBytesSent(updates);
        updates.setMessage(getProgressStr());
        statusParameters.setUpdates(updates);
        Frontend.getInstance().runAction(ActionType.TransferImageStatus, statusParameters, this::respondToPollStatus);
        return isContinuePolling();
    }, POLLING_DELAY_MS);
}
Also used : ImageTransfer(org.ovirt.engine.core.common.businessentities.storage.ImageTransfer) TransferImageStatusParameters(org.ovirt.engine.core.common.action.TransferImageStatusParameters)

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