parent
12661a53d3
commit
e48af410dd
@ -1,48 +1,70 @@
|
|||||||
package com.platform.controller;
|
package com.platform.controller;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.List;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import org.apache.commons.io.FileUtils;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import org.springframework.http.HttpHeaders;
|
|
||||||
import org.springframework.http.HttpStatus;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
import com.base.BaseController;
|
import org.springframework.ui.ModelMap;
|
||||||
import com.platform.utils.Configs;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import com.platform.utils.ZipCompressUtils;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
@Controller
|
import com.base.BaseController;
|
||||||
@RequestMapping("/filePackage")
|
import com.platform.entities.MyFilesEntity;
|
||||||
public class FilePackageController extends BaseController {
|
import com.platform.entities.PreDataInfo;
|
||||||
|
import com.platform.service.IScriptMakeService;
|
||||||
@RequestMapping("/download")
|
import com.platform.utils.Configs;
|
||||||
public ResponseEntity<byte[]> downloadFile(HttpServletRequest request,
|
import com.platform.utils.ZipCompressUtils;
|
||||||
HttpServletResponse response) throws Exception {
|
|
||||||
String filePath = Configs.PACKAGE_DOWNLOAD_PATH;
|
@Controller
|
||||||
System.out.println(filePath + Configs.PACKAGE_NAME);
|
@RequestMapping("/filePackage")
|
||||||
ZipCompressUtils.zip(new File(filePath + Configs.PACKAGE_NAME),
|
public class FilePackageController extends BaseController {
|
||||||
filePath + "package.zip"); // 产生压缩文件
|
|
||||||
File file = new File(filePath + "package.zip");
|
@Resource(name = "scriptMakeService")
|
||||||
if (file.exists()) {
|
private IScriptMakeService scriptMakeService;
|
||||||
HttpHeaders headers = new HttpHeaders();
|
|
||||||
String fileName = new String(file.getName());// 为了解决中文名称乱码问题
|
@RequestMapping("/download")
|
||||||
System.out.println(fileName);
|
public ResponseEntity<byte[]> downloadFile(HttpServletRequest request,
|
||||||
headers.setContentDispositionFormData("attachment", fileName);
|
HttpServletResponse response) throws Exception {
|
||||||
headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
|
scriptMakeService.makeCfg();
|
||||||
ResponseEntity<byte[]> responseEntity = new ResponseEntity<byte[]>(
|
scriptMakeService.makeXml();
|
||||||
FileUtils.readFileToByteArray(file), headers,
|
String filePath = Configs.PACKAGE_DOWNLOAD_PATH;
|
||||||
HttpStatus.CREATED);
|
System.out.println(filePath + Configs.PACKAGE_NAME);
|
||||||
file.delete(); //
|
ZipCompressUtils.zip(new File(filePath + Configs.PACKAGE_NAME),
|
||||||
return responseEntity;
|
filePath + "package.zip"); // 产生压缩文件
|
||||||
} else {
|
File file = new File(filePath + "package.zip");
|
||||||
response.setStatus(500);
|
if (file.exists()) {
|
||||||
return null;
|
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;
|
package com.platform.utils;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
public class Configs {
|
public class Configs {
|
||||||
|
|
||||||
/** 全局自定义异常--编码 */
|
/** 全局自定义异常--编码 */
|
||||||
public static final String GLOBAL_EXP_CUSTOM = "3001001001";
|
public static final String GLOBAL_EXP_CUSTOM = "3001001001";
|
||||||
|
|
||||||
/** 全局非自定义异常--编码 */
|
/** 全局非自定义异常--编码 */
|
||||||
public static final String GLOBAL_EXP_NOT_CUSTOM = "3001001002";
|
public static final String GLOBAL_EXP_NOT_CUSTOM = "3001001002";
|
||||||
|
|
||||||
public static final String CONFIG_LOCALTION = "WebContent/WEB-INF/config/config.properties";
|
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 CONSOLE_LOGGER = Logger.getLogger("console");
|
||||||
|
|
||||||
public static final Logger DAILY_ROLLING_LOGGER = Logger
|
public static final Logger DAILY_ROLLING_LOGGER = Logger
|
||||||
.getLogger("dailyRollingFile");
|
.getLogger("dailyRollingFile");
|
||||||
|
|
||||||
public static final Logger DAILY_LOGGER = Logger.getLogger("railyFile");
|
public static final Logger DAILY_LOGGER = Logger.getLogger("railyFile");
|
||||||
|
|
||||||
public static final Logger LOGGER = Logger.getLogger(Configs.class);
|
public static final Logger LOGGER = Logger.getLogger(Configs.class);
|
||||||
|
|
||||||
public static String KUBE_MASTER_URL = "http://192.168.0.110:8080/"; // kubernetes集群的maser
|
public static String KUBE_MASTER_URL = "http://192.168.0.110:8080/"; // kubernetes集群的maser
|
||||||
// URl
|
// URl
|
||||||
|
|
||||||
public static int ORACLE_DEFAULT_PORT = 1521; // oracle的默认端口号
|
public static int ORACLE_DEFAULT_PORT = 1521; // oracle的默认端口号
|
||||||
|
|
||||||
public static String COLLECT_USER_NAME = "system"; //采集统一的登入用户名
|
public static String COLLECT_USER_NAME = "system"; //采集统一的登入用户名
|
||||||
|
|
||||||
public static String COLLECT_PASSWORD = "oracle"; //采集统一的登入密码
|
public static String COLLECT_PASSWORD = "oracle"; //采集统一的登入密码
|
||||||
|
|
||||||
public static String COLLECT_SERVICE_NAME = "orcl"; //采集库统一的服务名
|
public static String COLLECT_SERVICE_NAME = "orcl"; //采集库统一的服务名
|
||||||
|
|
||||||
public static String GATHER_PORT ="1521"; //汇总库的端口号
|
public static String GATHER_PORT ="1521"; //汇总库的端口号
|
||||||
|
|
||||||
public static String GATHER_USER_NAME = "system"; //汇总库的登入用户名
|
public static String GATHER_USER_NAME = "system"; //汇总库的登入用户名
|
||||||
|
|
||||||
public static String GATHER_USER_PASSWORD = "1"; //汇总库的登入密码
|
public static String GATHER_USER_PASSWORD = "1"; //汇总库的登入密码
|
||||||
|
|
||||||
public static String GATHER_SERVICE_NAME = "orcl"; //汇总库的服务名
|
public static String GATHER_SERVICE_NAME = "orcl"; //汇总库的服务名
|
||||||
|
|
||||||
public static String TABLE_SUFFIX = "_20152016"; //汇总库汇总表的后缀名
|
public static String TABLE_SUFFIX = "_20152016"; //汇总库汇总表的后缀名
|
||||||
|
|
||||||
public static String EXTRACT_LOG_LOCALTION = "D:\\log"; //数据汇总日志保存位置
|
public static String EXTRACT_LOG_LOCALTION = "D:\\log"; //数据汇总日志保存位置
|
||||||
|
|
||||||
public static String GATHER_TABLESPACE_NAME=""; //表空间名
|
public static String GATHER_TABLESPACE_NAME=""; //表空间名
|
||||||
|
|
||||||
public static String GATHER_TABLESPACE_PATH=""; //表空间路径
|
public static String GATHER_TABLESPACE_PATH=""; //表空间路径
|
||||||
|
|
||||||
public static String GATHER_TABLE_PASSWORD="1"; //登入密码
|
public static String GATHER_TABLE_PASSWORD="1"; //登入密码
|
||||||
|
|
||||||
public static String FILE_UPLOAD_PATH="";
|
public static String FILE_UPLOAD_PATH="";
|
||||||
|
|
||||||
public static String FILE_DOWNLOAD_PATH="";
|
public static String FILE_DOWNLOAD_PATH="";
|
||||||
|
|
||||||
public static String PACKAGE_DOWNLOAD_PATH="";
|
public static String PACKAGE_DOWNLOAD_PATH="";
|
||||||
|
|
||||||
public static String PACKAGE_NAME="";
|
public static String PACKAGE_NAME="";
|
||||||
|
|
||||||
public static String sql_script_path_last="";
|
public static String SQL_SCRIPT_PATH_LAST="";
|
||||||
|
|
||||||
public static String sql_script_path_standard="";
|
public static String SQL_SCRIPT_PATH_STANDARD="";
|
||||||
}
|
}
|
||||||
|
@ -1,95 +1,95 @@
|
|||||||
package com.platform.utils;
|
package com.platform.utils;
|
||||||
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import javax.servlet.ServletContextEvent;
|
import javax.servlet.ServletContextEvent;
|
||||||
import javax.servlet.ServletContextListener;
|
import javax.servlet.ServletContextListener;
|
||||||
|
|
||||||
import com.platform.http.gfs.HttpClientConstant;
|
import com.platform.http.gfs.HttpClientConstant;
|
||||||
|
|
||||||
public class ConfigsLoader implements ServletContextListener {
|
public class ConfigsLoader implements ServletContextListener {
|
||||||
private static ConfigPropertyReader cReader = null;
|
private static ConfigPropertyReader cReader = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void contextDestroyed(ServletContextEvent sEvent) {
|
public void contextDestroyed(ServletContextEvent sEvent) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
Configs.CONSOLE_LOGGER.info("系统停止..");
|
Configs.CONSOLE_LOGGER.info("系统停止..");
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("static-access")
|
@SuppressWarnings("static-access")
|
||||||
@Override
|
@Override
|
||||||
public void contextInitialized(ServletContextEvent sEvent) {
|
public void contextInitialized(ServletContextEvent sEvent) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
Configs.CONSOLE_LOGGER.info("系统初始化..");
|
Configs.CONSOLE_LOGGER.info("系统初始化..");
|
||||||
String contextPath = sEvent.getServletContext().getRealPath("/")
|
String contextPath = sEvent.getServletContext().getRealPath("/")
|
||||||
+ "WEB-INF/config/config.properties";
|
+ "WEB-INF/config/config.properties";
|
||||||
this.cReader = ConfigPropertyReader.Builder(contextPath);
|
this.cReader = ConfigPropertyReader.Builder(contextPath);
|
||||||
init();
|
init();
|
||||||
new ThreadVolume("ThreadVolume-in-ConfigsLoader").start();
|
new ThreadVolume("ThreadVolume-in-ConfigsLoader").start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void init() {
|
public static void init() {
|
||||||
Properties properties = cReader.getProperties();
|
Properties properties = cReader.getProperties();
|
||||||
|
|
||||||
Configs.KUBE_MASTER_URL = properties.getProperty("kubeMasterUrl");
|
Configs.KUBE_MASTER_URL = properties.getProperty("kubeMasterUrl");
|
||||||
|
|
||||||
Configs.COLLECT_USER_NAME = properties.getProperty("collect-user-name");
|
Configs.COLLECT_USER_NAME = properties.getProperty("collect-user-name");
|
||||||
|
|
||||||
Configs.COLLECT_PASSWORD = properties.getProperty("collect-password");
|
Configs.COLLECT_PASSWORD = properties.getProperty("collect-password");
|
||||||
|
|
||||||
Configs.COLLECT_SERVICE_NAME = properties
|
Configs.COLLECT_SERVICE_NAME = properties
|
||||||
.getProperty("collect-service-name");
|
.getProperty("collect-service-name");
|
||||||
|
|
||||||
Configs.GATHER_USER_NAME = properties.getProperty("gather-user-name");
|
Configs.GATHER_USER_NAME = properties.getProperty("gather-user-name");
|
||||||
|
|
||||||
Configs.GATHER_USER_PASSWORD = properties
|
Configs.GATHER_USER_PASSWORD = properties
|
||||||
.getProperty("gather-user-password");
|
.getProperty("gather-user-password");
|
||||||
|
|
||||||
Configs.GATHER_PORT = properties.getProperty("gather-port");
|
Configs.GATHER_PORT = properties.getProperty("gather-port");
|
||||||
|
|
||||||
Configs.GATHER_SERVICE_NAME = properties
|
Configs.GATHER_SERVICE_NAME = properties
|
||||||
.getProperty("gather-service-name");
|
.getProperty("gather-service-name");
|
||||||
|
|
||||||
Configs.TABLE_SUFFIX = properties.getProperty("table-suffix");
|
Configs.TABLE_SUFFIX = properties.getProperty("table-suffix");
|
||||||
|
|
||||||
Configs.EXTRACT_LOG_LOCALTION = properties
|
Configs.EXTRACT_LOG_LOCALTION = properties
|
||||||
.getProperty("extract-log-localtion");
|
.getProperty("extract-log-localtion");
|
||||||
|
|
||||||
Configs.GATHER_TABLESPACE_NAME = properties
|
Configs.GATHER_TABLESPACE_NAME = properties
|
||||||
.getProperty("gather-tablespace-name");
|
.getProperty("gather-tablespace-name");
|
||||||
|
|
||||||
Configs.GATHER_TABLESPACE_PATH = properties
|
Configs.GATHER_TABLESPACE_PATH = properties
|
||||||
.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");
|
||||||
|
|
||||||
Configs.FILE_UPLOAD_PATH = properties.getProperty("file_upload_path");
|
Configs.FILE_UPLOAD_PATH = properties.getProperty("file_upload_path");
|
||||||
|
|
||||||
Configs.FILE_DOWNLOAD_PATH = properties.getProperty("file_download_path");
|
Configs.FILE_DOWNLOAD_PATH = properties.getProperty("file_download_path");
|
||||||
|
|
||||||
Configs.PACKAGE_DOWNLOAD_PATH = properties.getProperty("package_download_path");
|
Configs.PACKAGE_DOWNLOAD_PATH = properties.getProperty("package_download_path");
|
||||||
|
|
||||||
Configs.PACKAGE_NAME = properties.getProperty("package_name");
|
Configs.PACKAGE_NAME = properties.getProperty("package_name");
|
||||||
|
|
||||||
Configs.sql_script_path_last = properties.getProperty("sql_script_path_last");
|
Configs.SQL_SCRIPT_PATH_LAST = properties.getProperty("sql_script_path_last");
|
||||||
|
|
||||||
Configs.sql_script_path_standard = properties.getProperty("sql_script_path_standard");
|
Configs.SQL_SCRIPT_PATH_STANDARD = properties.getProperty("sql_script_path_standard");
|
||||||
|
|
||||||
HttpClientConstant.URL_IP_PORT = properties.getProperty("HttpClientConstant_URL_IP_PORT").trim();
|
HttpClientConstant.URL_IP_PORT = properties.getProperty("HttpClientConstant_URL_IP_PORT").trim();
|
||||||
|
|
||||||
Constant.hostIp=properties.getProperty("gfs_control_ip").trim();
|
Constant.hostIp=properties.getProperty("gfs_control_ip").trim();
|
||||||
Constant.rootPasswd=properties.getProperty("gfs_control_rootPassWd").trim();
|
Constant.rootPasswd=properties.getProperty("gfs_control_rootPassWd").trim();
|
||||||
Constant.ganymedSSH = new GanymedSSH(Constant.hostIp, Constant.rootUser, Constant.rootPasswd, Constant.port);
|
Constant.ganymedSSH = new GanymedSSH(Constant.hostIp, Constant.rootUser, Constant.rootPasswd, Constant.port);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConfigPropertyReader getcReader() {
|
public ConfigPropertyReader getcReader() {
|
||||||
return cReader;
|
return cReader;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("static-access")
|
@SuppressWarnings("static-access")
|
||||||
public void setcReader(ConfigPropertyReader cReader) {
|
public void setcReader(ConfigPropertyReader cReader) {
|
||||||
this.cReader = 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