commit
355b6e47a4
File diff suppressed because it is too large
Load Diff
@ -1,11 +1,11 @@
|
||||
package com.platform.glusterfs;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
public class SetCluster {
|
||||
public static Logger log = Logger.getLogger ( SetCluster.class);
|
||||
|
||||
public int addPeer(String peerip){
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
package com.platform.glusterfs;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
public class SetCluster {
|
||||
public static Logger log = Logger.getLogger ( SetCluster.class);
|
||||
|
||||
public int addPeer(String peerip){
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,105 +1,105 @@
|
||||
package com.platform.glusterfs;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
|
||||
import org.apache.log4j.PropertyConfigurator;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.platform.utils.Constant;
|
||||
|
||||
|
||||
public class ShowData {
|
||||
|
||||
public static Logger log = Logger.getLogger ( ShowData.class);
|
||||
|
||||
/**
|
||||
* get the data of volumeName Map<string s1,string s2> s1 is data name and s2 is type file or folder
|
||||
* <功能详细描述>
|
||||
* @param volumeName
|
||||
* @return
|
||||
* @see [类、类#方法、类#成员]
|
||||
*/
|
||||
public Map<String,String> showVolumeFiles(String volumeName){
|
||||
log.info("start show the data");
|
||||
Map<String,String> data_type=new HashMap<String, String>();
|
||||
/**
|
||||
* get mount point of volumeName
|
||||
*/
|
||||
String folderName=volumeName;
|
||||
|
||||
data_type=showFolderData(volumeName);
|
||||
return data_type;
|
||||
}
|
||||
/**
|
||||
* get the data of folder name
|
||||
* Map<String,String> is folder name and type 1 is file and others is folder
|
||||
|
||||
|
||||
* @param FolderName
|
||||
* @return
|
||||
*/
|
||||
public Map<String,String> showFolderData(String folderName){
|
||||
log.info(" start get "+folderName+" data");
|
||||
|
||||
|
||||
Map<String,String> data_type=new HashMap<String, String>();
|
||||
String command="ls -l "+folderName;
|
||||
|
||||
/*
|
||||
RunCommand runCommand=new RunCommand();
|
||||
List<String> reStrings=runCommand.runCommandWait(command);
|
||||
*/
|
||||
List<String> reStrings = Constant.ganymedSSH.execCmdWait(Constant.hostIp, Constant.rootUser, Constant.rootPasswd, Constant.port, command);
|
||||
if(reStrings==null){
|
||||
log.error("2101 command get result is null");
|
||||
return null;
|
||||
}
|
||||
if(reStrings.size()==0){
|
||||
log.info("2102 the folder is empty");
|
||||
return data_type;
|
||||
}
|
||||
if(reStrings.get(0).contains("No such file or directory")){
|
||||
log.info("2103 the "+folderName+" is not exists");
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* remove first line total number
|
||||
*/
|
||||
reStrings.remove(0);
|
||||
|
||||
for(Iterator it2 = reStrings.iterator();it2.hasNext();){
|
||||
String line=(String)it2.next();
|
||||
line=line.replaceAll(" +", " ");
|
||||
String keyValue[]=line.split(" ");
|
||||
if(keyValue.length<9){
|
||||
log.error("2104 "+line+" length is short");
|
||||
continue;
|
||||
}
|
||||
|
||||
data_type.put(keyValue[8], keyValue[1]);
|
||||
|
||||
}
|
||||
log.info(" get "+folderName+" data successed");
|
||||
return data_type;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* <一句话功能简述>
|
||||
* <功能详细描述>
|
||||
* @see [类、类#方法、类#成员]
|
||||
*/
|
||||
@Test
|
||||
public void testShowData(){
|
||||
|
||||
System.out.println(showFolderData("/home"));
|
||||
|
||||
}
|
||||
package com.platform.glusterfs;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
|
||||
import org.apache.log4j.PropertyConfigurator;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.platform.utils.Constant;
|
||||
|
||||
|
||||
public class ShowData {
|
||||
|
||||
public static Logger log = Logger.getLogger ( ShowData.class);
|
||||
|
||||
/**
|
||||
* get the data of volumeName Map<string s1,string s2> s1 is data name and s2 is type file or folder
|
||||
* <功能详细描述>
|
||||
* @param volumeName
|
||||
* @return
|
||||
* @see [类、类#方法、类#成员]
|
||||
*/
|
||||
public Map<String,String> showVolumeFiles(String volumeName){
|
||||
log.info("start show the data");
|
||||
Map<String,String> data_type=new HashMap<String, String>();
|
||||
/**
|
||||
* get mount point of volumeName
|
||||
*/
|
||||
String folderName=volumeName;
|
||||
|
||||
data_type=showFolderData(volumeName);
|
||||
return data_type;
|
||||
}
|
||||
/**
|
||||
* get the data of folder name
|
||||
* Map<String,String> is folder name and type 1 is file and others is folder
|
||||
|
||||
|
||||
* @param FolderName
|
||||
* @return
|
||||
*/
|
||||
public Map<String,String> showFolderData(String folderName){
|
||||
log.info(" start get "+folderName+" data");
|
||||
|
||||
|
||||
Map<String,String> data_type=new HashMap<String, String>();
|
||||
String command="ls -l "+folderName;
|
||||
|
||||
/*
|
||||
RunCommand runCommand=new RunCommand();
|
||||
List<String> reStrings=runCommand.runCommandWait(command);
|
||||
*/
|
||||
List<String> reStrings = Constant.ganymedSSH.execCmdWait(Constant.hostIp, Constant.rootUser, Constant.rootPasswd, Constant.port, command);
|
||||
if(reStrings==null){
|
||||
log.error("2101 command get result is null");
|
||||
return null;
|
||||
}
|
||||
if(reStrings.size()==0){
|
||||
log.info("2102 the folder is empty");
|
||||
return data_type;
|
||||
}
|
||||
if(reStrings.get(0).contains("No such file or directory")){
|
||||
log.info("2103 the "+folderName+" is not exists");
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* remove first line total number
|
||||
*/
|
||||
reStrings.remove(0);
|
||||
|
||||
for(Iterator it2 = reStrings.iterator();it2.hasNext();){
|
||||
String line=(String)it2.next();
|
||||
line=line.replaceAll(" +", " ");
|
||||
String keyValue[]=line.split(" ");
|
||||
if(keyValue.length<9){
|
||||
log.error("2104 "+line+" length is short");
|
||||
continue;
|
||||
}
|
||||
|
||||
data_type.put(keyValue[8], keyValue[1]);
|
||||
|
||||
}
|
||||
log.info(" get "+folderName+" data successed");
|
||||
return data_type;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* <一句话功能简述>
|
||||
* <功能详细描述>
|
||||
* @see [类、类#方法、类#成员]
|
||||
*/
|
||||
@Test
|
||||
public void testShowData(){
|
||||
|
||||
System.out.println(showFolderData("/home"));
|
||||
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,19 +1,19 @@
|
||||
package com.platform.utils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.platform.entities.FolderNode;
|
||||
|
||||
public class CacheTreeData {
|
||||
|
||||
private static List<FolderNode> folders = null;
|
||||
|
||||
public static List<FolderNode> getFolders() {
|
||||
return folders;
|
||||
}
|
||||
|
||||
public static void setFolders(List<FolderNode> folders) {
|
||||
CacheTreeData.folders = folders;
|
||||
}
|
||||
|
||||
}
|
||||
package com.platform.utils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.platform.entities.FolderNode;
|
||||
|
||||
public class CacheTreeData {
|
||||
|
||||
private static List<FolderNode> folders = null;
|
||||
|
||||
public static List<FolderNode> getFolders() {
|
||||
return folders;
|
||||
}
|
||||
|
||||
public static void setFolders(List<FolderNode> folders) {
|
||||
CacheTreeData.folders = folders;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,74 +1,74 @@
|
||||
package com.platform.utils;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.servlet.ServletContextEvent;
|
||||
import javax.servlet.ServletContextListener;
|
||||
|
||||
public class ConfigsLoader implements ServletContextListener {
|
||||
private static ConfigPropertyReader cReader = null;
|
||||
|
||||
@Override
|
||||
public void contextDestroyed(ServletContextEvent sEvent) {
|
||||
// TODO Auto-generated method stub
|
||||
Configs.CONSOLE_LOGGER.info("系统停止..");
|
||||
}
|
||||
|
||||
@SuppressWarnings("static-access")
|
||||
@Override
|
||||
public void contextInitialized(ServletContextEvent sEvent) {
|
||||
// TODO Auto-generated method stub
|
||||
Configs.CONSOLE_LOGGER.info("系统初始化..");
|
||||
String contextPath = sEvent.getServletContext().getRealPath("/")
|
||||
+ "WEB-INF/config/config.properties";
|
||||
this.cReader = ConfigPropertyReader.Builder(contextPath);
|
||||
init();
|
||||
new ThreadVolume("").start();
|
||||
}
|
||||
|
||||
public static void init() {
|
||||
Properties properties = cReader.getProperties();
|
||||
|
||||
Configs.KUBE_MASTER_URL = properties.getProperty("kubeMasterUrl");
|
||||
|
||||
Configs.COLLECT_USER_NAME = properties.getProperty("collect-user-name");
|
||||
|
||||
Configs.COLLECT_PASSWORD = properties.getProperty("collect-password");
|
||||
|
||||
Configs.COLLECT_SERVICE_NAME = properties
|
||||
.getProperty("collect-service-name");
|
||||
|
||||
Configs.GATHER_USER_NAME = properties.getProperty("gather-user-name");
|
||||
|
||||
Configs.GATHER_USER_PASSWORD = properties
|
||||
.getProperty("gather-user-password");
|
||||
|
||||
Configs.GATHER_PORT = properties.getProperty("gather-port");
|
||||
|
||||
Configs.GATHER_SERVICE_NAME = properties
|
||||
.getProperty("gather-service-name");
|
||||
|
||||
Configs.TABLE_SUFFIX = properties.getProperty("table-suffix");
|
||||
|
||||
Configs.EXTRACT_LOG_LOCALTION = properties
|
||||
.getProperty("extract-log-localtion");
|
||||
|
||||
Configs.GATHER_TABLESPACE_NAME = properties
|
||||
.getProperty("gather-tablespace-name");
|
||||
|
||||
Configs.GATHER_TABLESPACE_PATH = properties
|
||||
.getProperty("gather-tablespace-path");
|
||||
|
||||
Configs.GATHER_TABLE_PASSWORD=properties.getProperty("gather-table-user-password");
|
||||
}
|
||||
|
||||
public ConfigPropertyReader getcReader() {
|
||||
return cReader;
|
||||
}
|
||||
|
||||
@SuppressWarnings("static-access")
|
||||
public void setcReader(ConfigPropertyReader cReader) {
|
||||
this.cReader = cReader;
|
||||
}
|
||||
|
||||
}
|
||||
package com.platform.utils;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.servlet.ServletContextEvent;
|
||||
import javax.servlet.ServletContextListener;
|
||||
|
||||
public class ConfigsLoader implements ServletContextListener {
|
||||
private static ConfigPropertyReader cReader = null;
|
||||
|
||||
@Override
|
||||
public void contextDestroyed(ServletContextEvent sEvent) {
|
||||
// TODO Auto-generated method stub
|
||||
Configs.CONSOLE_LOGGER.info("系统停止..");
|
||||
}
|
||||
|
||||
@SuppressWarnings("static-access")
|
||||
@Override
|
||||
public void contextInitialized(ServletContextEvent sEvent) {
|
||||
// TODO Auto-generated method stub
|
||||
Configs.CONSOLE_LOGGER.info("系统初始化..");
|
||||
String contextPath = sEvent.getServletContext().getRealPath("/")
|
||||
+ "WEB-INF/config/config.properties";
|
||||
this.cReader = ConfigPropertyReader.Builder(contextPath);
|
||||
init();
|
||||
new ThreadVolume("").start();
|
||||
}
|
||||
|
||||
public static void init() {
|
||||
Properties properties = cReader.getProperties();
|
||||
|
||||
Configs.KUBE_MASTER_URL = properties.getProperty("kubeMasterUrl");
|
||||
|
||||
Configs.COLLECT_USER_NAME = properties.getProperty("collect-user-name");
|
||||
|
||||
Configs.COLLECT_PASSWORD = properties.getProperty("collect-password");
|
||||
|
||||
Configs.COLLECT_SERVICE_NAME = properties
|
||||
.getProperty("collect-service-name");
|
||||
|
||||
Configs.GATHER_USER_NAME = properties.getProperty("gather-user-name");
|
||||
|
||||
Configs.GATHER_USER_PASSWORD = properties
|
||||
.getProperty("gather-user-password");
|
||||
|
||||
Configs.GATHER_PORT = properties.getProperty("gather-port");
|
||||
|
||||
Configs.GATHER_SERVICE_NAME = properties
|
||||
.getProperty("gather-service-name");
|
||||
|
||||
Configs.TABLE_SUFFIX = properties.getProperty("table-suffix");
|
||||
|
||||
Configs.EXTRACT_LOG_LOCALTION = properties
|
||||
.getProperty("extract-log-localtion");
|
||||
|
||||
Configs.GATHER_TABLESPACE_NAME = properties
|
||||
.getProperty("gather-tablespace-name");
|
||||
|
||||
Configs.GATHER_TABLESPACE_PATH = properties
|
||||
.getProperty("gather-tablespace-path");
|
||||
|
||||
Configs.GATHER_TABLE_PASSWORD=properties.getProperty("gather-table-user-password");
|
||||
}
|
||||
|
||||
public ConfigPropertyReader getcReader() {
|
||||
return cReader;
|
||||
}
|
||||
|
||||
@SuppressWarnings("static-access")
|
||||
public void setcReader(ConfigPropertyReader cReader) {
|
||||
this.cReader = cReader;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,32 +1,33 @@
|
||||
package com.platform.utils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Constant {
|
||||
public static String rootUser = "root";
|
||||
public static String rootPasswd = "root";
|
||||
public static String hostIp = "192.168.0.116";
|
||||
// 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 distributed="distributed";
|
||||
public static String replica="replica";
|
||||
public static String stripe="stripe";
|
||||
public static String noVolume="No volumes present";
|
||||
public static GanymedSSH ganymedSSH=new GanymedSSH(hostIp, rootUser, rootPasswd, port);
|
||||
public static String fileGetTreeData="./WEB-INF/config/getTreedata.sh";
|
||||
|
||||
/**
|
||||
* volume 获取的线程休眠时间
|
||||
*/
|
||||
public final static int get_volume_sleep_time = 300000;
|
||||
|
||||
/**
|
||||
* volume 获取的线程休眠时间
|
||||
*/
|
||||
public final static int update_dataInfo_sleep_time = 3000;
|
||||
}
|
||||
package com.platform.utils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Constant {
|
||||
public static String rootUser = "root";
|
||||
public static String rootPasswd = "root";
|
||||
public static String hostIp = "192.168.0.116";
|
||||
// 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 distributed="distributed";
|
||||
public static String replica="replica";
|
||||
public static String stripe="stripe";
|
||||
public static String noVolume="No volumes present";
|
||||
public static GanymedSSH ganymedSSH=new GanymedSSH(hostIp, rootUser, rootPasswd, port);
|
||||
public static String fileGetTreeData="./WEB-INF/config/getTreedata.sh";
|
||||
|
||||
/**
|
||||
* volume 获取的线程休眠时间
|
||||
*/
|
||||
public final static int get_volume_sleep_time = 300000;
|
||||
|
||||
/**
|
||||
* volume 获取的线程休眠时间
|
||||
*/
|
||||
public final static int update_dataInfo_sleep_time = 3000;
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,48 +1,48 @@
|
||||
package com.platform.utils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.platform.entities.FolderNode;
|
||||
|
||||
public class getTreeDataByPath {
|
||||
|
||||
/**
|
||||
* @param path
|
||||
* @return
|
||||
*/
|
||||
public FolderNode findByPath(String path) {
|
||||
List<FolderNode> folderNodelist = CacheTreeData.getFolders();
|
||||
if (null == folderNodelist) {
|
||||
return null;
|
||||
}
|
||||
FolderNode folder = null;
|
||||
for (FolderNode folderNode : folderNodelist) {
|
||||
folder = getFolder(folderNode, path);
|
||||
if (null != folder) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return folder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param f
|
||||
* @return
|
||||
*/
|
||||
private FolderNode getFolder(FolderNode f, String path){
|
||||
FolderNode result = null;
|
||||
if(path.equals(f.getPath())){
|
||||
return f;
|
||||
}
|
||||
List<FolderNode> folds = f.getChildNodes();
|
||||
if (null != folds) {
|
||||
for (FolderNode folderNode : folds) {
|
||||
result = getFolder(folderNode, path);
|
||||
if (null != result) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
package com.platform.utils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.platform.entities.FolderNode;
|
||||
|
||||
public class getTreeDataByPath {
|
||||
|
||||
/**
|
||||
* @param path
|
||||
* @return
|
||||
*/
|
||||
public FolderNode findByPath(String path) {
|
||||
List<FolderNode> folderNodelist = CacheTreeData.getFolders();
|
||||
if (null == folderNodelist) {
|
||||
return null;
|
||||
}
|
||||
FolderNode folder = null;
|
||||
for (FolderNode folderNode : folderNodelist) {
|
||||
folder = getFolder(folderNode, path);
|
||||
if (null != folder) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return folder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param f
|
||||
* @return
|
||||
*/
|
||||
private FolderNode getFolder(FolderNode f, String path){
|
||||
FolderNode result = null;
|
||||
if(path.equals(f.getPath())){
|
||||
return f;
|
||||
}
|
||||
List<FolderNode> folds = f.getChildNodes();
|
||||
if (null != folds) {
|
||||
for (FolderNode folderNode : folds) {
|
||||
result = getFolder(folderNode, path);
|
||||
if (null != result) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in new issue