Threshold failure detector issue
[voldemort/jeffpc.git] / test / common / voldemort / FailureDetectorTestUtils.java
blob9325cb00ec22b166c949689f03ecf133a5f6a385
1 /*
2 * Copyright 2009-2010 LinkedIn, Inc
3 *
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
6 * the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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
14 * the License.
17 package voldemort;
19 import voldemort.cluster.Node;
20 import voldemort.cluster.failuredetector.FailureDetector;
21 import voldemort.cluster.failuredetector.MutableStoreVerifier;
22 import voldemort.store.UnreachableStoreException;
24 public class FailureDetectorTestUtils {
26 public static void recordException(FailureDetector failureDetector, Node node) {
27 recordException(failureDetector, node, 0, null);
30 public static void recordException(FailureDetector failureDetector,
31 Node node,
32 long requestTime,
33 UnreachableStoreException e) {
34 ((MutableStoreVerifier) failureDetector.getConfig().getStoreVerifier()).setErrorStore(node,
35 new UnreachableStoreException("junit injected test error"));
36 failureDetector.recordException(node, requestTime, e);
39 public static void recordSuccess(FailureDetector failureDetector, Node node) throws Exception {
40 recordSuccess(failureDetector, node, 0, true);
43 public static void recordSuccess(FailureDetector failureDetector,
44 Node node,
45 long requestTime,
46 boolean shouldWait) throws Exception {
47 ((MutableStoreVerifier) failureDetector.getConfig().getStoreVerifier()).setErrorStore(node,
48 null);
49 failureDetector.recordSuccess(node, requestTime);
51 if(shouldWait)
52 failureDetector.waitForAvailability(node);