/* * Copyright (c) 2017 Pantheon Technologies s.r.o. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ package org.opendaylight.mdsal.binding.javav2.api; import com.google.common.annotations.Beta; import java.util.function.BiConsumer; import org.opendaylight.mdsal.binding.javav2.spec.base.TreeNode; import org.opendaylight.mdsal.common.api.DataValidationFailedException; import org.opendaylight.mdsal.common.api.PostCanCommitStep; /** * Commit cohort participating in commit of data modification, which can validate data tree * modifications, with option to reject supplied modification, and with callbacks describing state * of commit. * *

Performance implications

* * {@link DataTreeCommitCohort}s are hooked up into commit of data tree changes and MAY * negatively affect performance of data broker / store. * *

* Implementations of this interface are discouraged, unless you really need ability to veto data * tree changes, or to provide external state change in sync with visibility of commited data. * *

Implementation requirements

* *

Correctness assumptions

Implementation SHOULD use only provided * {@link DataTreeModification} for validation purposes. * *

* Use of any other external mutable state is discouraged, implementation MUST NOT use any * transaction related APIs on same data broker / data store instance during invocation of * callbacks, except ones provided as argument. Note that this MAY BE enforced by some * implementations of {@link DataBroker} or Commit coordinator * *

* Note that this may be enforced by some implementations of {@link DataTreeCommitCohortRegistry} * and such calls may fail. * *

DataTreeCandidate assumptions

Implementation SHOULD NOT make any assumptions on * {@link DataTreeModification} being successfully committed until associated * {@link PostCanCommitStep#preCommit()} and * {@link org.opendaylight.mdsal.common.api.PostPreCommitStep#commit()} callback was invoked. * *

Usage patterns

* *

Data Tree Validator

* *

* Validator is implementation, which only validates {@link DataTreeModification} and does not * retain any state derived from edited data - does not care if {@link DataTreeModification} was * rejected afterwards or transaction was cancelled. * *

* Implementation may opt-out from receiving {@code preCommit()}, {@code commit()}, {@code abort()} * callbacks by returning {@link PostCanCommitStep#NOOP}. */ @Beta public interface DataTreeCommitCohort { /** * Performs canCommit? message in three-phase commit algorithm. * * @param txId Transaction identifier * @param modification modification of data tree * @param callback result callback */ void canCommit(Object txId, DataTreeModification modification, BiConsumer callback); }