Sahina Bose has uploaded a new change for review.

Change subject: engine: Set brick port and pid when returned
......................................................................

engine: Set brick port and pid when returned

When gluster process is restarted, the gluster
CLI returns the brick port as NA. This causes
the VDS xml return handler to fail as the brick
port is expected as an integer value.

Added code to set the int values only if
returned correctly.
If brick port is N/A then brick's status should
be set offline.

Change-Id: I544b0aa4705b4bcde7638f15b5b235ba10deb3b1
Bug-Url: https://bugzilla.redhat.com/1036039
Signed-off-by: Sahina Bose <sab...@redhat.com>
---
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/gluster/GlusterVolumeStatusReturnForXmlRpc.java
1 file changed, 12 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/08/21908/1

diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/gluster/GlusterVolumeStatusReturnForXmlRpc.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/gluster/GlusterVolumeStatusReturnForXmlRpc.java
index 0839856..9cf085b 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/gluster/GlusterVolumeStatusReturnForXmlRpc.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/gluster/GlusterVolumeStatusReturnForXmlRpc.java
@@ -4,10 +4,12 @@
 import java.util.List;
 import java.util.Map;
 
+import org.apache.commons.lang.StringUtils;
 import org.ovirt.engine.core.common.businessentities.gluster.BrickDetails;
 import org.ovirt.engine.core.common.businessentities.gluster.BrickProperties;
 import 
org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity;
 import org.ovirt.engine.core.common.businessentities.gluster.GlusterClientInfo;
+import 
org.ovirt.engine.core.common.businessentities.gluster.GlusterServerService;
 import 
org.ovirt.engine.core.common.businessentities.gluster.GlusterServiceStatus;
 import org.ovirt.engine.core.common.businessentities.gluster.GlusterStatus;
 import 
org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeAdvancedDetails;
@@ -15,7 +17,6 @@
 import org.ovirt.engine.core.common.businessentities.gluster.MallInfo;
 import org.ovirt.engine.core.common.businessentities.gluster.MemoryStatus;
 import org.ovirt.engine.core.common.businessentities.gluster.Mempool;
-import 
org.ovirt.engine.core.common.businessentities.gluster.GlusterServerService;
 import org.ovirt.engine.core.common.businessentities.gluster.ServiceType;
 import org.ovirt.engine.core.common.utils.gluster.GlusterCoreUtil;
 import org.ovirt.engine.core.compat.Guid;
@@ -121,12 +122,12 @@
             String brickStatus = (String) volumeServiceInfo.get(STATUS);
             if (brickStatus.toUpperCase().equals(ONLINE)) {
                 serviceInfo.setStatus(GlusterServiceStatus.RUNNING);
-                // parse the port and pid only if the brick is online.
-                if (volumeServiceInfo.containsKey(PORT)) {
+                // parse the port and pid only if the service is running.
+                if (volumeServiceInfo.containsKey(PORT) && 
StringUtils.isNumeric((String)volumeServiceInfo.get(PORT))) {
                     serviceInfo.setPort(Integer.parseInt((String) 
volumeServiceInfo.get(PORT)));
                 }
 
-                if (volumeServiceInfo.containsKey(PID)) {
+                if (volumeServiceInfo.containsKey(PID) && 
StringUtils.isNumeric((String)volumeServiceInfo.get(PID))) {
                     serviceInfo.setPid(Integer.parseInt((String) 
volumeServiceInfo.get(PID)));
                 }
             } else {
@@ -176,9 +177,14 @@
                 brickProperties.setStatus(GlusterStatus.UP);
 
                 if (brick.containsKey(PORT)) {
-                    brickProperties.setPort(Integer.parseInt((String) 
brick.get(PORT)));
+                    if (StringUtils.isNumeric((String)brick.get(PORT))) {
+                        brickProperties.setPort(Integer.parseInt((String) 
brick.get(PORT)));
+                    } else {
+                        //if there's no port registered, then the brick status 
is down.
+                        brickProperties.setStatus(GlusterStatus.DOWN);
+                    }
                 }
-                if (brick.containsKey(PID)) {
+                if (brick.containsKey(PID) && 
StringUtils.isNumeric((String)brick.get(PID))) {
                     brickProperties.setPid(Integer.parseInt((String) 
brick.get(PID)));
                 }
             } else {


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

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

Reply via email to