diff options
author | Håkon Hallingstad <hakon@oath.com> | 2018-01-24 21:02:23 +0100 |
---|---|---|
committer | Håkon Hallingstad <hakon@oath.com> | 2018-01-24 21:02:23 +0100 |
commit | 8ad1b3e52610a3102c76042dd2459112a6782873 (patch) | |
tree | d7af8a30052f772d8cacc4a3ce742ab2dd840baa /node-admin/src/main/java | |
parent | 5221a44babdf7f75195ca959e9ffdde30c1734e6 (diff) |
Remove ProcessApi
Diffstat (limited to 'node-admin/src/main/java')
3 files changed, 0 insertions, 66 deletions
diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/component/TaskContext.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/component/TaskContext.java index 226d5129cf6..9def627e87f 100644 --- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/component/TaskContext.java +++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/component/TaskContext.java @@ -1,8 +1,6 @@ // Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.hosted.node.admin.component; -import com.yahoo.vespa.hosted.node.admin.task.util.process.ProcessApi; - import java.nio.file.FileSystem; import java.util.EnumSet; import java.util.logging.Logger; @@ -18,7 +16,6 @@ public interface TaskContext { } FileSystem fileSystem(); - default ProcessApi processApi() { return null; } void logSystemModification(Logger logger, String actionDescription); } diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/process/ProcessApi.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/process/ProcessApi.java deleted file mode 100644 index 10728334021..00000000000 --- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/process/ProcessApi.java +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.hosted.node.admin.task.util.process;// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -import java.nio.file.Path; -import java.util.List; - -public interface ProcessApi { - ChildProcessImpl spawn(List<String> args, Path outFile); -} diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/process/ProcessImpl.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/process/ProcessImpl.java deleted file mode 100644 index d6eb32163ba..00000000000 --- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/process/ProcessImpl.java +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.hosted.node.admin.task.util.process; - -import com.yahoo.vespa.hosted.node.admin.task.util.file.IOExceptionUtil; - -import java.nio.file.Path; -import java.util.List; -import java.util.regex.Pattern; -import java.util.stream.Collectors; - -public class ProcessImpl implements ProcessApi { - private static Pattern ARGUMENT_PATTERN = Pattern.compile("^[a-zA-Z0-9=@%/+:.,_-]+$"); - - @Override - public ChildProcessImpl spawn(List<String> arguments, Path outFile) { - ProcessBuilder builder = new ProcessBuilder(arguments) - .redirectError(ProcessBuilder.Redirect.appendTo(outFile.toFile())) - .redirectOutput(outFile.toFile()); - Process process = IOExceptionUtil.uncheck(builder::start); - return new ChildProcessImpl(process, outFile, commandLine(arguments)); - } - - String commandLine(List<String> arguments) { - return arguments.stream() - .map(ProcessImpl::maybeEscapeArgument) - .collect(Collectors.joining(" ")); - } - - private static String maybeEscapeArgument(String argument) { - if (ARGUMENT_PATTERN.matcher(argument).matches()) { - return argument; - } else { - return escapeArgument(argument); - } - } - - private static String escapeArgument(String argument) { - StringBuilder doubleQuoteEscaped = new StringBuilder(argument.length() + 10); - - for (int i = 0; i < argument.length(); ++i) { - char c = argument.charAt(i); - switch (c) { - case '"': - case '\\': - doubleQuoteEscaped.append("\\").append(c); - break; - default: - doubleQuoteEscaped.append(c); - } - } - - return "\"" + doubleQuoteEscaped + "\""; - } -} |