From 9b311366a59be250eb1c7d8eccb8b89494805608 Mon Sep 17 00:00:00 2001 From: lily Date: Wed, 28 Sep 2016 09:10:33 +0800 Subject: [PATCH] fix otherConn null --- src/com/platform/glusterfs/ClusterInfo.java | 7 +++++-- src/com/platform/utils/ConfigsLoader.java | 4 ++++ src/com/platform/utils/Constant.java | 1 + 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/com/platform/glusterfs/ClusterInfo.java b/src/com/platform/glusterfs/ClusterInfo.java index 3f0eefd3..8b418e58 100644 --- a/src/com/platform/glusterfs/ClusterInfo.java +++ b/src/com/platform/glusterfs/ClusterInfo.java @@ -41,7 +41,7 @@ public class ClusterInfo { public Map showClusterInfo() { log.info("get cluster info"); Map peerIps = new HashMap(); - peerIps.put(Constant.hostIp, Constant.peerincluster_connected); + List reStrings = Constant.ganymedSSH.execCmdWaitAcquiescent(Constant.glusterPeerStatus); if (reStrings == null) { log.error("1101 command get result is null"); @@ -93,6 +93,9 @@ public class ClusterInfo { for (Map.Entry entry:peerIps.entrySet()){ String key=entry.getKey(); String value=entry.getValue(); + if(Constant.ganymedSSH.otherConns==null){ + Constant.ganymedSSH.otherConns=new HashMap(); + } if(!Constant.ganymedSSH.otherConns.containsKey(key)){ Connection connection=null; try { @@ -104,7 +107,7 @@ public class ClusterInfo { Constant.ganymedSSH.otherConns.put(key,connection); } } - + peerIps.put(Constant.hostIp, Constant.peerincluster_connected); return peerIps; } diff --git a/src/com/platform/utils/ConfigsLoader.java b/src/com/platform/utils/ConfigsLoader.java index 6976a098..4b0f703f 100644 --- a/src/com/platform/utils/ConfigsLoader.java +++ b/src/com/platform/utils/ConfigsLoader.java @@ -1,10 +1,13 @@ package com.platform.utils; +import java.util.HashMap; import java.util.Properties; import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; +import ch.ethz.ssh2.Connection; + public class ConfigsLoader implements ServletContextListener { private static ConfigPropertyReader cReader = null; @@ -65,6 +68,7 @@ public class ConfigsLoader implements ServletContextListener { Constant.hostIp=properties.getProperty("gfs_control_ip").trim(); Constant.rootPasswd=properties.getProperty("gfs_control_rootPassWd").trim(); Constant.ganymedSSH = new GanymedSSH(Constant.hostIp, Constant.rootUser, Constant.rootPasswd, Constant.port); + Constant.ganymedSSH.otherConns=new HashMap(); } public ConfigPropertyReader getcReader() { diff --git a/src/com/platform/utils/Constant.java b/src/com/platform/utils/Constant.java index 00ccccd4..1f283d67 100644 --- a/src/com/platform/utils/Constant.java +++ b/src/com/platform/utils/Constant.java @@ -1,6 +1,7 @@ package com.platform.utils; +import java.util.HashMap; public class Constant { public static String rootUser = "root";