diff --git a/WebContent/WEB-INF/config/mybatis-applicationConfig.xml b/WebContent/WEB-INF/config/mybatis-applicationConfig.xml
index ae09a182..b2c5e781 100644
--- a/WebContent/WEB-INF/config/mybatis-applicationConfig.xml
+++ b/WebContent/WEB-INF/config/mybatis-applicationConfig.xml
@@ -11,6 +11,7 @@
+
diff --git a/WebContent/WEB-INF/web.xml b/WebContent/WEB-INF/web.xml
index 2d425519..304a7726 100644
--- a/WebContent/WEB-INF/web.xml
+++ b/WebContent/WEB-INF/web.xml
@@ -60,7 +60,7 @@
-
+
\ No newline at end of file
diff --git a/src/com/base/BaseController.java b/src/com/base/BaseController.java
index 804f833a..395cd09e 100644
--- a/src/com/base/BaseController.java
+++ b/src/com/base/BaseController.java
@@ -30,7 +30,7 @@ import com.platform.utils.Configs;
public class BaseController {
/** log4j */
- public static Logger log = Logger.getRootLogger();
+ public static Logger log = Configs.DAILY_ROLLING_LOGGER;
/**
* <一句话功能简述> 基于@ExceptionHandler异常处理----全局异常处理
diff --git a/src/com/base/CustomException.java b/src/com/base/CustomException.java
index e40f5697..e59bb6bd 100644
--- a/src/com/base/CustomException.java
+++ b/src/com/base/CustomException.java
@@ -94,7 +94,7 @@ public class CustomException extends Exception {
sbuf.append("\r\n");
// 是否 写入 文件
- log.debug(sbuf.toString());
+ log.error(sbuf.toString());
}
/**
diff --git a/src/com/dao/mapper/data-details-mapper.xml b/src/com/dao/mapper/data-details-mapper.xml
index 61071bd0..73a338c0 100644
--- a/src/com/dao/mapper/data-details-mapper.xml
+++ b/src/com/dao/mapper/data-details-mapper.xml
@@ -76,7 +76,7 @@ PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
- AND CONCAT(regionalism_code,system_code,city_name,district_name,system_name) LIKE CONCAT('%',CONCAT(#{item},'%'))
+ AND CONCAT(regionalism_code,system_code,data_version,city_name,district_name,system_name) LIKE CONCAT('%',CONCAT(#{item},'%'))
diff --git a/src/com/platform/controller/VolumeController.java b/src/com/platform/controller/VolumeController.java
index a787ce07..4f94761a 100644
--- a/src/com/platform/controller/VolumeController.java
+++ b/src/com/platform/controller/VolumeController.java
@@ -12,6 +12,8 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.base.BaseController;
+import com.platform.entities.VolumeEntity;
+import com.platform.entities.VolumeForm;
import com.platform.entities.VolumeInitEntity;
import com.platform.service.IVolumeService;
import com.platform.utils.Configs;
@@ -25,44 +27,23 @@ public class VolumeController extends BaseController{
private IVolumeService volumeService;
- @RequestMapping(value = "/volume/insert", method = RequestMethod.POST)
+ @RequestMapping(value = "/volume/update", method = RequestMethod.POST)
@ResponseBody
- public void volumeInsert(HttpServletRequest res, HttpServletResponse req,
- @RequestBody VolumeInitEntity entity) throws Exception {
+ public void volumeUpdate(HttpServletRequest res, HttpServletResponse req,
+ @RequestBody VolumeEntity form) throws Exception {
Configs.CONSOLE_LOGGER.error("/oracle/{name}/extract");
- volumeService.save(entity);
+ volumeService.save(form);
req.setStatus(200);
}
- @RequestMapping(value = "/volume/{name}/delete", method = RequestMethod.POST)
+ @RequestMapping(value = "/volume/delete", method = RequestMethod.POST)
@ResponseBody
public void volumeDelete(HttpServletRequest res, HttpServletResponse req,
- @RequestBody VolumeInitEntity entity) throws Exception {
+ @RequestBody VolumeEntity entity) throws Exception {
Configs.CONSOLE_LOGGER.error("/oracle/{name}/extract");
volumeService.delete(entity);
req.setStatus(200);
}
-
- @RequestMapping(value = "/volume/{name}/start", method = RequestMethod.POST)
- @ResponseBody
- public void volumeStart(HttpServletRequest res, HttpServletResponse req,
- @RequestBody VolumeInitEntity entity) throws Exception {
- Configs.CONSOLE_LOGGER.error("/oracle/{name}/extract");
- res.setCharacterEncoding("UTF-8");
- volumeService.start(entity);
- req.setStatus(200);
- }
-
-
- @RequestMapping(value = "/volume/{name}/stop", method = RequestMethod.POST)
- @ResponseBody
- public void volumeStop(HttpServletRequest res, HttpServletResponse req,
- @RequestBody VolumeInitEntity entity) throws Exception {
- Configs.CONSOLE_LOGGER.error("/oracle/{name}/extract");
- res.setCharacterEncoding("UTF-8");
- volumeService.stop(entity);
- req.setStatus(200);
- }
}
diff --git a/src/com/platform/entities/VolumeEntity.java b/src/com/platform/entities/VolumeEntity.java
index ae2604ea..450b7154 100644
--- a/src/com/platform/entities/VolumeEntity.java
+++ b/src/com/platform/entities/VolumeEntity.java
@@ -159,4 +159,5 @@ public class VolumeEntity {
this.brick = brick;
}
+
}
diff --git a/src/com/platform/entities/VolumeForm.java b/src/com/platform/entities/VolumeForm.java
new file mode 100644
index 00000000..5baab4fe
--- /dev/null
+++ b/src/com/platform/entities/VolumeForm.java
@@ -0,0 +1,23 @@
+package com.platform.entities;
+
+import java.util.List;
+
+public class VolumeForm {
+
+ List volumes;
+
+ /**
+ * @return the volumes
+ */
+ public List getVolumes() {
+ return volumes;
+ }
+
+ /**
+ * @param volumes the volumes to set
+ */
+ public void setVolumes(List volumes) {
+ this.volumes = volumes;
+ }
+
+}
diff --git a/src/com/platform/entities/VolumeInitEntity.java b/src/com/platform/entities/VolumeInitEntity.java
index fef17763..8f340164 100644
--- a/src/com/platform/entities/VolumeInitEntity.java
+++ b/src/com/platform/entities/VolumeInitEntity.java
@@ -9,14 +9,13 @@ public class VolumeInitEntity {
private String name;
private String ip;
-
+ /** 挂载点 */
private String path;
private String mark;
private List bricks;
- private String mountPoint;
/**
* @return the id
@@ -102,19 +101,4 @@ public class VolumeInitEntity {
this.bricks = bricks;
}
- /**
- * @return the mountPoint
- */
- public String getMountPoint() {
- return mountPoint;
- }
-
- /**
- * @param mountPoint the mountPoint to set
- */
- public void setMountPoint(String mountPoint) {
- this.mountPoint = mountPoint;
- }
-
-
}
diff --git a/src/com/platform/glusterfs/ClusterInfo.java b/src/com/platform/glusterfs/ClusterInfo.java
index 793b86ca..bbd81e1b 100644
--- a/src/com/platform/glusterfs/ClusterInfo.java
+++ b/src/com/platform/glusterfs/ClusterInfo.java
@@ -35,7 +35,7 @@ public class ClusterInfo {
* @see [类、类#方法、类#成员]
*/
public Map showClusterInfo() {
- log.info("get cluster info");
+// log.info("get cluster info");
Map peerIps = new HashMap();
List reStrings = Constant.ganymedSSH.execCmdWaitAcquiescent(Constant.glusterPeerStatus);
diff --git a/src/com/platform/glusterfs/SizeInfo.java b/src/com/platform/glusterfs/SizeInfo.java
index 4d639be2..03f74228 100644
--- a/src/com/platform/glusterfs/SizeInfo.java
+++ b/src/com/platform/glusterfs/SizeInfo.java
@@ -23,7 +23,7 @@ public class SizeInfo {
* @return
*/
public long showAllSize() {
- log.info("get AllSize ");
+// log.info("get AllSize ");
List volumeNames = volumeInfo.showAllVolumeName();
if (volumeNames == null) {
log.error("1201 showAllVolumeName error");
diff --git a/src/com/platform/service/IVolumeService.java b/src/com/platform/service/IVolumeService.java
index 15e211a7..653bded8 100644
--- a/src/com/platform/service/IVolumeService.java
+++ b/src/com/platform/service/IVolumeService.java
@@ -1,15 +1,16 @@
package com.platform.service;
+import com.platform.entities.VolumeEntity;
import com.platform.entities.VolumeInitEntity;
public interface IVolumeService {
- public int save(VolumeInitEntity entity) throws Exception;
+ public int save(VolumeEntity entity) throws Exception;
- public int delete(VolumeInitEntity entity) throws Exception;
+ public int delete(VolumeEntity entity) throws Exception;
- public int start(VolumeInitEntity entity) throws Exception;
+ public int start(VolumeEntity entity) throws Exception;
- public int stop(VolumeInitEntity entity) throws Exception;
+ public int stop(VolumeEntity entity) throws Exception;
}
diff --git a/src/com/platform/service/OracleExtractHelper.java b/src/com/platform/service/OracleExtractHelper.java
index 26d5643d..d2e688a9 100644
--- a/src/com/platform/service/OracleExtractHelper.java
+++ b/src/com/platform/service/OracleExtractHelper.java
@@ -35,7 +35,7 @@ public class OracleExtractHelper {
.fileWrite(filePath, sql+ "\r\n"+"OK \r\n");
} catch (Exception e) {
FileOperateHelper
- .fileWrite(filePath, sql+ "\r\n"+ e.getMessage() + " \r\n");
+ .fileWrite(filePath, sql+ "\r\n"+ e.getMessage() + "\r\n,连接异常! \r\n");
new CustomException(Custom4exception.threadVolume_Oracle_Except, e, rSet);
}
return flag;
diff --git a/src/com/platform/service/impl/VolumeServiceImpl.java b/src/com/platform/service/impl/VolumeServiceImpl.java
index c674f4db..3e41d5ee 100644
--- a/src/com/platform/service/impl/VolumeServiceImpl.java
+++ b/src/com/platform/service/impl/VolumeServiceImpl.java
@@ -1,12 +1,21 @@
package com.platform.service.impl;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.platform.dao.VolumeDao;
+import com.platform.entities.Brick;
+import com.platform.entities.VolumeEntity;
import com.platform.entities.VolumeInitEntity;
import com.platform.glusterfs.SetVolume;
+import com.platform.service.IGfsService;
import com.platform.service.IVolumeService;
@Service(value = "volumeService")
@@ -15,23 +24,98 @@ public class VolumeServiceImpl implements IVolumeService {
/** gfs的api */
SetVolume volumeService = new SetVolume();
+ @Resource(name = "gfsService")
+ private IGfsService gfsService;
+
@Resource(name = "volumeDao")
private VolumeDao volumeDao;
@Override
- public int save(VolumeInitEntity entity) throws Exception {
+ public int save(VolumeEntity entity) throws Exception {
//createVolume("lili_test1", 0, "distributed", bricksToCreate, "/home/lili_test1_point")
- if (null == entity.getBricks()) {
- return -1;
+ List result = gfsService.getAllVolumes();
+ List addVolumes = new ArrayList();
+ VolumeEntity volumeTmp = null;
+ if (null != result) {
+ boolean isExits = false;
+ //.trim() 去掉空格
+ for (VolumeEntity volumeOnServer : result) {
+ if(entity.getName().trim().equals(volumeOnServer.getName().trim())){
+ isExits = true;
+ //TODO 服务器上有该volume,
+ volumeTmp = volumeOnServer;
+ break;
+ }
+ }
+ //如果服务器上没有该volume,
+ if (!isExits) {
+ addVolumes.add(entity);
+ }
+
+ }
+ boolean isContinue = true;
+ //TODO 对比volume信息--原数据没有该volume,则新增volume:
+ for (VolumeEntity add : addVolumes) {
+ //创建volume
+ volumeService.createVolume(add.getName(), 0, "distributed", add.getBrick(), add.getPath());
+ //记录volume信息,
+ VolumeInitEntity volInSql = new VolumeInitEntity();
+ volInSql.setName(add.getName());
+ volInSql.setPath(add.getPath());
+ volumeDao.save(volInSql);
+ isContinue = false;
+ }
+ // 修改 brick
+ if (isContinue && null != volumeTmp) {
+ List newBricks = entity.getBrick();
+ List serverBricks = volumeTmp.getBrick();
+ Map newMap = new HashMap();
+ Map serverMap = new HashMap();
+ for (Brick brick : newBricks) {
+ //IP + path 才 确认唯一的 brick
+ newMap.put(brick.getIp() + ":" + brick.getPath(), brick);
+ }
+ for (Brick brick : serverBricks) {
+ serverMap.put(brick.getIp() + ":" + brick.getPath(), brick);
+ }
+ // ----对比volume信息--原数据有该volume,则对比brick信息,确认那几个brick是新增的,那几个brick是待删除的----start
+ Set newBrickKeys = newMap.keySet();
+ Set serverBrickKeys = serverMap.keySet();
+ //新增的Brick的 Keys
+ newBrickKeys.removeAll(serverBrickKeys);
+ List newKeys = new ArrayList();
+ newKeys.addAll(newBrickKeys);
+ // 新增brick s,
+ if (newKeys.size() > 0) {
+ volumeService.addBrickVolume(entity.getName(), newKeys, 0, "distributed");
+ }
+ //待删除的Brick的 Keys
+ newBrickKeys = newMap.keySet();
+ serverBrickKeys.removeAll(newBrickKeys);
+ List deleteKeys = new ArrayList();
+ deleteKeys.addAll(serverBrickKeys);
+ // 删除brick s,
+ if (deleteKeys.size() > 0) {
+ volumeService.deleteBrickVolume(entity.getName(), deleteKeys, 0, "distributed");
+ }
+ // ---对比volume信息--原数据有该volume,则对比brick信息,确认那几个brick是新增的,那几个brick是待删除的----- end
+
+ //TODO 查看状态 状态Started,Stopped,Created
+ if (!volumeTmp.getStatus().equals(entity.getStatus())) {
+ if ("Started".equals(entity.getStatus())) {
+ this.start(entity);
+ }
+ else if ("Stopped".equals(entity.getStatus())) {
+ this.stop(entity);
+ }
+ }
}
- volumeService.createVolume(entity.getName(), 0, "distributed", entity.getBricks(), entity.getMountPoint());
- volumeDao.save(entity);
return 0;
}
@Override
- public int delete(VolumeInitEntity entity) throws Exception {
+ public int delete(VolumeEntity entity) throws Exception {
if (null == entity.getName() || "".equals(entity.getName())) {
return -1;
}
@@ -41,7 +125,7 @@ public class VolumeServiceImpl implements IVolumeService {
}
@Override
- public int start(VolumeInitEntity entity) throws Exception {
+ public int start(VolumeEntity entity) throws Exception {
if (null == entity.getName() || "".equals(entity.getName())) {
return -1;
}
@@ -49,7 +133,7 @@ public class VolumeServiceImpl implements IVolumeService {
}
@Override
- public int stop(VolumeInitEntity entity) throws Exception {
+ public int stop(VolumeEntity entity) throws Exception {
if (null == entity.getName() || "".equals(entity.getName())) {
return -1;
}
diff --git a/src/com/platform/service/thread/ThreadMoveData.java b/src/com/platform/service/thread/ThreadMoveData.java
index 9967e056..3b0d82ed 100644
--- a/src/com/platform/service/thread/ThreadMoveData.java
+++ b/src/com/platform/service/thread/ThreadMoveData.java
@@ -138,7 +138,6 @@ public class ThreadMoveData{
data.setDataPath(dataMove.getDstPath());
data.setVolumeIp(dataMove.getDstVolumeIp());
data.setVolumePath(dataMove.getDstVolumePath());
- data.setYear(DateForm.date2StringByMin(new Date()));
data.setVolumeIp(dataMove.getVolumeIp());
data.setId(0);
dataInfoDao.save(data);
diff --git a/src/com/platform/utils/Constant.java b/src/com/platform/utils/Constant.java
index 4d230460..30fc1994 100644
--- a/src/com/platform/utils/Constant.java
+++ b/src/com/platform/utils/Constant.java
@@ -39,7 +39,7 @@ public class Constant {
/**
* volume 获取的线程休眠时间
*/
- public final static int get_volume_sleep_time = 600000;
+ public final static int get_volume_sleep_time = 10000;
/**
* volume 获取的线程休眠时间
diff --git a/src/com/platform/utils/ThreadVolume.java b/src/com/platform/utils/ThreadVolume.java
index 03832e9e..ed7cf144 100644
--- a/src/com/platform/utils/ThreadVolume.java
+++ b/src/com/platform/utils/ThreadVolume.java
@@ -61,7 +61,7 @@ public class ThreadVolume extends Thread implements Runnable{
if (null != path && path.size() > 0) {
volume.setPath(path.get(0));
}
- volume.setAllSize(volumeInfo.getVolumeAvailableSize(volumeName));
+ volume.setAllSize(volumeInfo.getVolumeAvailableSize(volumeName)+volumeInfo.getVolumeUseSize(volumeName));
volume.setStatus(volumeInfo.getVolumeStatus(volumeName));
volume.setUsedSize(volumeInfo.getVolumeUseSize(volumeName));
volume.setType(volumeInfo.getVolumeType(volumeName));