diff --git a/WebContent/WEB-INF/config/config.properties b/WebContent/WEB-INF/config/config.properties index 7381d79d..ed3ca5f6 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://127.0.0.1:3306/extend_glusterfs?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true +jdbc.mysql.url=jdbc:mysql://192.168.0.110:3306/ftpdata?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true # 用户名 jdbc.mysql.username=root # 密码 @@ -46,11 +46,11 @@ gather-tablespace-name=TS_TTSSS gather-tablespace-path= gather-table-user-password= -kubeMasterUrl=http://192.168.191.23:8080/ +kubeMasterUrl=http://192.168.0.110:8080/ collect-user-name=system collect-password=oracle collect-service-name=orcl -gfs_control_ip=192.168.191.23 +gfs_control_ip=192.168.0.110 gfs_control_rootPassWd=root \ No newline at end of file diff --git a/src/com/platform/controller/VolumeController.java b/src/com/platform/controller/VolumeController.java index 0d6600f2..8adf52fb 100644 --- a/src/com/platform/controller/VolumeController.java +++ b/src/com/platform/controller/VolumeController.java @@ -33,7 +33,7 @@ public class VolumeController extends BaseController{ @ResponseBody public void volumeUpdate(HttpServletRequest res, HttpServletResponse req, @RequestBody VolumeEntity form) throws Exception { - Configs.CONSOLE_LOGGER.error("/oracle/{name}/extract"); + Configs.CONSOLE_LOGGER.error("/oracle/update"); volumeService.save(form); req.setStatus(200); new ThreadVolumeImm("ThreadVolumeImm-in-VolumeController-update").start(); diff --git a/src/com/platform/oracle/OracleConnector.java b/src/com/platform/oracle/OracleConnector.java index 923d578b..16f9d09a 100644 --- a/src/com/platform/oracle/OracleConnector.java +++ b/src/com/platform/oracle/OracleConnector.java @@ -8,6 +8,7 @@ import java.sql.Statement; import com.base.Custom4exception; import com.base.CustomException; +import com.platform.entities.OracleConnectorParams; import com.platform.utils.Configs; import com.platform.utils.FileOperateHelper; @@ -25,19 +26,23 @@ public class OracleConnector { public synchronized static Connection ConnectionBuilder(String url, String user, - String password) { + String password, OracleConnectorParams oc) { Connection conn=null; try { conn = DriverManager.getConnection(url, user, password); } catch (SQLException e) { new CustomException(Custom4exception.OracleSQL_Except, e); Configs.CONSOLE_LOGGER.info("创建oracle连接失败: [" + e.getMessage() + "]"); + if (null != oc) { + FileOperateHelper.fileWrite(Configs.EXTRACT_LOG_LOCALTION + + oc.getName(), "创建oracle连接失败: [" + e.getMessage() + "]\r\n"); + } } return conn; } public synchronized static boolean canConnect(String url, String user, String password) { - return (null != ConnectionBuilder(url, user, password)); + return (null != ConnectionBuilder(url, user, password, null)); } public synchronized static ResultSet getSQLExecResultSet(Connection conn, String sql, String filePath) { @@ -60,7 +65,7 @@ public class OracleConnector { public synchronized static ResultSet getSQLExecResultSet(String url, String user, String password, String sql, String filePath) { - return getSQLExecResultSet(ConnectionBuilder(url, user, password), sql, filePath); + return getSQLExecResultSet(ConnectionBuilder(url, user, password, null), sql, filePath); } /** diff --git a/src/com/platform/service/DataInfoServiceImp.java b/src/com/platform/service/DataInfoServiceImp.java index 4baf7db0..f947f72f 100644 --- a/src/com/platform/service/DataInfoServiceImp.java +++ b/src/com/platform/service/DataInfoServiceImp.java @@ -3,9 +3,12 @@ package com.platform.service; import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import javax.annotation.Resource; +import org.apache.log4j.Logger; import org.springframework.stereotype.Service; import org.springframework.ui.ModelMap; @@ -13,12 +16,20 @@ import com.base.CustomException; import com.platform.dao.DataInfoDao; import com.platform.entities.DataInfoEntity; import com.platform.entities.PagerOptions; +import com.platform.glusterfs.RemoveData; import com.platform.utils.Bean2MapUtils; +import com.platform.utils.Configs; @Service(value = "dataInfoService") public class DataInfoServiceImp implements DataInfoService { + + /** log4j */ + public static Logger log = Configs.DAILY_ROLLING_LOGGER; + @Resource(name = "dataInfoDao") private DataInfoDao dfdDao; + + private RemoveData removedata = new RemoveData(); public void setDfdDao(DataInfoDao dfdDao) { this.dfdDao = dfdDao; @@ -70,9 +81,24 @@ public class DataInfoServiceImp implements DataInfoService { //数据在不在? List paths = dfdDao.getIdIsExist(ids); if(paths.size()>0){ - //删除文件操作 + //TODO 删除文件操作 + Pattern pattern = Pattern + .compile("\\/$"); for (int i = 0; i < paths.size(); i++) { - System.out.println(paths.get(i)); + String folderPath = paths.get(i); + Matcher matcher = pattern.matcher(folderPath); + String tailPath = ""; + if (matcher.find()) { + tailPath = matcher.group(); + } + folderPath = folderPath.substring(0, folderPath.length()-tailPath.length()); + int res = removedata.deleteFolder(folderPath); + if (res != 1) { + log.error( folderPath+ " 删除失败!\n"); + } + else { + log.info( folderPath+ " 删除成功!\n"); + } } //删除数据库记录 dfdDao.removes(ids); diff --git a/src/com/platform/service/OracleExtractService.java b/src/com/platform/service/OracleExtractService.java index 1b23ed7c..23df97ce 100644 --- a/src/com/platform/service/OracleExtractService.java +++ b/src/com/platform/service/OracleExtractService.java @@ -13,7 +13,7 @@ public class OracleExtractService extends Thread implements Runnable { public OracleExtractService(OracleConnectorParams ocp){ this.ocp=ocp; String url = ""; - this.conn=OracleConnector.ConnectionBuilder(url, Configs.GATHER_USER_NAME, Configs.GATHER_USER_PASSWORD); + this.conn=OracleConnector.ConnectionBuilder(url, Configs.GATHER_USER_NAME, Configs.GATHER_USER_PASSWORD, null); } @Override public void run() { diff --git a/src/com/platform/service/impl/OracleExtractServiceImpl.java b/src/com/platform/service/impl/OracleExtractServiceImpl.java index 908dc4c9..a53bef9b 100644 --- a/src/com/platform/service/impl/OracleExtractServiceImpl.java +++ b/src/com/platform/service/impl/OracleExtractServiceImpl.java @@ -19,6 +19,7 @@ import com.platform.service.IOracleExtractService; import com.platform.service.OracleExtractHelper; import com.platform.utils.Configs; import com.platform.utils.Constant; +import com.platform.utils.FileOperateHelper; @Service(value = "OracleExtract") public class OracleExtractServiceImpl implements IOracleExtractService { @@ -48,8 +49,16 @@ public class OracleExtractServiceImpl implements IOracleExtractService { GatherOracleInfo oracleModel = oracleConnect; //采集库连接参数 List datainfos = dataInfolist; + if (datainfos.size() == 0) { + return false; + } Connection conn = OracleConnector.ConnectionBuilder("jdbc:oracle:thin:@" + oracleModel.getIp() + ":" + oracleModel.getPort() + ":" - + oracleModel.getDatabaseName(), oracleModel.getUser(), oracleModel.getPassword()); + + oracleModel.getDatabaseName(), oracleModel.getUser(), oracleModel.getPassword(),dataInfolist.get(0)); + if (null == conn) { + FileOperateHelper.fileWrite(Configs.EXTRACT_LOG_LOCALTION + + dataInfolist.get(0).getName(), "创建oracle连接失败: [" + conn + "]\r\n"); + return false; + } for (OracleConnectorParams collectOracle : datainfos) { if(null != collectOracle.getDataId() && !"".equals(collectOracle.getDataId())){ diff --git a/src/com/platform/service/thread/ThreadMoveData.java b/src/com/platform/service/thread/ThreadMoveData.java index 3b0d82ed..569a62b0 100644 --- a/src/com/platform/service/thread/ThreadMoveData.java +++ b/src/com/platform/service/thread/ThreadMoveData.java @@ -101,12 +101,20 @@ public class ThreadMoveData{ srcSizeTemp = show.getFolderSize(dataMove.getDataPath()); long srcSize = (long) (srcSizeTemp * 0.998); dstSize = show.getFolderSize(dataMove.getDstPath()); + boolean isExist = false; if (srcSize < 0) { log.error(dataMove.getDataPath() + " : 路径不存在! "); - continue; + isExist = true; } if (dstSize < 0) { log.error(dataMove.getDstPath() + " : 路径不存在! "); + isExist = true; + } + if (isExist) { + // 3:表示 迁移失败 + dataMove.setLastTime(DateForm.date2StringBysecond(new Date())); + dataMove.setCompleteStatus("3"); + dataInfoMoveTmpDao.update(dataMove); continue; } if (srcSize > 0 && dstSize > 0) { diff --git a/src/com/platform/utils/GanymedSSH.java b/src/com/platform/utils/GanymedSSH.java index c7295702..611f4e5e 100644 --- a/src/com/platform/utils/GanymedSSH.java +++ b/src/com/platform/utils/GanymedSSH.java @@ -149,7 +149,9 @@ public class GanymedSSH { // TODO Auto-generated catch block e.printStackTrace(); } finally { - sess.close(); + if (null != sess) { + sess.close(); + } } return reStrings;