parent
12661a53d3
commit
e48af410dd
@ -1,48 +1,70 @@
|
||||
package com.platform.controller;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import com.base.BaseController;
|
||||
import com.platform.utils.Configs;
|
||||
import com.platform.utils.ZipCompressUtils;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/filePackage")
|
||||
public class FilePackageController extends BaseController {
|
||||
|
||||
@RequestMapping("/download")
|
||||
public ResponseEntity<byte[]> downloadFile(HttpServletRequest request,
|
||||
HttpServletResponse response) throws Exception {
|
||||
String filePath = Configs.PACKAGE_DOWNLOAD_PATH;
|
||||
System.out.println(filePath + Configs.PACKAGE_NAME);
|
||||
ZipCompressUtils.zip(new File(filePath + Configs.PACKAGE_NAME),
|
||||
filePath + "package.zip"); // 产生压缩文件
|
||||
File file = new File(filePath + "package.zip");
|
||||
if (file.exists()) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
String fileName = new String(file.getName());// 为了解决中文名称乱码问题
|
||||
System.out.println(fileName);
|
||||
headers.setContentDispositionFormData("attachment", fileName);
|
||||
headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
|
||||
ResponseEntity<byte[]> responseEntity = new ResponseEntity<byte[]>(
|
||||
FileUtils.readFileToByteArray(file), headers,
|
||||
HttpStatus.CREATED);
|
||||
file.delete(); //
|
||||
return responseEntity;
|
||||
} else {
|
||||
response.setStatus(500);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
package com.platform.controller;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import com.base.BaseController;
|
||||
import com.platform.entities.MyFilesEntity;
|
||||
import com.platform.entities.PreDataInfo;
|
||||
import com.platform.service.IScriptMakeService;
|
||||
import com.platform.utils.Configs;
|
||||
import com.platform.utils.ZipCompressUtils;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/filePackage")
|
||||
public class FilePackageController extends BaseController {
|
||||
|
||||
@Resource(name = "scriptMakeService")
|
||||
private IScriptMakeService scriptMakeService;
|
||||
|
||||
@RequestMapping("/download")
|
||||
public ResponseEntity<byte[]> downloadFile(HttpServletRequest request,
|
||||
HttpServletResponse response) throws Exception {
|
||||
scriptMakeService.makeCfg();
|
||||
scriptMakeService.makeXml();
|
||||
String filePath = Configs.PACKAGE_DOWNLOAD_PATH;
|
||||
System.out.println(filePath + Configs.PACKAGE_NAME);
|
||||
ZipCompressUtils.zip(new File(filePath + Configs.PACKAGE_NAME),
|
||||
filePath + "package.zip"); // 产生压缩文件
|
||||
File file = new File(filePath + "package.zip");
|
||||
if (file.exists()) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
String fileName = new String(file.getName());// 为了解决中文名称乱码问题
|
||||
System.out.println(fileName);
|
||||
headers.setContentDispositionFormData("attachment", fileName);
|
||||
headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
|
||||
ResponseEntity<byte[]> responseEntity = new ResponseEntity<byte[]>(
|
||||
FileUtils.readFileToByteArray(file), headers,
|
||||
HttpStatus.CREATED);
|
||||
file.delete(); //
|
||||
return responseEntity;
|
||||
} else {
|
||||
response.setStatus(500);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping("/findAll")
|
||||
public ModelMap findAll() throws Exception {
|
||||
ModelMap modelMap = new ModelMap();
|
||||
List<MyFilesEntity> result = scriptMakeService.FindAllFiles();
|
||||
modelMap.addAttribute("data", result);
|
||||
modelMap.addAttribute("length", result.size());
|
||||
return modelMap;
|
||||
}
|
||||
}
|
||||
|
@ -1,53 +0,0 @@
|
||||
package com.platform.entities;
|
||||
|
||||
public class MyFileEntity {
|
||||
|
||||
private String fileName;
|
||||
|
||||
private String lastTime;
|
||||
|
||||
private String filePath;
|
||||
|
||||
/**
|
||||
* @return the fileName
|
||||
*/
|
||||
public String getFileName() {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param fileName the fileName to set
|
||||
*/
|
||||
public void setFileName(String fileName) {
|
||||
this.fileName = fileName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the lastTime
|
||||
*/
|
||||
public String getLastTime() {
|
||||
return lastTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param lastTime the lastTime to set
|
||||
*/
|
||||
public void setLastTime(String lastTime) {
|
||||
this.lastTime = lastTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the filePath
|
||||
*/
|
||||
public String getFilePath() {
|
||||
return filePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param filePath the filePath to set
|
||||
*/
|
||||
public void setFilePath(String filePath) {
|
||||
this.filePath = filePath;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,279 @@
|
||||
package com.platform.entities;
|
||||
|
||||
public class MyFilesEntity{
|
||||
|
||||
private int id;
|
||||
|
||||
/** 状态 */
|
||||
private int sysStatus;
|
||||
|
||||
private String areaCode;
|
||||
|
||||
private int sysCode;
|
||||
|
||||
private String cityName;
|
||||
|
||||
private String districtName;
|
||||
|
||||
private String sysName;
|
||||
|
||||
/** 数据库类型 */
|
||||
private String dataBaseType;
|
||||
|
||||
private int userTableStatus;
|
||||
|
||||
private String userTableScriptPathLast;
|
||||
|
||||
private String userTableScriptPathStandard;
|
||||
|
||||
private int ckPayStatus;
|
||||
|
||||
private String ckPayScriptPathLast;
|
||||
|
||||
private String ckPayScriptPathStandard;
|
||||
|
||||
private int ckIndicateStatus;
|
||||
|
||||
private String ckIndicateScriptPathLast;
|
||||
|
||||
private String ckIndicateScriptPathStandard;
|
||||
|
||||
/**
|
||||
* @return the id
|
||||
*/
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id the id to set
|
||||
*/
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the sysStatus
|
||||
*/
|
||||
public int getSysStatus() {
|
||||
return sysStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param sysStatus the sysStatus to set
|
||||
*/
|
||||
public void setSysStatus(int sysStatus) {
|
||||
this.sysStatus = sysStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the areaCode
|
||||
*/
|
||||
public String getAreaCode() {
|
||||
return areaCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param areaCode the areaCode to set
|
||||
*/
|
||||
public void setAreaCode(String areaCode) {
|
||||
this.areaCode = areaCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the sysCode
|
||||
*/
|
||||
public int getSysCode() {
|
||||
return sysCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param sysCode the sysCode to set
|
||||
*/
|
||||
public void setSysCode(int sysCode) {
|
||||
this.sysCode = sysCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the cityName
|
||||
*/
|
||||
public String getCityName() {
|
||||
return cityName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param cityName the cityName to set
|
||||
*/
|
||||
public void setCityName(String cityName) {
|
||||
this.cityName = cityName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the districtName
|
||||
*/
|
||||
public String getDistrictName() {
|
||||
return districtName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param districtName the districtName to set
|
||||
*/
|
||||
public void setDistrictName(String districtName) {
|
||||
this.districtName = districtName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the sysName
|
||||
*/
|
||||
public String getSysName() {
|
||||
return sysName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param sysName the sysName to set
|
||||
*/
|
||||
public void setSysName(String sysName) {
|
||||
this.sysName = sysName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the dataBaseType
|
||||
*/
|
||||
public String getDataBaseType() {
|
||||
return dataBaseType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dataBaseType the dataBaseType to set
|
||||
*/
|
||||
public void setDataBaseType(String dataBaseType) {
|
||||
this.dataBaseType = dataBaseType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the userTableStatus
|
||||
*/
|
||||
public int getUserTableStatus() {
|
||||
return userTableStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param userTableStatus the userTableStatus to set
|
||||
*/
|
||||
public void setUserTableStatus(int userTableStatus) {
|
||||
this.userTableStatus = userTableStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ckPayStatus the ckPayStatus to set
|
||||
*/
|
||||
public void setCkPayStatus(int ckPayStatus) {
|
||||
this.ckPayStatus = ckPayStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ckIndicateStatus the ckIndicateStatus to set
|
||||
*/
|
||||
public void setCkIndicateStatus(int ckIndicateStatus) {
|
||||
this.ckIndicateStatus = ckIndicateStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the userTableScriptPathLast
|
||||
*/
|
||||
public String getUserTableScriptPathLast() {
|
||||
return userTableScriptPathLast;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param userTableScriptPathLast the userTableScriptPathLast to set
|
||||
*/
|
||||
public void setUserTableScriptPathLast(String userTableScriptPathLast) {
|
||||
this.userTableScriptPathLast = userTableScriptPathLast;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the userTableScriptPathStandard
|
||||
*/
|
||||
public String getUserTableScriptPathStandard() {
|
||||
return userTableScriptPathStandard;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param userTableScriptPathStandard the userTableScriptPathStandard to set
|
||||
*/
|
||||
public void setUserTableScriptPathStandard(String userTableScriptPathStandard) {
|
||||
this.userTableScriptPathStandard = userTableScriptPathStandard;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the ckPayScriptPathLast
|
||||
*/
|
||||
public String getCkPayScriptPathLast() {
|
||||
return ckPayScriptPathLast;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ckPayScriptPathLast the ckPayScriptPathLast to set
|
||||
*/
|
||||
public void setCkPayScriptPathLast(String ckPayScriptPathLast) {
|
||||
this.ckPayScriptPathLast = ckPayScriptPathLast;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the ckPayScriptPathStandard
|
||||
*/
|
||||
public String getCkPayScriptPathStandard() {
|
||||
return ckPayScriptPathStandard;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ckPayScriptPathStandard the ckPayScriptPathStandard to set
|
||||
*/
|
||||
public void setCkPayScriptPathStandard(String ckPayScriptPathStandard) {
|
||||
this.ckPayScriptPathStandard = ckPayScriptPathStandard;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the ckIndicateScriptPathLast
|
||||
*/
|
||||
public String getCkIndicateScriptPathLast() {
|
||||
return ckIndicateScriptPathLast;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ckIndicateScriptPathLast the ckIndicateScriptPathLast to set
|
||||
*/
|
||||
public void setCkIndicateScriptPathLast(String ckIndicateScriptPathLast) {
|
||||
this.ckIndicateScriptPathLast = ckIndicateScriptPathLast;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the ckIndicateScriptPathStandard
|
||||
*/
|
||||
public String getCkIndicateScriptPathStandard() {
|
||||
return ckIndicateScriptPathStandard;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ckIndicateScriptPathStandard the ckIndicateScriptPathStandard to set
|
||||
*/
|
||||
public void setCkIndicateScriptPathStandard(String ckIndicateScriptPathStandard) {
|
||||
this.ckIndicateScriptPathStandard = ckIndicateScriptPathStandard;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the ckPayStatus
|
||||
*/
|
||||
public int getCkPayStatus() {
|
||||
return ckPayStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the ckIndicateStatus
|
||||
*/
|
||||
public int getCkIndicateStatus() {
|
||||
return ckIndicateStatus;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.platform.utils;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
import com.platform.entities.MyFilesEntity;
|
||||
|
||||
public class Compare4MyFilesEntity implements Comparator<MyFilesEntity> {
|
||||
|
||||
@Override
|
||||
public int compare(MyFilesEntity arg0, MyFilesEntity arg1) {
|
||||
if (arg0.getSysStatus() < arg1.getSysStatus())
|
||||
return 1;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
@ -1,64 +1,64 @@
|
||||
package com.platform.utils;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
public class Configs {
|
||||
|
||||
/** 全局自定义异常--编码 */
|
||||
public static final String GLOBAL_EXP_CUSTOM = "3001001001";
|
||||
|
||||
/** 全局非自定义异常--编码 */
|
||||
public static final String GLOBAL_EXP_NOT_CUSTOM = "3001001002";
|
||||
|
||||
public static final String CONFIG_LOCALTION = "WebContent/WEB-INF/config/config.properties";
|
||||
|
||||
public static final Logger CONSOLE_LOGGER = Logger.getLogger("console");
|
||||
|
||||
public static final Logger DAILY_ROLLING_LOGGER = Logger
|
||||
.getLogger("dailyRollingFile");
|
||||
|
||||
public static final Logger DAILY_LOGGER = Logger.getLogger("railyFile");
|
||||
|
||||
public static final Logger LOGGER = Logger.getLogger(Configs.class);
|
||||
|
||||
public static String KUBE_MASTER_URL = "http://192.168.0.110:8080/"; // kubernetes集群的maser
|
||||
// URl
|
||||
|
||||
public static int ORACLE_DEFAULT_PORT = 1521; // oracle的默认端口号
|
||||
|
||||
public static String COLLECT_USER_NAME = "system"; //采集统一的登入用户名
|
||||
|
||||
public static String COLLECT_PASSWORD = "oracle"; //采集统一的登入密码
|
||||
|
||||
public static String COLLECT_SERVICE_NAME = "orcl"; //采集库统一的服务名
|
||||
|
||||
public static String GATHER_PORT ="1521"; //汇总库的端口号
|
||||
|
||||
public static String GATHER_USER_NAME = "system"; //汇总库的登入用户名
|
||||
|
||||
public static String GATHER_USER_PASSWORD = "1"; //汇总库的登入密码
|
||||
|
||||
public static String GATHER_SERVICE_NAME = "orcl"; //汇总库的服务名
|
||||
|
||||
public static String TABLE_SUFFIX = "_20152016"; //汇总库汇总表的后缀名
|
||||
|
||||
public static String EXTRACT_LOG_LOCALTION = "D:\\log"; //数据汇总日志保存位置
|
||||
|
||||
public static String GATHER_TABLESPACE_NAME=""; //表空间名
|
||||
|
||||
public static String GATHER_TABLESPACE_PATH=""; //表空间路径
|
||||
|
||||
public static String GATHER_TABLE_PASSWORD="1"; //登入密码
|
||||
|
||||
public static String FILE_UPLOAD_PATH="";
|
||||
|
||||
public static String FILE_DOWNLOAD_PATH="";
|
||||
|
||||
public static String PACKAGE_DOWNLOAD_PATH="";
|
||||
|
||||
public static String PACKAGE_NAME="";
|
||||
|
||||
public static String sql_script_path_last="";
|
||||
|
||||
public static String sql_script_path_standard="";
|
||||
}
|
||||
package com.platform.utils;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
public class Configs {
|
||||
|
||||
/** 全局自定义异常--编码 */
|
||||
public static final String GLOBAL_EXP_CUSTOM = "3001001001";
|
||||
|
||||
/** 全局非自定义异常--编码 */
|
||||
public static final String GLOBAL_EXP_NOT_CUSTOM = "3001001002";
|
||||
|
||||
public static final String CONFIG_LOCALTION = "WebContent/WEB-INF/config/config.properties";
|
||||
|
||||
public static final Logger CONSOLE_LOGGER = Logger.getLogger("console");
|
||||
|
||||
public static final Logger DAILY_ROLLING_LOGGER = Logger
|
||||
.getLogger("dailyRollingFile");
|
||||
|
||||
public static final Logger DAILY_LOGGER = Logger.getLogger("railyFile");
|
||||
|
||||
public static final Logger LOGGER = Logger.getLogger(Configs.class);
|
||||
|
||||
public static String KUBE_MASTER_URL = "http://192.168.0.110:8080/"; // kubernetes集群的maser
|
||||
// URl
|
||||
|
||||
public static int ORACLE_DEFAULT_PORT = 1521; // oracle的默认端口号
|
||||
|
||||
public static String COLLECT_USER_NAME = "system"; //采集统一的登入用户名
|
||||
|
||||
public static String COLLECT_PASSWORD = "oracle"; //采集统一的登入密码
|
||||
|
||||
public static String COLLECT_SERVICE_NAME = "orcl"; //采集库统一的服务名
|
||||
|
||||
public static String GATHER_PORT ="1521"; //汇总库的端口号
|
||||
|
||||
public static String GATHER_USER_NAME = "system"; //汇总库的登入用户名
|
||||
|
||||
public static String GATHER_USER_PASSWORD = "1"; //汇总库的登入密码
|
||||
|
||||
public static String GATHER_SERVICE_NAME = "orcl"; //汇总库的服务名
|
||||
|
||||
public static String TABLE_SUFFIX = "_20152016"; //汇总库汇总表的后缀名
|
||||
|
||||
public static String EXTRACT_LOG_LOCALTION = "D:\\log"; //数据汇总日志保存位置
|
||||
|
||||
public static String GATHER_TABLESPACE_NAME=""; //表空间名
|
||||
|
||||
public static String GATHER_TABLESPACE_PATH=""; //表空间路径
|
||||
|
||||
public static String GATHER_TABLE_PASSWORD="1"; //登入密码
|
||||
|
||||
public static String FILE_UPLOAD_PATH="";
|
||||
|
||||
public static String FILE_DOWNLOAD_PATH="";
|
||||
|
||||
public static String PACKAGE_DOWNLOAD_PATH="";
|
||||
|
||||
public static String PACKAGE_NAME="";
|
||||
|
||||
public static String SQL_SCRIPT_PATH_LAST="";
|
||||
|
||||
public static String SQL_SCRIPT_PATH_STANDARD="";
|
||||
}
|
||||
|
@ -1,95 +1,95 @@
|
||||
package com.platform.utils;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.servlet.ServletContextEvent;
|
||||
import javax.servlet.ServletContextListener;
|
||||
|
||||
import com.platform.http.gfs.HttpClientConstant;
|
||||
|
||||
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("ThreadVolume-in-ConfigsLoader").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");
|
||||
|
||||
Configs.FILE_UPLOAD_PATH = properties.getProperty("file_upload_path");
|
||||
|
||||
Configs.FILE_DOWNLOAD_PATH = properties.getProperty("file_download_path");
|
||||
|
||||
Configs.PACKAGE_DOWNLOAD_PATH = properties.getProperty("package_download_path");
|
||||
|
||||
Configs.PACKAGE_NAME = properties.getProperty("package_name");
|
||||
|
||||
Configs.sql_script_path_last = properties.getProperty("sql_script_path_last");
|
||||
|
||||
Configs.sql_script_path_standard = properties.getProperty("sql_script_path_standard");
|
||||
|
||||
HttpClientConstant.URL_IP_PORT = properties.getProperty("HttpClientConstant_URL_IP_PORT").trim();
|
||||
|
||||
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() {
|
||||
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;
|
||||
|
||||
import com.platform.http.gfs.HttpClientConstant;
|
||||
|
||||
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("ThreadVolume-in-ConfigsLoader").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");
|
||||
|
||||
Configs.FILE_UPLOAD_PATH = properties.getProperty("file_upload_path");
|
||||
|
||||
Configs.FILE_DOWNLOAD_PATH = properties.getProperty("file_download_path");
|
||||
|
||||
Configs.PACKAGE_DOWNLOAD_PATH = properties.getProperty("package_download_path");
|
||||
|
||||
Configs.PACKAGE_NAME = properties.getProperty("package_name");
|
||||
|
||||
Configs.SQL_SCRIPT_PATH_LAST = properties.getProperty("sql_script_path_last");
|
||||
|
||||
Configs.SQL_SCRIPT_PATH_STANDARD = properties.getProperty("sql_script_path_standard");
|
||||
|
||||
HttpClientConstant.URL_IP_PORT = properties.getProperty("HttpClientConstant_URL_IP_PORT").trim();
|
||||
|
||||
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() {
|
||||
return cReader;
|
||||
}
|
||||
|
||||
@SuppressWarnings("static-access")
|
||||
public void setcReader(ConfigPropertyReader cReader) {
|
||||
this.cReader = cReader;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,41 @@
|
||||
package com.platform.utils;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
public class ProcessMyUtil {
|
||||
|
||||
private static Logger logger = Logger.getLogger(ProcessMyUtil.class);
|
||||
|
||||
public static List<String> execCmdWaitAcquiescent(String cmd) {
|
||||
return runcmd(cmd);
|
||||
}
|
||||
|
||||
private static List<String> runcmd(String cmd) {
|
||||
List<String> result = new ArrayList<String>();
|
||||
InputStream in = null;
|
||||
String[] cmds = {"/bin/sh", "-c", cmd};
|
||||
try {
|
||||
Process pro = Runtime.getRuntime().exec(cmds);
|
||||
pro.waitFor();
|
||||
in = pro.getInputStream();
|
||||
BufferedReader read = new BufferedReader(new InputStreamReader(in));
|
||||
String line = null;
|
||||
while ((line=read.readLine()) != null) {
|
||||
result.add(line);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
logger.error(e.getStackTrace());
|
||||
} catch (InterruptedException e) {
|
||||
logger.error(e.getStackTrace());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package com.platform.utils;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/** 删除文件
|
||||
* @author chen
|
||||
*
|
||||
*/
|
||||
public class ThreadRemoveFile extends Thread {
|
||||
|
||||
private List<String> path4Delete = new ArrayList<String>();
|
||||
|
||||
public ThreadRemoveFile(List<String> paths) {
|
||||
this.path4Delete = paths;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
while (true) {
|
||||
List<String> tmpPathArr = new ArrayList<String>();
|
||||
if (null != path4Delete && path4Delete.size() > 0) {
|
||||
for (String path : path4Delete) {
|
||||
File f = new File(path);
|
||||
if (f.exists()) {
|
||||
if (!f.delete()) {
|
||||
tmpPathArr.add(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
path4Delete = tmpPathArr;
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in new issue