use of org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode 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.schema.tree.DataTreeCandidateNode in project controller by opendaylight.
the class CandidateListChangeListener method onDataTreeChanged.
@Override
public void onDataTreeChanged(Collection<DataTreeCandidate> changes) {
for (DataTreeCandidate change : changes) {
DataTreeCandidateNode changeRoot = change.getRootNode();
ModificationType type = changeRoot.getModificationType();
LOG.debug("{}: Candidate node changed: {}, {}", logId, type, change.getRootPath());
NodeIdentifierWithPredicates candidateKey = (NodeIdentifierWithPredicates) change.getRootPath().getLastPathArgument();
String candidate = candidateKey.getKeyValues().get(CANDIDATE_NAME_QNAME).toString();
YangInstanceIdentifier entityId = extractEntityPath(change.getRootPath());
if (type == ModificationType.WRITE || type == ModificationType.APPEARED) {
LOG.debug("{}: Candidate {} was added for entity {}", logId, candidate, entityId);
Collection<String> newCandidates = addToCurrentCandidates(entityId, candidate);
shard.tell(new CandidateAdded(entityId, candidate, new ArrayList<>(newCandidates)), shard);
} else if (type == ModificationType.DELETE || type == ModificationType.DISAPPEARED) {
LOG.debug("{}: Candidate {} was removed for entity {}", logId, candidate, entityId);
Collection<String> newCandidates = removeFromCurrentCandidates(entityId, candidate);
shard.tell(new CandidateRemoved(entityId, candidate, new ArrayList<>(newCandidates)), shard);
}
}
}
use of org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode in project controller by opendaylight.
the class DataTreeCandidateInputOutput method writeDataTreeCandidate.
public static void writeDataTreeCandidate(final DataOutput out, DataTreeCandidate candidate) throws IOException {
try (NormalizedNodeDataOutput writer = NormalizedNodeInputOutput.newDataOutput(out)) {
writer.writeYangInstanceIdentifier(candidate.getRootPath());
final DataTreeCandidateNode node = candidate.getRootNode();
switch(node.getModificationType()) {
case APPEARED:
writer.writeByte(APPEARED);
writeChildren(writer, node.getChildNodes());
break;
case DELETE:
writer.writeByte(DELETE);
break;
case DISAPPEARED:
writer.writeByte(DISAPPEARED);
writeChildren(writer, node.getChildNodes());
break;
case SUBTREE_MODIFIED:
writer.writeByte(SUBTREE_MODIFIED);
writeChildren(writer, node.getChildNodes());
break;
case UNMODIFIED:
writer.writeByte(UNMODIFIED);
break;
case WRITE:
writer.writeByte(WRITE);
writer.writeNormalizedNode(node.getDataAfter().get());
break;
default:
throwUnhandledNodeType(node);
}
}
}
use of org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode in project controller by opendaylight.
the class AbstractShardTest method mockUnmodifiedCandidate.
static DataTreeCandidateTip mockUnmodifiedCandidate(final String name) {
final DataTreeCandidateTip mockCandidate = mock(DataTreeCandidateTip.class, name);
final DataTreeCandidateNode mockCandidateNode = mock(DataTreeCandidateNode.class, name + "-node");
doReturn(ModificationType.UNMODIFIED).when(mockCandidateNode).getModificationType();
doReturn(YangInstanceIdentifier.EMPTY).when(mockCandidate).getRootPath();
doReturn(mockCandidateNode).when(mockCandidate).getRootNode();
return mockCandidate;
}
use of org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode in project controller by opendaylight.
the class AbstractShardTest method mockCandidate.
public static DataTreeCandidateTip mockCandidate(final String name) {
final DataTreeCandidateTip mockCandidate = mock(DataTreeCandidateTip.class, name);
final DataTreeCandidateNode mockCandidateNode = mock(DataTreeCandidateNode.class, name + "-node");
doReturn(ModificationType.WRITE).when(mockCandidateNode).getModificationType();
doReturn(Optional.of(ImmutableNodes.containerNode(CarsModel.CARS_QNAME))).when(mockCandidateNode).getDataAfter();
doReturn(CarsModel.BASE_PATH).when(mockCandidate).getRootPath();
doReturn(mockCandidateNode).when(mockCandidate).getRootNode();
return mockCandidate;
}
Aggregations