Search in sources :

Example 1 with DOMDataTreeCommitCohortRegistry

use of org.opendaylight.controller.md.sal.dom.api.DOMDataTreeCommitCohortRegistry in project controller by opendaylight.

the class LegacyDOMDataBrokerAdapterTest method testDataTreeCommitCohortRegistry.

@SuppressWarnings("unchecked")
@Test
public void testDataTreeCommitCohortRegistry() {
    DOMDataTreeCommitCohortRegistry domCohortRegistry = (DOMDataTreeCommitCohortRegistry) adapter.getSupportedExtensions().get(DOMDataTreeCommitCohortRegistry.class);
    assertNotNull("DOMDataTreeCommitCohortRegistry not found", domCohortRegistry);
    DOMDataTreeCommitCohort mockCohort = mock(DOMDataTreeCommitCohort.class);
    org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier treeId = new org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier(org.opendaylight.mdsal.common.api.LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH);
    DOMDataTreeCommitCohortRegistration<DOMDataTreeCommitCohort> mockReg = mock(DOMDataTreeCommitCohortRegistration.class);
    doReturn(mockReg).when(mockConfigStore).registerCommitCohort(treeId, mockCohort);
    DOMDataTreeCommitCohortRegistration<DOMDataTreeCommitCohort> reg = domCohortRegistry.registerCommitCohort(treeId, mockCohort);
    assertEquals("DOMDataTreeCommitCohortRegistration", mockReg, reg);
    verify(mockConfigStore).registerCommitCohort(treeId, mockCohort);
}
Also used : DOMDataTreeIdentifier(org.opendaylight.controller.md.sal.dom.api.DOMDataTreeIdentifier) DOMDataTreeCommitCohortRegistry(org.opendaylight.controller.md.sal.dom.api.DOMDataTreeCommitCohortRegistry) DOMDataTreeCommitCohort(org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohort) Test(org.junit.Test)

Example 2 with DOMDataTreeCommitCohortRegistry

use of org.opendaylight.controller.md.sal.dom.api.DOMDataTreeCommitCohortRegistry in project controller by opendaylight.

the class CarProvider method registerCommitCohort.

@Override
public synchronized Future<RpcResult<Void>> registerCommitCohort() {
    if (commitCohortReg.get() != null) {
        return RpcResultBuilder.<Void>success().buildFuture();
    }
    final DOMDataTreeCommitCohortRegistry commitCohortRegistry = (DOMDataTreeCommitCohortRegistry) domDataBroker.getSupportedExtensions().get(DOMDataTreeCommitCohortRegistry.class);
    if (commitCohortRegistry == null) {
        // Shouldn't happen
        return RpcResultBuilder.<Void>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 org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier(org.opendaylight.mdsal.common.api.LogicalDatastoreType.CONFIGURATION, carEntryPath), new CarEntryDataTreeCommitCohort()));
    LOG_CAR_PROVIDER.info("Registered commit cohort");
    return RpcResultBuilder.<Void>success().buildFuture();
}
Also used : DOMDataTreeCommitCohortRegistry(org.opendaylight.controller.md.sal.dom.api.DOMDataTreeCommitCohortRegistry) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)

Aggregations

DOMDataTreeCommitCohortRegistry (org.opendaylight.controller.md.sal.dom.api.DOMDataTreeCommitCohortRegistry)2 Test (org.junit.Test)1 DOMDataTreeIdentifier (org.opendaylight.controller.md.sal.dom.api.DOMDataTreeIdentifier)1 DOMDataTreeCommitCohort (org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohort)1 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)1