Frank Kobzik has uploaded a new change for review. Change subject: engine: Cache spice support for os/compatibility version ......................................................................
engine: Cache spice support for os/compatibility version Patch 31903bda17f97c2d785238b3d0d557d3c24f40b9 introduced detection of spice support on OSs and compatibility version. This detection implemented as an async query to OsRepository. This query is called from updateActionAvailability but the design requires the calls to be synchronous. This patch introduces caching spice support depending on all OSs and compatibility versions. Change-Id: Ib97d68ccd0d30fd07e8d1a7d1322f731aef220f7 Signed-off-by: Frantisek Kobzik <[email protected]> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/OsRepositoryQuery.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/osinfo/OsRepository.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/osinfo/OsRepositoryImpl.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/OsQueryParameters.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/ConsoleModelsCache.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmListModel.java 7 files changed, 54 insertions(+), 28 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/37/19137/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/OsRepositoryQuery.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/OsRepositoryQuery.java index 424ba0f..a277b0f 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/OsRepositoryQuery.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/OsRepositoryQuery.java @@ -39,6 +39,9 @@ case HasSpiceSupport: setReturnValue(osRepository.hasSpiceSupport(getParameters().getOsId(), getParameters().getVersion())); break; + case HasSpiceSupportMatrix: + setReturnValue(osRepository.hasSpiceSupportMatrix()); + break; case GetNetworkDevices: setReturnValue(osRepository.getNetworkDevices(getParameters().getOsId(), getParameters().getVersion())); break; diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/osinfo/OsRepository.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/osinfo/OsRepository.java index d18c98c..553ea19 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/osinfo/OsRepository.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/osinfo/OsRepository.java @@ -3,6 +3,7 @@ import java.util.ArrayList; import java.util.HashMap; +import java.util.Map; import org.ovirt.engine.core.compat.Version; /** @@ -69,6 +70,12 @@ */ public boolean hasSpiceSupport(int osId, Version version); + /** + * @return map (osId -> compatibility version -> true/false) that indicates SPICE support for all OSs and + * compatibility versions + */ + public Map<Integer, Map<Version, Boolean>> hasSpiceSupportMatrix(); + /** * this is Windows OSs specific path to the sysprep file * @param osId diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/osinfo/OsRepositoryImpl.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/osinfo/OsRepositoryImpl.java index 74877f6..242992a 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/osinfo/OsRepositoryImpl.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/osinfo/OsRepositoryImpl.java @@ -149,6 +149,22 @@ } @Override + public Map<Integer, Map<Version, Boolean>> hasSpiceSupportMatrix() { + Map<Integer, Map<Version, Boolean>> spiceSupportMatrix = new HashMap<Integer, Map<Version, Boolean>>(); + + for (Integer osId : getOsIds()) { + spiceSupportMatrix.put(osId, new HashMap<Version, Boolean>()); + + for (Version ver : Version.ALL) { + boolean spiceSupport = getBoolean(getValueByVersion(idToUnameLookup.get(osId), "spiceSupport", ver), false); + spiceSupportMatrix.get(osId).put(ver, spiceSupport); + } + } + + return spiceSupportMatrix; + } + + @Override public String getSysprepPath(int osId, Version version) { return getValueByVersion(idToUnameLookup.get(osId), "sysprepPath", version); } diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/OsQueryParameters.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/OsQueryParameters.java index 733f10f..fc5bccb 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/OsQueryParameters.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/OsQueryParameters.java @@ -39,6 +39,7 @@ public enum OsRepositoryVerb { HasSpiceSupport, + HasSpiceSupportMatrix, GetLinuxOss, GetOsIds, GetMinimumOsRam, diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java index c450bc8..749d8fd 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java @@ -10,7 +10,6 @@ import java.util.List; import java.util.Map; import java.util.MissingResourceException; - import org.ovirt.engine.core.common.AuditLogType; import org.ovirt.engine.core.common.EventNotificationEntity; import org.ovirt.engine.core.common.TimeZoneType; @@ -49,8 +48,6 @@ import org.ovirt.engine.core.common.businessentities.VmTemplateStatus; import org.ovirt.engine.core.common.businessentities.VolumeFormat; import org.ovirt.engine.core.common.businessentities.VolumeType; -import org.ovirt.engine.core.common.businessentities.permissions; -import org.ovirt.engine.core.common.businessentities.tags; import org.ovirt.engine.core.common.businessentities.comparators.NameableComparator; import org.ovirt.engine.core.common.businessentities.gluster.GlusterClusterService; import org.ovirt.engine.core.common.businessentities.gluster.GlusterHookEntity; @@ -63,6 +60,8 @@ import org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface; import org.ovirt.engine.core.common.businessentities.network.VnicProfile; import org.ovirt.engine.core.common.businessentities.network.VnicProfileView; +import org.ovirt.engine.core.common.businessentities.permissions; +import org.ovirt.engine.core.common.businessentities.tags; import org.ovirt.engine.core.common.interfaces.SearchType; import org.ovirt.engine.core.common.mode.ApplicationMode; import org.ovirt.engine.core.common.queries.CommandVersionsInfo; @@ -160,6 +159,9 @@ // cached windows OS private static List<Integer> windowsOsIds; + // cached os's support for SPICE (given compatibility version) + private static Map<Integer, Map<Version, Boolean>> spiceSupportForVersionAndOs; + public static String getDefaultConfigurationVersion() { return _defaultConfigurationVersion; } @@ -196,6 +198,7 @@ initUniqueOsNames(); initLinuxOsTypes(); initWindowsOsTypes(); + initHasSpiceSupport(); } public static void getDomainListViaPublic(AsyncQuery aQuery, boolean filterInternalDomain) { @@ -3081,10 +3084,19 @@ return osNames.get(osId); } - public static void hasSpiceSupport(int osId, Version version, AsyncQuery callback) { - Frontend.RunQuery(VdcQueryType.OsRepository, - new OsQueryParameters(OsRepositoryVerb.HasSpiceSupport, osId, version), - callback); + public static Boolean hasSpiceSupport(int osId, Version version) { + return spiceSupportForVersionAndOs.get(osId).get(version); + } + + private static void initHasSpiceSupport() { + AsyncQuery callback = new AsyncQuery(); + callback.asyncCallback = new INewAsyncCallback() { + @Override + public void onSuccess(Object model, Object returnValue) { + spiceSupportForVersionAndOs = ((VdcQueryReturnValue) returnValue).getReturnValue(); + } + }; + Frontend.RunQuery(VdcQueryType.OsRepository, new OsQueryParameters(OsRepositoryVerb.HasSpiceSupportMatrix), callback); } public static List<Integer> getOsIds() { diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/ConsoleModelsCache.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/ConsoleModelsCache.java index 90111fe..be99af6 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/ConsoleModelsCache.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/ConsoleModelsCache.java @@ -3,13 +3,9 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; - import org.ovirt.engine.core.common.businessentities.DisplayType; import org.ovirt.engine.core.common.businessentities.VM; -import org.ovirt.engine.core.common.queries.VdcQueryReturnValue; import org.ovirt.engine.core.compat.Guid; -import org.ovirt.engine.ui.frontend.AsyncQuery; -import org.ovirt.engine.ui.frontend.INewAsyncCallback; import org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider; import org.ovirt.engine.ui.uicommonweb.models.vms.ConsoleModel; import org.ovirt.engine.ui.uicommonweb.models.vms.ConsoleModelErrorEventListener; @@ -77,21 +73,13 @@ final boolean isWindowsExplorer = parentModel.getConfigurator().isClientWindowsExplorer(); - final AsyncQuery asyncQuery = new AsyncQuery(); - - asyncQuery.asyncCallback = new INewAsyncCallback() { - @Override - public void onSuccess(Object model, Object returnValue) { - Boolean hasSpiceSupport = (Boolean) ((VdcQueryReturnValue) returnValue).getReturnValue(); - if (isWindowsExplorer && hasSpiceSupport != null && hasSpiceSupport.booleanValue()) { - cachedModels.get(RDP_INDEX).setUserSelected(true); - } else { - determineConsoleModelFromVm(vm, cachedModels).setUserSelected(true); - } - setupSelectionContext(vm); - }}; - - AsyncDataProvider.hasSpiceSupport(vm.getOs(), vm.getVdsGroupCompatibilityVersion(), asyncQuery); + Boolean hasSpiceSupport = AsyncDataProvider.hasSpiceSupport(vm.getOs(), vm.getVdsGroupCompatibilityVersion()); + if (isWindowsExplorer && hasSpiceSupport != null && hasSpiceSupport.booleanValue()) { + cachedModels.get(RDP_INDEX).setUserSelected(true); + } else { + determineConsoleModelFromVm(vm, cachedModels).setUserSelected(true); + } + setupSelectionContext(vm); } private void deselectUserSelectedProtocol(Guid vmId) { diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmListModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmListModel.java index 6218f07..160aaef 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmListModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmListModel.java @@ -2291,8 +2291,7 @@ } } - private void updateActionAvailability() - { + private void updateActionAvailability() { List items = getSelectedItems() != null && getSelectedItem() != null ? getSelectedItems() : new ArrayList(); -- To view, visit http://gerrit.ovirt.org/19137 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ib97d68ccd0d30fd07e8d1a7d1322f731aef220f7 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Frank Kobzik <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
