diff options
author | Martin Polden <martin.polden@gmail.com> | 2017-06-09 11:32:23 +0200 |
---|---|---|
committer | Martin Polden <martin.polden@gmail.com> | 2017-06-09 11:32:23 +0200 |
commit | 8322f4b1a0992f4b7edb77d1755bce87d681499c (patch) | |
tree | e25b6bae87529a7d82bf7aeabcfafb123fd0e66e /node-maintainer | |
parent | f2e64369ceb8ced2949eb45d14911823d6cff3b3 (diff) |
Remove reference to internal URL
Diffstat (limited to 'node-maintainer')
3 files changed, 18 insertions, 7 deletions
diff --git a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/maintainer/CoredumpHandler.java b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/maintainer/CoredumpHandler.java index 2a641ae2356..9f2feea0ca1 100644 --- a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/maintainer/CoredumpHandler.java +++ b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/maintainer/CoredumpHandler.java @@ -28,7 +28,7 @@ import java.util.stream.Collectors; * @author freva */ public class CoredumpHandler { - public static final String FEED_ENDPOINT = "http://panic.vespa.us-west-1.prod.vespa.yahooapis.com:4080/document/v1/panic/core_dump/docid"; + public static final String PROCESSING_DIRECTORY_NAME = "processing"; public static final String METADATA_FILE_NAME = "metadata.json"; @@ -41,15 +41,17 @@ public class CoredumpHandler { private final Path doneCoredumpsPath; private final Map<String, Object> nodeAttributes; private final Optional<Path> yinstStatePath; + private final String feedEndpoint; public CoredumpHandler(HttpClient httpClient, CoreCollector coreCollector, Path coredumpsPath, Path doneCoredumpsPath, - Map<String, Object> nodeAttributes, Optional<Path> yinstStatePath) { + Map<String, Object> nodeAttributes, Optional<Path> yinstStatePath, String feedEndpoint) { this.httpClient = httpClient; this.coreCollector = coreCollector; this.coredumpsPath = coredumpsPath; this.doneCoredumpsPath = doneCoredumpsPath; this.nodeAttributes = nodeAttributes; this.yinstStatePath = yinstStatePath; + this.feedEndpoint = feedEndpoint; } public void processAll() throws IOException { @@ -140,7 +142,7 @@ public class CoredumpHandler { // Use core dump UUID as document ID String documentId = coredumpDirectory.getFileName().toString(); - HttpPost post = new HttpPost(FEED_ENDPOINT + "/" + documentId); + HttpPost post = new HttpPost(feedEndpoint + "/" + documentId); post.setHeader(HttpHeaders.CONTENT_TYPE, "application/json"); post.setEntity(new StringEntity(metadata)); @@ -157,4 +159,5 @@ public class CoredumpHandler { void finishProcessing(Path coredumpDirectory) throws IOException { Files.move(coredumpDirectory, doneCoredumpsPath.resolve(coredumpDirectory.getFileName())); } + } diff --git a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/maintainer/Maintainer.java b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/maintainer/Maintainer.java index dac6b293942..97c6457e49c 100644 --- a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/maintainer/Maintainer.java +++ b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/maintainer/Maintainer.java @@ -24,6 +24,7 @@ import java.util.concurrent.atomic.AtomicInteger; * @author freva */ public class Maintainer { + private static final CoreCollector coreCollector = new CoreCollector(new ProcessExecuter()); private static final HttpClient httpClient = createHttpClient(Duration.ofSeconds(5)); @@ -142,10 +143,12 @@ public class Maintainer { Path doneCoredumpsPath = Paths.get(getFieldOrFail(arguments, "doneCoredumpsPath").asString()); Map<String, Object> attributesMap = parseMap(arguments); Optional<Path> yinstStatePath = SlimeUtils.optionalString(arguments.field("yinstStatePath")).map(Paths::get); + String feedEndpoint = getFieldOrFail(arguments, "feedEndpoint").asString(); try { - CoredumpHandler coredumpHandler = new CoredumpHandler(httpClient, coreCollector, - coredumpsPath, doneCoredumpsPath, attributesMap, yinstStatePath); + CoredumpHandler coredumpHandler = new CoredumpHandler(httpClient, coreCollector, coredumpsPath, + doneCoredumpsPath, attributesMap, yinstStatePath, + feedEndpoint); coredumpHandler.processAll(); } catch (IOException e) { throw new RuntimeException("Failed processing coredumps at " + coredumpsPath.toAbsolutePath() + @@ -194,4 +197,5 @@ public class Maintainer { .build()) .build(); } + } diff --git a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/maintainer/CoredumpHandlerTest.java b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/maintainer/CoredumpHandlerTest.java index faf2e03d068..13a6f7b334b 100644 --- a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/maintainer/CoredumpHandlerTest.java +++ b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/maintainer/CoredumpHandlerTest.java @@ -42,6 +42,7 @@ import static org.mockito.Mockito.when; * @author freva */ public class CoredumpHandlerTest { + private final HttpClient httpClient = mock(HttpClient.class); private final CoreCollector coreCollector = mock(CoreCollector.class); private static final Map<String, Object> attributes = new LinkedHashMap<>(); @@ -53,6 +54,7 @@ public class CoredumpHandlerTest { "\"vespa_version\":\"6.48.4\"," + "\"kernel_version\":\"2.6.32-573.22.1.el6.YAHOO.20160401.10.x86_64\"," + "\"docker_image\":\"vespa/ci:6.48.4\"}}"; + private static final String feedEndpoint = "http://feed-endpoint.hostname.tld/feed"; static { attributes.put("hostname", "host123.yahoo.com"); @@ -76,7 +78,8 @@ public class CoredumpHandlerTest { crashPath = folder.newFolder("crash").toPath(); donePath = folder.newFolder("done").toPath(); - coredumpHandler = new CoredumpHandler(httpClient, coreCollector, crashPath, donePath, attributes, Optional.empty()); + coredumpHandler = new CoredumpHandler(httpClient, coreCollector, crashPath, donePath, attributes, + Optional.empty(), feedEndpoint); } @Test @@ -207,10 +210,11 @@ public class CoredumpHandlerTest { ArgumentCaptor<HttpPost> capturedPost = ArgumentCaptor.forClass(HttpPost.class); verify(httpClient).execute(capturedPost.capture()); - URI expectedURI = new URI(CoredumpHandler.FEED_ENDPOINT + "/" + documentId); + URI expectedURI = new URI(feedEndpoint + "/" + documentId); assertEquals(expectedURI, capturedPost.getValue().getURI()); assertEquals("application/json", capturedPost.getValue().getHeaders(HttpHeaders.CONTENT_TYPE)[0].getValue()); assertEquals(expectedBody, new BufferedReader(new InputStreamReader(capturedPost.getValue().getEntity().getContent())).readLine()); } + } |