From 876377736345419a21387106d278c4c5a9ed7f99 Mon Sep 17 00:00:00 2001 From: lily Date: Wed, 28 Sep 2016 17:33:32 +0800 Subject: [PATCH] fix no peer --- WebContent/WEB-INF/config/log4j-config.xml | 2 +- src/com/platform/glusterfs/ClusterInfo.java | 11 +++++++---- src/com/platform/utils/GanymedSSH.java | 4 ++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/WebContent/WEB-INF/config/log4j-config.xml b/WebContent/WEB-INF/config/log4j-config.xml index 801540e5..fb39773b 100644 --- a/WebContent/WEB-INF/config/log4j-config.xml +++ b/WebContent/WEB-INF/config/log4j-config.xml @@ -24,7 +24,7 @@ - + diff --git a/src/com/platform/glusterfs/ClusterInfo.java b/src/com/platform/glusterfs/ClusterInfo.java index 017efe41..df56469a 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"); @@ -51,9 +51,12 @@ public class ClusterInfo { log.error("1102 command get result is nothing"); return null; } - + + if (reStrings.get(0).contains("No peers present")) { + return peerIps; + } + if (!(reStrings.get(0).split(":")[0].contains("Number of Peers"))) { - log.error("1103 get result string wrong"); return null; } @@ -90,7 +93,7 @@ public class ClusterInfo { } } - peerIps.put(Constant.hostIp, Constant.peerincluster_connected); + // for (Map.Entry entry:peerIps.entrySet()){ // String key=entry.getKey(); // if(key.equals(Constant.hostIp)){ diff --git a/src/com/platform/utils/GanymedSSH.java b/src/com/platform/utils/GanymedSSH.java index 0571fc59..c7295702 100644 --- a/src/com/platform/utils/GanymedSSH.java +++ b/src/com/platform/utils/GanymedSSH.java @@ -123,7 +123,7 @@ public class GanymedSSH { BufferedReader stdoutReader = new BufferedReader(new InputStreamReader(stdout)); BufferedReader stderrReader = new BufferedReader(new InputStreamReader(stderr)); while (true) { - String line = stderrReader.readLine(); + String line = stdoutReader.readLine(); if (line != null) { // System.out.println(line); @@ -135,7 +135,7 @@ public class GanymedSSH { if(reStrings.size()==0){ while (true) { - String line = stdoutReader.readLine(); + String line = stderrReader.readLine(); if (line != null) { // System.out.println(line);