集成gfs的web项目。

web_backend_develope
chenlw 10 years ago
parent d07a4457bb
commit 5a7bb65c0b

@ -0,0 +1,44 @@
/**
* : MyException.java
* : </>
* : <>
* @author liliy
* : <>
* 20161019
* <>
*/
package com.base;
/**
* <>
* <>
* @author liliy
* @version [20161019]
* @see [/]
* @since [/]
*/
public class MyException {
private String mess;
public MyException() {
}
/**
* <>
* <>
* @see [##]
*/
public MyException(String mess) {
// TODO Auto-generated constructor stub
setMess(mess);
}
public void setMess(String mess){
this.mess=mess;
}
public String getMess(){
return this.mess;
}
}

@ -0,0 +1,114 @@
/**
* : PostObj.java
* : </>
* : <>
* @author liliy
* : <>
* 20161018
* <>
*/
package com.base;
import java.util.List;
import java.util.Stack;
/**
* <>
* <>
* @author liliy
* @version [20161018]
* @see [/]
* @since [/]
*/
public class PostData {
private Object data;
private Stack<MyException> exceptionsStack;
/**
* <>
* <>
* @see [##]
*/
public PostData() {
// TODO Auto-generated constructor stub
exceptionsStack=new Stack<>();
}
public PostData(Object data) {
// TODO Auto-generated constructor stub
this.data=data;
exceptionsStack=new Stack<>();
}
/**
* @return the data
*/
public Object getData() {
return data;
}
/**
* @param data the data to set
*/
public void setData(Object data) {
this.data = data;
}
/**
*
* <>
* <>
* @param e
* @see [##]
*/
public void pushExceptionsStack(String mess){
MyException myException=new MyException(mess);
exceptionsStack.push(myException);
}
public void pushExceptionsStackList(List<String> messs){
if(messs==null)return;
for(String mess:messs){
MyException myException=new MyException(mess);
exceptionsStack.push(myException);
}
}
/**
*
* <>
* <>
* @return
* @see [##]
*/
public MyException popExceptionsStack(){
if (isEmptyExceptionsStack()){
return null;
}
return exceptionsStack.pop();
}
/**
*
* <>
* <>
* @return
* @see [##]
*/
public boolean isEmptyExceptionsStack(){
return exceptionsStack.empty();
}
/**
*
* <>
* <>
* @return
* @see [##]
*/
public Stack<MyException> getExceptionsStack() {
return exceptionsStack;
}
/**
* @param exceptionsStack the exceptionsStack to set
*/
public void setExceptionsStack(Stack<MyException> exceptionsStack) {
this.exceptionsStack = exceptionsStack;
}
}

@ -0,0 +1,182 @@
/**
* : TaskOperateData.java
* : </>
* : <>
* @author liliy
* : <>
* 2016112
* <>
*/
package com.base;
import java.util.ArrayList;
import java.util.List;
import com.platform.glusterfs.SetCluster;
import com.platform.utils.Constant;
import com.platform.utils.Support;
/**
* <>
*
* @author liliy
* @version [2016112]
* @see [/]
* @since [/]
*/
public class TaskOperateData {
/**
* 012MD53-1,-2:
* 4:5-3
*/
private int status = 1;
/**
*
*/
// private int taskReturn = 0;
/**
*
*/
private Long allSize = 0L;
/**
*
*/
private Long completedSize = 0L;
/**
*
*/
private int progress = 0;
/**
*
*/
private String sourcePath = null;
/** 目的路径 */
private String destPath = null;
/**
*
*/
private String removeDataName = null;
/**
*
*/
private String startTime = null;
/** 结束时间 */
private String endTime = null;
/**
* @return the status
*/
public int getStatus() {
return status;
}
/**
* @param status the status to set
*/
public void setStatus(int status) {
this.status = status;
}
/**
* @return the allSize
*/
public Long getAllSize() {
return allSize;
}
/**
* @param allSize the allSize to set
*/
public void setAllSize(Long allSize) {
this.allSize = allSize;
}
/**
* @return the completedSize
*/
public Long getCompletedSize() {
return completedSize;
}
/**
* @param completedSize the completedSize to set
*/
public void setCompletedSize(Long completedSize) {
this.completedSize = completedSize;
}
/**
* @return the progress
*/
public int getProgress() {
return progress;
}
/**
* @param progress the progress to set
*/
public void setProgress(int progress) {
this.progress = progress;
}
/**
* @return the sourcePath
*/
public String getSourcePath() {
return sourcePath;
}
/**
* @param sourcePath the sourcePath to set
*/
public void setSourcePath(String sourcePath) {
this.sourcePath = sourcePath;
}
/**
* @return the destPath
*/
public String getDestPath() {
return destPath;
}
/**
* @param destPath the destPath to set
*/
public void setDestPath(String destPath) {
this.destPath = destPath;
}
/**
* @return the removeDataName
*/
public String getRemoveDataName() {
return removeDataName;
}
/**
* @param removeDataName the removeDataName to set
*/
public void setRemoveDataName(String removeDataName) {
this.removeDataName = removeDataName;
}
/**
* @return the startTime
*/
public String getStartTime() {
return startTime;
}
/**
* @param startTime the startTime to set
*/
public void setStartTime(String startTime) {
this.startTime = startTime;
}
/**
* @return the endTime
*/
public String getEndTime() {
return endTime;
}
/**
* @param endTime the endTime to set
*/
public void setEndTime(String endTime) {
this.endTime = endTime;
}
}

@ -203,6 +203,18 @@ PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
<if test="extractStatus > 0">
extract_status,
</if>
<if test="payResult != null and payResult != ''">
checkout_pay,
</if>
<if test="execResult != null and execResult != ''">
checkout_indicate,
</if>
<if test="startMonth != null and startMonth != ''">
start_month,
</if>
<if test="endMonth != null and endMonth != ''">
end_month,
</if>
</trim>
)
VALUES(
@ -255,6 +267,18 @@ PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
<if test="extractStatus > 0">
#{extractStatus},
</if>
<if test="payResult != null and payResult != ''">
#{payResult},
</if>
<if test="execResult != null and execResult != ''">
#{execResult},
</if>
<if test="startMonth != null and startMonth != ''">
#{startMonth},
</if>
<if test="endMonth != null and endMonth != ''">
#{endMonth},
</if>
</trim>
)
</insert>

@ -61,7 +61,8 @@ PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
b.data_version dataVersion,b.submitted_batch submittedBatch,b.data_path dataPath,b.data_charset charset,
b.collection_time collectingTime,b.collector_name collectorName,b.collector_contacts collectorContacts,
b.data_year year,b.extract_status extractStatus,b.start_year startYear,b.end_year endYear,
b.volume_ip volumeIp,b.volume_path volumePath
b.volume_ip volumeIp,b.volume_path volumePath,b.checkout_pay payResult,b.checkout_indicate execResult,
b.start_month startMonth,b.end_month endMonth
FROM
move_data_tmp a LEFT JOIN data_details b
ON a.system_code = b.system_code AND a.regionalism_code = b.regionalism_code AND a.fkid = b.id
@ -78,6 +79,7 @@ PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
<where>
a.id = #{id}
</where>
for update
</select>
<update id="update" parameterType="com.platform.entities.DataInfoEntityMoveTmp">

@ -26,6 +26,7 @@ import com.platform.service.ICheckoutService;
@Controller
@RequestMapping("/checkout")
public class CheckoutController extends BaseController {
//日志
public final static Logger log = Logger.getLogger(CheckoutController.class);
@Resource(name = "checkoutService")

@ -29,7 +29,7 @@ import com.platform.entities.GatherOracleInfo;
import com.platform.form.PagerOptions;
import com.platform.form.oracleForm;
import com.platform.form.volumeMoveForm;
import com.platform.http.gfs.HttpUtils;
import com.platform.http.HttpUtils;
import com.platform.service.DataInfoService;
import com.platform.service.ICodeService;
import com.platform.service.IGfsService;
@ -37,6 +37,7 @@ import com.platform.service.ILogRead;
import com.platform.service.IMoveDataService;
import com.platform.service.IGatherOracleService;
import com.platform.service.IOracleExtractService;
import com.platform.service.IVolumeService;
import com.platform.service.OracleStatusService;
import com.platform.service.thread.ThreadExtractOracle;
import com.platform.service.thread.ThreadGainOracleConnect;
@ -61,8 +62,8 @@ public class DataModelController extends BaseController {
/**
* gfs
*/
@Resource(name = "gfsService")
private IGfsService gfsService;
@Resource(name = "volumeService")
private IVolumeService volumeService;
/**
* mysql
@ -202,9 +203,8 @@ public class DataModelController extends BaseController {
@RequestMapping(value = "/volume/list", method = RequestMethod.POST)
@ResponseBody
public String volumeList() throws Exception {
HttpUtils ht = new HttpUtils();
log.debug("-----/volume/list------");
String rest = ht.sendPost("gfs/getAllvolume", null);
String rest = volumeService.getAllvolume();
return rest;
}

@ -4,6 +4,8 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.RandomAccessFile;
import java.io.StringWriter;
import java.io.Writer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
@ -16,7 +18,9 @@ import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.sf.json.JSONArray;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
@ -36,6 +40,8 @@ import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.multipart.commons.CommonsMultipartResolver;
import com.base.BaseController;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.platform.entities.PreDataInfo;
import com.platform.entities.ResumableInfo;
import com.platform.entities.ResumableInfoStorage;
@ -55,6 +61,7 @@ import com.platform.utils.UtilsHelper;
@RequestMapping("/fileOperation")
public class ExcelController extends BaseController{
private static ObjectMapper mapper = new ObjectMapper();
/**
*
*/
@ -259,8 +266,11 @@ public class ExcelController extends BaseController{
public ModelMap importExcel(HttpServletRequest request,
HttpServletResponse response, @RequestBody String fileNameList) throws Exception {
log.info("---importExcel---" + fileNameList);
JSONArray jsonArray = JSONArray.fromObject(fileNameList);
List<String> jsonlist = (List<String>) JSONArray.toCollection(jsonArray, String.class);
List<String> jsonlist = mapper.readValue(fileNameList, new TypeReference<List<String>>() {});
// JavaType javaType = mapper.getTypeFactory().constructParametricType(List.class, String.class);
// JSONArray jsonArray = JSONArray.fromObject(fileNameList);
// List<String> jsonlist = (List<String>) JSONArray.toCollection(jsonArray, String.class);
ModelMap modelMap = new ModelMap();
if (null == jsonlist || jsonlist.size() == 0) {

@ -10,7 +10,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import com.base.BaseController;
import com.platform.entities.VolumeEntity;
import com.platform.entities.VolumeDataEntity;
import com.platform.service.IGfsService;
@ -81,7 +81,7 @@ public class FolderController extends BaseController {
@RequestMapping(value="/volume/findByName", method= RequestMethod.POST)
public Object getVolumByName(String volumeName) throws Exception{
log.info(volumeName);
VolumeEntity result = gfsService.getOneVolume(volumeName);
VolumeDataEntity result = gfsService.getOneVolume(volumeName);
return result;
}
}

@ -12,8 +12,8 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.base.BaseController;
import com.platform.entities.VolumeEntity;
import com.platform.http.gfs.HttpUtils;
import com.platform.entities.VolumeDataEntity;
import com.platform.http.gfs.SetVolume;
import com.platform.service.IVolumeService;
import com.platform.utils.ThreadVolumeImm;
@ -33,9 +33,9 @@ public class VolumeController extends BaseController{
private IVolumeService volumeService;
/**
* http
* volumeClient
*/
HttpUtils ht = new HttpUtils();
SetVolume volumeClient = new SetVolume();
/** volume
* @param res
@ -47,7 +47,7 @@ public class VolumeController extends BaseController{
@RequestMapping(value = "/volume/update", method = RequestMethod.POST)
@ResponseBody
public String volumeUpdate(HttpServletRequest res, HttpServletResponse req,
@RequestBody VolumeEntity form) throws Exception {
@RequestBody VolumeDataEntity form) throws Exception {
log.error("/oracle/update");
int rest = volumeService.save(form);
if (rest == 1) {
@ -56,7 +56,7 @@ public class VolumeController extends BaseController{
else {
req.setStatus(500);
}
String result = ht.sendPost("gfs/getAllvolume", null);
String result = volumeService.getAllvolume();
new ThreadVolumeImm("ThreadVolumeImm-in-VolumeController-update").start();
return result;
}
@ -71,7 +71,7 @@ public class VolumeController extends BaseController{
@RequestMapping(value = "/volume/delete", method = RequestMethod.POST)
@ResponseBody
public String volumeDelete(HttpServletRequest res, HttpServletResponse req,
@RequestBody VolumeEntity entity) throws Exception {
@RequestBody VolumeDataEntity entity) throws Exception {
log.error("/volume/delete");
int rest = volumeService.delete(entity);
if (rest == 1) {
@ -80,7 +80,7 @@ public class VolumeController extends BaseController{
else {
req.setStatus(500);
}
String result = ht.sendPost("gfs/getAllvolume", null);
String result = volumeClient.getAllvolume();
new ThreadVolumeImm("ThreadVolumeImm-in-VolumeController-delete").start();
return result;
}

@ -57,6 +57,12 @@ public class DataInfoEntity {
/** 是否进行了校验 */
private String checkoutFlag;
/** 起始月份 */
private String startMonth;
/** 结束月份 */
private String endMonth;
/** 是否进行了抽取 */
private String standardExtractStatus;
@ -402,6 +408,34 @@ public class DataInfoEntity {
this.standardExtractStatus = standardExtractStatus;
}
/**
* @return the startMonth
*/
public String getStartMonth() {
return startMonth;
}
/**
* @param startMonth the startMonth to set
*/
public void setStartMonth(String startMonth) {
this.startMonth = startMonth;
}
/**
* @return the endMonth
*/
public String getEndMonth() {
return endMonth;
}
/**
* @param endMonth the endMonth to set
*/
public void setEndMonth(String endMonth) {
this.endMonth = endMonth;
}
@Override
public String toString() {
return "id=" + this.id + " ,regionalismCode=" + this.regionalismCode

@ -22,7 +22,7 @@ import java.util.List;
* @since [/]
*/
public class VolumeEntity {
public class VolumeDataEntity {
/** volume总大小 */
private Double allSize;
@ -43,6 +43,7 @@ public class VolumeEntity {
/** volume树形目录 */
private List<FolderNode> folder = new ArrayList<FolderNode>();
// private FolderNode folder = new FolderNode();
/** volume的 块 */
private List<Brick> brick = new ArrayList<Brick>();
@ -146,6 +147,13 @@ public class VolumeEntity {
this.folder = folder;
}
/**
* @return the status
*/
public Boolean getStatus() {
return status;
}
/**
* @return the brick
*/

@ -0,0 +1,14 @@
package com.platform.http;
/** http
* @author chen
*
*/
public class HttpClientConstant {
/**
* gfs web IP
*/
public static String URL_IP_PORT = "http://192.168.0.110:9001/";
}

@ -0,0 +1,214 @@
package com.platform.http;
import java.beans.IntrospectionException;
import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import org.apache.log4j.Logger;
import org.springframework.http.HttpStatus;
import com.fasterxml.jackson.core.JsonGenerationException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.platform.utils.Bean2MapUtils;
/** http
* @author chen
*
*/
public class HttpUtils {
private static ObjectMapper mapper = new ObjectMapper();
/**
*
*/
public final static Logger log = Logger.getLogger(HttpUtils.class);
/** post json
* @param subUrl
* @param data
* @return
* @throws IOException
* @throws JsonMappingException
* @throws JsonGenerationException
*/
public String sendAjaxPost(String subUrl, Object data) throws JsonGenerationException, JsonMappingException, IOException {
String jsondata = null;
//转成json
if (null != data) {
Writer strWriter = new StringWriter();
mapper.writeValue(strWriter, data);
jsondata = strWriter.toString();
}
return sendAjaxPost(subUrl, jsondata);
}
/** post
* @param subUrl
* @param map
* @return
*/
public String sendAjaxPost(String subUrl, String json) {
String resultStr = "";
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(HttpClientConstant.URL_IP_PORT + subUrl);
try {
// 传参
if (null != json && !"".equals(json)) {
// 建立一个NameValuePair数组用于存储欲传送的参数
StringEntity entity = new StringEntity(json,"UTF-8");
entity.setContentEncoding("UTF-8");
entity.setContentType("application/json");
post.setEntity(entity);
}
// 发送
HttpResponse respone = client.execute(post);
//接收返回值
if(respone.getStatusLine().getStatusCode() == HttpStatus.OK.value()){
HttpEntity result = respone.getEntity();
if (null != result) {
resultStr = EntityUtils.toString(result);
}
}
} catch (Exception e) {
log.info(HttpClientConstant.URL_IP_PORT + subUrl);
log.error(e);
}
return resultStr;
}
/** post map
* @param subUrl
* @param data
* @return
*/
public String sendPost(String subUrl, Object data) {
Map<String, Object> map = null;
if (null != data) {
//转成json
try {
map = Bean2MapUtils.convertBean(data);
} catch (IllegalAccessException e) {
log.error(e);
} catch (InvocationTargetException e) {
log.error(e);
} catch (IntrospectionException e) {
log.error(e);
}
}
return sendPost(subUrl, map);
}
/** map
* @param subUrl
* @param map
* @return
*/
public String sendPost(String subUrl, Map<String, Object> map) {
String resultStr = "";
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(HttpClientConstant.URL_IP_PORT + subUrl);
try {
// 传参
List<NameValuePair> parameters = new ArrayList<NameValuePair>();
if (null != map) {
// 封装数据
for (String key : map.keySet()) {
String value = "";
Object obj = map.get(key);
String type = obj.getClass().getName();
//字符串
if (type.equals("java.lang.String")) {
value = (String) obj;
}
//数组
else if(type.contains("[L")){
JSONArray jsonarr = JSONArray.fromObject(obj);
value = jsonarr.toString();
}
//集合
else if(type.contains("java.util.")){
JSONArray jsonarr = JSONArray.fromObject(obj);
value = jsonarr.toString();
}
//除字符外的 其他 基本类型
else if(type.contains("java.lang.")){
value = String.valueOf(obj);
}
//对象
else {
JSONObject jsondata = JSONObject.fromObject(obj);
value = jsondata.toString();
}
parameters.add(new BasicNameValuePair(key, value));
}
// 传参 放入 url的 form中
UrlEncodedFormEntity entity = new UrlEncodedFormEntity(parameters,
"UTF-8");
post.setEntity(entity);
}
// 发送
HttpResponse respone = client.execute(post);
HttpEntity result = respone.getEntity();
if (null != result) {
resultStr = EntityUtils.toString(result);
}
} catch (Exception e) {
log.info(HttpClientConstant.URL_IP_PORT + subUrl);
log.error(e);
}
return resultStr;
}
// public static void main(String[] args) {
// HttpUtils ht = new HttpUtils();
// Volume v = new Volume("a", 200, 10, null, null);
// String rest = ht.sendPost("data/getOperateTasks", v);
// System.out.println(rest);
// Map<String, Object> m = new HashMap<String, Object>();
// m.put("a", 1);
// rest = ht.sendPost("data/getOperateTasks", m);
// System.out.println(rest);
// rest = ht.sendPost("data/getOperateTasks", null);
// System.out.println(rest);
// //
// String[] str = new String[2];
// str[1] = "1";
// str[0] = "0";
// m.put("arr", str);
//
// Volume[] vli = new Volume[2];
// vli[1] = new Volume("a", 200, 10, null, null);
// vli[0] = new Volume("a", 200, 10, null, null);
// m.put("vli", vli);
// List<Integer> num = new ArrayList<Integer>();
// num.add(2);
// m.put("num", num);
// m.put("bool", true);
// rest = ht.sendPost("data/getOperateTasks", m);
// System.out.println(rest);
// }
}

@ -0,0 +1,167 @@
/**
* : VolumeEntity.java
* : </>
* : <>
* @author chen
* : <>
* 201699
* <>
*/
package com.platform.http;
import java.util.ArrayList;
import java.util.List;
import com.platform.entities.Brick;
import com.platform.entities.FolderNode;
/**
* gfs volume
*
* @author chen
* @version [201699]
* @see [/]
* @since [/]
*/
public class VolumeEntity {
/** volume总大小 */
private double allSize;
/** volume已使用大小 */
private double usedSize;
/** volume名称 */
private String name;
/** 挂载点 */
private String path;
/** * exist正常返回状态Started,Stopped,Created */
private String status;
private String type;
/** volume数据的树形目录 */
private FolderNode folder = new FolderNode();
/** volume的 块 */
private List<Brick> brick = new ArrayList<Brick>();
/**
* @return the allSize
*/
public double getAllSize() {
return allSize;
}
/**
* @param allSize the allSize to set
*/
public void setAllSize(double allSize) {
this.allSize = allSize;
}
/**
* @return the usedSize
*/
public double getUsedSize() {
return usedSize;
}
/**
* @param usedSize the usedSize to set
*/
public void setUsedSize(double usedSize) {
this.usedSize = usedSize;
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* @return the path
*/
public String getPath() {
return path;
}
/**
* @param path the path to set
*/
public void setPath(String path) {
this.path = path;
}
/**
* @return the status
*/
public String getStatus() {
return status;
}
/**
* @param status the status to set
*/
public void setStatus(String status) {
this.status = status;
}
/**
* @return the type
*/
public String getType() {
return type;
}
/**
* @param type the type to set
*/
public void setType(String type) {
this.type = type;
}
/**
* @return the folder
*/
public FolderNode getFolder() {
return folder;
}
/**
* @param folder the folder to set
*/
public void setFolder(FolderNode folder) {
this.folder = folder;
}
/**
* @return the brick
*/
public List<Brick> getBrick() {
return brick;
}
/**
* @param brick the brick to set
*/
public void setBrick(List<Brick> brick) {
this.brick = brick;
}
}

@ -0,0 +1,131 @@
package com.platform.http.gfs;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.sf.json.JSONArray;
import org.apache.log4j.Logger;
import com.base.MyException;
import com.base.PostData;
import com.base.TaskOperateData;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.platform.http.HttpUtils;
import com.platform.http.VolumeEntity;
import com.platform.utils.DateForm;
/**
* <>
* <>
* @author chen
* @version [201698]
* @see [/]
* @since [/]
*/
public class CopyData {
public static Logger log = Logger.getLogger(CopyData.class);
HttpUtils ht = new HttpUtils();
/**
* sourceFolderNamedestFolderName
* 1sourceFolderName-2 destFolderName-3
* @param sourceFolderName
* @param destFolderName
* @return
* @see [##]
*/
public int copyFolder(String sourceFolderName, String destFolderName) throws Exception{
int reslut = 0;
log.info(" copyFolder " + sourceFolderName + " --> " + destFolderName);
Map<String, Object> map = new HashMap<String, Object>();
map.put("sourcePath", sourceFolderName);
map.put("destPath", destFolderName);
//请求web
String rest = ht.sendPost("data/copyData", map);
if (null == rest || "".equals(rest)) {
log.error(" --- gluster is disconnect ! \n");
return 0;
}
Gson gs = new Gson();
PostData data = gs.fromJson(rest, PostData.class);
// 1 : 成功
double copyResult = (double) data.getData();
reslut = (int) copyResult;
getExcept(data);
return reslut;
}
/**
* sourceFolderNamedestFolderName
* 1sourceFolderName-2 destFolderName-3
* @param sourceFolderName
* @param destFolderName
* @return
* @see [##]
*/
public List<TaskOperateData> operationTask() throws Exception{
List<TaskOperateData> li = new ArrayList<TaskOperateData>();
Map<String, Object> map = new HashMap<String, Object>();
Calendar c2 = Calendar.getInstance();
map.put("endTime", DateForm.date2StringBysecond(c2.getTime()));
// 时间设置为 10天 前的时间
c2.set(Calendar.DAY_OF_YEAR, c2.get(Calendar.DAY_OF_YEAR) -10);
String time = DateForm.date2StringBysecond(c2.getTime());
map.put("startTime", time);
List<Integer> typeList = new ArrayList<Integer>();
typeList.add(0);
typeList.add(1);
typeList.add(2);
typeList.add(3);
typeList.add(-1);
typeList.add(-2);
map.put("statusList", typeList);
//请求web
String rest = ht.sendPost("data/getOperateTasks", map);
if (null == rest || "".equals(rest)) {
log.error(" --- gluster is disconnect ! \n");
return li;
}
Gson gs = new Gson();
PostData data = gs.fromJson(rest, (new PostData(new ArrayList<TaskOperateData>()).getClass()));
li = (List<TaskOperateData>) data.getData();
//解析 PostData
if(li.size() > 0){
JSONArray jsonarr = JSONArray.fromObject(data.getData());
try {
li = gs.fromJson(jsonarr.toString(), new TypeToken<List<TaskOperateData>>(){}.getType());
} catch (Exception e) {
log.error(e);
}
}
getExcept(data);
return li;
}
/**
* @param pd
*/
private void getExcept(PostData pd) {
StringBuffer sb = new StringBuffer();
for ( MyException object : pd.getExceptionsStack()) {
sb.append(object.getMess()).append(",");
}
if (!"".equals(sb.toString())) {
log.error(sb.toString());
}
}
}

@ -1,7 +0,0 @@
package com.platform.http.gfs;
public class HttpClientConstant {
public static String URL_IP_PORT = "http://192.168.0.110:8088/jfinal/";
}

@ -1,90 +0,0 @@
package com.platform.http.gfs;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import net.sf.json.JSONObject;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import org.apache.log4j.Logger;
import com.platform.controller.DataModelController;
import com.platform.utils.Bean2MapUtils;
import com.platform.utils.Configs;
public class HttpUtils {
public static Logger log = Configs.DAILY_ROLLING_LOGGER.getLogger(HttpUtils.class);
public String sendPost(String subUrl, Object data) {
String resultStr = "";
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(HttpClientConstant.URL_IP_PORT + subUrl);
try {
// 传参
List<NameValuePair> parameters = new ArrayList<NameValuePair>();
if (null != data) {
// 转 map
Map<String, Object> map = Bean2MapUtils.convertBean(data);
// 转json
JSONObject jsondata = JSONObject.fromObject(map);
// 封装数据
parameters.add(new BasicNameValuePair("jsondata", jsondata
.toString()));
parameters.add(new BasicNameValuePair("type", data.getClass()
.getName()));
// 传参 放入 url的 form中
UrlEncodedFormEntity entity = new UrlEncodedFormEntity(parameters,
"UTF-8");
post.setEntity(entity);
}
// 发送
HttpResponse respone = client.execute(post);
HttpEntity result = respone.getEntity();
if (null != result) {
resultStr = EntityUtils.toString(result);
}
// resultMap = Bean2MapUtils.convertBean(result);
} catch (Exception e) {
System.out.println(e);
}
return resultStr;
}
// public static void main(String[] args) {
// Date d = new Date();
// HttpUtils ht = new HttpUtils();
// BaseForm1 bas = new BaseForm1();
// bas.setId("12");
// bas.setName("n12");
// String rest = ht.sendPost("gfs/getAllvolume", null);
// if (null != rest) {
// System.out.println(rest);
// JSONArray jsondata = JSONArray.fromObject(rest);
// ArrayList<VolumeEntity> fo = (ArrayList<VolumeEntity>) JSONArray.toCollection(jsondata, VolumeEntity.class);
// System.err.println(fo);
// try {
// System.err.println(Bean2MapUtils.convertBean(fo));
// } catch (IllegalAccessException | InvocationTargetException
// | IntrospectionException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// }
//
// Date r = new Date();
// System.err.println(r.getTime() - d.getTime());
// }
}

@ -0,0 +1,84 @@
package com.platform.http.gfs;
import java.util.HashMap;
import java.util.Map;
import org.apache.log4j.Logger;
import com.base.MyException;
import com.base.PostData;
import com.google.gson.Gson;
import com.platform.http.HttpUtils;
/**
* @author chen
*
*/
public class RemoveData {
public static Logger log = Logger.getLogger ( RemoveData.class);
HttpUtils ht = new HttpUtils();
/**
* -1 :error; 0: the filename is not exists ; 1: right
* @param folderName
* @param fileName
* @return
*/
public int deleteFolder(String folderName) throws Exception{
int reslut = 0;
log.info("start delete "+folderName);
Map<String, Object> map = new HashMap<String, Object>();
map.put("removePath", folderName);
//请求 web sendPost
String rest = ht.sendPost("data/removeData", map);
if (null == rest || "".equals(rest)) {
log.error(" --- gluster is disconnect ! \n");
return 0;
}
Gson gs = new Gson();
PostData data = gs.fromJson(rest, PostData.class);
// 1 : 成功
double copyResult = (double) data.getData();
reslut = (int) copyResult;
getExcept(data);
return reslut;
}
public int abortcopyFolder(String sourceFolderName, String destFolderName) throws Exception{
int reslut = 0;
log.info(" abortcopyFolder " + sourceFolderName + " --> " + destFolderName);
Map<String, Object> map = new HashMap<String, Object>();
map.put("sourcePath", sourceFolderName);
map.put("destPath", destFolderName);
//请求web
String rest = ht.sendPost("data/abortCopyData", map);
if (null == rest || "".equals(rest)) {
log.error(" --- gluster is disconnect ! \n");
return 0;
}
Gson gs = new Gson();
PostData data = gs.fromJson(rest, PostData.class);
// 1 : 成功
double copyResult = (double) data.getData();
reslut = (int) copyResult;
getExcept(data);
return reslut;
}
/**
* @param pd
*/
private void getExcept(PostData pd) {
StringBuffer sb = new StringBuffer();
for ( MyException object : pd.getExceptionsStack()) {
sb.append(object.getMess()).append(",");
}
if (!"".equals(sb.toString())) {
log.error(sb.toString());
}
}
}

File diff suppressed because it is too large Load Diff

@ -113,10 +113,9 @@ public class OracleConnector {
Statement statement = null;
try {
statement = conn.createStatement();
statement.execute(sql);
flag = true;
flag =statement.execute(sql);
FileOperateHelper
.fileWrite(filePath+".log", sql+ "\r\n"+"OK \r\n");
.fileWrite(filePath+".log", sql+ "\r\n"+ flag +" \r\n");
} catch (SQLException e) {
flag = false;
FileOperateHelper

@ -17,7 +17,7 @@ import java.util.Map;
import com.platform.entities.FolderNode;
import com.platform.entities.RegionalismEntity;
import com.platform.entities.SystemEntity;
import com.platform.entities.VolumeEntity;
import com.platform.entities.VolumeDataEntity;
/**

@ -11,7 +11,7 @@ package com.platform.service;
import java.util.List;
import com.platform.entities.FolderNode;
import com.platform.entities.VolumeEntity;
import com.platform.entities.VolumeDataEntity;
/**
* <>
@ -44,7 +44,7 @@ public interface IGfsService {
* @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
@ -53,7 +53,7 @@ public interface IGfsService {
* @throws Exception
* @see [##]
*/
public List<VolumeEntity> getAllVolumes() throws Exception;
public List<VolumeDataEntity> getAllVolumes() throws Exception;
/**
* <> volume volume
@ -62,7 +62,7 @@ public interface IGfsService {
* @throws Exception
* @see [##]
*/
public VolumeEntity getOneVolume(String volumeName) throws Exception;
public VolumeDataEntity getOneVolume(String volumeName) throws Exception;
/**
* @param volumeName
@ -71,7 +71,7 @@ public interface IGfsService {
* @return
* @throws Exception
*/
public int moveData(String volumeName, String srcPath, String dstPath) throws Exception;
// public int moveData(String volumeName, String srcPath, String dstPath) throws Exception;
/**
* @param volumeName

@ -1,35 +1,41 @@
package com.platform.service;
import com.platform.entities.VolumeEntity;
import com.platform.entities.VolumeDataEntity;
public interface IVolumeService {
/** volume
* @return
* @throws Exception
*/
public String getAllvolume() throws Exception;
/** volume
* @param entity
* @return
* @throws Exception
*/
public int save(VolumeEntity entity) throws Exception;
public int save(VolumeDataEntity entity) throws Exception;
/** volume
* @param entity
* @return
* @throws Exception
*/
public int delete(VolumeEntity entity) throws Exception;
public int delete(VolumeDataEntity entity) throws Exception;
/** volume
* @param entity
* @return
* @throws Exception
*/
public int start(VolumeEntity entity) throws Exception;
public int start(VolumeDataEntity entity) throws Exception;
/** volume
* @param entity
* @return
* @throws Exception
*/
public int stop(VolumeEntity entity) throws Exception;
public int stop(VolumeDataEntity entity) throws Exception;
}

@ -71,7 +71,9 @@ public class OracleExtractHelper {
+ linkName;
//删除 dblink
if (OracleConnector.execOracleSQL(conn, deleteSql, Configs.EXTRACT_LOG_LOCALTION + oc.getName())) {
OracleConnector.execOracleSQL(conn, sql, Configs.EXTRACT_LOG_LOCALTION + oc.getName());
if(!OracleConnector.execOracleSQL(conn, sql, Configs.EXTRACT_LOG_LOCALTION + oc.getName())){
OracleConnector.execUpdateOracleSQL(conn, sql, Configs.EXTRACT_LOG_LOCALTION + oc.getName());
}
} else {
Configs.CONSOLE_LOGGER.error("删除已有的DBLink失败,无法创建新的DBLink!");
FileOperateHelper.fileWrite(Configs.EXTRACT_LOG_LOCALTION
@ -80,7 +82,9 @@ public class OracleExtractHelper {
} else {
// 否则创建dblink
OracleConnector.execOracleSQL(conn, sql, Configs.EXTRACT_LOG_LOCALTION + oc.getName());
if(!OracleConnector.execOracleSQL(conn, sql, Configs.EXTRACT_LOG_LOCALTION + oc.getName())){
OracleConnector.execUpdateOracleSQL(conn, sql, Configs.EXTRACT_LOG_LOCALTION + oc.getName());
}
}
}
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save