aboutsummaryrefslogtreecommitdiffstats
path: root/container-core/src/main/java/com/yahoo/container/protect/FreezeDetector.java
blob: 6a8a3239c17c87d04355215130f911c9d2f9fa3b (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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.container.protect;

import java.util.Timer;

import com.yahoo.component.AbstractComponent;
import com.yahoo.concurrent.ThreadLocalDirectory;
import com.yahoo.container.core.DiagnosticsConfig;

/**
 * Runs and initializes a {@link Watchdog} instance.
 *
 * @author Steinar Knutsen
 * @deprecated this is not in use and will be removed in the next major release
 */
@Deprecated
// TODO: Remove on Vespa 7
public class FreezeDetector extends AbstractComponent {

    private final Timer timeoutWatchdog;
    private final Watchdog watchdog;

    public FreezeDetector(DiagnosticsConfig diagnosticsConfig) {
        timeoutWatchdog = null;
        watchdog = null;
    }

    public void register(ThreadLocalDirectory<TimeoutRate, Boolean> timeouts) {
        if (watchdog == null) {
            return;
        }
        watchdog.addTimeouts(timeouts);
    }

    public boolean isBreakdown() {
        if (watchdog == null) {
            return false;
        }
        return watchdog.isBreakdown();
    }

    public void unRegister(ThreadLocalDirectory<TimeoutRate, Boolean> timeouts) {
        if (watchdog == null) {
            return;
        }
        watchdog.removeTimeouts(timeouts);
    }

    @Override
    public void deconstruct() {
        super.deconstruct();
        if (timeoutWatchdog != null) {
            timeoutWatchdog.cancel();
        }
    }

}