diff options
author | gjoranv <gv@yahoo-inc.com> | 2017-05-19 00:50:00 +0200 |
---|---|---|
committer | gjoranv <gv@yahoo-inc.com> | 2017-05-19 00:50:44 +0200 |
commit | 55bb871b9bd9f5dac8c65a9c87060b746b7dde2a (patch) | |
tree | 71bba9047b4ee9b1091e842bac12f7bed6cd5f20 /container-di/src/main/scala/com/yahoo/container/di/Container.scala | |
parent | d26a8194240be170ea1b2bcea90b175436da8a66 (diff) |
Improve error message upon exit.
+ Use Duration instead of Long.
Diffstat (limited to 'container-di/src/main/scala/com/yahoo/container/di/Container.scala')
-rw-r--r-- | container-di/src/main/scala/com/yahoo/container/di/Container.scala | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/container-di/src/main/scala/com/yahoo/container/di/Container.scala b/container-di/src/main/scala/com/yahoo/container/di/Container.scala index 1dacb5529e0..0c77a723fdf 100644 --- a/container-di/src/main/scala/com/yahoo/container/di/Container.scala +++ b/container-di/src/main/scala/com/yahoo/container/di/Container.scala @@ -18,6 +18,8 @@ import com.yahoo.vespa.config.ConfigKey import scala.collection.JavaConversions._ import scala.math.max +import scala.concurrent.duration._ +import scala.language.postfixOps /** @@ -68,13 +70,13 @@ class Container( } private def invalidateGeneration(generation: Long, cause: Throwable) { - val maxWaitToExit = 180L + val maxWaitToExit = 180 seconds def newGraphErrorMessage(generation: Long, cause: Throwable): String = { val failedFirstMessage = "Failed to set up first component graph" val failedNewMessage = "Failed to set up new component graph" val constructMessage = "due to error when constructing one of the components" - val exitMessage = s"Exiting within $maxWaitToExit seconds." + val exitMessage = s"Exiting within $maxWaitToExit." val retainMessage = "Retaining previous component generation." generation match { case 0 => @@ -93,11 +95,11 @@ class Container( def logAndDie(message: String, cause: Throwable): Unit = { log.log(Level.SEVERE, message, cause) try { - Thread.sleep((new Random(System.nanoTime).nextDouble * maxWaitToExit * 1000).toLong) + Thread.sleep((new Random(System.nanoTime).nextDouble * maxWaitToExit.toMillis).toLong) } catch { case _: InterruptedException => // Do nothing } - Process.logAndDie("Exited.", cause) + Process.logAndDie("Exited for reason (repeated from above):", cause) } val message = newGraphErrorMessage(generation, cause) |