Write failed node data on recovery to a file
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / utils / AbstractBatchedModificationsCursor.java
1 /*
2  * Copyright (c) 2015 Brocade Communications 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.datastore.utils;
9
10 import org.opendaylight.controller.cluster.datastore.messages.BatchedModifications;
11 import org.opendaylight.controller.cluster.datastore.modification.DeleteModification;
12 import org.opendaylight.controller.cluster.datastore.modification.MergeModification;
13 import org.opendaylight.controller.cluster.datastore.modification.WriteModification;
14 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
15 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
16
17 /**
18  * Base class for a DataTreeModificationCursor that publishes to BatchedModifications instance(s).
19  *
20  * @author Thomas Pantelis
21  */
22 public abstract class AbstractBatchedModificationsCursor extends AbstractDataTreeModificationCursor {
23     protected abstract BatchedModifications getModifications();
24
25     @Override
26     public void delete(final PathArgument child) {
27         getModifications().addModification(new DeleteModification(next(child)));
28     }
29
30     @Override
31     public void merge(final PathArgument child, final NormalizedNode<?, ?> data) {
32         getModifications().addModification(new MergeModification(next(child), data));
33     }
34
35     @Override
36     public void write(final PathArgument child, final NormalizedNode<?, ?> data) {
37         getModifications().addModification(new WriteModification(next(child), data));
38     }
39 }