glusterfs-api
parent
9aa8e675ae
commit
ab64ab35d2
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,5 +0,0 @@
|
||||
<?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-unit name="aggregation-platform">
|
||||
</persistence-unit>
|
||||
</persistence>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,151 @@
|
||||
<?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.DataInfoMoveTmpDao">
|
||||
<resultMap id="getEntityByText" type="com.platform.entities.DataInfoEntityMoveTmp">
|
||||
<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" />
|
||||
|
||||
<result property="dstPath" column="dst_path" javaType="string"
|
||||
jdbcType="VARCHAR" />
|
||||
<result property="completeStatus" column="complete_status" javaType="string"
|
||||
jdbcType="VARCHAR" />
|
||||
<result property="rate" column="rate" javaType="int"
|
||||
jdbcType="INTEGER" />
|
||||
</resultMap>
|
||||
|
||||
<!-- 获取数据全部记录信息 -->
|
||||
<select id="findAll" parameterType="" resultMap="getEntityByText">
|
||||
SELECT
|
||||
a.id,a.regionalism_code,b.city_name,b.district_name, a.system_code,b.system_name,b.data_type,b.data_version,b.submitted_batch,
|
||||
b.data_path,b.data_charset,b.collection_time,b.collector_name,b.collector_contacts,b.data_year,a.dst_path,a.complete_status,a.rate
|
||||
FROM
|
||||
move_data_tmp a LEFT JOIN data_details b
|
||||
ON a.system_code = b.system_code AND a.regionalism_code = b.regionalism_code;
|
||||
</select>
|
||||
|
||||
<update id="update" parameterType="com.platform.entities.DataInfoEntityMoveTmp">
|
||||
UPDATE
|
||||
move_data_tmp
|
||||
<set >
|
||||
<trim suffixOverrides=",">
|
||||
<if test="regionalismCode != null and regionalismCode != ''">
|
||||
regionalism_code = #{regionalismCode},
|
||||
</if>
|
||||
<if test="systemCode != null and systemCode != ''">
|
||||
system_code= #{systemCode},
|
||||
</if>
|
||||
<if test="dstPath != null and dstPath != ''">
|
||||
dst_path= #{dstPath},
|
||||
</if>
|
||||
<if test="completeStatus != null and completeStatus != ''">
|
||||
complete_status= #{completeStatus},
|
||||
</if>
|
||||
rate= #{rate}
|
||||
</trim>
|
||||
</set>
|
||||
<where>
|
||||
id = #{id}
|
||||
</where>
|
||||
</update>
|
||||
|
||||
<insert id="save" parameterType="">
|
||||
INSERT INTO
|
||||
move_data_tmp(
|
||||
<trim suffixOverrides=",">
|
||||
<if test="id > 0">
|
||||
id,
|
||||
</if>
|
||||
<if test="regionalismCode != null and regionalismCode != ''">
|
||||
regionalism_code,
|
||||
</if>
|
||||
<if test="systemCode != null and systemCode != ''">
|
||||
system_code,
|
||||
</if>
|
||||
<if test="dstPath != null and dstPath != ''">
|
||||
dst_path,
|
||||
</if>
|
||||
<if test="completeStatus != null and completeStatus != ''">
|
||||
complete_status,
|
||||
</if>
|
||||
rate
|
||||
</trim>
|
||||
)
|
||||
VALUES(
|
||||
<trim suffixOverrides=",">
|
||||
<if test="id > 0">
|
||||
id,
|
||||
</if>
|
||||
<if test="regionalismCode != null and regionalismCode != ''">
|
||||
#{regionalismCode},
|
||||
</if>
|
||||
<if test="systemCode != null and systemCode != ''">
|
||||
#{systemCode},
|
||||
</if>
|
||||
<if test="dstPath != null and dstPath != ''">
|
||||
#{dstPath},
|
||||
</if>
|
||||
<if test="completeStatus != null and completeStatus != ''">
|
||||
#{completeStatus},
|
||||
</if>
|
||||
#{rate}
|
||||
</trim>
|
||||
)
|
||||
</insert>
|
||||
|
||||
<delete id="remove" parameterType="java.lang.INTEGER">
|
||||
DELETE FROM
|
||||
move_data_tmp
|
||||
WHERE
|
||||
id = #{id}
|
||||
</delete>
|
||||
|
||||
<!-- 获取数据符合筛选条件的总记录条数 -->
|
||||
<select id="getLimitedDataCount" resultType="java.lang.Integer"
|
||||
parameterType="PagerOptions">
|
||||
SELECT COUNT(id) FROM move_data_tmp
|
||||
<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 move_data_tmp
|
||||
ORDER BY id LIMIT 0,#{PagerOptions.totalLimit}) AS TEMP
|
||||
</select>
|
||||
|
||||
</mapper>
|
@ -0,0 +1,54 @@
|
||||
package com.platform.entities;
|
||||
|
||||
public class DataInfoEntityMoveTmp extends DataInfoEntity {
|
||||
|
||||
private String dstPath;
|
||||
|
||||
private String completeStatus;
|
||||
|
||||
private int rate;
|
||||
|
||||
/**
|
||||
* @return the dstPath
|
||||
*/
|
||||
public String getDstPath() {
|
||||
return dstPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dstPath the dstPath to set
|
||||
*/
|
||||
public void setDstPath(String dstPath) {
|
||||
this.dstPath = dstPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the completeStatus
|
||||
*/
|
||||
public String getCompleteStatus() {
|
||||
return completeStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param completeStatus the completeStatus to set
|
||||
*/
|
||||
public void setCompleteStatus(String completeStatus) {
|
||||
this.completeStatus = completeStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the rate
|
||||
*/
|
||||
public int getRate() {
|
||||
return rate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rate the rate to set
|
||||
*/
|
||||
public void setRate(int rate) {
|
||||
this.rate = rate;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,5 +1,11 @@
|
||||
package com.platform.glusterfs;
|
||||
|
||||
public class SetCluster {
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
public class SetCluster {
|
||||
public static Logger log = Logger.getLogger ( SetCluster.class);
|
||||
|
||||
public int addPeer(String peerip){
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,25 @@
|
||||
package com.platform.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.platform.entities.GatherOracleInfo;
|
||||
|
||||
public interface IMySqlService {
|
||||
|
||||
/**
|
||||
* @return 查询
|
||||
* @throws Exception
|
||||
*/
|
||||
public List<GatherOracleInfo> findAllMySql() throws Exception;
|
||||
|
||||
/** 删除
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public int deleteMySql(int id) throws Exception;
|
||||
|
||||
public int insertOracle(GatherOracleInfo oracle) throws Exception;
|
||||
|
||||
public int updateOracle(GatherOracleInfo oracle) throws Exception;
|
||||
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.platform.service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface IOracleExtractService {
|
||||
|
||||
/** 抽取数据库
|
||||
* @param name
|
||||
* @param dataInfo //采集库连接参数
|
||||
* @param oracleConnect
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public boolean extractOracle(String name, List<Map<String, String>> dataInfo, Map<String, String> oracleConnect) throws Exception;
|
||||
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
package com.platform.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.platform.dao.GatherOracleDao;
|
||||
import com.platform.entities.GatherOracleInfo;
|
||||
import com.platform.service.IMySqlService;
|
||||
|
||||
@Service(value = "mySqlService")
|
||||
public class MySqlServiceImpl implements IMySqlService{
|
||||
|
||||
@Resource(name = "gatherOracleDao")
|
||||
private GatherOracleDao gatherOracleDao;
|
||||
|
||||
@Override
|
||||
public List<GatherOracleInfo> findAllMySql() throws Exception {
|
||||
List<GatherOracleInfo> result = gatherOracleDao.selectAllOracle();
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteMySql(int id) throws Exception {
|
||||
|
||||
int result = 0;
|
||||
if (id > 0) {
|
||||
// result = gatherOracleDao.deleteOracleById(id);
|
||||
GatherOracleInfo oracle = new GatherOracleInfo();
|
||||
oracle.setId(id);
|
||||
oracle.setRemove("1");
|
||||
result = gatherOracleDao.updateOracleById(oracle );
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public int insertOracle(GatherOracleInfo oracle) throws Exception {
|
||||
int result = gatherOracleDao.insertOracle(oracle);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateOracle(GatherOracleInfo oracle) throws Exception {
|
||||
int result;
|
||||
if (oracle.getId() > 0) {
|
||||
result = gatherOracleDao.updateOracleById(oracle);
|
||||
}
|
||||
else {
|
||||
result = gatherOracleDao.insertOracle(oracle);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
package com.platform.service.impl;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.platform.entities.DataInfoEntity;
|
||||
import com.platform.entities.GatherOracleInfo;
|
||||
import com.platform.entities.OracleConnectorParams;
|
||||
import com.platform.oracle.OracleConnector;
|
||||
import com.platform.service.IOracleExtractService;
|
||||
import com.platform.service.OracleExtractHelper;
|
||||
import com.platform.utils.Bean2MapUtils;
|
||||
|
||||
@Service(value = "OracleExtract")
|
||||
public class OracleExtractServiceImpl implements IOracleExtractService {
|
||||
|
||||
/**
|
||||
* 抽取
|
||||
*/
|
||||
private OracleExtractHelper oracleExtract = new OracleExtractHelper();
|
||||
|
||||
/**
|
||||
* 数据库连接实现类
|
||||
*/
|
||||
private OracleConnector connect = new OracleConnector();
|
||||
|
||||
@Override
|
||||
public boolean extractOracle(String name, List<Map<String, String>> dataInfoMap,
|
||||
Map<String, String> 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:@" + oracleModel.getIp() + ":" + oracleModel.getPort() + "/"
|
||||
+ oracleModel.getDatabaseName(), oracleModel.getUser(), oracleModel.getPassword());
|
||||
|
||||
for (OracleConnectorParams collectOracle : datainfos) {
|
||||
|
||||
oracleExtract.createDBLink(conn, collectOracle);
|
||||
oracleExtract.createTableSpace(conn, oracleModel);
|
||||
oracleExtract.createUser(conn, oracleModel);
|
||||
oracleExtract.extractColleDB(conn, collectOracle);
|
||||
}
|
||||
isSuccess = true;
|
||||
}catch(Exception e){
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,87 @@
|
||||
package com.platform.utils;
|
||||
|
||||
import java.beans.BeanInfo;
|
||||
import java.beans.IntrospectionException;
|
||||
import java.beans.Introspector;
|
||||
import java.beans.PropertyDescriptor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class Bean2MapUtils {
|
||||
|
||||
/**
|
||||
* 将一个 Map 对象转化为一个 JavaBean
|
||||
* @param type 要转化的类型
|
||||
* @param map 包含属性值的 map
|
||||
* @return 转化出来的 JavaBean 对象
|
||||
* @throws IntrospectionException
|
||||
* 如果分析类属性失败
|
||||
* @throws IllegalAccessException
|
||||
* 如果实例化 JavaBean 失败
|
||||
* @throws InstantiationException
|
||||
* 如果实例化 JavaBean 失败
|
||||
* @throws InvocationTargetException
|
||||
* 如果调用属性的 setter 方法失败
|
||||
*/
|
||||
public static Object convertMap(Class type, Map map)
|
||||
throws IntrospectionException, IllegalAccessException,
|
||||
InstantiationException, InvocationTargetException {
|
||||
BeanInfo beanInfo = Introspector.getBeanInfo(type); // 获取类属性
|
||||
Object obj = type.newInstance(); // 创建 JavaBean 对象
|
||||
|
||||
// 给 JavaBean 对象的属性赋值
|
||||
PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
|
||||
for (int i = 0; i< propertyDescriptors.length; i++) {
|
||||
PropertyDescriptor descriptor = propertyDescriptors[i];
|
||||
String propertyName = descriptor.getName();
|
||||
try{
|
||||
if (map.containsKey(propertyName)) {
|
||||
// 下面一句可以 try 起来,这样当一个属性赋值失败的时候就不会影响其他属性赋值。
|
||||
Object value = map.get(propertyName);
|
||||
|
||||
Object[] args = new Object[1];
|
||||
args[0] = value;
|
||||
|
||||
descriptor.getWriteMethod().invoke(obj, args);
|
||||
}
|
||||
}
|
||||
catch(Exception e){
|
||||
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将一个 JavaBean 对象转化为一个 Map
|
||||
* @param bean 要转化的JavaBean 对象
|
||||
* @return 转化出来的 Map 对象
|
||||
* @throws IntrospectionException 如果分析类属性失败
|
||||
* @throws IllegalAccessException 如果实例化 JavaBean 失败
|
||||
* @throws InvocationTargetException 如果调用属性的 setter 方法失败
|
||||
*/
|
||||
public static Map convertBean(Object bean)
|
||||
throws IntrospectionException, IllegalAccessException, InvocationTargetException {
|
||||
Class type = bean.getClass();
|
||||
Map returnMap = new HashMap();
|
||||
BeanInfo beanInfo = Introspector.getBeanInfo(type);
|
||||
|
||||
PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
|
||||
for (int i = 0; i< propertyDescriptors.length; i++) {
|
||||
PropertyDescriptor descriptor = propertyDescriptors[i];
|
||||
String propertyName = descriptor.getName();
|
||||
if (!propertyName.equals("class")) {
|
||||
Method readMethod = descriptor.getReadMethod();
|
||||
Object result = readMethod.invoke(bean, new Object[0]);
|
||||
if (result != null) {
|
||||
returnMap.put(propertyName, result);
|
||||
} else {
|
||||
returnMap.put(propertyName, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
return returnMap;
|
||||
}
|
||||
}
|
@ -1,18 +1,19 @@
|
||||
package com.platform.utils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.platform.entities.FolderNode;
|
||||
|
||||
public class CacheTreeData {
|
||||
|
||||
private static FolderNode folders = null;
|
||||
private static List<FolderNode> folders = null;
|
||||
|
||||
public static FolderNode getFolders() {
|
||||
public static List<FolderNode> getFolders() {
|
||||
return folders;
|
||||
}
|
||||
|
||||
public static void setFolders(FolderNode folders) {
|
||||
public static void setFolders(List<FolderNode> folders) {
|
||||
CacheTreeData.folders = folders;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,31 @@
|
||||
package com.platform.utils;
|
||||
|
||||
public class ThreadMoveData extends Thread {
|
||||
|
||||
/**
|
||||
* : 实时更新数据库--根据查询到的 正则迁移的数据
|
||||
*/
|
||||
public ThreadMoveData() {
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Thread#run()
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
// TODO Auto-generated method stub
|
||||
super.run();
|
||||
//查询 表 move_data_tmp
|
||||
|
||||
|
||||
|
||||
|
||||
try {
|
||||
Thread.sleep(Constant.update_dataInfo_sleep_time);
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
package com.platform.utils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.platform.entities.FolderNode;
|
||||
import com.platform.glusterfs.GetTreeData;
|
||||
import com.platform.glusterfs.VolumeInfo;
|
||||
|
||||
public class VolumeThread extends Thread implements Runnable{
|
||||
|
||||
/**
|
||||
* 挂载点路径
|
||||
*/
|
||||
private static String pointPath = "/home";
|
||||
|
||||
public VolumeThread() {
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public VolumeThread(String path) {
|
||||
if (null != path && !"".equals(path.trim())) {
|
||||
VolumeThread.pointPath = path;
|
||||
}
|
||||
}
|
||||
|
||||
/** gfs目录树形展示 */
|
||||
private GetTreeData gfsTree = new GetTreeData();
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
super.run();
|
||||
while(true){
|
||||
FolderNode folders = gfsTree.getDatas(pointPath);
|
||||
//TODO
|
||||
CacheTreeData.setFolders(folders);
|
||||
try {
|
||||
Thread.sleep(Constant.get_volume_sleep_time);
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static String getPointPath() {
|
||||
return pointPath;
|
||||
}
|
||||
|
||||
public static void setPointPath(String pointPath) {
|
||||
VolumeThread.pointPath = pointPath;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in new issue