use of org.ovirt.engine.core.common.action.TransferImageStatusParameters in project ovirt-engine by oVirt.
the class DownloadImageHandler method closeSession.
private void closeSession(ImageTransferPhase imageTransferPhase, AuditLogType auditLogType) {
ImageTransfer updates = new ImageTransfer();
updates.setPhase(imageTransferPhase);
TransferImageStatusParameters parameters = new TransferImageStatusParameters();
parameters.setDiskId(diskImage.getId());
parameters.setUpdates(updates);
if (auditLogType != null) {
parameters.setAuditLogType(auditLogType);
}
Frontend.getInstance().runAction(ActionType.TransferImageStatus, parameters);
}
use of org.ovirt.engine.core.common.action.TransferImageStatusParameters in project ovirt-engine by oVirt.
the class UploadImageHandler method finalizeImageUpload.
private void finalizeImageUpload() {
if (getUploadState() == UploadState.ENGINE_PAUSE) {
// $NON-NLS-1$
log.info("Upload paused; stopping model execution");
return;
}
ImageTransfer updates = new ImageTransfer();
TransferImageStatusParameters statusParameters = new TransferImageStatusParameters(getCommandId(), updates);
if (getUploadState() == UploadState.SUCCESS) {
// $NON-NLS-1$
setProgressStr("Finalizing success...");
statusParameters.getUpdates().setPhase(ImageTransferPhase.FINALIZING_SUCCESS);
raiseUploadFinishedEvent(ImageTransferPhase.FINALIZING_SUCCESS);
} else if (getUploadState() == UploadState.CLIENT_ERROR) {
// $NON-NLS-1$
setProgressStr("Pausing due to client error");
statusParameters.getUpdates().setPhase(ImageTransferPhase.PAUSED_SYSTEM);
statusParameters.setDiskId(getDiskId());
statusParameters.setAuditLogType(auditLogType);
} else {
// $NON-NLS-1$
setProgressStr("Finalizing failure...");
statusParameters.getUpdates().setPhase(ImageTransferPhase.FINALIZING_FAILURE);
raiseUploadFinishedEvent(ImageTransferPhase.FINALIZING_FAILURE);
}
// $NON-NLS-1$
log.info("Updating status to " + statusParameters.getUpdates().getPhase());
Frontend.getInstance().runAction(ActionType.TransferImageStatus, statusParameters, result -> {
if (!result.getReturnValue().getSucceeded()) {
if (++failedFinalizationAttempts < MAX_FAILED_POLL_ATTEMPTS) {
finalizeImageUpload();
} else {
setContinuePolling(false);
// $NON-NLS-1$
setProgressStr("Failed to update upload status on engine");
}
}
});
}
use of org.ovirt.engine.core.common.action.TransferImageStatusParameters in project ovirt-engine by oVirt.
the class UploadImageHandler method initiateResumeUploadCheckStatus.
private void initiateResumeUploadCheckStatus(FrontendActionAsyncResult result) {
AsyncQuery<String> asyncQuery = (AsyncQuery<String>) result.getState();
if (result.getReturnValue() != null && result.getReturnValue().getSucceeded()) {
ImageTransfer rv = result.getReturnValue().getActionReturnValue();
if (rv.getBytesTotal() != getImageSize()) {
if (rv.getBytesTotal() == 0) {
// This upload was generated by the API.
asyncQuery.getAsyncCallback().onSuccess(messages.uploadImageFailedToResumeUploadOriginatedInAPI());
} else {
asyncQuery.getAsyncCallback().onSuccess(messages.uploadImageFailedToResumeSizeMessage(rv.getBytesTotal(), getImageSize()));
}
return;
}
// Resumable uploads already have a command running on engine, so get its id and resume it.
ImageTransfer updates = new ImageTransfer();
updates.setPhase(ImageTransferPhase.RESUMING);
TransferImageStatusParameters parameters = new TransferImageStatusParameters(rv.getId());
parameters.setUpdates(updates);
Frontend.getInstance().runAction(ActionType.TransferImageStatus, parameters, this::initiateResumeUploadStartTransfer);
} else {
setProgressStr(messages.uploadImageFailedToResumeMessage(result.getReturnValue().getDescription()));
}
asyncQuery.getAsyncCallback().onSuccess(null);
}
use of org.ovirt.engine.core.common.action.TransferImageStatusParameters in project ovirt-engine by oVirt.
the class UploadImageModel method pauseUploads.
public static void pauseUploads(List<? extends Disk> disks) {
ArrayList<ActionParametersBase> list = new ArrayList<>();
for (Disk disk : disks) {
ImageTransfer updates = new ImageTransfer();
updates.setPhase(ImageTransferPhase.PAUSED_USER);
TransferImageStatusParameters parameters = new TransferImageStatusParameters();
parameters.setUpdates(updates);
parameters.setDiskId(disk.getId());
list.add(parameters);
}
Frontend.getInstance().runMultipleAction(ActionType.TransferImageStatus, list);
}
use of org.ovirt.engine.core.common.action.TransferImageStatusParameters in project ovirt-engine by oVirt.
the class UploadImageModel method initiateResumeUpload.
private void initiateResumeUpload() {
TransferImageStatusParameters parameters = new TransferImageStatusParameters();
parameters.setDiskId(getDiskModel().getDisk().getId());
startProgress();
final UploadImageModel model = this;
UploadImageManager.getInstance().resumeUpload(getImageFileUploadElement(), parameters, new AsyncQuery<>(errorMessage -> {
model.stopProgress();
if (errorMessage != null) {
model.setMessage(errorMessage);
} else {
// Close dialog
model.getCancelCommand().execute();
}
}));
}
Aggregations