Bug 7805: Add make-leader-local rpc for module based shard.
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / databroker / actors / dds / FailedDataTreeModification.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, 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.controller.cluster.databroker.actors.dds;
9
10 import com.google.common.base.Optional;
11 import com.google.common.base.Preconditions;
12 import java.util.function.Supplier;
13 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
14 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
15 import org.opendaylight.yangtools.yang.data.api.schema.tree.CursorAwareDataTreeModification;
16 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModificationCursor;
17
18 /**
19  * An implementation of DataTreeModification which throws a specified {@link RuntimeException} when any of its methods
20  * are invoked.
21  *
22  * @author Robert Varga
23  */
24 final class FailedDataTreeModification implements CursorAwareDataTreeModification {
25     private final Supplier<? extends RuntimeException> supplier;
26
27     FailedDataTreeModification(final Supplier<? extends RuntimeException> supplier) {
28         this.supplier = Preconditions.checkNotNull(supplier);
29     }
30
31     @Override
32     public Optional<NormalizedNode<?, ?>> readNode(final YangInstanceIdentifier path) {
33         throw supplier.get();
34     }
35
36     @Override
37     public CursorAwareDataTreeModification newModification() {
38         throw supplier.get();
39     }
40
41     @Override
42     public void delete(final YangInstanceIdentifier path) {
43         throw supplier.get();
44     }
45
46     @Override
47     public void merge(final YangInstanceIdentifier path, final NormalizedNode<?, ?> data) {
48         throw supplier.get();
49     }
50
51     @Override
52     public void write(final YangInstanceIdentifier path, final NormalizedNode<?, ?> data) {
53         throw supplier.get();
54     }
55
56     @Override
57     public void ready() {
58         throw supplier.get();
59     }
60
61     @Override
62     public void applyToCursor(final DataTreeModificationCursor cursor) {
63         throw supplier.get();
64     }
65
66     @Override
67     public DataTreeModificationCursor createCursor(final YangInstanceIdentifier path) {
68         throw supplier.get();
69     }
70 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.