2 * Copyright 2009-2010 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
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
,
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
,
46 boolean shouldWait
) throws Exception
{
47 ((MutableStoreVerifier
) failureDetector
.getConfig().getStoreVerifier()).setErrorStore(node
,
49 failureDetector
.recordSuccess(node
, requestTime
);
52 failureDetector
.waitForAvailability(node
);