Search in sources :

Example 11 with AsyncQuery

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);
}
Also used : HashMap(java.util.HashMap) Version(org.ovirt.engine.core.compat.Version) RpmVersion(org.ovirt.engine.core.compat.RpmVersion) AsyncQuery(org.ovirt.engine.ui.frontend.AsyncQuery) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) StorageServerConnectionQueryParametersBase(org.ovirt.engine.core.common.queries.StorageServerConnectionQueryParametersBase) ArrayList(java.util.ArrayList) List(java.util.List) MigrationPolicy(org.ovirt.engine.core.common.migration.MigrationPolicy) NoMigrationPolicy(org.ovirt.engine.core.common.migration.NoMigrationPolicy) Map(java.util.Map) HashMap(java.util.HashMap)

Example 12 with AsyncQuery

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());
}
Also used : ClusterParametersBase(org.ovirt.engine.core.common.action.ClusterParametersBase) StoragePoolParametersBase(org.ovirt.engine.core.common.action.StoragePoolParametersBase) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) StoragePoolStatus(org.ovirt.engine.core.common.businessentities.StoragePoolStatus) IEnlistmentNotification(org.ovirt.engine.ui.uicompat.IEnlistmentNotification) Linq(org.ovirt.engine.ui.uicommonweb.Linq) Guid(org.ovirt.engine.core.compat.Guid) PreparingEnlistment(org.ovirt.engine.ui.uicompat.PreparingEnlistment) StringHelper(org.ovirt.engine.core.compat.StringHelper) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) StoragePoolManagementParameter(org.ovirt.engine.core.common.action.StoragePoolManagementParameter) Objects(java.util.Objects) ActionType(org.ovirt.engine.core.common.action.ActionType) Frontend(org.ovirt.engine.ui.frontend.Frontend) VDSStatus(org.ovirt.engine.core.common.businessentities.VDSStatus) Enlistment(org.ovirt.engine.ui.uicompat.Enlistment) ChangeVDSClusterParameters(org.ovirt.engine.core.common.action.ChangeVDSClusterParameters) AsyncQuery(org.ovirt.engine.ui.frontend.AsyncQuery) DataCenterModel(org.ovirt.engine.ui.uicommonweb.models.datacenters.DataCenterModel) VDS(org.ovirt.engine.core.common.businessentities.VDS) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) VDS(org.ovirt.engine.core.common.businessentities.VDS) PreparingEnlistment(org.ovirt.engine.ui.uicompat.PreparingEnlistment) Enlistment(org.ovirt.engine.ui.uicompat.Enlistment)

Example 13 with AsyncQuery

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();
    }
}
Also used : VdsActionParameters(org.ovirt.engine.core.common.action.VdsActionParameters) StorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType) IEnlistmentNotification(org.ovirt.engine.ui.uicompat.IEnlistmentNotification) StorageDomainManagementParameter(org.ovirt.engine.core.common.action.StorageDomainManagementParameter) PreparingEnlistment(org.ovirt.engine.ui.uicompat.PreparingEnlistment) StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) ActionType(org.ovirt.engine.core.common.action.ActionType) Frontend(org.ovirt.engine.ui.frontend.Frontend) VDSStatus(org.ovirt.engine.core.common.businessentities.VDSStatus) Enlistment(org.ovirt.engine.ui.uicompat.Enlistment) StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) StorageServerConnectionParametersBase(org.ovirt.engine.core.common.action.StorageServerConnectionParametersBase) AsyncQuery(org.ovirt.engine.ui.frontend.AsyncQuery) StorageDomainType(org.ovirt.engine.core.common.businessentities.StorageDomainType) VDS(org.ovirt.engine.core.common.businessentities.VDS) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) Timer(com.google.gwt.user.client.Timer) VDS(org.ovirt.engine.core.common.businessentities.VDS) Timer(com.google.gwt.user.client.Timer) PreparingEnlistment(org.ovirt.engine.ui.uicompat.PreparingEnlistment)

Example 14 with AsyncQuery

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);
}
Also used : ImageTransfer(org.ovirt.engine.core.common.businessentities.storage.ImageTransfer) AsyncQuery(org.ovirt.engine.ui.frontend.AsyncQuery) TransferImageStatusParameters(org.ovirt.engine.core.common.action.TransferImageStatusParameters)

Example 15 with AsyncQuery

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);
}
Also used : QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) ConsoleOptionsParams(org.ovirt.engine.core.common.queries.ConsoleOptionsParams) AsyncQuery(org.ovirt.engine.ui.frontend.AsyncQuery)

Aggregations

AsyncQuery (org.ovirt.engine.ui.frontend.AsyncQuery)35 List (java.util.List)25 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)24 Guid (org.ovirt.engine.core.compat.Guid)24 Frontend (org.ovirt.engine.ui.frontend.Frontend)24 AsyncDataProvider (org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider)24 ArrayList (java.util.ArrayList)22 VmBase (org.ovirt.engine.core.common.businessentities.VmBase)21 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)21 VmTemplate (org.ovirt.engine.core.common.businessentities.VmTemplate)20 QueryType (org.ovirt.engine.core.common.queries.QueryType)20 Collection (java.util.Collection)19 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)19 Linq (org.ovirt.engine.ui.uicommonweb.Linq)19 BuilderExecutor (org.ovirt.engine.ui.uicommonweb.builders.BuilderExecutor)18 Arrays (java.util.Arrays)17 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)17 StringHelper (org.ovirt.engine.core.compat.StringHelper)17 VDS (org.ovirt.engine.core.common.businessentities.VDS)16 Collections (java.util.Collections)15