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