use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates in project controller by opendaylight.
the class PrefixedShardConfigWriter method doDelete.
private DOMStoreThreePhaseCommitCohort doDelete(final YangInstanceIdentifier path) {
final ClientTransaction tx = history.createTransaction();
final DOMDataTreeWriteCursor cursor = tx.openCursor();
ClusterUtils.SHARD_LIST_PATH.getPathArguments().forEach(cursor::enter);
cursor.delete(new NodeIdentifierWithPredicates(ClusterUtils.SHARD_LIST_QNAME, ClusterUtils.SHARD_PREFIX_QNAME, path));
cursor.close();
return tx.ready();
}
use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates 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.YangInstanceIdentifier.NodeIdentifierWithPredicates in project controller by opendaylight.
the class ResolveDataChangeState method getListenerChildrenWildcarded.
private static Collection<RegistrationTreeNode<DataChangeListenerRegistration<?>>> getListenerChildrenWildcarded(final Collection<RegistrationTreeNode<DataChangeListenerRegistration<?>>> parentNodes, final PathArgument child) {
if (parentNodes.isEmpty()) {
return Collections.emptyList();
}
final List<RegistrationTreeNode<DataChangeListenerRegistration<?>>> result = new ArrayList<>();
if (child instanceof NodeWithValue || child instanceof NodeIdentifierWithPredicates) {
NodeIdentifier wildcardedIdentifier = new NodeIdentifier(child.getNodeType());
addChildNodes(result, parentNodes, wildcardedIdentifier);
}
addChildNodes(result, parentNodes, child);
return result;
}
use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates in project controller by opendaylight.
the class SimpletxDomRead method executeList.
@Override
public void executeList() {
final LogicalDatastoreType dsType = getDataStoreType();
final org.opendaylight.yangtools.yang.common.QName olId = QName.create(OuterList.QNAME, "id");
final YangInstanceIdentifier pid = YangInstanceIdentifier.builder().node(TestExec.QNAME).node(OuterList.QNAME).build();
try (DOMDataReadOnlyTransaction tx = domDataBroker.newReadOnlyTransaction()) {
for (int l = 0; l < outerListElem; l++) {
YangInstanceIdentifier yid = pid.node(new NodeIdentifierWithPredicates(OuterList.QNAME, olId, l));
CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> submitFuture = tx.read(dsType, yid);
try {
Optional<NormalizedNode<?, ?>> optionalDataObject = submitFuture.checkedGet();
if (optionalDataObject != null && optionalDataObject.isPresent()) {
NormalizedNode<?, ?> ret = optionalDataObject.get();
LOG.trace("optionalDataObject is {}", ret);
txOk++;
} else {
txError++;
LOG.warn("optionalDataObject is either null or .isPresent is false");
}
} catch (final ReadFailedException e) {
LOG.warn("failed to ....", e);
txError++;
}
}
}
}
use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates in project controller by opendaylight.
the class TxchainDomRead method executeList.
@Override
public void executeList() {
final LogicalDatastoreType dsType = getDataStoreType();
final org.opendaylight.yangtools.yang.common.QName olId = QName.create(OuterList.QNAME, "id");
final YangInstanceIdentifier pid = YangInstanceIdentifier.builder().node(TestExec.QNAME).node(OuterList.QNAME).build();
try (DOMDataReadOnlyTransaction tx = domDataBroker.newReadOnlyTransaction()) {
for (int l = 0; l < outerListElem; l++) {
YangInstanceIdentifier yid = pid.node(new NodeIdentifierWithPredicates(OuterList.QNAME, olId, l));
Optional<NormalizedNode<?, ?>> optionalDataObject;
CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> submitFuture = tx.read(dsType, yid);
try {
optionalDataObject = submitFuture.checkedGet();
if (optionalDataObject != null && optionalDataObject.isPresent()) {
txOk++;
}
} catch (final ReadFailedException e) {
LOG.warn("failed to ....", e);
txError++;
}
}
}
}
Aggregations