diff options
author | Valerij Fredriksen <valerijf@yahooinc.com> | 2021-11-15 16:39:14 +0100 |
---|---|---|
committer | Valerij Fredriksen <valerijf@yahooinc.com> | 2021-11-15 16:39:14 +0100 |
commit | f322121bbe051b8c0e9b2efd6218468234e30928 (patch) | |
tree | 433a1fbe3ed6161a6c8f0f65737a9e011a69ac88 /node-admin | |
parent | 63c1f5a8008d231dd580bc76c38a4d48cd3d1970 (diff) |
Remove unused class
Diffstat (limited to 'node-admin')
-rw-r--r-- | node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/maintenance/servicedump/AbstractProducer.java | 68 |
1 files changed, 0 insertions, 68 deletions
diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/maintenance/servicedump/AbstractProducer.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/maintenance/servicedump/AbstractProducer.java deleted file mode 100644 index a1416d3274c..00000000000 --- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/maintenance/servicedump/AbstractProducer.java +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.hosted.node.admin.maintenance.servicedump; - -import com.yahoo.vespa.hosted.node.admin.container.ContainerOperations; -import com.yahoo.vespa.hosted.node.admin.nodeagent.NodeAgentContext; -import com.yahoo.vespa.hosted.node.admin.task.util.fs.ContainerPath; -import com.yahoo.vespa.hosted.node.admin.task.util.process.CommandResult; - -import java.io.IOException; -import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; -import java.util.stream.Collectors; - -/** - * @author bjorncs - */ -abstract class AbstractProducer implements ArtifactProducer { - - private final Logger log = Logger.getLogger(getClass().getName()); - - private final ContainerOperations container; - - protected AbstractProducer(ContainerOperations container) { this.container = container; } - - protected ContainerOperations container() { return container; } - - protected CommandResult executeCommand(NodeAgentContext ctx, List<String> command, boolean logOutput) throws IOException { - CommandResult result = container.executeCommandInContainerAsRoot(ctx, command.toArray(new String[0])); - String cmdString = command.stream().map(s -> "'" + s + "'").collect(Collectors.joining(" ", "\"", "\"")); - int exitCode = result.getExitCode(); - String output = result.getOutput().trim(); - String prefixedOutput = output.contains("\n") - ? "\n" + output - : (output.isEmpty() ? "<no output>" : output); - if (exitCode > 0) { - String errorMsg = logOutput - ? String.format("Failed to execute %s (exited with code %d): %s", cmdString, exitCode, prefixedOutput) - : String.format("Failed to execute %s (exited with code %d)", cmdString, exitCode); - throw new IOException(errorMsg); - } else { - String logMsg = logOutput - ? String.format("Executed command %s. Exited with code %d and output: %s", cmdString, exitCode, prefixedOutput) - : String.format("Executed command %s. Exited with code %d.", cmdString, exitCode); - ctx.log(log, logMsg); - } - return result; - } - - protected int findVespaServicePid(NodeAgentContext ctx, String configId) throws IOException { - ContainerPath findPidBinary = ctx.paths().underVespaHome("libexec/vespa/find-pid"); - CommandResult findPidResult = executeCommand(ctx, List.of(findPidBinary.pathInContainer(), configId), true); - return Integer.parseInt(findPidResult.getOutput()); - } - - protected double duration(NodeAgentContext ctx, ServiceDumpReport.DumpOptions options, double defaultValue) { - double duration = options != null && options.duration() != null && options.duration() > 0 - ? options.duration() : defaultValue; - double maxDuration = 300; - if (duration > maxDuration) { - ctx.log(log, Level.WARNING, - String.format("Specified duration %.3fs longer than max allowed (%.3fs)", duration, maxDuration)); - return maxDuration; - } - return duration; - } - -} |