Merge branch 'web_backend_develope' of

https://git.trustie.net/fhx569287825/aggregation-platform into
web_backend_develope

Conflicts:
	src/com/platform/utils/GanymedSSH.java
web_backend_develope
chenlw 9 years ago
commit a9b94717c1

@ -37,5 +37,6 @@
<nature>org.eclipse.wst.common.project.facet.core.nature</nature> <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature> <nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.wst.jsdt.core.jsNature</nature> <nature>org.eclipse.wst.jsdt.core.jsNature</nature>
<nature>com.sysdeo.eclipse.tomcat.tomcatnature</nature>
</natures> </natures>
</projectDescription> </projectDescription>

@ -4,7 +4,7 @@
# 驱动程序 # 驱动程序
jdbc.mysql.driver=com.mysql.jdbc.Driver jdbc.mysql.driver=com.mysql.jdbc.Driver
# 连接url # 连接url
jdbc.mysql.url=jdbc:mysql://192.168.0.110:3306/ftpdata?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true jdbc.mysql.url=jdbc:mysql://127.0.0.1:3306/extend_glusterfs?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true
# 用户名 # 用户名
jdbc.mysql.username=root jdbc.mysql.username=root
# 密码 # 密码
@ -43,9 +43,14 @@ jdbc.minEvictableIdleTimeMillis=300000
table-suffix=_20152016 table-suffix=_20152016
extract-log-localtion=/home/web_manage/log/ extract-log-localtion=/home/web_manage/log/
gather-tablespace-name=TS_TTSSS gather-tablespace-name=TS_TTSSS
gather-tablespace-path=1
gather-table-user-password=1 gather-tablespace-path=
kubeMasterUrl=http://192.168.0.110:8080/ gather-table-user-password=
kubeMasterUrl=http://192.168.191.23:8080/
collect-user-name=system collect-user-name=system
collect-password=oracle collect-password=oracle
collect-service-name=orcl collect-service-name=orcl
gfs_control_ip=192.168.191.23
gfs_control_rootPassWd=root

@ -5,6 +5,7 @@ package com.platform.glusterfs;
import java.io.File; import java.io.File;
import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
@ -16,6 +17,8 @@ import org.apache.log4j.PropertyConfigurator;
import com.platform.utils.Constant; import com.platform.utils.Constant;
import ch.ethz.ssh2.Connection;
/** /**
* *
* @author liliy * @author liliy
@ -32,10 +35,11 @@ public class ClusterInfo {
* ipPeerinCluster(Connected) * ipPeerinCluster(Connected)
* ipPeerinCluster(Disconnected) * ipPeerinCluster(Disconnected)
* @return * @return
* @throws IOException
* @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>();
peerIps.put(Constant.hostIp, Constant.peerincluster_connected); peerIps.put(Constant.hostIp, Constant.peerincluster_connected);
List<String> reStrings = Constant.ganymedSSH.execCmdWaitAcquiescent(Constant.glusterPeerStatus); List<String> reStrings = Constant.ganymedSSH.execCmdWaitAcquiescent(Constant.glusterPeerStatus);
@ -86,6 +90,20 @@ public class ClusterInfo {
} }
} }
for (Map.Entry<String, String> entry:peerIps.entrySet()){
String key=entry.getKey();
String value=entry.getValue();
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("get volume name"); log.info(Constant.ganymedSSH+"get volume name");
List<String> volNames = new ArrayList<String>(); List<String> volNames = new ArrayList<String>();
/* /*
@ -46,6 +46,8 @@ 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);

@ -60,6 +60,11 @@ public class ConfigsLoader implements ServletContextListener {
.getProperty("gather-tablespace-path"); .getProperty("gather-tablespace-path");
Configs.GATHER_TABLE_PASSWORD=properties.getProperty("gather-table-user-password"); Configs.GATHER_TABLE_PASSWORD=properties.getProperty("gather-table-user-password");
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);
} }
public ConfigPropertyReader getcReader() { public ConfigPropertyReader getcReader() {

@ -5,8 +5,8 @@ package com.platform.utils;
public class Constant { public class Constant {
public static String rootUser = "root"; public static String rootUser = "root";
public static String rootPasswd = "root"; public static String rootPasswd = "root";
public static String hostIp = "192.168.0.110"; // public static String hostIp = "192.168.191.23";
// public static String hostIp = "192.168.1.105"; public static String hostIp = "";
public static int port = 22; public static int port = 22;
public static String glusterPeerStatus = "gluster peer status"; public static String glusterPeerStatus = "gluster peer status";
public static String glusterVolumeInfo = "gluster volume info "; public static String glusterVolumeInfo = "gluster volume info ";
@ -21,7 +21,7 @@ public class Constant {
public static String success = "success"; public static String success = "success";
public static String failed = "failed"; public static String failed = "failed";
public static String noSuchFile = "No such file or directory"; public static String noSuchFile = "No such file or directory";
public static GanymedSSH ganymedSSH = new GanymedSSH(hostIp, rootUser, rootPasswd, port); public static GanymedSSH ganymedSSH = null;
public static String fileGetTreeData = "WebContent\\WEB-INF\\config\\getTreedata.sh"; public static String fileGetTreeData = "WebContent\\WEB-INF\\config\\getTreedata.sh";
public static String AutoMountfile="/gfsAutoMount/AutoRun.sh"; public static String AutoMountfile="/gfsAutoMount/AutoRun.sh";
public static String MountRecord="/gfsAutoMount/mountPoint.record"; public static String MountRecord="/gfsAutoMount/mountPoint.record";

@ -24,7 +24,7 @@ import ch.ethz.ssh2.*;
public class GanymedSSH { public class GanymedSSH {
public static Logger log = Logger.getLogger(GanymedSSH.class); public static Logger log = Logger.getLogger(GanymedSSH.class);
Connection conn; Connection conn;
public Map<String, Connection> otherConns;
public boolean status = true;// 锟角凤拷锟斤拷锟街达拷锟斤拷锟斤拷锟阶刺<E998B6> public boolean status = true;// 锟角凤拷锟斤拷锟街达拷锟斤拷锟斤拷锟阶刺<E998B6>
public GanymedSSH() { public GanymedSSH() {
@ -44,22 +44,22 @@ public class GanymedSSH {
} }
public Connection getOpenedConnection(String host, String username, String password, int port) public static Connection getOpenedConnection(String host, String username, String password, int port)
throws IOException { throws IOException {
conn = new Connection(host, port); Connection conns = new Connection(host, port);
conn.connect(); // make sure the connection is opened conns.connect(); // make sure the connection is opened
boolean isAuthenticated = conn.authenticateWithPassword(username, password); boolean isAuthenticated = conns.authenticateWithPassword(username, password);
if (isAuthenticated == false) if (isAuthenticated == false)
throw new IOException("Authentication failed."); throw new IOException("Authentication failed.");
return conn; return conns;
} }
public void execCmdNoWaitAcquiescent(String cmd) { public void execCmdNoWaitAcquiescent(String cmd) {
String host=Constant.hostIp; // String host=Constant.hostIp;
String username=Constant.rootUser; // String username=Constant.rootUser;
String password=Constant.rootPasswd; // String password=Constant.rootPasswd;
int port=Constant.port; // int port=Constant.port;
Session sess = null; Session sess = null;
try { try {
@ -79,8 +79,15 @@ public class GanymedSSH {
public void execCmdNoWait(String host, String username, String password, int port, String cmd) { public void execCmdNoWait(String host, String username, String password, int port, String cmd) {
Session sess = null; Session sess = null;
Connection new_conn;
try { try {
conn = getOpenedConnection(host, username, password, port); 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 = conn.openSession();
// 执锟斤拷cmd // 执锟斤拷cmd
sess.execCommand(cmd); sess.execCommand(cmd);
@ -94,10 +101,10 @@ public class GanymedSSH {
} }
public List<String> execCmdWaitAcquiescent(String cmd) { public List<String> execCmdWaitAcquiescent(String cmd) {
String host=Constant.hostIp; // String host=Constant.hostIp;
String username=Constant.rootUser; // String username=Constant.rootUser;
String password=Constant.rootPasswd; // String password=Constant.rootPasswd;
int port=Constant.port; // int port=Constant.port;
List<String> reStrings = new ArrayList<String>(); List<String> reStrings = new ArrayList<String>();
Session sess = null; Session sess = null;
@ -148,8 +155,15 @@ public class GanymedSSH {
List<String> reStrings = new ArrayList<String>(); List<String> reStrings = new ArrayList<String>();
Session sess = null; Session sess = null;
Connection new_conn;
try { try {
// conn = getOpenedConnection(host, username, password, port); 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 = conn.openSession();
// 执锟斤拷cmd // 执锟斤拷cmd
sess.execCommand(cmd); sess.execCommand(cmd);

Loading…
Cancel
Save