summaryrefslogtreecommitdiffstats
path: root/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/report/BenchmarkReport.java
blob: 0d21816e69b5e68cb38f1d64f3885ecae208fbc9 (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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package com.yahoo.vespa.hosted.node.verification.commons.report;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

/**
 * Created by sgrostad on 12/07/2017.
 * JSON-mapped class for reporting benchmark results to node repo
 */
@JsonInclude(JsonInclude.Include.NON_NULL)
public class BenchmarkReport {

    @JsonProperty
    private Double cpuCyclesPerSec;
    @JsonProperty
    private Double diskSpeedMbs;
    @JsonProperty
    private Double memoryWriteSpeedGBs;
    @JsonProperty
    private Double memoryReadSpeedGBs;

    public void setCpuCyclesPerSec(double cpuCyclesPerSec) {
        this.cpuCyclesPerSec = cpuCyclesPerSec;
    }

    public void setDiskSpeedMbs(Double diskSpeedMbs) {
        this.diskSpeedMbs = diskSpeedMbs != null ? diskSpeedMbs : -1;
    }


    public void setMemoryWriteSpeedGBs(Double memoryWriteSpeedGBs) {
        this.memoryWriteSpeedGBs = memoryWriteSpeedGBs != null ? memoryWriteSpeedGBs : -1;
    }

    public void setMemoryReadSpeedGBs(Double memoryReadSpeedGBs) {
        this.memoryReadSpeedGBs = memoryReadSpeedGBs != null ? memoryReadSpeedGBs : -1;
    }

    public Double getCpuCyclesPerSec() {
        return cpuCyclesPerSec;
    }

    public Double getDiskSpeedMbs() {
        return diskSpeedMbs;
    }

    public Double getMemoryWriteSpeedGBs() {
        return memoryWriteSpeedGBs;
    }

    public Double getMemoryReadSpeedGBs() {
        return memoryReadSpeedGBs;
    }

    @JsonIgnore
    public boolean isAllBenchmarksOK() {
        ObjectMapper om = new ObjectMapper();
        try {
            String jsonReport = om.writeValueAsString(this);
            return jsonReport.length() == 2;
        } catch (JsonProcessingException e){
            e.printStackTrace();
            return false;
        }
    }

}