use of org.ovirt.engine.ui.frontend.AsyncQuery in project ovirt-engine by oVirt.
the class AsyncDataProvider method initMigrationPolicies.
private void initMigrationPolicies() {
AsyncQuery<Map<Version, List<MigrationPolicy>>> aQuery = new AsyncQuery<>(returnValue -> migrationPoliciesByVersion = returnValue);
aQuery.converterCallback = returnValue -> {
if (returnValue == null) {
return new HashMap<>();
}
Map<Version, List<MigrationPolicy>> policiesByVersion = (Map<Version, List<MigrationPolicy>>) returnValue;
for (List<MigrationPolicy> policies : policiesByVersion.values()) {
Collections.sort(policies, Comparator.comparing((MigrationPolicy m) -> !NoMigrationPolicy.ID.equals(m.getId())).thenComparing(MigrationPolicy::getName));
}
return policiesByVersion;
};
Frontend.getInstance().runQuery(QueryType.GetAllMigrationPolicies, new QueryParametersBase(), aQuery);
}
use of org.ovirt.engine.ui.frontend.AsyncQuery in project ovirt-engine by oVirt.
the class AddDataCenterRM method rollback2.
public void rollback2() {
Enlistment enlistment = context.enlistment;
EnlistmentContext enlistmentContext = (EnlistmentContext) enlistment.getContext();
HostListModel<?> model = enlistmentContext.getModel();
VDS host = model.getSelectedItem();
// Retrieve host to make sure we have an updated status etc.
AsyncDataProvider.getInstance().getHostById(new AsyncQuery<>(returnValue -> {
context.hostFoundById = returnValue;
rollback3();
}), host.getId());
}
use of org.ovirt.engine.ui.frontend.AsyncQuery in project ovirt-engine by oVirt.
the class AddStorageDomainRM method prepare3.
private void prepare3() {
PreparingEnlistment enlistment = (PreparingEnlistment) context.enlistment;
EnlistmentContext enlistmentContext = (EnlistmentContext) enlistment.getContext();
HostListModel<?> model = enlistmentContext.getModel();
VDS host = model.getSelectedItem();
if (context.waitTries < MaxWaitTries) {
context.waitTries++;
AsyncDataProvider.getInstance().getHostById(new AsyncQuery<>(returnValue -> {
context.host = returnValue;
timer = new Timer() {
@Override
public void run() {
prepare4();
}
};
timer.scheduleRepeating(WaitInterval);
}), host.getId());
} else {
context.enlistment = null;
enlistment.forceRollback();
}
}
use of org.ovirt.engine.ui.frontend.AsyncQuery 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.ui.frontend.AsyncQuery in project ovirt-engine by oVirt.
the class VncNativeImpl method invokeClient.
@Override
public void invokeClient() {
// todo avoid code duplication with spice
AsyncQuery<QueryReturnValue> callback = new AsyncQuery<>(returnValue -> // $NON-NLS-1$
ConsoleModel.makeConsoleConfigRequest(// $NON-NLS-1$
"console.vv", // $NON-NLS-1$
"application/x-virt-viewer; charset=UTF-8", returnValue.getReturnValue()));
Frontend.getInstance().runQuery(QueryType.GetConsoleDescriptorFile, new ConsoleOptionsParams(getOptions()), callback);
}
Aggregations