aboutsummaryrefslogtreecommitdiffstats
path: root/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/configserver/cores/CoresImpl.java
blob: 200fe97283c3c6e306cdac8c2015ddcc69971a7c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.node.admin.configserver.cores;

import com.yahoo.config.provision.HostName;
import com.yahoo.vespa.hosted.node.admin.configserver.ConfigServerApi;
import com.yahoo.vespa.hosted.node.admin.configserver.StandardConfigServerResponse;
import com.yahoo.vespa.hosted.node.admin.configserver.cores.bindings.ReportCoreDumpRequest;

/**
 * @author hakonhall
 */
public class CoresImpl implements Cores {
    private final ConfigServerApi configServerApi;

    public CoresImpl(ConfigServerApi configServerApi) {
        this.configServerApi = configServerApi;
    }

    @Override
    public void report(HostName hostname, String id, CoreDumpMetadata metadata) {
        var request = new ReportCoreDumpRequest().fillFrom(metadata);
        String uriPath = "/cores/v1/report/" + hostname.value() + "/" + id;
        configServerApi.post(uriPath, request, StandardConfigServerResponse.class)
                       .throwOnError("Failed to report core dump at " + metadata.coredumpPath());
    }
}