web_backend_develope
lily 9 years ago
parent 9b311366a5
commit c647b81234

@ -39,7 +39,7 @@ public class ClusterInfo {
* @see [##] * @see [##]
*/ */
public Map<String, String> showClusterInfo() { public Map<String, String> showClusterInfo() {
log.info("get cluster info"); // log.info("get cluster info");
Map<String, String> peerIps = new HashMap<String, String>(); Map<String, String> peerIps = new HashMap<String, String>();
List<String> reStrings = Constant.ganymedSSH.execCmdWaitAcquiescent(Constant.glusterPeerStatus); List<String> reStrings = Constant.ganymedSSH.execCmdWaitAcquiescent(Constant.glusterPeerStatus);
@ -90,24 +90,28 @@ public class ClusterInfo {
} }
} }
for (Map.Entry<String, String> entry:peerIps.entrySet()){
String key=entry.getKey();
String value=entry.getValue();
if(Constant.ganymedSSH.otherConns==null){
Constant.ganymedSSH.otherConns=new HashMap<String,Connection>();
}
if(!Constant.ganymedSSH.otherConns.containsKey(key)){
Connection connection=null;
try {
connection = Constant.ganymedSSH.getOpenedConnection(key, Constant.rootUser, Constant.rootPasswd, Constant.port);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Constant.ganymedSSH.otherConns.put(key,connection);
}
}
peerIps.put(Constant.hostIp, Constant.peerincluster_connected); peerIps.put(Constant.hostIp, Constant.peerincluster_connected);
// for (Map.Entry<String, String> entry:peerIps.entrySet()){
// String key=entry.getKey();
// if(key.equals(Constant.hostIp)){
// continue;
// }
// String value=entry.getValue();
// if(Constant.ganymedSSH.otherConns==null){
// Constant.ganymedSSH.otherConns=new HashMap<String,Connection>();
// }
// if(!Constant.ganymedSSH.otherConns.containsKey(key)){
// Connection connection=null;
// try {
// connection = Constant.ganymedSSH.getOpenedConnection(key, Constant.rootUser, Constant.rootPasswd, Constant.port);
// } catch (IOException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// Constant.ganymedSSH.otherConns.put(key,connection);
// }
// }
return peerIps; return peerIps;
} }

@ -37,7 +37,7 @@ public class VolumeInfo {
* @see [##] * @see [##]
*/ */
public List<String> showAllVolumeName() { public List<String> showAllVolumeName() {
log.info(Constant.ganymedSSH+"get volume name"); // log.info(Constant.ganymedSSH+"get volume name");
List<String> volNames = new ArrayList<String>(); List<String> volNames = new ArrayList<String>();
/* /*
@ -46,8 +46,7 @@ public class VolumeInfo {
* runCommand = new RunCommand(); List<String> reStrings = * runCommand = new RunCommand(); List<String> reStrings =
* runCommand.runCommandWait(command); * runCommand.runCommandWait(command);
*/ */
Constant.ganymedSSH
.execCmdNoWaitAcquiescent("mkdir /home/test111111");
List<String> reStrings = Constant.ganymedSSH List<String> reStrings = Constant.ganymedSSH
.execCmdWaitAcquiescent(Constant.glusterVolumeInfo + "|grep ^Volume.Name"); .execCmdWaitAcquiescent(Constant.glusterVolumeInfo + "|grep ^Volume.Name");
// System.out.println(reStrings); // System.out.println(reStrings);

@ -68,7 +68,7 @@ public class ConfigsLoader implements ServletContextListener {
Constant.hostIp=properties.getProperty("gfs_control_ip").trim(); Constant.hostIp=properties.getProperty("gfs_control_ip").trim();
Constant.rootPasswd=properties.getProperty("gfs_control_rootPassWd").trim(); Constant.rootPasswd=properties.getProperty("gfs_control_rootPassWd").trim();
Constant.ganymedSSH = new GanymedSSH(Constant.hostIp, Constant.rootUser, Constant.rootPasswd, Constant.port); Constant.ganymedSSH = new GanymedSSH(Constant.hostIp, Constant.rootUser, Constant.rootPasswd, Constant.port);
Constant.ganymedSSH.otherConns=new HashMap<String,Connection>();
} }
public ConfigPropertyReader getcReader() { public ConfigPropertyReader getcReader() {

@ -36,6 +36,7 @@ public class GanymedSSH {
// TODO Auto-generated constructor stub // TODO Auto-generated constructor stub
try { try {
conn = getOpenedConnection(host, username, password, port); conn = getOpenedConnection(host, username, password, port);
otherConns=new HashMap<String,Connection>();
} catch (IOException e) { } catch (IOException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
@ -81,14 +82,17 @@ public class GanymedSSH {
Session sess = null; Session sess = null;
Connection new_conn; Connection new_conn;
try { try {
if(otherConns.containsKey(host) && otherConns.get(host)!=null){ if(Constant.hostIp.equals(host)){
new_conn=conn;
}
else if(otherConns.containsKey(host) && otherConns.get(host)!=null){
new_conn=otherConns.get(host); new_conn=otherConns.get(host);
} }
else{ else{
new_conn = getOpenedConnection(host, username, password, port); new_conn = getOpenedConnection(host, username, password, port);
otherConns.put(host, new_conn); otherConns.put(host, new_conn);
} }
sess = conn.openSession(); sess = new_conn.openSession();
// 执锟斤拷cmd // 执锟斤拷cmd
sess.execCommand(cmd); sess.execCommand(cmd);
} catch (IOException e) { } catch (IOException e) {
@ -157,14 +161,17 @@ public class GanymedSSH {
Session sess = null; Session sess = null;
Connection new_conn; Connection new_conn;
try { try {
if(otherConns.containsKey(host) && otherConns.get(host)!=null){ if(Constant.hostIp.equals(host)){
new_conn=conn;
}
else if(otherConns.containsKey(host) && otherConns.get(host)!=null){
new_conn=otherConns.get(host); new_conn=otherConns.get(host);
} }
else{ else{
new_conn = getOpenedConnection(host, username, password, port); new_conn = getOpenedConnection(host, username, password, port);
otherConns.put(host, new_conn); otherConns.put(host, new_conn);
} }
sess = conn.openSession(); sess = new_conn.openSession();
// 执锟斤拷cmd // 执锟斤拷cmd
sess.execCommand(cmd); sess.execCommand(cmd);

Loading…
Cancel
Save