diff --git a/src/com/platform/glusterfs/CheckoutMD5.java b/src/com/platform/glusterfs/CheckoutMD5.java index 810ec443..33b5d3ad 100644 --- a/src/com/platform/glusterfs/CheckoutMD5.java +++ b/src/com/platform/glusterfs/CheckoutMD5.java @@ -6,9 +6,6 @@ import java.util.List; import java.util.Map; import org.apache.log4j.Logger; -import org.aspectj.weaver.ast.And; - -import com.mysql.jdbc.log.Log; import com.platform.utils.Constant; public class CheckoutMD5 { diff --git a/src/com/platform/http/gfs/BaseForm1.java b/src/com/platform/http/gfs/BaseForm1.java new file mode 100644 index 00000000..bbd86721 --- /dev/null +++ b/src/com/platform/http/gfs/BaseForm1.java @@ -0,0 +1,20 @@ +package com.platform.http.gfs; + +public class BaseForm1 { + + private String id; + private String name; + public String getId() { + return id; + } + public void setId(String id) { + this.id = id; + } + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + +} diff --git a/src/com/platform/http/gfs/HttpClientConstant.java b/src/com/platform/http/gfs/HttpClientConstant.java new file mode 100644 index 00000000..527cf7b2 --- /dev/null +++ b/src/com/platform/http/gfs/HttpClientConstant.java @@ -0,0 +1,7 @@ +package com.platform.http.gfs; + +public class HttpClientConstant { + + public static String URL_IP_PORT = "http://localhost"; + +} diff --git a/src/com/platform/http/gfs/HttpUtils.java b/src/com/platform/http/gfs/HttpUtils.java new file mode 100644 index 00000000..df7e1995 --- /dev/null +++ b/src/com/platform/http/gfs/HttpUtils.java @@ -0,0 +1,88 @@ +package com.platform.http.gfs; + +import java.beans.IntrospectionException; +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; + +import javax.sound.midi.SysexMessage; + +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 com.platform.entities.FolderNode; +import com.platform.utils.Bean2MapUtils; + +public class HttpUtils { + + public Object sendPost(String subUrl, Object data) { + Map resultMap = null; + String resultStr = null; + HttpClient client = new DefaultHttpClient(); + HttpPost post = new HttpPost(HttpClientConstant.URL_IP_PORT + subUrl); + try { + // 传参 + List parameters = new ArrayList(); + // 转 map + Map 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"); + Object rest = ht.sendPost("/hello/gain", bas); + if (null != rest) { + System.out.println(rest); + JSONObject jsondata = JSONObject.fromObject(rest); + FolderNode fo = (FolderNode) JSONObject.toBean((JSONObject) jsondata, FolderNode.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()); + } + +} diff --git a/src/com/platform/utils/ThreadVolume.java b/src/com/platform/utils/ThreadVolume.java index b0b9ac91..640600d8 100644 --- a/src/com/platform/utils/ThreadVolume.java +++ b/src/com/platform/utils/ThreadVolume.java @@ -27,6 +27,9 @@ public class ThreadVolume extends Thread { private ClusterInfo cluster = new ClusterInfo(); + /** gfs目录树形展示 */ + private GetTreeData gfsTree = new GetTreeData(); + public ThreadVolume() { // TODO Auto-generated constructor stub } @@ -41,9 +44,6 @@ public class ThreadVolume extends Thread { } } - /** gfs目录树形展示 */ - private GetTreeData gfsTree = new GetTreeData(); - @Override public void run() { super.run();