web_backend_develope
lily 9 years ago
parent 9b311366a5
commit c647b81234

@ -39,7 +39,7 @@ public class ClusterInfo {
* @see [##]
*/
public Map<String, String> showClusterInfo() {
log.info("get cluster info");
// log.info("get cluster info");
Map<String, String> peerIps = new HashMap<String, String>();
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);
// 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;
}

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

@ -68,7 +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<String,Connection>();
}
public ConfigPropertyReader getcReader() {

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

Loading…
Cancel
Save