summaryrefslogtreecommitdiffstats
path: root/container-search/src/main/java/com/yahoo/search/cluster/MonitorConfiguration.java
blob: 226e0180d2e5a7d075f0f831150c3c3852d87a4a (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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.cluster;

/**
 * The configuration of a cluster monitor instance
 *
 * @author bratseth
 */
public class MonitorConfiguration  {

    /**
     * The interval in ms between consecutive checks of the monitored
     * nodes
     */
    private long checkInterval=1000;

    /**
     * The number of times a failed node must respond before getting
     * traffic again
     */
    private int responseAfterFailLimit=3;

    /**
     * The number of ms a node is allowed to stay idle before it is
     * pinged
     */
    private long idleLimit=3000;

    /**
     * The number of milliseconds to attempt to complete a request
     * before giving up
     */
    private long requestTimeout = 5000;

    /**
     * The number of milliseconds a node is allowed to fail before we
     * mark it as not working
     */
    private long failLimit=5000;

    /**
     * The number of times a node is allowed to fail in one hour
     * before it is quarantined for an hour
     */
    private int failQuarantineLimit=3;

    /**
     * The number of ms to quarantine an unstable node
     */
    private long quarantineTime=1000*60*60;

    /**
     * Sets the interval between each ping of idle or failing nodes
     * Default is 1000ms
     */
    public void setCheckInterval(long intervalMs) {
        this.checkInterval=intervalMs;
    }

    /**
     * Returns the interval between each ping of idle or failing nodes
     * Default is 1000ms
     */
    public long getCheckInterval() {
        return checkInterval;
    }

    /**
     * Sets the number of times a failed node must respond before it is put
     * back in service. Default is 3.
     */
    public void setResponseAfterFailLimit(int responseAfterFailLimit) {
        this.responseAfterFailLimit=responseAfterFailLimit;
    }

    /**
     * Sets the number of ms a node (failing or working) is allowed to
     * stay idle before it is pinged. Default is 3000
     */
    public void setIdleLimit(int idleLimit) {
        this.idleLimit=idleLimit;
    }

    /**
     * Gets the number of ms a node (failing or working)
     * is allowed to stay idle before it is pinged. Default is 3000
     */
    public long getIdleLimit() {
        return idleLimit;
    }

    /**
     * Returns the number of milliseconds to attempt to service a request
     * (at different nodes) before giving up. Default is 5000 ms.
     */
    public long getRequestTimeout() { return requestTimeout; }

    /**
     * Sets the number of milliseconds a node is allowed to fail before we
     * mark it as not working
     */
    public void setFailLimit(long failLimit) { this.failLimit=failLimit; }

    /**
     * Returns the number of milliseconds a node is allowed to fail before we
     * mark it as not working
     */
    public long getFailLimit() { return failLimit; }

    /**
     * The number of times a node must fail in one hour to be placed
     * in quarantine.  Once in quarantine it won't be put back in
     * productuion before quarantineTime has expired even if it is
     * working. Default is 3
     */
    public void setFailQuarantineLimit(int failQuarantineLimit) {
        this.failQuarantineLimit=failQuarantineLimit;
    }

    /**
     * The number of ms an unstable node is quarantined. Default is
     * 100*60*60
     */
    public void setQuarantineTime(long quarantineTime) {
        this.quarantineTime=quarantineTime;
    }

    public String toString() {
        return "monitor configuration [" +
            "checkInterval: " + checkInterval +
            " responseAfterFailLimit: " + responseAfterFailLimit +
            " idleLimit: " + idleLimit +
            " requestTimeout " + requestTimeout +
            " feilLimit " + failLimit +
            " failQuerantineLimit " + failQuarantineLimit +
            " quarantineTime " + quarantineTime +
            "]";
    }

}