summaryrefslogtreecommitdiffstats
path: root/node-maintainer
diff options
context:
space:
mode:
authorOla Aunrønning <olaa@yahoo-inc.com>2017-08-09 15:03:02 +0200
committerOla Aunrønning <olaa@yahoo-inc.com>2017-08-15 12:29:40 +0200
commit35fab7f245e8755585ce4f5cb3115fdcc1971d5f (patch)
tree9ea5cad2b4912888d03771e64edb967e8f3a1268 /node-maintainer
parenta5a59c808b733681d894cf001466fd711555f02b (diff)
Now sends HTTP Patch including benchmark/verification results to node repo
Diffstat (limited to 'node-maintainer')
-rw-r--r--node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/ReportSender.java39
1 files changed, 20 insertions, 19 deletions
diff --git a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/ReportSender.java b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/ReportSender.java
index cd89a1524cf..d058c4c263e 100644
--- a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/ReportSender.java
+++ b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/ReportSender.java
@@ -2,23 +2,28 @@ package com.yahoo.vespa.hosted.node.verification.commons;
import com.fasterxml.jackson.databind.ObjectMapper;
-import com.yahoo.application.Networking;
-import com.yahoo.application.container.handler.Request;
-import com.yahoo.application.container.JDisc;
-import com.yahoo.application.container.handler.Response;
-import com.yahoo.text.Utf8;
import com.yahoo.vespa.hosted.node.verification.commons.noderepo.NodeRepoInfoRetriever;
import com.yahoo.vespa.hosted.node.verification.commons.noderepo.NodeRepoJsonModel;
import com.yahoo.vespa.hosted.node.verification.commons.report.BenchmarkReport;
import com.yahoo.vespa.hosted.node.verification.commons.report.HardwareDivergenceReport;
import com.yahoo.vespa.hosted.node.verification.commons.report.SpecVerificationReport;
+import org.apache.http.client.ClientProtocolException;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpPatch;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
+import java.util.logging.Level;
+import java.util.logging.Logger;
public class ReportSender {
+ private static final Logger logger = Logger.getLogger(ReportSender.class.getName());
+
private static void updateNodeRepository(ArrayList<URL> nodeInfoUrls, HardwareDivergenceReport hardwareDivergenceReport) throws IOException {
ObjectMapper om = new ObjectMapper();
String report;
@@ -28,21 +33,17 @@ public class ReportSender {
else {
report = "{\"hardwareDivergence\": " + om.writeValueAsString(hardwareDivergenceReport) + "}";
}
- System.out.println(report);
- /*
- //TODO: Update node repo
- String url = nodeInfoUrls.get(0).toString();
- Request request = new Request(url, Utf8.toBytes(report), Request.Method.PATCH);
- JDisc container = JDisc.fromServicesXml("<jdisc version=\"1.0\"/>", Networking.disable);
- Response response = container.handleRequest(request);
- container.close();
-
- for (URL nodeInfoUrl : nodeInfoUrls) {
- new Request(nodeInfoUrl.toString(),
- Utf8.toBytes(report),
- Request.Method.PATCH);
+ HttpPatch httpPatch = new HttpPatch(nodeInfoUrls.get(0).toString());
+ httpPatch.setEntity(new StringEntity(report));
+ CloseableHttpClient httpClient = HttpClients.createDefault();
+ try {
+ CloseableHttpResponse httpResponse = httpClient.execute(httpPatch);
+ logger.log(Level.INFO, "Response code: " + httpResponse.getStatusLine().getStatusCode());
- }*/
+ } catch (ClientProtocolException e) {
+ System.out.println("Failed to patch node repo - Invalid URL");
+ }
+ httpClient.close();
}
public static void reportBenchmarkResults(BenchmarkReport benchmarkReport, ArrayList<URL> nodeInfoUrls) throws IOException {