diff options
author | youbowu <wu.youbo@zte.com.cn> | 2017-03-11 17:56:07 +0800 |
---|---|---|
committer | 6092002067 <wu.youbo@zte.com.cn> | 2017-03-11 17:56:07 +0800 |
commit | 6112b640c9ae4a08fa5ac3b37026a70c1ed0f8c5 (patch) | |
tree | b080f064d2361e3db6b9b9fc26306727df53b9a5 /rulemgt/src/main/java | |
parent | a07e2612edf2b7f52a30151886a580cbea49ee52 (diff) |
Add log for debugging
Issue-ID: HOLMES-51
Change-Id: I3188905c119716a3b8ca772a45a86100cc85045b
Signed-off-by: youbowu <wu.youbo@zte.com.cn>
Diffstat (limited to 'rulemgt/src/main/java')
-rw-r--r-- | rulemgt/src/main/java/org/openo/holmes/rulemgt/bolt/enginebolt/EngineService.java | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/rulemgt/src/main/java/org/openo/holmes/rulemgt/bolt/enginebolt/EngineService.java b/rulemgt/src/main/java/org/openo/holmes/rulemgt/bolt/enginebolt/EngineService.java index 72e9a66..5588dd4 100644 --- a/rulemgt/src/main/java/org/openo/holmes/rulemgt/bolt/enginebolt/EngineService.java +++ b/rulemgt/src/main/java/org/openo/holmes/rulemgt/bolt/enginebolt/EngineService.java @@ -24,6 +24,7 @@ import org.apache.commons.lang3.StringUtils; import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpDelete;
+import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.client.methods.HttpRequestBase;
@@ -31,6 +32,7 @@ import org.apache.http.entity.BufferedHttpEntity; import org.apache.http.entity.ByteArrayEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
+import org.apache.http.util.EntityUtils;
import org.jvnet.hk2.annotations.Service;
import org.openo.holmes.common.config.MicroServiceConfig;
import org.openo.holmes.common.exception.CorrelationException;
@@ -43,21 +45,33 @@ import org.openo.holmes.rulemgt.constant.RuleMgtConstant; @Service
public class EngineService {
+ String url = "http://10.250.0.3:9102";
+
protected HttpResponse delete(String packageName) throws IOException {
- return deleteRequest(MicroServiceConfig.getMsbServerAddr() + RuleMgtConstant.ENGINE_PATH + "/" + packageName);
+ return deleteRequest(url + RuleMgtConstant.ENGINE_PATH + "/" + packageName);
}
protected HttpResponse check(CorrelationCheckRule4Engine correlationCheckRule4Engine)
throws IOException {
ObjectMapper mapper = new ObjectMapper();
String content = mapper.writeValueAsString(correlationCheckRule4Engine);
- return postRequest(MicroServiceConfig.getMsbServerAddr() + RuleMgtConstant.ENGINE_PATH, content);
+ String queryUrl = MicroServiceConfig.getMsbServerAddr()
+ + "/openoapi/microservices/v1/services/holmes-engine/version/v1";
+ HttpGet httpGet = new HttpGet(queryUrl);
+ CloseableHttpClient httpClient = HttpClients.createDefault();
+ try {
+ HttpResponse httpResponse = httpClient.execute(httpGet);
+ log.info("response entity:" + EntityUtils.toString(httpResponse.getEntity()));
+ } finally {
+ httpClient.close();
+ }
+ return postRequest(url + RuleMgtConstant.ENGINE_PATH, content);
}
protected HttpResponse deploy(CorrelationDeployRule4Engine correlationDeployRule4Engine) throws IOException {
ObjectMapper mapper = new ObjectMapper();
String content = mapper.writeValueAsString(correlationDeployRule4Engine);
- return putRequest(MicroServiceConfig.getMsbServerAddr() + RuleMgtConstant.ENGINE_PATH, content);
+ return putRequest(url + RuleMgtConstant.ENGINE_PATH, content);
}
private HttpResponse postRequest(String url, String content) throws IOException {
@@ -104,6 +118,7 @@ public class EngineService { httpRequestBase.setHeader("Content-Type", "text/html;charset=UTF-8");
httpRequestBase.setHeader("Accept", "application/json");
httpRequestBase.setHeader("Content-Type", "application/json");
+ httpRequestBase.setHeader("Content-Length", "2000");
}
public byte[] getData(HttpEntity httpEntity) throws IOException {
|