Fix javadoc failures in genius
[genius.git] / mdsalutil / mdsalutil-testutils / src / main / java / org / opendaylight / genius / datastoreutils / testutils / DataBrokerFailures.java
1 /*
2  * Copyright (c) 2017 Red Hat, Inc. and others. All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.genius.datastoreutils.testutils;
9
10 import org.opendaylight.mdsal.binding.api.ReadWriteTransaction;
11 import org.opendaylight.mdsal.binding.api.WriteTransaction;
12 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
13 import org.opendaylight.mdsal.common.api.ReadFailedException;
14 import org.opendaylight.mdsal.common.api.TransactionCommitFailedException;
15 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
16
17 /**
18  * Configures a DataBroker to simulate failures, useful for tests.
19  *
20  * @author Michael Vorburger.ch
21  */
22 public interface DataBrokerFailures {
23
24     /**
25      * Fails all future reads.
26      *
27      * @param exception a {@link ReadFailedException} to throw from a
28      * {@link ReadWriteTransaction#read(LogicalDatastoreType, InstanceIdentifier)} call.
29      */
30     void failReads(ReadFailedException exception);
31
32     /**
33      * Fails N future reads.
34      *
35      * @param howManyTimes how many times to throw the passed exception, until it resets.
36      *
37      * @param exception a {@link ReadFailedException} to throw from a
38      * {@link ReadWriteTransaction#read(LogicalDatastoreType, InstanceIdentifier)} call.
39      */
40     void failReads(int howManyTimes, ReadFailedException exception);
41
42     /**
43      * Fails all future Transaction submits.
44      *
45      * @param exception
46      *            an Exception to throw from a {@link WriteTransaction#commit()}
47      *            (also {@link ReadWriteTransaction#commit()} ) method
48      */
49     void failSubmits(TransactionCommitFailedException exception);
50
51     /**
52      * Fails N future Transaction submits.
53      *
54      * @param howManyTimes
55      *               how many times to throw the passed exception, until it resets
56      *
57      * @param exception
58      *            an Exception to throw from a {@link WriteTransaction#commit()}
59      *            (also {@link ReadWriteTransaction#commit()}  method
60      */
61     void failSubmits(int howManyTimes, TransactionCommitFailedException exception);
62
63     /**
64      * To simulate scenarios where even though the transaction throws a
65      * TransactionCommitFailedException (caused by
66      * akka.pattern.AskTimeoutException) it eventually succeeds. These timeouts
67      * are typically seen in scaled cluster environments under load. The new
68      * tell-based protocol, which will soon be enabled by default (c/61002),
69      * adds internal retries for transactions, making the application not to
70      * handle such scenarios.
71      */
72     void failButSubmitsAnyways();
73
74     /**
75      * Resets any earlier {@link #failReads(ReadFailedException)} or {@link #failReads(int, ReadFailedException)}.
76      */
77     void unfailReads();
78
79     /**
80      * Resets any earlier {@link #failSubmits(TransactionCommitFailedException)} or
81      * {@link #failSubmits(int, TransactionCommitFailedException)}.
82      */
83     void unfailSubmits();
84 }