Search in sources :

Example 6 with TransferImageStatusParameters

use of org.ovirt.engine.core.common.action.TransferImageStatusParameters in project ovirt-engine by oVirt.

the class BackendImageTransferResource method prepareStatusParams.

private TransferImageStatusParameters prepareStatusParams(ImageTransferPhase phase) {
    org.ovirt.engine.core.common.businessentities.storage.ImageTransfer updates = new org.ovirt.engine.core.common.businessentities.storage.ImageTransfer(guid);
    updates.setPhase(phase);
    TransferImageStatusParameters params = new TransferImageStatusParameters();
    params.setTransferImageCommandId(guid);
    params.setUpdates(updates);
    return params;
}
Also used : ImageTransfer(org.ovirt.engine.api.model.ImageTransfer) TransferImageStatusParameters(org.ovirt.engine.core.common.action.TransferImageStatusParameters)

Example 7 with TransferImageStatusParameters

use of org.ovirt.engine.core.common.action.TransferImageStatusParameters 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 8 with TransferImageStatusParameters

use of org.ovirt.engine.core.common.action.TransferImageStatusParameters 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 9 with TransferImageStatusParameters

use of org.ovirt.engine.core.common.action.TransferImageStatusParameters 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)

Example 10 with TransferImageStatusParameters

use of org.ovirt.engine.core.common.action.TransferImageStatusParameters in project ovirt-engine by oVirt.

the class UploadImageModel method initiateSilentResumeUpload.

private void initiateSilentResumeUpload() {
    TransferImageStatusParameters parameters = new TransferImageStatusParameters();
    parameters.setDiskId(getDiskModel().getDisk().getId());
    UploadImageManager.getInstance().resumeUpload(null, parameters, new AsyncQuery<>(errorMessage -> {
        if (errorMessage != null) {
            getLogger().error(errorMessage, null);
        }
    }));
}
Also used : DiskContentType(org.ovirt.engine.core.common.businessentities.storage.DiskContentType) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) ImageTransferPhase(org.ovirt.engine.core.common.businessentities.storage.ImageTransferPhase) Guid(org.ovirt.engine.core.compat.Guid) AddDiskParameters(org.ovirt.engine.core.common.action.AddDiskParameters) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) Event(org.ovirt.engine.ui.uicompat.Event) TransferType(org.ovirt.engine.core.common.businessentities.storage.TransferType) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) ArrayList(java.util.ArrayList) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ActionType(org.ovirt.engine.core.common.action.ActionType) Frontend(org.ovirt.engine.ui.frontend.Frontend) RequestBuilder(com.google.gwt.http.client.RequestBuilder) RequestException(com.google.gwt.http.client.RequestException) TransferDiskImageParameters(org.ovirt.engine.core.common.action.TransferDiskImageParameters) Response(com.google.gwt.http.client.Response) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) ICommandTarget(org.ovirt.engine.ui.uicommonweb.ICommandTarget) EventArgs(org.ovirt.engine.ui.uicompat.EventArgs) UIMessages(org.ovirt.engine.ui.uicompat.UIMessages) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) StorageFormatType(org.ovirt.engine.core.common.businessentities.StorageFormatType) Model(org.ovirt.engine.ui.uicommonweb.models.Model) NewDiskModel(org.ovirt.engine.ui.uicommonweb.models.vms.NewDiskModel) DiskStorageType(org.ovirt.engine.core.common.businessentities.storage.DiskStorageType) IValidation(org.ovirt.engine.ui.uicommonweb.validation.IValidation) ValidationResult(org.ovirt.engine.ui.uicommonweb.validation.ValidationResult) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) TransferImageStatusParameters(org.ovirt.engine.core.common.action.TransferImageStatusParameters) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) ConfigValues(org.ovirt.engine.core.common.config.ConfigValues) StringHelper(org.ovirt.engine.core.compat.StringHelper) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) Logger(java.util.logging.Logger) Request(com.google.gwt.http.client.Request) List(java.util.List) UIConstants(org.ovirt.engine.ui.uicompat.UIConstants) ReadOnlyDiskModel(org.ovirt.engine.ui.uicommonweb.models.vms.ReadOnlyDiskModel) ImageTransfer(org.ovirt.engine.core.common.businessentities.storage.ImageTransfer) Element(com.google.gwt.dom.client.Element) VDS(org.ovirt.engine.core.common.businessentities.VDS) AbstractDiskModel(org.ovirt.engine.ui.uicommonweb.models.vms.AbstractDiskModel) RequestCallback(com.google.gwt.http.client.RequestCallback) TransferImageStatusParameters(org.ovirt.engine.core.common.action.TransferImageStatusParameters)

Aggregations

TransferImageStatusParameters (org.ovirt.engine.core.common.action.TransferImageStatusParameters)11 ImageTransfer (org.ovirt.engine.core.common.businessentities.storage.ImageTransfer)10 ArrayList (java.util.ArrayList)4 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)4 Disk (org.ovirt.engine.core.common.businessentities.storage.Disk)4 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)3 Element (com.google.gwt.dom.client.Element)2 Request (com.google.gwt.http.client.Request)2 RequestBuilder (com.google.gwt.http.client.RequestBuilder)2 RequestCallback (com.google.gwt.http.client.RequestCallback)2 RequestException (com.google.gwt.http.client.RequestException)2 Response (com.google.gwt.http.client.Response)2 List (java.util.List)2 Logger (java.util.logging.Logger)2 ActionType (org.ovirt.engine.core.common.action.ActionType)2 AddDiskParameters (org.ovirt.engine.core.common.action.AddDiskParameters)2 TransferDiskImageParameters (org.ovirt.engine.core.common.action.TransferDiskImageParameters)2 StorageFormatType (org.ovirt.engine.core.common.businessentities.StorageFormatType)2 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)2 VDS (org.ovirt.engine.core.common.businessentities.VDS)2