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.jdt.core.javanature</nature>
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
<nature>com.sysdeo.eclipse.tomcat.tomcatnature</nature>
</natures>
</projectDescription>

@ -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

@ -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 {
* ipPeerinCluster(Connected)
* ipPeerinCluster(Disconnected)
* @return
* @throws IOException
* @see [##]
*/
public Map<String, String> showClusterInfo() {
// log.info("get cluster info");
log.info("get cluster info");
Map<String, String> peerIps = new HashMap<String, String>();
peerIps.put(Constant.hostIp, Constant.peerincluster_connected);
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;
}

@ -37,7 +37,7 @@ public class VolumeInfo {
* @see [##]
*/
public List<String> showAllVolumeName() {
// log.info("get volume name");
log.info(Constant.ganymedSSH+"get volume name");
List<String> volNames = new ArrayList<String>();
/*
@ -46,6 +46,8 @@ 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);

@ -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() {

@ -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;
}

@ -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<String, Connection> otherConns;
public boolean status = true;// 锟角凤拷锟斤拷锟街达拷锟斤拷锟斤拷锟阶刺<E998B6>
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<String> 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<String> reStrings = new ArrayList<String>();
Session sess = null;
@ -148,8 +155,15 @@ public class GanymedSSH {
List<String> reStrings = new ArrayList<String>();
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);

Loading…
Cancel
Save