blob: a2483435e18a337329d04e6ac3f4953d5cc1d9e8 (
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.node.verification.commons.noderepo;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.net.InetAddresses;
import com.yahoo.vespa.hosted.node.verification.spec.retrievers.HardwareInfo;
import com.yahoo.vespa.hosted.node.verification.spec.retrievers.HardwareInfo.DiskType;
import java.net.Inet4Address;
import java.net.Inet6Address;
import java.net.InetAddress;
import java.util.stream.Stream;
/**
* Object with the information node repositories has about the node.
*
* @author olaaun
* @author sgrostad
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public class NodeSpec {
@JsonProperty("minDiskAvailableGb")
private double minDiskAvailableGb;
@JsonProperty("minMainMemoryAvailableGb")
private double minMainMemoryAvailableGb;
@JsonProperty("minCpuCores")
private double minCpuCores;
@JsonProperty("fastDisk")
private boolean fastDisk;
@JsonProperty("ipAddresses")
private String[] ipAddresses;
@JsonProperty
private String hostname;
@JsonProperty
private String hardwareDivergence;
private String nodeRepoUrl;
public HardwareInfo copyToHardwareInfo() {
HardwareInfo hardwareInfo = new HardwareInfo();
hardwareInfo.setMinMainMemoryAvailableGb(this.minMainMemoryAvailableGb);
hardwareInfo.setMinDiskAvailableGb(this.minDiskAvailableGb);
hardwareInfo.setMinCpuCores((int) Math.round(this.minCpuCores));
hardwareInfo.setDiskType(this.fastDisk ? DiskType.FAST : DiskType.SLOW);
hardwareInfo.setIpv6Connection(getIpv6Address() != null);
return hardwareInfo;
}
public String getIpv6Address() {
return Stream.of(ipAddresses)
.map(InetAddresses::forString)
.filter(ip -> ip instanceof Inet6Address)
.findFirst().map(InetAddress::getHostAddress).orElse(null);
}
public String getIpv4Address() {
return Stream.of(ipAddresses)
.map(InetAddresses::forString)
.filter(ip -> ip instanceof Inet4Address)
.findFirst().map(InetAddress::getHostAddress).orElse(null);
}
public double getMinDiskAvailableGb() {
return minDiskAvailableGb;
}
public double getMinMainMemoryAvailableGb() {
return minMainMemoryAvailableGb;
}
public double getMinCpuCores() {
return minCpuCores;
}
public boolean isFastDisk() {
return fastDisk;
}
public String getHostname() {
return hostname;
}
public String getHardwareDivergence() {
return hardwareDivergence;
}
}
|