aboutsummaryrefslogtreecommitdiffstats
path: root/container-core/src/main/java/com/yahoo/container/protect/ProcessTerminator.java
blob: e1c1ace4c81256732877d57b4fb230b668463207 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.container.protect;

import com.yahoo.protect.Process;

/**
 * An injectable terminator of the Java vm.
 * Components that encounters conditions where the vm should be terminated should
 * request an instance of this injected. That makes termination testable
 * as tests can create subclasses of this which register the termination request
 * rather than terminating.
 *
 * @author bratseth
 */
public class ProcessTerminator {

    /** Logs and dies without taking a thread dump */
    public void logAndDie(String message) {
        logAndDie(message, false);
    }

    /**
     * Logs and dies
     *
     * @param dumpThreads if true the stack trace of all threads is dumped to the
     *                   log with level info before shutting down
     */
    public void logAndDie(String message, boolean dumpThreads) {
        Process.logAndDie(message, dumpThreads);
    }

}