Shubhendu Tripathi has uploaded a new change for review.

Change subject: gluster: Matrix for cluster level swift status
......................................................................

gluster: Matrix for cluster level swift status

Created a matrix which decides the cosolidated swift status at cluster
level during sync job.

This fixes various descrepencies in overall status of swift services at
cluster level.

Change-Id: Iffa4af8f3a6dfed4b153f56c52eaef1fddeb5038
Bug-Url: https://bugzilla.redhat.com/973622
Signed-off-by: Shubhendu Tripathi <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterServiceSyncJob.java
M 
backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/GlusterServiceSyncJobTest.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/GlusterServiceStatus.java
3 files changed, 55 insertions(+), 11 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/76/15976/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterServiceSyncJob.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterServiceSyncJob.java
index 99beab2..f16b14f 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterServiceSyncJob.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterServiceSyncJob.java
@@ -131,10 +131,16 @@
             if (foundStatus == null) {
                 fetchedServiceTypeStatusMap.put(type, status);
             } else if (foundStatus != status) {
-                fetchedServiceTypeStatusMap.put(type, 
GlusterServiceStatus.MIXED);
+                GlusterServiceStatus finalStatus = getFinalStatus(status, 
foundStatus);
+                fetchedServiceTypeStatusMap.put(type, finalStatus);
             }
         }
         return fetchedServiceTypeStatusMap;
+    }
+
+    private GlusterServiceStatus getFinalStatus(GlusterServiceStatus 
firstStatus, GlusterServiceStatus secondStatus) {
+        String compositeErrorCode = firstStatus.getErrorCode() + "" + 
secondStatus.getErrorCode();
+        return compositeStatusMap.get(compositeErrorCode);
     }
 
     private Map<String, GlusterServiceStatus> 
mergeServiceStatusMaps(List<Map<String, GlusterServiceStatus>> 
serviceStatusMaps) {
@@ -147,7 +153,8 @@
                 if (alreadyFoundStatus == null) {
                     mergedServiceStatusMap.put(serviceName, status);
                 } else if (alreadyFoundStatus != status && alreadyFoundStatus 
!= GlusterServiceStatus.MIXED) {
-                    mergedServiceStatusMap.put(serviceName, 
GlusterServiceStatus.MIXED);
+                    GlusterServiceStatus finalStatus = getFinalStatus(status, 
alreadyFoundStatus);
+                    mergedServiceStatusMap.put(serviceName, finalStatus);
                 }
             }
         }
@@ -341,4 +348,34 @@
     protected Map<String, GlusterService> getServiceNameMap() {
         return serviceNameMap;
     }
+
+    private static final Map<String, GlusterServiceStatus> compositeStatusMap 
= new HashMap<String, GlusterServiceStatus>() {
+        {
+            put("11", GlusterServiceStatus.RUNNING);
+            put("12", GlusterServiceStatus.MIXED);
+            put("14", GlusterServiceStatus.RUNNING);
+            put("15", GlusterServiceStatus.MIXED);
+            put("16", GlusterServiceStatus.RUNNING);
+            put("21", GlusterServiceStatus.MIXED);
+            put("22", GlusterServiceStatus.STOPPED);
+            put("24", GlusterServiceStatus.STOPPED);
+            put("25", GlusterServiceStatus.MIXED);
+            put("26", GlusterServiceStatus.STOPPED);
+            put("41", GlusterServiceStatus.RUNNING);
+            put("42", GlusterServiceStatus.STOPPED);
+            put("44", GlusterServiceStatus.NOT_AVAILABLE);
+            put("45", GlusterServiceStatus.MIXED);
+            put("46", GlusterServiceStatus.UNKNOWN);
+            put("51", GlusterServiceStatus.MIXED);
+            put("52", GlusterServiceStatus.MIXED);
+            put("54", GlusterServiceStatus.MIXED);
+            put("55", GlusterServiceStatus.MIXED);
+            put("56", GlusterServiceStatus.MIXED);
+            put("61", GlusterServiceStatus.RUNNING);
+            put("62", GlusterServiceStatus.STOPPED);
+            put("64", GlusterServiceStatus.UNKNOWN);
+            put("65", GlusterServiceStatus.MIXED);
+            put("66", GlusterServiceStatus.UNKNOWN);
+        }
+    };
 }
diff --git 
a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/GlusterServiceSyncJobTest.java
 
b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/GlusterServiceSyncJobTest.java
index 24d349f..b7dd52f 100644
--- 
a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/GlusterServiceSyncJobTest.java
+++ 
b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/GlusterServiceSyncJobTest.java
@@ -280,9 +280,6 @@
 
         // One update on serverServiceDao to update statuses of all services 
of server1
         verify(serverServiceDao, 
times(1)).updateAll(argThat(isCollectionOfServicesOfServer1WithStatusUnknown()));
-
-        // two updates on clusterServiceDao to update status of each service 
type to MIXED
-        verify(clusterServiceDao, 
times(2)).update(argThat(isClusterServiceWithMixedStatus()));
     }
 
     private void verifyWithChanges() {
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/GlusterServiceStatus.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/GlusterServiceStatus.java
index 04a3c5e..9f3f8b1 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/GlusterServiceStatus.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/GlusterServiceStatus.java
@@ -4,11 +4,21 @@
  * Enum for status of gluster related services
  */
 public enum GlusterServiceStatus {
-    RUNNING,
-    STOPPED,
-    ERROR, // when service status command is failed in vdsm
-    NOT_AVAILABLE, // service is not installed in the host
-    MIXED, // cluster-wide status, few up, few down
-    UNKNOWN, // Couldn't fetch status
+    RUNNING(1),
+    STOPPED(2),
+    ERROR(3), // when service status command is failed in vdsm
+    NOT_AVAILABLE(4), // service is not installed in the host
+    MIXED(5), // cluster-wide status, few up, few down
+    UNKNOWN(6), // Couldn't fetch status
     ;
+
+    private int errorCode;
+
+    private GlusterServiceStatus(int code) {
+        errorCode = code;
+    }
+
+    public int getErrorCode() {
+        return errorCode;
+    }
 }


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iffa4af8f3a6dfed4b153f56c52eaef1fddeb5038
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Shubhendu Tripathi <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to