diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2017-06-14 09:22:41 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-14 09:22:41 +0200 |
commit | 00d572fb45c22b0328a3141f6bed1902d3ba1b0b (patch) | |
tree | 7bf1383d680a1de7ae9514c878dd6eb2312aecfb | |
parent | 0d0e6ca025d9e0e3420fe3852406ff29f38d0a57 (diff) | |
parent | 69a8573b9255f30fd98de2b3cd941232a4bcd36c (diff) |
Merge pull request #2753 from yahoo/hmusum/handle-errors-when-reinitializing-filedistributor
Handle errors when reinitializing file distributor
-rw-r--r-- | filedistributionmanager/src/main/java/com/yahoo/vespa/filedistribution/FileDistributionManager.java | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/filedistributionmanager/src/main/java/com/yahoo/vespa/filedistribution/FileDistributionManager.java b/filedistributionmanager/src/main/java/com/yahoo/vespa/filedistribution/FileDistributionManager.java index 64cdd9da416..7965cf34ccf 100644 --- a/filedistributionmanager/src/main/java/com/yahoo/vespa/filedistribution/FileDistributionManager.java +++ b/filedistributionmanager/src/main/java/com/yahoo/vespa/filedistribution/FileDistributionManager.java @@ -1,10 +1,14 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.filedistribution; +import com.yahoo.system.execution.ProcessExecutor; +import com.yahoo.system.execution.ProcessResult; + import java.io.File; import java.io.IOException; import java.util.Collection; import java.util.List; +import java.util.Optional; import java.util.concurrent.locks.Lock; /** @@ -109,10 +113,19 @@ public class FileDistributionManager { } public void reloadDeployFileDistributor() { + String binaryName = "filedistributor"; + String command = "pkill -SIGUSR1 -x " + binaryName; + int timeoutSeconds = 10; try (LockGuard guard = new LockGuard(lock)) { - Runtime.getRuntime().exec("pkill -SIGUSR1 -x filedistributor"); + Optional<ProcessResult> result = new ProcessExecutor.Builder(timeoutSeconds).build().execute(command); + if (! result.isPresent()) { + throw new RuntimeException(String.format("Executing '%s' timed out", command)); + } else if (result.get().exitCode != 0) { + throw new RuntimeException(String.format("Error when executing '%s', exit code %d: %s\n%s", + command, result.get().exitCode, result.get().stdOut, result.get().stdErr)); + } } catch (IOException e) { - throw new RuntimeException("Failed to reinitialize the filedistributor", e); + throw new RuntimeException("Failed to reinitialize " + binaryName, e); } } |