2 * Copyright (c) 2017 Red Hat, Inc. and others. All rights reserved.
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
8 package org.opendaylight.mdsal.binding.testutils;
10 import org.opendaylight.mdsal.binding.api.ReadTransaction;
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;
18 * Configures a DataBroker to simulate failures, useful for tests.
20 * @author Michael Vorburger.ch
22 public interface DataBrokerFailures {
25 * Fails all future reads.
27 * @param exception a {@link ReadFailedException} to throw from a
28 * {@link ReadTransaction#read(LogicalDatastoreType, InstanceIdentifier)} call.
30 void failReads(ReadFailedException exception);
33 * Fails N future reads.
35 * @param howManyTimes how many times to throw the passed exception, until it resets.
37 * @param exception a {@link ReadFailedException} to throw from a
38 * {@link ReadTransaction#read(LogicalDatastoreType, InstanceIdentifier)} call.
40 void failReads(int howManyTimes, ReadFailedException exception);
43 * Fails all future Transaction commits.
45 * @param exception an Exception to throw from a {@link WriteTransaction#commit()} method.
47 void failCommits(TransactionCommitFailedException exception);
50 * Fails N future Transaction commits.
53 * how many times to throw the passed exception, until it resets
55 * @param exception an Exception to throw from a {@link WriteTransaction#commit()} method.
57 void failCommits(int howManyTimes, TransactionCommitFailedException exception);
60 * To simulate scenarios where even though the transaction throws a
61 * TransactionCommitFailedException (caused by
62 * akka.pattern.AskTimeoutException) it eventually succeeds. These timeouts
63 * are typically seen in scaled cluster environments under load. The new
64 * tell-based protocol, which will soon be enabled by default (c/61002),
65 * adds internal retries for transactions, making the application not to
66 * handle such scenarios.
68 void failButCommitAnyway();
71 * Resets any earlier {@link #failReads(ReadFailedException)} or {@link #failReads(int, ReadFailedException)}.
76 * Resets any earlier {@link #failCommits(TransactionCommitFailedException)} or
77 * {@link #failCommits(int, TransactionCommitFailedException)}.