From 6aa31f96f5fc92d0095874fc8eb8f2f179b81743 Mon Sep 17 00:00:00 2001 From: chenlw <874313221@qq.com> Date: Wed, 28 Sep 2016 11:06:53 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dgfs=E8=BF=9E=E6=8E=A5?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WebContent/WEB-INF/config/config.properties | 6 +++--- src/com/platform/oracle/OracleConnector.java | 11 ++++++++--- src/com/platform/service/OracleExtractService.java | 2 +- .../service/impl/OracleExtractServiceImpl.java | 11 ++++++++++- src/com/platform/utils/GanymedSSH.java | 4 +++- 5 files changed, 25 insertions(+), 9 deletions(-) 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/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/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/utils/GanymedSSH.java b/src/com/platform/utils/GanymedSSH.java index a2fa59e3..e236ced5 100644 --- a/src/com/platform/utils/GanymedSSH.java +++ b/src/com/platform/utils/GanymedSSH.java @@ -145,7 +145,9 @@ public class GanymedSSH { // TODO Auto-generated catch block e.printStackTrace(); } finally { - sess.close(); + if (null != sess) { + sess.close(); + } } return reStrings; From 1bbd61f8c0961cd0a39c5c715f5ae1e107b66eae Mon Sep 17 00:00:00 2001 From: chenlw <874313221@qq.com> Date: Wed, 28 Sep 2016 16:43:35 +0800 Subject: [PATCH 2/5] =?UTF-8?q?volume=E5=8F=98=E5=8C=96=E5=90=8E=E7=AB=8B?= =?UTF-8?q?=E5=8D=B3=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/com/platform/controller/VolumeController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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(); From b803b3825c23da5b8b27ef60ae96d12fec7f9944 Mon Sep 17 00:00:00 2001 From: chenlw <874313221@qq.com> Date: Wed, 28 Sep 2016 16:44:24 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=EF=BC=8C=E5=8F=AA=E5=88=A0=E9=99=A4=E8=AF=A5=E6=9D=A1=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E7=9B=AE=E5=BD=95=E7=9A=84=E7=89=88=E6=9C=AC=E7=9B=AE?= =?UTF-8?q?=E5=BD=95=EF=BC=8C=E4=B8=8D=E5=88=A0=E9=99=A4=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../platform/service/DataInfoServiceImp.java | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) 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); From df71293e0dcf7853fbc7ac32b409e21d73e60bab Mon Sep 17 00:00:00 2001 From: chenlw <874313221@qq.com> Date: Wed, 28 Sep 2016 16:45:09 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E8=BF=81=E7=A7=BB=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E6=BA=90=E7=9B=AE=E5=BD=95=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=B8=8D=E5=AD=98=E5=9C=A8=E6=97=B6=EF=BC=8C=E8=BF=81=E7=A7=BB?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/com/platform/service/thread/ThreadMoveData.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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) { From 94a18d8258aa871eb7c9d922eae9e99bbb20c101 Mon Sep 17 00:00:00 2001 From: chenlw <874313221@qq.com> Date: Wed, 28 Sep 2016 16:46:54 +0800 Subject: [PATCH 5/5] =?UTF-8?q?shell=E5=91=BD=E4=BB=A4=E8=8E=B7=E5=BE=97?= =?UTF-8?q?=E6=AD=A3=E5=B8=B8=E8=BE=93=E5=87=BA=E6=B5=81=E5=90=8E=E5=B0=B1?= =?UTF-8?q?=E4=B8=8D=E5=86=8D=E5=8E=BB=E8=8E=B7=E5=8F=96=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E6=B5=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/com/platform/utils/GanymedSSH.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/com/platform/utils/GanymedSSH.java b/src/com/platform/utils/GanymedSSH.java index 72d8f2c6..611f4e5e 100644 --- a/src/com/platform/utils/GanymedSSH.java +++ b/src/com/platform/utils/GanymedSSH.java @@ -123,7 +123,7 @@ public class GanymedSSH { BufferedReader stdoutReader = new BufferedReader(new InputStreamReader(stdout)); BufferedReader stderrReader = new BufferedReader(new InputStreamReader(stderr)); while (true) { - String line = stderrReader.readLine(); + String line = stdoutReader.readLine(); if (line != null) { // System.out.println(line); @@ -135,7 +135,7 @@ public class GanymedSSH { if(reStrings.size()==0){ while (true) { - String line = stdoutReader.readLine(); + String line = stderrReader.readLine(); if (line != null) { // System.out.println(line);