diff --git a/.project b/.project
index c9ff485b..766e275f 100644
--- a/.project
+++ b/.project
@@ -37,5 +37,6 @@
org.eclipse.wst.common.project.facet.core.nature
org.eclipse.jdt.core.javanature
org.eclipse.wst.jsdt.core.jsNature
+ com.sysdeo.eclipse.tomcat.tomcatnature
diff --git a/WebContent/WEB-INF/config/config.properties b/WebContent/WEB-INF/config/config.properties
index 3a1999a8..7381d79d 100644
--- a/WebContent/WEB-INF/config/config.properties
+++ b/WebContent/WEB-INF/config/config.properties
@@ -4,7 +4,7 @@
# 驱动程序
jdbc.mysql.driver=com.mysql.jdbc.Driver
# 连接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
# 密码
@@ -43,9 +43,14 @@ jdbc.minEvictableIdleTimeMillis=300000
table-suffix=_20152016
extract-log-localtion=/home/web_manage/log/
gather-tablespace-name=TS_TTSSS
-gather-tablespace-path=1
-gather-table-user-password=1
-kubeMasterUrl=http://192.168.0.110:8080/
+
+gather-tablespace-path=
+gather-table-user-password=
+kubeMasterUrl=http://192.168.191.23:8080/
+
collect-user-name=system
collect-password=oracle
collect-service-name=orcl
+
+gfs_control_ip=192.168.191.23
+gfs_control_rootPassWd=root
\ No newline at end of file
diff --git a/src/com/platform/glusterfs/ClusterInfo.java b/src/com/platform/glusterfs/ClusterInfo.java
index 982ed6bf..91030a01 100644
--- a/src/com/platform/glusterfs/ClusterInfo.java
+++ b/src/com/platform/glusterfs/ClusterInfo.java
@@ -5,6 +5,7 @@ package com.platform.glusterfs;
import java.io.File;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
@@ -16,6 +17,8 @@ import org.apache.log4j.PropertyConfigurator;
import com.platform.utils.Constant;
+import ch.ethz.ssh2.Connection;
+
/**
* 获取集群信息
* @author liliy
@@ -32,10 +35,11 @@ public class ClusterInfo {
* 如果ip在集群中且联通状态为PeerinCluster(Connected)
* 如果ip在集群中且但不连通为PeerinCluster(Disconnected)
* @return
+ * @throws IOException
* @see [类、类#方法、类#成员]
*/
public Map showClusterInfo() {
-// log.info("get cluster info");
+ log.info("get cluster info");
Map peerIps = new HashMap();
peerIps.put(Constant.hostIp, Constant.peerincluster_connected);
List reStrings = Constant.ganymedSSH.execCmdWaitAcquiescent(Constant.glusterPeerStatus);
@@ -86,6 +90,20 @@ public class ClusterInfo {
}
}
+ for (Map.Entry 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;
}
diff --git a/src/com/platform/glusterfs/VolumeInfo.java b/src/com/platform/glusterfs/VolumeInfo.java
index f3583102..d090b21e 100644
--- a/src/com/platform/glusterfs/VolumeInfo.java
+++ b/src/com/platform/glusterfs/VolumeInfo.java
@@ -37,7 +37,7 @@ public class VolumeInfo {
* @see [类、类#方法、类#成员]
*/
public List showAllVolumeName() {
-// log.info("get volume name");
+ log.info(Constant.ganymedSSH+"get volume name");
List volNames = new ArrayList();
/*
@@ -46,6 +46,8 @@ public class VolumeInfo {
* runCommand = new RunCommand(); List reStrings =
* runCommand.runCommandWait(command);
*/
+ Constant.ganymedSSH
+ .execCmdNoWaitAcquiescent("mkdir /home/test111111");
List reStrings = Constant.ganymedSSH
.execCmdWaitAcquiescent(Constant.glusterVolumeInfo + "|grep ^Volume.Name");
// System.out.println(reStrings);
diff --git a/src/com/platform/utils/ConfigsLoader.java b/src/com/platform/utils/ConfigsLoader.java
index 0f4490b0..6976a098 100644
--- a/src/com/platform/utils/ConfigsLoader.java
+++ b/src/com/platform/utils/ConfigsLoader.java
@@ -60,6 +60,11 @@ public class ConfigsLoader implements ServletContextListener {
.getProperty("gather-tablespace-path");
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() {
diff --git a/src/com/platform/utils/Constant.java b/src/com/platform/utils/Constant.java
index 98066dc3..00ccccd4 100644
--- a/src/com/platform/utils/Constant.java
+++ b/src/com/platform/utils/Constant.java
@@ -1,49 +1,49 @@
-
-package com.platform.utils;
-
-
-public class Constant {
- public static String rootUser = "root";
- public static String rootPasswd = "root";
- public static String hostIp = "192.168.0.110";
- // public static String hostIp = "192.168.1.105";
- public static int port = 22;
- public static String glusterPeerStatus = "gluster peer status";
- public static String glusterVolumeInfo = "gluster volume info ";
- public static String df = "df -k ";
- public static String peerincluster_connected = "PeerinCluster(Connected)";
- public static String peerincluster_disconnected = "PeerinCluster(Disconnected)";
- public static String peerNotinCluster = "PeerNotinCluster";
- public static String distributed = "distributed";
- public static String replica = "replica";
- public static String stripe = "stripe";
- public static String noVolume = "No volumes present";
- public static String success = "success";
- public static String failed = "failed";
- public static String noSuchFile = "No such file or directory";
- public static GanymedSSH ganymedSSH = new GanymedSSH(hostIp, rootUser, rootPasswd, port);
- public static String fileGetTreeData = "WebContent\\WEB-INF\\config\\getTreedata.sh";
- public static String AutoMountfile="/gfsAutoMount/AutoRun.sh";
- public static String MountRecord="/gfsAutoMount/mountPoint.record";
- public static String strGetTreeData = "function ergodic(){\n "
- + "for file in \\`ls \\$1\\`\n do\n if [ \"\\$file\" != \"app\" -a -d \\$1\\\"/\\\"\\$file ]\n "
- + "then\n ergodic \\$1\"/\"\\$file\n else\n local path=\\$1\"/\"\\$file\n "
- + "echo \\$path \n fi\n done\n}\n\nIFS=\\$\\'\\n\\' "
- + "#这个必须要,否则会在文件名中有空格时出错\nINIT_PATH=\".\";\nergodic \\$1\n";
-
- /**
- * volume 获取的线程休眠时间
- */
- public final static int moveFileMaxNum = 1;
-
- /**
- * volume 获取的线程休眠时间
- */
- public final static int get_volume_sleep_time = 10000;
-
- /**
- * volume 获取的线程休眠时间
- */
- public final static int update_dataInfo_sleep_time = 1500;
-
-}
+
+package com.platform.utils;
+
+
+public class Constant {
+ public static String rootUser = "root";
+ public static String rootPasswd = "root";
+// public static String hostIp = "192.168.191.23";
+ public static String hostIp = "";
+ public static int port = 22;
+ public static String glusterPeerStatus = "gluster peer status";
+ public static String glusterVolumeInfo = "gluster volume info ";
+ public static String df = "df -k ";
+ public static String peerincluster_connected = "PeerinCluster(Connected)";
+ public static String peerincluster_disconnected = "PeerinCluster(Disconnected)";
+ public static String peerNotinCluster = "PeerNotinCluster";
+ public static String distributed = "distributed";
+ public static String replica = "replica";
+ public static String stripe = "stripe";
+ public static String noVolume = "No volumes present";
+ public static String success = "success";
+ public static String failed = "failed";
+ public static String noSuchFile = "No such file or directory";
+ public static GanymedSSH ganymedSSH = null;
+ public static String fileGetTreeData = "WebContent\\WEB-INF\\config\\getTreedata.sh";
+ public static String AutoMountfile="/gfsAutoMount/AutoRun.sh";
+ public static String MountRecord="/gfsAutoMount/mountPoint.record";
+ public static String strGetTreeData = "function ergodic(){\n "
+ + "for file in \\`ls \\$1\\`\n do\n if [ \"\\$file\" != \"app\" -a -d \\$1\\\"/\\\"\\$file ]\n "
+ + "then\n ergodic \\$1\"/\"\\$file\n else\n local path=\\$1\"/\"\\$file\n "
+ + "echo \\$path \n fi\n done\n}\n\nIFS=\\$\\'\\n\\' "
+ + "#这个必须要,否则会在文件名中有空格时出错\nINIT_PATH=\".\";\nergodic \\$1\n";
+
+ /**
+ * volume 获取的线程休眠时间
+ */
+ public final static int moveFileMaxNum = 1;
+
+ /**
+ * volume 获取的线程休眠时间
+ */
+ public final static int get_volume_sleep_time = 10000;
+
+ /**
+ * volume 获取的线程休眠时间
+ */
+ public final static int update_dataInfo_sleep_time = 1500;
+
+}
diff --git a/src/com/platform/utils/GanymedSSH.java b/src/com/platform/utils/GanymedSSH.java
index fbad5d07..a2fa59e3 100644
--- a/src/com/platform/utils/GanymedSSH.java
+++ b/src/com/platform/utils/GanymedSSH.java
@@ -23,8 +23,8 @@ import ch.ethz.ssh2.*;
public class GanymedSSH {
public static Logger log = Logger.getLogger(GanymedSSH.class);
- Connection conn;
-
+ Connection conn;
+ public Map otherConns;
public boolean status = true;// 锟角凤拷锟斤拷锟街达拷锟斤拷锟斤拷锟阶刺�
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 {
- conn = new Connection(host, port);
- conn.connect(); // make sure the connection is opened
- boolean isAuthenticated = conn.authenticateWithPassword(username, password);
+ Connection conns = new Connection(host, port);
+ conns.connect(); // make sure the connection is opened
+ boolean isAuthenticated = conns.authenticateWithPassword(username, password);
if (isAuthenticated == false)
throw new IOException("Authentication failed.");
- return conn;
+ return conns;
}
public void execCmdNoWaitAcquiescent(String cmd) {
- String host=Constant.hostIp;
- String username=Constant.rootUser;
- String password=Constant.rootPasswd;
- int port=Constant.port;
+// String host=Constant.hostIp;
+// String username=Constant.rootUser;
+// String password=Constant.rootPasswd;
+// int port=Constant.port;
Session sess = null;
try {
@@ -79,8 +79,15 @@ public class GanymedSSH {
public void execCmdNoWait(String host, String username, String password, int port, String cmd) {
Session sess = null;
+ Connection new_conn;
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();
// 执锟斤拷cmd
sess.execCommand(cmd);
@@ -94,10 +101,10 @@ public class GanymedSSH {
}
public List execCmdWaitAcquiescent(String cmd) {
- String host=Constant.hostIp;
- String username=Constant.rootUser;
- String password=Constant.rootPasswd;
- int port=Constant.port;
+// String host=Constant.hostIp;
+// String username=Constant.rootUser;
+// String password=Constant.rootPasswd;
+// int port=Constant.port;
List reStrings = new ArrayList();
Session sess = null;
@@ -148,8 +155,15 @@ public class GanymedSSH {
List reStrings = new ArrayList();
Session sess = null;
+ Connection new_conn;
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();
// 执锟斤拷cmd
sess.execCommand(cmd);