+
+ private synchronized ListenableFuture<RpcResult<RegisterCommitCohortOutput>> registerCommitCohort(
+ final RegisterCommitCohortInput input) {
+ if (commitCohortReg.get() != null) {
+ return RpcResultBuilder.success(new RegisterCommitCohortOutputBuilder().build()).buildFuture();
+ }
+
+ final DOMDataTreeCommitCohortRegistry commitCohortRegistry = domDataBroker.getExtensions().getInstance(
+ DOMDataTreeCommitCohortRegistry.class);
+
+ if (commitCohortRegistry == null) {
+ // Shouldn't happen
+ return RpcResultBuilder.<RegisterCommitCohortOutput>failed().withError(ErrorType.APPLICATION,
+ "DOMDataTreeCommitCohortRegistry not found").buildFuture();
+ }
+
+ // Note: it may look strange that we specify the CarEntry.QNAME twice in the path below. This must be done in
+ // order to register the commit cohort for CarEntry instances. In the underlying data tree, a yang list is
+ // represented as a MapNode with MapEntryNodes representing the child list entries. Therefore, in order to
+ // address a list entry, you must specify the path argument for the MapNode and the path argument for the
+ // MapEntryNode. In the path below, the first CarEntry.QNAME argument addresses the MapNode and, since we want
+ // to address all list entries, the second path argument is wild-carded by specifying just the CarEntry.QNAME.
+ final YangInstanceIdentifier carEntryPath = YangInstanceIdentifier.builder(
+ YangInstanceIdentifier.of(Cars.QNAME)).node(CarEntry.QNAME).node(CarEntry.QNAME).build();
+ commitCohortReg.set(commitCohortRegistry.registerCommitCohort(new DOMDataTreeIdentifier(
+ LogicalDatastoreType.CONFIGURATION, carEntryPath), new CarEntryDataTreeCommitCohort()));
+
+ LOG.info("Registered commit cohort");
+
+ return RpcResultBuilder.success(new RegisterCommitCohortOutputBuilder().build()).buildFuture();
+ }