use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier in project bgpcep by opendaylight.
the class AdjRibInWriter method transform.
AdjRibInWriter transform(final PeerId newPeerId, final RIBSupportContextRegistry registry, final Set<TablesKey> tableTypes, final Map<TablesKey, SendReceive> addPathTablesType, @Nullable final RegisterAppPeerListener registerAppPeerListener) {
final DOMDataWriteTransaction tx = this.chain.newWriteOnlyTransaction();
final YangInstanceIdentifier newPeerPath;
newPeerPath = createEmptyPeerStructure(newPeerId, tx);
final ImmutableMap<TablesKey, TableContext> tb = createNewTableInstances(newPeerPath, registry, tableTypes, addPathTablesType, tx);
Futures.addCallback(tx.submit(), new FutureCallback<Void>() {
@Override
public void onSuccess(final Void result) {
if (registerAppPeerListener != null) {
LOG.trace("Application Peer Listener registered");
registerAppPeerListener.register();
}
}
@Override
public void onFailure(final Throwable throwable) {
if (registerAppPeerListener != null) {
LOG.error("Failed to create Empty Structure, Application Peer Listener won't be registered", throwable);
} else {
LOG.error("Failed to create Empty Structure", throwable);
}
}
}, MoreExecutors.directExecutor());
return new AdjRibInWriter(this.ribPath, this.chain, this.role, newPeerPath, tb);
}
use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier in project bgpcep by opendaylight.
the class AdjRibInWriter method createEmptyPeerStructure.
private YangInstanceIdentifier createEmptyPeerStructure(final PeerId newPeerId, final DOMDataWriteTransaction tx) {
final NodeIdentifierWithPredicates peerKey = IdentifierUtils.domPeerId(newPeerId);
final YangInstanceIdentifier newPeerPath = this.ribPath.node(Peer.QNAME).node(peerKey);
tx.put(LogicalDatastoreType.OPERATIONAL, newPeerPath, peerSkeleton(peerKey, newPeerId.getValue()));
LOG.debug("New peer {} structure installed.", newPeerPath);
return newPeerPath;
}
use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier in project bgpcep by opendaylight.
the class ApplicationPeer method processRoutesTable.
private synchronized void processRoutesTable(final DataTreeCandidateNode node, final YangInstanceIdentifier identifier, final DOMDataWriteTransaction tx, final YangInstanceIdentifier routeTableIdentifier) {
for (final DataTreeCandidateNode child : node.getChildNodes()) {
final YangInstanceIdentifier childIdentifier = identifier.node(child.getIdentifier());
switch(child.getModificationType()) {
case DELETE:
LOG.trace("App peer -> AdjRibsIn path delete: {}", childIdentifier);
tx.delete(LogicalDatastoreType.OPERATIONAL, childIdentifier);
break;
case UNMODIFIED:
// No-op
break;
case SUBTREE_MODIFIED:
// we need to go deeper three levels
if (!routeTableIdentifier.equals(childIdentifier.getParent().getParent().getParent())) {
processRoutesTable(child, childIdentifier, tx, routeTableIdentifier);
break;
}
case WRITE:
if (child.getDataAfter().isPresent()) {
final NormalizedNode<?, ?> dataAfter = child.getDataAfter().get();
LOG.trace("App peer -> AdjRibsIn path : {}", childIdentifier);
LOG.trace("App peer -> AdjRibsIn data : {}", dataAfter);
tx.put(LogicalDatastoreType.OPERATIONAL, childIdentifier, dataAfter);
}
break;
default:
break;
}
}
}
use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier in project controller by opendaylight.
the class ClientTransactionCursorTest method testWrite.
@Test
public void testWrite() throws Exception {
final YangInstanceIdentifier.NodeIdentifier path = YangInstanceIdentifier.NodeIdentifier.create(NODE_1);
final ContainerNode data = createData(path.getNodeType());
cursor.write(path, data);
final YangInstanceIdentifier expected = createId(NODE_1);
verify(transaction).write(expected, data);
}
use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier in project controller by opendaylight.
the class ClientTransactionCursorTest method testEnterNodeIterables.
@Test
public void testEnterNodeIterables() throws Exception {
final Iterable<YangInstanceIdentifier.PathArgument> collect = toPathArg(NODE_1, NODE_2);
cursor.enter(collect);
cursor.delete(YangInstanceIdentifier.NodeIdentifier.create(NODE_3));
final YangInstanceIdentifier expected = createId(NODE_1, NODE_2, NODE_3);
verify(transaction).delete(expected);
}
Aggregations