Search in sources :

Example 21 with ImageTransfer

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

the class UploadImageHandler method respondToPollStatus.

private void respondToPollStatus(FrontendActionAsyncResult result) {
    if (result.getReturnValue() != null && result.getReturnValue().getSucceeded()) {
        ImageTransfer rv = result.getReturnValue().getActionReturnValue();
        // $NON-NLS-1$
        log.info("Upload phase: " + rv.getPhase().toString());
        switch(rv.getPhase()) {
            case UNKNOWN:
                // The job may have failed and removed the entity
                pollingFailed();
                return;
            case INITIALIZING:
            case RESUMING:
                break;
            case TRANSFERRING:
                if (getUploadState() == UploadState.NEW) {
                    setVdsId(rv.getVdsId());
                    setDiskId(rv.getDiskId());
                    setImageTicketId(rv.getImagedTicketId());
                    String proxyURI = rv.getProxyUri();
                    String signedTicket = rv.getSignedTicket();
                    int chunkSizeKB = AsyncDataProvider.getInstance().getUploadImageChunkSizeKB();
                    int xhrTimeoutSec = AsyncDataProvider.getInstance().getUploadImageXhrTimeoutInSeconds();
                    int xhrRetryIntervalSec = AsyncDataProvider.getInstance().getUploadImageXhrRetryIntervalInSeconds();
                    int maxRetries = AsyncDataProvider.getInstance().getUploadImageXhrMaxRetries();
                    // Start upload task
                    setUploadState(UploadState.INITIALIZING);
                    // $NON-NLS-1$
                    setProgressStr("Uploading from byte " + getBytesSent());
                    startUpload(getFileUploadElement(), proxyURI, getImageTicketId().toString(), getBytesSent(), getBytesEndOffset(), signedTicket, chunkSizeKB, xhrTimeoutSec, xhrRetryIntervalSec, maxRetries);
                }
                break;
            case PAUSED_USER:
            case PAUSED_SYSTEM:
                setContinuePolling(false);
                setUploadState(UploadState.ENGINE_PAUSE);
                break;
            // In this case, the default case is reached which does largely the same thing.
            case CANCELLED:
            case FINALIZING_SUCCESS:
            case FINALIZING_FAILURE:
            case FINISHED_SUCCESS:
            case FINISHED_FAILURE:
                // $NON-NLS-1$
                log.info("Upload task terminating");
                setContinuePolling(false);
                stopJsUpload(UploadState.ENGINE_CANCEL);
                break;
            default:
                // $NON-NLS-1$
                log.info("Unknown upload status from backend, job is likely complete");
                setContinuePolling(false);
                stopJsUpload(UploadState.CLIENT_ERROR);
                break;
        }
        failedPollAttempts = 0;
    } else {
        // $NON-NLS-1$
        log.info("No poll result for upload status");
        pollingFailed();
    }
}
Also used : ImageTransfer(org.ovirt.engine.core.common.businessentities.storage.ImageTransfer)

Example 22 with ImageTransfer

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

the class UploadImageModel method onCancelUpload.

public static void onCancelUpload(ConfirmationModel model, List<? extends Disk> disks) {
    if (model.getProgress() != null) {
        return;
    }
    model.startProgress(null);
    ArrayList<ActionParametersBase> list = new ArrayList<>();
    for (Disk disk : disks) {
        ImageTransfer updates = new ImageTransfer();
        updates.setPhase(ImageTransferPhase.CANCELLED);
        TransferImageStatusParameters parameters = new TransferImageStatusParameters();
        parameters.setUpdates(updates);
        parameters.setDiskId(disk.getId());
        list.add(parameters);
    }
    Frontend.getInstance().runMultipleAction(ActionType.TransferImageStatus, list, result -> {
        ConfirmationModel localModel = (ConfirmationModel) result.getState();
        localModel.stopProgress();
        // parent.cancel();
        localModel.getCancelCommand().execute();
    }, model);
}
Also used : ImageTransfer(org.ovirt.engine.core.common.businessentities.storage.ImageTransfer) ArrayList(java.util.ArrayList) TransferImageStatusParameters(org.ovirt.engine.core.common.action.TransferImageStatusParameters) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase)

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