import org.opendaylight.mdsal.binding.api.DataTreeCommitCohort;
import org.opendaylight.mdsal.binding.api.DataTreeCommitCohortRegistry;
import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
-import org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohortRegistry;
+import org.opendaylight.mdsal.dom.api.DOMDataBroker.CommitCohortExtension;
import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.binding.Augmentation;
import org.opendaylight.yangtools.yang.binding.DataObject;
final class BindingDOMDataTreeCommitCohortRegistryAdapter
- extends AbstractBindingAdapter<DOMDataTreeCommitCohortRegistry> implements DataTreeCommitCohortRegistry {
- BindingDOMDataTreeCommitCohortRegistryAdapter(final AdapterContext codec,
- final DOMDataTreeCommitCohortRegistry registry) {
- super(codec, registry);
+ extends AbstractBindingAdapter<CommitCohortExtension> implements DataTreeCommitCohortRegistry {
+ BindingDOMDataTreeCommitCohortRegistryAdapter(final AdapterContext codec, final CommitCohortExtension extension) {
+ super(codec, extension);
}
@Override
import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
import org.opendaylight.mdsal.binding.dom.adapter.test.util.BindingBrokerTestFactory;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-import org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohortRegistry;
+import org.opendaylight.mdsal.dom.api.DOMDataBroker.CommitCohortExtension;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.Top;
import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
@ExtendWith(MockitoExtension.class)
public class BindingDOMDataTreeCommitCohortRegistryAdapterTest {
@Mock
- private DOMDataTreeCommitCohortRegistry cohortRegistry;
+ private CommitCohortExtension cohortExtension;
@Mock
private Registration cohortRegistration;
@Mock
final var bindingTestContext = bindingBrokerTestFactory.getTestContext();
bindingTestContext.start();
- doReturn(cohortRegistration).when(cohortRegistry).registerCommitCohort(any(), any());
+ doReturn(cohortRegistration).when(cohortExtension).registerCommitCohort(any(), any());
doNothing().when(cohortRegistration).close();
final var registryAdapter = new BindingDOMDataTreeCommitCohortRegistryAdapter(bindingTestContext.getCodec(),
- cohortRegistry);
+ cohortExtension);
final var dataTreeIdentifier = DataTreeIdentifier.of(LogicalDatastoreType.CONFIGURATION,
InstanceIdentifier.create(Top.class));
*/
package org.opendaylight.mdsal.dom.api;
-import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
/**
* <b>Implementation Note:</b> This interface is not intended to be implemented by users of MD-SAL,
* but only to be consumed by them.
*/
+@NonNullByDefault
public interface DOMDataBroker extends DOMService<DOMDataBroker, DOMDataBroker.Extension>, DOMTransactionFactory {
/**
* Type capture of a {@link DOMService.Extension} applicable to {@link DOMDataBroker} implementations.
*
* @return A new transaction chain.
*/
- @NonNull DOMTransactionChain createTransactionChain();
+ DOMTransactionChain createTransactionChain();
/**
* Create a new transaction chain. The chain will be initialized to read from its backing datastore, with
*
* @return A new transaction chain.
*/
- @NonNull DOMTransactionChain createMergingTransactionChain();
+ DOMTransactionChain createMergingTransactionChain();
+
+ /**
+ * Optional support for allowing a {@link DOMDataTreeCommitCohort} to participate in the process of committing
+ * {@link DOMDataTreeWriteTransaction}s.
+ */
+ interface CommitCohortExtension extends Extension {
+ /**
+ * Register commit cohort which will participate in three-phase commit protocols of
+ * {@link DOMDataTreeWriteTransaction} in data broker associated with this instance of extension.
+ *
+ * @param path Subtree path on which commit cohort operates.
+ * @param cohort A {@link DOMDataTreeCommitCohort}
+ * @return A {@link Registration}
+ * @throws NullPointerException if any argument is {@code null}
+ */
+ Registration registerCommitCohort(DOMDataTreeIdentifier path, DOMDataTreeCommitCohort cohort);
+ }
}
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.mdsal.common.api.DataValidationFailedException;
import org.opendaylight.mdsal.common.api.PostCanCommitStep;
+import org.opendaylight.mdsal.common.api.PostPreCommitStep;
+import org.opendaylight.mdsal.dom.api.DOMDataBroker.CommitCohortExtension;
import org.opendaylight.yangtools.util.concurrent.ExceptionMapper;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
/**
- * 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.
+ * 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.
*
* <h2>Performance implications</h2>
- * {@link DOMDataTreeCommitCohort}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 committed data.
+ * {@link DOMDataTreeCommitCohort}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 committed data.
*
* <h2>Implementation requirements</h2>
- * <h3>Correctness assumptions</h3> Implementation SHOULD use only the {@link DOMDataTreeCandidate} instances and
- * provided {@link EffectiveModelContext} 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 DOMDataBroker} or DOMDataCommitCoordinator
- * Note that this may be enforced by some implementations of {@link DOMDataTreeCommitCohortRegistry}
- * and such calls may fail.
- * <h3>Correct model usage</h3> If implementation is performing YANG-model driven validation
- * implementation SHOULD use provided schema context.
- * Any other instance of {@link EffectiveModelContext} obtained by other means, may not be valid for the
- * associated DOMDataTreeCandidates and it may lead to incorrect validation or processing of provided
- * data.
- * <h3>DataTreeCandidate assumptions</h3> Implementation SHOULD NOT make any assumptions on a
- * {@link DOMDataTreeCandidate} being successfully committed until associated
- * {@link PostCanCommitStep#preCommit()} and
- * {@link org.opendaylight.mdsal.common.api.PostPreCommitStep#commit()} callback was invoked.
+ * <h3>Correctness assumptions</h3>
+ * Implementation SHOULD use only the {@link DOMDataTreeCandidate} instances and provided {@link EffectiveModelContext}
+ * for validation purposes.
+ *
+ * <p>
+ * Use of any other external mutable state is discouraged, implementation MUST NOT use any transaction related APIs on
+ * the 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 DOMDataBroker} or {@link CommitCohortExtension},
+ * potentially enforced through the extension and such calls may fail.
+ *
+ * <h3>Correct model usage</h3>
+ * If implementation is performing YANG-model driven validation implementation SHOULD use provided schema context. Any
+ * other instance of {@link EffectiveModelContext} obtained by other means, may not be valid for the associated
+ * {@link DOMDataTreeCandidate}s and it may lead to incorrect validation or processing of provided data.
+ *
+ * <h3>DataTreeCandidate assumptions</h3>
+ * Implementation SHOULD NOT make any assumptions on a {@link DOMDataTreeCandidate} being successfully committed until
+ * the associated {@link PostCanCommitStep#preCommit()} and {@link PostPreCommitStep#commit()} callback was invoked.
+ *
* <h2>Usage patterns</h2>
* <h3>Data Tree Validator</h3>
- * Validator is implementation, which only validates {@link DOMDataTreeCandidate} instances and does not
- * retain any state derived from edited data - does not care if a {@link DOMDataTreeCandidate} 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}.
- *
- * @author Tony Tkacik
+ * Validator is implementation, which only validates {@link DOMDataTreeCandidate} instances and does not retain any
+ * state derived from edited data - does not care if a {@link DOMDataTreeCandidate} was rejected afterwards or
+ * the transaction was cancelled. Implementation may opt-out from receiving {@code preCommit()}, {@code commit()},
+ * {@code abort()} callbacks by returning {@link PostCanCommitStep#NOOP}.
*/
// TODO: Provide example and describe more usage patterns
@Beta
public interface DOMDataTreeCommitCohort {
-
/**
* Validates the supplied data tree modifications and associates the cohort-specific steps with data broker
* transaction.
* Note the implementations are expected to do validation and processing asynchronous. Implementations SHOULD do
* processing fast, and are discouraged from blocking on any external resources. Implementation MUST NOT access
* any data transaction related APIs during invocation of the callback. Note that this may be enforced by some
- * implementations of {@link DOMDataTreeCommitCohortRegistry} and such calls may fail.
+ * implementations of {@link CommitCohortExtension} and such calls may fail.
*
* <p>
* Implementation MAY opt-out from implementing other steps by returning
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.dom.api;
-
-import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.opendaylight.yangtools.concepts.Registration;
-
-/**
- * Commit Cohort registry for {@link DOMDataTreeWriteTransaction}. See {@link DOMDataTreeCommitCohort} for more details.
- */
-@NonNullByDefault
-public interface DOMDataTreeCommitCohortRegistry extends DOMDataBroker.Extension {
- /**
- * Register commit cohort which will participate in three-phase commit protocols of
- * {@link DOMDataTreeWriteTransaction} in data broker associated with this instance of extension.
- *
- * @param path Subtree path on which commit cohort operates.
- * @param cohort Commit cohort
- * @return A {@link Registration}
- * @throws NullPointerException if any argument is {@code null}
- */
- Registration registerCommitCohort(DOMDataTreeIdentifier path, DOMDataTreeCommitCohort cohort);
-}
\ No newline at end of file
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeService;
-import org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohortRegistry;
import org.opendaylight.mdsal.dom.api.DOMTransactionChain;
import org.opendaylight.mdsal.dom.spi.store.DOMStore;
import org.opendaylight.mdsal.dom.spi.store.DOMStoreTransactionChain;
throw new IllegalStateException("Publisher for " + dsType + " data store is not available");
});
}
- if (isSupported(datastores, DOMDataTreeCommitCohortRegistry.class)) {
- builder.add((DOMDataTreeCommitCohortRegistry) (path, cohort) -> {
+ if (isSupported(datastores, CommitCohortExtension.class)) {
+ builder.add((CommitCohortExtension) (path, cohort) -> {
final var dsType = path.datastore();
- if (getTxFactories().get(dsType) instanceof DOMDataTreeCommitCohortRegistry registry) {
- return registry.registerCommitCohort(path, cohort);
+ if (getTxFactories().get(dsType) instanceof CommitCohortExtension extension) {
+ return extension.registerCommitCohort(path, cohort);
}
throw new IllegalStateException("Cohort registry for " + dsType + " data store is not available");
});