解决冲突----

web_backend_develope
wu ming 9 years ago
commit 5ba88b2d41

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

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"> <persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="aggregation-platform"> <persistence-unit name="aggregation-platform">
</persistence-unit> </persistence-unit>
</persistence> </persistence>

@ -1,65 +1,65 @@
/** /**
* BaseController.java * BaseController.java
* : XX * : XX
* : <> * : <>
* 201697 * 201697
* <> * <>
*/ */
package com.base; package com.base;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ExceptionHandler;
import com.platform.utils.Configs; import com.platform.utils.Configs;
/** /**
* <> * <>
* <> * <>
* @author chen * @author chen
* @version [201697] * @version [201697]
* @see [/] * @see [/]
* @since [/] * @since [/]
*/ */
public class BaseController { public class BaseController {
/** log4j */ /** log4j */
public static Logger log = Logger.getRootLogger(); public static Logger log = Logger.getRootLogger();
/** /**
* <> @ExceptionHandler---- * <> @ExceptionHandler----
* <> * <>
* @param request * @param request
* @param ex * @param ex
* @return * @return
* @see [##] * @see [##]
*/ */
@ExceptionHandler @ExceptionHandler
public Object exp(HttpServletRequest request, HttpServletResponse response,Exception ex) { public Object exp(HttpServletRequest request, HttpServletResponse response,Exception ex) {
System.out.println("URI"+request.getRequestURI()); System.out.println("URI"+request.getRequestURI());
request.setAttribute("ex", ex); request.setAttribute("ex", ex);
System.err.println("BaseController --exp "); System.err.println("BaseController --exp ");
// 根据不同错误转向不同页面 // 根据不同错误转向不同页面
if(ex instanceof CustomException) { if(ex instanceof CustomException) {
CustomException cuse = (CustomException) ex; CustomException cuse = (CustomException) ex;
Map<String, String> errmsg = new HashMap<>(); Map<String, String> errmsg = new HashMap<>();
errmsg.put("code", cuse.getCode()); errmsg.put("code", cuse.getCode());
errmsg.put("msg", cuse.getMsg()); errmsg.put("msg", cuse.getMsg());
log.error(cuse.getCode()); log.error(cuse.getCode());
response.setStatus(500); response.setStatus(500);
return response; return response;
} else { } else {
//其他错误则 调到指定页面 //其他错误则 调到指定页面
log.error(Configs.GLOBAL_EXP_NOT_CUSTOM, ex); log.error(Configs.GLOBAL_EXP_NOT_CUSTOM, ex);
response.setStatus(500); response.setStatus(500);
return response; return response;
} }
} }
} }

@ -1,23 +1,23 @@
package com.base; package com.base;
/** /**
* <> * <>
* <> * <>
* @author chen * @author chen
* @version [201698] * @version [201698]
* @see [/] * @see [/]
* @since [/] * @since [/]
*/ */
public class Constant { public class Constant {
/** 国际话配置文件文件-i18n.properties */ /** 国际话配置文件文件-i18n.properties */
public static String I18N_PROPERTIES_FIEL_PATH = "/com/base/i18n.properties"; public static String I18N_PROPERTIES_FIEL_PATH = "/com/base/i18n.properties";
/** WritefileThread-线程睡眠时间--3000 */ /** WritefileThread-线程睡眠时间--3000 */
public final static long THREAD_SLEEP_WRITEFILETHREAD = 3000; public final static long THREAD_SLEEP_WRITEFILETHREAD = 3000;
/** CustomException记录报异常的对象的对象个数--10 */ /** CustomException记录报异常的对象的对象个数--10 */
public final static int CustomException_log_object_size = 10; public final static int CustomException_log_object_size = 10;
} }

@ -1,20 +1,20 @@
package com.base; package com.base;
/** /**
* <> * <>
* <> * <>
* @author chen * @author chen
* @version [201698] * @version [201698]
* @see [/] * @see [/]
* @since [/] * @since [/]
*/ */
public class Custom4exception { public class Custom4exception {
//3003001001 : 第一位:标识异常, 第二到第四位:标识模块,第五道第七位:标识类别,第八道第十位标识具体异常 //3003001001 : 第一位:标识异常, 第二到第四位:标识模块,第五道第七位:标识类别,第八道第十位标识具体异常
/**eg /**eg
* 3 * 3
* 003 * 003
* 001 * 001
* 001 * 001
*/ */
} }

@ -1,127 +1,127 @@
package com.base; package com.base;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
/** /**
* <> * <>
* <> * <>
* @author chen * @author chen
* @version [201698] * @version [201698]
* @see [/] * @see [/]
* @since [/] * @since [/]
*/ */
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class CustomException extends Exception { public class CustomException extends Exception {
/** log4j */ /** log4j */
public static Logger log = Logger.getRootLogger(); public static Logger log = Logger.getRootLogger();
/** 自定义异常信息-错误信息 */ /** 自定义异常信息-错误信息 */
private String msg; private String msg;
/** 自定义异常信息-错误代码 */ /** 自定义异常信息-错误代码 */
private String code; private String code;
/** 操作对象 */ /** 操作对象 */
private Object[] objArray; private Object[] objArray;
/** 异常 */ /** 异常 */
private Throwable cause; private Throwable cause;
public CustomException() { public CustomException() {
super(); super();
} }
/** /**
* @ * @
* @param code * @param code
* @param msg * @param msg
* @param e * @param e
* @param obj * @param obj
*/ */
public CustomException(String code,Exception e,Object... obj) { public CustomException(String code,Exception e,Object... obj) {
super(code); super(code);
StringBuffer sbuf= new StringBuffer(); StringBuffer sbuf= new StringBuffer();
sbuf.append(msg); sbuf.append(msg);
this.code = code; this.code = code;
sbuf.append(code); sbuf.append(code);
sbuf.append("\r\n"); sbuf.append("\r\n");
msg = Resource.getProperties().get(code); msg = Resource.getProperties().get(code);
// 记录自定义的 异常 // 记录自定义的 异常
if (null != msg) { if (null != msg) {
sbuf.append(msg); sbuf.append(msg);
sbuf.append("\r\n"); sbuf.append("\r\n");
} }
// 记录原始的异常 // 记录原始的异常
if (null != e) { if (null != e) {
StackTraceElement[] array = e.getStackTrace(); StackTraceElement[] array = e.getStackTrace();
cause = e.getCause(); cause = e.getCause();
for (StackTraceElement stackTraceElement : array) { for (StackTraceElement stackTraceElement : array) {
sbuf.append(stackTraceElement.toString()); sbuf.append(stackTraceElement.toString());
sbuf.append("\r\n"); sbuf.append("\r\n");
} }
} }
//记录 出现异常时 当前的对象 //记录 出现异常时 当前的对象
if (null != obj) { if (null != obj) {
Object[] array = obj; Object[] array = obj;
sbuf.append("Object[] size : "); sbuf.append("Object[] size : ");
sbuf.append(array.length); sbuf.append(array.length);
int forSize = 0; int forSize = 0;
if (Constant.CustomException_log_object_size < array.length) { if (Constant.CustomException_log_object_size < array.length) {
forSize = Constant.CustomException_log_object_size; forSize = Constant.CustomException_log_object_size;
} }
else { else {
forSize = array.length; forSize = array.length;
} }
for (int i = 0; i < forSize; i++) { for (int i = 0; i < forSize; i++) {
sbuf.append(array[i]); sbuf.append(array[i]);
sbuf.append("\r\n"); sbuf.append("\r\n");
} }
sbuf.append("......"); sbuf.append("......");
sbuf.append("\r\n"); sbuf.append("\r\n");
} }
else { else {
sbuf.append("null"); sbuf.append("null");
sbuf.append("\r\n"); sbuf.append("\r\n");
} }
sbuf.append("\r\n"); sbuf.append("\r\n");
// 是否 写入 文件 // 是否 写入 文件
log.error(sbuf.toString()); log.error(sbuf.toString());
} }
/** /**
* @ msg * @ msg
* @return msg * @return msg
*/ */
public String getMsg() { public String getMsg() {
return msg; return msg;
} }
/** /**
* @return the code * @return the code
*/ */
public String getCode() { public String getCode() {
return code; return code;
} }
/** /**
* @ objArray * @ objArray
* @return objArray * @return objArray
*/ */
public Object[] getObjArray() { public Object[] getObjArray() {
return objArray; return objArray;
} }
/** /**
* @ cause * @ cause
* @return cause * @return cause
*/ */
public Throwable getCause() { public Throwable getCause() {
return cause; return cause;
} }
} }

@ -1,79 +1,79 @@
package com.base; package com.base;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.Map;
import java.util.Properties; import java.util.Properties;
import com.base.Constant; import com.base.Constant;
public class Resource { public class Resource {
private static Map<String, String> properties = new HashMap<>(); private static Map<String, String> properties = new HashMap<>();
static{ static{
// 读取 properties文件 // 读取 properties文件
// readPropertiesFile(Constant.SYSTEM_PROPERTIES_FIEL_PATH); // readPropertiesFile(Constant.SYSTEM_PROPERTIES_FIEL_PATH);
readPropertiesFile4Chinese(Constant.I18N_PROPERTIES_FIEL_PATH); readPropertiesFile4Chinese(Constant.I18N_PROPERTIES_FIEL_PATH);
} }
/** /**
* @ * @
* @param filename "/com/utils/exception/i18n.properties" * @param filename "/com/utils/exception/i18n.properties"
*/ */
public static void readPropertiesFile4Chinese(String filename) { public static void readPropertiesFile4Chinese(String filename) {
Properties pro = new Properties(); Properties pro = new Properties();
try { try {
// 读取属性文件 XXXX.propertiesReader。writer解决中文乱码 // 读取属性文件 XXXX.propertiesReader。writer解决中文乱码
// InputStreamReader in= new InputStreamReader(Resource.class.getClassLoader().getResourceAsStream(filename), "UTF-8"); // InputStreamReader in= new InputStreamReader(Resource.class.getClassLoader().getResourceAsStream(filename), "UTF-8");
InputStreamReader in= new InputStreamReader(Resource.class.getResourceAsStream(filename), "UTF-8"); InputStreamReader in= new InputStreamReader(Resource.class.getResourceAsStream(filename), "UTF-8");
BufferedReader bf = new BufferedReader(in); BufferedReader bf = new BufferedReader(in);
// InputStreamReader in = new BufferedInputStream(new FileInputStream(filename)); // InputStreamReader in = new BufferedInputStream(new FileInputStream(filename));
pro.load(bf); // /加载属性列表 pro.load(bf); // /加载属性列表
Iterator<String> it = pro.stringPropertyNames().iterator(); Iterator<String> it = pro.stringPropertyNames().iterator();
while (it.hasNext()) { while (it.hasNext()) {
String key = it.next(); String key = it.next();
properties.put(key, pro.getProperty(key)); properties.put(key, pro.getProperty(key));
} }
in.close(); in.close();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
/** /**
* @ properties * @ properties
* @return properties * @return properties
*/ */
public static Map<String, String> getProperties() { public static Map<String, String> getProperties() {
return properties; return properties;
} }
/** /**
* @ * @
* @param filename * @param filename
*/ */
public static void readPropertiesFile(String filename) { public static void readPropertiesFile(String filename) {
Properties pro = new Properties(); Properties pro = new Properties();
try { try {
// 读取属性文件 XXXX.properties 中文会 乱码) // 读取属性文件 XXXX.properties 中文会 乱码)
BufferedInputStream bf = new BufferedInputStream(new FileInputStream(filename)); BufferedInputStream bf = new BufferedInputStream(new FileInputStream(filename));
pro.load(bf); // /加载属性列表 pro.load(bf); // /加载属性列表
Iterator<String> it = pro.stringPropertyNames().iterator(); Iterator<String> it = pro.stringPropertyNames().iterator();
while (it.hasNext()) { while (it.hasNext()) {
String key = it.next(); String key = it.next();
properties.put(key, pro.getProperty(key)); properties.put(key, pro.getProperty(key));
} }
bf.close(); bf.close();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
} }

@ -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>

@ -1,146 +1,146 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper <!DOCTYPE mapper
PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN" PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
"http://ibatis.apache.org/dtd/ibatis-3-mapper.dtd"> "http://ibatis.apache.org/dtd/ibatis-3-mapper.dtd">
<mapper namespace="com.platform.dao.GatherOracleDao"> <mapper namespace="com.platform.dao.GatherOracleDao">
<resultMap type="com.platform.entities.GatherOracleInfo" id="getEntityBytext"> <resultMap type="com.platform.entities.GatherOracleInfo" id="getEntityBytext">
<id property="id" column="id" javaType="int" jdbcType="INTEGER" /> <id property="id" column="id" javaType="int" jdbcType="INTEGER" />
<result property="port" column="service_port" javaType="int" jdbcType="INTEGER"/> <result property="port" column="service_port" javaType="int" jdbcType="INTEGER"/>
<result property="ip" column="service_ip" javaType="string" jdbcType="VARCHAR"/> <result property="ip" column="service_ip" javaType="string" jdbcType="VARCHAR"/>
<result property="name" column="service_name" javaType="string" jdbcType="VARCHAR"/> <result property="name" column="service_name" javaType="string" jdbcType="VARCHAR"/>
<result property="user" column="service_user" javaType="string" jdbcType="VARCHAR"/> <result property="user" column="service_user" javaType="string" jdbcType="VARCHAR"/>
<result property="password" column="service_password" javaType="string" jdbcType="VARCHAR"/> <result property="password" column="service_password" javaType="string" jdbcType="VARCHAR"/>
<result property="databaseName" column="service_database" javaType="string" jdbcType="VARCHAR"/> <result property="databaseName" column="service_database" javaType="string" jdbcType="VARCHAR"/>
<result property="tableName" column="service_table" javaType="string" jdbcType="VARCHAR"/> <result property="tableName" column="service_table" javaType="string" jdbcType="VARCHAR"/>
<result property="suffix" column="service_suffix" javaType="string" jdbcType="VARCHAR"/> <result property="suffix" column="service_suffix" javaType="string" jdbcType="VARCHAR"/>
<result property="status" column="service_status" javaType="string" jdbcType="VARCHAR"/> <result property="status" column="service_status" javaType="string" jdbcType="VARCHAR"/>
<result property="remove" column="remove" jdbcType="CHAR"/> <result property="remove" column="remove" jdbcType="CHAR"/>
</resultMap> </resultMap>
<sql id="baseOracleInfo"> <sql id="baseOracleInfo">
id id, service_port port, service_ip ip, service_name name, service_user user, service_password password, service_database databaseName, service_table tableName, service_suffix suffix, service_status status id id, service_port port, service_ip ip, service_name name, service_user user, service_password password, service_database databaseName, service_table tableName, service_suffix suffix, service_status status
</sql> </sql>
<select id="selectAllOracle" resultType="com.platform.entities.GatherOracleInfo"> <select id="selectAllOracle" resultType="com.platform.entities.GatherOracleInfo">
SELECT SELECT
<include refid="baseOracleInfo" /> <include refid="baseOracleInfo" />
FROM services_info FROM services_info
WHERE remove = "0" WHERE remove = "0"
</select> </select>
<insert id="insertOracle" parameterType="com.platform.entities.GatherOracleInfo"> <insert id="insertOracle" parameterType="com.platform.entities.GatherOracleInfo">
INSERT INTO INSERT INTO
services_info( services_info(
<trim suffixOverrides=","> <trim suffixOverrides=",">
<if test="port > 0"> <if test="port > 0">
service_port, service_port,
</if> </if>
<if test="ip != null and ip != ''"> <if test="ip != null and ip != ''">
service_ip, service_ip,
</if> </if>
<if test="name != null and name != ''"> <if test="name != null and name != ''">
service_name, service_name,
</if> </if>
<if test="user != null and user != ''"> <if test="user != null and user != ''">
service_user, service_user,
</if> </if>
<if test="password != null and password != ''"> <if test="password != null and password != ''">
service_password, service_password,
</if> </if>
<if test="databaseName != null and databaseName != ''"> <if test="databaseName != null and databaseName != ''">
service_database, service_database,
</if> </if>
<if test="tableName != null and tableName != ''"> <if test="tableName != null and tableName != ''">
service_table, service_table,
</if> </if>
<if test="suffix != null and suffix != ''"> <if test="suffix != null and suffix != ''">
service_suffix, service_suffix,
</if> </if>
<if test="status != null and status != ''"> <if test="status != null and status != ''">
service_status, service_status,
</if> </if>
</trim> </trim>
) )
VALUES( VALUES(
<trim suffixOverrides=","> <trim suffixOverrides=",">
<if test="port > 0"> <if test="port > 0">
#{port}, #{port},
</if> </if>
<if test="ip != null and ip != ''"> <if test="ip != null and ip != ''">
#{ip}, #{ip},
</if> </if>
<if test="name != null and name != ''"> <if test="name != null and name != ''">
#{name}, #{name},
</if> </if>
<if test="user != null and user != ''"> <if test="user != null and user != ''">
#{user}, #{user},
</if> </if>
<if test="password != null and password != ''"> <if test="password != null and password != ''">
#{password}, #{password},
</if> </if>
<if test="databaseName != null and databaseName != ''"> <if test="databaseName != null and databaseName != ''">
#{databaseName}, #{databaseName},
</if> </if>
<if test="tableName != null and tableName != ''"> <if test="tableName != null and tableName != ''">
#{tableName}, #{tableName},
</if> </if>
<if test="suffix != null and suffix != ''"> <if test="suffix != null and suffix != ''">
#{suffix}, #{suffix},
</if> </if>
<if test="status != null and status != ''"> <if test="status != null and status != ''">
#{status}, #{status},
</if> </if>
</trim> </trim>
) )
</insert> </insert>
<delete id="deleteOracleById" parameterType="java.lang.Integer"> <delete id="deleteOracleById" parameterType="java.lang.Integer">
DELETE FROM services_info DELETE FROM services_info
<where> <where>
id =#{id} id =#{id}
</where> </where>
</delete> </delete>
<update id="updateOracleById" parameterType="com.platform.entities.GatherOracleInfo"> <update id="updateOracleById" parameterType="com.platform.entities.GatherOracleInfo">
UPDATE UPDATE
services_info services_info
<set > <set >
<trim suffixOverrides=","> <trim suffixOverrides=",">
<if test="name != null and name != ''"> <if test="name != null and name != ''">
service_name = #{name}, service_name = #{name},
</if> </if>
<if test="ip != null and ip != ''"> <if test="ip != null and ip != ''">
service_ip = #{ip}, service_ip = #{ip},
</if> </if>
<if test="port > 0"> <if test="port > 0">
service_port= #{port}, service_port= #{port},
</if> </if>
<if test="user != null and user != ''"> <if test="user != null and user != ''">
service_user= #{user}, service_user= #{user},
</if> </if>
<if test="password != null and password != ''"> <if test="password != null and password != ''">
service_password= #{password}, service_password= #{password},
</if> </if>
<if test="databaseName != null and databaseName != ''"> <if test="databaseName != null and databaseName != ''">
service_database= #{databaseName}, service_database= #{databaseName},
</if> </if>
<if test="tableName != null and tableName != ''"> <if test="tableName != null and tableName != ''">
service_table= #{tableName}, service_table= #{tableName},
</if> </if>
<if test="suffix != null and suffix != ''"> <if test="suffix != null and suffix != ''">
service_suffix= #{suffix}, service_suffix= #{suffix},
</if> </if>
<if test="status != null and status != ''"> <if test="status != null and status != ''">
service_status= #{status}, service_status= #{status},
</if> </if>
<if test="remove != null and remove != ''"> <if test="remove != null and remove != ''">
remove= #{remove}, remove= #{remove},
</if> </if>
</trim> </trim>
</set> </set>
<where> <where>
id = #{id} id = #{id}
</where> </where>
</update> </update>
</mapper> </mapper>

@ -1,208 +1,248 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper <!DOCTYPE mapper
PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN" PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
"http://ibatis.apache.org/dtd/ibatis-3-mapper.dtd"> "http://ibatis.apache.org/dtd/ibatis-3-mapper.dtd">
<mapper namespace="com.platform.dao.DataInfoDao"> <mapper namespace="com.platform.dao.DataInfoDao">
<resultMap id="getEntityByText" type="DataInfoEntity"> <resultMap id="getEntityByText" type="DataInfoEntity">
<id property="id" column="id" javaType="int" jdbcType="INTEGER" /> <id property="id" column="id" javaType="int" jdbcType="INTEGER" />
<result property="regionalismCode" column="regionalism_code" <result property="regionalismCode" column="regionalism_code"
javaType="string" jdbcType="VARCHAR" /> javaType="string" jdbcType="VARCHAR" />
<result property="cityName" column="city_name" javaType="string" <result property="cityName" column="city_name" javaType="string"
jdbcType="VARCHAR" /> jdbcType="VARCHAR" />
<result property="districtName" column="district_name" <result property="districtName" column="district_name"
javaType="string" jdbcType="VARCHAR" /> javaType="string" jdbcType="VARCHAR" />
<result property="systemCode" column="system_code" javaType="int" <result property="systemCode" column="system_code" javaType="int"
jdbcType="INTEGER" /> jdbcType="INTEGER" />
<result property="systemName" column="system_name" javaType="string" <result property="systemName" column="system_name" javaType="string"
jdbcType="VARCHAR" /> jdbcType="VARCHAR" />
<result property="dataType" column="data_type" javaType="string" <result property="dataType" column="data_type" javaType="string"
jdbcType="VARCHAR" /> jdbcType="VARCHAR" />
<result property="dataVersion" column="data_version" javaType="int" <result property="dataVersion" column="data_version" javaType="int"
jdbcType="INTEGER" /> jdbcType="INTEGER" />
<result property="submittedBatch" column="submitted_batch" <result property="submittedBatch" column="submitted_batch"
javaType="string" jdbcType="VARCHAR" /> javaType="string" jdbcType="VARCHAR" />
<result property="dataPath" column="data_path" javaType="string" <result property="dataPath" column="data_path" javaType="string"
jdbcType="VARCHAR" /> jdbcType="VARCHAR" />
<result property="charset" column="data_charset" javaType="string" <result property="charset" column="data_charset" javaType="string"
jdbcType="VARCHAR" /> jdbcType="VARCHAR" />
<result property="collectingTime" column="collection_time" <result property="collectingTime" column="collection_time"
javaType="string" jdbcType="DATE" /> javaType="string" jdbcType="DATE" />
<result property="collectorContacts" column="collector_contacts" <result property="collectorContacts" column="collector_contacts"
javaType="string" jdbcType="VARCHAR" /> javaType="string" jdbcType="VARCHAR" />
<result property="collectorName" column="collector_name" <result property="collectorName" column="collector_name"
javaType="string" jdbcType="VARCHAR" /> javaType="string" jdbcType="VARCHAR" />
<result property="year" column="data_year" javaType="string" <result property="extractStatus" column="extract_status" jdbcType="INTEGER" />
jdbcType="VARCHAR" />
</resultMap> <result property="year" column="data_year" javaType="string"
<sql id="conditionsFilters"> jdbcType="VARCHAR" />
<if test="PagerOptions.dataType!=null"> <result property="startYear" column="start_year" javaType="string"
and data_details.data_type=#{PagerOptions.dataType} jdbcType="VARCHAR" />
</if> <result property="endYear" column="end_year" javaType="string"
<if test="PagerOptions.submittedBatch!=null"> jdbcType="VARCHAR" />
and <result property="volumeIp" column="volume_ip" javaType="string"
data_details.submitted_batch=#{PagerOptions.submittedBatch} jdbcType="VARCHAR" />
</if> <result property="volumePath" column="volume_path" javaType="string"
<if test="PagerOptions.cityName!=null"> jdbcType="VARCHAR" />
and data_details.city_name=#{PagerOptions.cityName} </resultMap>
</if> <sql id="conditionsFilters">
<if test="PagerOptions.districtName!=null"> <if test="PagerOptions.dataType!=null">
and and data_details.data_type=#{PagerOptions.dataType}
data_details.district_name=#{PagerOptions.districtName} </if>
</if> <if test="PagerOptions.submittedBatch!=null">
<if test="PagerOptions.dataVersion !=null"> and
and data_details.data_version=#{PagerOptions.dataVersion} data_details.submitted_batch=#{PagerOptions.submittedBatch}
</if> </if>
<if test="PagerOptions.systemName !=null"> <if test="PagerOptions.cityName!=null">
and data_details=#{PagerOptions.systemName} and data_details.city_name=#{PagerOptions.cityName}
</if> </if>
<if test="PagerOptions.dataYear !=null"> <if test="PagerOptions.districtName!=null">
and data_details.data_year=#{PagerOptions.dataYear} and
</if> data_details.district_name=#{PagerOptions.districtName}
</sql> </if>
<if test="PagerOptions.dataVersion !=null">
<!-- 获取数据符合筛选条件的全部记录信息 --> and data_details.data_version=#{PagerOptions.dataVersion}
<select id="getLimitedDataInfoEntities" parameterType="PagerOptions" </if>
resultMap="getEntityByText"> <if test="PagerOptions.systemName !=null">
SELECT and data_details=#{PagerOptions.systemName}
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 </if>
FROM data_details <if test="PagerOptions.dataYear !=null">
<if test="PagerOptions!=null"> and data_details.data_year=#{PagerOptions.dataYear}
<where> </if>
<include refid="conditionsFilters" /> </sql>
<choose>
<when test="PagerOptions.offset > 0"> <!-- 获取数据符合筛选条件的全部记录信息 -->
and data_details.id>= #{PagerOptions.offset} <select id="getLimitedDataInfoEntities" parameterType="PagerOptions"
</when> resultMap="getEntityByText">
<otherwise> SELECT
and data_details.id>=0 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
</otherwise> FROM data_details
</choose> <if test="PagerOptions!=null">
</where> <where>
<include refid="conditionsFilters" />
ORDER BY data_details.id <choose>
<if test="PagerOptions.limit > 0"> <when test="PagerOptions.offset > 0">
LIMIT #{PagerOptions.limit} and data_details.id>= #{PagerOptions.offset}
</if> </when>
</if> <otherwise>
</select> and data_details.id>=0
</otherwise>
<!-- 获取数据符合筛选条件的总记录条数 --> </choose>
<select id="getLimitedDataCount" resultType="java.lang.Integer" </where>
parameterType="PagerOptions">
SELECT COUNT(id) FROM data_details ORDER BY data_details.id
<if test="PagerOptions!=null"> <if test="PagerOptions.limit > 0">
<where> LIMIT #{PagerOptions.limit}
<include refid="conditionsFilters" /> </if>
</where> </if>
</if> </select>
</select> <!-- 获取数据符合筛选条件的总记录条数 -->
<select id="getLimitedDataCount" resultType="java.lang.Integer"
<!-- 获取数据查询的起始di --> parameterType="PagerOptions">
<select id="getLimitedBeginId" resultType="java.lang.Integer" SELECT COUNT(id) FROM data_details
parameterType="PagerOptions"> <if test="PagerOptions!=null">
SELECT MAX(idx) FROM (SELECT id idx FROM data_details <where>
ORDER BY id LIMIT 0,#{PagerOptions.totalLimit}) AS TEMP <include refid="conditionsFilters" />
</select> </where>
</if>
<insert id="save" parameterType="com.platform.entities.DataInfoEntity">
INSERT INTO </select>
data_info(
<trim suffixOverrides=","> <!-- 获取数据查询的起始di -->
<if test="regionalismCode != null and regionalismCode != ''"> <select id="getLimitedBeginId" resultType="java.lang.Integer"
regionalism_code, parameterType="PagerOptions">
</if> SELECT MAX(idx) FROM (SELECT id idx FROM data_details
<if test="systemCode > 0"> ORDER BY id LIMIT 0,#{PagerOptions.totalLimit}) AS TEMP
system_code, </select>
</if>
<if test="dataType != null and dataType != ''"> <insert id="save" parameterType="com.platform.entities.DataInfoEntity">
data_type, INSERT INTO
</if> data_info(
<if test="dataVersion != null"> <trim suffixOverrides=",">
data_version, <if test="regionalismCode != null and regionalismCode != ''">
</if> regionalism_code,
<if test="submittedBatch != null and submittedBatch != ''"> </if>
submitted_batch, <if test="systemCode != null">
</if> system_code,
<if test="dataPath != null and dataPath != ''"> </if>
data_path, <if test="dataType != null and dataType != ''">
</if> data_type,
<if test="collectingTime != null"> </if>
collection_time, <if test="dataVersion != null">
</if> data_version,
<if test="collectorName != null and collectorName != ''"> </if>
collector_name, <if test="submittedBatch != null and submittedBatch != ''">
</if> submitted_batch,
<if test="collectorContacts != null and collectorContacts != ''"> </if>
collector_contacts, <if test="dataPath != null and dataPath != ''">
</if> data_path,
<if test="charset != null and charset != ''"> </if>
data_charset, <if test="collectingTime != null">
</if> collection_time,
<if test="year != null and year != ''"> </if>
data_year <if test="collectorName != null and collectorName != ''">
</if> collector_name,
</trim> </if>
) <if test="collectorContacts != null and collectorContacts != ''">
VALUES( collector_contacts,
<trim suffixOverrides=","> </if>
<if test="regionalismCode != null and regionalismCode != ''"> <if test="charset != null and charset != ''">
#{regionalismCode}, data_charset,
</if> </if>
<if test="systemCode != null"> <if test="year != null and year != ''">
#{systemCode}, data_year,
</if> </if>
<if test="dataType != null and dataType != ''"> <if test="startYear != null and startYear != ''">
#{dataType}, start_year,
</if> </if>
<if test="dataVersion != null"> <if test="endYear != null and endYear != ''">
#{dataVersion}, end_year,
</if> </if>
<if test="submittedBatch != null and submittedBatch != ''"> <if test="volumeIp != null and volumeIp != ''">
#{submittedBatch}, volume_ip,
</if> </if>
<if test="dataPath != null and dataPath != ''"> <if test="volumePath != null and volumePath != ''">
#{dataPath}, volume_path,
</if> </if>
<if test="collectingTime != null"> <if test="extractStatus > 0">
#{collectingTime}, extract_status,
</if> </if>
<if test="collectorName != null and collectorName != ''"> </trim>
#{collectorName}, )
</if> VALUES(
<if test="collectorContacts != null and collectorContacts != ''"> <trim suffixOverrides=",">
#{collectorContacts}, <if test="regionalismCode != null and regionalismCode != ''">
</if> #{regionalismCode},
<if test="charset != null and charset != ''"> </if>
#{charset}, <if test="systemCode != null">
</if> #{systemCode},
<if test="year != null and year != ''"> </if>
#{year} <if test="dataType != null and dataType != ''">
</if> #{dataType},
</trim> </if>
) <if test="dataVersion != null">
</insert> #{dataVersion},
</if>
<select id="getIdIsExist" parameterType="java.util.List" resultType="java.lang.String"> <if test="submittedBatch != null and submittedBatch != ''">
select data_path #{submittedBatch},
from data_info </if>
where id in <if test="dataPath != null and dataPath != ''">
<foreach item="item" index="index" collection="list" open="(" separator="," close=")"> #{dataPath},
#{item} </if>
</foreach> <if test="collectingTime != null">
and remove ='0' #{collectingTime},
</select> </if>
<if test="collectorName != null and collectorName != ''">
<update id="removes" parameterType="java.util.List"> #{collectorName},
UPDATE </if>
data_info <if test="collectorContacts != null and collectorContacts != ''">
set remove = '1' #{collectorContacts},
where id in </if>
<foreach item="item" index="index" collection="list" open="(" separator="," close=")"> <if test="charset != null and charset != ''">
#{item} #{charset},
</foreach> </if>
and remove ='0' <if test="year != null and year != ''">
</update> #{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>
)
</insert>
<select id="getIdIsExist" parameterType="java.util.List" resultType="java.lang.String">
select data_path
from data_info
where id in
<foreach item="item" index="index" collection="list" open="(" separator="," close=")">
#{item}
</foreach>
and remove ='0'
</select>
<update id="removes" parameterType="java.util.List">
UPDATE
data_info
set remove = '1'
where id in
<foreach item="item" index="index" collection="list" open="(" separator="," close=")">
#{item}
</foreach>
and remove ='0'
</update>
</mapper> </mapper>

@ -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>

@ -1,178 +1,189 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper <!DOCTYPE mapper
PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN" PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
"http://ibatis.apache.org/dtd/ibatis-3-mapper.dtd"> "http://ibatis.apache.org/dtd/ibatis-3-mapper.dtd">
<mapper namespace="com.platform.dao.DataInfoMoveTmpDao"> <mapper namespace="com.platform.dao.DataInfoMoveTmpDao">
<resultMap id="getEntityByText" type="com.platform.entities.DataInfoEntityMoveTmp"> <resultMap id="getEntityByText" type="com.platform.entities.DataInfoEntityMoveTmp">
<id property="id" column="id" javaType="int" jdbcType="INTEGER" /> <id property="id" column="id" javaType="int" jdbcType="INTEGER" />
<result property="regionalismCode" column="regionalism_code" <result property="regionalismCode" column="regionalism_code"
javaType="string" jdbcType="VARCHAR" /> javaType="string" jdbcType="VARCHAR" />
<result property="cityName" column="city_name" javaType="string" <result property="cityName" column="city_name" javaType="string"
jdbcType="VARCHAR" /> jdbcType="VARCHAR" />
<result property="districtName" column="district_name" <result property="districtName" column="district_name"
javaType="string" jdbcType="VARCHAR" /> javaType="string" jdbcType="VARCHAR" />
<result property="systemCode" column="system_code" javaType="int" <result property="systemCode" column="system_code" javaType="int"
jdbcType="INTEGER" /> jdbcType="INTEGER" />
<result property="systemName" column="system_name" javaType="string" <result property="systemName" column="system_name" javaType="string"
jdbcType="VARCHAR" /> jdbcType="VARCHAR" />
<result property="dataType" column="data_type" javaType="string" <result property="dataType" column="data_type" javaType="string"
jdbcType="VARCHAR" /> jdbcType="VARCHAR" />
<result property="dataVersion" column="data_version" javaType="int" <result property="dataVersion" column="data_version" javaType="int"
jdbcType="INTEGER" /> jdbcType="INTEGER" />
<result property="submittedBatch" column="submitted_batch" <result property="submittedBatch" column="submitted_batch"
javaType="string" jdbcType="VARCHAR" /> javaType="string" jdbcType="VARCHAR" />
<result property="dataPath" column="data_path" javaType="string" <result property="dataPath" column="data_path" javaType="string"
jdbcType="VARCHAR" /> jdbcType="VARCHAR" />
<result property="charset" column="data_charset" javaType="string" <result property="charset" column="data_charset" javaType="string"
jdbcType="VARCHAR" /> jdbcType="VARCHAR" />
<result property="collectingTime" column="collection_time" <result property="collectingTime" column="collection_time"
javaType="string" jdbcType="DATE" /> javaType="string" jdbcType="DATE" />
<result property="collectorContacts" column="collector_contacts" <result property="collectorContacts" column="collector_contacts"
javaType="string" jdbcType="VARCHAR" /> javaType="string" jdbcType="VARCHAR" />
<result property="collectorName" column="collector_name" <result property="collectorName" column="collector_name"
javaType="string" jdbcType="VARCHAR" /> javaType="string" jdbcType="VARCHAR" />
<result property="year" column="data_year" javaType="string" <result property="year" column="data_year" javaType="string"
jdbcType="VARCHAR" /> jdbcType="VARCHAR" />
<result property="dstPath" column="dst_path" javaType="string" <result property="dstPath" column="dst_path" javaType="string"
jdbcType="VARCHAR" /> jdbcType="VARCHAR" />
<result property="completeStatus" column="complete_status" javaType="string" <result property="completeStatus" column="complete_status" javaType="string"
jdbcType="VARCHAR" /> jdbcType="VARCHAR" />
<result property="rate" column="rate" javaType="int" <result property="rate" column="rate" javaType="int"
jdbcType="INTEGER" /> jdbcType="INTEGER" />
<result property="lastTime" column="lasttime" <result property="lastTime" column="lasttime"
javaType="string" jdbcType="VARCHAR" /> javaType="string" jdbcType="VARCHAR" />
</resultMap> <result property="fkid" column="fkid" javaType="int" jdbcType="INTEGER" />
<result property="dstVolumeIp" column="dst_volume_ip" jdbcType="VARCHAR" />
<sql id="Base_Column_List"> <result property="dstVolumePath" column="dst_volume_ip" jdbcType="VARCHAR" />
regionalism_code,system_code,dst_path,lasttime </resultMap>
</sql>
<sql id="Base_Column_List">
<!-- 获取数据全部记录信息 --> regionalism_code,system_code,dst_path,lasttime,fkid
<select id="findAll" resultType="com.platform.entities.DataInfoEntityMoveTmp"> </sql>
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, <select id="findAll" resultType="com.platform.entities.DataInfoEntityMoveTmp">
b.submitted_batch submittedBatch,b.data_path dataPath,b.data_charset charset,b.collection_time collectionTime, SELECT
b.collector_name collectorName,b.collector_contacts collectorContacts,b.data_year dataYear,a.dst_path dstPath, a.id id,a.regionalism_code regionalismCode,a.dst_path dstPath,a.complete_status completeStatus,
a.complete_status completeStatus,a.rate rate, a.lasttime lastTime a.rate rate, a.lasttime lastTime, a.system_code systemCode,a.dst_volume_ip dstVolumeIp,a.dst_volume_path dstVolumePath,
FROM b.city_name cityName,b.district_name districtName,b.system_name systemName,b.data_type dataType,
move_data_tmp a LEFT JOIN data_details b b.data_version dataVersion,b.submitted_batch submittedBatch,b.data_path dataPath,b.data_charset charset,
ON a.system_code = b.system_code AND a.regionalism_code = b.regionalism_code b.collection_time collectingTime,b.collector_name collectorName,b.collector_contacts collectorContacts,
ORDER BY a.id b.data_year year,b.extract_status extractStatus,b.start_year startYear,b.end_year endYear,
</select> b.volume_ip volumeIp,b.volume_path volumePath
FROM
<update id="update" parameterType="com.platform.entities.DataInfoEntityMoveTmp"> move_data_tmp a LEFT JOIN data_details b
UPDATE ON a.system_code = b.system_code AND a.regionalism_code = b.regionalism_code AND a.fkid = b.id
move_data_tmp ORDER BY a.id
<set > </select>
<trim suffixOverrides=",">
<if test="dstPath != null and dstPath != ''"> <update id="update" parameterType="com.platform.entities.DataInfoEntityMoveTmp">
dst_path= #{dstPath}, UPDATE
</if> move_data_tmp
<if test="completeStatus != null and completeStatus != ''"> <set >
complete_status= #{completeStatus}, <trim suffixOverrides=",">
</if> <if test="dstPath != null and dstPath != ''">
<if test="rate > 0"> dst_path= #{dstPath},
rate= #{rate}, </if>
</if> <if test="completeStatus != null and completeStatus != ''">
<if test="lastTime != null and lastTime != ''"> complete_status= #{completeStatus},
lasttime= #{lastTime}, </if>
</if> <if test="rate > 0">
</trim> rate= #{rate},
</set> </if>
<where> <if test="lastTime != null and lastTime != ''">
id = #{id} lasttime= #{lastTime},
</where> </if>
</update> </trim>
</set>
<insert id="save" parameterType="com.platform.entities.DataInfoEntityMoveTmp"> <where>
INSERT INTO id = #{id}
move_data_tmp( </where>
<trim suffixOverrides=","> </update>
<if test="id > 0">
id, <insert id="save" parameterType="com.platform.entities.DataInfoEntityMoveTmp">
</if> INSERT INTO
<if test="regionalismCode != null and regionalismCode != ''"> move_data_tmp(
regionalism_code, <trim suffixOverrides=",">
</if> <if test="id > 0">
<if test="systemCode != null"> id,
system_code, </if>
</if> <if test="regionalismCode != null and regionalismCode != ''">
<if test="dstPath != null and dstPath != ''"> regionalism_code,
dst_path, </if>
</if> <if test="systemCode != null">
<if test="completeStatus != null and completeStatus != ''"> system_code,
complete_status, </if>
</if> <if test="dstPath != null and dstPath != ''">
<if test="rate > 0"> dst_path,
rate, </if>
</if> <if test="completeStatus != null and completeStatus != ''">
<if test="lastTime != null and lastTime != ''"> complete_status,
lasttime, </if>
</if> <if test="rate > 0">
</trim> rate,
) </if>
VALUES( <if test="lastTime != null and lastTime != ''">
<trim suffixOverrides=","> lasttime,
<if test="id > 0"> </if>
id, <if test="fkid > 0 ">
</if> fkid,
<if test="regionalismCode != null and regionalismCode != ''"> </if>
#{regionalismCode}, </trim>
</if> )
<if test="systemCode != null and systemCode != ''"> VALUES(
#{systemCode}, <trim suffixOverrides=",">
</if> <if test="id > 0">
<if test="dstPath != null and dstPath != ''"> id,
#{dstPath}, </if>
</if> <if test="regionalismCode != null and regionalismCode != ''">
<if test="completeStatus != null and completeStatus != ''"> #{regionalismCode},
#{completeStatus}, </if>
</if> <if test="systemCode != null and systemCode != ''">
<if test="rate > 0"> #{systemCode},
#{rate} </if>
</if> <if test="dstPath != null and dstPath != ''">
<if test="lastTime != null and lastTime != ''"> #{dstPath},
#{lastTime}, </if>
</if> <if test="completeStatus != null and completeStatus != ''">
</trim> #{completeStatus},
) </if>
</insert> <if test="rate > 0">
#{rate}
<select id="insertBatch" parameterType="java.util.List"> </if>
INSERT INTO move_data_tmp ( <include refid="Base_Column_List" /> ) <if test="lastTime != null and lastTime != ''">
VALUES #{lastTime},
<foreach collection="list" item="item" index="index" separator=","> </if>
(#{item.regionalismCode,jdbcType=VARCHAR},#{item.systemCode,jdbcType=INTEGER},#{item.dstPath,jdbcType=VARCHAR},#{item.lastTime,jdbcType=VARCHAR}) <if test="fkid > 0 ">
</foreach> #{fkid),
</select> </if>
</trim>
<delete id="remove" parameterType="java.lang.Integer"> )
DELETE FROM </insert>
move_data_tmp
WHERE <select id="insertBatch" parameterType="java.util.List">
id = #{id} INSERT INTO move_data_tmp ( <include refid="Base_Column_List" /> )
</delete> 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.fkid})
<select id="getLimitedDataCount" resultType="java.lang.Integer" </foreach>
parameterType="PagerOptions"> </select>
SELECT COUNT(id) FROM move_data_tmp
<if test="PagerOptions!=null"> <delete id="remove" parameterType="java.lang.Integer">
<where> DELETE FROM
<include refid="conditionsFilters" /> move_data_tmp
</where> WHERE
</if> id = #{id}
</delete>
</select> <!-- 获取数据符合筛选条件的总记录条数 -->
<!--
获取数据查询的起始di <select id="getLimitedDataCount" resultType="java.lang.Integer"
<select id="getLimitedBeginId" resultType="java.lang.Integer" parameterType="PagerOptions">
parameterType="PagerOptions"> SELECT COUNT(id) FROM move_data_tmp
SELECT MAX(idx) FROM (SELECT id idx FROM move_data_tmp <if test="PagerOptions!=null">
ORDER BY id LIMIT 0,#{PagerOptions.totalLimit}) AS TEMP <where>
</select> --> <include refid="conditionsFilters" />
</where>
</if>
</select>
获取数据查询的起始di
<select id="getLimitedBeginId" resultType="java.lang.Integer"
parameterType="PagerOptions">
SELECT MAX(idx) FROM (SELECT id idx FROM move_data_tmp
ORDER BY id LIMIT 0,#{PagerOptions.totalLimit}) AS TEMP
</select> -->
</mapper> </mapper>

@ -2,6 +2,7 @@ package com.platform.controller;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -11,11 +12,15 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject; import net.sf.json.JSONObject;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;
import org.springframework.ui.ModelMap; 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.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody; 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.DataInfoEntityMoveTmp;
import com.platform.entities.FolderNode; import com.platform.entities.FolderNode;
import com.platform.entities.GatherOracleInfo; import com.platform.entities.GatherOracleInfo;
import com.platform.entities.OracleConnectorParams;
import com.platform.entities.PagerOptions; import com.platform.entities.PagerOptions;
import com.platform.entities.VolumeEntity; import com.platform.entities.VolumeEntity;
import com.platform.glusterfs.CheckoutMD5;
import com.platform.service.DataInfoService; import com.platform.service.DataInfoService;
import com.platform.service.ICodeService;
import com.platform.service.IGfsService; import com.platform.service.IGfsService;
import com.platform.service.IMoveDataService; import com.platform.service.IMoveDataService;
import com.platform.service.IMySqlService; import com.platform.service.IMySqlService;
import com.platform.service.IOracleExtractService; import com.platform.service.IOracleExtractService;
import com.platform.service.OracleExtractHelper;
import com.platform.service.OracleStatusService; 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.Bean2MapUtils;
import com.platform.utils.Configs; import com.platform.utils.Configs;
import com.platform.utils.UtilsHelper; import com.platform.utils.UtilsHelper;
@Controller @Controller
public class DataModelController extends BaseController{ public class DataModelController extends BaseController{
public static Logger log = Logger.getLogger(DataModelController.class);
@Resource(name = "dataInfoService") @Resource(name = "dataInfoService")
private DataInfoService dfs; private DataInfoService dfs;
@ -53,7 +69,10 @@ public class DataModelController extends BaseController{
@Resource(name = "moveDataService") @Resource(name = "moveDataService")
private IMoveDataService moveDataService; private IMoveDataService moveDataService;
@Resource(name = "codeService")
private ICodeService codeService;
public void setDfsImp(DataInfoService dfs) { public void setDfsImp(DataInfoService dfs) {
this.dfs = 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) @RequestMapping(value="/oracle/{name}/extract", method= RequestMethod.POST)
public void extractOracleData(HttpServletRequest res, public void oracleExtract(HttpServletRequest res,
HttpServletResponse req, String name) throws Exception { HttpServletResponse req, String name) throws Exception {
res.setCharacterEncoding("UTF-8"); res.setCharacterEncoding("UTF-8");
System.out.println("------extract-------"); System.out.println("------extract-------");
@ -147,24 +165,44 @@ public class DataModelController extends BaseController{
OracleExtract.extractOracle(name, colleclist, map); 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) @RequestMapping(value="/volume/list", method= RequestMethod.POST)
@ResponseBody @ResponseBody
public List<VolumeEntity> getFolder(HttpServletRequest res, HttpServletResponse req) throws Exception { public List<VolumeEntity> volumeList() throws Exception {
System.out.println("get Request"); log.debug("-----/volume/list------");
// 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);
List<VolumeEntity> result = gfsService.getAllVolumes(); List<VolumeEntity> result = gfsService.getAllVolumes();
return result; return result;
} }
@SuppressWarnings({ "unused", "rawtypes" })
@RequestMapping(value = "/volume/{name}/move", method= RequestMethod.POST) @RequestMapping(value = "/volume/{name}/move", method= RequestMethod.POST)
@ResponseBody // @ResponseBody
public Object move(HttpServletRequest res, HttpServletResponse req, String name, public void volumeMove(HttpServletRequest res, HttpServletResponse req, String name,
FolderNode selectNode, DataInfoEntity selectItems) throws Exception { FolderNode selectNode, DataInfoEntity selectItems) throws Exception {
res.setCharacterEncoding("UTF-8"); res.setCharacterEncoding("UTF-8");
System.out.println("get Request"); System.out.println("get Request");
@ -188,71 +226,95 @@ public class DataModelController extends BaseController{
System.out.println(string); System.out.println(string);
JSONObject jsobj = JSONObject.fromObject(string); JSONObject jsobj = JSONObject.fromObject(string);
Map itemmap = jsobj; Map itemmap = jsobj;
if (null != itemmap.get("volume")) {
srcVolumes.add((String) itemmap.get("volume"));
}
DataInfoEntity data = (DataInfoEntity) Bean2MapUtils.convertMap(DataInfoEntity.class, itemmap); DataInfoEntity data = (DataInfoEntity) Bean2MapUtils.convertMap(DataInfoEntity.class, itemmap);
datas.add(data); datas.add(data);
} }
System.out.println("------/volume/{name}/move--------"); System.out.println("------/volume/{name}/move--------");
boolean result = false ;
if (datas.size() >0) { 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) @RequestMapping(value="/oracle/list", method= RequestMethod.POST)
@ResponseBody @ResponseBody
public List<GatherOracleInfo> getOracleInfo(HttpServletRequest res, public List<GatherOracleInfo> oracleList() throws Exception {
HttpServletResponse req) throws Exception { log.debug("----------getOracleInfo-----------------------");
List<GatherOracleInfo> result = mySqlService.findAllMySql(); List<GatherOracleInfo> result = mySqlService.findAllMySql();
System.out.println("----------getOracleInfo-----------------------");
return result; return result;
} }
@RequestMapping(value="/oracle/{id}/delete", method= RequestMethod.POST) @RequestMapping(value="/oracle/{id}/delete", method= RequestMethod.POST)
@ResponseBody @ResponseBody
public void deleteOracleInfo(HttpServletRequest res, public void oracleDelete(int id) throws Exception {
HttpServletResponse req, int id) throws Exception { log.debug("----------deleteOracleInfo----------------");
res.setCharacterEncoding("UTF-8");
mySqlService.deleteMySql(id); mySqlService.deleteMySql(id);
System.out.println("----------deleteOracleInfo-----------------------");
} }
@RequestMapping(value="/oracle/{id}/insert", method= RequestMethod.POST) @RequestMapping(value="/oracle/{id}/insert", method= RequestMethod.POST)
@ResponseBody @ResponseBody
public void insertOracleInfo(HttpServletRequest res, public void oracleInsert(GatherOracleInfo oracle) throws Exception {
HttpServletResponse req, GatherOracleInfo oracle) throws Exception { log.debug("----------insertOracleInfo----------------");
res.setCharacterEncoding("UTF-8");
mySqlService.insertOracle(oracle); mySqlService.insertOracle(oracle);
System.out.println("----------insertOracleInfo-----------------------");
} }
@RequestMapping(value="/oracle/{id}/update", method= RequestMethod.POST) @RequestMapping(value="/oracle/{id}/update", method= RequestMethod.POST)
@ResponseBody public void oracleUpdate(@RequestBody GatherOracleInfo oracle) throws Exception {
public void updateOracleInfo(HttpServletRequest res, log.debug("----------updateOracleInfo-----------------------");
HttpServletResponse req, GatherOracleInfo oracle) throws Exception { log.debug(oracle);
res.setCharacterEncoding("gb2312");
System.out.println(oracle.getName());
System.out.println(oracle);
mySqlService.updateOracle(oracle); mySqlService.updateOracle(oracle);
System.out.println("----------updateOracleInfo-----------------------");
} }
@RequestMapping(value="/task/transfer/list", method= RequestMethod.POST) @RequestMapping(value="/task/transfer/list", method= RequestMethod.POST)
@ResponseBody @ResponseBody
public Object taskList() throws Exception { public Object taskTransferList() throws Exception {
log.debug("----------/task/transfer/list-----------------------");
List<DataInfoEntityMoveTmp> result = moveDataService.findAll(); List<DataInfoEntityMoveTmp> result = moveDataService.findAll();
return result; return result;
} }
@RequestMapping(value="/task/transfer/{id}/delete", method= RequestMethod.POST) @RequestMapping(value="/task/transfer/delete", method= RequestMethod.POST)
@ResponseBody @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); int result = moveDataService.delete(move);
return result; 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;
}
} }

@ -1,32 +1,32 @@
package com.platform.controller; package com.platform.controller;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap; import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
import com.platform.utils.Configs; import com.platform.utils.Configs;
@Controller @Controller
public class DefaultController { public class DefaultController {
@RequestMapping("/") @RequestMapping("/")
public ModelAndView defaultHandler(HttpServletRequest req, HttpServletResponse res){ public ModelAndView defaultHandler(HttpServletRequest req, HttpServletResponse res){
//处理不匹配的请求 //处理不匹配的请求
System.out.println("index"); System.out.println("index");
return new ModelAndView("index"); return new ModelAndView("index");
} }
@RequestMapping("/test") @RequestMapping("/test")
public ModelMap test(HttpServletRequest req, HttpServletResponse res){ public ModelMap test(HttpServletRequest req, HttpServletResponse res){
//System.out.println(Class.class.getClass().getResource("/").getPath()); //System.out.println(Class.class.getClass().getResource("/").getPath());
System.out.println(Configs.EXTRACT_LOG_LOCALTION); System.out.println(Configs.EXTRACT_LOG_LOCALTION);
return new ModelMap(); return new ModelMap();
} }
} }

@ -1,114 +1,114 @@
package com.platform.controller; package com.platform.controller;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import javax.annotation.Resource; import javax.annotation.Resource;
import oracle.sql.DATE; import oracle.sql.DATE;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import com.base.BaseController; import com.base.BaseController;
import com.base.CustomException; import com.base.CustomException;
import com.platform.entities.GfsFolderEntity; import com.platform.entities.GfsFolderEntity;
import com.platform.entities.VolumeEntity; import com.platform.entities.VolumeEntity;
import com.platform.glusterfs.VolumeInfo; import com.platform.glusterfs.VolumeInfo;
import com.platform.entities.VolumeEntity; import com.platform.entities.VolumeEntity;
import com.platform.glusterfs.VolumeInfo; import com.platform.glusterfs.VolumeInfo;
import com.platform.service.IGfsService; import com.platform.service.IGfsService;
/** /**
* <> * <>
* <> * <>
* @author chen * @author chen
* @version [201698] * @version [201698]
* @see [/] * @see [/]
* @since [/] * @since [/]
*/ */
@Controller @Controller
@RequestMapping("") @RequestMapping("")
public class FolderController extends BaseController { public class FolderController extends BaseController {
@Resource(name = "gfsService") @Resource(name = "gfsService")
private IGfsService gfsService; private IGfsService gfsService;
@RequestMapping(value="/getAllSubPathByPath", method= RequestMethod.POST) @RequestMapping(value="/getAllSubPathByPath", method= RequestMethod.POST)
public Object getAllSubPathByPath(String path) throws Exception { public Object getAllSubPathByPath(String path) throws Exception {
System.out.println(path); System.out.println(path);
Object result = null; Object result = null;
if (null != path && !"".equals(path)) { if (null != path && !"".equals(path)) {
System.out.println(path); System.out.println(path);
result = gfsService.getFolder(path); result = gfsService.getFolder(path);
} }
return result; return result;
} }
@RequestMapping("/copyFolder") @RequestMapping("/copyFolder")
public Object copyFolder(String srcpath, String dstPath, String name) throws Exception { public Object copyFolder(String srcpath, String dstPath, String name) throws Exception {
// -1 :error; -2: the filename is not exists ;-3 :destFolderName ; 1: right // -1 :error; -2: the filename is not exists ;-3 :destFolderName ; 1: right
int result = 0; int result = 0;
// int result = gfsService.copyFolder(srcpath, dstPath, name); // int result = gfsService.copyFolder(srcpath, dstPath, name);
System.out.println(srcpath); System.out.println(srcpath);
System.out.println(dstPath); System.out.println(dstPath);
String obj = "right"; String obj = "right";
if (1 != result) { if (1 != result) {
obj = "err"; obj = "err";
} }
return obj; return obj;
} }
// /** // /**
// * <一句话功能简述> 查询集群中所有的 volume 及其 信息 // * <一句话功能简述> 查询集群中所有的 volume 及其 信息
// * <功能详细描述> // * <功能详细描述>
// * @return // * @return
// * @throws Exception // * @throws Exception
// * @see [类、类#方法、类#成员] // * @see [类、类#方法、类#成员]
// */ // */
// @RequestMapping(value="/volume/list", method= RequestMethod.POST) // @RequestMapping(value="/volume/list", method= RequestMethod.POST)
// public Object getVolums() throws Exception{ // public Object getVolums() throws Exception{
// System.out.println("----------------------------------"); // System.out.println("----------------------------------");
// long a = new Date().getTime(); // long a = new Date().getTime();
// List<VolumeEntity> result = gfsService.getAllVolumes(); // List<VolumeEntity> result = gfsService.getAllVolumes();
// System.out.println("----------------------------------"); // System.out.println("----------------------------------");
// System.out.println(new Date().getTime()-a); // System.out.println(new Date().getTime()-a);
// return result; // return result;
// } // }
// //
/** /**
* <> volume * <> volume
* <> * <>
* @param volumeName "/home/gfs_ftp_point" "/home/v1_point" * @param volumeName "/home/gfs_ftp_point" "/home/v1_point"
* @return * @return
* @throws Exception * @throws Exception
* @see [##] * @see [##]
*/ */
@RequestMapping(value="/volume/findByName", method= RequestMethod.POST) @RequestMapping(value="/volume/findByName", method= RequestMethod.POST)
public Object getVolumByName(String volumeName) throws Exception{ public Object getVolumByName(String volumeName) throws Exception{
VolumeEntity result = gfsService.getOneVolume(volumeName); VolumeEntity result = gfsService.getOneVolume(volumeName);
return result; return result;
} }
} }

@ -1,52 +1,52 @@
/** /**
* : SetGlusterfs.java * : SetGlusterfs.java
* : </> * : </>
* : <> * : <>
* @author liliy * @author liliy
* : <> * : <>
* 201698 * 201698
* <> * <>
*/ */
package com.platform.controller; package com.platform.controller;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
/** /**
* <> * <>
* <> * <>
* <> * <>
* @author liliy * @author liliy
* @version [201698] * @version [201698]
* @see [/] * @see [/]
* @since [/] * @since [/]
*/ */
@Controller @Controller
public class SetGlusterfsController { public class SetGlusterfsController {
@RequestMapping("/tes") @RequestMapping("/tes")
public Object defaultHandler(HttpServletRequest req, HttpServletResponse request) { public Object defaultHandler(HttpServletRequest req, HttpServletResponse request) {
//<2F><><EFBFBD><><C6A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> //<2F><><EFBFBD><><C6A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
try { try {
System.out.println("fsdfds"); System.out.println("fsdfds");
return "listAll"; return "listAll";
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
return "result"; return "result";
} }
} }
} }

@ -1,50 +1,50 @@
/** /**
* : ShowGlusterfsController.java * : ShowGlusterfsController.java
* : </> * : </>
* : <> * : <>
* @author liliy * @author liliy
* : <> * : <>
* 201698 * 201698
* <> * <>
*/ */
package com.platform.controller; package com.platform.controller;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import com.platform.glusterfs.ClusterInfo; import com.platform.glusterfs.ClusterInfo;
import com.platform.glusterfs.VolumeInfo; import com.platform.glusterfs.VolumeInfo;
/** /**
* <> * <>
* <> * <>
* @author liliy * @author liliy
* @version [201698] * @version [201698]
* @see [/] * @see [/]
* @since [/] * @since [/]
*/ */
@Controller @Controller
public class ShowGlusterfsController { public class ShowGlusterfsController {
/** /**
* <> * <>
* <> * <>
* @return * @return
* @see [##] * @see [##]
*/ */
@RequestMapping("/showPeerStatus") @RequestMapping("/showPeerStatus")
public Map<String,String> showPeerStatus(){ public Map<String,String> showPeerStatus(){
Map<String, String> peer_status=new ClusterInfo().showClusterInfo(); Map<String, String> peer_status=new ClusterInfo().showClusterInfo();
return peer_status; return peer_status;
} }
} }

@ -1,26 +1,26 @@
package com.platform.dao; package com.platform.dao;
import java.util.List; import java.util.List;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import com.platform.entities.DataInfoEntity; import com.platform.entities.DataInfoEntity;
import com.platform.entities.PagerOptions; import com.platform.entities.PagerOptions;
@Repository(value = "dataInfoDao") @Repository(value = "dataInfoDao")
public interface DataInfoDao { public interface DataInfoDao {
int getLimitedDataCount(@Param("PagerOptions")PagerOptions pagerOptions); int getLimitedDataCount(@Param("PagerOptions")PagerOptions pagerOptions);
int getLimitedBeginId(@Param("PagerOptions")PagerOptions pagerOptions); int getLimitedBeginId(@Param("PagerOptions")PagerOptions pagerOptions);
List<DataInfoEntity> getLimitedDataInfoEntities(@Param("PagerOptions")PagerOptions pagerOptions); List<DataInfoEntity> getLimitedDataInfoEntities(@Param("PagerOptions")PagerOptions pagerOptions);
List<String> getIdIsExist(List<Integer> list)throws Exception; List<String> getIdIsExist(List<Integer> list)throws Exception;
int removes(List<Integer> list)throws Exception; int removes(List<Integer> list)throws Exception;
int save(DataInfoEntity data) throws Exception; int save(DataInfoEntity data) throws Exception;
} }

@ -1,29 +1,29 @@
package com.platform.dao; package com.platform.dao;
import java.util.List; import java.util.List;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import com.platform.entities.DataInfoEntityMoveTmp; import com.platform.entities.DataInfoEntityMoveTmp;
/** /**
* @author chen * @author chen
* *
*/ */
@Repository(value = "dataInfoMoveTmpDao") @Repository(value = "dataInfoMoveTmpDao")
public interface DataInfoMoveTmpDao { public interface DataInfoMoveTmpDao {
/** /**
* @return * @return
* @throws Exception * @throws Exception
*/ */
List<DataInfoEntityMoveTmp> findAll() throws Exception; List<DataInfoEntityMoveTmp> findAll() throws Exception;
int update(DataInfoEntityMoveTmp data) throws Exception; int update(DataInfoEntityMoveTmp data) throws Exception;
int save(DataInfoEntityMoveTmp data) throws Exception; int save(DataInfoEntityMoveTmp data) throws Exception;
void insertBatch(List<DataInfoEntityMoveTmp> list) throws Exception; void insertBatch(List<DataInfoEntityMoveTmp> list) throws Exception;
int remove(int id) throws Exception; int remove(int id) throws Exception;
} }

@ -1,99 +1,99 @@
package com.platform.dao; package com.platform.dao;
import java.util.List; import java.util.List;
import org.apache.ibatis.annotations.Delete; import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update; import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import com.platform.entities.EncodedInfoEntity; import com.platform.entities.EncodedInfoEntity;
/** /**
* : * :
* *
* @author wuming * @author wuming
* *
*/ */
@Repository(value = "encodeInfoDao") @Repository(value = "encodeInfoDao")
public interface EncodeInfoDao { public interface EncodeInfoDao {
/** /**
* / * /
* *
* @param tableName * @param tableName
* *
* @return : * @return :
*/ */
@Select("SELECT code, name FROM ${tableName}") @Select("SELECT code, name FROM ${tableName}")
public List<EncodedInfoEntity> getAllEntityInfo( public List<EncodedInfoEntity> getAllEntityInfo(
@Param("tableName") String tableName); @Param("tableName") String tableName);
/** /**
* / * /
* *
* @param code * @param code
* *
* @param tableName * @param tableName
* *
* @return * @return
*/ */
@Select("SELECT name FROM ${tableName} WHERE code = #{code}") @Select("SELECT name FROM ${tableName} WHERE code = #{code}")
public String getEncodeNameByCode(@Param("code") String code, public String getEncodeNameByCode(@Param("code") String code,
@Param("tableName") String tableName); @Param("tableName") String tableName);
/** /**
* / * /
* *
* @param name * @param name
* *
* @param tableName * @param tableName
* *
* @return * @return
*/ */
@Select("SELECT code FROM ${tableName} WHERE name = #{name}") @Select("SELECT code FROM ${tableName} WHERE name = #{name}")
public List<String> getEncodeCodeByName(@Param("name") String name, public List<String> getEncodeCodeByName(@Param("name") String name,
@Param("tableName") String tableName); @Param("tableName") String tableName);
/** /**
* / * /
* *
* @param code * @param code
* *
* @param tableName * @param tableName
* *
* @return * @return
*/ */
@Update("UPDATE ${tableName} SET name = #{name} WHERE code = #{code}") @Update("UPDATE ${tableName} SET name = #{name} WHERE code = #{code}")
public int updateEncodeNameByCode(@Param("code") String code, public int updateEncodeNameByCode(@Param("code") String code,
@Param("name") String name, @Param("tableName") String tableName); @Param("name") String name, @Param("tableName") String tableName);
/** /**
* / * /
* *
* @param efe * @param efe
* *
* @param tableName * @param tableName
* *
* @return * @return
*/ */
@Insert("INSERT INTO ${tableName} (code, name) VALUES (#{efe.code}, #{efe.name})") @Insert("INSERT INTO ${tableName} (code, name) VALUES (#{efe.code}, #{efe.name})")
public int insertEncodeEntity(@Param("efe") EncodedInfoEntity efe, public int insertEncodeEntity(@Param("efe") EncodedInfoEntity efe,
@Param("tableName") String tableName); @Param("tableName") String tableName);
/** /**
* / * /
* *
* @param code * @param code
* *
* @param tableName * @param tableName
* *
* @return * @return
*/ */
@Delete("DELETE FROM ${tableName} WHERE code = #{code}") @Delete("DELETE FROM ${tableName} WHERE code = #{code}")
public int deleteEncodeByCode(@Param("code") String code, public int deleteEncodeByCode(@Param("code") String code,
@Param("tableName") String tableName); @Param("tableName") String tableName);
} }

@ -1,39 +1,39 @@
package com.platform.dao; package com.platform.dao;
import java.util.List; import java.util.List;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import com.platform.entities.GatherOracleInfo; import com.platform.entities.GatherOracleInfo;
@Repository(value = "gatherOracleDao") @Repository(value = "gatherOracleDao")
public interface GatherOracleDao { public interface GatherOracleDao {
/** /**
* @return oracle * @return oracle
* @throws Exception * @throws Exception
*/ */
public List<GatherOracleInfo> selectAllOracle() throws Exception; public List<GatherOracleInfo> selectAllOracle() throws Exception;
/** /**
* @param id * @param id
* @return * @return
* @throws Exception * @throws Exception
*/ */
public int deleteOracleById(int id) throws Exception; public int deleteOracleById(int id) throws Exception;
/** /**
* @param oracle * @param oracle
* @return * @return
* @throws Exception * @throws Exception
*/ */
public int insertOracle(GatherOracleInfo oracle) throws Exception; public int insertOracle(GatherOracleInfo oracle) throws Exception;
/** /**
* @param oracle * @param oracle
* @return * @return
* @throws Exception * @throws Exception
*/ */
public int updateOracleById(GatherOracleInfo oracle) throws Exception; public int updateOracleById(GatherOracleInfo oracle) 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;
/**
* @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;
}

@ -1,48 +1,48 @@
package com.platform.entities; package com.platform.entities;
import java.util.Date; import java.util.Date;
public enum BasedType { public enum BasedType {
STRING("java.lang.String", String.class), INTEGER("java.lang.Integer", STRING("java.lang.String", String.class), INTEGER("java.lang.Integer",
Integer.class), SHORT("java.lang.Short", Short.class), LONG( Integer.class), SHORT("java.lang.Short", Short.class), LONG(
"java.lang.Long", Long.class), DATE("java.util.Date", Date.class); "java.lang.Long", Long.class), DATE("java.util.Date", Date.class);
private String type; private String type;
private Class<?> clazz; private Class<?> clazz;
private BasedType(String type, Class<?> clazz) { private BasedType(String type, Class<?> clazz) {
this.type = type; this.type = type;
this.clazz = clazz; this.clazz = clazz;
} }
public static Class<?> getTypeClass(String type) { public static Class<?> getTypeClass(String type) {
for (BasedType bt : BasedType.values()) { for (BasedType bt : BasedType.values()) {
if (bt.equals(type)) if (bt.equals(type))
return bt.clazz; return bt.clazz;
} }
return null; return null;
} }
public String getType() { public String getType() {
return type; return type;
} }
public void setType(String type) { public void setType(String type) {
this.type = type; this.type = type;
} }
public Class<?> getClazz() { public Class<?> getClazz() {
return clazz; return clazz;
} }
public void setClazz(Class<?> clazz) { public void setClazz(Class<?> clazz) {
this.clazz = clazz; this.clazz = clazz;
} }
@Override @Override
public String toString() { public String toString() {
return this.type; return this.type;
} }
} }

@ -1,186 +1,269 @@
package com.platform.entities; package com.platform.entities;
/** /**
* *
* *
* @author wuming * @author wuming
* *
*/ */
public class DataInfoEntity { public class DataInfoEntity {
private int id; private int id;
private String regionalismCode; // 行政区划编码 private String regionalismCode; // 行政区划编码
private String cityName; // 市 private String cityName; // 市
private String districtName; // 区县 private String districtName; // 区县
private int systemCode; // 系统编码 private int systemCode; // 系统编码
private String systemName; // 系统名称 private String systemName; // 系统名称
private String dataType; // 数据类型:财政\社保\... private String dataType; // 数据类型:财政\社保\...
private int dataVersion; // 数据版本 private int dataVersion; // 数据版本
private String submittedBatch; // 上报批次 private String submittedBatch; // 上报批次
private String dataPath; // 数据路径 private String dataPath; // 数据路径
private String collectingTime; // 采集时间 private String collectingTime; // 采集时间
private String collectorContacts; // 采集人的联系 private String collectorContacts; // 采集人的联系
private String charset; // 数据的字符编码 private String charset; // 数据的字符编码
private String collectorName; // 采集人姓名 private String collectorName; // 采集人姓名
private String year; // 数据年度 private String year; // 数据年度
public DataInfoEntity() { /** 是否抽取 */
} private int extractStatus;
/** 数据年度起始 */
public DataInfoEntity(int id, String regionalismCode, String cityName, private String startYear;
String districtName, int systemCode, String systemName, /** 数据年度结束 */
String dataType, int dataVersion, String submittedBatch, private String endYear;
String dataPath, String collectingTime, String collectorContacts,
String charset, String collectorName, String year) { /** volume的ip */
super(); private String volumeIp;
this.id = id; /** volume的path */
this.regionalismCode = regionalismCode; private String volumePath;
this.cityName = cityName;
this.districtName = districtName; public DataInfoEntity() {
this.systemCode = systemCode; }
this.systemName = systemName;
this.dataType = dataType; public DataInfoEntity(int id, String regionalismCode, String cityName,
this.dataVersion = dataVersion; String districtName, int systemCode, String systemName,
this.submittedBatch = submittedBatch; String dataType, int dataVersion, String submittedBatch,
this.dataPath = dataPath; String dataPath, String collectingTime, String collectorContacts,
this.collectingTime = collectingTime; String charset, String collectorName, String year) {
this.collectorContacts = collectorContacts; super();
this.charset = charset; this.id = id;
this.collectorName = collectorName; this.regionalismCode = regionalismCode;
this.year = year; this.cityName = cityName;
} this.districtName = districtName;
this.systemCode = systemCode;
public int getId() { this.systemName = systemName;
return id; this.dataType = dataType;
} this.dataVersion = dataVersion;
this.submittedBatch = submittedBatch;
public void setId(int id) { this.dataPath = dataPath;
this.id = id; this.collectingTime = collectingTime;
} this.collectorContacts = collectorContacts;
this.charset = charset;
public String getRegionalismCode() { this.collectorName = collectorName;
return regionalismCode; this.year = year;
} }
public void setRegionalismCode(String regionalismCode) { public int getId() {
this.regionalismCode = regionalismCode; return id;
} }
public String getCityName() { public void setId(int id) {
return cityName; this.id = id;
} }
public void setCityName(String cityName) { public String getRegionalismCode() {
this.cityName = cityName; return regionalismCode;
} }
public String getDistrictName() { public void setRegionalismCode(String regionalismCode) {
return districtName; this.regionalismCode = regionalismCode;
} }
public void setDistrictName(String districtName) { public String getCityName() {
this.districtName = districtName; return cityName;
} }
public int getSystemCode() { public void setCityName(String cityName) {
return systemCode; this.cityName = cityName;
} }
public void setSystemCode(int systemCode) { public String getDistrictName() {
this.systemCode = systemCode; return districtName;
} }
public String getSystemName() { public void setDistrictName(String districtName) {
return systemName; this.districtName = districtName;
} }
public void setSystemName(String systemName) { public int getSystemCode() {
this.systemName = systemName; return systemCode;
} }
public String getDataType() { public void setSystemCode(int systemCode) {
return dataType; this.systemCode = systemCode;
} }
public void setDataType(String dataType) { public String getSystemName() {
this.dataType = dataType; return systemName;
} }
public int getDataVersion() { public void setSystemName(String systemName) {
return dataVersion; this.systemName = systemName;
} }
public void setDataVersion(int dataVersion) { public String getDataType() {
this.dataVersion = dataVersion; return dataType;
} }
public String getSubmittedBatch() { public void setDataType(String dataType) {
return submittedBatch; this.dataType = dataType;
} }
public void setSubmittedBatch(String submittedBatch) { public int getDataVersion() {
this.submittedBatch = submittedBatch; return dataVersion;
} }
public String getDataPath() { public void setDataVersion(int dataVersion) {
return dataPath; this.dataVersion = dataVersion;
} }
public void setDataPath(String dataPath) { public String getSubmittedBatch() {
this.dataPath = dataPath; return submittedBatch;
} }
public String getCollectingTime() { public void setSubmittedBatch(String submittedBatch) {
return collectingTime; this.submittedBatch = submittedBatch;
} }
public void setCollectingTime(String collectingTime) { public String getDataPath() {
this.collectingTime = collectingTime; return dataPath;
} }
public String getCollectorContacts() { public void setDataPath(String dataPath) {
return collectorContacts; this.dataPath = dataPath;
} }
public void setCollectorContacts(String collectorContacts) { public String getCollectingTime() {
this.collectorContacts = collectorContacts; return collectingTime;
} }
public String getCharset() { public void setCollectingTime(String collectingTime) {
return charset; this.collectingTime = collectingTime;
} }
public void setCharset(String charset) { public String getCollectorContacts() {
this.charset = charset; return collectorContacts;
} }
public String getCollectorName() { public void setCollectorContacts(String collectorContacts) {
return collectorName; this.collectorContacts = collectorContacts;
} }
public void setCollectorName(String collectorName) { public String getCharset() {
this.collectorName = collectorName; return charset;
} }
public String getYear() { public void setCharset(String charset) {
return year; this.charset = charset;
} }
public void setYear(String year) { public String getCollectorName() {
this.year = year; return collectorName;
} }
@Override public void setCollectorName(String collectorName) {
public String toString() { this.collectorName = collectorName;
return "id=" + this.id + " ,regionalismCode=" + this.regionalismCode }
+ " ,cityName=" + this.cityName + " ,districtName="
+ this.districtName + " ,systemCode=" + this.systemCode public String getYear() {
+ " ,systemName" + this.systemName + " ,dataType=" return year;
+ this.dataType + " ,dataVersion=" + this.dataVersion }
+ " ,submittedBatch=" + this.submittedBatch + " ,dataPath="
+ this.dataPath + " ,collectingTime=" + this.collectingTime public void setYear(String year) {
+ " ,collectorContacts=" + this.collectorContacts this.year = year;
+ " ,charset=" + this.charset + " ,collectorName=" }
+ this.collectorName + " ,year=" + this.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
+ " ,cityName=" + this.cityName + " ,districtName="
+ this.districtName + " ,systemCode=" + this.systemCode
+ " ,systemName" + this.systemName + " ,dataType="
+ this.dataType + " ,dataVersion=" + this.dataVersion
+ " ,submittedBatch=" + this.submittedBatch + " ,dataPath="
+ this.dataPath + " ,collectingTime=" + this.collectingTime
+ " ,collectorContacts=" + this.collectorContacts
+ " ,charset=" + this.charset + " ,collectorName="
+ this.collectorName + " ,year=" + this.year + " startYear="
+this.startYear +" endYear="+this.endYear;
}
}

@ -1,73 +1,124 @@
package com.platform.entities; package com.platform.entities;
public class DataInfoEntityMoveTmp extends DataInfoEntity { public class DataInfoEntityMoveTmp extends DataInfoEntity {
private String dstPath; private String dstPath;
private String completeStatus; private String completeStatus;
private int rate; private int rate;
private String lastTime; // 采集时间 /**
*
public DataInfoEntityMoveTmp() { */
// TODO Auto-generated constructor stub private String lastTime;
}
private String dstVolumeIp;
/**
* @return the dstPath private String dstVolumePath;
*/
public String getDstPath() { private int fkid;
return dstPath;
} public DataInfoEntityMoveTmp() {
// TODO Auto-generated constructor stub
/** }
* @param dstPath the dstPath to set
*/ /**
public void setDstPath(String dstPath) { * @return the dstPath
this.dstPath = dstPath; */
} public String getDstPath() {
return dstPath;
/** }
* @return the completeStatus
*/ /**
public String getCompleteStatus() { * @param dstPath the dstPath to set
return completeStatus; */
} public void setDstPath(String dstPath) {
this.dstPath = dstPath;
/** }
* @param completeStatus the completeStatus to set
*/ /**
public void setCompleteStatus(String completeStatus) { * @return the completeStatus
this.completeStatus = completeStatus; */
} public String getCompleteStatus() {
return completeStatus;
/** }
* @return the rate
*/ /**
public int getRate() { * @param completeStatus the completeStatus to set
return rate; */
} public void setCompleteStatus(String completeStatus) {
this.completeStatus = completeStatus;
/** }
* @param rate the rate to set
*/ /**
public void setRate(int rate) { * @return the rate
this.rate = rate; */
} public int getRate() {
return rate;
/** }
* @return the lastTime
*/ /**
public String getLastTime() { * @param rate the rate to set
return lastTime; */
} public void setRate(int rate) {
this.rate = rate;
/** }
* @param lastTime the lastTime to set
*/ /**
public void setLastTime(String lastTime) { * @return the lastTime
this.lastTime = lastTime; */
} public String getLastTime() {
return lastTime;
} }
/**
* @param lastTime the lastTime to set
*/
public void setLastTime(String lastTime) {
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;
}
}

@ -1,41 +1,41 @@
package com.platform.entities; package com.platform.entities;
/** /**
* *
* *
* / * /
* @author wuming * @author wuming
* *
*/ */
public class EncodedInfoEntity { public class EncodedInfoEntity {
private String name; //名称 private String name; //名称
private String code; //编码 private String code; //编码
public EncodedInfoEntity() {} public EncodedInfoEntity() {}
public EncodedInfoEntity(String name, String code) { public EncodedInfoEntity(String name, String code) {
this.name = name; this.name = name;
this.code = code; this.code = code;
} }
public String getName() { public String getName() {
return name; return name;
} }
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
public String getCode() { public String getCode() {
return code; return code;
} }
public void setCode(String code) { public void setCode(String code) {
this.code = code; this.code = code;
} }
@Override @Override
public String toString(){ public String toString(){
return "code=" + this.code + ", name=" + this.name; return "code=" + this.code + ", name=" + this.name;
} }
} }

@ -1,65 +1,65 @@
package com.platform.entities; package com.platform.entities;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class FolderNode { public class FolderNode {
private String name; private String name;
private int isFolder; // 1 is file and other integer is folder show children number private int isFolder; // 1 is file and other integer is folder show children number
private String path; private String path;
private List<FolderNode> childNodes = new ArrayList<FolderNode>(); private List<FolderNode> childNodes = new ArrayList<FolderNode>();
public FolderNode() { public FolderNode() {
// TODO Auto-generated constructor stub // TODO Auto-generated constructor stub
} }
public FolderNode(String name) { public FolderNode(String name) {
this.name = name; this.name = name;
} }
public FolderNode(String name, int isFolder) { public FolderNode(String name, int isFolder) {
this.name = name; this.name = name;
this.isFolder = isFolder; this.isFolder = isFolder;
} }
public String getName() { public String getName() {
return name; return name;
} }
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
/** /**
* @return the isFolder * @return the isFolder
*/ */
public int getIsFolder() { public int getIsFolder() {
return isFolder; return isFolder;
} }
/** /**
* @param isFolder the isFolder to set * @param isFolder the isFolder to set
*/ */
public void setIsFolder(int isFolder) { public void setIsFolder(int isFolder) {
this.isFolder = isFolder; this.isFolder = isFolder;
} }
public String getPath() { public String getPath() {
return path; return path;
} }
public void setPath(String path) { public void setPath(String path) {
this.path = path; this.path = path;
} }
public List<FolderNode> getChildNodes() { public List<FolderNode> getChildNodes() {
return childNodes; return childNodes;
} }
public void setChildNodes(List<FolderNode> childNodes) { public void setChildNodes(List<FolderNode> childNodes) {
this.childNodes = childNodes; this.childNodes = childNodes;
} }
} }

@ -1,82 +1,82 @@
package com.platform.entities; package com.platform.entities;
import com.platform.entities.OracleConnectorParams; import com.platform.entities.OracleConnectorParams;
public class GatherOracleInfo extends OracleConnectorParams { public class GatherOracleInfo extends OracleConnectorParams {
private String tableName; private String tableName;
private String suffix; private String suffix;
private int id; private int id;
private String remove; private String remove;
/** /**
* 0: 1 2使 3 * 0: 1 2使 3
*/ */
private int status; private int status;
public GatherOracleInfo() { public GatherOracleInfo() {
super(); super();
} }
public GatherOracleInfo(String port, String ip, String name, String user, public GatherOracleInfo(String port, String ip, String name, String user,
String password, String database) { String password, String database) {
super(port, ip, name, user, password, database); super(port, ip, name, user, password, database);
// TODO Auto-generated constructor stub // TODO Auto-generated constructor stub
} }
public GatherOracleInfo(String port, String ip, String name, String user, public GatherOracleInfo(String port, String ip, String name, String user,
String password, String database, int _id, String tableName, String suffix, int status) { String password, String database, int _id, String tableName, String suffix, int status) {
super(port, ip, name, user, password, database); super(port, ip, name, user, password, database);
this.tableName = tableName; this.tableName = tableName;
this.suffix = suffix; this.suffix = suffix;
this.id=_id; this.id=_id;
this.status = status; this.status = status;
} }
public String getTableName() { public String getTableName() {
return tableName; return tableName;
} }
public void setTableName(String tableName) { public void setTableName(String tableName) {
this.tableName = tableName; this.tableName = tableName;
} }
public String getSuffix() { public String getSuffix() {
return suffix; return suffix;
} }
public void setSuffix(String suffix) { public void setSuffix(String suffix) {
this.suffix = suffix; this.suffix = suffix;
} }
public int getId() { public int getId() {
return id; return id;
} }
public void setId(int id) { public void setId(int id) {
this.id = id; this.id = id;
} }
public int getStatus() { public int getStatus() {
return status; return status;
} }
public void setStatus(int status) { public void setStatus(int status) {
this.status = status; this.status = status;
} }
public String getRemove() { public String getRemove() {
return remove; return remove;
} }
public void setRemove(String remove) { public void setRemove(String remove) {
this.remove = remove; this.remove = remove;
} }
} }

@ -1,77 +1,77 @@
/** /**
* : GfsPathModel.java * : GfsPathModel.java
* : </> * : </>
* : <> * : <>
* @author chen * @author chen
* : <> * : <>
* 201698 * 201698
* <> * <>
*/ */
package com.platform.entities; package com.platform.entities;
import java.util.List; import java.util.List;
/** /**
* <> * <>
* <> * <>
* @author chen * @author chen
* @version [201698] * @version [201698]
* @see [/] * @see [/]
* @since [/] * @since [/]
*/ */
public class GfsFolderEntity { public class GfsFolderEntity {
/** 当前路径 */ /** 当前路径 */
private String path; private String path;
/** 当前路径 */ /** 当前路径 */
private String name; private String name;
/** 子目录 */ /** 子目录 */
private List<GfsFolderEntity> children; private List<GfsFolderEntity> children;
/** /**
* @return the path * @return the path
*/ */
public String getPath() { public String getPath() {
return path; return path;
} }
/** /**
* @param path the path to set * @param path the path to set
*/ */
public void setPath(String path) { public void setPath(String path) {
this.path = path; this.path = path;
} }
/** /**
* @return the name * @return the name
*/ */
public String getName() { public String getName() {
return name; return name;
} }
/** /**
* @param name the name to set * @param name the name to set
*/ */
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
/** /**
* @return the children * @return the children
*/ */
public List<GfsFolderEntity> getChildren() { public List<GfsFolderEntity> getChildren() {
return children; return children;
} }
/** /**
* @param children the children to set * @param children the children to set
*/ */
public void setChildren(List<GfsFolderEntity> children) { public void setChildren(List<GfsFolderEntity> children) {
this.children = children; this.children = children;
} }
} }

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

@ -1,124 +1,124 @@
package com.platform.entities; package com.platform.entities;
public class PagerOptions { public class PagerOptions {
private Integer currentPageNum; //当前页码 private Integer currentPageNum; //当前页码
private String dataType; //数据类型 private String dataType; //数据类型
private String submittedBatch; //数据批次 private String submittedBatch; //数据批次
private String cityName; //城市名称 private String cityName; //城市名称
private String districtName; //区县名 private String districtName; //区县名
private Integer dataVersion; //数据版本 private Integer dataVersion; //数据版本
private String systemName; //系统名称 private String systemName; //系统名称
private String dataYear; // 数据年度 private String dataYear; // 数据年度
private Integer limit; //一次查询返回记录条数 private Integer limit; //一次查询返回记录条数
private Integer offset; // 查询偏移量起始id private Integer offset; // 查询偏移量起始id
private Integer totalLimit; //当前页前面已有多少条数据 private Integer totalLimit; //当前页前面已有多少条数据
private Integer priorTableSize; //前一次操作一页显示的数据条数 private Integer priorTableSize; //前一次操作一页显示的数据条数
public Integer getCurrentPageNum() { public Integer getCurrentPageNum() {
return currentPageNum; return currentPageNum;
} }
public void setCurrentPageNum(Integer currentPageNum) { public void setCurrentPageNum(Integer currentPageNum) {
this.currentPageNum = currentPageNum; this.currentPageNum = currentPageNum;
} }
public String getDataType() { public String getDataType() {
return dataType; return dataType;
} }
public void setDataType(String dataType) { public void setDataType(String dataType) {
this.dataType = dataType; this.dataType = dataType;
} }
public String getSubmittedBatch() { public String getSubmittedBatch() {
return submittedBatch; return submittedBatch;
} }
public void setSubmittedBatch(String submittedBatch) { public void setSubmittedBatch(String submittedBatch) {
this.submittedBatch = submittedBatch; this.submittedBatch = submittedBatch;
} }
public String getCityName() { public String getCityName() {
return cityName; return cityName;
} }
public void setCityName(String cityName) { public void setCityName(String cityName) {
this.cityName = cityName; this.cityName = cityName;
} }
public String getDistrictName() { public String getDistrictName() {
return districtName; return districtName;
} }
public void setDistrictName(String districtName) { public void setDistrictName(String districtName) {
this.districtName = districtName; this.districtName = districtName;
} }
public Integer getDataVersion() { public Integer getDataVersion() {
return dataVersion; return dataVersion;
} }
public void setDataVersion(Integer dataVersion) { public void setDataVersion(Integer dataVersion) {
this.dataVersion = dataVersion; this.dataVersion = dataVersion;
} }
public String getSystemName() { public String getSystemName() {
return systemName; return systemName;
} }
public void setSystemName(String systemName) { public void setSystemName(String systemName) {
this.systemName = systemName; this.systemName = systemName;
} }
public String getDataYear() { public String getDataYear() {
return dataYear; return dataYear;
} }
public void setDataYear(String dataYear) { public void setDataYear(String dataYear) {
this.dataYear = dataYear; this.dataYear = dataYear;
} }
public Integer getLimit() { public Integer getLimit() {
return limit; return limit;
} }
public void setLimit(Integer limit) { public void setLimit(Integer limit) {
this.limit = limit; this.limit = limit;
} }
public Integer getOffset() { public Integer getOffset() {
return offset; return offset;
} }
public void setOffset(Integer offset) { public void setOffset(Integer offset) {
this.offset = offset; this.offset = offset;
} }
public Integer getTotalLimit() { public Integer getTotalLimit() {
return totalLimit; return totalLimit;
} }
public void setTotalLimit(Integer totalLimit) { public void setTotalLimit(Integer totalLimit) {
this.totalLimit = totalLimit; this.totalLimit = totalLimit;
} }
public Integer getPriorTableSize() { public Integer getPriorTableSize() {
return priorTableSize; return priorTableSize;
} }
public void setPriorTableSize(Integer priorTableSize) { public void setPriorTableSize(Integer priorTableSize) {
this.priorTableSize = priorTableSize; this.priorTableSize = priorTableSize;
} }
} }

@ -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;
}
}

@ -1,44 +1,44 @@
package com.platform.entities; package com.platform.entities;
public class SimpleConfigParamsBean { public class SimpleConfigParamsBean {
private String masterUrl; private String masterUrl;
private String oracleUserName; private String oracleUserName;
private String oraclePassword; private String oraclePassword;
private String oracleDBName; private String oracleDBName;
public String getMasterUrl() { public String getMasterUrl() {
return masterUrl; return masterUrl;
} }
public void setMasterUrl(String masterUrl) { public void setMasterUrl(String masterUrl) {
this.masterUrl = masterUrl; this.masterUrl = masterUrl;
} }
public String getOracleUserName() { public String getOracleUserName() {
return oracleUserName; return oracleUserName;
} }
public void setOracleUserName(String oracleUserName) { public void setOracleUserName(String oracleUserName) {
this.oracleUserName = oracleUserName; this.oracleUserName = oracleUserName;
} }
public String getOraclePassword() { public String getOraclePassword() {
return oraclePassword; return oraclePassword;
} }
public void setOraclePassword(String oraclePassword) { public void setOraclePassword(String oraclePassword) {
this.oraclePassword = oraclePassword; this.oraclePassword = oraclePassword;
} }
public String getOracleDBName() { public String getOracleDBName() {
return oracleDBName; return oracleDBName;
} }
public void setOracleDBName(String oracleDBName) { public void setOracleDBName(String oracleDBName) {
this.oracleDBName = oracleDBName; this.oracleDBName = oracleDBName;
} }
} }

@ -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;
}
}

@ -1,129 +1,129 @@
/** /**
* : VolumeEntity.java * : VolumeEntity.java
* : </> * : </>
* : <> * : <>
* @author chen * @author chen
* : <> * : <>
* 201699 * 201699
* <> * <>
*/ */
package com.platform.entities; package com.platform.entities;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
* <> gfs volume * <> gfs volume
* <> * <>
* @author chen * @author chen
* @version [201699] * @version [201699]
* @see [/] * @see [/]
* @since [/] * @since [/]
*/ */
public class VolumeEntity { public class VolumeEntity {
/** volume总大小 */ /** volume总大小 */
private double allSize; private double allSize;
/** volume已使用大小 */ /** volume已使用大小 */
private double usedSize; private double usedSize;
/** volume名称 */ /** volume名称 */
private String name; private String name;
/** 挂载点 */ /** 挂载点 */
private String path; private String path;
/** volume树形目录 */ /** volume树形目录 */
private List<FolderNode> folder = new ArrayList<FolderNode>(); private List<FolderNode> folder = new ArrayList<FolderNode>();
/** volume的 块 */ /** volume的 块 */
private List<Brick> brick = new ArrayList<Brick>(); private List<Brick> brick = new ArrayList<Brick>();
/** /**
* @return the allSize * @return the allSize
*/ */
public double getAllSize() { public double getAllSize() {
return allSize; return allSize;
} }
/** /**
* @param allSize the allSize to set * @param allSize the allSize to set
*/ */
public void setAllSize(double allSize) { public void setAllSize(double allSize) {
this.allSize = allSize; this.allSize = allSize;
} }
/** /**
* @return the usedSize * @return the usedSize
*/ */
public double getUsedSize() { public double getUsedSize() {
return usedSize; return usedSize;
} }
/** /**
* @param usedSize the usedSize to set * @param usedSize the usedSize to set
*/ */
public void setUsedSize(double usedSize) { public void setUsedSize(double usedSize) {
this.usedSize = usedSize; this.usedSize = usedSize;
} }
/** /**
* @return the name * @return the name
*/ */
public String getName() { public String getName() {
return name; return name;
} }
/** /**
* @param name the name to set * @param name the name to set
*/ */
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
/** /**
* @return the path * @return the path
*/ */
public String getPath() { public String getPath() {
return path; return path;
} }
/** /**
* @param path the path to set * @param path the path to set
*/ */
public void setPath(String path) { public void setPath(String path) {
this.path = path; this.path = path;
} }
/** /**
* @return the folder * @return the folder
*/ */
public List<FolderNode> getFolder() { public List<FolderNode> getFolder() {
return folder; return folder;
} }
/** /**
* @param folder the folder to set * @param folder the folder to set
*/ */
public void setFolder(List<FolderNode> folder) { public void setFolder(List<FolderNode> folder) {
this.folder = folder; this.folder = folder;
} }
/** /**
* @return the brick * @return the brick
*/ */
public List<Brick> getBrick() { public List<Brick> getBrick() {
return brick; return brick;
} }
/** /**
* @param brick the brick to set * @param brick the brick to set
*/ */
public void setBrick(List<Brick> brick) { public void setBrick(List<Brick> brick) {
this.brick = brick; this.brick = brick;
} }
} }

@ -1,106 +1,106 @@
package com.platform.glusterfs; package com.platform.glusterfs;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.aspectj.weaver.ast.And; import org.aspectj.weaver.ast.And;
import com.mysql.jdbc.log.Log; import com.mysql.jdbc.log.Log;
import com.platform.utils.Constant; import com.platform.utils.Constant;
public class CheckoutMD5 { public class CheckoutMD5 {
public static Logger log = Logger.getLogger(CheckoutMD5.class); public static Logger log = Logger.getLogger(CheckoutMD5.class);
String sourcePath; String sourcePath;
String destPath; String destPath;
String dataName; String dataName;
// String cmd_crateSourceMD5File="find "+sourcePath+dataName+"/app/ -type f // String cmd_crateSourceMD5File="find "+sourcePath+dataName+"/app/ -type f
// -print0 | xargs -0 md5sum | sort >"+deskPath+dataName+"_md5.txt"; // -print0 | xargs -0 md5sum | sort >"+deskPath+dataName+"_md5.txt";
String cmd_getSourceMD5File; String cmd_getSourceMD5File;
// String cmd_crateDestMD5File="find "+destPath+dataName+"/app/ -type f // String cmd_crateDestMD5File="find "+destPath+dataName+"/app/ -type f
// -print0 | xargs -0 md5sum | sort >"+deskPath+dataName+"_md5.txt"; // -print0 | xargs -0 md5sum | sort >"+deskPath+dataName+"_md5.txt";
String cmd_getDestMD5File; String cmd_getDestMD5File;
Map<String, String> source_md5 = new HashMap<String, String>(); Map<String, String> source_md5 = new HashMap<String, String>();
Map<String, String> dest_md5 = new HashMap<String, String>(); Map<String, String> dest_md5 = new HashMap<String, String>();
public CheckoutMD5() { public CheckoutMD5() {
// TODO Auto-generated constructor stub // TODO Auto-generated constructor stub
} }
public CheckoutMD5(String sourcePath, String destPath, String dataName) { public CheckoutMD5(String sourcePath, String destPath, String dataName) {
// TODO Auto-generated constructor stub // TODO Auto-generated constructor stub
this.sourcePath = sourcePath; this.sourcePath = sourcePath;
this.destPath = destPath; this.destPath = destPath;
this.dataName = dataName; this.dataName = dataName;
cmd_getSourceMD5File = "find " + sourcePath + dataName + "/app/ -type f -print0 | xargs -0 md5sum | sort "; cmd_getSourceMD5File = "find " + sourcePath + dataName + "/app/ -type f -print0 | xargs -0 md5sum | sort ";
cmd_getDestMD5File = "find " + destPath + dataName + "/app/ -type f -print0 | xargs -0 md5sum | sort "; cmd_getDestMD5File = "find " + destPath + dataName + "/app/ -type f -print0 | xargs -0 md5sum | sort ";
} }
/** /**
* sourcePathdestPath1 * sourcePathdestPath1
* 0MD5-1-2-3 * 0MD5-1-2-3
* *
* @param sourcePath * @param sourcePath
* @param destPath * @param destPath
* @return * @return
* @see [##] * @see [##]
*/ */
public int checkoutMD5Folder(String sourcePath, String destPath) { public int checkoutMD5Folder(String sourcePath, String destPath) {
log.info("start checkout md5 "+sourcePath+" and "+ destPath); log.info("start checkout md5 "+sourcePath+" and "+ destPath);
List<String> wrong_files = new ArrayList<String>(); List<String> wrong_files = new ArrayList<String>();
String source_cmd = "find " + sourcePath + " -type f -print0 | xargs -0 md5sum"; String source_cmd = "find " + sourcePath + " -type f -print0 | xargs -0 md5sum";
String dest_cmd = "find " + destPath + " -type f -print0 | xargs -0 md5sum"; String dest_cmd = "find " + destPath + " -type f -print0 | xargs -0 md5sum";
List<String> sourceReStrings = Constant.ganymedSSH.execCmdWaitAcquiescent(source_cmd); List<String> sourceReStrings = Constant.ganymedSSH.execCmdWaitAcquiescent(source_cmd);
if (sourceReStrings == null || sourceReStrings.size() == 0) { if (sourceReStrings == null || sourceReStrings.size() == 0) {
log.error("get " + sourcePath + " MD5 error!"); log.error("get " + sourcePath + " MD5 error!");
return -1; return -1;
} }
if(sourceReStrings.get(0).contains(Constant.noSuchFile)){ if(sourceReStrings.get(0).contains(Constant.noSuchFile)){
log.error(sourcePath+" is not exist!"); log.error(sourcePath+" is not exist!");
return -2; return -2;
} }
List<String> destReStrings = Constant.ganymedSSH.execCmdWaitAcquiescent(dest_cmd); List<String> destReStrings = Constant.ganymedSSH.execCmdWaitAcquiescent(dest_cmd);
if (destReStrings == null || destReStrings.size() == 0) { if (destReStrings == null || destReStrings.size() == 0) {
log.error("get " + destReStrings + " MD5 error!"); log.error("get " + destReStrings + " MD5 error!");
return -1; return -1;
} }
if(destReStrings.get(0).contains(Constant.noSuchFile)){ if(destReStrings.get(0).contains(Constant.noSuchFile)){
log.error(destPath+" is not exist!"); log.error(destPath+" is not exist!");
return -3; return -3;
} }
Map<String, String> source_md5 = new HashMap<String, String>(); Map<String, String> source_md5 = new HashMap<String, String>();
Map<String, String> dest_md5 = new HashMap<String, String>(); Map<String, String> dest_md5 = new HashMap<String, String>();
for (String line : sourceReStrings) { for (String line : sourceReStrings) {
String[] lines = line.split(" "); String[] lines = line.split(" ");
String key = lines[1].replace(sourcePath, "").trim(); String key = lines[1].replace(sourcePath, "").trim();
String value = lines[0].trim(); String value = lines[0].trim();
source_md5.put(key, value); source_md5.put(key, value);
} }
for (String line : destReStrings) { for (String line : destReStrings) {
String[] lines = line.split(" "); String[] lines = line.split(" ");
String key = lines[1].replace(destPath, "").trim(); String key = lines[1].replace(destPath, "").trim();
String value = lines[0].trim(); String value = lines[0].trim();
dest_md5.put(key, value); dest_md5.put(key, value);
} }
for (Map.Entry<String, String> mapEntry : source_md5.entrySet()) { for (Map.Entry<String, String> mapEntry : source_md5.entrySet()) {
if (!(dest_md5.containsKey(mapEntry.getKey()) if (!(dest_md5.containsKey(mapEntry.getKey())
&& dest_md5.get(mapEntry.getKey()).equals(mapEntry.getValue()))) { && dest_md5.get(mapEntry.getKey()).equals(mapEntry.getValue()))) {
log.info(sourcePath + " and " + destPath + " is not same!"); log.info(sourcePath + " and " + destPath + " is not same!");
return 0; return 0;
// System.out.println(mapEntry.getKey()); // System.out.println(mapEntry.getKey());
} }
} }
log.info(sourcePath + " and " + destPath + " is same!"); log.info(sourcePath + " and " + destPath + " is same!");
return 1; return 1;
} }
public static void main(String[] args) { public static void main(String[] args) {
CheckoutMD5 checkoutMD5 = new CheckoutMD5(); CheckoutMD5 checkoutMD5 = new CheckoutMD5();
System.out.println(checkoutMD5.checkoutMD5Folder("/home/v1_copy","/home/ubuntu")); System.out.println(checkoutMD5.checkoutMD5Folder("/home/v1_copy","/home/ubuntu"));
} }
} }

@ -1,124 +1,124 @@
package com.platform.glusterfs; package com.platform.glusterfs;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator; import org.apache.log4j.PropertyConfigurator;
import com.platform.utils.Constant; import com.platform.utils.Constant;
/** /**
* *
* @author liliy * @author liliy
* @version [2016912] * @version [2016912]
* @see [/] * @see [/]
* @since [/] * @since [/]
*/ */
public class ClusterInfo { public class ClusterInfo {
public static Logger log = Logger.getLogger(ClusterInfo.class); public static Logger log = Logger.getLogger(ClusterInfo.class);
/** /**
* *
* nullmapipip * nullmapipip
* ipPeerinCluster(Connected) * ipPeerinCluster(Connected)
* ipPeerinCluster(Disconnected) * ipPeerinCluster(Disconnected)
* @return * @return
* @see [##] * @see [##]
*/ */
public Map<String, String> showClusterInfo() { public Map<String, String> showClusterInfo() {
log.info("get cluster info"); log.info("get cluster info");
Map<String, String> peerIps = new HashMap<String, String>(); Map<String, String> peerIps = new HashMap<String, String>();
List<String> reStrings = Constant.ganymedSSH.execCmdWaitAcquiescent(Constant.glusterPeerStatus); List<String> reStrings = Constant.ganymedSSH.execCmdWaitAcquiescent(Constant.glusterPeerStatus);
if (reStrings == null) { if (reStrings == null) {
log.error("1101 command get result is null"); log.error("1101 command get result is null");
return null; return null;
} }
if (reStrings.size() == 0) { if (reStrings.size() == 0) {
log.error("1102 command get result is nothing"); log.error("1102 command get result is nothing");
return null; return null;
} }
if (!(reStrings.get(0).split(":")[0].contains("Number of Peers"))) { if (!(reStrings.get(0).split(":")[0].contains("Number of Peers"))) {
log.error("1103 get result string wrong"); log.error("1103 get result string wrong");
return null; return null;
} }
// System.out.print(reStrings.get(0)); // System.out.print(reStrings.get(0));
int flag = 0; int flag = 0;
String ipString = ""; String ipString = "";
String state = ""; String state = "";
for (Iterator it2 = reStrings.iterator(); it2.hasNext();) { for (Iterator it2 = reStrings.iterator(); it2.hasNext();) {
String line = (String) it2.next(); String line = (String) it2.next();
line=line.replaceAll(" +", " "); line=line.replaceAll(" +", " ");
String keyValue[] = line.split(":"); String keyValue[] = line.split(":");
if (keyValue[0].equals("Hostname")) { if (keyValue[0].equals("Hostname")) {
if (keyValue.length < 2) { if (keyValue.length < 2) {
log.error("1105 command get result is wrong"); log.error("1105 command get result is wrong");
continue; continue;
} }
ipString = keyValue[1].replaceAll(" ", ""); ipString = keyValue[1].replaceAll(" ", "");
flag = 1; flag = 1;
} else if (flag == 1 && keyValue[0].equals("State")) { } else if (flag == 1 && keyValue[0].equals("State")) {
if (keyValue.length < 2) { if (keyValue.length < 2) {
log.error("1106 command get result is wrong"); log.error("1106 command get result is wrong");
continue; continue;
} }
state = keyValue[1].replaceAll(" ", ""); state = keyValue[1].replaceAll(" ", "");
flag = 0; flag = 0;
peerIps.put(ipString, state); peerIps.put(ipString, state);
} }
} }
return peerIps; return peerIps;
} }
/** /**
* ipip * ipip
* ipnull * ipnull
* ipPeerinCluster(Connected) * ipPeerinCluster(Connected)
* ipPeerinCluster(Disconnected) * ipPeerinCluster(Disconnected)
* @param peerip * @param peerip
* @return * @return
* @see [##] * @see [##]
*/ */
public String getPeerStatus(String peerip){ public String getPeerStatus(String peerip){
Map<String, String> peerIps=showClusterInfo(); Map<String, String> peerIps=showClusterInfo();
if(peerIps==null || peerIps.size()==0){ if(peerIps==null || peerIps.size()==0){
return null; return null;
} }
if(peerip.equals(Constant.hostIp)){ if(peerip.equals(Constant.hostIp)){
return Constant.peerincluster_connected; return Constant.peerincluster_connected;
} }
if(!peerIps.containsKey(peerip)){ if(!peerIps.containsKey(peerip)){
return Constant.peerNotinCluster; return Constant.peerNotinCluster;
} }
return peerIps.get(peerip); return peerIps.get(peerip);
} }
public static void main(String[] args) { public static void main(String[] args) {
// PropertyConfigurator.configure("log4j.properties"); // PropertyConfigurator.configure("log4j.properties");
System.out.println(new ClusterInfo().showClusterInfo()); System.out.println(new ClusterInfo().showClusterInfo());
System.out.println(new ClusterInfo().getPeerStatus("192.168.0.116")); System.out.println(new ClusterInfo().getPeerStatus("192.168.0.116"));
} }
} }

@ -36,6 +36,38 @@ public class CopyData {
status = copyFolderFilesAnyway(sourceFolderName, destFolderName, fileName); status = copyFolderFilesAnyway(sourceFolderName, destFolderName, fileName);
return status; 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 * -1 :error; -2: the filename is not exists ;-3 :destFolderName ; 1: right
@ -100,7 +132,7 @@ public class CopyData {
createFolders("/aaa/vvv/ddd/www/rrrr"); createFolders("/aaa/vvv/ddd/www/rrrr");
} }
//@Test //@Test
public void testCopyFolderFiles() { public void testCopyFolderFiles() {

@ -1,125 +1,125 @@
package com.platform.glusterfs; package com.platform.glusterfs;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.junit.Test; import org.junit.Test;
import com.platform.entities.FolderNode; import com.platform.entities.FolderNode;
import com.platform.utils.Constant; import com.platform.utils.Constant;
import com.platform.utils.FileOperateHelper; import com.platform.utils.FileOperateHelper;
import com.platform.utils.GanymedSSH; import com.platform.utils.GanymedSSH;
/** /**
* <> GFS * <> GFS
* <> * <>
* @author chen * @author chen
* @version [201698] * @version [201698]
* @see [/] * @see [/]
* @since [/] * @since [/]
*/ */
public class GetTreeData { public class GetTreeData {
ShowData showData = new ShowData(); ShowData showData = new ShowData();
/** /**
* <> * <>
* <> * <>
* @param name * @param name
* @return * @return
* @see [##] * @see [##]
*/ */
public FolderNode getDatas(String name) { public FolderNode getDatas(String name) {
String names[]=name.split("/"); String names[]=name.split("/");
String only_name=names[names.length-1]; String only_name=names[names.length-1];
FolderNode fileNode = new FolderNode(only_name); FolderNode fileNode = new FolderNode(only_name);
fileNode.setPath(name); fileNode.setPath(name);
Map<String, String> files = showData.showFolderData(name); Map<String, String> files = showData.showFolderData(name);
if(files==null || files.size()==0){ if(files==null || files.size()==0){
return fileNode; return fileNode;
} }
fileNode.setIsFolder(files.size()); fileNode.setIsFolder(files.size());
List<FolderNode> list = new ArrayList<FolderNode>(); List<FolderNode> list = new ArrayList<FolderNode>();
fileNode.setChildNodes(list); fileNode.setChildNodes(list);
for (Map.Entry<String, String> entry : files.entrySet()) { for (Map.Entry<String, String> entry : files.entrySet()) {
if(entry.getKey().equals("app")){ if(entry.getKey().equals("app")){
continue; continue;
} }
int number = Integer.parseInt(entry.getValue()); int number = Integer.parseInt(entry.getValue());
if (number == 1) { if (number == 1) {
fileNode.getChildNodes().add(new FolderNode(entry.getKey(), number)); fileNode.getChildNodes().add(new FolderNode(entry.getKey(), number));
} }
if (number > 1) { if (number > 1) {
FolderNode temp=getDatas(name+"/"+entry.getKey()); FolderNode temp=getDatas(name+"/"+entry.getKey());
fileNode.getChildNodes().add(temp); fileNode.getChildNodes().add(temp);
} }
} }
return fileNode; return fileNode;
} }
/** /**
* <> * <>
* <> * <>
* @param name * @param name
* @return * @return
* @see [##] * @see [##]
*/ */
public FolderNode getDatasWithShell(String name) { public FolderNode getDatasWithShell(String name) {
if(name.endsWith("/")){ if(name.endsWith("/")){
name=name.substring(0, name.length()-1); name=name.substring(0, name.length()-1);
} }
// String names[]=name.split("/"); // String names[]=name.split("/");
// String only_name=names[names.length-1]; // String only_name=names[names.length-1];
FolderNode fileNode = new FolderNode(name); FolderNode fileNode = new FolderNode(name);
fileNode.setPath(name); fileNode.setPath(name);
// String shellComment= new FileOperateHelper().fileReaderAndendline(Constant.fileGetTreeData); // String shellComment= new FileOperateHelper().fileReaderAndendline(Constant.fileGetTreeData);
String shellComment= Constant.strGetTreeData; String shellComment= Constant.strGetTreeData;
String sh_path="/getTreedata.sh"; String sh_path="/getTreedata.sh";
String cmd="echo -e \""+shellComment+"\" > "+sh_path+" & chmod +x "+sh_path; String cmd="echo -e \""+shellComment+"\" > "+sh_path+" & chmod +x "+sh_path;
Constant.ganymedSSH.execCmdWaitAcquiescent(cmd); Constant.ganymedSSH.execCmdWaitAcquiescent(cmd);
// Map<String, String> files = showData.showFolderData(name); // Map<String, String> files = showData.showFolderData(name);
List<String> files=Constant.ganymedSSH.execCmdWaitAcquiescent(sh_path+" "+name); List<String> files=Constant.ganymedSSH.execCmdWaitAcquiescent(sh_path+" "+name);
if(files==null){ if(files==null){
return null; return null;
} }
if(files.size()==0){ if(files.size()==0){
return fileNode; return fileNode;
} }
for(String file:files){ for(String file:files){
} }
return fileNode; return fileNode;
} }
@Test @Test
public void test_getTreeData() { public void test_getTreeData() {
GetTreeData getTreeData=new GetTreeData(); GetTreeData getTreeData=new GetTreeData();
// FolderNode fileOrFolder=getTreeData.getDatas("/home/gfs_ftp_point"); // FolderNode fileOrFolder=getTreeData.getDatas("/home/gfs_ftp_point");
FolderNode fileOrFolder=getTreeData.getDatasWithShell("/home/gfs_ftp_point/"); FolderNode fileOrFolder=getTreeData.getDatasWithShell("/home/gfs_ftp_point/");
System.out.println(fileOrFolder); System.out.println(fileOrFolder);
} }
} }
/* /*
class FileOrFolder { class FileOrFolder {
String name; String name;
int isFolder; // 1 is file and other integer is folder show children number int isFolder; // 1 is file and other integer is folder show children number
List<FileOrFolder> children; List<FileOrFolder> children;
public FileOrFolder(String name) { public FileOrFolder(String name) {
// TODO Auto-generated constructor stub // TODO Auto-generated constructor stub
this.name = name; this.name = name;
} }
public FileOrFolder(String name, int isFolder) { public FileOrFolder(String name, int isFolder) {
// TODO Auto-generated constructor stub // TODO Auto-generated constructor stub
this.name = name; this.name = name;
this.isFolder = isFolder; this.isFolder = isFolder;
} }
} }
*/ */

@ -1,56 +1,56 @@
package com.platform.glusterfs; package com.platform.glusterfs;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator; import org.apache.log4j.PropertyConfigurator;
import org.junit.Test; import org.junit.Test;
import com.platform.utils.Constant; import com.platform.utils.Constant;
public class RemoveData { public class RemoveData {
public static Logger log = Logger.getLogger ( RemoveData.class); public static Logger log = Logger.getLogger ( RemoveData.class);
/** /**
* -1 :error; 0: the filename is not exists ; 1: right * -1 :error; 0: the filename is not exists ; 1: right
* @param folderName * @param folderName
* @param fileName * @param fileName
* @return * @return
*/ */
public int deleteFolder(String folderName){ public int deleteFolder(String folderName){
log.info("start delete "+folderName); log.info("start delete "+folderName);
ShowData showData=new ShowData(); ShowData showData=new ShowData();
Map<String,String> reStrings=showData.showFolderData(folderName); Map<String,String> reStrings=showData.showFolderData(folderName);
if(reStrings==null){ if(reStrings==null){
log.error("3301 "+folderName+" is not exists"); log.error("3301 "+folderName+" is not exists");
return -1; return -1;
} }
String command="rm -r "+folderName; String command="rm -r "+folderName;
// int status=runCommand.runCommand(command); // int status=runCommand.runCommand(command);
Constant.ganymedSSH.execCmdNoWaitAcquiescent(command); Constant.ganymedSSH.execCmdNoWaitAcquiescent(command);
log.info("delete "+folderName+" running"); log.info("delete "+folderName+" running");
return 1; return 1;
} }
@Test @Test
public void testDeleteFolderFiles() { public void testDeleteFolderFiles() {
PropertyConfigurator.configure("log4j.properties"); PropertyConfigurator.configure("log4j.properties");
deleteFolder("/home/ubuntu"); deleteFolder("/home/ubuntu");
} }
} }

@ -1,67 +1,67 @@
package com.platform.glusterfs; package com.platform.glusterfs;
import java.util.List; import java.util.List;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.hamcrest.core.Is; import org.hamcrest.core.Is;
import com.platform.utils.Constant; import com.platform.utils.Constant;
import com.platform.utils.Support; import com.platform.utils.Support;
public class SetCluster { public class SetCluster {
public static Logger log = Logger.getLogger ( SetCluster.class); public static Logger log = Logger.getLogger ( SetCluster.class);
/** /**
* *
* 1-1ip-2 0 * 1-1ip-2 0
* @param peerip * @param peerip
* @return * @return
* @see [##] * @see [##]
*/ */
public int probePeer(String peerip){ public int probePeer(String peerip){
if(!Support.checkIP(peerip)){ if(!Support.checkIP(peerip)){
log.error(peerip +"is illegal!" ); log.error(peerip +"is illegal!" );
return -1; return -1;
} }
String cmd="gluster peer probe "+peerip; String cmd="gluster peer probe "+peerip;
List<String> reStrings=Constant.ganymedSSH.execCmdWaitAcquiescent(cmd); List<String> reStrings=Constant.ganymedSSH.execCmdWaitAcquiescent(cmd);
if(reStrings==null || reStrings.size()==0){ if(reStrings==null || reStrings.size()==0){
log.error("detach error! "); log.error("detach error! ");
return -2; return -2;
} }
if(reStrings.contains(Constant.success)){ if(reStrings.contains(Constant.success)){
log.info("probe success!"); log.info("probe success!");
return 1; return 1;
} }
log.info("probe failed!"); log.info("probe failed!");
return 0; return 0;
} }
/** /**
* *
* 1-1ip-2 0 * 1-1ip-2 0
* @param peerip * @param peerip
* @return * @return
* @see [##] * @see [##]
*/ */
public int detachPeer(String peerip){ public int detachPeer(String peerip){
if(!Support.checkIP(peerip)){ if(!Support.checkIP(peerip)){
log.error(peerip +"is illegal!" ); log.error(peerip +"is illegal!" );
return -1; return -1;
} }
String cmd="gluster peer detach "+peerip; String cmd="gluster peer detach "+peerip;
List<String> reStrings=Constant.ganymedSSH.execCmdWaitAcquiescent(cmd); List<String> reStrings=Constant.ganymedSSH.execCmdWaitAcquiescent(cmd);
if(reStrings==null || reStrings.size()==0){ if(reStrings==null || reStrings.size()==0){
log.error("detach error! "); log.error("detach error! ");
return -2; return -2;
} }
if(reStrings.contains(Constant.success)){ if(reStrings.contains(Constant.success)){
log.info("detach success!"); log.info("detach success!");
return 1; return 1;
} }
log.info("detach failed!"); log.info("detach failed!");
return 0; return 0;
} }
} }

File diff suppressed because it is too large Load Diff

@ -1,131 +1,132 @@
package com.platform.glusterfs; package com.platform.glusterfs;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator; import org.apache.log4j.PropertyConfigurator;
import org.junit.Test; import org.junit.Test;
import com.platform.utils.Constant; import com.platform.utils.Constant;
public class ShowData { public class ShowData {
public static Logger log = Logger.getLogger ( ShowData.class); public static Logger log = Logger.getLogger ( ShowData.class);
/** /**
* get the data of volumeName Map<string s1,string s2> s1 is data name and s2 is type file or folder * get the data of volumeName Map<string s1,string s2> s1 is data name and s2 is type file or folder
* <> * <>
* @param volumeName * @param volumeName
* @return * @return
* @see [##] * @see [##]
*/ */
public Map<String,String> showVolumeFiles(String volumeName){ public Map<String,String> showVolumeFiles(String volumeName){
log.info("start show the data"); log.info("start show the data");
Map<String,String> data_type=new HashMap<String, String>(); Map<String,String> data_type=new HashMap<String, String>();
/** /**
* get mount point of volumeName * get mount point of volumeName
*/ */
String folderName=volumeName; String folderName=volumeName;
data_type=showFolderData(volumeName); data_type=showFolderData(volumeName);
return data_type; return data_type;
} }
/** /**
* get the data of folder name * get the data of folder name
* Map<String,String> is folder name and type 1 is file and others is folder * Map<String,String> is folder name and type 1 is file and others is folder
* @param FolderName * @param FolderName
* @return * @return
*/ */
public Map<String,String> showFolderData(String folderName){ public Map<String,String> showFolderData(String folderName){
log.info(" start get "+folderName+" data"); log.info(" start get "+folderName+" data");
Map<String,String> data_type=new HashMap<String, String>(); Map<String,String> data_type=new HashMap<String, String>();
String command="ls -l "+folderName; String command="ls -l "+folderName;
/* /*
RunCommand runCommand=new RunCommand(); <<<<<<< HEAD
List<String> reStrings=runCommand.runCommandWait(command); * 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){ List<String> reStrings = Constant.ganymedSSH.execCmdWaitAcquiescent(command);
log.error("2101 command get result is null"); if (reStrings == null) {
return null; log.error("2101 command get result is null");
} return null;
if(reStrings.size()==0){ }
log.info("2102 the folder is empty"); if(reStrings.size()==0){
return data_type; log.info("2102 the folder is empty");
} return data_type;
if(reStrings.get(0).contains("No such file or directory")){ }
log.info("2103 the "+folderName+" is not exists"); if(reStrings.get(0).contains("No such file or directory")){
return null; log.info("2103 the "+folderName+" is not exists");
} return null;
/** }
* remove first line total number /**
*/ * remove first line total number
reStrings.remove(0); */
reStrings.remove(0);
for(Iterator it2 = reStrings.iterator();it2.hasNext();){
String line=(String)it2.next(); for(Iterator it2 = reStrings.iterator();it2.hasNext();){
line=line.replaceAll(" +", " "); String line=(String)it2.next();
String keyValue[]=line.split(" "); line=line.replaceAll(" +", " ");
if(keyValue.length<9){ String keyValue[]=line.split(" ");
log.error("2104 "+line+" length is short"); if(keyValue.length<9){
continue; log.error("2104 "+line+" length is short");
} continue;
}
data_type.put(keyValue[8], keyValue[1]);
data_type.put(keyValue[8], keyValue[1]);
}
log.info(" get "+folderName+" data successed"); }
return data_type; log.info(" get "+folderName+" data successed");
} return data_type;
}
/**
* folder /**
* -2-1folderfolder * folder
* @param folderPath * -2-1folderfolder
* @return * @param folderPath
* @see [##] * @return
*/ * @see [##]
public long getFolderSize(String folderPath) { */
log.info("get " + folderPath + " Size "); public long getFolderSize(String folderPath) {
log.info("get " + folderPath + " Size ");
String command = "du -k -d 0 "+folderPath+" | grep " + folderPath + "|awk \'{print $1}\'";
List<String> reStrings = Constant.ganymedSSH.execCmdWaitAcquiescent(command); String command = "du -k -d 0 "+folderPath+" | grep " + folderPath + "|awk \'{print $1}\'";
if(reStrings==null || reStrings.size()==0){ List<String> reStrings = Constant.ganymedSSH.execCmdWaitAcquiescent(command);
log.error("get " + folderPath + " Size error!"); if(reStrings==null || reStrings.size()==0){
return -2; log.error("get " + folderPath + " Size error!");
} return -2;
if (reStrings.get(0).contains(Constant.noSuchFile)) { }
log.error(folderPath+" is not exists"); if (reStrings.get(0).contains(Constant.noSuchFile)) {
return -1; log.error(folderPath+" is not exists");
} return -1;
long size = Long.valueOf(reStrings.get(0)); }
long size = Long.valueOf(reStrings.get(0));
return size;
} return size;
}
/**
* /**
* <> *
* <> * <>
* @see [##] * <>
*/ * @see [##]
@Test */
public void testShowData(){ @Test
public void testShowData(){
System.out.println(showFolderData("/home"));
System.out.println(showFolderData("/home"));
}
}
} }

@ -1,93 +1,93 @@
package com.platform.glusterfs; package com.platform.glusterfs;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator; import org.apache.log4j.PropertyConfigurator;
import com.platform.utils.Constant; import com.platform.utils.Constant;
public class SizeInfo { public class SizeInfo {
public static Logger log = Logger.getLogger(ClusterInfo.class); public static Logger log = Logger.getLogger(ClusterInfo.class);
VolumeInfo volumeInfo = new VolumeInfo(); VolumeInfo volumeInfo = new VolumeInfo();
/** /**
* <EFBFBD>?<EFBFBD><EFBFBD>volume size * <EFBFBD>?<EFBFBD><EFBFBD>volume size
* -1<EFBFBD>? 0volume longsize * -1<EFBFBD>? 0volume longsize
* @return * @return
*/ */
public long showAllSize() { public long showAllSize() {
log.info("get AllSize "); log.info("get AllSize ");
List<String> volumeNames = volumeInfo.showAllVolumeName(); List<String> volumeNames = volumeInfo.showAllVolumeName();
if (volumeNames == null) { if (volumeNames == null) {
log.error("1201 showAllVolumeName error"); log.error("1201 showAllVolumeName error");
return -1; return -1;
} }
if (volumeNames.size() == 0) { if (volumeNames.size() == 0) {
log.error("1202 It is not exist any volume"); log.error("1202 It is not exist any volume");
return 0; return 0;
} }
List<String> reStrings = null; List<String> reStrings = null;
long size = 0L; long size = 0L;
for (String str : volumeNames) { for (String str : volumeNames) {
String command = "df |grep " + str + "|awk \'{print $2}\'"; String command = "df |grep " + str + "|awk \'{print $2}\'";
reStrings = Constant.ganymedSSH.execCmdWait(Constant.hostIp, Constant.rootUser, Constant.rootPasswd, Constant.port, reStrings = Constant.ganymedSSH.execCmdWait(Constant.hostIp, Constant.rootUser, Constant.rootPasswd, Constant.port,
command); command);
if (reStrings.isEmpty()) { if (reStrings.isEmpty()) {
log.error("1203 The brick is unmount"); log.error("1203 The brick is unmount");
} else { } else {
size += Long.parseLong(reStrings.get(0)); size += Long.parseLong(reStrings.get(0));
} }
} }
return size; return size;
} }
/** /**
* *
* @return * @return
* -1<EFBFBD>? 0volume longsize * -1<EFBFBD>? 0volume longsize
*/ */
public long showUseSize() { public long showUseSize() {
log.info("get UseSize "); log.info("get UseSize ");
List<String> volumeNames = volumeInfo.showAllVolumeName(); List<String> volumeNames = volumeInfo.showAllVolumeName();
List<String> reStrings = null; List<String> reStrings = null;
long size = 0L; long size = 0L;
if (volumeNames == null) { if (volumeNames == null) {
log.error("1201 showAllVolumeName error"); log.error("1201 showAllVolumeName error");
return -1; return -1;
} }
if (volumeNames.size() == 0) { if (volumeNames.size() == 0) {
log.error("1202 It is not exist any volume"); log.error("1202 It is not exist any volume");
return 0; return 0;
} }
for (String str : volumeNames) { for (String str : volumeNames) {
String command = "df |grep " + str + "|awk \'{print $3}\'"; String command = "df |grep " + str + "|awk \'{print $3}\'";
reStrings = Constant.ganymedSSH.execCmdWait(Constant.hostIp, Constant.rootUser, Constant.rootPasswd, reStrings = Constant.ganymedSSH.execCmdWait(Constant.hostIp, Constant.rootUser, Constant.rootPasswd,
Constant.port, command); Constant.port, command);
if (reStrings.isEmpty()) { if (reStrings.isEmpty()) {
log.error("1202 The brick is unmount"); log.error("1202 The brick is unmount");
} else { } else {
size += Integer.valueOf(reStrings.get(0)); size += Integer.valueOf(reStrings.get(0));
} }
} }
return size; return size;
} }
public static void main(String[] args) { public static void main(String[] args) {
PropertyConfigurator.configure("log4j.properties"); PropertyConfigurator.configure("log4j.properties");
System.out.println(new SizeInfo().showAllSize()); System.out.println(new SizeInfo().showAllSize());
System.out.println(new SizeInfo().showUseSize()); System.out.println(new SizeInfo().showUseSize());
} }
} }

@ -1,422 +1,406 @@
package com.platform.glusterfs; package com.platform.glusterfs;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator; import org.apache.log4j.PropertyConfigurator;
import org.junit.Test; import org.junit.Test;
import org.omg.CosNaming.NamingContextExtPackage.StringNameHelper; import org.omg.CosNaming.NamingContextExtPackage.StringNameHelper;
import com.platform.utils.Constant; import com.platform.utils.Constant;
import com.platform.utils.GanymedSSH; import com.platform.utils.GanymedSSH;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
/** /**
* volume <> * volume <>
* *
* @author liliy * @author liliy
* @version [2016913] * @version [2016913]
* @see [/] * @see [/]
* @since [/] * @since [/]
*/ */
public class VolumeInfo { public class VolumeInfo {
public static Logger log = Logger.getLogger(VolumeInfo.class); public static Logger log = Logger.getLogger(VolumeInfo.class);
/** /**
* volume <> * volume <>
* *
* @return * @return
* @see [##] * @see [##]
*/ */
public List<String> showAllVolumeName() { public List<String> showAllVolumeName() {
log.info("get volume name"); log.info("get volume name");
List<String> volNames = new ArrayList<String>(); List<String> volNames = new ArrayList<String>();
/* /*
* String command = "echo \"" + Constant.rootPasswd + * String command = "echo \"" + Constant.rootPasswd +
* "\" |sudo -S gluster volume info|grep ^Volume.Name"; RunCommand * "\" |sudo -S gluster volume info|grep ^Volume.Name"; RunCommand
* runCommand = new RunCommand(); List<String> reStrings = * runCommand = new RunCommand(); List<String> reStrings =
* runCommand.runCommandWait(command); * runCommand.runCommandWait(command);
*/ */
List<String> reStrings = Constant.ganymedSSH List<String> reStrings = Constant.ganymedSSH
.execCmdWaitAcquiescent(Constant.glusterVolumeInfo + "|grep ^Volume.Name"); .execCmdWaitAcquiescent(Constant.glusterVolumeInfo + "|grep ^Volume.Name");
// System.out.println(reStrings); // System.out.println(reStrings);
if (reStrings == null) { if (reStrings == null) {
log.error("1401 get result is null"); log.error("1401 get result is null");
return null; return null;
} }
if (reStrings.size() == 0) { if (reStrings.size() == 0) {
log.error("1402 get result is nothing"); log.error("1402 get result is nothing");
return null; return null;
} }
if (reStrings.get(0).contains(Constant.noVolume)) { if (reStrings.get(0).contains(Constant.noVolume)) {
reStrings.clear(); reStrings.clear();
return reStrings; return reStrings;
} }
if (!(reStrings.get(0).split(":")[0].contains("Volume Name"))) { if (!(reStrings.get(0).split(":")[0].contains("Volume Name"))) {
log.error("1403 get result string wrong"); log.error("1403 get result string wrong");
return null; return null;
} }
String nameInfo = ""; String nameInfo = "";
for (Iterator it = reStrings.iterator(); it.hasNext();) { for (Iterator it = reStrings.iterator(); it.hasNext();) {
String line = (String) it.next(); String line = (String) it.next();
String str[] = line.split(":"); String str[] = line.split(":");
volNames.add(str[1].replaceAll(" ", "")); volNames.add(str[1].replaceAll(" ", ""));
} }
return volNames; return volNames;
} }
/** /**
* volumevolume <> * volumevolume
* *
* @param volumeName * @param volumeName
* @return * @return
* @see [##] * @see [##]
*/ */
public String getVolumeType(String volumeName) { public String getVolumeType(String volumeName) {
log.info("get volume type"); log.info("get volume type");
String volType = ""; String volType = "";
List<String> reStrings = Constant.ganymedSSH List<String> reStrings = Constant.ganymedSSH
.execCmdWaitAcquiescent(Constant.glusterVolumeInfo + volumeName + "|grep ^Type"); .execCmdWaitAcquiescent(Constant.glusterVolumeInfo + volumeName + "|grep ^Type");
// System.out.println(reStrings); // System.out.println(reStrings);
if (reStrings == null) { if (reStrings == null) {
log.error("1501 get result is null"); log.error("1501 get result is null");
return null; return null;
} }
if (reStrings.size() == 0) { if (reStrings.size() == 0) {
log.error("1502 get result is nothing"); log.error("1502 get result is nothing");
return null; return null;
} }
if (!(reStrings.get(0).split(":")[0].contains("Type"))) { if (!(reStrings.get(0).split(":")[0].contains("Type"))) {
log.error("1503 get result string wrong"); log.error("1503 get result string wrong");
return null; return null;
} }
// System.out.println(reStrings); // System.out.println(reStrings);
for (Iterator it = reStrings.iterator(); it.hasNext();) { for (Iterator it = reStrings.iterator(); it.hasNext();) {
String line = (String) it.next(); String line = (String) it.next();
String str[] = line.split(":"); String str[] = line.split(":");
volType = str[1]; volType = str[1];
} }
volType = volType.replaceAll(" ", ""); volType = volType.replaceAll(" ", "");
return volType; return volType;
} }
/** /**
* volumeName nullvolumeNameVolume volumeName does not * volumeName nullvolumeNameVolume volumeName does not
* existStarted,Stopped,Created * existStarted,Stopped,Created
* *
* @param volumeName * @param volumeName
* @return * @return
* @see [##] * @see [##]
*/ */
public String getVolumeStatus(String volumeName) { public String getVolumeStatus(String volumeName) {
log.info("get volume status"); log.info("get volume status");
String volStatus = ""; String volStatus = "";
String cmd = Constant.glusterVolumeInfo + " " + volumeName + " |grep ^Status"; String cmd = Constant.glusterVolumeInfo + " " + volumeName + " |grep ^Status";
List<String> reStrings = Constant.ganymedSSH.execCmdWaitAcquiescent(cmd); List<String> reStrings = Constant.ganymedSSH.execCmdWaitAcquiescent(cmd);
// System.out.println(reStrings); // System.out.println(reStrings);
if (reStrings == null) { if (reStrings == null) {
log.error("1701 get result is null"); log.error("1701 get result is null");
return null; return null;
} }
if (reStrings.size() == 0) { if (reStrings.size() == 0) {
log.error("1702 get result is nothing"); log.error("1702 get result is nothing");
return null; return null;
} }
if (reStrings.get(0).contains("does not exist")) { if (reStrings.get(0).contains("does not exist")) {
log.error("1703 " + reStrings.get(0)); log.error("1703 " + reStrings.get(0));
return reStrings.get(0); return reStrings.get(0);
} }
if (!(reStrings.get(0).split(":")[0].contains("Status"))) { if (!(reStrings.get(0).split(":")[0].contains("Status"))) {
log.error("1704 get result string wrong"); log.error("1704 get result string wrong");
return null; return null;
} }
for (Iterator it = reStrings.iterator(); it.hasNext();) { for (Iterator it = reStrings.iterator(); it.hasNext();) {
String line = (String) it.next(); String line = (String) it.next();
String str[] = line.split(":"); String str[] = line.split(":");
volStatus = str[1].replaceAll(" ", ""); volStatus = str[1].replaceAll(" ", "");
} }
return volStatus; return volStatus;
} }
/** /**
* volumeName * volumeName
* volumeName-1-2 volumeName * volumeName-1-2 volumeName
* @param volumeName * @param volumeName
* @return * @return
* @see [##] * @see [##]
*/ */
public Long getVolumeAvailableSize(String volumeName) { public Long getVolumeAvailableSize(String volumeName) {
log.info("get volume availableSize"); log.info("get volume availableSize");
Long allSize = 0L; Long allSize = 0L;
String cmd = Constant.df + " | grep " + volumeName + "|awk '{print $4}'"; String cmd = Constant.df + " | grep " + volumeName + "|awk '{print $4}'";
List<String> reStrings = Constant.ganymedSSH.execCmdWaitAcquiescent(cmd); List<String> reStrings = Constant.ganymedSSH.execCmdWaitAcquiescent(cmd);
// System.out.println(reStrings); // System.out.println(reStrings);
if (reStrings == null) { if (reStrings == null) {
log.error("1802 get result is error"); log.error("1802 get result is error");
return -2L; return -2L;
} }
if (reStrings.size() == 0) { if (reStrings.size() == 0) {
log.error("1801 " + volumeName + " is not exists!"); log.error("1801 " + volumeName + " is not exists!");
return -1L; return -1L;
} }
allSize = Long.parseLong(reStrings.get(0)); allSize = Long.parseLong(reStrings.get(0));
return allSize; return allSize;
} }
/** /**
* volumeName * volumeName
* volumeName-1-2 volumeName * volumeName-1-2 volumeName
* @param volumeName * @param volumeName
* @return * @return
* @see [##] * @see [##]
*/ */
public Long getVolumeUseSize(String volumeName) { public Long getVolumeUseSize(String volumeName) {
log.info("get volume used size"); log.info("get volume used size");
Long usedSize = 0L; Long usedSize = 0L;
if (volumeIsExists(volumeName) == false) { if (volumeIsExists(volumeName) == false) {
log.error("1901 " + volumeName + " is not exists!"); log.error("1901 " + volumeName + " is not exists!");
return -1L; return -1L;
} }
String cmd = "df | grep " + volumeName + "|awk '{print $3}'"; String cmd = "df | grep " + volumeName + "|awk '{print $3}'";
List<String> reStrings = Constant.ganymedSSH.execCmdWaitAcquiescent(cmd); List<String> reStrings = Constant.ganymedSSH.execCmdWaitAcquiescent(cmd);
// System.out.println(reStrings); // System.out.println(reStrings);
if (reStrings == null) { if (reStrings == null) {
log.error("1901 get result is null"); log.error("1901 get result is null");
return -2L; return -2L;
} }
if (reStrings.size() == 0) { if (reStrings.size() == 0) {
log.error("1902 " + volumeName + " is not exists!"); log.error("1902 " + volumeName + " is not exists!");
return -1L; return -1L;
} }
usedSize = Long.parseLong(reStrings.get(0)); usedSize = Long.parseLong(reStrings.get(0));
return usedSize; return usedSize;
} }
/** /**
* volumeNamebricks * volumeNamebricks
* birckslist ip:path,volumeNamenull * birckslist ip:path,volumeNamenull
* @param volumeName * @param volumeName
* @return * @return
* @see [##] * @see [##]
*/ */
public List<String> getVolumeBricks(String volumeName) { public List<String> getVolumeBricks(String volumeName) {
log.info("get volume bricks"); log.info("get volume bricks");
String cmd = "gluster volume info " + volumeName + " |grep ^Brick'[0-9]\\+' |awk '{print $2}'"; String cmd = "gluster volume info " + volumeName + " |grep ^Brick'[0-9]\\+' |awk '{print $2}'";
List<String> reStrings = Constant.ganymedSSH.execCmdWaitAcquiescent(cmd); List<String> reStrings = Constant.ganymedSSH.execCmdWaitAcquiescent(cmd);
// System.out.println(reStrings); // System.out.println(reStrings);
if (reStrings == null) { if (reStrings == null) {
log.error("1601 get volume bricks wrong"); log.error("1601 get volume bricks wrong");
return null; return null;
} }
if (reStrings.size()==0) { if (reStrings.size()==0) {
log.error("1602 "+volumeName+" is not exists!"); log.error("1602 "+volumeName+" is not exists!");
return null; return null;
} }
return reStrings; return reStrings;
} }
/** /**
* volumeName * volumeName
* <> * <>
* @param volumeName * @param volumeName
* @return * @return
* @see [##] * @see [##]
*/ */
public List<String> getVolumeMountPoint(String volumeName) { public List<String> getVolumeMountPoint(String volumeName) {
log.info("get volume MountPoint"); log.info("get volume MountPoint");
List<String> mountPoints = new ArrayList<>(); List<String> mountPoints = new ArrayList<>();
String cmd=Constant.df + "|grep " + volumeName + "|awk '{print $6}'"; String cmd=Constant.df + "|grep " + volumeName + "|awk '{print $6}'";
List<String> reStrings = Constant.ganymedSSH.execCmdWaitAcquiescent(cmd); List<String> reStrings = Constant.ganymedSSH.execCmdWaitAcquiescent(cmd);
// System.out.println(reStrings); // System.out.println(reStrings);
if (reStrings == null) { if (reStrings == null) {
log.error("11001 get result string wrong"); log.error("11001 get result string wrong");
return null; return null;
} }
if (reStrings.size() == 0) { if (reStrings.size() == 0) {
log.error("11002 " + volumeName + " is not exists or no mountpoint"); log.error("11002 " + volumeName + " is not exists or no mountpoint");
return null; return null;
} }
// char flag = reStrings.get(0).trim().toCharArray()[0]; for (String mountPoint : reStrings) {
// if (flag != '/') { mountPoint = mountPoint.replaceAll(" ", "");
// log.error("11003 get result string wrong"); mountPoints.add(mountPoint);
// return null; }
// } return mountPoints;
}
for (String mountPoint : reStrings) {
mountPoint = mountPoint.replaceAll(" ", ""); public String getOneVolumeMountPoint(String volumeName) {
mountPoints.add(mountPoint); log.info("get one volume MountPoint");
}
return mountPoints; String mountPoint=null;
}
List<String> mountpoints = getVolumeMountPoint(volumeName);
public String getOneVolumeMountPoint(String volumeName) { // System.out.println(reStrings);
log.info("get one volume MountPoint"); if (mountpoints == null || mountpoints.size() == 0) {
log.error("11001 get result string wrong");
String mountPoint=null; return null;
String cmd=Constant.df + "|grep " + volumeName + "|awk '{print $6}'"; }
List<String> reStrings = Constant.ganymedSSH.execCmdWaitAcquiescent(cmd);
// System.out.println(reStrings); mountPoint=mountpoints.get(0);
if (reStrings == null) { return mountPoint;
log.error("11001 get result string wrong"); }
return null;
} /**
if (reStrings.size() == 0) { * volumeNamebrick
log.error("11002 " + volumeName + " is not exists or no mountpoint"); * mapbricks <ip:path,data_size>
return null; * @param volumeName
} * @return
* @see [##]
// char flag = reStrings.get(0).trim().toCharArray()[0]; */
// if (flag != '/') { public Map<String, Double> getVolumebricksDataSize(String volumeName) {
// log.error("11003 get result string wrong"); List<String> bricks = getVolumeBricks(volumeName);
// return null; Map<String, Double> brick_size = new HashMap<>();
// } if (bricks == null) {
return null;
mountPoint=reStrings.get(0); }
return mountPoint; for (String brick : bricks) {
} String ipAndpath[] = brick.split(":");
String ip = ipAndpath[0];
/** String path = ipAndpath[1];
* volumeNamebrick String cmd = "du -d 0 " + path + "|awk '{print $1}'";
* mapbricks <ip:path,data_size> List<String> reStrings = Constant.ganymedSSH.execCmdWait(ip, Constant.rootUser, Constant.rootPasswd,
* @param volumeName Constant.port, cmd);
* @return // System.out.println(reStrings);
* @see [##] if (reStrings == null) {
*/ log.error("1901 get result is null");
public Map<String, Double> getVolumebricksDataSize(String volumeName) { return null;
List<String> bricks = getVolumeBricks(volumeName); }
Map<String, Double> brick_size = new HashMap<>(); if (reStrings.size() == 0) {
if (bricks == null) { log.error("1902 "+brick+" is not exits!");
return null; return null;
} }
for (String brick : bricks) { Pattern pattern = Pattern.compile("[0-9]*");
String ipAndpath[] = brick.split(":"); Matcher isNum = pattern.matcher(reStrings.get(0));
String ip = ipAndpath[0]; if (!isNum.matches()) {
String path = ipAndpath[1]; log.error("1903 " + reStrings.get(0) + " is unexpect");
String cmd = "du -d 0 " + path + "|awk '{print $1}'"; return null;
List<String> reStrings = Constant.ganymedSSH.execCmdWait(ip, Constant.rootUser, Constant.rootPasswd, }
Constant.port, cmd); brick_size.put(brick, Double.parseDouble(reStrings.get(0)));
// System.out.println(reStrings); }
if (reStrings == null) { return brick_size;
log.error("1901 get result is null"); }
return null;
} /**
if (reStrings.size() == 0) { * volumeNamebrick
log.error("1902 "+brick+" is not exits!"); * mapbricks <ip:path,available_size>
return null; * @param volumeName
} * @return
Pattern pattern = Pattern.compile("[0-9]*"); * @see [##]
Matcher isNum = pattern.matcher(reStrings.get(0)); */
if (!isNum.matches()) { public Map<String, Double> getVolumebricksAvailableSize(String volumeName) {
log.error("1903 " + reStrings.get(0) + " is unexpect"); List<String> bricks = getVolumeBricks(volumeName);
return null; Map<String, Double> brick_size = new HashMap<>();
} if (bricks == null) {
brick_size.put(brick, Double.parseDouble(reStrings.get(0))); return null;
} }
return brick_size; for (String brick : bricks) {
} String ipAndpath[] = brick.split(":");
String ip = ipAndpath[0];
/** String path = ipAndpath[1];
* volumeNamebrick String cmd = "df " + path + "|awk '{print $4}'";
* mapbricks <ip:path,available_size> List<String> reStrings = Constant.ganymedSSH.execCmdWait(ip, Constant.rootUser, Constant.rootPasswd,
* @param volumeName Constant.port, cmd);
* @return // System.out.println(reStrings);
* @see [##] if (reStrings == null) {
*/ log.error("1901 get result is null");
public Map<String, Double> getVolumebricksAvailableSize(String volumeName) { return null;
List<String> bricks = getVolumeBricks(volumeName); }
Map<String, Double> brick_size = new HashMap<>(); if (reStrings.size() == 0) {
if (bricks == null) { log.error("1902 get result is nothing");
return null; return null;
} }
for (String brick : bricks) { Pattern pattern = Pattern.compile("[0-9]*");
String ipAndpath[] = brick.split(":"); Matcher isNum = pattern.matcher(reStrings.get(1));
String ip = ipAndpath[0]; if (!isNum.matches()) {
String path = ipAndpath[1]; log.error("1903 " + reStrings.get(1) + " is unexpect");
String cmd = "df " + path + "|awk '{print $4}'"; return null;
List<String> reStrings = Constant.ganymedSSH.execCmdWait(ip, Constant.rootUser, Constant.rootPasswd, }
Constant.port, cmd); brick_size.put(brick, Double.parseDouble(reStrings.get(1)));
// System.out.println(reStrings); }
if (reStrings == null) { return brick_size;
log.error("1901 get result is null"); }
return null;
} /**
if (reStrings.size() == 0) { * volumeNametruefalse
log.error("1902 get result is nothing"); *
return null; * @param volumeName
} * @return
Pattern pattern = Pattern.compile("[0-9]*"); * @see [##]
Matcher isNum = pattern.matcher(reStrings.get(1)); */
if (!isNum.matches()) { public boolean volumeIsExists(String volumeName) {
log.error("1903 " + reStrings.get(1) + " is unexpect"); List<String> volumes = showAllVolumeName();
return null; if (volumes == null) {
} return false;
brick_size.put(brick, Double.parseDouble(reStrings.get(1))); }
} if (volumes.contains(volumeName)) {
return brick_size; return true;
} }
return false;
/** }
* volumeNametruefalse <>
* // @Test
* @param volumeName public void test_getVolumebricksDataSize() {
* @return System.out.println(getVolumebricksDataSize("gfs_ftp"));
* @see [##] }
*/
public boolean volumeIsExists(String volumeName) { // @Test
List<String> volumes = showAllVolumeName(); public void test_getVolumebricksAvailableSize() {
if (volumes == null) { System.out.println(getVolumebricksAvailableSize("gfs_ftp"));
return false; }
}
if (volumes.contains(volumeName)) { // @Test
return true; public void test_getVolumeBricks() {
} getVolumeBricks("gfs_ftp");
return false; }
}
@Test
// @Test public void test_getVolumeStatus() {
public void test_getVolumebricksDataSize() { System.out.println(getVolumeStatus("gs_fp"));
System.out.println(getVolumebricksDataSize("gfs_ftp")); }
}
// @Test
// @Test public void test_getVolumeMountPoint() {
public void test_getVolumebricksAvailableSize() { System.out.println(getVolumeMountPoint("gfs_ftp"));
System.out.println(getVolumebricksAvailableSize("gfs_ftp")); System.out.println(getVolumeMountPoint("v1"));
} }
}
// @Test
public void test_getVolumeBricks() {
getVolumeBricks("gfs_ftp");
}
@Test
public void test_getVolumeStatus() {
System.out.println(getVolumeStatus("gs_fp"));
}
// @Test
public void test_getVolumeMountPoint() {
System.out.println(getVolumeMountPoint("gfs_ftp"));
System.out.println(getVolumeMountPoint("v1"));
}
}

@ -1,154 +1,154 @@
package com.platform.kubernetes; package com.platform.kubernetes;
import io.fabric8.kubernetes.api.model.Container; import io.fabric8.kubernetes.api.model.Container;
import io.fabric8.kubernetes.api.model.ContainerPort; import io.fabric8.kubernetes.api.model.ContainerPort;
import io.fabric8.kubernetes.api.model.Pod; import io.fabric8.kubernetes.api.model.Pod;
import io.fabric8.kubernetes.api.model.ReplicationController; import io.fabric8.kubernetes.api.model.ReplicationController;
import io.fabric8.kubernetes.client.Config; import io.fabric8.kubernetes.client.Config;
import io.fabric8.kubernetes.client.ConfigBuilder; import io.fabric8.kubernetes.client.ConfigBuilder;
import io.fabric8.kubernetes.client.DefaultKubernetesClient; import io.fabric8.kubernetes.client.DefaultKubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClient; import io.fabric8.kubernetes.client.KubernetesClient;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import com.platform.utils.Configs; import com.platform.utils.Configs;
import com.platform.utils.UtilsHelper; import com.platform.utils.UtilsHelper;
public class SimpleKubeClient { public class SimpleKubeClient {
private KubernetesClient client; private KubernetesClient client;
private final static String DEFAULT_NAMESPACE = "default"; private final static String DEFAULT_NAMESPACE = "default";
public SimpleKubeClient() { public SimpleKubeClient() {
this.client = new DefaultKubernetesClient(Configs.KUBE_MASTER_URL); this.client = new DefaultKubernetesClient(Configs.KUBE_MASTER_URL);
} }
public SimpleKubeClient(String masterUrl) { public SimpleKubeClient(String masterUrl) {
this.client = new DefaultKubernetesClient(masterUrl); this.client = new DefaultKubernetesClient(masterUrl);
} }
public SimpleKubeClient(Config config) { public SimpleKubeClient(Config config) {
Config cf = config; Config cf = config;
if (null == config) { if (null == config) {
cf = new ConfigBuilder().withMasterUrl(Configs.KUBE_MASTER_URL).build(); cf = new ConfigBuilder().withMasterUrl(Configs.KUBE_MASTER_URL).build();
} }
this.client = new DefaultKubernetesClient(cf); this.client = new DefaultKubernetesClient(cf);
} }
public void updateOrAddReplicasLabelById(String namespace, public void updateOrAddReplicasLabelById(String namespace,
String resourceId, String key, String value) { String resourceId, String key, String value) {
KubernetesClient kubeClient = client; KubernetesClient kubeClient = client;
if (checkClientNull()) if (checkClientNull())
kubeClient = new DefaultKubernetesClient(Configs.KUBE_MASTER_URL); kubeClient = new DefaultKubernetesClient(Configs.KUBE_MASTER_URL);
kubeClient.replicationControllers().inNamespace(namespace) kubeClient.replicationControllers().inNamespace(namespace)
.withName(resourceId).edit().editMetadata() .withName(resourceId).edit().editMetadata()
.addToLabels(key, value).endMetadata().done(); .addToLabels(key, value).endMetadata().done();
} }
public void updateOrAddReplicasLabelByEntity(String namespace, public void updateOrAddReplicasLabelByEntity(String namespace,
ReplicationController replicas, String key, String value) { ReplicationController replicas, String key, String value) {
updateOrAddReplicasLabelById(namespace, replicas.getMetadata() updateOrAddReplicasLabelById(namespace, replicas.getMetadata()
.getName(), key, value); .getName(), key, value);
} }
public void updateOrAddReplicasLabelById(String resourceId, String key, public void updateOrAddReplicasLabelById(String resourceId, String key,
String value) { String value) {
updateOrAddReplicasLabelById(DEFAULT_NAMESPACE, resourceId, key, value); updateOrAddReplicasLabelById(DEFAULT_NAMESPACE, resourceId, key, value);
} }
public void updateOrAddReplicasLabelByEntity( public void updateOrAddReplicasLabelByEntity(
ReplicationController replicas, String key, String value) { ReplicationController replicas, String key, String value) {
updateOrAddReplicasLabelByEntity(DEFAULT_NAMESPACE, replicas, key, updateOrAddReplicasLabelByEntity(DEFAULT_NAMESPACE, replicas, key,
value); value);
} }
@SuppressWarnings("resource") @SuppressWarnings("resource")
public ReplicationController getReplicationController(String namespace, public ReplicationController getReplicationController(String namespace,
String replicasName) { String replicasName) {
KubernetesClient kubeClient = client; KubernetesClient kubeClient = client;
if (checkClientNull()) if (checkClientNull())
kubeClient = new DefaultKubernetesClient(Configs.KUBE_MASTER_URL); kubeClient = new DefaultKubernetesClient(Configs.KUBE_MASTER_URL);
return kubeClient.replicationControllers().inNamespace(namespace) return kubeClient.replicationControllers().inNamespace(namespace)
.withName(replicasName).get(); .withName(replicasName).get();
} }
public ReplicationController getReplicationController(String replicasName) { public ReplicationController getReplicationController(String replicasName) {
return getReplicationController(DEFAULT_NAMESPACE, replicasName); return getReplicationController(DEFAULT_NAMESPACE, replicasName);
} }
@SuppressWarnings("resource") @SuppressWarnings("resource")
public List<Pod> getPodsForApplicaList(ReplicationController rc) { public List<Pod> getPodsForApplicaList(ReplicationController rc) {
Map<String, String> selector = rc.getSpec().getSelector(); Map<String, String> selector = rc.getSpec().getSelector();
KubernetesClient kubeClient = client; KubernetesClient kubeClient = client;
if (checkClientNull()) if (checkClientNull())
kubeClient = new DefaultKubernetesClient(Configs.KUBE_MASTER_URL); kubeClient = new DefaultKubernetesClient(Configs.KUBE_MASTER_URL);
List<Pod> podList = kubeClient.pods() List<Pod> podList = kubeClient.pods()
.inNamespace(rc.getMetadata().getNamespace()).list().getItems(); .inNamespace(rc.getMetadata().getNamespace()).list().getItems();
return getPods(podList, selector); return getPods(podList, selector);
} }
private boolean checkClientNull() { private boolean checkClientNull() {
return null == client; return null == client;
} }
public List<Pod> getPods(List<Pod> pods, Map<String, String> selector) { public List<Pod> getPods(List<Pod> pods, Map<String, String> selector) {
List<Pod> result = new ArrayList<Pod>(); List<Pod> result = new ArrayList<Pod>();
for (int i = 0; i < pods.size(); i++) for (int i = 0; i < pods.size(); i++)
if (UtilsHelper.isSubMap(getLabels(pods.get(i)), selector)) if (UtilsHelper.isSubMap(getLabels(pods.get(i)), selector))
result.add(pods.get(i)); result.add(pods.get(i));
return result; return result;
} }
private Map<String, String> getLabels(Pod pod) { private Map<String, String> getLabels(Pod pod) {
return pod.getMetadata().getLabels(); return pod.getMetadata().getLabels();
} }
public KubernetesClient getClient() { public KubernetesClient getClient() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return client; return client;
} }
public int getPodContainerport(Pod pod) { public int getPodContainerport(Pod pod) {
int port = Configs.ORACLE_DEFAULT_PORT; int port = Configs.ORACLE_DEFAULT_PORT;
List<Container> containers = pod.getSpec().getContainers(); List<Container> containers = pod.getSpec().getContainers();
if (null != containers && containers.size() > 0) { if (null != containers && containers.size() > 0) {
List<ContainerPort> ports = containers.get(0).getPorts(); List<ContainerPort> ports = containers.get(0).getPorts();
if (null != ports && ports.size() > 0) if (null != ports && ports.size() > 0)
port = ports.get(0).getHostPort(); port = ports.get(0).getHostPort();
} }
return port; return port;
} }
public String getPodHostIp(Pod pod) { public String getPodHostIp(Pod pod) {
return pod.getSpec().getNodeName(); return pod.getSpec().getNodeName();
} }
@SuppressWarnings("resource") @SuppressWarnings("resource")
public Map<String, ReplicationController> getReplicationControllerList( public Map<String, ReplicationController> getReplicationControllerList(
String namespace) { String namespace) {
KubernetesClient kubeClient = client; KubernetesClient kubeClient = client;
Map<String, ReplicationController> rcMap = new HashMap<String, ReplicationController>(); Map<String, ReplicationController> rcMap = new HashMap<String, ReplicationController>();
if (checkClientNull()) if (checkClientNull())
kubeClient = new DefaultKubernetesClient(Configs.KUBE_MASTER_URL); kubeClient = new DefaultKubernetesClient(Configs.KUBE_MASTER_URL);
List<ReplicationController> replicasList = kubeClient List<ReplicationController> replicasList = kubeClient
.replicationControllers().list().getItems(); .replicationControllers().list().getItems();
if (replicasList != null) if (replicasList != null)
for (int i = 0; i < replicasList.size(); i++) { for (int i = 0; i < replicasList.size(); i++) {
ReplicationController rController = replicasList.get(i); ReplicationController rController = replicasList.get(i);
rcMap.put(rController.getMetadata().getName(), rController); rcMap.put(rController.getMetadata().getName(), rController);
} }
return rcMap; return rcMap;
} }
public Map<String, ReplicationController> getReplicationControllerList() { public Map<String, ReplicationController> getReplicationControllerList() {
return getReplicationControllerList(DEFAULT_NAMESPACE); return getReplicationControllerList(DEFAULT_NAMESPACE);
} }
public void close() { public void close() {
if (!checkClientNull()) if (!checkClientNull())
client.close(); client.close();
} }
} }

@ -73,4 +73,4 @@ public class OracleConnector {
} }
return flag; return flag;
} }
} }

@ -1,16 +1,16 @@
package com.platform.service; package com.platform.service;
import org.springframework.ui.ModelMap; import org.springframework.ui.ModelMap;
import com.platform.dao.DataInfoDao; import com.platform.dao.DataInfoDao;
import com.platform.entities.DataInfoEntity; import com.platform.entities.DataInfoEntity;
import com.platform.entities.PagerOptions; import com.platform.entities.PagerOptions;
public interface DataInfoService { public interface DataInfoService {
public ModelMap getPagerTableData(PagerOptions pagerOptions); public ModelMap getPagerTableData(PagerOptions pagerOptions);
void deleteData(String[] id) throws Exception; void deleteData(String[] id) throws Exception;
int save(DataInfoEntity data) throws Exception; int save(DataInfoEntity data) throws Exception;
} }

@ -1,71 +1,77 @@
package com.platform.service; package com.platform.service;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.annotation.Resource; import javax.annotation.Resource;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.ui.ModelMap; import org.springframework.ui.ModelMap;
import com.platform.dao.DataInfoDao; import com.platform.dao.DataInfoDao;
import com.platform.entities.DataInfoEntity; import com.platform.entities.DataInfoEntity;
import com.platform.entities.PagerOptions; import com.platform.entities.PagerOptions;
@Service(value = "dataInfoService") @Service(value = "dataInfoService")
public class DataInfoServiceImp implements DataInfoService { public class DataInfoServiceImp implements DataInfoService {
@Resource(name = "dataInfoDao") @Resource(name = "dataInfoDao")
private DataInfoDao dfdDao; private DataInfoDao dfdDao;
public void setDfdDao(DataInfoDao dfdDao) { public void setDfdDao(DataInfoDao dfdDao) {
this.dfdDao = dfdDao; this.dfdDao = dfdDao;
} }
@Override @Override
public ModelMap getPagerTableData(PagerOptions pagerOptions) { public ModelMap getPagerTableData(PagerOptions pagerOptions) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
ModelMap modelMap = new ModelMap(); ModelMap modelMap = new ModelMap();
int count = dfdDao.getLimitedDataCount(pagerOptions); //获取总记录条数 int count = dfdDao.getLimitedDataCount(pagerOptions); //获取总记录条数
System.out.println("total colume " + count); System.out.println("total colume " + count);
int offset = 0; int offset = 0;
if (pagerOptions.getCurrentPageNum() > 1) { if (pagerOptions.getCurrentPageNum() > 1) {
pagerOptions.setTotalLimit((pagerOptions.getCurrentPageNum() - 1) pagerOptions.setTotalLimit((pagerOptions.getCurrentPageNum() - 1)
* pagerOptions.getPriorTableSize()); * pagerOptions.getPriorTableSize());
offset = dfdDao.getLimitedBeginId(pagerOptions); //获取起始查询id offset = dfdDao.getLimitedBeginId(pagerOptions); //获取起始查询id
System.out.println(offset); System.out.println(offset);
} }
pagerOptions.setOffset(offset + 1); pagerOptions.setOffset(offset + 1);
List<DataInfoEntity> result = dfdDao List<DataInfoEntity> result = dfdDao
.getLimitedDataInfoEntities(pagerOptions); .getLimitedDataInfoEntities(pagerOptions);
modelMap.addAttribute("data", result); modelMap.addAttribute("data", result);
modelMap.addAttribute("length", count); modelMap.addAttribute("length", count);
return modelMap; return modelMap;
} }
@Override @Override
public void deleteData(String[] id) throws Exception { public void deleteData(String[] id) throws Exception {
// TODO Auto-generated method stub // TODO Auto-generated method stub
List<Integer> ids = new ArrayList<Integer>(); List<Integer> ids = new ArrayList<Integer>();
for(String idx: id){ for(String idx: id){
ids.add(Integer.parseInt(idx)); ids.add(Integer.parseInt(idx));
} }
if (ids.size() > 0) { if (ids.size() > 0) {
//数据在不在? //数据在不在?
List<String> paths = dfdDao.getIdIsExist(ids); List<String> paths = dfdDao.getIdIsExist(ids);
if(paths.size()>0){ if(paths.size()>0){
//删除文件操作 //删除文件操作
for (int i = 0; i < paths.size(); i++) { for (int i = 0; i < paths.size(); i++) {
System.out.println(paths.get(i)); System.out.println(paths.get(i));
} }
//删除数据库记录 //删除数据库记录
dfdDao.removes(ids); dfdDao.removes(ids);
} }
} }
} }
@Override @Override
public int save(DataInfoEntity data) throws Exception { public int save(DataInfoEntity data) throws Exception {
int result = dfdDao.save(data); int result = 0;
return result; try {
} result = dfdDao.save(data);
} } catch (Exception e) {
// TODO: handle exception
System.out.println("");
}
return result;
}
}

@ -1,20 +1,20 @@
package com.platform.service; package com.platform.service;
import java.util.List; import java.util.List;
import com.platform.entities.EncodedInfoEntity; import com.platform.entities.EncodedInfoEntity;
/** /**
* *
* *
* @author wuming * @author wuming
* *
*/ */
public interface EncodeInfoService { public interface EncodeInfoService {
public List<EncodedInfoEntity> getAllEncodeInfo(String tableName); public List<EncodedInfoEntity> getAllEncodeInfo(String tableName);
public int deleteEncodeByCode(String code, String tableName); public int deleteEncodeByCode(String code, String tableName);
public String getEncodeNameByCode(String code, String name); public String getEncodeNameByCode(String code, String name);
} }

@ -1,52 +1,52 @@
package com.platform.service; package com.platform.service;
import java.util.List; import java.util.List;
import javax.annotation.Resource; import javax.annotation.Resource;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.platform.dao.EncodeInfoDao; import com.platform.dao.EncodeInfoDao;
import com.platform.entities.EncodedInfoEntity; import com.platform.entities.EncodedInfoEntity;
/** /**
* *
* *
* @author wuming * @author wuming
* *
*/ */
@Service("encodeInfoService") @Service("encodeInfoService")
public class EncodeInfoServiceImpl implements EncodeInfoService { public class EncodeInfoServiceImpl implements EncodeInfoService {
@Resource(name = "encodeInfoDao") @Resource(name = "encodeInfoDao")
private EncodeInfoDao eiDao; private EncodeInfoDao eiDao;
public void setEiDao(EncodeInfoDao eiDao) { public void setEiDao(EncodeInfoDao eiDao) {
this.eiDao = eiDao; this.eiDao = eiDao;
} }
/** /**
* tableName/ * tableName/
*/ */
@Override @Override
public List<EncodedInfoEntity> getAllEncodeInfo(String tableName) { public List<EncodedInfoEntity> getAllEncodeInfo(String tableName) {
return eiDao.getAllEntityInfo(tableName); return eiDao.getAllEntityInfo(tableName);
} }
/** /**
* *
*/ */
@Override @Override
public int deleteEncodeByCode(String code, String tableName) { public int deleteEncodeByCode(String code, String tableName) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
int cursor = eiDao.deleteEncodeByCode(code, tableName); int cursor = eiDao.deleteEncodeByCode(code, tableName);
//cursor = cursor / 0; //cursor = cursor / 0;
return cursor; return cursor;
} }
@Override @Override
public String getEncodeNameByCode(String code, String tableName) { public String getEncodeNameByCode(String code, String tableName) {
return eiDao.getEncodeNameByCode(code, tableName); return eiDao.getEncodeNameByCode(code, tableName);
} }
} }

@ -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;
}

@ -1,76 +1,76 @@
/** /**
* : IGfsService.java * : IGfsService.java
* : </> * : </>
* : <> * : <>
* @author chen * @author chen
* : <> * : <>
* 201698 * 201698
* <> * <>
*/ */
package com.platform.service; package com.platform.service;
import java.util.List; import java.util.List;
import com.platform.entities.FolderNode; import com.platform.entities.FolderNode;
import com.platform.entities.VolumeEntity; import com.platform.entities.VolumeEntity;
/** /**
* <> * <>
* <> * <>
* @author chen * @author chen
* @version [201698] * @version [201698]
* @see [/] * @see [/]
* @since [/] * @since [/]
*/ */
public interface IGfsService { public interface IGfsService {
/** /**
* <> path * <> path
* <> * <>
* @param path * @param path
* @return * @return
* @throws Exception * @throws Exception
* @see [##] * @see [##]
*/ */
public FolderNode getFolder(String path) throws Exception; public FolderNode getFolder(String path) throws Exception;
/** /**
* <> path * <> path
* <> * <>
* @param srcPath * @param srcPath
* @param dstPath * @param dstPath
* @return * @return
* @throws Exception * @throws Exception
* @see [##] * @see [##]
*/ */
public int copyFolder(List<String> srcFolders, String dstFolder, String name) throws Exception; public int copyFolder(List<String> srcFolders, String dstFolder, String name) throws Exception;
/** /**
* <> volume name \ allsize \ usedsize \ folderTree \ brick * <> volume name \ allsize \ usedsize \ folderTree \ brick
* <> * <>
* @return * @return
* @throws Exception * @throws Exception
* @see [##] * @see [##]
*/ */
public List<VolumeEntity> getAllVolumes() throws Exception; public List<VolumeEntity> getAllVolumes() throws Exception;
/** /**
* <> * <>
* <> * <>
* @return * @return
* @throws Exception * @throws Exception
* @see [##] * @see [##]
*/ */
public VolumeEntity getOneVolume(String volumeName) throws Exception; public VolumeEntity getOneVolume(String volumeName) throws Exception;
public int moveData(String volumeName, String srcPath, String dstPath) throws Exception; public int moveData(String volumeName, String srcPath, String dstPath) throws Exception;
public int deleteData(String volumeName, String srcPath) throws Exception; public int deleteData(String volumeName, String srcPath) throws Exception;
} }

@ -1,40 +1,40 @@
package com.platform.service; package com.platform.service;
import java.util.List; import java.util.List;
import com.platform.entities.DataInfoEntity; import com.platform.entities.DataInfoEntity;
import com.platform.entities.DataInfoEntityMoveTmp; import com.platform.entities.DataInfoEntityMoveTmp;
/** /**
* @author chen * @author chen
* *
*/ */
public interface IMoveDataService { public interface IMoveDataService {
/** /**
* @param a dataInfo * @param a dataInfo
* @param dstPath volumefoldereg: XXX/320198_16/1,or XXX/320122KFQ_15/1 * @param dstPath volumefoldereg: XXX/320198_16/1,or XXX/320122KFQ_15/1
* @return * @return
* @throws Exception * @throws Exception
*/ */
public boolean moveData(List<DataInfoEntity> data, String dstPath) throws Exception; public boolean moveData(List<DataInfoEntity> data, String dstPath) throws Exception;
/** /**
* @return * @return
* @throws Exception * @throws Exception
*/ */
public List<DataInfoEntityMoveTmp> findAll() throws Exception; public List<DataInfoEntityMoveTmp> findAll() throws Exception;
/** /**
* @return * @return
* @throws Exception * @throws Exception
*/ */
public int delete(DataInfoEntityMoveTmp dataMove) throws Exception; public int delete(DataInfoEntityMoveTmp dataMove) throws Exception;
public int update(DataInfoEntityMoveTmp data) throws Exception; public int update(DataInfoEntityMoveTmp data) throws Exception;
public int save(DataInfoEntityMoveTmp data) throws Exception; public int save(DataInfoEntityMoveTmp data) throws Exception;
public int insertBatch(List<DataInfoEntityMoveTmp> list) throws Exception; public int insertBatch(List<DataInfoEntityMoveTmp> list) throws Exception;
} }

@ -1,25 +1,25 @@
package com.platform.service; package com.platform.service;
import java.util.List; import java.util.List;
import com.platform.entities.GatherOracleInfo; import com.platform.entities.GatherOracleInfo;
public interface IMySqlService { public interface IMySqlService {
/** /**
* @return * @return
* @throws Exception * @throws Exception
*/ */
public List<GatherOracleInfo> findAllMySql() throws Exception; public List<GatherOracleInfo> findAllMySql() throws Exception;
/** /**
* @return * @return
* @throws Exception * @throws Exception
*/ */
public int deleteMySql(int id) throws Exception; public int deleteMySql(int id) throws Exception;
public int insertOracle(GatherOracleInfo oracle) throws Exception; public int insertOracle(GatherOracleInfo oracle) throws Exception;
public int updateOracle(GatherOracleInfo oracle) throws Exception; public int updateOracle(GatherOracleInfo oracle) throws Exception;
} }

@ -1,17 +1,22 @@
package com.platform.service; package com.platform.service;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
public interface IOracleExtractService { import com.platform.entities.DataInfoEntity;
import com.platform.entities.GatherOracleInfo;
/** import com.platform.entities.OracleConnectorParams;
* @param name
* @param dataInfo //采集库连接参数 public interface IOracleExtractService {
* @param oracleConnect
* @return /**
* @throws Exception * @param name
*/ * @param dataInfo //采集库连接参数
public boolean extractOracle(String name, List<Map<String, String>> dataInfo, Map<String, String> oracleConnect) throws Exception; * @param oracleConnect
* @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;
}

@ -1,163 +1,163 @@
package com.platform.service; package com.platform.service;
import java.sql.Connection; import java.sql.Connection;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import com.platform.entities.GatherOracleInfo; import com.platform.entities.GatherOracleInfo;
import com.platform.entities.OracleConnectorParams; import com.platform.entities.OracleConnectorParams;
import com.platform.oracle.OracleConnector; import com.platform.oracle.OracleConnector;
import com.platform.utils.Configs; import com.platform.utils.Configs;
import com.platform.utils.FileOperateHelper; import com.platform.utils.FileOperateHelper;
public class OracleExtractHelper { public class OracleExtractHelper {
private OracleConnector oConnector; private OracleConnector oConnector;
/** /**
* dblink * dblink
* *
* @param conn * @param conn
* @param linkName * @param linkName
* dblink * dblink
* @return * @return
*/ */
private boolean hasSameNameDBLink(Connection conn, String linkName) { private boolean hasSameNameDBLink(Connection conn, String linkName) {
boolean flag = false; boolean flag = false;
String sql = "SELECT * FROM ALL_DB_LINKS WHERE DB_LINK=" + linkName; String sql = "SELECT * FROM ALL_DB_LINKS WHERE DB_LINK=" + linkName;
ResultSet rSet = oConnector.getSQLExecResultSet(conn, sql); ResultSet rSet = oConnector.getSQLExecResultSet(conn, sql);
try { try {
rSet.last(); rSet.last();
if (rSet.getRow() > 0) if (rSet.getRow() > 0)
flag = true; flag = true;
} catch (Exception e) { } catch (Exception e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
return flag; return flag;
} }
/** /**
* dblink * dblink
* *
<<<<<<< HEAD <<<<<<< HEAD
<<<<<<< HEAD <<<<<<< HEAD
* @param conn * @param conn
* @param oc * @param oc
======= =======
* @param conn * @param conn
* @param oc * @param oc
>>>>>>> 355b6e47a4fa8d058029ec939fe4fefdaa751275 >>>>>>> 355b6e47a4fa8d058029ec939fe4fefdaa751275
======= =======
* @param conn * @param conn
* @param oc * @param oc
>>>>>>> web_backend_develope >>>>>>> web_backend_develope
* dblink * dblink
*/ */
public void createDBLink(Connection conn, OracleConnectorParams oc) { public void createDBLink(Connection conn, OracleConnectorParams oc) {
String linkName = "LinkTo" + oc.getName(); String linkName = "LinkTo" + oc.getName();
String sql = "CREATE PUBLIC DATABASE LINK " String sql = "CREATE PUBLIC DATABASE LINK "
+ linkName + linkName
+ " CONNECT TO " + " CONNECT TO "
+ oc.getUser() + oc.getUser()
+ " IDENTIFIED BY " + " IDENTIFIED BY "
+ oc.getPassword() + oc.getPassword()
+ " USING '(DESCRIPTION =(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = " + " USING '(DESCRIPTION =(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = "
+ oc.getIp() + ")(PORT = " + oc.getPort() + oc.getIp() + ")(PORT = " + oc.getPort()
+ ")))(CONNECT_DATA =(SERVICE_NAME =" + oc.getDatabaseName() + ")))(CONNECT_DATA =(SERVICE_NAME =" + oc.getDatabaseName()
+ ")))';"; + ")))';";
if (null != oc) { if (null != oc) {
if (hasSameNameDBLink(conn, linkName)) { // 如果dblink已经存在,先删除dblink在创建dblink if (hasSameNameDBLink(conn, linkName)) { // 如果dblink已经存在,先删除dblink在创建dblink
String deleteSql = "DROP PUBLIC DATABASE LINK LinkTo" String deleteSql = "DROP PUBLIC DATABASE LINK LinkTo"
+ linkName; + linkName;
FileOperateHelper FileOperateHelper
.fileWrite( .fileWrite(
Configs.EXTRACT_LOG_LOCALTION + oc.getName(), Configs.EXTRACT_LOG_LOCALTION + oc.getName(),
deleteSql); deleteSql);
if (oConnector.execOracleSQL(conn, deleteSql)) { if (oConnector.execOracleSQL(conn, deleteSql)) {
FileOperateHelper.fileWrite(Configs.EXTRACT_LOG_LOCALTION FileOperateHelper.fileWrite(Configs.EXTRACT_LOG_LOCALTION
+ oc.getName(), sql); + oc.getName(), sql);
oConnector.execOracleSQL(conn, sql); oConnector.execOracleSQL(conn, sql);
} else { } else {
Configs.CONSOLE_LOGGER.error("删除已有的DBLink失败,无法创建新的DBLink!"); Configs.CONSOLE_LOGGER.error("删除已有的DBLink失败,无法创建新的DBLink!");
FileOperateHelper.fileWrite(Configs.EXTRACT_LOG_LOCALTION FileOperateHelper.fileWrite(Configs.EXTRACT_LOG_LOCALTION
+ oc.getName(), "删除已有的DBLink失败,无法创建新的DBLink!"); + oc.getName(), "删除已有的DBLink失败,无法创建新的DBLink!");
} }
} else { } else {
// 否则创建dblink // 否则创建dblink
oConnector.execOracleSQL(conn, sql); oConnector.execOracleSQL(conn, sql);
FileOperateHelper.fileWrite( FileOperateHelper.fileWrite(
Configs.EXTRACT_LOG_LOCALTION + oc.getName(), sql); Configs.EXTRACT_LOG_LOCALTION + oc.getName(), sql);
} }
} }
} }
/** /**
* *
* *
* @param conn * @param conn
* @param oc * @param oc
* @return * @return
*/ */
public boolean createTableSpace(Connection conn, GatherOracleInfo oc) { public boolean createTableSpace(Connection conn, GatherOracleInfo oc) {
String tmpSql = "select TABLESPACE_NAME from dba_tablespaces where TABLESPACE_NAME = '" String tmpSql = "select TABLESPACE_NAME from dba_tablespaces where TABLESPACE_NAME = '"
+ Configs.GATHER_TABLESPACE_NAME + "'"; + Configs.GATHER_TABLESPACE_NAME + "'";
if (oConnector.execOracleSQL(conn, tmpSql)) { if (oConnector.execOracleSQL(conn, tmpSql)) {
return true; return true;
} else { } else {
String sql = "create tablespace " + Configs.GATHER_TABLESPACE_NAME String sql = "create tablespace " + Configs.GATHER_TABLESPACE_NAME
+ " datafile '" + Configs.GATHER_TABLESPACE_PATH + " datafile '" + Configs.GATHER_TABLESPACE_PATH
+ Configs.GATHER_TABLESPACE_NAME + ".dbf" + Configs.GATHER_TABLESPACE_NAME + ".dbf"
+ "' size 512M autoextend on next 512M maxsize unlimited"; + "' size 512M autoextend on next 512M maxsize unlimited";
return oConnector.execOracleSQL(conn, sql); return oConnector.execOracleSQL(conn, sql);
} }
} }
/** /**
* *
* *
* @param conn * @param conn
* @param oc * @param oc
*/ */
public void createUser(Connection conn, GatherOracleInfo oc) { public void createUser(Connection conn, GatherOracleInfo oc) {
String strTUser = oc.getName() + Configs.TABLE_SUFFIX; String strTUser = oc.getName() + Configs.TABLE_SUFFIX;
String sql = "Create user " + strTUser + " default tablespace " String sql = "Create user " + strTUser + " default tablespace "
+ Configs.GATHER_TABLESPACE_NAME + " identified by " + Configs.GATHER_TABLESPACE_NAME + " identified by "
+ Configs.GATHER_TABLE_PASSWORD; + Configs.GATHER_TABLE_PASSWORD;
String grantSql = "grant connect, resource, dba to " + strTUser; String grantSql = "grant connect, resource, dba to " + strTUser;
oConnector.execOracleSQL(conn, sql); oConnector.execOracleSQL(conn, sql);
oConnector.execOracleSQL(conn, grantSql); oConnector.execOracleSQL(conn, grantSql);
} }
/** /**
* *
* *
* @param conn * @param conn
* @param oc * @param oc
*/ */
public void extractColleDB(Connection conn, OracleConnectorParams oc) { public void extractColleDB(Connection conn, OracleConnectorParams oc) {
String strTUser = oc.getName() + Configs.TABLE_SUFFIX; String strTUser = oc.getName() + Configs.TABLE_SUFFIX;
String sql = "SELECT 'create table " String sql = "SELECT 'create table "
+ strTUser + strTUser
+ ".J'|| substr(t.OWNER||'_'||t.TABLE_NAME,0,29)||' as select * from '||t.OWNER||'.'||t.TABLE_NAME||" + ".J'|| substr(t.OWNER||'_'||t.TABLE_NAME,0,29)||' as select * from '||t.OWNER||'.'||t.TABLE_NAME||"
+ "'@linkTo" + "'@linkTo"
+ oc.getName() + oc.getName()
+ ";' FROM dba_tables@linkTo" + ";' FROM dba_tables@linkTo"
+ oc.getName() + oc.getName()
+ " t WHERE t.TABLESPACE_NAME NOT IN ('SYSTEM','SYSAUX')" + " t WHERE t.TABLESPACE_NAME NOT IN ('SYSTEM','SYSAUX')"
+ " and t.owner||t.table_name not in (select owner||table_name from dba_tables@linkTo" + " and t.owner||t.table_name not in (select owner||table_name from dba_tables@linkTo"
+ oc.getName() + " where 'data_type'='CLOB')"; + oc.getName() + " where 'data_type'='CLOB')";
ResultSet rsSet = oConnector.getSQLExecResultSet(conn, sql); ResultSet rsSet = oConnector.getSQLExecResultSet(conn, sql);
try { try {
while (rsSet.next()) { while (rsSet.next()) {
String resultSql = rsSet.getString(0); String resultSql = rsSet.getString(0);
oConnector.execOracleSQL(conn, resultSql); oConnector.execOracleSQL(conn, resultSql);
} }
} catch (SQLException e) { } catch (SQLException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
} }
} }

@ -1,24 +1,24 @@
package com.platform.service; package com.platform.service;
import com.platform.entities.OracleConnectorParams; import com.platform.entities.OracleConnectorParams;
import com.platform.oracle.OracleConnector; import com.platform.oracle.OracleConnector;
import com.platform.utils.Configs; import com.platform.utils.Configs;
public class OracleExtractService extends Thread implements Runnable { public class OracleExtractService extends Thread implements Runnable {
private OracleConnectorParams ocp; private OracleConnectorParams ocp;
private java.sql.Connection conn; private java.sql.Connection conn;
public OracleExtractService(OracleConnectorParams ocp){ public OracleExtractService(OracleConnectorParams ocp){
this.ocp=ocp; this.ocp=ocp;
String url = ""; 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);
} }
@Override @Override
public void run() { public void run() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
} }

@ -150,4 +150,4 @@ public class OracleStatusService {
return count; return count;
} }
} }
} }

@ -1,20 +1,20 @@
package com.platform.service; package com.platform.service;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import com.platform.entities.SimpleConfigParamsBean; import com.platform.entities.SimpleConfigParamsBean;
public class SimplePropertyReader { public class SimplePropertyReader {
@Autowired @Qualifier("simpeConfig") @Autowired @Qualifier("simpeConfig")
private SimpleConfigParamsBean configParamsBean; private SimpleConfigParamsBean configParamsBean;
public void setConfigParamsBean(SimpleConfigParamsBean configParamsBean) { public void setConfigParamsBean(SimpleConfigParamsBean configParamsBean) {
this.configParamsBean = configParamsBean; this.configParamsBean = configParamsBean;
} }
public SimpleConfigParamsBean getConfigParamsBean() { public SimpleConfigParamsBean getConfigParamsBean() {
return configParamsBean; return configParamsBean;
} }
} }

@ -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;
}
}

@ -1,141 +1,148 @@
package com.platform.service.impl; package com.platform.service.impl;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import javax.annotation.Resource; import javax.annotation.Resource;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.platform.dao.DataInfoDao; import com.platform.dao.DataInfoDao;
import com.platform.dao.DataInfoMoveTmpDao; import com.platform.dao.DataInfoMoveTmpDao;
import com.platform.entities.DataInfoEntity; import com.platform.entities.DataInfoEntity;
import com.platform.entities.DataInfoEntityMoveTmp; import com.platform.entities.DataInfoEntityMoveTmp;
import com.platform.glusterfs.CheckoutMD5; import com.platform.glusterfs.CheckoutMD5;
import com.platform.glusterfs.CopyData; import com.platform.glusterfs.CopyData;
import com.platform.glusterfs.ShowData; import com.platform.glusterfs.RemoveData;
import com.platform.service.IMoveDataService; import com.platform.glusterfs.ShowData;
import com.platform.utils.Bean2MapUtils; import com.platform.service.IMoveDataService;
import com.platform.utils.Constant; import com.platform.utils.Bean2MapUtils;
import com.platform.utils.DateForm; import com.platform.utils.Constant;
import com.platform.utils.DateForm;
@Component
@Service(value = "moveDataService") @Component
public class MoveDataServiceImpl implements IMoveDataService{ @Service(value = "moveDataService")
public class MoveDataServiceImpl implements IMoveDataService{
@Resource(name = "dataInfoDao")
private DataInfoDao dataInfoDao; @Resource(name = "dataInfoDao")
private DataInfoDao dataInfoDao;
/**
* private RemoveData removeservice = new RemoveData();
*/
CopyData copy = new CopyData(); /**
*
/** */
* MD5 CopyData copy = new CopyData();
*/
CheckoutMD5 check = new CheckoutMD5(); /**
* MD5
@Resource(name = "dataInfoMoveTmpDao") */
private DataInfoMoveTmpDao dataInfoMoveTmpDao; CheckoutMD5 check = new CheckoutMD5();
/** @Resource(name = "dataInfoMoveTmpDao")
* private DataInfoMoveTmpDao dataInfoMoveTmpDao;
*/
ShowData show = new ShowData(); /**
*
@Override */
public boolean moveData(List<DataInfoEntity> data, String dstPath) throws Exception { ShowData show = new ShowData();
boolean isSuccess = false;
String tailPath = ""; @Override
if (null != data) { public boolean moveData(List<DataInfoEntity> data, String dstPath) throws Exception {
//XXX/320198_16/1,or XXX/320122KFQ_15/1 ---> /320198_16/1, or /320122KFQ_15/1 boolean isSuccess = false;
List<DataInfoEntityMoveTmp> exist = dataInfoMoveTmpDao.findAll(); String tailPath = "";
List<String> existIds = new ArrayList<String>(); if (null != data) {
if (null != exist) { //XXX/320198_16/1,or XXX/320122KFQ_15/1 ---> /320198_16/1, or /320122KFQ_15/1
for (DataInfoEntityMoveTmp dataInfoEntityMoveTmp : exist) { List<DataInfoEntityMoveTmp> exist = dataInfoMoveTmpDao.findAll();
if ("0".equals(dataInfoEntityMoveTmp.getCompleteStatus()) || "1".equals(dataInfoEntityMoveTmp.getCompleteStatus())) { List<String> existIds = new ArrayList<String>();
if (null != dataInfoEntityMoveTmp.getDataPath()) { if (null != exist) {
existIds.add(dataInfoEntityMoveTmp.getDataPath()); for (DataInfoEntityMoveTmp dataInfoEntityMoveTmp : exist) {
} if ("0".equals(dataInfoEntityMoveTmp.getCompleteStatus()) || "1".equals(dataInfoEntityMoveTmp.getCompleteStatus())) {
} if (null != dataInfoEntityMoveTmp.getDataPath()) {
} existIds.add(dataInfoEntityMoveTmp.getDataPath());
} }
Pattern pattern = Pattern.compile("\\/\\d+[a-z]*[A-Z]*_\\d+\\/\\d*\\/*$"); }
// 末尾 含有 / }
Pattern pattern2 = Pattern.compile("\\/$"); }
Matcher matcher2 = pattern2.matcher(dstPath); Pattern pattern = Pattern.compile("\\/\\d+[a-z]*[A-Z]*_\\d+\\/\\d*\\/*$");
//去掉 最后 的 / 符合 // 末尾 含有 /
if (matcher2.find()) { Pattern pattern2 = Pattern.compile("\\/$");
dstPath = dstPath.substring(0, dstPath.length()-1); Matcher matcher2 = pattern2.matcher(dstPath);
} //去掉 最后 的 / 符合
List<DataInfoEntityMoveTmp> moveList = new ArrayList<DataInfoEntityMoveTmp>(); if (matcher2.find()) {
for (DataInfoEntity dataInfoEntity : data) { dstPath = dstPath.substring(0, dstPath.length()-1);
if (existIds.contains(dataInfoEntity.getDataPath())) { }
continue; List<DataInfoEntityMoveTmp> moveList = new ArrayList<DataInfoEntityMoveTmp>();
} for (DataInfoEntity dataInfoEntity : data) {
//TODO 正则:取出 data 的后面 的 路径eg: XXX/320198_16/1,or XXX/320122KFQ_15/1 if (existIds.contains(dataInfoEntity.getDataPath())) {
Matcher matcher = pattern.matcher(dataInfoEntity.getDataPath()); continue;
// tailPath 第一个字符是 / 符号 }
if (matcher.find()) { //TODO 正则:取出 data 的后面 的 路径eg: XXX/320198_16/1,or XXX/320122KFQ_15/1
tailPath = matcher.group(); Matcher matcher = pattern.matcher(dataInfoEntity.getDataPath());
} // tailPath 第一个字符是 / 符号
String finalDestPath = dstPath + tailPath; if (matcher.find()) {
DataInfoEntityMoveTmp dataMove = new DataInfoEntityMoveTmp(); tailPath = matcher.group();
dataMove.setSystemCode(dataInfoEntity.getSystemCode()); }
dataMove.setRegionalismCode(dataInfoEntity.getRegionalismCode()); String finalDestPath = dstPath + tailPath;
dataMove.setDstPath(finalDestPath); DataInfoEntityMoveTmp dataMove = new DataInfoEntityMoveTmp();
dataMove.setLastTime(DateForm.date2StringBysecond(new Date())); dataMove.setSystemCode(dataInfoEntity.getSystemCode());
moveList.add(dataMove); dataMove.setRegionalismCode(dataInfoEntity.getRegionalismCode());
} dataMove.setDstPath(finalDestPath);
if (moveList.size() > 0) { dataMove.setLastTime(DateForm.date2StringBysecond(new Date()));
dataInfoMoveTmpDao.insertBatch(moveList); dataMove.setFkid(dataInfoEntity.getId());
isSuccess = true; moveList.add(dataMove);
} }
} if (moveList.size() > 0) {
return isSuccess; dataInfoMoveTmpDao.insertBatch(moveList);
} isSuccess = true;
}
@Override }
public List<DataInfoEntityMoveTmp> findAll() throws Exception { return isSuccess;
List<DataInfoEntityMoveTmp> result = new ArrayList<DataInfoEntityMoveTmp>(); }
try {
result = dataInfoMoveTmpDao.findAll(); @Override
public List<DataInfoEntityMoveTmp> findAll() throws Exception {
} catch (Exception e) { List<DataInfoEntityMoveTmp> result = new ArrayList<DataInfoEntityMoveTmp>();
System.err.println(e); try {
} result = dataInfoMoveTmpDao.findAll();
return result;
} } catch (Exception e) {
System.err.println(e);
@Override }
public int delete(DataInfoEntityMoveTmp dataMove) throws Exception { return result;
int result = dataInfoMoveTmpDao.remove(dataMove.getId()); }
return result;
} @Override
public int delete(DataInfoEntityMoveTmp dataMove) throws Exception {
if ("1".equals(dataMove.getCompleteStatus())) {
@Override removeservice.deleteFolder(dataMove.getDstPath());
public int save(DataInfoEntityMoveTmp data) throws Exception { }
dataInfoMoveTmpDao.save(data); int result = dataInfoMoveTmpDao.remove(dataMove.getId());
return 0; return result;
} }
@Override
public int insertBatch(List<DataInfoEntityMoveTmp> list) throws Exception { @Override
// TODO Auto-generated method stub public int save(DataInfoEntityMoveTmp data) throws Exception {
return 0; dataInfoMoveTmpDao.save(data);
} return 0;
}
@Override
public int update(DataInfoEntityMoveTmp data) throws Exception { @Override
int result = dataInfoMoveTmpDao.update(data); public int insertBatch(List<DataInfoEntityMoveTmp> list) throws Exception {
return result; // TODO Auto-generated method stub
} return 0;
}
}
@Override
public int update(DataInfoEntityMoveTmp data) throws Exception {
int result = dataInfoMoveTmpDao.update(data);
return result;
}
}

@ -1,56 +1,56 @@
package com.platform.service.impl; package com.platform.service.impl;
import java.util.List; import java.util.List;
import javax.annotation.Resource; import javax.annotation.Resource;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.platform.dao.GatherOracleDao; import com.platform.dao.GatherOracleDao;
import com.platform.entities.GatherOracleInfo; import com.platform.entities.GatherOracleInfo;
import com.platform.service.IMySqlService; import com.platform.service.IMySqlService;
@Service(value = "mySqlService") @Service(value = "mySqlService")
public class MySqlServiceImpl implements IMySqlService{ public class MySqlServiceImpl implements IMySqlService{
@Resource(name = "gatherOracleDao") @Resource(name = "gatherOracleDao")
private GatherOracleDao gatherOracleDao; private GatherOracleDao gatherOracleDao;
@Override @Override
public List<GatherOracleInfo> findAllMySql() throws Exception { public List<GatherOracleInfo> findAllMySql() throws Exception {
List<GatherOracleInfo> result = gatherOracleDao.selectAllOracle(); List<GatherOracleInfo> result = gatherOracleDao.selectAllOracle();
return result; return result;
} }
@Override @Override
public int deleteMySql(int id) throws Exception { public int deleteMySql(int id) throws Exception {
int result = 0; int result = 0;
if (id > 0) { if (id > 0) {
// result = gatherOracleDao.deleteOracleById(id); // result = gatherOracleDao.deleteOracleById(id);
GatherOracleInfo oracle = new GatherOracleInfo(); GatherOracleInfo oracle = new GatherOracleInfo();
oracle.setId(id); oracle.setId(id);
oracle.setRemove("1"); oracle.setRemove("1");
result = gatherOracleDao.updateOracleById(oracle ); result = gatherOracleDao.updateOracleById(oracle );
} }
return result; return result;
} }
public int insertOracle(GatherOracleInfo oracle) throws Exception { public int insertOracle(GatherOracleInfo oracle) throws Exception {
int result = gatherOracleDao.insertOracle(oracle); int result = gatherOracleDao.insertOracle(oracle);
return result; return result;
} }
@Override @Override
public int updateOracle(GatherOracleInfo oracle) throws Exception { public int updateOracle(GatherOracleInfo oracle) throws Exception {
int result; int result;
if (oracle.getId() > 0) { if (oracle.getId() > 0) {
result = gatherOracleDao.updateOracleById(oracle); result = gatherOracleDao.updateOracleById(oracle);
} }
else { else {
result = gatherOracleDao.insertOracle(oracle); result = gatherOracleDao.insertOracle(oracle);
} }
return result; return result;
} }
} }

@ -1,63 +1,94 @@
package com.platform.service.impl; package com.platform.service.impl;
import java.sql.Connection; import java.sql.Connection;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.platform.entities.DataInfoEntity; import com.platform.entities.DataInfoEntity;
import com.platform.entities.GatherOracleInfo; import com.platform.entities.GatherOracleInfo;
import com.platform.entities.OracleConnectorParams; import com.platform.entities.OracleConnectorParams;
import com.platform.oracle.OracleConnector; import com.platform.oracle.OracleConnector;
import com.platform.service.IOracleExtractService; import com.platform.service.IOracleExtractService;
import com.platform.service.OracleExtractHelper; import com.platform.service.OracleExtractHelper;
import com.platform.utils.Bean2MapUtils; import com.platform.utils.Bean2MapUtils;
@Service(value = "OracleExtract") @Service(value = "OracleExtract")
public class OracleExtractServiceImpl implements IOracleExtractService { public class OracleExtractServiceImpl implements IOracleExtractService {
/** /**
* *
*/ */
private OracleExtractHelper oracleExtract = new OracleExtractHelper(); private OracleExtractHelper oracleExtract = new OracleExtractHelper();
/** /**
* *
*/ */
private OracleConnector connect = new OracleConnector(); private OracleConnector connect = new OracleConnector();
@Override @Override
public boolean extractOracle(String name, List<Map<String, String>> dataInfoMap, public boolean extractOracle(String name, List<Map<String, String>> dataInfoMap,
Map<String, String> oracleConnect) throws Exception { Map<String, String> oracleConnect) throws Exception {
boolean isSuccess = false; boolean isSuccess = false;
try{ try{
//map转 bean(汇总库信息-带tableName的) //map转 bean(汇总库信息-带tableName的)
GatherOracleInfo oracleModel = (GatherOracleInfo) Bean2MapUtils.convertMap(GatherOracleInfo.class, oracleConnect); GatherOracleInfo oracleModel = (GatherOracleInfo) Bean2MapUtils.convertMap(GatherOracleInfo.class, oracleConnect);
//采集库连接参数 //采集库连接参数
List<OracleConnectorParams> datainfos = new ArrayList<OracleConnectorParams>(); List<OracleConnectorParams> datainfos = new ArrayList<OracleConnectorParams>();
for (Map<String, String> map : dataInfoMap) { for (Map<String, String> map : dataInfoMap) {
OracleConnectorParams dataInfoEntity = (OracleConnectorParams) Bean2MapUtils.convertMap(OracleConnectorParams.class, oracleConnect); OracleConnectorParams dataInfoEntity = (OracleConnectorParams) Bean2MapUtils.convertMap(OracleConnectorParams.class, oracleConnect);
datainfos.add(dataInfoEntity); datainfos.add(dataInfoEntity);
} }
Connection conn = OracleConnector.ConnectionBuilder("jdbc:oracle:thin:@" + oracleModel.getIp() + ":" + oracleModel.getPort() + "/" Connection conn = OracleConnector.ConnectionBuilder("jdbc:oracle:thin:@" + oracleModel.getIp() + ":" + oracleModel.getPort() + "/"
+ oracleModel.getDatabaseName(), oracleModel.getUser(), oracleModel.getPassword()); + oracleModel.getDatabaseName(), oracleModel.getUser(), oracleModel.getPassword());
for (OracleConnectorParams collectOracle : datainfos) { for (OracleConnectorParams collectOracle : datainfos) {
oracleExtract.createDBLink(conn, collectOracle); oracleExtract.createDBLink(conn, collectOracle);
oracleExtract.createTableSpace(conn, oracleModel); oracleExtract.createTableSpace(conn, oracleModel);
oracleExtract.createUser(conn, oracleModel); oracleExtract.createUser(conn, oracleModel);
oracleExtract.extractColleDB(conn, collectOracle); oracleExtract.extractColleDB(conn, collectOracle);
} }
isSuccess = true; isSuccess = true;
}catch(Exception e){ }catch(Exception e){
} }
return false; 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;
// }
}

@ -1,158 +1,189 @@
package com.platform.service.thread; package com.platform.service.thread;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.regex.Matcher;
import javax.annotation.Resource; import java.util.regex.Pattern;
import org.springframework.scheduling.annotation.Scheduled; import javax.annotation.Resource;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service; import org.apache.log4j.Logger;
import org.springframework.scheduling.annotation.Scheduled;
import com.platform.dao.DataInfoDao; import org.springframework.stereotype.Component;
import com.platform.dao.DataInfoMoveTmpDao; import org.springframework.stereotype.Service;
import com.platform.dao.GatherOracleDao;
import com.platform.entities.DataInfoEntity; import com.platform.dao.DataInfoDao;
import com.platform.entities.DataInfoEntityMoveTmp; import com.platform.dao.DataInfoMoveTmpDao;
import com.platform.entities.GatherOracleInfo; import com.platform.dao.GatherOracleDao;
import com.platform.glusterfs.CheckoutMD5; import com.platform.entities.DataInfoEntity;
import com.platform.glusterfs.CopyData; import com.platform.entities.DataInfoEntityMoveTmp;
import com.platform.glusterfs.ShowData; import com.platform.entities.GatherOracleInfo;
import com.platform.service.DataInfoService; import com.platform.glusterfs.CheckoutMD5;
import com.platform.service.DataInfoServiceImp; import com.platform.glusterfs.CopyData;
import com.platform.service.IMoveDataService; import com.platform.glusterfs.ShowData;
import com.platform.service.impl.MoveDataServiceImpl; import com.platform.service.DataInfoService;
import com.platform.utils.Bean2MapUtils; import com.platform.service.DataInfoServiceImp;
import com.platform.utils.Constant; import com.platform.service.IMoveDataService;
import com.platform.utils.DateForm; import com.platform.service.impl.MoveDataServiceImpl;
import com.platform.utils.Bean2MapUtils;
@Component import com.platform.utils.Constant;
public class ThreadMoveData{ import com.platform.utils.DateForm;
@Resource(name = "dataInfoDao") @Component
private DataInfoDao dataInfoDao; public class ThreadMoveData{
/** public static Logger log = Logger.getLogger(ThreadMoveData.class);
*
*/ @Resource(name = "dataInfoDao")
CopyData copy = new CopyData(); private DataInfoDao dataInfoDao;
/** /**
* MD5 *
*/ */
CheckoutMD5 check = new CheckoutMD5(); CopyData copy = new CopyData();
@Resource(name = "dataInfoMoveTmpDao") /**
private DataInfoMoveTmpDao dataInfoMoveTmpDao; * MD5
*/
/** CheckoutMD5 check = new CheckoutMD5();
*
*/ @Resource(name = "dataInfoMoveTmpDao")
ShowData show = new ShowData(); private DataInfoMoveTmpDao dataInfoMoveTmpDao;
/** /**
* : -- *
*/ */
public ThreadMoveData() { ShowData show = new ShowData();
}
/**
//5秒 * : --
@Scheduled(fixedDelay = 5000) */
public void doSomething() { public ThreadMoveData() {
}
try {
List<DataInfoEntityMoveTmp> result = null; //5秒
//查询 表 move_data_tmp @Scheduled(fixedDelay = 5000)
result = dataInfoMoveTmpDao.findAll(); public void doSomething() {
if (null != result) {
//gfs 获取size try {
int rsize = result.size(); List<DataInfoEntityMoveTmp> result = null;
boolean isNoMove = true; //查询 表 move_data_tmp
//该循环必须 循环每个,不能有 break; result = dataInfoMoveTmpDao.findAll();
// rate:大小:假的,待换成真实比例 if (null != result) {
double realRate = 0.00; //gfs 获取size
for (int i = 0; i < rsize; i++) { int rsize = result.size();
DataInfoEntityMoveTmp dataMove = result.get(i); boolean isNoMove = true;
//如果拷贝进度超过20分钟未进行-- 判断为 迁移失败。 //该循环必须 循环每个,不能有 break;
// "1" :正在上传0等待 迁移, 2成功 3失败 // rate:大小:假的,待换成真实比例
if ("1".equals(dataMove.getCompleteStatus())) { double realRate = 0.00;
long nowTime = new Date().getTime(); int moveFileCurrNum = 0;
long timelong = nowTime - DateForm.string2DateBysecond(dataMove.getLastTime()).getTime(); for (int i = 0; i < rsize; i++) {
if (timelong > 1000*60*20) { DataInfoEntityMoveTmp dataMove = result.get(i);
dataMove.setCompleteStatus("3"); //如果拷贝进度超过20分钟未进行-- 判断为 迁移失败。
dataInfoMoveTmpDao.update(dataMove); // "1" :正在上传0等待 迁移, 2成功 3失败
} if ("1".equals(dataMove.getCompleteStatus())) {
isNoMove = false; long nowTime = new Date().getTime();
// 查询大小:。//gfs 获取size long timelong = nowTime - DateForm.string2DateBysecond(dataMove.getLastTime()).getTime();
long srcSize = show.getFolderSize(dataMove.getDataPath()); if (timelong > 1000*60*20) {
long dstSize = show.getFolderSize(dataMove.getDstPath()); dataMove.setCompleteStatus("3");
if (srcSize > 0 && dstSize > 0) { dataInfoMoveTmpDao.update(dataMove);
realRate = dstSize / srcSize * 100; }
dataMove.setRate((int) realRate); //正在上传的个数。
dataMove.setLastTime(DateForm.date2StringBysecond(new Date())); moveFileCurrNum++;
} if (moveFileCurrNum >= Constant.moveFileMaxNum) {
isNoMove = false;
} }
if("1".equals(dataMove.getCompleteStatus()) &&dataMove.getRate() > 0){ // 查询大小:。//gfs 获取size
//传输完毕:进行校验 long srcSize = show.getFolderSize(dataMove.getDataPath());
if (realRate == 100) { long dstSize = show.getFolderSize(dataMove.getDstPath());
//TODO 进行MD5校验 if (srcSize < 0) {
int resl = check.checkoutMD5Folder(dataMove.getDataPath(), dataMove.getDstPath()); log.error(dataMove.getDataPath() + " : 路径不存在! ");
//TODO 校验成功--则删除数据库记录 continue;
if(resl == 1){ }
//校验成功--修改 数据库记录-- if (dstSize < 0) {
dataMove.setCompleteStatus("2"); log.error(dataMove.getDstPath() + " : 路径不存在! ");
dataMove.setLastTime(DateForm.date2StringBysecond(new Date())); continue;
dataInfoMoveTmpDao.update(dataMove); }
//TODO 新增 一条数据-到-dataInfo if (srcSize > 0 && dstSize > 0) {
DataInfoEntity data = (DataInfoEntity) Bean2MapUtils.convertMap( realRate = (dstSize*100 / srcSize );
DataInfoEntity.class, Bean2MapUtils.convertBean(dataMove)); dataMove.setRate((int) realRate);
data.setDataPath(dataMove.getDstPath()); dataMove.setLastTime(DateForm.date2StringBysecond(new Date()));
data.setYear(dataMove.getYear()+" (迁移完成时间 " + DateForm.date2StringByMin(new Date())+")"); }
dataInfoDao.save(data); if (srcSize == dstSize) {
} realRate = 100;
else { }
// 3:表示 迁移失败 }
dataMove.setCompleteStatus("3"); if("1".equals(dataMove.getCompleteStatus()) &&dataMove.getRate() > 0){
} //传输完毕:进行校验
} if (realRate == 100) {
dataMove.setLastTime(DateForm.date2StringBysecond(new Date())); //TODO 进行MD5校验
dataInfoMoveTmpDao.update(dataMove); int resl = check.checkoutMD5Folder(dataMove.getDataPath(), dataMove.getDstPath());
} //TODO 校验成功--则删除数据库记录
} if(resl == 1){
//循环 完了, 确定没有上传的 ,没有正在上传的 //校验成功--修改 数据库记录--
if (isNoMove) { dataMove.setCompleteStatus("2");
//查询 表 move_data_tmp dataMove.setLastTime(DateForm.date2StringBysecond(new Date()));
result = dataInfoMoveTmpDao.findAll(); dataInfoMoveTmpDao.update(dataMove);
if (null != result) { //TODO 新增 一条数据-到-dataInfo
DataInfoEntity data = (DataInfoEntity) Bean2MapUtils.convertMap(
int tmpsize = result.size(); DataInfoEntity.class, Bean2MapUtils.convertBean(dataMove));
// 上传下一个后 data.setDataPath(dataMove.getDstPath());
for (int i = 0; i < tmpsize; i++) { data.setVolumeIp(dataMove.getDstVolumeIp());
DataInfoEntityMoveTmp next2move = result.get(i); data.setVolumePath(dataMove.getDstVolumePath());
//如果是 待 迁移状态的 data.setYear(DateForm.date2StringByMin(new Date()));
if ("0".equals(next2move.getCompleteStatus())) { dataInfoDao.save(data);
//待迁移的数据 -- 开始迁移 }
copy.copyFolderFilesAnyway(next2move.getDataPath(), next2move.getDstPath(), "app"); else {
// "1" :正在上传0等待 迁移, 2成功 3失败 // 3:表示 迁移失败
next2move.setCompleteStatus("1"); dataMove.setCompleteStatus("3");
next2move.setLastTime(DateForm.date2StringBysecond(new Date())); }
//更新sql }
dataInfoMoveTmpDao.update(next2move); dataMove.setLastTime(DateForm.date2StringBysecond(new Date()));
break; dataInfoMoveTmpDao.update(dataMove);
} }
} }
} //循环 完了, 确定没有上传的 ,没有正在上传的
} if (isNoMove) {
} //查询 表 move_data_tmp
result = dataInfoMoveTmpDao.findAll();
Thread.sleep(Constant.update_dataInfo_sleep_time); if (null != result) {
} catch (Exception e) {
System.err.println(e); int tmpsize = result.size();
} // 上传下一个后
for (int i = 0; i < tmpsize; i++) {
} DataInfoEntityMoveTmp next2move = result.get(i);
//如果是 待 迁移状态的
} if ("0".equals(next2move.getCompleteStatus())) {
//待迁移的数据 -- 开始迁移
// 末尾 含有 /
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()));
//更新sql
dataInfoMoveTmpDao.update(next2move);
break;
}
}
}
}
}
Thread.sleep(Constant.update_dataInfo_sleep_time);
} catch (Exception e) {
System.err.println(e);
}
}
}

@ -1,47 +1,47 @@
package com.platform.service.thread; package com.platform.service.thread;
import java.util.List; import java.util.List;
import javax.annotation.Resource; import javax.annotation.Resource;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.platform.dao.DataInfoMoveTmpDao; import com.platform.dao.DataInfoMoveTmpDao;
import com.platform.entities.DataInfoEntityMoveTmp; import com.platform.entities.DataInfoEntityMoveTmp;
import com.platform.service.IMoveDataService; import com.platform.service.IMoveDataService;
import com.platform.service.impl.MoveDataServiceImpl; import com.platform.service.impl.MoveDataServiceImpl;
import com.platform.utils.Constant; import com.platform.utils.Constant;
public class TreadMoveData2Start extends Thread{ public class TreadMoveData2Start extends Thread{
private IMoveDataService dataInfoMove= new MoveDataServiceImpl(); private IMoveDataService dataInfoMove= new MoveDataServiceImpl();
public TreadMoveData2Start() { public TreadMoveData2Start() {
} }
@Override @Override
public void run() { public void run() {
boolean isBreak = false; boolean isBreak = false;
while(true){ while(true){
if (isBreak) { if (isBreak) {
break; break;
} }
try { try {
List<DataInfoEntityMoveTmp> resultlist = dataInfoMove.findAll(); List<DataInfoEntityMoveTmp> resultlist = dataInfoMove.findAll();
for (DataInfoEntityMoveTmp moveEntity : resultlist) { for (DataInfoEntityMoveTmp moveEntity : resultlist) {
if ("1".equals(moveEntity.getCompleteStatus())) { if ("1".equals(moveEntity.getCompleteStatus())) {
moveEntity.setCompleteStatus("3"); moveEntity.setCompleteStatus("3");
dataInfoMove.update(moveEntity); dataInfoMove.update(moveEntity);
} }
} }
isBreak = true; isBreak = true;
Thread.sleep(Constant.update_dataInfo_sleep_time); Thread.sleep(Constant.update_dataInfo_sleep_time);
} catch (Exception e) { } catch (Exception e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
} }
} }
} }

@ -1,87 +1,87 @@
package com.platform.utils; package com.platform.utils;
import java.beans.BeanInfo; import java.beans.BeanInfo;
import java.beans.IntrospectionException; import java.beans.IntrospectionException;
import java.beans.Introspector; import java.beans.Introspector;
import java.beans.PropertyDescriptor; import java.beans.PropertyDescriptor;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
public class Bean2MapUtils { public class Bean2MapUtils {
/** /**
* Map JavaBean * Map JavaBean
* @param type * @param type
* @param map map * @param map map
* @return JavaBean * @return JavaBean
* @throws IntrospectionException * @throws IntrospectionException
* *
* @throws IllegalAccessException * @throws IllegalAccessException
* JavaBean * JavaBean
* @throws InstantiationException * @throws InstantiationException
* JavaBean * JavaBean
* @throws InvocationTargetException * @throws InvocationTargetException
* setter * setter
*/ */
public static Object convertMap(Class type, Map map) public static Object convertMap(Class type, Map map)
throws IntrospectionException, IllegalAccessException, throws IntrospectionException, IllegalAccessException,
InstantiationException, InvocationTargetException { InstantiationException, InvocationTargetException {
BeanInfo beanInfo = Introspector.getBeanInfo(type); // 获取类属性 BeanInfo beanInfo = Introspector.getBeanInfo(type); // 获取类属性
Object obj = type.newInstance(); // 创建 JavaBean 对象 Object obj = type.newInstance(); // 创建 JavaBean 对象
// 给 JavaBean 对象的属性赋值 // 给 JavaBean 对象的属性赋值
PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors(); PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
for (int i = 0; i< propertyDescriptors.length; i++) { for (int i = 0; i< propertyDescriptors.length; i++) {
PropertyDescriptor descriptor = propertyDescriptors[i]; PropertyDescriptor descriptor = propertyDescriptors[i];
String propertyName = descriptor.getName(); String propertyName = descriptor.getName();
try{ try{
if (map.containsKey(propertyName)) { if (map.containsKey(propertyName)) {
// 下面一句可以 try 起来,这样当一个属性赋值失败的时候就不会影响其他属性赋值。 // 下面一句可以 try 起来,这样当一个属性赋值失败的时候就不会影响其他属性赋值。
Object value = map.get(propertyName); Object value = map.get(propertyName);
Object[] args = new Object[1]; Object[] args = new Object[1];
args[0] = value; args[0] = value;
descriptor.getWriteMethod().invoke(obj, args); descriptor.getWriteMethod().invoke(obj, args);
} }
} }
catch(Exception e){ catch(Exception e){
} }
} }
return obj; return obj;
} }
/** /**
* JavaBean Map * JavaBean Map
* @param bean JavaBean * @param bean JavaBean
* @return Map * @return Map
* @throws IntrospectionException * @throws IntrospectionException
* @throws IllegalAccessException JavaBean * @throws IllegalAccessException JavaBean
* @throws InvocationTargetException setter * @throws InvocationTargetException setter
*/ */
public static Map convertBean(Object bean) public static Map convertBean(Object bean)
throws IntrospectionException, IllegalAccessException, InvocationTargetException { throws IntrospectionException, IllegalAccessException, InvocationTargetException {
Class type = bean.getClass(); Class type = bean.getClass();
Map returnMap = new HashMap(); Map returnMap = new HashMap();
BeanInfo beanInfo = Introspector.getBeanInfo(type); BeanInfo beanInfo = Introspector.getBeanInfo(type);
PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors(); PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
for (int i = 0; i< propertyDescriptors.length; i++) { for (int i = 0; i< propertyDescriptors.length; i++) {
PropertyDescriptor descriptor = propertyDescriptors[i]; PropertyDescriptor descriptor = propertyDescriptors[i];
String propertyName = descriptor.getName(); String propertyName = descriptor.getName();
if (!propertyName.equals("class")) { if (!propertyName.equals("class")) {
Method readMethod = descriptor.getReadMethod(); Method readMethod = descriptor.getReadMethod();
Object result = readMethod.invoke(bean, new Object[0]); Object result = readMethod.invoke(bean, new Object[0]);
if (result != null) { if (result != null) {
returnMap.put(propertyName, result); returnMap.put(propertyName, result);
} else { } else {
returnMap.put(propertyName, ""); returnMap.put(propertyName, "");
} }
} }
} }
return returnMap; return returnMap;
} }
} }

@ -1,84 +1,84 @@
package com.platform.utils; package com.platform.utils;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.Properties; import java.util.Properties;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
public class ConfigLoder { public class ConfigLoder {
private String configPath; private String configPath;
private volatile static ConfigLoder configLoder; private volatile static ConfigLoder configLoder;
private ConfigLoder(String configPath) { private ConfigLoder(String configPath) {
this.configPath = configPath; this.configPath = configPath;
} }
public static ConfigLoder Builder(String configPtah) { public static ConfigLoder Builder(String configPtah) {
if (null == configLoder) { if (null == configLoder) {
synchronized (ConfigLoder.class) { synchronized (ConfigLoder.class) {
if (null == configLoder) if (null == configLoder)
configLoder = new ConfigLoder(configPtah); configLoder = new ConfigLoder(configPtah);
} }
} }
return configLoder; return configLoder;
} }
/** /**
* Property * Property
* *
* @param key * @param key
* @return * @return
*/ */
public String getProperty(String key) { public String getProperty(String key) {
String value = null; String value = null;
if (StringUtils.isEmpty(key)) if (StringUtils.isEmpty(key))
return value; return value;
try { try {
InputStream is = new BufferedInputStream(new FileInputStream( InputStream is = new BufferedInputStream(new FileInputStream(
new File(configPath))); new File(configPath)));
Properties properties = new Properties(); Properties properties = new Properties();
properties.load(is); properties.load(is);
value = properties.getProperty(key); value = properties.getProperty(key);
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} catch (IOException e) { } catch (IOException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
return value; return value;
} }
public Properties getProperties() { public Properties getProperties() {
Properties properties = null; Properties properties = null;
try { try {
InputStream is; InputStream is;
properties = new Properties(); properties = new Properties();
is = new BufferedInputStream(new FileInputStream(new File( is = new BufferedInputStream(new FileInputStream(new File(
configPath))); configPath)));
properties.load(is); properties.load(is);
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} catch (IOException e) { } catch (IOException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
return properties; return properties;
} }
public String getConfigPath() { public String getConfigPath() {
return configPath; return configPath;
} }
public void setConfigPath(String configPath) { public void setConfigPath(String configPath) {
this.configPath = configPath; this.configPath = configPath;
} }
} }

@ -1,84 +1,84 @@
package com.platform.utils; package com.platform.utils;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.Properties; import java.util.Properties;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
public class ConfigPropertyReader { public class ConfigPropertyReader {
private String configPath; private String configPath;
private volatile static ConfigPropertyReader configLoder; private volatile static ConfigPropertyReader configLoder;
private ConfigPropertyReader(String configPath) { private ConfigPropertyReader(String configPath) {
this.configPath = configPath; this.configPath = configPath;
} }
public static ConfigPropertyReader Builder(String configPtah) { public static ConfigPropertyReader Builder(String configPtah) {
if (null == configLoder) { if (null == configLoder) {
synchronized (ConfigPropertyReader.class) { synchronized (ConfigPropertyReader.class) {
if (null == configLoder) if (null == configLoder)
configLoder = new ConfigPropertyReader(configPtah); configLoder = new ConfigPropertyReader(configPtah);
} }
} }
return configLoder; return configLoder;
} }
/** /**
* Property * Property
* *
* @param key * @param key
* @return * @return
*/ */
public synchronized String getProperty(String key) { public synchronized String getProperty(String key) {
String value = null; String value = null;
if (StringUtils.isEmpty(key)) if (StringUtils.isEmpty(key))
return value; return value;
try { try {
InputStream is = new BufferedInputStream(new FileInputStream( InputStream is = new BufferedInputStream(new FileInputStream(
new File(configPath))); new File(configPath)));
Properties properties = new Properties(); Properties properties = new Properties();
properties.load(is); properties.load(is);
value = properties.getProperty(key); value = properties.getProperty(key);
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} catch (IOException e) { } catch (IOException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
return value; return value;
} }
public Properties getProperties() { public Properties getProperties() {
Properties properties = null; Properties properties = null;
try { try {
InputStream is; InputStream is;
properties = new Properties(); properties = new Properties();
is = new BufferedInputStream(new FileInputStream(new File( is = new BufferedInputStream(new FileInputStream(new File(
configPath))); configPath)));
properties.load(is); properties.load(is);
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} catch (IOException e) { } catch (IOException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
return properties; return properties;
} }
public String getConfigPath() { public String getConfigPath() {
return configPath; return configPath;
} }
public void setConfigPath(String configPath) { public void setConfigPath(String configPath) {
this.configPath = configPath; this.configPath = configPath;
} }
} }

@ -1,52 +1,52 @@
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.113:8080/"; // kubernetes集群的maser public static String KUBE_MASTER_URL = "http://192.168.0.113: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 = "/home/log"; //数据汇总日志保存位置 public static String EXTRACT_LOG_LOCALTION = "/home/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=""; //登入密码 public static String GATHER_TABLE_PASSWORD=""; //登入密码
} }

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

@ -1,137 +1,137 @@
package com.platform.utils; package com.platform.utils;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
public class DateForm { public class DateForm {
private static final String date_format_second = "yyyy-MM-dd HH:mm:ss"; private static final String date_format_second = "yyyy-MM-dd HH:mm:ss";
private static final String date_format_second_non = "yyyy-MM-dd_HH-mm-ss"; private static final String date_format_second_non = "yyyy-MM-dd_HH-mm-ss";
private static final String data_format_min = "yyyy-MM-dd HH:mm"; private static final String data_format_min = "yyyy-MM-dd HH:mm";
private static final String data_format_day = "yyyy-MM-dd"; private static final String data_format_day = "yyyy-MM-dd";
private static ThreadLocal<DateFormat> threadLocal_second = new ThreadLocal<DateFormat>(); private static ThreadLocal<DateFormat> threadLocal_second = new ThreadLocal<DateFormat>();
private static ThreadLocal<DateFormat> threadLocal_second_non = new ThreadLocal<DateFormat>(); private static ThreadLocal<DateFormat> threadLocal_second_non = new ThreadLocal<DateFormat>();
private static ThreadLocal<DateFormat> threadLocal_min = new ThreadLocal<DateFormat>(); private static ThreadLocal<DateFormat> threadLocal_min = new ThreadLocal<DateFormat>();
private static ThreadLocal<DateFormat> threadLocal_day = new ThreadLocal<DateFormat>(); private static ThreadLocal<DateFormat> threadLocal_day = new ThreadLocal<DateFormat>();
public static String date2StringBysecond(Date date) { public static String date2StringBysecond(Date date) {
if (date == null) { if (date == null) {
return null; return null;
} }
DateFormat format = threadLocal_second.get(); DateFormat format = threadLocal_second.get();
if(format == null){ if(format == null){
format = new SimpleDateFormat(date_format_second); format = new SimpleDateFormat(date_format_second);
threadLocal_second.set(format); threadLocal_second.set(format);
} }
return format.format(date); return format.format(date);
} }
public static String date2StringBysecondNon(Date date) { public static String date2StringBysecondNon(Date date) {
if (date == null) { if (date == null) {
return null; return null;
} }
DateFormat format = threadLocal_second_non.get(); DateFormat format = threadLocal_second_non.get();
if(format == null){ if(format == null){
format = new SimpleDateFormat(date_format_second_non); format = new SimpleDateFormat(date_format_second_non);
threadLocal_second_non.set(format); threadLocal_second_non.set(format);
} }
return format.format(date); return format.format(date);
} }
public static String date2StringByMin(Date date) { public static String date2StringByMin(Date date) {
if (date == null) { if (date == null) {
return null; return null;
} }
DateFormat format = threadLocal_min.get(); DateFormat format = threadLocal_min.get();
if(format == null){ if(format == null){
format = new SimpleDateFormat(data_format_min); format = new SimpleDateFormat(data_format_min);
threadLocal_min.set(format); threadLocal_min.set(format);
} }
return format.format(date); return format.format(date);
} }
public static String date2StringByDay(Date date) { public static String date2StringByDay(Date date) {
if (date == null) { if (date == null) {
return null; return null;
} }
DateFormat format = threadLocal_day.get(); DateFormat format = threadLocal_day.get();
if(format == null){ if(format == null){
format = new SimpleDateFormat(data_format_day); format = new SimpleDateFormat(data_format_day);
threadLocal_day.set(format); threadLocal_day.set(format);
} }
return format.format(date); return format.format(date);
} }
public static Date string2DateBysecond(String date) { public static Date string2DateBysecond(String date) {
if (date == null) { if (date == null) {
return null; return null;
} }
date = date.trim(); date = date.trim();
if (date.isEmpty()) { if (date.isEmpty()) {
return null; return null;
} }
DateFormat format = threadLocal_second.get(); DateFormat format = threadLocal_second.get();
try { try {
if(format == null){ if(format == null){
format = new SimpleDateFormat(date_format_second); format = new SimpleDateFormat(date_format_second);
threadLocal_second.set(format); threadLocal_second.set(format);
} }
return format.parse(date); return format.parse(date);
} catch (ParseException e) { } catch (ParseException e) {
e.printStackTrace(); e.printStackTrace();
} }
return null; return null;
} }
public static Date string2DateByMin(String date) { public static Date string2DateByMin(String date) {
if (date == null) { if (date == null) {
return null; return null;
} }
date = date.trim(); date = date.trim();
if (date.isEmpty()) { if (date.isEmpty()) {
return null; return null;
} }
DateFormat format = threadLocal_min.get(); DateFormat format = threadLocal_min.get();
try { try {
if(format == null){ if(format == null){
format = new SimpleDateFormat(data_format_min); format = new SimpleDateFormat(data_format_min);
threadLocal_min.set(format); threadLocal_min.set(format);
} }
return format.parse(date); return format.parse(date);
} catch (ParseException e) { } catch (ParseException e) {
e.printStackTrace(); e.printStackTrace();
} }
return null; return null;
} }
public static Date string2DateByDay(String date) { public static Date string2DateByDay(String date) {
if (date == null) { if (date == null) {
return null; return null;
} }
date = date.trim(); date = date.trim();
if (date.isEmpty()) { if (date.isEmpty()) {
return null; return null;
} }
DateFormat format = threadLocal_day.get(); DateFormat format = threadLocal_day.get();
try { try {
if(format == null){ if(format == null){
format = new SimpleDateFormat(data_format_day); format = new SimpleDateFormat(data_format_day);
threadLocal_day.set(format); threadLocal_day.set(format);
} }
return format.parse(date); return format.parse(date);
} catch (ParseException e) { } catch (ParseException e) {
e.printStackTrace(); e.printStackTrace();
} }
return null; return null;
} }
} }

@ -1,9 +1,9 @@
package com.platform.utils; package com.platform.utils;
import java.util.Date; import java.util.Date;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
public class DateHandle { public class DateHandle {
public static String getNow() { public static String getNow() {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格å¼<C3A5> SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格å¼<C3A5>
return df.format(new Date());// new Date()为获å<C2B7>当å‰<C3A5>系统时é—? return df.format(new Date());// new Date()为获å<C2B7>当å‰<C3A5>系统时é—?
} }
} }

@ -1,95 +1,95 @@
package com.platform.utils; package com.platform.utils;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import org.junit.Test; import org.junit.Test;
/** /**
* *
* *
* @author wuming * @author wuming
* *
*/ */
public class FileOperateHelper { public class FileOperateHelper {
/** /**
* *
* *
* @param path * @param path
* @param message * @param message
*/ */
@SuppressWarnings("resource") @SuppressWarnings("resource")
public static void fileWrite(String path, String message) { public static void fileWrite(String path, String message) {
try { try {
File file = new File(path); File file = new File(path);
if (file.exists()) if (file.exists())
file.createNewFile(); file.createNewFile();
FileOutputStream out = new FileOutputStream(file, true); // 如果追加方式用true FileOutputStream out = new FileOutputStream(file, true); // 如果追加方式用true
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
sb.append(message).append("\n"); sb.append(message).append("\n");
out.write(sb.toString().getBytes("utf-8")); out.write(sb.toString().getBytes("utf-8"));
} catch (IOException e) { } catch (IOException e) {
// TODO: handle exception // TODO: handle exception
} }
} }
/** /**
* *
* @param path * @param path
* @return * @return
*/ */
@SuppressWarnings("resource") @SuppressWarnings("resource")
public static String fileReader(String path) { public static String fileReader(String path) {
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
String tempString = ""; String tempString = "";
try { try {
File file = new File(path); File file = new File(path);
if (!file.exists()) if (!file.exists())
return ""; return "";
FileInputStream fis = new FileInputStream(file); FileInputStream fis = new FileInputStream(file);
BufferedReader br = new BufferedReader(new InputStreamReader(fis)); BufferedReader br = new BufferedReader(new InputStreamReader(fis));
while ((tempString = br.readLine()) != null) { while ((tempString = br.readLine()) != null) {
sb.append(tempString); sb.append(tempString);
} }
} catch (Exception e) { } catch (Exception e) {
// TODO: handle exception // TODO: handle exception
} }
return sb.toString(); return sb.toString();
} }
/** /**
* *
* @param path * @param path
* @return * @return
*/ */
@SuppressWarnings("resource") @SuppressWarnings("resource")
public static String fileReaderAndendline(String path) { public static String fileReaderAndendline(String path) {
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
String tempString = ""; String tempString = "";
try { try {
File file = new File(path); File file = new File(path);
if (!file.exists()) if (!file.exists())
return ""; return "";
FileInputStream fis = new FileInputStream(file); FileInputStream fis = new FileInputStream(file);
BufferedReader br = new BufferedReader(new InputStreamReader(fis)); BufferedReader br = new BufferedReader(new InputStreamReader(fis));
while ((tempString = br.readLine()) != null) { while ((tempString = br.readLine()) != null) {
sb.append(tempString+"\n"); sb.append(tempString+"\n");
} }
} catch (Exception e) { } catch (Exception e) {
// TODO: handle exception // TODO: handle exception
} }
return sb.toString(); return sb.toString();
} }
} }

@ -1,268 +1,268 @@
package com.platform.utils; package com.platform.utils;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator; import org.apache.log4j.PropertyConfigurator;
import ch.ethz.ssh2.Connection; import ch.ethz.ssh2.Connection;
import ch.ethz.ssh2.Session; import ch.ethz.ssh2.Session;
import ch.ethz.ssh2.StreamGobbler; import ch.ethz.ssh2.StreamGobbler;
import ch.ethz.ssh2.*; import ch.ethz.ssh2.*;
public class GanymedSSH { public class GanymedSSH {
public static Logger log = Logger.getLogger(GanymedSSH.class); public static Logger log = Logger.getLogger(GanymedSSH.class);
Connection conn; Connection conn;
public boolean status = true;// 锟角凤拷锟斤拷锟街达拷锟斤拷锟斤拷锟阶刺<E998B6> public boolean status = true;// 锟角凤拷锟斤拷锟街达拷锟斤拷锟斤拷锟阶刺<E998B6>
public GanymedSSH() { public GanymedSSH() {
// TODO Auto-generated constructor stub // TODO Auto-generated constructor stub
} }
public GanymedSSH(String host, String username, String password, int port) { public GanymedSSH(String host, String username, String password, int port) {
// TODO Auto-generated constructor stub // TODO Auto-generated constructor stub
try { try {
conn = getOpenedConnection(host, username, password, port); conn = getOpenedConnection(host, username, password, port);
} catch (IOException e) { } catch (IOException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
} }
public Connection getOpenedConnection(String host, String username, String password, int port) public Connection getOpenedConnection(String host, String username, String password, int port)
throws IOException { throws IOException {
conn = new Connection(host, port); conn = new Connection(host, port);
conn.connect(); // make sure the connection is opened conn.connect(); // make sure the connection is opened
boolean isAuthenticated = conn.authenticateWithPassword(username, password); boolean isAuthenticated = conn.authenticateWithPassword(username, password);
if (isAuthenticated == false) if (isAuthenticated == false)
throw new IOException("Authentication failed."); throw new IOException("Authentication failed.");
return conn; return conn;
} }
public void execCmdNoWaitAcquiescent(String cmd) { public void execCmdNoWaitAcquiescent(String cmd) {
String host=Constant.hostIp; String host=Constant.hostIp;
String username=Constant.rootUser; String username=Constant.rootUser;
String password=Constant.rootPasswd; String password=Constant.rootPasswd;
int port=Constant.port; int port=Constant.port;
Session sess = null; Session sess = null;
try { try {
sess = conn.openSession(); sess = conn.openSession();
// 执锟斤拷cmd // 执锟斤拷cmd
sess.execCommand(cmd); sess.execCommand(cmd);
} catch (IOException e) { } catch (IOException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} finally { } finally {
sess.close(); sess.close();
} }
} }
public void execCmdNoWait(String host, String username, String password, int port, String cmd) { public void execCmdNoWait(String host, String username, String password, int port, String cmd) {
Session sess = null; Session sess = null;
try { try {
conn = getOpenedConnection(host, username, password, port); conn = getOpenedConnection(host, username, password, port);
sess = conn.openSession(); sess = conn.openSession();
// 执锟斤拷cmd // 执锟斤拷cmd
sess.execCommand(cmd); sess.execCommand(cmd);
} catch (IOException e) { } catch (IOException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} finally { } finally {
sess.close(); sess.close();
} }
} }
public List<String> execCmdWaitAcquiescent(String cmd) { public List<String> execCmdWaitAcquiescent(String cmd) {
String host=Constant.hostIp; String host=Constant.hostIp;
String username=Constant.rootUser; String username=Constant.rootUser;
String password=Constant.rootPasswd; String password=Constant.rootPasswd;
int port=Constant.port; int port=Constant.port;
List<String> reStrings = new ArrayList<String>(); List<String> reStrings = new ArrayList<String>();
Session sess = null; Session sess = null;
try { try {
sess = conn.openSession(); sess = conn.openSession();
// 执锟斤拷cmd // 执锟斤拷cmd
sess.execCommand(cmd); sess.execCommand(cmd);
InputStream stdout = new StreamGobbler(sess.getStdout()); InputStream stdout = new StreamGobbler(sess.getStdout());
InputStream stderr = new StreamGobbler(sess.getStderr()); InputStream stderr = new StreamGobbler(sess.getStderr());
BufferedReader stdoutReader = new BufferedReader(new InputStreamReader(stdout)); BufferedReader stdoutReader = new BufferedReader(new InputStreamReader(stdout));
BufferedReader stderrReader = new BufferedReader(new InputStreamReader(stderr)); BufferedReader stderrReader = new BufferedReader(new InputStreamReader(stderr));
while (true) { while (true) {
String line = stderrReader.readLine(); String line = stderrReader.readLine();
if (line != null) { if (line != null) {
// System.out.println(line); // System.out.println(line);
reStrings.add(line); reStrings.add(line);
} else { } else {
break; break;
} }
} }
if(reStrings.size()==0){ if(reStrings.size()==0){
while (true) { while (true) {
String line = stdoutReader.readLine(); String line = stdoutReader.readLine();
if (line != null) { if (line != null) {
// System.out.println(line); // System.out.println(line);
reStrings.add(line); reStrings.add(line);
} else { } else {
break; break;
} }
} }
} }
} catch (IOException e) { } catch (IOException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} finally { } finally {
sess.close(); sess.close();
} }
return reStrings; return reStrings;
} }
public List<String> execCmdWait(String host, String username, String password, int port, String cmd) { public List<String> execCmdWait(String host, String username, String password, int port, String cmd) {
List<String> reStrings = new ArrayList<String>(); List<String> reStrings = new ArrayList<String>();
Session sess = null; Session sess = null;
try { try {
sess = conn.openSession(); sess = conn.openSession();
// 执锟斤拷cmd // 执锟斤拷cmd
sess.execCommand(cmd); sess.execCommand(cmd);
InputStream stdout = new StreamGobbler(sess.getStdout()); InputStream stdout = new StreamGobbler(sess.getStdout());
InputStream stderr = new StreamGobbler(sess.getStderr()); InputStream stderr = new StreamGobbler(sess.getStderr());
BufferedReader stdoutReader = new BufferedReader(new InputStreamReader(stdout)); BufferedReader stdoutReader = new BufferedReader(new InputStreamReader(stdout));
BufferedReader stderrReader = new BufferedReader(new InputStreamReader(stderr)); BufferedReader stderrReader = new BufferedReader(new InputStreamReader(stderr));
while (true) { while (true) {
String line = stdoutReader.readLine(); String line = stdoutReader.readLine();
if (line != null) { if (line != null) {
// System.out.println(line); // System.out.println(line);
reStrings.add(line); reStrings.add(line);
} else { } else {
break; break;
} }
} }
if(reStrings.size()==0){ if(reStrings.size()==0){
while (true) { while (true) {
String line = stderrReader.readLine(); String line = stderrReader.readLine();
if (line != null) { if (line != null) {
// System.out.println(line); // System.out.println(line);
reStrings.add(line); reStrings.add(line);
} else { } else {
break; break;
} }
} }
} }
} catch (IOException e) { } catch (IOException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} finally { } finally {
sess.close(); sess.close();
} }
return reStrings; return reStrings;
} }
public Map<String, String> execMD5cmd(String cmd) { public Map<String, String> execMD5cmd(String cmd) {
Map<String, String> md5 = new HashMap<String, String>(); Map<String, String> md5 = new HashMap<String, String>();
Session sess = null; Session sess = null;
try { try {
sess = conn.openSession(); sess = conn.openSession();
// 执锟斤拷cmd // 执锟斤拷cmd
sess.execCommand(cmd); sess.execCommand(cmd);
InputStream stdout = new StreamGobbler(sess.getStdout()); InputStream stdout = new StreamGobbler(sess.getStdout());
InputStream stderr = new StreamGobbler(sess.getStderr()); InputStream stderr = new StreamGobbler(sess.getStderr());
BufferedReader stdoutReader = new BufferedReader(new InputStreamReader(stdout)); BufferedReader stdoutReader = new BufferedReader(new InputStreamReader(stdout));
BufferedReader stderrReader = new BufferedReader(new InputStreamReader(stderr)); BufferedReader stderrReader = new BufferedReader(new InputStreamReader(stderr));
while (true) { while (true) {
String line = stdoutReader.readLine(); String line = stdoutReader.readLine();
if (line != null) { if (line != null) {
String[] lines = line.split(" "); String[] lines = line.split(" ");
String key = lines[1].trim(); String key = lines[1].trim();
String value = lines[0].trim(); String value = lines[0].trim();
md5.put(key, value); md5.put(key, value);
} else { } else {
break; break;
} }
} }
} catch (IOException e) { } catch (IOException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} finally { } finally {
sess.close(); sess.close();
} }
return md5; return md5;
} }
public String execGetSize(String cmd) { public String execGetSize(String cmd) {
status = false; status = false;
String str_size = "0"; String str_size = "0";
Session sess = null; Session sess = null;
try { try {
// 执锟斤拷cmd // 执锟斤拷cmd
sess = conn.openSession(); sess = conn.openSession();
sess.execCommand(cmd); sess.execCommand(cmd);
InputStream stdout = new StreamGobbler(sess.getStdout()); InputStream stdout = new StreamGobbler(sess.getStdout());
@SuppressWarnings("resource") @SuppressWarnings("resource")
BufferedReader br = new BufferedReader(new InputStreamReader(stdout)); BufferedReader br = new BufferedReader(new InputStreamReader(stdout));
while (true) { while (true) {
String line = br.readLine(); String line = br.readLine();
if (line != null) { if (line != null) {
// String[] lines=line.split(" "); // String[] lines=line.split(" ");
// str_size=lines[0]; // str_size=lines[0];
str_size = line; str_size = line;
} else { } else {
break; break;
} }
} }
} catch (IOException e) { } catch (IOException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} finally { } finally {
sess.close(); sess.close();
} }
status = true; status = true;
return str_size; return str_size;
} }
public static void main(String[] args) { public static void main(String[] args) {
PropertyConfigurator.configure("log4j.properties"); PropertyConfigurator.configure("log4j.properties");
} }
} }

@ -1,60 +1,60 @@
package com.platform.utils; package com.platform.utils;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.apache.log4j.*; import org.apache.log4j.*;
public class RunCommand { public class RunCommand {
public static Logger log = Logger.getLogger(RunCommand.class); public static Logger log = Logger.getLogger(RunCommand.class);
public List<String> runCommandWait(String command) { public List<String> runCommandWait(String command) {
List<String> reStrings = null; List<String> reStrings = null;
String cmds[] = { "/bin/bash", "-c", command }; String cmds[] = { "/bin/bash", "-c", command };
try { try {
Process ps = Runtime.getRuntime().exec(cmds); Process ps = Runtime.getRuntime().exec(cmds);
ps.waitFor(); ps.waitFor();
BufferedReader br = new BufferedReader(new InputStreamReader(ps.getInputStream())); BufferedReader br = new BufferedReader(new InputStreamReader(ps.getInputStream()));
reStrings = new ArrayList<String>(); reStrings = new ArrayList<String>();
String line; String line;
while ((line = br.readLine()) != null) { while ((line = br.readLine()) != null) {
reStrings.add(line); reStrings.add(line);
// System.out.println(line); // System.out.println(line);
} }
br = new BufferedReader(new InputStreamReader(ps.getErrorStream())); br = new BufferedReader(new InputStreamReader(ps.getErrorStream()));
reStrings = new ArrayList<String>(); reStrings = new ArrayList<String>();
while ((line = br.readLine()) != null) { while ((line = br.readLine()) != null) {
reStrings.add(line); reStrings.add(line);
// System.out.println(line); // System.out.println(line);
} }
} catch (Exception e) { } catch (Exception e) {
log.error("0001 runCommandWait is error"); log.error("0001 runCommandWait is error");
e.printStackTrace(); e.printStackTrace();
} }
return reStrings; return reStrings;
} }
public int runCommand(String command) { public int runCommand(String command) {
List<String> reStrings = null; List<String> reStrings = null;
String cmds[] = { "/bin/bash", "-c", command }; String cmds[] = { "/bin/bash", "-c", command };
try { try {
Process ps = Runtime.getRuntime().exec(cmds); Process ps = Runtime.getRuntime().exec(cmds);
} catch (Exception e) { } catch (Exception e) {
log.error("0002 runCommand execute " + command + " is error"); log.error("0002 runCommand execute " + command + " is error");
e.printStackTrace(); e.printStackTrace();
return -1; return -1;
} }
return 1; return 1;
} }
} }

@ -1,31 +1,31 @@
/** /**
* : Support.java * : Support.java
* : </> * : </>
* : <> * : <>
* @author liliy * @author liliy
* : <> * : <>
* 2016912 * 2016912
* <> * <>
*/ */
package com.platform.utils; package com.platform.utils;
import java.util.regex.Pattern; import java.util.regex.Pattern;
/** /**
* <> * <>
* <> * <>
* @author liliy * @author liliy
* @version [2016912] * @version [2016912]
* @see [/] * @see [/]
* @since [/] * @since [/]
*/ */
public class Support { public class Support {
public static boolean checkIP(String str) { public static boolean checkIP(String str) {
Pattern pattern = Pattern Pattern pattern = Pattern
.compile("^((\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5]" .compile("^((\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5]"
+ "|[*])\\.){3}(\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5]|[*])$"); + "|[*])\\.){3}(\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5]|[*])$");
return pattern.matcher(str).matches(); return pattern.matcher(str).matches();
} }
} }

@ -1,14 +1,14 @@
package com.platform.utils; package com.platform.utils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class TestSupport { public class TestSupport {
public List<String> strToList(String str) { public List<String> strToList(String str) {
List<String> reStrings=new ArrayList<String>(); List<String> reStrings=new ArrayList<String>();
for(String one:str.split("\n")){ for(String one:str.split("\n")){
reStrings.add(one); reStrings.add(one);
} }
return reStrings; return reStrings;
} }
} }

@ -1,124 +1,124 @@
package com.platform.utils; package com.platform.utils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.platform.entities.Brick; import com.platform.entities.Brick;
import com.platform.entities.FolderNode; import com.platform.entities.FolderNode;
import com.platform.entities.VolumeEntity; import com.platform.entities.VolumeEntity;
import com.platform.glusterfs.ClusterInfo; import com.platform.glusterfs.ClusterInfo;
import com.platform.glusterfs.GetTreeData; import com.platform.glusterfs.GetTreeData;
import com.platform.glusterfs.VolumeInfo; import com.platform.glusterfs.VolumeInfo;
public class ThreadVolume extends Thread implements Runnable{ public class ThreadVolume extends Thread implements Runnable{
/** /**
* -- * --
*/ */
private static String pointPath = "/home"; private static String pointPath = "/home";
/** Volume信息查询 */ /** Volume信息查询 */
private VolumeInfo volumeInfo = new VolumeInfo(); private VolumeInfo volumeInfo = new VolumeInfo();
private ClusterInfo cluster = new ClusterInfo(); private ClusterInfo cluster = new ClusterInfo();
public ThreadVolume() { public ThreadVolume() {
// TODO Auto-generated constructor stub // TODO Auto-generated constructor stub
} }
public ThreadVolume(String path) { public ThreadVolume(String path) {
if (null != path && !"".equals(path.trim())) { if (null != path && !"".equals(path.trim())) {
ThreadVolume.pointPath = path; ThreadVolume.pointPath = path;
} }
} }
/** gfs目录树形展示 */ /** gfs目录树形展示 */
private GetTreeData gfsTree = new GetTreeData(); private GetTreeData gfsTree = new GetTreeData();
@Override @Override
public void run() { public void run() {
super.run(); super.run();
while(true){ while(true){
try { try {
List<FolderNode> folderlist = new ArrayList<FolderNode>(); List<FolderNode> folderlist = new ArrayList<FolderNode>();
List<VolumeEntity> volumeList = new ArrayList<VolumeEntity>(); List<VolumeEntity> volumeList = new ArrayList<VolumeEntity>();
// brick状态 map集合 // brick状态 map集合
Map<String, String> brickStatusMap = cluster.showClusterInfo(); Map<String, String> brickStatusMap = cluster.showClusterInfo();
//查询 volume name //查询 volume name
List<String> volumeNameList = volumeInfo.showAllVolumeName(); List<String> volumeNameList = volumeInfo.showAllVolumeName();
if (null != volumeNameList) { if (null != volumeNameList) {
for (String volumeName : volumeNameList) { for (String volumeName : volumeNameList) {
VolumeEntity volume = new VolumeEntity(); VolumeEntity volume = new VolumeEntity();
volume.setName(volumeName); volume.setName(volumeName);
List<String> path = volumeInfo.getVolumeMountPoint(volumeName); List<String> path = volumeInfo.getVolumeMountPoint(volumeName);
//默认加载第一个路径 //默认加载第一个路径
if (null != path && path.size() > 0) { if (null != path && path.size() > 0) {
volume.setPath(path.get(0)); volume.setPath(path.get(0));
} }
volume.setAllSize(volumeInfo.getVolumeAvailableSize(volumeName)); volume.setAllSize(volumeInfo.getVolumeAvailableSize(volumeName));
volume.setUsedSize(volumeInfo.getVolumeUseSize(volumeName)); volume.setUsedSize(volumeInfo.getVolumeUseSize(volumeName));
//TODO 查询brick-- //TODO 查询brick--
//返回 ip:path //返回 ip:path
List<String> brickStrs = volumeInfo.getVolumeBricks(volumeName); List<String> brickStrs = volumeInfo.getVolumeBricks(volumeName);
//brick已用大小 //brick已用大小
Map<String, Double> usedSize = volumeInfo.getVolumebricksDataSize(volumeName); Map<String, Double> usedSize = volumeInfo.getVolumebricksDataSize(volumeName);
Map<String, Double> availableSize = volumeInfo.getVolumebricksAvailableSize(volumeName); Map<String, Double> availableSize = volumeInfo.getVolumebricksAvailableSize(volumeName);
List<Brick> brickList = new ArrayList<Brick>(); List<Brick> brickList = new ArrayList<Brick>();
for (String brickIpPath : brickStrs) { for (String brickIpPath : brickStrs) {
Brick b = new Brick(); Brick b = new Brick();
String ipAndpath[] = brickIpPath.split(":"); String ipAndpath[] = brickIpPath.split(":");
String brickip = ipAndpath[0]; String brickip = ipAndpath[0];
String brickpath = ipAndpath[1]; String brickpath = ipAndpath[1];
//iP , path , //iP , path ,
b.setIp(brickip); b.setIp(brickip);
if(brickStatusMap==null || brickStatusMap.size()==0){ if(brickStatusMap==null || brickStatusMap.size()==0){
b.setStatus(false); b.setStatus(false);
}else if (brickStatusMap.containsKey(brickip)) { }else if (brickStatusMap.containsKey(brickip)) {
b.setStatus(true); b.setStatus(true);
} }
else { else {
b.setStatus(false); b.setStatus(false);
} }
b.setPath(brickpath); b.setPath(brickpath);
b.setAvailableSize(availableSize.get(brickIpPath)); b.setAvailableSize(availableSize.get(brickIpPath));
b.setUsedSize(usedSize.get(brickIpPath)); b.setUsedSize(usedSize.get(brickIpPath));
brickList.add(b); brickList.add(b);
} }
volume.setBrick(brickList); volume.setBrick(brickList);
//默认加载第一个路径 //默认加载第一个路径
if (null != path && path.size() > 0) { if (null != path && path.size() > 0) {
//装入 folder //装入 folder
//查询 每个 volume 下的 folder //查询 每个 volume 下的 folder
FolderNode foldertmp = gfsTree.getDatas(path.get(0)); FolderNode foldertmp = gfsTree.getDatas(path.get(0));
folderlist.add(foldertmp); folderlist.add(foldertmp);
} }
volumeList.add(volume); volumeList.add(volume);
} }
} }
//TODO 更新folder 目录 //TODO 更新folder 目录
CacheTreeData.setFolders(folderlist); CacheTreeData.setFolders(folderlist);
CacheTreeData.setVolumeList(volumeList); CacheTreeData.setVolumeList(volumeList);
Thread.sleep(Constant.get_volume_sleep_time); Thread.sleep(Constant.get_volume_sleep_time);
} catch (InterruptedException e) { } catch (InterruptedException e) {
} }
} }
} }
public static String getPointPath() { public static String getPointPath() {
return pointPath; return pointPath;
} }
public static void setPointPath(String pointPath) { public static void setPointPath(String pointPath) {
ThreadVolume.pointPath = pointPath; ThreadVolume.pointPath = pointPath;
} }
} }

@ -1,113 +1,113 @@
package com.platform.utils; package com.platform.utils;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
public class UtilsHelper { public class UtilsHelper {
/** /**
* *
* @param clazz * @param clazz
* @param req * @param req
* @return * @return
*/ */
public static Object newObjAndSetAttrsByClass(Class<?> clazz, public static Object newObjAndSetAttrsByClass(Class<?> clazz,
Map<String, String> paramMap) { Map<String, String> paramMap) {
Object object = null; Object object = null;
try { try {
object = clazz.newInstance(); object = clazz.newInstance();
Field[] fileds = clazz.getDeclaredFields(); Field[] fileds = clazz.getDeclaredFields();
for (Field fs : fileds) { for (Field fs : fileds) {
String fieldName = fs.getName(); String fieldName = fs.getName();
String fieldType = fs.getGenericType().toString() String fieldType = fs.getGenericType().toString()
.replace("class ", ""); // 如果type是类类型则前面包含"class ",后面跟类名 .replace("class ", ""); // 如果type是类类型则前面包含"class ",后面跟类名
if (paramMap.containsKey(fieldName)) { if (paramMap.containsKey(fieldName)) {
Method method = clazz.getDeclaredMethod( Method method = clazz.getDeclaredMethod(
getAttributeSetName(fs), Class.forName(fieldType)); getAttributeSetName(fs), Class.forName(fieldType));
String value = paramMap.get(fieldName); String value = paramMap.get(fieldName);
if ("java.lang.Integer".equals(fieldType)) { if ("java.lang.Integer".equals(fieldType)) {
method.invoke(object, Integer.valueOf(value)); method.invoke(object, Integer.valueOf(value));
} else { } else {
method.invoke(object, value); method.invoke(object, value);
} }
} }
} }
} catch (InstantiationException e) { } catch (InstantiationException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} catch (IllegalAccessException e) { } catch (IllegalAccessException e) {
// TODO Auto-generated catch blockAQA // TODO Auto-generated catch blockAQA
e.printStackTrace(); e.printStackTrace();
} catch (NoSuchMethodException e) { } catch (NoSuchMethodException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} catch (SecurityException e) { } catch (SecurityException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} catch (InvocationTargetException e) { } catch (InvocationTargetException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
return object; return object;
}; };
/** /**
* *
* @param object * @param object
* @param req * @param req
* @return * @return
*/ */
public static Object newObjAndSetAttrsByInstance(Object object, public static Object newObjAndSetAttrsByInstance(Object object,
Map<String, String> mapParam) { Map<String, String> mapParam) {
return newObjAndSetAttrsByClass(object.getClass(), mapParam); return newObjAndSetAttrsByClass(object.getClass(), mapParam);
} }
/** /**
* {@fs}set * {@fs}set
* *
* @param fs * @param fs
* *
* @return set * @return set
*/ */
private static String getAttributeSetName(Field fs) { private static String getAttributeSetName(Field fs) {
String fieldName = fs.getName(); String fieldName = fs.getName();
char[] cs = fieldName.toCharArray(); char[] cs = fieldName.toCharArray();
cs[0] -= 32; cs[0] -= 32;
return "set" + String.valueOf(cs); return "set" + String.valueOf(cs);
} }
public static <K, V> Map<K, V> updateMap(Map<K, V> map1, Map<K, V> map2) { public static <K, V> Map<K, V> updateMap(Map<K, V> map1, Map<K, V> map2) {
if (null == map1 || map1.size() <= 0) if (null == map1 || map1.size() <= 0)
return map2; return map2;
Iterator<Entry<K, V>> iterator = map2.entrySet().iterator(); Iterator<Entry<K, V>> iterator = map2.entrySet().iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
Map.Entry<K, V> entry = iterator.next(); Map.Entry<K, V> entry = iterator.next();
map1.put(entry.getKey(), entry.getValue()); map1.put(entry.getKey(), entry.getValue());
} }
return map1; return map1;
} }
public static <K, V> boolean isSubMap(Map<K, V> map1, Map<K, V> map2) { public static <K, V> boolean isSubMap(Map<K, V> map1, Map<K, V> map2) {
boolean flag = true; boolean flag = true;
if (null == map2 || map2.size() <= 0 || null == map1) if (null == map2 || map2.size() <= 0 || null == map1)
return false; return false;
Iterator<Map.Entry<K, V>> iterator = map1.entrySet().iterator(); Iterator<Map.Entry<K, V>> iterator = map1.entrySet().iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
Map.Entry<K, V> entry = iterator.next(); Map.Entry<K, V> entry = iterator.next();
if (!map2.containsKey(entry.getKey()) if (!map2.containsKey(entry.getKey())
|| !map2.containsValue(entry.getValue())) || !map2.containsValue(entry.getValue()))
return false; return false;
} }
return flag; return flag;
} }
} }

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

Loading…
Cancel
Save