Add log for debugging
authoryoubowu <wu.youbo@zte.com.cn>
Sat, 11 Mar 2017 09:56:07 +0000 (17:56 +0800)
committer6092002067 <wu.youbo@zte.com.cn>
Sat, 11 Mar 2017 09:56:07 +0000 (17:56 +0800)
Issue-ID: HOLMES-51

Change-Id: I3188905c119716a3b8ca772a45a86100cc85045b
Signed-off-by: youbowu <wu.youbo@zte.com.cn>
rulemgt/src/main/java/org/openo/holmes/rulemgt/bolt/enginebolt/EngineService.java

index 72e9a66..5588dd4 100644 (file)
@@ -24,6 +24,7 @@ import org.apache.commons.lang3.StringUtils;
 import org.apache.http.HttpEntity;\r
 import org.apache.http.HttpResponse;\r
 import org.apache.http.client.methods.HttpDelete;\r
+import org.apache.http.client.methods.HttpGet;\r
 import org.apache.http.client.methods.HttpPost;\r
 import org.apache.http.client.methods.HttpPut;\r
 import org.apache.http.client.methods.HttpRequestBase;\r
@@ -31,6 +32,7 @@ import org.apache.http.entity.BufferedHttpEntity;
 import org.apache.http.entity.ByteArrayEntity;\r
 import org.apache.http.impl.client.CloseableHttpClient;\r
 import org.apache.http.impl.client.HttpClients;\r
+import org.apache.http.util.EntityUtils;\r
 import org.jvnet.hk2.annotations.Service;\r
 import org.openo.holmes.common.config.MicroServiceConfig;\r
 import org.openo.holmes.common.exception.CorrelationException;\r
@@ -43,21 +45,33 @@ import org.openo.holmes.rulemgt.constant.RuleMgtConstant;
 @Service\r
 public class EngineService {\r
 \r
+    String url = "http://10.250.0.3:9102";\r
+\r
     protected HttpResponse delete(String packageName) throws IOException {\r
-        return deleteRequest(MicroServiceConfig.getMsbServerAddr() + RuleMgtConstant.ENGINE_PATH + "/" + packageName);\r
+        return deleteRequest(url + RuleMgtConstant.ENGINE_PATH + "/" + packageName);\r
     }\r
 \r
     protected HttpResponse check(CorrelationCheckRule4Engine correlationCheckRule4Engine)\r
             throws IOException {\r
         ObjectMapper mapper = new ObjectMapper();\r
         String content = mapper.writeValueAsString(correlationCheckRule4Engine);\r
-        return postRequest(MicroServiceConfig.getMsbServerAddr() + RuleMgtConstant.ENGINE_PATH, content);\r
+        String queryUrl = MicroServiceConfig.getMsbServerAddr()\r
+                + "/openoapi/microservices/v1/services/holmes-engine/version/v1";\r
+        HttpGet httpGet = new HttpGet(queryUrl);\r
+        CloseableHttpClient httpClient = HttpClients.createDefault();\r
+        try {\r
+            HttpResponse httpResponse = httpClient.execute(httpGet);\r
+            log.info("response entity:" + EntityUtils.toString(httpResponse.getEntity()));\r
+        } finally {\r
+            httpClient.close();\r
+        }\r
+        return postRequest(url + RuleMgtConstant.ENGINE_PATH, content);\r
     }\r
 \r
     protected HttpResponse deploy(CorrelationDeployRule4Engine correlationDeployRule4Engine) throws IOException {\r
         ObjectMapper mapper = new ObjectMapper();\r
         String content = mapper.writeValueAsString(correlationDeployRule4Engine);\r
-        return putRequest(MicroServiceConfig.getMsbServerAddr() + RuleMgtConstant.ENGINE_PATH, content);\r
+        return putRequest(url + RuleMgtConstant.ENGINE_PATH, content);\r
     }\r
 \r
     private HttpResponse postRequest(String url, String content) throws IOException {\r
@@ -104,6 +118,7 @@ public class EngineService {
         httpRequestBase.setHeader("Content-Type", "text/html;charset=UTF-8");\r
         httpRequestBase.setHeader("Accept", "application/json");\r
         httpRequestBase.setHeader("Content-Type", "application/json");\r
+        httpRequestBase.setHeader("Content-Length", "2000");\r
     }\r
 \r
     public byte[] getData(HttpEntity httpEntity) throws IOException {\r