解决冲突----

web_backend_develope
wu ming 9 years ago
commit 5ba88b2d41

@ -9,10 +9,14 @@
<typeAlias alias="PagerOptions" type="com.platform.entities.PagerOptions"/>
<typeAlias alias="GatherOracleInfo" type="com.platform.entities.GatherOracleInfo"/>
<typeAlias alias="DataInfoEntityMoveTmp" type="com.platform.entities.DataInfoEntityMoveTmp"/>
<typeAlias alias="SystemEntity" type="com.platform.entities.SystemEntity"/>
<typeAlias alias="RegionalismEntity" type="com.platform.entities.RegionalismEntity"/>
</typeAliases>
<mappers>
<mapper resource="com/dao/mapper/data-details-mapper.xml" />
<mapper resource="com/dao/mapper/config-details-mapper.xml"/>
<mapper resource="com/dao/mapper/dataInfoMoveTmpmapper.xml"/>
<mapper resource="com/dao/mapper/RegionalismMapper.xml"/>
<mapper resource="com/dao/mapper/SystemCodeMapper.xml"/>
</mappers>
</configuration>

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
"http://ibatis.apache.org/dtd/ibatis-3-mapper.dtd">
<mapper namespace="com.platform.dao.IRegionalismCodeDao">
<resultMap id="getEntityByText" type="com.platform.entities.RegionalismEntity">
<id property="code" column="code" jdbcType="VARCHAR" />
<result property="cityName" column="city_name" jdbcType="VARCHAR" />
<result property="districtName" column="district_name" jdbcType="VARCHAR" />
</resultMap>
<sql id="Base_Column_List">
code,city_name,district_name
</sql>
<!-- 获取数据全部记录信息 -->
<select id="findAllRegionalism" resultMap="getEntityByText">
SELECT
<include refid="Base_Column_List" />
FROM regionalism_info
order by code
</select>
<select id="findSubRegionalism" parameterType="com.platform.entities.RegionalismEntity" resultMap="getEntityByText">
SELECT
<include refid="Base_Column_List" />
FROM regionalism_info
<where>
<if test="code != null and code != ''">
AND code LIKE CONCAT(CONCAT('%', #{code}), '%')
</if>
<if test="cityName != null and cityName != ''">
AND city_name LIKE CONCAT(CONCAT('%', #{cityName}), '%')
</if>
<if test="districtName != null and districtName != ''">
AND district_name LIKE CONCAT(CONCAT('%', #{districtName}), '%')
</if>
</where>
order by code
</select>
</mapper>

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
"http://ibatis.apache.org/dtd/ibatis-3-mapper.dtd">
<mapper namespace="com.platform.dao.ISystemCodeDao">
<resultMap id="getEntityByText" type="com.platform.entities.SystemEntity">
<id property="code" column="code" jdbcType="INTEGER" />
<result property="systemName" column="system_name" jdbcType="VARCHAR" />
</resultMap>
<sql id="Base_Column_List">
code,system_name
</sql>
<!-- 获取数据全部记录信息 -->
<select id="findAllSystem" resultMap="getEntityByText">
SELECT
<include refid="Base_Column_List" />
FROM system_info
order by code
</select>
<select id="findSubSystem" parameterType="com.platform.entities.SystemEntity" resultMap="getEntityByText">
SELECT
<include refid="Base_Column_List" />
FROM system_info
<where>
<if test="code > 0">
AND code = #{code}
</if>
<if test="cityName != null and cityName != ''">
AND city_name LIKE CONCAT(CONCAT('%', #{cityName}), '%')
</if>
<if test="districtName != null and districtName != ''">
AND district_name LIKE CONCAT(CONCAT('%', #{districtName}), '%')
</if>
</where>
order by code
</select>
</mapper>

@ -32,8 +32,18 @@ PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
javaType="string" jdbcType="VARCHAR" />
<result property="collectorName" column="collector_name"
javaType="string" jdbcType="VARCHAR" />
<result property="extractStatus" column="extract_status" jdbcType="INTEGER" />
<result property="year" column="data_year" javaType="string"
jdbcType="VARCHAR" />
<result property="startYear" column="start_year" javaType="string"
jdbcType="VARCHAR" />
<result property="endYear" column="end_year" javaType="string"
jdbcType="VARCHAR" />
<result property="volumeIp" column="volume_ip" javaType="string"
jdbcType="VARCHAR" />
<result property="volumePath" column="volume_path" javaType="string"
jdbcType="VARCHAR" />
</resultMap>
<sql id="conditionsFilters">
<if test="PagerOptions.dataType!=null">
@ -65,7 +75,7 @@ PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
<select id="getLimitedDataInfoEntities" parameterType="PagerOptions"
resultMap="getEntityByText">
SELECT
id,regionalism_code,city_name,district_name,system_code,system_name,data_type,data_version,submitted_batch,data_path,data_charset,collection_time,collector_name,collector_contacts,data_year
id,regionalism_code,city_name,district_name,system_code,system_name,data_type,data_version,submitted_batch,data_path,data_charset,collection_time,collector_name,collector_contacts,extract_status,data_year,start_year,end_year,volume_ip,volume_path
FROM data_details
<if test="PagerOptions!=null">
<where>
@ -113,7 +123,7 @@ PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
<if test="regionalismCode != null and regionalismCode != ''">
regionalism_code,
</if>
<if test="systemCode > 0">
<if test="systemCode != null">
system_code,
</if>
<if test="dataType != null and dataType != ''">
@ -141,7 +151,22 @@ PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
data_charset,
</if>
<if test="year != null and year != ''">
data_year
data_year,
</if>
<if test="startYear != null and startYear != ''">
start_year,
</if>
<if test="endYear != null and endYear != ''">
end_year,
</if>
<if test="volumeIp != null and volumeIp != ''">
volume_ip,
</if>
<if test="volumePath != null and volumePath != ''">
volume_path,
</if>
<if test="extractStatus > 0">
extract_status,
</if>
</trim>
)
@ -178,7 +203,22 @@ PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
#{charset},
</if>
<if test="year != null and year != ''">
#{year}
#{year},
</if>
<if test="startYear != null and startYear != ''">
#{start_year},
</if>
<if test="endYear != null and endYear != ''">
#{end_year},
</if>
<if test="volumeIp != null and volumeIp != ''">
#{volumeIp},
</if>
<if test="volumePath != null and volumePath != ''">
#{volumePath},
</if>
<if test="extractStatus > 0">
#{extractStatus},
</if>
</trim>
)

@ -1,109 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
"http://ibatis.apache.org/dtd/ibatis-3-mapper.dtd">
<mapper namespace="com.platform.dao.DataInfoDao">
<resultMap id="getEntityByText" type="DataInfoEntity">
<id property="id" column="id" javaType="int" jdbcType="INTEGER" />
<result property="regionalismCode" column="regionalism_code"
javaType="string" jdbcType="VARCHAR" />
<result property="cityName" column="city_name" javaType="string"
jdbcType="VARCHAR" />
<result property="districtName" column="district_name"
javaType="string" jdbcType="VARCHAR" />
<result property="systemCode" column="system_code" javaType="int"
jdbcType="INTEGER" />
<result property="systemName" column="system_name" javaType="string"
jdbcType="VARCHAR" />
<result property="dataType" column="data_type" javaType="string"
jdbcType="VARCHAR" />
<result property="dataVersion" column="data_version" javaType="int"
jdbcType="INTEGER" />
<result property="submittedBatch" column="submitted_batch"
javaType="string" jdbcType="VARCHAR" />
<result property="dataPath" column="data_path" javaType="string"
jdbcType="VARCHAR" />
<result property="charset" column="data_charset" javaType="string"
jdbcType="VARCHAR" />
<result property="collectingTime" column="collection_time"
javaType="string" jdbcType="DATE" />
<result property="collectorContacts" column="collector_contacts"
javaType="string" jdbcType="VARCHAR" />
<result property="collectorName" column="collector_name"
javaType="string" jdbcType="VARCHAR" />
<result property="year" column="data_year" javaType="string"
jdbcType="VARCHAR" />
</resultMap>
<sql id="conditionsFilters">
<if test="PagerOptions.dataType!=null">
and data_details.data_type=#{PagerOptions.dataType}
</if>
<if test="PagerOptions.submittedBatch!=null">
and
data_details.submitted_batch=#{PagerOptions.submittedBatch}
</if>
<if test="PagerOptions.cityName!=null">
and data_details.city_name=#{PagerOptions.cityName}
</if>
<if test="PagerOptions.districtName!=null">
and
data_details.district_name=#{PagerOptions.districtName}
</if>
<if test="PagerOptions.dataVersion !=null">
and data_details.data_version=#{PagerOptions.dataVersion}
</if>
<if test="PagerOptions.systemName !=null">
and data_details=#{PagerOptions.systemName}
</if>
<if test="PagerOptions.dataYear !=null">
and data_details.data_year=#{PagerOptions.dataYear}
</if>
</sql>
<!-- 获取数据符合筛选条件的全部记录信息 -->
<select id="3
" parameterType="PagerOptions"
resultMap="getEntityByText">
SELECT
id,regionalism_code,city_name,district_name,system_code,system_name,data_type,data_version,submitted_batch,data_path,data_charset,collection_time,collector_name,collector_contacts,data_year
FROM data_details
<if test="PagerOptions!=null">
<where>
<include refid="conditionsFilters" />
<choose>
<when test="PagerOptions.offset > 0">
and data_details.id>= #{PagerOptions.offset}
</when>
<otherwise>
and data_details.id>=0
</otherwise>
</choose>
</where>
ORDER BY data_details.id
<if test="PagerOptions.limit > 0">
LIMIT #{PagerOptions.limit}
</if>
</if>
</select>
<!-- 获取数据符合筛选条件的总记录条数 -->
<select id="getLimitedDataCount" resultType="java.lang.Integer"
parameterType="PagerOptions">
SELECT COUNT(id) FROM data_details
<if test="PagerOptions!=null">
<where>
<include refid="conditionsFilters" />
</where>
</if>
</select>
<!-- 获取数据查询的起始di -->
<select id="getLimitedBeginId" resultType="java.lang.Integer"
parameterType="PagerOptions">
SELECT MAX(idx) FROM (SELECT id idx FROM data_details
ORDER BY id LIMIT 0,#{PagerOptions.totalLimit}) AS TEMP
</select>
</mapper>

@ -43,23 +43,28 @@ PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
jdbcType="INTEGER" />
<result property="lastTime" column="lasttime"
javaType="string" jdbcType="VARCHAR" />
<result property="fkid" column="fkid" javaType="int" jdbcType="INTEGER" />
<result property="dstVolumeIp" column="dst_volume_ip" jdbcType="VARCHAR" />
<result property="dstVolumePath" column="dst_volume_ip" jdbcType="VARCHAR" />
</resultMap>
<sql id="Base_Column_List">
regionalism_code,system_code,dst_path,lasttime
regionalism_code,system_code,dst_path,lasttime,fkid
</sql>
<!-- 获取数据全部记录信息 -->
<select id="findAll" resultType="com.platform.entities.DataInfoEntityMoveTmp">
SELECT
a.id id,a.regionalism_code regionalismCode,b.city_name cityName,b.district_name districtName,
a.system_code systemCode,b.system_name systemName,b.data_type dataType,b.data_version dataVersion,
b.submitted_batch submittedBatch,b.data_path dataPath,b.data_charset charset,b.collection_time collectionTime,
b.collector_name collectorName,b.collector_contacts collectorContacts,b.data_year dataYear,a.dst_path dstPath,
a.complete_status completeStatus,a.rate rate, a.lasttime lastTime
a.id id,a.regionalism_code regionalismCode,a.dst_path dstPath,a.complete_status completeStatus,
a.rate rate, a.lasttime lastTime, a.system_code systemCode,a.dst_volume_ip dstVolumeIp,a.dst_volume_path dstVolumePath,
b.city_name cityName,b.district_name districtName,b.system_name systemName,b.data_type dataType,
b.data_version dataVersion,b.submitted_batch submittedBatch,b.data_path dataPath,b.data_charset charset,
b.collection_time collectingTime,b.collector_name collectorName,b.collector_contacts collectorContacts,
b.data_year year,b.extract_status extractStatus,b.start_year startYear,b.end_year endYear,
b.volume_ip volumeIp,b.volume_path volumePath
FROM
move_data_tmp a LEFT JOIN data_details b
ON a.system_code = b.system_code AND a.regionalism_code = b.regionalism_code
ON a.system_code = b.system_code AND a.regionalism_code = b.regionalism_code AND a.fkid = b.id
ORDER BY a.id
</select>
@ -112,6 +117,9 @@ PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
<if test="lastTime != null and lastTime != ''">
lasttime,
</if>
<if test="fkid > 0 ">
fkid,
</if>
</trim>
)
VALUES(
@ -137,6 +145,9 @@ PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
<if test="lastTime != null and lastTime != ''">
#{lastTime},
</if>
<if test="fkid > 0 ">
#{fkid),
</if>
</trim>
)
</insert>
@ -145,7 +156,7 @@ PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
INSERT INTO move_data_tmp ( <include refid="Base_Column_List" /> )
VALUES
<foreach collection="list" item="item" index="index" separator=",">
(#{item.regionalismCode,jdbcType=VARCHAR},#{item.systemCode,jdbcType=INTEGER},#{item.dstPath,jdbcType=VARCHAR},#{item.lastTime,jdbcType=VARCHAR})
(#{item.regionalismCode,jdbcType=VARCHAR},#{item.systemCode,jdbcType=INTEGER},#{item.dstPath,jdbcType=VARCHAR},#{item.lastTime,jdbcType=VARCHAR},#{item.fkid})
</foreach>
</select>

@ -2,6 +2,7 @@ package com.platform.controller;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -11,11 +12,15 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
@ -25,20 +30,31 @@ import com.platform.entities.DataInfoEntity;
import com.platform.entities.DataInfoEntityMoveTmp;
import com.platform.entities.FolderNode;
import com.platform.entities.GatherOracleInfo;
import com.platform.entities.OracleConnectorParams;
import com.platform.entities.PagerOptions;
import com.platform.entities.VolumeEntity;
import com.platform.glusterfs.CheckoutMD5;
import com.platform.service.DataInfoService;
import com.platform.service.ICodeService;
import com.platform.service.IGfsService;
import com.platform.service.IMoveDataService;
import com.platform.service.IMySqlService;
import com.platform.service.IOracleExtractService;
import com.platform.service.OracleExtractHelper;
import com.platform.service.OracleStatusService;
import com.platform.service.impl.MySqlServiceImpl;
import com.platform.test.Brick;
import com.platform.test.FolderReader;
import com.platform.test.Volume;
import com.platform.utils.Bean2MapUtils;
import com.platform.utils.Configs;
import com.platform.utils.UtilsHelper;
@Controller
public class DataModelController extends BaseController{
public static Logger log = Logger.getLogger(DataModelController.class);
@Resource(name = "dataInfoService")
private DataInfoService dfs;
@ -54,6 +70,9 @@ public class DataModelController extends BaseController{
@Resource(name = "moveDataService")
private IMoveDataService moveDataService;
@Resource(name = "codeService")
private ICodeService codeService;
public void setDfsImp(DataInfoService dfs) {
this.dfs = dfs;
}
@ -119,9 +138,8 @@ public class DataModelController extends BaseController{
}
}
@SuppressWarnings({ "unused", "rawtypes", "unchecked" })
@RequestMapping(value="/oracle/{name}/extract", method= RequestMethod.POST)
public void extractOracleData(HttpServletRequest res,
public void oracleExtract(HttpServletRequest res,
HttpServletResponse req, String name) throws Exception {
res.setCharacterEncoding("UTF-8");
System.out.println("------extract-------");
@ -147,24 +165,44 @@ public class DataModelController extends BaseController{
OracleExtract.extractOracle(name, colleclist, map);
}
// public void oracleExtract(HttpServletRequest res,
// HttpServletResponse req, String name, @RequestBody GatherOracleInfo gather, @RequestBody List<OracleConnectorParams> collectOracles)
// throws Exception {
//// res.setCharacterEncoding("UTF-8");
// log.debug("------extract-------");
//// Map<String, String[]> paramMap = res.getParameterMap();
//// log.debug(paramMap);
//// //汇总库 对象信息--带有tableName-
//// String[] nodes = paramMap.get("target");
//// Map map = null;
//// for (String string : nodes) {
//// JSONObject jsonobject = JSONObject.fromObject(string);
//// map = jsonobject;
//// System.out.println(map);
//// }
////
//// // 采集库对象--(多个采集库抽取到1个汇总库的1个tableName下)
//// String[] inneed = paramMap.get("inneed");
//// List<Map<String, String>> colleclist = new ArrayList<Map<String,String>>();
//// for (String string : nodes) {
//// JSONObject jsonobject = JSONObject.fromObject(string);
//// Map inneedMap = jsonobject;
//// colleclist.add(inneedMap);
//// }
// OracleExtract.extractOracle(name, collectOracles, gather);
// }
@RequestMapping(value="/volume/list", method= RequestMethod.POST)
@ResponseBody
public List<VolumeEntity> getFolder(HttpServletRequest res, HttpServletResponse req) throws Exception {
System.out.println("get Request");
// Brick brick1 = new Brick("192.168.0.101", "D:/bootstrap");
// Brick brick2 = new Brick("192.168.0.103", "D:\book");
// List<Brick> bricks = new ArrayList<Brick>();
// bricks.add(brick1);
// bricks.add(brick2);
public List<VolumeEntity> volumeList() throws Exception {
log.debug("-----/volume/list------");
List<VolumeEntity> result = gfsService.getAllVolumes();
return result;
}
@SuppressWarnings({ "unused", "rawtypes" })
@RequestMapping(value = "/volume/{name}/move", method= RequestMethod.POST)
@ResponseBody
public Object move(HttpServletRequest res, HttpServletResponse req, String name,
// @ResponseBody
public void volumeMove(HttpServletRequest res, HttpServletResponse req, String name,
FolderNode selectNode, DataInfoEntity selectItems) throws Exception {
res.setCharacterEncoding("UTF-8");
System.out.println("get Request");
@ -188,71 +226,95 @@ public class DataModelController extends BaseController{
System.out.println(string);
JSONObject jsobj = JSONObject.fromObject(string);
Map itemmap = jsobj;
if (null != itemmap.get("volume")) {
srcVolumes.add((String) itemmap.get("volume"));
}
DataInfoEntity data = (DataInfoEntity) Bean2MapUtils.convertMap(DataInfoEntity.class, itemmap);
datas.add(data);
}
System.out.println("------/volume/{name}/move--------");
boolean result = false ;
if (datas.size() >0) {
result = moveDataService.moveData(datas, (String)map.get("path"));
moveDataService.moveData(datas, (String)map.get("path"));
}
return result;
}
// public Object volumeMove(HttpServletRequest res, HttpServletResponse req, String name,
// @RequestBody FolderNode selectNode, @RequestBody List<DataInfoEntity> selectItems) throws Exception {
// log.debug("-----/volume/{name}/move------");
//// Map<String, String[]> paramMap = res.getParameterMap();
//// System.out.println(paramMap);
// Map<String, String[]> paramMap = res.getParameterMap();
// log.debug(paramMap);
// //汇总库 对象信息--带有tableName-
// String[] nodes = (String[]) paramMap.get("selectNode");
// Map map = null;
// JSONObject jsonobject = JSONObject.fromObject(string);
// map = jsonobject;
//
//
// log.debug(selectItems);
// log.debug(selectNode);
// boolean result = false ;
// if (selectItems.size() >0) {
// result = moveDataService.moveData(selectItems, selectNode.getPath());
// }
// return result;
// }
@RequestMapping(value="/oracle/list", method= RequestMethod.POST)
@ResponseBody
public List<GatherOracleInfo> getOracleInfo(HttpServletRequest res,
HttpServletResponse req) throws Exception {
public List<GatherOracleInfo> oracleList() throws Exception {
log.debug("----------getOracleInfo-----------------------");
List<GatherOracleInfo> result = mySqlService.findAllMySql();
System.out.println("----------getOracleInfo-----------------------");
return result;
}
@RequestMapping(value="/oracle/{id}/delete", method= RequestMethod.POST)
@ResponseBody
public void deleteOracleInfo(HttpServletRequest res,
HttpServletResponse req, int id) throws Exception {
res.setCharacterEncoding("UTF-8");
public void oracleDelete(int id) throws Exception {
log.debug("----------deleteOracleInfo----------------");
mySqlService.deleteMySql(id);
System.out.println("----------deleteOracleInfo-----------------------");
}
@RequestMapping(value="/oracle/{id}/insert", method= RequestMethod.POST)
@ResponseBody
public void insertOracleInfo(HttpServletRequest res,
HttpServletResponse req, GatherOracleInfo oracle) throws Exception {
res.setCharacterEncoding("UTF-8");
public void oracleInsert(GatherOracleInfo oracle) throws Exception {
log.debug("----------insertOracleInfo----------------");
mySqlService.insertOracle(oracle);
System.out.println("----------insertOracleInfo-----------------------");
}
@RequestMapping(value="/oracle/{id}/update", method= RequestMethod.POST)
@ResponseBody
public void updateOracleInfo(HttpServletRequest res,
HttpServletResponse req, GatherOracleInfo oracle) throws Exception {
res.setCharacterEncoding("gb2312");
System.out.println(oracle.getName());
System.out.println(oracle);
public void oracleUpdate(@RequestBody GatherOracleInfo oracle) throws Exception {
log.debug("----------updateOracleInfo-----------------------");
log.debug(oracle);
mySqlService.updateOracle(oracle);
System.out.println("----------updateOracleInfo-----------------------");
}
@RequestMapping(value="/task/transfer/list", method= RequestMethod.POST)
@ResponseBody
public Object taskList() throws Exception {
public Object taskTransferList() throws Exception {
log.debug("----------/task/transfer/list-----------------------");
List<DataInfoEntityMoveTmp> result = moveDataService.findAll();
return result;
}
@RequestMapping(value="/task/transfer/{id}/delete", method= RequestMethod.POST)
@RequestMapping(value="/task/transfer/delete", method= RequestMethod.POST)
@ResponseBody
public Object taskdeletes(DataInfoEntityMoveTmp move) throws Exception {
public Object taskTransferDelete(DataInfoEntityMoveTmp move) throws Exception {
log.debug("----------/task/transfer/delete-----------------------");
int result = moveDataService.delete(move);
return result;
}
@RequestMapping(value="/task/transfer/save", method= RequestMethod.POST)
@ResponseBody
public Object taskTransferSave(DataInfoEntity move) throws Exception {
log.debug("---------/task/transfer/save-----------------------");
int result = dfs.save(move);
return result;
}
@RequestMapping(value="/code/list", method= RequestMethod.POST)
@ResponseBody
public Object findCodeList() throws Exception {
log.debug("---------/findSystemCode-----------------------");
Map<String, Object> result = codeService.findAll();
return result;
}
}

@ -0,0 +1,28 @@
package com.platform.dao;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import com.platform.entities.DataInfoEntity;
import com.platform.entities.DataInfoEntityMoveTmp;
import com.platform.entities.PagerOptions;
import com.platform.entities.RegionalismEntity;
/**
* @author chen
*
*/
@Repository(value = "regionalismCodeDao")
public interface IRegionalismCodeDao {
/**
* @return
* @throws Exception
*/
List<RegionalismEntity> findAllRegionalism() throws Exception;
List<RegionalismEntity> findSubRegionalism(RegionalismEntity region) throws Exception;
}

@ -0,0 +1,28 @@
package com.platform.dao;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import com.platform.entities.DataInfoEntity;
import com.platform.entities.DataInfoEntityMoveTmp;
import com.platform.entities.PagerOptions;
import com.platform.entities.RegionalismEntity;
import com.platform.entities.SystemEntity;
/**
* @author chen
*
*/
@Repository(value = "systemCodeDao")
public interface ISystemCodeDao {
/**
* @return
* @throws Exception
*/
List<SystemEntity> findAllSystem() throws Exception;
List<SystemEntity> findSubSystem(SystemEntity system) throws Exception;
}

@ -23,6 +23,18 @@ public class DataInfoEntity {
private String collectorName; // 采集人姓名
private String year; // 数据年度
/** 是否抽取 */
private int extractStatus;
/** 数据年度起始 */
private String startYear;
/** 数据年度结束 */
private String endYear;
/** volume的ip */
private String volumeIp;
/** volume的path */
private String volumePath;
public DataInfoEntity() {
}
@ -169,6 +181,76 @@ public class DataInfoEntity {
this.year = year;
}
/**
* @return the startYear
*/
public String getStartYear() {
return startYear;
}
/**
* @param startYear the startYear to set
*/
public void setStartYear(String startYear) {
this.startYear = startYear;
}
/**
* @return the endYear
*/
public String getEndYear() {
return endYear;
}
/**
* @param endYear the endYear to set
*/
public void setEndYear(String endYear) {
this.endYear = endYear;
}
/**
* @return the extractStatus
*/
public int getExtractStatus() {
return extractStatus;
}
/**
* @param extractStatus the extractStatus to set
*/
public void setExtractStatus(int extractStatus) {
this.extractStatus = extractStatus;
}
/**
* @return the volumeIp
*/
public String getVolumeIp() {
return volumeIp;
}
/**
* @param volumeIp the volumeIp to set
*/
public void setVolumeIp(String volumeIp) {
this.volumeIp = volumeIp;
}
/**
* @return the volumePath
*/
public String getVolumePath() {
return volumePath;
}
/**
* @param volumePath the volumePath to set
*/
public void setVolumePath(String volumePath) {
this.volumePath = volumePath;
}
@Override
public String toString() {
return "id=" + this.id + " ,regionalismCode=" + this.regionalismCode
@ -180,7 +262,8 @@ public class DataInfoEntity {
+ this.dataPath + " ,collectingTime=" + this.collectingTime
+ " ,collectorContacts=" + this.collectorContacts
+ " ,charset=" + this.charset + " ,collectorName="
+ this.collectorName + " ,year=" + this.year + "";
+ this.collectorName + " ,year=" + this.year + " startYear="
+this.startYear +" endYear="+this.endYear;
}
}

@ -8,7 +8,16 @@ public class DataInfoEntityMoveTmp extends DataInfoEntity {
private int rate;
private String lastTime; // 采集时间
/**
*
*/
private String lastTime;
private String dstVolumeIp;
private String dstVolumePath;
private int fkid;
public DataInfoEntityMoveTmp() {
// TODO Auto-generated constructor stub
@ -70,4 +79,46 @@ public class DataInfoEntityMoveTmp extends DataInfoEntity {
this.lastTime = lastTime;
}
/**
* @return the fkid
*/
public int getFkid() {
return fkid;
}
/**
* @param fkid the fkid to set
*/
public void setFkid(int fkid) {
this.fkid = fkid;
}
/**
* @return the dstVolumeIp
*/
public String getDstVolumeIp() {
return dstVolumeIp;
}
/**
* @param dstVolumeIp the dstVolumeIp to set
*/
public void setDstVolumeIp(String dstVolumeIp) {
this.dstVolumeIp = dstVolumeIp;
}
/**
* @return the dstVolumePath
*/
public String getDstVolumePath() {
return dstVolumePath;
}
/**
* @param dstVolumePath the dstVolumePath to set
*/
public void setDstVolumePath(String dstVolumePath) {
this.dstVolumePath = dstVolumePath;
}
}

@ -89,5 +89,4 @@ public class OracleConnectorParams {
public void setDatabaseName(String databaseName) {
this.databaseName = databaseName;
}
}

@ -0,0 +1,53 @@
package com.platform.entities;
public class RegionalismEntity {
private String code;
private String cityName;
private String districtName;
/**
* @return the code
*/
public String getCode() {
return code;
}
/**
* @param code the code to set
*/
public void setCode(String code) {
this.code = code;
}
/**
* @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;
}
}

@ -0,0 +1,37 @@
package com.platform.entities;
public class SystemEntity {
private int code;
private String systemName;
/**
* @return the code
*/
public int getCode() {
return code;
}
/**
* @param code the code to set
*/
public void setCode(int code) {
this.code = code;
}
/**
* @return the systemName
*/
public String getSystemName() {
return systemName;
}
/**
* @param systemName the systemName to set
*/
public void setSystemName(String systemName) {
this.systemName = systemName;
}
}

@ -37,6 +37,38 @@ public class CopyData {
return status;
}
/**
* sourceFolderNamedestFolderName
* 1sourceFolderName-2 destFolderName-3
* @param sourceFolderName
* @param destFolderName
* @return
* @see [##]
*/
public int copyFolder(String sourceFolderName, String destFolderName) {
createFolders(destFolderName);
int progress=0;
log.info("start copy " + sourceFolderName + " to " + destFolderName);
ShowData showData=new ShowData();
Map<String,String> reStrings=showData.showFolderData(destFolderName);
if(reStrings==null){
log.info("3201 "+destFolderName+" is not exists");
return -3;
}
reStrings=showData.showFolderData(sourceFolderName);
if(reStrings==null){
log.info("3202 "+sourceFolderName+" is not exists");
return -2;
}
String command = "cp -r " + sourceFolderName+" "+destFolderName;
Constant.ganymedSSH.execCmdNoWaitAcquiescent(command);
log.info("copy " + sourceFolderName + " to " + destFolderName + " running");
return 1;
}
/**
* -1 :error; -2: the filename is not exists ;-3 :destFolderName ; 1: right
* not exists

@ -1,13 +1,10 @@
/**
* @author
* volumevolumevolumebrick
*/
package com.platform.glusterfs;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
@ -17,17 +14,24 @@ import java.util.Map;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
import org.junit.Test;
import com.platform.utils.Constant;
public class SetVolume {
public static Logger log = Logger.getLogger(SetVolume.class);
/*
* volume 1
/**
* volume 1 1: ;-1brickip; -2 -3
* -4:brick ; -5 :volumeName -6 -7
*
* @param volumeName
* @param count
* @param type
* @param bricks
* @param mountPoint
* @return
* @see [##]
*/
public int createVolume(String volumeName, int count, String type, List bricks, String mountPoint) {
log.info("Creat new volume");
@ -50,8 +54,7 @@ public class SetVolume {
}
// 执行命令
List<String> reStrings = Constant.ganymedSSH.execCmdWait(Constant.hostIp, Constant.rootUser, Constant.rootPasswd,
Constant.port, command);
List<String> reStrings = Constant.ganymedSSH.execCmdWaitAcquiescent(command);
// 创建成功时返回信息格式volume create: volumename success:
if (reStrings == null || reStrings.size() == 0) {
@ -59,27 +62,24 @@ public class SetVolume {
return -7;
}
if (reStrings.get(0).contains("volume create: " + volumeName + ": " + "success:")) {
log.info("create volume "+volumeName+" successed!");
log.info("create volume " + volumeName + " successed!");
// 创建成功则启动并进行挂载
if (startVolume(volumeName) == 0) {
log.info("start volume "+volumeName+" successed!");
if ((new ShowData().showFolderData(mountPoint)) == null) {
Constant.ganymedSSH.execCmdWaitAcquiescent("mkdir " + mountPoint);
}
log.info("start volume " + volumeName + " successed!");
log.info("create "+mountPoint);
new CopyData().createFolders(mountPoint);
// 进行挂载
String command3 = "mount -t glusterfs " + Constant.hostIp + ":/" + volumeName + " " + mountPoint;
List<String> reStrings3 = Constant.ganymedSSH.execCmdWait(Constant.hostIp, Constant.rootUser,
Constant.rootPasswd, Constant.port, command3);
// 这里需要添加解析挂载命令返回字符串的语句由于我的系统有问题导致挂载成功后返回WARNING: getfattr
// not found, certain checks will be skipped..
// 所以这句代码未经测试
// 成功挂载时没有任何返回信息
if (reStrings3.size() == 0 || reStrings.get(0).contains("GlusterFS is already mounted"))
{
String command3 = "mount -t glusterfs " + Constant.hostIp + ":" + volumeName + " " + mountPoint;
List<String> reStrings3 = Constant.ganymedSSH.execCmdWaitAcquiescent(command3);
if (reStrings3.size() == 0 || reStrings.get(0).contains("GlusterFS is already mounted")) {
log.info("mount point successed!");
String addRecord = "echo \"" + volumeName + ":" + mountPoint + "\" >> " + Constant.MountRecord;
Constant.ganymedSSH.execCmdNoWaitAcquiescent(addRecord);
return 1;
}
}
}
} else {
log.error("3104 volume create failed with error" + reStrings.get(0));
@ -96,46 +96,66 @@ public class SetVolume {
}
/**
* volume
*
* volume 1 -1volume name-2volume
* -3-4/gfsAutoMount/mountPoint.record
* @param volumeName
* @return 1 -1volume name-2volume
* @return
* @see [##]
*/
public int deleteVolume(String volumeName) {
int status = 0;
List<String> volumeNames = new VolumeInfo().showAllVolumeName();
VolumeInfo volumeInfo = new VolumeInfo();
List<String> volumeNames = volumeInfo.showAllVolumeName();
if (!volumeNames.contains(volumeName)) {
log.error("3801 " + volumeName + " is not exists !");
return -1;
}
List<String> mountPoints = new VolumeInfo().getVolumeMountPoint(volumeName);
List<String> mountPoints = volumeInfo.getVolumeMountPoint(volumeName);
String cmd = "cat " + Constant.MountRecord;
List<String> mountRecord = Constant.ganymedSSH.execCmdWaitAcquiescent(cmd);
if (stopVolume(volumeName) != 0) {
log.error("3802 " + volumeName + " stop failed !");
return -2;
}
log.info("stop "+volumeName+" successed!");
for(String mountPoint:mountPoints){
if (mountPoint != null) {
String command = "umount -l " + mountPoint;
Constant.ganymedSSH.execCmdNoWaitAcquiescent(command);
log.info("umount "+mountPoint+" successed!");
String command = "echo -e \"y\"| gluster volume delete " + volumeName;
List<String> reStrings = Constant.ganymedSSH.execCmdWaitAcquiescent(command);
if (reStrings == null || reStrings.size() == 0
|| !(reStrings.get(0).contains("volume delete: " + volumeName + ": success"))) {
log.error("3803 : delete volume " + volumeName + " failed !");
return -3;
}
log.info("delete " + volumeName + " successed!");
if (mountRecord.size() != 0 && mountPoints.get(0).contains(Constant.noSuchFile)) {
log.error("3804 : " + Constant.MountRecord + " is not exits");
return -4;
}
String command="echo -e \"y\"| gluster volume delete "+volumeName;
List<String> reStrings=Constant.ganymedSSH.execCmdWaitAcquiescent(command);
if(reStrings==null || reStrings.size()>0 || !(reStrings.get(0).contains("volume delete: "+volumeName+": success"))){
log.error("3803 : delete volume "+volumeName+" failed !");
return -3;
for (String mountPoint : mountPoints) {
command = "umount -l " + mountPoint;
Constant.ganymedSSH.execCmdNoWaitAcquiescent(command);
log.info("umount " + mountPoint + " successed!");
String oneRecord=volumeName+":"+mountPoint;
if (mountRecord.contains(oneRecord)) {
mountRecord.remove(oneRecord);
}
}
String newRecords="";
for(String one:mountRecord){
newRecords+=one+"\n";
}
log.info("delete "+volumeName+" successed!");
command="echo -ne \""+newRecords+"\" > "+Constant.MountRecord;
Constant.ganymedSSH.execCmdNoWaitAcquiescent(command);
return 1;
}
/**
* volumebrick, 1 ;
* volumebrickcount
* <>
*
* @param volumeName
* @param brickName
* @param count
@ -162,8 +182,7 @@ public class SetVolume {
else if (type.equals(Constant.stripe))
command = "gluster volume add-brick " + volumeName + " " + "stripe " + count + " " + brick + "force";
List<String> reStrings = Constant.ganymedSSH.execCmdWait(Constant.hostIp, Constant.rootUser, Constant.rootPasswd,
Constant.port, command);
List<String> reStrings = Constant.ganymedSSH.execCmdWaitAcquiescent(command);
// 添加成功的返回信息是volume add-brick: success
if (reStrings != null && reStrings.size() > 0 && reStrings.get(0).contains("volume add-brick: success")) {
@ -171,15 +190,16 @@ public class SetVolume {
return 1;
} else {
log.error("3205 add brick failed,please check the system");
// System.out.println("3202 add brick failed,please check the system");
// System.out.println("3202 add brick failed,please check the
// system");
return -5;
}
}
/**
* volumebrick, 1 ;
* volumebrickcount
*
* @param volumeName
* @param brickName
* @param count
@ -214,8 +234,7 @@ public class SetVolume {
return -5;
}
log.info("即将执行删除命令");
List<String> reStrings = Constant.ganymedSSH.execCmdWait(Constant.hostIp, Constant.rootUser, Constant.rootPasswd,
Constant.port, command);
List<String> reStrings = Constant.ganymedSSH.execCmdWaitAcquiescent(command);
// System.out.println(reStrings);
log.info("删除命令执行完毕");
@ -264,8 +283,7 @@ public class SetVolume {
return -1;
} else {
String command = "echo -e \"y\"| gluster volume stop " + volumeName;
List<String> reStrings = Constant.ganymedSSH.execCmdWait(Constant.hostIp, Constant.rootUser, Constant.rootPasswd,
Constant.port, command);
List<String> reStrings = Constant.ganymedSSH.execCmdWaitAcquiescent(command);
// 标记操作结果operation = 1 操作成功
// operation = 0 操作失败
@ -313,8 +331,7 @@ public class SetVolume {
int operation = 0;
// 执行命令
List<String> reStrings = Constant.ganymedSSH.execCmdWait(Constant.hostIp, Constant.rootUser, Constant.rootPasswd,
Constant.port, command);
List<String> reStrings = Constant.ganymedSSH.execCmdWaitAcquiescent(command);
for (String temp2 : reStrings) {
if (temp2.equals("volume start: " + volumeName + ": " + "success")) {
operation = 1;
@ -393,20 +410,22 @@ public class SetVolume {
}
List<String> volumeNames = new VolumeInfo().showAllVolumeName();
if(volumeNames==null){
if (volumeNames == null) {
log.error("3108 showAllVolumeName return error");
return -7;
}
if (volumeNames.contains(volumeName)) {
if (volumeNames.contains(volumeName)) {
log.error("3106 " + volumeName + " is already exists! ");
return -5;
}
/*
Map datas = new ShowData().showFolderData(mountPoint);
if (datas != null && datas.size() > 0) {
log.error("3107 " + mountPoint + " is not exists or not empty ! ");
return -6;
}
*/
return 1;
}
@ -464,18 +483,29 @@ public class SetVolume {
return 1;
}
@Test
public void test_deleteVolume(){
System.out.println(deleteVolume("lili_test1"));
}
// @Test
public void test_createVolume(){
List<String> bricksToCreate = new ArrayList<String>();
bricksToCreate.add("192.168.0.110:/lili_test1");
bricksToCreate.add("192.168.0.116:/lili_test1");
System.out.println(createVolume("lili_test1", 0, "distributed", bricksToCreate, "/home/lili_test1_point"));
}
public static void main(String[] args) {
SetVolume setVolume = new SetVolume();
int operation = 0;
// PropertyConfigurator.configure("log4j.properties");
// PropertyConfigurator.configure("log4j.properties");
// TODO Auto-generated method stub
// 测试创建volume的代码
List<String> bricksToCreate = new ArrayList<String>();
bricksToCreate.add("192.168.0.110:/v2");
bricksToCreate.add("192.168.0.116:/v2");
operation = setVolume.createVolume("v2", 0, "distributed", bricksToCreate, "/home/v2_point");
// operation = setVolume.deleteVolume("v3");
// List<String> bricksToCreate = new ArrayList<String>();
// bricksToCreate.add("192.168.0.110:/v2");
// bricksToCreate.add("192.168.0.116:/v2");
// operation = setVolume.createVolume("v2", 0, "distributed", bricksToCreate, "/home/v2_point");
// operation = setVolume.deleteVolume("v3");
//
// // 以下是测试添加brick的代码
//
@ -508,4 +538,3 @@ public class SetVolume {
// System.out.println(operation);
}
}

@ -52,11 +52,12 @@ public class ShowData {
String command="ls -l "+folderName;
/*
RunCommand runCommand=new RunCommand();
List<String> reStrings=runCommand.runCommandWait(command);
*/
List<String> reStrings = Constant.ganymedSSH.execCmdWait(Constant.hostIp, Constant.rootUser, Constant.rootPasswd, Constant.port, command);
if(reStrings==null){
<<<<<<< HEAD
* RunCommand runCommand=new RunCommand(); List<String>
* reStrings=runCommand.runCommandWait(command);
*/
List<String> reStrings = Constant.ganymedSSH.execCmdWaitAcquiescent(command);
if (reStrings == null) {
log.error("2101 command get result is null");
return null;
}

@ -77,7 +77,7 @@ public class VolumeInfo {
}
/**
* volumevolume <>
* volumevolume
*
* @param volumeName
* @return
@ -257,12 +257,6 @@ public class VolumeInfo {
return null;
}
// char flag = reStrings.get(0).trim().toCharArray()[0];
// if (flag != '/') {
// log.error("11003 get result string wrong");
// return null;
// }
for (String mountPoint : reStrings) {
mountPoint = mountPoint.replaceAll(" ", "");
mountPoints.add(mountPoint);
@ -274,25 +268,15 @@ public class VolumeInfo {
log.info("get one volume MountPoint");
String mountPoint=null;
String cmd=Constant.df + "|grep " + volumeName + "|awk '{print $6}'";
List<String> reStrings = Constant.ganymedSSH.execCmdWaitAcquiescent(cmd);
List<String> mountpoints = getVolumeMountPoint(volumeName);
// System.out.println(reStrings);
if (reStrings == null) {
if (mountpoints == null || mountpoints.size() == 0) {
log.error("11001 get result string wrong");
return null;
}
if (reStrings.size() == 0) {
log.error("11002 " + volumeName + " is not exists or no mountpoint");
return null;
}
// char flag = reStrings.get(0).trim().toCharArray()[0];
// if (flag != '/') {
// log.error("11003 get result string wrong");
// return null;
// }
mountPoint=reStrings.get(0);
mountPoint=mountpoints.get(0);
return mountPoint;
}
@ -377,7 +361,7 @@ public class VolumeInfo {
}
/**
* volumeNametruefalse <>
* volumeNametruefalse
*
* @param volumeName
* @return

@ -65,7 +65,13 @@ public class DataInfoServiceImp implements DataInfoService {
@Override
public int save(DataInfoEntity data) throws Exception {
int result = dfdDao.save(data);
int result = 0;
try {
result = dfdDao.save(data);
} catch (Exception e) {
// TODO: handle exception
System.out.println("");
}
return result;
}
}

@ -0,0 +1,40 @@
/**
* : IGfsService.java
* : </>
* : <>
* @author chen
* : <>
* 201698
* <>
*/
package com.platform.service;
import java.util.List;
import java.util.Map;
import com.platform.entities.FolderNode;
import com.platform.entities.RegionalismEntity;
import com.platform.entities.SystemEntity;
import com.platform.entities.VolumeEntity;
/**
* <>
* <>
* @author chen
* @version [201698]
* @see [/]
* @since [/]
*/
public interface ICodeService {
public List<SystemEntity> findSystem(SystemEntity sys) throws Exception;
public List<RegionalismEntity> findRegionalism(RegionalismEntity region) throws Exception;
public Map<String, Object> findAll() throws Exception;
}

@ -3,6 +3,10 @@ package com.platform.service;
import java.util.List;
import java.util.Map;
import com.platform.entities.DataInfoEntity;
import com.platform.entities.GatherOracleInfo;
import com.platform.entities.OracleConnectorParams;
public interface IOracleExtractService {
/**
@ -12,6 +16,7 @@ public interface IOracleExtractService {
* @return
* @throws Exception
*/
// public boolean extractOracle(String name, List<OracleConnectorParams> dataInfos, GatherOracleInfo oracleConnect) throws Exception;
// public boolean extractOracle(String name, List<DataInfoEntity> dataInfos, Map<String, String> oracleConnect) throws Exception;
public boolean extractOracle(String name, List<Map<String, String>> dataInfo, Map<String, String> oracleConnect) throws Exception;
}

@ -0,0 +1,66 @@
package com.platform.service.impl;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.platform.dao.DataInfoDao;
import com.platform.dao.IRegionalismCodeDao;
import com.platform.dao.ISystemCodeDao;
import com.platform.entities.RegionalismEntity;
import com.platform.entities.SystemEntity;
import com.platform.service.ICodeService;
@Service(value = "codeService")
public class CodeServiceImpl implements ICodeService {
@Resource(name = "systemCodeDao")
private ISystemCodeDao systemCodeDao;
@Resource(name = "regionalismCodeDao")
private IRegionalismCodeDao regionalismCodeDao;
@Override
public List<SystemEntity> findSystem(SystemEntity sys) throws Exception {
List<SystemEntity> result = null;
try {
result = new ArrayList<SystemEntity>();
result = systemCodeDao.findSubSystem(sys);
} catch (Exception e) {
// TODO: handle exception
}
return result;
}
@Override
public List<RegionalismEntity> findRegionalism(RegionalismEntity region) throws Exception {
List<RegionalismEntity> result = null;
try {
result = regionalismCodeDao.findSubRegionalism(region);
} catch (Exception e) {
// TODO: handle exception
}
return result;
}
@Override
public Map<String, Object> findAll() throws Exception {
Map<String, Object> result = new HashMap<String, Object>();
try {
List<RegionalismEntity> regions = regionalismCodeDao.findAllRegionalism();
List<SystemEntity> syss = systemCodeDao.findAllSystem();
result.put("system", syss);
result.put("regionalism", regions);
} catch (Exception e) {
// TODO: handle exception
}
return result;
}
}

@ -18,6 +18,7 @@ import com.platform.entities.DataInfoEntity;
import com.platform.entities.DataInfoEntityMoveTmp;
import com.platform.glusterfs.CheckoutMD5;
import com.platform.glusterfs.CopyData;
import com.platform.glusterfs.RemoveData;
import com.platform.glusterfs.ShowData;
import com.platform.service.IMoveDataService;
import com.platform.utils.Bean2MapUtils;
@ -31,6 +32,8 @@ public class MoveDataServiceImpl implements IMoveDataService{
@Resource(name = "dataInfoDao")
private DataInfoDao dataInfoDao;
private RemoveData removeservice = new RemoveData();
/**
*
*/
@ -91,6 +94,7 @@ public class MoveDataServiceImpl implements IMoveDataService{
dataMove.setRegionalismCode(dataInfoEntity.getRegionalismCode());
dataMove.setDstPath(finalDestPath);
dataMove.setLastTime(DateForm.date2StringBysecond(new Date()));
dataMove.setFkid(dataInfoEntity.getId());
moveList.add(dataMove);
}
if (moveList.size() > 0) {
@ -115,6 +119,9 @@ public class MoveDataServiceImpl implements IMoveDataService{
@Override
public int delete(DataInfoEntityMoveTmp dataMove) throws Exception {
if ("1".equals(dataMove.getCompleteStatus())) {
removeservice.deleteFolder(dataMove.getDstPath());
}
int result = dataInfoMoveTmpDao.remove(dataMove.getId());
return result;
}

@ -60,4 +60,35 @@ public class OracleExtractServiceImpl implements IOracleExtractService {
return false;
}
// @Override
// public boolean extractOracle(String name, List<OracleConnectorParams> dataInfos, GatherOracleInfo oracleConnect) throws Exception {
// boolean isSuccess = false;
// try{
// //map转 bean(汇总库信息-带tableName的)
//// GatherOracleInfo oracleModel = (GatherOracleInfo) Bean2MapUtils.convertMap(GatherOracleInfo.class, oracleConnect);
//
// //采集库连接参数
//// List<OracleConnectorParams> datainfos = new ArrayList<OracleConnectorParams>();
//// for (Map<String, String> map : dataInfoMap) {
//// OracleConnectorParams dataInfoEntity = (OracleConnectorParams) Bean2MapUtils.convertMap(OracleConnectorParams.class, oracleConnect);
//// datainfos.add(dataInfoEntity);
//// }
//
// Connection conn = OracleConnector.ConnectionBuilder("jdbc:oracle:thin:@" + oracleConnect.getIp() + ":" + oracleConnect.getPort() + "/"
// + oracleConnect.getDatabaseName(), oracleConnect.getUser(), oracleConnect.getPassword());
//
// for (OracleConnectorParams collectOracle : dataInfos) {
//
// oracleExtract.createDBLink(conn, collectOracle);
// oracleExtract.createTableSpace(conn, oracleConnect);
// oracleExtract.createUser(conn, oracleConnect);
// oracleExtract.extractColleDB(conn, collectOracle);
// }
// isSuccess = true;
// }catch(Exception e){
//
// }
// return false;
// }
}

@ -4,9 +4,12 @@ import java.util.Date;
import java.util.HashMap;
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.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
@ -31,6 +34,8 @@ import com.platform.utils.DateForm;
@Component
public class ThreadMoveData{
public static Logger log = Logger.getLogger(ThreadMoveData.class);
@Resource(name = "dataInfoDao")
private DataInfoDao dataInfoDao;
@ -73,6 +78,7 @@ public class ThreadMoveData{
//该循环必须 循环每个,不能有 break;
// rate:大小:假的,待换成真实比例
double realRate = 0.00;
int moveFileCurrNum = 0;
for (int i = 0; i < rsize; i++) {
DataInfoEntityMoveTmp dataMove = result.get(i);
//如果拷贝进度超过20分钟未进行-- 判断为 迁移失败。
@ -84,16 +90,30 @@ public class ThreadMoveData{
dataMove.setCompleteStatus("3");
dataInfoMoveTmpDao.update(dataMove);
}
isNoMove = false;
//正在上传的个数。
moveFileCurrNum++;
if (moveFileCurrNum >= Constant.moveFileMaxNum) {
isNoMove = false;
}
// 查询大小:。//gfs 获取size
long srcSize = show.getFolderSize(dataMove.getDataPath());
long dstSize = show.getFolderSize(dataMove.getDstPath());
if (srcSize < 0) {
log.error(dataMove.getDataPath() + " : 路径不存在! ");
continue;
}
if (dstSize < 0) {
log.error(dataMove.getDstPath() + " : 路径不存在! ");
continue;
}
if (srcSize > 0 && dstSize > 0) {
realRate = dstSize / srcSize * 100;
realRate = (dstSize*100 / srcSize );
dataMove.setRate((int) realRate);
dataMove.setLastTime(DateForm.date2StringBysecond(new Date()));
}
if (srcSize == dstSize) {
realRate = 100;
}
}
if("1".equals(dataMove.getCompleteStatus()) &&dataMove.getRate() > 0){
//传输完毕:进行校验
@ -110,7 +130,9 @@ public class ThreadMoveData{
DataInfoEntity data = (DataInfoEntity) Bean2MapUtils.convertMap(
DataInfoEntity.class, Bean2MapUtils.convertBean(dataMove));
data.setDataPath(dataMove.getDstPath());
data.setYear(dataMove.getYear()+" (迁移完成时间 " + DateForm.date2StringByMin(new Date())+")");
data.setVolumeIp(dataMove.getDstVolumeIp());
data.setVolumePath(dataMove.getDstVolumePath());
data.setYear(DateForm.date2StringByMin(new Date()));
dataInfoDao.save(data);
}
else {
@ -135,7 +157,16 @@ public class ThreadMoveData{
//如果是 待 迁移状态的
if ("0".equals(next2move.getCompleteStatus())) {
//待迁移的数据 -- 开始迁移
copy.copyFolderFilesAnyway(next2move.getDataPath(), next2move.getDstPath(), "app");
// 末尾 含有 /
Pattern pattern2 = Pattern.compile("\\/$");
String dstPath = next2move.getDataPath();
Matcher matcher2 = pattern2.matcher(dstPath);
//去掉 最后 的 / 符合
if (matcher2.find()) {
dstPath = dstPath.substring(0, dstPath.length()-1);
}
//数据迁移。
copy.copyFolder(dstPath+"/app", next2move.getDstPath());
// "1" :正在上传0等待 迁移, 2成功 3失败
next2move.setCompleteStatus("1");
next2move.setLastTime(DateForm.date2StringBysecond(new Date()));

@ -23,14 +23,18 @@ public class Constant {
public static String noSuchFile = "No such file or directory";
public static GanymedSSH ganymedSSH = new GanymedSSH(hostIp, rootUser, rootPasswd, port);
public static String fileGetTreeData = "WebContent\\WEB-INF\\config\\getTreedata.sh";
public static String AutoMountfile="/gfsAutoMount/AutoRun.sh";
public static String MountRecord="/gfsAutoMount/mountPoint.record";
public static String strGetTreeData = "function ergodic(){\n "
+ "for file in \\`ls \\$1\\`\n do\n if [ \"\\$file\" != \"app\" -a -d \\$1\\\"/\\\"\\$file ]\n "
+ "then\n ergodic \\$1\"/\"\\$file\n else\n local path=\\$1\"/\"\\$file\n "
+ "echo \\$path \n fi\n done\n}\n\nIFS=\\$\\'\\n\\' "
+ "#这个必须要,否则会在文件名中有空格时出错\nINIT_PATH=\".\";\nergodic \\$1\n";
/**
* volume 线
*/
public final static int moveFileMaxNum = 1;
/**
* volume 线

@ -46,3 +46,4 @@ public class getTreeDataByPath {
return result;
}
}

Loading…
Cancel
Save