diff options
author | Harald Musum <musum@yahoo-inc.com> | 2017-06-14 08:31:09 +0200 |
---|---|---|
committer | Harald Musum <musum@yahoo-inc.com> | 2017-06-14 08:31:09 +0200 |
commit | 69a8573b9255f30fd98de2b3cd941232a4bcd36c (patch) | |
tree | f7b3bbb2413c4618943e68a4b7b5b16c5ffe6b02 /filedistributionmanager | |
parent | b77870459d58bff7b0d2411d09b40735643de04c (diff) |
Handle errors when reinitializing file distributor
Diffstat (limited to 'filedistributionmanager')
-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); } } |