2 * Copyright 2008-2009 LinkedIn, Inc
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 * use this file except in compliance with the License. You may obtain a copy of
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 * License for the specific language governing permissions and limitations under
17 package voldemort
.cluster
.failuredetector
;
19 import java
.util
.concurrent
.atomic
.AtomicInteger
;
22 * Holds the status of a node--either available or unavailable as well as the
23 * last date the status was checked.
25 * Operations on this class are not atomic, but that is okay.
31 private long lastChecked
;
33 private boolean isAvailable
;
35 private long startMillis
;
43 private final AtomicInteger numConsecutiveCatastrophicErrors
;
46 numConsecutiveCatastrophicErrors
= new AtomicInteger(0);
49 public long getLastChecked() {
53 public void setLastChecked(long lastChecked
) {
54 this.lastChecked
= lastChecked
;
57 public boolean isAvailable() {
61 public void setAvailable(boolean isAvailable
) {
62 this.isAvailable
= isAvailable
;
65 public long getStartMillis() {
69 public void setStartMillis(long startMillis
) {
70 this.startMillis
= startMillis
;
73 public long getSuccess() {
77 public long getFailure() {
81 public long getTotal() {
85 public int getNumConsecutiveCatastrophicErrors() {
86 return numConsecutiveCatastrophicErrors
.get();
89 public void resetNumConsecutiveCatastrophicErrors() {
90 this.numConsecutiveCatastrophicErrors
.set(0);
93 public int incrementConsecutiveCatastrophicErrors() {
94 return this.numConsecutiveCatastrophicErrors
.incrementAndGet();
97 public void resetCounters(long currentTime
) {
98 setStartMillis(currentTime
);
99 // Not resetting the catastrophic errors, as they will be reset
100 // whenever a success is received.
106 public void recordOperation(boolean isSuccess
) {