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();
}
}
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);
}
Aggregations