diff options
Diffstat (limited to 'node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification')
30 files changed, 212 insertions, 106 deletions
diff --git a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/CommandExecutor.java b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/CommandExecutor.java index e1d0e46c173..eac0bc574c3 100644 --- a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/CommandExecutor.java +++ b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/CommandExecutor.java @@ -10,16 +10,19 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.StringReader; import java.util.ArrayList; +import java.util.List; /** - * Created by olaa on 03/07/2017. * Wrapper for executing terminal commands + * + * @author olaaun + * @author sgrostad */ public class CommandExecutor { - public ArrayList<String> executeCommand(String command) throws IOException { + public List<String> executeCommand(String command) throws IOException { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); - ArrayList<String> results = new ArrayList<>(); + List<String> results = new ArrayList<>(); writeToOutputStream(outputStream, command); writeOutputStreamToResults(outputStream, results); return results; @@ -35,7 +38,7 @@ public class CommandExecutor { executor.execute(cmdLine); } - private void writeOutputStreamToResults(ByteArrayOutputStream outputStream, ArrayList<String> results) throws IOException { + private void writeOutputStreamToResults(ByteArrayOutputStream outputStream, List<String> results) throws IOException { String out = outputStream.toString(); BufferedReader br = new BufferedReader(new StringReader(out)); String line; diff --git a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/HostURLGenerator.java b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/HostURLGenerator.java index b43c9caed54..7e8b198428f 100644 --- a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/HostURLGenerator.java +++ b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/HostURLGenerator.java @@ -5,10 +5,13 @@ import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; +import java.util.List; /** - * Created by olaa on 14/07/2017. * Makes the URL used to retrieve the JSON from the node repository with information about the node's spec. + * + * @author olaaun + * @author sgrostad */ public class HostURLGenerator { @@ -18,8 +21,8 @@ public class HostURLGenerator { private static final String PARSE_ALL_HOSTNAMES_REGEX = ","; private static final String PROTOCOL_REGEX = "^(https?|file)://.*$"; - public static ArrayList<URL> generateNodeInfoUrl(CommandExecutor commandExecutor, String commaSeparatedUrls) throws IOException { - ArrayList<URL> nodeInfoUrls = new ArrayList<>(); + public static List<URL> generateNodeInfoUrl(CommandExecutor commandExecutor, String commaSeparatedUrls) throws IOException { + List<URL> nodeInfoUrls = new ArrayList<>(); String[] configServerHostNames = commaSeparatedUrls.split(PARSE_ALL_HOSTNAMES_REGEX); String nodeHostName = generateNodeHostName(commandExecutor); for (String configServerHostName : configServerHostNames) { @@ -34,7 +37,7 @@ public class HostURLGenerator { } protected static String getEnvironmentVariable(CommandExecutor commandExecutor) throws IOException { - ArrayList<String> output = commandExecutor.executeCommand("hostname"); + List<String> output = commandExecutor.executeCommand("hostname"); if (output.size() == 1) { return output.get(0); } diff --git a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/noderepo/IPAddressVerifier.java b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/noderepo/IPAddressVerifier.java index 483c07002dd..db4eb6e73cd 100644 --- a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/noderepo/IPAddressVerifier.java +++ b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/noderepo/IPAddressVerifier.java @@ -12,14 +12,17 @@ import javax.naming.directory.InitialDirContext; import java.util.ArrayList; import java.util.Enumeration; import java.util.Hashtable; +import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; /** * Created by olaa on 14/07/2017. * Verifies that the IP addresses of a node points to the correct hostname + * + * @author olaaun + * @author sgrostad */ - public class IPAddressVerifier { private static final Logger logger = Logger.getLogger(IPAddressVerifier.class.getName()); @@ -33,7 +36,7 @@ public class IPAddressVerifier { public String[] getFaultyIpAddresses(NodeRepoJsonModel jsonModel) { String expectedHostname = jsonModel.getHostname(); - ArrayList<String> faultyIpAddresses = new ArrayList<>(); + List<String> faultyIpAddresses = new ArrayList<>(); if (expectedHostname == null || expectedHostname.equals("")) return new String[0]; if (!isValidIpv4(jsonModel.getIpv4Address(), expectedHostname)) { diff --git a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/noderepo/NodeJsonConverter.java b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/noderepo/NodeJsonConverter.java index ef6d706a1a4..5cf4bede3f1 100644 --- a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/noderepo/NodeJsonConverter.java +++ b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/noderepo/NodeJsonConverter.java @@ -4,8 +4,10 @@ package com.yahoo.vespa.hosted.node.verification.commons.noderepo; import com.yahoo.vespa.hosted.node.verification.spec.retrievers.HardwareInfo; /** - * Created by olaa on 07/07/2017. * Converts a NodeRepoJsonModel object to a HardwareInfo object. + * + * @author olaaun + * @author sgrostad */ public class NodeJsonConverter { diff --git a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/noderepo/NodeRepoInfoRetriever.java b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/noderepo/NodeRepoInfoRetriever.java index 4d261334d35..57506e44961 100644 --- a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/noderepo/NodeRepoInfoRetriever.java +++ b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/noderepo/NodeRepoInfoRetriever.java @@ -6,18 +6,21 @@ import com.fasterxml.jackson.databind.ObjectMapper; import java.io.IOException; import java.net.URL; import java.util.ArrayList; +import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; /** - * Created by olaa on 04/07/2017. * Parse JSON from node repository and stores information as a NodeRepoJsonModel object. + * + * @author olaaun + * @author sgrostad */ public class NodeRepoInfoRetriever { private static final Logger logger = Logger.getLogger(NodeRepoInfoRetriever.class.getName()); - public static NodeRepoJsonModel retrieve(ArrayList<URL> nodeInfoUrls) throws IOException { + public static NodeRepoJsonModel retrieve(List<URL> nodeInfoUrls) throws IOException { NodeRepoJsonModel nodeRepoJsonModel; ObjectMapper objectMapper = new ObjectMapper(); for (URL nodeInfoURL : nodeInfoUrls) { diff --git a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/noderepo/NodeRepoJsonModel.java b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/noderepo/NodeRepoJsonModel.java index 043cccb681c..5d7ff0df8d1 100644 --- a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/noderepo/NodeRepoJsonModel.java +++ b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/noderepo/NodeRepoJsonModel.java @@ -13,12 +13,14 @@ import java.net.InetAddress; import java.util.stream.Stream; /** - * Created by olaa on 05/07/2017. * Object with the information node repositories has about the node. + * + * @author olaaun + * @author sgrostad */ - @JsonIgnoreProperties(ignoreUnknown = true) public class NodeRepoJsonModel { + @JsonProperty("minDiskAvailableGb") private double minDiskAvailableGb; @JsonProperty("minMainMemoryAvailableGb") diff --git a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/parser/OutputParser.java b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/parser/OutputParser.java index 88e1d22cc0e..5da5abd4ad2 100644 --- a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/parser/OutputParser.java +++ b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/parser/OutputParser.java @@ -2,19 +2,22 @@ package com.yahoo.vespa.hosted.node.verification.commons.parser; import java.util.ArrayList; +import java.util.List; import java.util.regex.Pattern; /** - * Created by sgrostad on 17/07/2017. * Parses terminal command output, and returns results based on ParseInstructions + * + * @author sgrostad + * @author olaaaun */ public class OutputParser { - public static ArrayList<ParseResult> parseOutput(ParseInstructions parseInstructions, ArrayList<String> commandOutput) { - ArrayList<ParseResult> results = new ArrayList<>(); + public static List<ParseResult> parseOutput(ParseInstructions parseInstructions, List<String> commandOutput) { + List<ParseResult> results = new ArrayList<>(); int searchElementIndex = parseInstructions.getSearchElementIndex(); int valueElementIndex = parseInstructions.getValueElementIndex(); - ArrayList<String> searchWords = parseInstructions.getSearchWords(); + List<String> searchWords = parseInstructions.getSearchWords(); for (String line : commandOutput) { String[] lineSplit = line.trim().split(parseInstructions.getSplitRegex()); if (lineSplit.length <= Math.max(searchElementIndex, valueElementIndex)) { @@ -30,15 +33,15 @@ public class OutputParser { return results; } - public static ParseResult parseSingleOutput(ParseInstructions parseInstructions, ArrayList<String> commandOutput) { - ArrayList<ParseResult> parseResults = parseOutput(parseInstructions, commandOutput); + public static ParseResult parseSingleOutput(ParseInstructions parseInstructions, List<String> commandOutput) { + List<ParseResult> parseResults = parseOutput(parseInstructions, commandOutput); if (parseResults.size() == 0) { return new ParseResult("invalid", "invalid"); } return parseResults.get(0); } - private static boolean matchingSearchWord(ArrayList<String> searchWords, String searchWordCandidate) { + private static boolean matchingSearchWord(List<String> searchWords, String searchWordCandidate) { return searchWords.stream().anyMatch(w -> Pattern.compile(w).matcher(searchWordCandidate).matches()); } diff --git a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/parser/ParseInstructions.java b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/parser/ParseInstructions.java index 6fb962c8232..262bfcba0b9 100644 --- a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/parser/ParseInstructions.java +++ b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/parser/ParseInstructions.java @@ -1,19 +1,22 @@ // 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.parser; -import java.util.ArrayList; +import java.util.List; /** - * Created by sgrostad on 17/07/2017. + * Contains instructions of how a command line output should be parsed + * + * @author sgrostad + * @author olaaaun */ public class ParseInstructions { private final int searchElementIndex; private final int valueElementIndex; private final String splitRegex; - private final ArrayList<String> searchWords; + private final List<String> searchWords; - public ParseInstructions(int searchElementIndex, int returnElementNum, String splitRegex, ArrayList<String> searchWords) { + public ParseInstructions(int searchElementIndex, int returnElementNum, String splitRegex, List<String> searchWords) { this.searchElementIndex = searchElementIndex; this.valueElementIndex = returnElementNum; this.splitRegex = splitRegex; @@ -32,7 +35,7 @@ public class ParseInstructions { return splitRegex; } - public ArrayList<String> getSearchWords() { + public List<String> getSearchWords() { return searchWords; } diff --git a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/parser/ParseResult.java b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/parser/ParseResult.java index df16897066b..a89cfd89f31 100644 --- a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/parser/ParseResult.java +++ b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/parser/ParseResult.java @@ -4,7 +4,10 @@ package com.yahoo.vespa.hosted.node.verification.commons.parser; import java.util.Objects; /** - * Created by sgrostad on 17/07/2017. + * Contains the results from parsing a command line output + * + * @author sgrostad + * @author olaaun */ public class ParseResult { diff --git a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/report/BenchmarkReport.java b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/report/BenchmarkReport.java index f27d132df42..ce4e3685a25 100644 --- a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/report/BenchmarkReport.java +++ b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/report/BenchmarkReport.java @@ -8,8 +8,10 @@ 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 + * + * @author sgrostad + * @author olaaun */ @JsonInclude(JsonInclude.Include.NON_NULL) public class BenchmarkReport { diff --git a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/report/HardwareDivergenceReport.java b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/report/HardwareDivergenceReport.java index 953a052ccfc..11830c24cef 100644 --- a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/report/HardwareDivergenceReport.java +++ b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/report/HardwareDivergenceReport.java @@ -5,6 +5,12 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +/** + * JSON-wrapped report for node repo + * + * @author sgrostad + * @author olaaun + */ @JsonInclude(JsonInclude.Include.NON_NULL) public class HardwareDivergenceReport { diff --git a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/report/Reporter.java b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/report/Reporter.java index 87644cb90d0..11835cab14b 100644 --- a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/report/Reporter.java +++ b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/report/Reporter.java @@ -8,9 +8,16 @@ import com.yahoo.vespa.hosted.node.verification.commons.noderepo.NodeRepoJsonMod import java.io.IOException; import java.net.URL; import java.util.ArrayList; +import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; +/** + * Responsible for printing hardware divergence report to standard out + * + * @author sgrostad + * @author olaaun + */ public class Reporter { private static final Logger logger = Logger.getLogger(Reporter.class.getName()); @@ -26,19 +33,19 @@ public class Reporter { System.out.print(report); } - public static void reportBenchmarkResults(BenchmarkReport benchmarkReport, ArrayList<URL> nodeInfoUrls) throws IOException { + public static void reportBenchmarkResults(BenchmarkReport benchmarkReport, List<URL> nodeInfoUrls) throws IOException { HardwareDivergenceReport hardwareDivergenceReport = generateHardwareDivergenceReport(nodeInfoUrls); hardwareDivergenceReport.setBenchmarkReport(benchmarkReport); printHardwareDivergenceReport(hardwareDivergenceReport); } - public static void reportSpecVerificationResults(SpecVerificationReport specVerificationReport, ArrayList<URL> nodeInfoUrls) throws IOException { + public static void reportSpecVerificationResults(SpecVerificationReport specVerificationReport, List<URL> nodeInfoUrls) throws IOException { HardwareDivergenceReport hardwareDivergenceReport = generateHardwareDivergenceReport(nodeInfoUrls); hardwareDivergenceReport.setSpecVerificationReport(specVerificationReport); printHardwareDivergenceReport(hardwareDivergenceReport); } - private static HardwareDivergenceReport generateHardwareDivergenceReport(ArrayList<URL> nodeInfoUrls) throws IOException { + private static HardwareDivergenceReport generateHardwareDivergenceReport(List<URL> nodeInfoUrls) throws IOException { NodeRepoJsonModel nodeRepoJsonModel = NodeRepoInfoRetriever.retrieve(nodeInfoUrls); ObjectMapper om = new ObjectMapper(); if (nodeRepoJsonModel.getHardwareDivergence() == null || nodeRepoJsonModel.getHardwareDivergence().equals("null")) { @@ -52,4 +59,5 @@ public class Reporter { return new HardwareDivergenceReport(); } } + } diff --git a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/report/SpecVerificationReport.java b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/report/SpecVerificationReport.java index 424b591652b..ef99208a7ce 100644 --- a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/report/SpecVerificationReport.java +++ b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/report/SpecVerificationReport.java @@ -13,6 +13,9 @@ import com.yahoo.vespa.hosted.node.verification.spec.retrievers.HardwareInfo; * Stores results of caomparing node repo spec and actual hardware info. * In case of divergent values, set the corresponding attribute to the actual hardware info value. * Attributes of equal value remain null. + * + * @author sgrostad + * @author olaaun */ @JsonInclude(JsonInclude.Include.NON_NULL) public class SpecVerificationReport { diff --git a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/hardware/BenchmarkResultInspector.java b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/hardware/BenchmarkResultInspector.java index 30592c59151..4989c574ed4 100644 --- a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/hardware/BenchmarkResultInspector.java +++ b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/hardware/BenchmarkResultInspector.java @@ -4,6 +4,12 @@ package com.yahoo.vespa.hosted.node.verification.hardware; import com.yahoo.vespa.hosted.node.verification.commons.report.BenchmarkReport; import com.yahoo.vespa.hosted.node.verification.hardware.benchmarks.BenchmarkResults; +/** + * Responsible for checking the benchmarks results, and adding unreasonable results to BenchmarkReport + * + * @author sgrostad + * @author olaaun + */ public class BenchmarkResultInspector { private static final double CPU_FREQUENCY_LOWER_LIMIT = 0.5; diff --git a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/hardware/HardwareBenchmarker.java b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/hardware/HardwareBenchmarker.java index e332804e880..7e151a6a87e 100644 --- a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/hardware/HardwareBenchmarker.java +++ b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/hardware/HardwareBenchmarker.java @@ -16,6 +16,7 @@ import java.io.IOException; import java.net.URL; import java.util.ArrayList; import java.util.Arrays; +import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; @@ -26,9 +27,9 @@ public class HardwareBenchmarker { private static final Logger logger = Logger.getLogger(HardwareBenchmarker.class.getName()); - public static boolean hardwareBenchmarks(CommandExecutor commandExecutor, ArrayList<URL> nodeInfoUrls) throws IOException { + public static boolean hardwareBenchmarks(CommandExecutor commandExecutor, List<URL> nodeInfoUrls) throws IOException { BenchmarkResults benchmarkResults = new BenchmarkResults(); - ArrayList<Benchmark> benchmarks = new ArrayList<>(Arrays.asList( + List<Benchmark> benchmarks = new ArrayList<>(Arrays.asList( new DiskBenchmark(benchmarkResults, commandExecutor), new CPUBenchmark(benchmarkResults, commandExecutor), new MemoryBenchmark(benchmarkResults, commandExecutor))); @@ -43,7 +44,7 @@ public class HardwareBenchmarker { public static void main(String[] args) throws IOException { LogSetup.initVespaLogging("hardware-benchmarker"); CommandExecutor commandExecutor = new CommandExecutor(); - ArrayList<URL> nodeInfoUrls; + List<URL> nodeInfoUrls; if (args.length == 0) { throw new IllegalStateException("Expected config server URL as parameter"); } diff --git a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/hardware/benchmarks/Benchmark.java b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/hardware/benchmarks/Benchmark.java index c1791ef45bd..1e5b512f492 100644 --- a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/hardware/benchmarks/Benchmark.java +++ b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/hardware/benchmarks/Benchmark.java @@ -2,10 +2,14 @@ package com.yahoo.vespa.hosted.node.verification.hardware.benchmarks; /** - * Created by sgrostad on 11/07/2017. + * @author sgrostad + * @author olaaun */ public interface Benchmark { + /** + * Should perform benchmark for some part of the hardware, and store the result in BenchmarkResults instance passed to class + */ void doBenchmark(); } diff --git a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/hardware/benchmarks/BenchmarkResults.java b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/hardware/benchmarks/BenchmarkResults.java index 999af15da09..dfa436460e1 100644 --- a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/hardware/benchmarks/BenchmarkResults.java +++ b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/hardware/benchmarks/BenchmarkResults.java @@ -2,9 +2,12 @@ package com.yahoo.vespa.hosted.node.verification.hardware.benchmarks; /** - * Created by sgrostad on 11/07/2017. * Stores results from benchmarks + * + * @author sgrostad + * @author olaaun */ +// TODO: This should be immutable public class BenchmarkResults { private double cpuCyclesPerSec; @@ -12,7 +15,6 @@ public class BenchmarkResults { private double memoryWriteSpeedGBs; private double memoryReadSpeedGBs; - public double getMemoryWriteSpeedGBs() { return memoryWriteSpeedGBs; } diff --git a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/hardware/benchmarks/CPUBenchmark.java b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/hardware/benchmarks/CPUBenchmark.java index e70385bb3a2..a55a92ba8a3 100644 --- a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/hardware/benchmarks/CPUBenchmark.java +++ b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/hardware/benchmarks/CPUBenchmark.java @@ -9,11 +9,15 @@ import com.yahoo.vespa.hosted.node.verification.commons.parser.ParseResult; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; +import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; /** - * Created by sgrostad on 11/07/2017. + * Responsible for benchmarking CPU clock frequency, and storing the result in a BenchmarkResults instance + * + * @author sgrostad + * @author olaaun */ public class CPUBenchmark implements Benchmark { @@ -33,31 +37,32 @@ public class CPUBenchmark implements Benchmark { this.commandExecutor = commandExecutor; } + @Override public void doBenchmark() { try { - ArrayList<String> commandOutput = commandExecutor.executeCommand(CPU_BENCHMARK_COMMAND); - ArrayList<ParseResult> parseResults = parseCpuCyclesPerSec(commandOutput); + List<String> commandOutput = commandExecutor.executeCommand(CPU_BENCHMARK_COMMAND); + List<ParseResult> parseResults = parseCpuCyclesPerSec(commandOutput); setCpuCyclesPerSec(parseResults); } catch (IOException e) { logger.log(Level.WARNING, "Failed to perform CPU benchmark", e); } } - protected ArrayList<ParseResult> parseCpuCyclesPerSec(ArrayList<String> commandOutput) { - ArrayList<String> searchWords = new ArrayList<>(Arrays.asList(CYCLES_SEARCH_WORD, SECONDS_SEARCH_WORD)); + protected List<ParseResult> parseCpuCyclesPerSec(List<String> commandOutput) { + List<String> searchWords = new ArrayList<>(Arrays.asList(CYCLES_SEARCH_WORD, SECONDS_SEARCH_WORD)); ParseInstructions parseInstructions = new ParseInstructions(SEARCH_ELEMENT_INDEX, RETURN_ELEMENT_INDEX, SPLIT_REGEX_STRING, searchWords); return OutputParser.parseOutput(parseInstructions, commandOutput); } - protected void setCpuCyclesPerSec(ArrayList<ParseResult> parseResults) { + protected void setCpuCyclesPerSec(List<ParseResult> parseResults) { double cpuCyclesPerSec = getCyclesPerSecond(parseResults); if (cpuCyclesPerSec > 0) { benchmarkResults.setCpuCyclesPerSec(cpuCyclesPerSec); } } - protected double getCyclesPerSecond(ArrayList<ParseResult> parseResults) { + protected double getCyclesPerSecond(List<ParseResult> parseResults) { double cycles = -1; double seconds = -1; for (ParseResult parseResult : parseResults) { diff --git a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/hardware/benchmarks/DiskBenchmark.java b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/hardware/benchmarks/DiskBenchmark.java index ff8e1f21612..2a4c8d9b694 100644 --- a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/hardware/benchmarks/DiskBenchmark.java +++ b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/hardware/benchmarks/DiskBenchmark.java @@ -9,12 +9,16 @@ import com.yahoo.vespa.hosted.node.verification.commons.parser.ParseResult; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; +import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; /** - * Created by olaa on 10/07/2017. + * Responsible for benchmarking disk write speed, and storing the result in a BenchmarkResults instance + * + * @author olaaun + * @author sgrostad */ public class DiskBenchmark implements Benchmark { @@ -34,9 +38,10 @@ public class DiskBenchmark implements Benchmark { this.commandExecutor = commandExecutor; } + @Override public void doBenchmark() { try { - ArrayList<String> commandOutput = commandExecutor.executeCommand(DISK_BENCHMARK_COMMAND); + List<String> commandOutput = commandExecutor.executeCommand(DISK_BENCHMARK_COMMAND); ParseResult parseResult = parseDiskSpeed(commandOutput); setDiskSpeed(parseResult); } catch (IOException e) { @@ -44,8 +49,8 @@ public class DiskBenchmark implements Benchmark { } } - protected ParseResult parseDiskSpeed(ArrayList<String> commandOutput) { - ArrayList<String> searchWords = new ArrayList<>(Arrays.asList(KILO_BYTE_SEARCH_WORD, MEGA_BYTE_SEARCH_WORD, GIGA_BYTE_SEARCH_WORD)); + protected ParseResult parseDiskSpeed(List<String> commandOutput) { + List<String> searchWords = new ArrayList<>(Arrays.asList(KILO_BYTE_SEARCH_WORD, MEGA_BYTE_SEARCH_WORD, GIGA_BYTE_SEARCH_WORD)); ParseInstructions parseInstructions = new ParseInstructions(SEARCH_ELEMENT_INDEX, RETURN_ELEMENT_INDEX, SPLIT_REGEX_STRING, searchWords); return OutputParser.parseSingleOutput(parseInstructions, commandOutput); } diff --git a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/hardware/benchmarks/MemoryBenchmark.java b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/hardware/benchmarks/MemoryBenchmark.java index 0aa4bc28eb1..b701d9a02f8 100644 --- a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/hardware/benchmarks/MemoryBenchmark.java +++ b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/hardware/benchmarks/MemoryBenchmark.java @@ -9,11 +9,15 @@ import com.yahoo.vespa.hosted.node.verification.commons.parser.ParseResult; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; +import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; /** - * Created by sgrostad on 11/07/2017. + * Responsible for benchmarking memory read/write speed, and storing the result in a BenchmarkResults instance + * + * @author sgrostad + * @author olaaun */ public class MemoryBenchmark implements Benchmark { @@ -36,10 +40,11 @@ public class MemoryBenchmark implements Benchmark { this.commandExecutor = commandExecutor; } + @Override public void doBenchmark() { try { setupMountPoint(); - ArrayList<String> commandOutput = commandExecutor.executeCommand(MEM_BENCHMARK_WRITE_SPEED); + List<String> commandOutput = commandExecutor.executeCommand(MEM_BENCHMARK_WRITE_SPEED); ParseResult parseResult = parseMemorySpeed(commandOutput); updateMemoryWriteSpeed(parseResult.getValue()); commandOutput = commandExecutor.executeCommand(MEM_BENCHMARK_READ_SPEED); @@ -70,8 +75,8 @@ public class MemoryBenchmark implements Benchmark { } } - protected ParseResult parseMemorySpeed(ArrayList<String> commandOutput) { - ArrayList<String> searchWords = new ArrayList<>(Arrays.asList(READ_AND_WRITE_SEARCH_WORD)); + protected ParseResult parseMemorySpeed(List<String> commandOutput) { + List<String> searchWords = new ArrayList<>(Arrays.asList(READ_AND_WRITE_SEARCH_WORD)); ParseInstructions parseInstructions = new ParseInstructions(SEARCH_ELEMENT_INDEX, RETURN_ELEMENT_INDEX, SPLIT_REGEX_STRING, searchWords); return OutputParser.parseSingleOutput(parseInstructions, commandOutput); } diff --git a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/HardwareNodeComparator.java b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/HardwareNodeComparator.java index 0885dbafcac..88bd0539ccd 100644 --- a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/HardwareNodeComparator.java +++ b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/HardwareNodeComparator.java @@ -6,8 +6,10 @@ import com.yahoo.vespa.hosted.node.verification.spec.retrievers.HardwareInfo; import com.yahoo.vespa.hosted.node.verification.spec.retrievers.HardwareInfo.DiskType; /** - * Created by olaa on 04/07/2017. * Compares two HardwareInfo objects and stores divergent values in a SpecVerificationReport + * + * @author olaaun + * @author sgrostad */ public class HardwareNodeComparator { diff --git a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/SpecVerifier.java b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/SpecVerifier.java index ee76cb7884e..e4cae4d7e9e 100644 --- a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/SpecVerifier.java +++ b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/SpecVerifier.java @@ -16,20 +16,22 @@ import com.yahoo.vespa.hosted.node.verification.spec.retrievers.HardwareInfoRetr import java.io.IOException; import java.net.URL; import java.util.ArrayList; +import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; /** - * Created by olaa on 14/07/2017. * Creates two HardwareInfo objects, one with spec from node repository and one from spec retrieved at the node. * Compares the objects and returns the result. + * + * @author olaaun + * @author sgrostad */ public class SpecVerifier { private static final Logger logger = Logger.getLogger(SpecVerifier.class.getName()); - private static final String VIRTUAL_ENVIRONMENT = "VIRTUAL_MACHINE"; - public static boolean verifySpec(CommandExecutor commandExecutor, ArrayList<URL> nodeInfoUrls) throws IOException { + public static boolean verifySpec(CommandExecutor commandExecutor, List<URL> nodeInfoUrls) throws IOException { NodeRepoJsonModel nodeRepoJsonModel = getNodeRepositoryJSON(nodeInfoUrls); VerifierSettings verifierSettings = new VerifierSettings(nodeRepoJsonModel); HardwareInfo actualHardware = HardwareInfoRetriever.retrieve(commandExecutor, verifierSettings); @@ -45,7 +47,7 @@ public class SpecVerifier { return specVerificationReport; } - protected static NodeRepoJsonModel getNodeRepositoryJSON(ArrayList<URL> nodeInfoUrls) throws IOException { + protected static NodeRepoJsonModel getNodeRepositoryJSON(List<URL> nodeInfoUrls) throws IOException { NodeRepoJsonModel nodeRepoJsonModel = NodeRepoInfoRetriever.retrieve(nodeInfoUrls); return nodeRepoJsonModel; } @@ -53,7 +55,7 @@ public class SpecVerifier { public static void main(String[] args) { LogSetup.initVespaLogging("spec-verifier"); CommandExecutor commandExecutor = new CommandExecutor(); - ArrayList<URL> nodeInfoUrls; + List<URL> nodeInfoUrls; if (args.length == 0) { throw new IllegalStateException("Expected config server URL as parameter"); } diff --git a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/VerifierSettings.java b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/VerifierSettings.java index 357af559014..2b5a19ce818 100644 --- a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/VerifierSettings.java +++ b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/VerifierSettings.java @@ -4,10 +4,11 @@ package com.yahoo.vespa.hosted.node.verification.spec; import com.yahoo.vespa.hosted.node.verification.commons.noderepo.NodeRepoJsonModel; /** - * Created by sgrostad on 07/08/2017. * Contains information on what spec should be verified or not. + * + * @author sgrostad + * @author olaaun */ - public class VerifierSettings { private final boolean checkIPv6; diff --git a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/retrievers/CPURetriever.java b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/retrievers/CPURetriever.java index b02f37533da..b8ae5d89b55 100644 --- a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/retrievers/CPURetriever.java +++ b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/retrievers/CPURetriever.java @@ -9,11 +9,15 @@ import com.yahoo.vespa.hosted.node.verification.commons.parser.ParseResult; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; +import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; /** - * Created by olaa on 30/06/2017. + * Retrieves number of CPU cores, and stores the result in a HardwareInfo instance + * + * @author olaaun + * @author sgrostad */ public class CPURetriever implements HardwareRetriever { @@ -31,28 +35,29 @@ public class CPURetriever implements HardwareRetriever { this.commandExecutor = commandExecutor; } + @Override public void updateInfo() { try { - ArrayList<String> commandOutput = commandExecutor.executeCommand(CPU_INFO_COMMAND); - ArrayList<ParseResult> parseResults = parseCPUInfoFile(commandOutput); + List<String> commandOutput = commandExecutor.executeCommand(CPU_INFO_COMMAND); + List<ParseResult> parseResults = parseCPUInfoFile(commandOutput); setCpuCores(parseResults); } catch (IOException e) { logger.log(Level.WARNING, "Failed to retrieve CPU info", e); } } - protected ArrayList<ParseResult> parseCPUInfoFile(ArrayList<String> commandOutput) { - ArrayList<String> searchWords = new ArrayList<>(Arrays.asList(SEARCH_WORD)); + protected List<ParseResult> parseCPUInfoFile(List<String> commandOutput) { + List<String> searchWords = new ArrayList<>(Arrays.asList(SEARCH_WORD)); ParseInstructions parseInstructions = new ParseInstructions(SEARCH_ELEMENT_INDEX, RETURN_ELEMENT_INDEX, REGEX_SPLIT, searchWords); - ArrayList<ParseResult> parseResults = OutputParser.parseOutput(parseInstructions, commandOutput); + List<ParseResult> parseResults = OutputParser.parseOutput(parseInstructions, commandOutput); return parseResults; } - protected void setCpuCores(ArrayList<ParseResult> parseResults) { + protected void setCpuCores(List<ParseResult> parseResults) { hardwareInfo.setMinCpuCores(countCpuCores(parseResults)); } - protected int countCpuCores(ArrayList<ParseResult> parseResults) { + protected int countCpuCores(List<ParseResult> parseResults) { return parseResults.size(); } diff --git a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/retrievers/DiskRetriever.java b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/retrievers/DiskRetriever.java index 2b1f7cf6a77..c86bdee18df 100644 --- a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/retrievers/DiskRetriever.java +++ b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/retrievers/DiskRetriever.java @@ -10,13 +10,18 @@ import com.yahoo.vespa.hosted.node.verification.spec.retrievers.HardwareInfo.Dis import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; +import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; /** - * Created by olaa on 30/06/2017. + * Retrieves disk space and type, and stores the result in a HardwareInfo instance + * + * @author olaaun + * @author sgrostad */ public class DiskRetriever implements HardwareRetriever { + private static final String DISK_CHECK_TYPE = "lsblk -d -o name,rota"; private static final String DISK_CHECK_SIZE = "pvdisplay --units G | grep 'PV Size'"; private static final String DISK_NAME = "sda"; @@ -37,6 +42,7 @@ public class DiskRetriever implements HardwareRetriever { this.commandExecutor = commandExecutor; } + @Override public void updateInfo() { updateDiskType(); updateDiskSize(); @@ -44,7 +50,7 @@ public class DiskRetriever implements HardwareRetriever { protected void updateDiskType() { try { - ArrayList<String> commandOutput = commandExecutor.executeCommand(DISK_CHECK_TYPE); + List<String> commandOutput = commandExecutor.executeCommand(DISK_CHECK_TYPE); ParseResult parseResult = parseDiskType(commandOutput); setDiskType(parseResult); } catch (IOException e) { @@ -54,16 +60,16 @@ public class DiskRetriever implements HardwareRetriever { protected void updateDiskSize() { try { - ArrayList<String> commandOutput = commandExecutor.executeCommand(DISK_CHECK_SIZE); - ArrayList<ParseResult> parseResult = parseDiskSize(commandOutput); + List<String> commandOutput = commandExecutor.executeCommand(DISK_CHECK_SIZE); + List<ParseResult> parseResult = parseDiskSize(commandOutput); setDiskSize(parseResult); } catch (IOException e) { logger.log(Level.WARNING, "Failed to retrieve disk size", e); } } - protected ParseResult parseDiskType(ArrayList<String> commandOutput) throws IOException { - ArrayList<String> searchWords = new ArrayList<>(Arrays.asList(DISK_NAME)); + protected ParseResult parseDiskType(List<String> commandOutput) throws IOException { + List<String> searchWords = new ArrayList<>(Arrays.asList(DISK_NAME)); ParseInstructions parseInstructions = new ParseInstructions(DISK_TYPE_SEARCH_ELEMENT_INDEX, DISK_TYPE_RETURN_ELEMENT_INDEX, DISK_TYPE_REGEX_SPLIT, searchWords); ParseResult parseResult = OutputParser.parseSingleOutput(parseInstructions, commandOutput); if (!parseResult.getSearchWord().equals(DISK_NAME)) { @@ -83,13 +89,13 @@ public class DiskRetriever implements HardwareRetriever { } } - protected ArrayList<ParseResult> parseDiskSize(ArrayList<String> commandOutput) { - ArrayList<String> searchWords = new ArrayList<>(Arrays.asList(DISK_SIZE_SEARCH_WORD)); + protected List<ParseResult> parseDiskSize(List<String> commandOutput) { + List<String> searchWords = new ArrayList<>(Arrays.asList(DISK_SIZE_SEARCH_WORD)); ParseInstructions parseInstructions = new ParseInstructions(DISK_SIZE_SEARCH_ELEMENT_INDEX, DISK_SIZE_RETURN_ELEMENT_INDEX, DISK_SIZE_REGEX_SPLIT, searchWords); return OutputParser.parseOutput(parseInstructions, commandOutput); } - protected void setDiskSize(ArrayList<ParseResult> parseResults) { + protected void setDiskSize(List<ParseResult> parseResults) { double diskSize = 0; try { for (ParseResult parseResult : parseResults) { diff --git a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/retrievers/HardwareInfo.java b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/retrievers/HardwareInfo.java index 8d726c507ba..1c17d73523b 100644 --- a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/retrievers/HardwareInfo.java +++ b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/retrievers/HardwareInfo.java @@ -2,10 +2,12 @@ package com.yahoo.vespa.hosted.node.verification.spec.retrievers; /** - * Created by olaa on 04/07/2017. * All information the different retrievers retrieve is stored as a HardwareInfo object. + * + * @author olaaun + * @author sgrostad */ - +// TODO: This should be immutable public class HardwareInfo { private double minDiskAvailableGb; @@ -17,7 +19,6 @@ public class HardwareInfo { private double interfaceSpeedMbs; private DiskType diskType; - public double getInterfaceSpeedMbs() { return interfaceSpeedMbs; } diff --git a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/retrievers/HardwareInfoRetriever.java b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/retrievers/HardwareInfoRetriever.java index e3235590169..ba29f07baeb 100644 --- a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/retrievers/HardwareInfoRetriever.java +++ b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/retrievers/HardwareInfoRetriever.java @@ -5,16 +5,19 @@ import com.yahoo.vespa.hosted.node.verification.commons.CommandExecutor; import com.yahoo.vespa.hosted.node.verification.spec.VerifierSettings; import java.util.ArrayList; +import java.util.List; /** - * Created by olaa on 30/06/2017. * Makes a HardwareInfo object and calls all the retrievers for this object. + * + * @author olaaun + * @author sgrostad */ public class HardwareInfoRetriever { public static HardwareInfo retrieve(CommandExecutor commandExecutor, VerifierSettings verifierSettings) { HardwareInfo hardwareInfo = new HardwareInfo(); - ArrayList<HardwareRetriever> infoList = new ArrayList<>(); + List<HardwareRetriever> infoList = new ArrayList<>(); infoList.add(new CPURetriever(hardwareInfo, commandExecutor)); infoList.add(new MemoryRetriever(hardwareInfo, commandExecutor)); infoList.add(new DiskRetriever(hardwareInfo, commandExecutor)); diff --git a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/retrievers/HardwareRetriever.java b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/retrievers/HardwareRetriever.java index 90e00560e59..d77342db982 100644 --- a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/retrievers/HardwareRetriever.java +++ b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/retrievers/HardwareRetriever.java @@ -2,10 +2,14 @@ package com.yahoo.vespa.hosted.node.verification.spec.retrievers; /** - * Created by olaa on 30/06/2017. + * @author olaaun + * @author sgrostad */ public interface HardwareRetriever { + /** + * Should retrieve spec from some part of the hardware, and store the result in hardwareinfo instance passed to class + */ void updateInfo(); } diff --git a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/retrievers/MemoryRetriever.java b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/retrievers/MemoryRetriever.java index 2a64e0f4b21..c6655e13797 100644 --- a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/retrievers/MemoryRetriever.java +++ b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/retrievers/MemoryRetriever.java @@ -9,11 +9,15 @@ import com.yahoo.vespa.hosted.node.verification.commons.parser.ParseResult; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; +import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; /** - * Created by olaa on 30/06/2017. + * Retrieves memory size, and stores the result in a HardwareInfo instance + * + * @author olaaun + * @author sgrostad */ public class MemoryRetriever implements HardwareRetriever { @@ -31,10 +35,10 @@ public class MemoryRetriever implements HardwareRetriever { this.commandExecutor = commandExecutor; } - + @Override public void updateInfo() { try { - ArrayList<String> commandOutput = commandExecutor.executeCommand(MEMORY_INFO_COMMAND); + List<String> commandOutput = commandExecutor.executeCommand(MEMORY_INFO_COMMAND); ParseResult parseResult = parseMemInfoFile(commandOutput); updateMemoryInfo(parseResult); } catch (IOException e) { @@ -42,8 +46,8 @@ public class MemoryRetriever implements HardwareRetriever { } } - protected ParseResult parseMemInfoFile(ArrayList<String> commandOutput) throws IOException { - ArrayList<String> searchWords = new ArrayList<>(Arrays.asList(SEARCH_WORD)); + protected ParseResult parseMemInfoFile(List<String> commandOutput) throws IOException { + List<String> searchWords = new ArrayList<>(Arrays.asList(SEARCH_WORD)); ParseInstructions parseInstructions = new ParseInstructions(SEARCH_ELEMENT_INDEX, RETURN_ELEMENT_INDEX, REGEX_SPLIT, searchWords); ParseResult parseResult = OutputParser.parseSingleOutput(parseInstructions, commandOutput); if (!parseResult.getSearchWord().matches(SEARCH_WORD)) { diff --git a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/retrievers/NetRetriever.java b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/retrievers/NetRetriever.java index 746279915bf..f30d455f339 100644 --- a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/retrievers/NetRetriever.java +++ b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/retrievers/NetRetriever.java @@ -11,11 +11,16 @@ import org.apache.commons.exec.ExecuteException; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; +import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; /** - * Created by olaa on 30/06/2017. + * Retrieves IPv4/IPv6 interface, and checks interface speed. If node should have IPv6, tries to ping6. + * The results are stored in a HardwareInfo instance + * + * @author olaaun + * @author sgrostad */ public class NetRetriever implements HardwareRetriever { @@ -48,8 +53,9 @@ public class NetRetriever implements HardwareRetriever { this.verifierSettings = verifierSettings; } + @Override public void updateInfo() { - ArrayList<ParseResult> parseResults = findInterface(); + List<ParseResult> parseResults = findInterface(); findInterfaceSpeed(parseResults); if (verifierSettings.isCheckIPv6()) { testPingResponse(parseResults); @@ -57,10 +63,10 @@ public class NetRetriever implements HardwareRetriever { updateHardwareInfoWithNet(parseResults); } - protected ArrayList<ParseResult> findInterface() { - ArrayList<ParseResult> parseResults = new ArrayList<>(); + protected List<ParseResult> findInterface() { + List<ParseResult> parseResults = new ArrayList<>(); try { - ArrayList<String> commandOutput = commandExecutor.executeCommand(NET_FIND_INTERFACE); + List<String> commandOutput = commandExecutor.executeCommand(NET_FIND_INTERFACE); parseResults = parseNetInterface(commandOutput); } catch (IOException e) { @@ -69,16 +75,16 @@ public class NetRetriever implements HardwareRetriever { return parseResults; } - protected ArrayList<ParseResult> parseNetInterface(ArrayList<String> commandOutput) { - ArrayList<String> searchWords = new ArrayList<>(Arrays.asList(SEARCH_WORD_INTERFACE_IP4, SEARCH_WORD_INTERFACE_IPV6)); + protected List<ParseResult> parseNetInterface(List<String> commandOutput) { + List<String> searchWords = new ArrayList<>(Arrays.asList(SEARCH_WORD_INTERFACE_IP4, SEARCH_WORD_INTERFACE_IPV6)); ParseInstructions parseInstructions = new ParseInstructions(INTERFACE_SEARCH_ELEMENT_INDEX, INTERFACE_RETURN_ELEMENT_INDEX, INTERFACE_NAME_REGEX_SPLIT, searchWords); - ArrayList<ParseResult> parseResults = OutputParser.parseOutput(parseInstructions, commandOutput); + List<ParseResult> parseResults = OutputParser.parseOutput(parseInstructions, commandOutput); return parseResults; } - protected void findInterfaceSpeed(ArrayList<ParseResult> parseResults) { + protected void findInterfaceSpeed(List<ParseResult> parseResults) { try { - ArrayList<String> commandOutput = commandExecutor.executeCommand(NET_CHECK_INTERFACE_SPEED); + List<String> commandOutput = commandExecutor.executeCommand(NET_CHECK_INTERFACE_SPEED); ParseResult parseResult = parseInterfaceSpeed(commandOutput); parseResults.add(parseResult); } catch (IOException e) { @@ -86,8 +92,8 @@ public class NetRetriever implements HardwareRetriever { } } - protected ParseResult parseInterfaceSpeed(ArrayList<String> commandOutput) throws IOException { - ArrayList<String> searchWords = new ArrayList<>(Arrays.asList(SEARCH_WORD_INTERFACE_SPEED)); + protected ParseResult parseInterfaceSpeed(List<String> commandOutput) throws IOException { + List<String> searchWords = new ArrayList<>(Arrays.asList(SEARCH_WORD_INTERFACE_SPEED)); ParseInstructions parseInstructions = new ParseInstructions(INTERFACE_SPEED_SEARCH_ELEMENT_INDEX, INTERFACE_SPEED_RETURN_ELEMENT_INDEX, INTERFACE_SPEED_REGEX_SPLIT, searchWords); ParseResult parseResult = OutputParser.parseSingleOutput(parseInstructions, commandOutput); if (!parseResult.getSearchWord().matches(SEARCH_WORD_INTERFACE_SPEED)) { @@ -96,9 +102,9 @@ public class NetRetriever implements HardwareRetriever { return parseResult; } - protected void testPingResponse(ArrayList<ParseResult> parseResults) { + protected void testPingResponse(List<ParseResult> parseResults) { try { - ArrayList<String> commandOutput = commandExecutor.executeCommand(PING_NET_COMMAND); + List<String> commandOutput = commandExecutor.executeCommand(PING_NET_COMMAND); parseResults.add(parsePingResponse(commandOutput)); } catch (ExecuteException e) { logger.log(Level.WARNING, "Failed to execute ping6", e); @@ -107,8 +113,8 @@ public class NetRetriever implements HardwareRetriever { } } - protected ParseResult parsePingResponse(ArrayList<String> commandOutput) throws IOException { - ArrayList<String> searchWords = new ArrayList<>(Arrays.asList(PING_SEARCH_WORD)); + protected ParseResult parsePingResponse(List<String> commandOutput) throws IOException { + List<String> searchWords = new ArrayList<>(Arrays.asList(PING_SEARCH_WORD)); ParseInstructions parseInstructions = new ParseInstructions(PING_SEARCH_ELEMENT_INDEX, PING_RETURN_ELEMENT_INDEX, PING_SPLIT_REGEX_STRING, searchWords); ParseResult parseResult = OutputParser.parseSingleOutput(parseInstructions, commandOutput); if (!parseResult.getSearchWord().matches(PING_SEARCH_WORD)) { @@ -117,7 +123,7 @@ public class NetRetriever implements HardwareRetriever { return new ParseResult(PING_SEARCH_WORD, parseResult.getValue()); } - protected void updateHardwareInfoWithNet(ArrayList<ParseResult> parseResults) { + protected void updateHardwareInfoWithNet(List<ParseResult> parseResults) { hardwareInfo.setIpv6Interface(false); hardwareInfo.setIpv4Interface(false); for (ParseResult parseResult : parseResults) { |