ofri masad has uploaded a new change for review.

Change subject: core: Fast init cache
......................................................................

core: Fast init cache

Add DB and backend support for fast cache initialize in QuotaManager

Change-Id: Id3db08957e413d2f1e0480b764334dd7268c8221
Bug-Url: https://bugzilla.redhat.com/??????
Signed-off-by: Ofri Masad <oma...@redhat.com>
---
M backend/manager/dbscripts/create_functions.sql
1 file changed, 53 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/59/10159/1

diff --git a/backend/manager/dbscripts/create_functions.sql 
b/backend/manager/dbscripts/create_functions.sql
index d804a71..3d57548 100644
--- a/backend/manager/dbscripts/create_functions.sql
+++ b/backend/manager/dbscripts/create_functions.sql
@@ -603,6 +603,59 @@
 LANGUAGE plpgsql;
 
 
+DROP TYPE IF EXISTS all_vds_group_usage_rs CASCADE;
+CREATE TYPE all_vds_group_usage_rs AS
+    (quota_vds_group_id UUID, quota_id UUID,vds_group_id UUID,vds_group_name 
character,virtual_cpu INTEGER,virtual_cpu_usage INTEGER,mem_size_mb 
BIGINT,mem_size_mb_usage BIGINT);
+
+
+-- Summarize the VCPU usage and the RAM usage for all the VMs in the quota 
which are not down or suspended
+-- If vds group id is null, then returns the global usage of the quota, other 
wise returns only the summarize of all VMs in the specific cluster.
+-- NOTE: VmDynamic status (0/13/14/15) must be persistent with UpdateVmCommand
+CREATE OR REPLACE FUNCTION CalculateAllVdsGroupUsage()
+RETURNS SETOF all_vds_group_usage_rs
+AS $function$
+SELECT
+        quota_limitation.id AS quota_vds_group_id,
+        quota.id as quota_id,
+        quota_limitation.vds_group_id as vds_group_id,
+        vds_groups.name AS vds_group_name,
+        quota_limitation.virtual_cpu,
+        cast(COALESCE(sum(num_of_sockets * cpu_per_socket), 0) as INTEGER) as 
virtual_cpu_usage,
+        quota_limitation.mem_size_mb,
+        COALESCE(sum(vm_static.mem_size_mb), 0) as mem_size_mb_usage
+    FROM vm_static, vm_dynamic, quota, quota_limitation, vds_groups
+    WHERE vm_static.quota_id = quota.id
+      AND quota_limitation.quota_id = quota.id
+      AND vm_dynamic.vm_guid = vm_static.vm_guid
+      AND vm_dynamic.status not in (0, 13 , 14, 15)
+      AND vds_groups.vds_group_id = vm_static.vds_group_id
+      AND quota_limitation.virtual_cpu IS NOT NULL
+      AND quota_limitation.mem_size_mb IS NOT NULL
+    GROUP BY quota.id, vds_groups.vds_group_id, vm_static.vds_group_id, 
quota_limitation.id;
+END; $function$
+LANGUAGE plpgsql;
+
+
+
+DROP TYPE IF EXISTS all_storage_usage_rs CASCADE;
+CREATE TYPE all_storage_usage_rs AS
+    (quota_id UUID,storage_domain_id UUID,storage_usage double precision);
+
+
+CREATE OR REPLACE FUNCTION CalculateAllStorageUsage()
+RETURNS SETOF all_storage_usage_rs
+AS $function$
+BEGIN
+    -- Summarize size of all disks that are active.
+    RETURN QUERY SELECT COALESCE(sum(size * cast(active as integer) + 
disk_image_dynamic.actual_size * cast((not active) as integer)) / (1024 * 1024 
* 1024),0) as storage_usage, images.quota_id as quota_id, 
image_storage_domain_map.storage_domain_id as storage_id
+    FROM images, disk_image_dynamic, image_storage_domain_map
+    WHERE image_guid = disk_image_dynamic.image_id
+       AND images.image_guid = image_storage_domain_map.image_id
+    GROUP BY quota_id, storage_domain_id;
+END; $function$
+LANGUAGE plpgsql;
+
+
 -- Summarize the storage usage for all the disks in the quota
 -- For active disks, we summarize the full size and for snapshots and other 
disks, we summarize only the actual size.
 -- If v_storage_id is null, then return only the global usage of the quota, 
other wise return only the summarize in the specific storage.


--
To view, visit http://gerrit.ovirt.org/10159
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id3db08957e413d2f1e0480b764334dd7268c8221
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: ofri masad <oma...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to