@Test public void testOnSubtreeModified() { when(rootNode.getModificationType()).thenReturn(DataObjectModification.ModificationType.SUBTREE_MODIFIED); classifierListener.onDataTreeChanged(changes); verify(classifierListener).onSubtreeModified(rootNode, rootIdentifier); }
@Override protected void onSubtreeModified(DataObjectModification<ResolvedPolicy> rootNode, InstanceIdentifier<ResolvedPolicy> rootIdentifier) { ResolvedPolicy resolvedPolicyAfter = rootNode.getDataAfter(); ResolvedPolicy resolvedPolicyBefore = rootNode.getDataBefore(); Map<InstanceIdentifier<Classifier>, Classifier> classifierByIidAfter = resolveClassifiers(resolvedPolicyAfter, rootIdentifier); Map<InstanceIdentifier<Classifier>, Classifier> classifierByIidBefore = resolveClassifiers(resolvedPolicyBefore, rootIdentifier); MapDifference<InstanceIdentifier<Classifier>, Classifier> difference = Maps.difference(classifierByIidBefore, classifierByIidAfter); Map<InstanceIdentifier<Classifier>, Classifier> createdClassifierByIid = difference.entriesOnlyOnRight(); for (Entry<InstanceIdentifier<Classifier>, Classifier> createdClassfierEntry : createdClassifierByIid .entrySet()) { LOG.trace("New classifier created: {}\n{}", createdClassfierEntry.getKey(), createdClassfierEntry.getValue()); ofStatsManager.pullStatsForClassifier(createdClassfierEntry.getKey(), createdClassfierEntry.getValue()); } }
ResolvedPolicyClassifierListener extends DataTreeChangeHandler<ResolvedPolicy> { @Override protected void onSubtreeModified(DataObjectModification<ResolvedPolicy> rootNode, InstanceIdentifier<ResolvedPolicy> rootIdentifier) { ResolvedPolicy resolvedPolicyAfter = rootNode.getDataAfter(); ResolvedPolicy resolvedPolicyBefore = rootNode.getDataBefore(); Map<InstanceIdentifier<Classifier>, Classifier> classifierByIidAfter = resolveClassifiers(resolvedPolicyAfter, rootIdentifier); Map<InstanceIdentifier<Classifier>, Classifier> classifierByIidBefore = resolveClassifiers(resolvedPolicyBefore, rootIdentifier); MapDifference<InstanceIdentifier<Classifier>, Classifier> difference = Maps.difference(classifierByIidBefore, classifierByIidAfter); Map<InstanceIdentifier<Classifier>, Classifier> createdClassifierByIid = difference.entriesOnlyOnRight(); for (Entry<InstanceIdentifier<Classifier>, Classifier> createdClassfierEntry : createdClassifierByIid .entrySet()) { LOG.trace("New classifier created: {}\n{}", createdClassfierEntry.getKey(), createdClassfierEntry.getValue()); ofStatsManager.pullStatsForClassifier(createdClassfierEntry.getKey(), createdClassfierEntry.getValue()); } } }
ResolvedPolicyClassifierListener extends DataTreeChangeHandler<ResolvedPolicy> { @Override protected void onSubtreeModified(DataObjectModification<ResolvedPolicy> rootNode, InstanceIdentifier<ResolvedPolicy> rootIdentifier) { ResolvedPolicy resolvedPolicyAfter = rootNode.getDataAfter(); ResolvedPolicy resolvedPolicyBefore = rootNode.getDataBefore(); Map<InstanceIdentifier<Classifier>, Classifier> classifierByIidAfter = resolveClassifiers(resolvedPolicyAfter, rootIdentifier); Map<InstanceIdentifier<Classifier>, Classifier> classifierByIidBefore = resolveClassifiers(resolvedPolicyBefore, rootIdentifier); MapDifference<InstanceIdentifier<Classifier>, Classifier> difference = Maps.difference(classifierByIidBefore, classifierByIidAfter); Map<InstanceIdentifier<Classifier>, Classifier> createdClassifierByIid = difference.entriesOnlyOnRight(); for (Entry<InstanceIdentifier<Classifier>, Classifier> createdClassfierEntry : createdClassifierByIid .entrySet()) { LOG.trace("New classifier created: {}\n{}", createdClassfierEntry.getKey(), createdClassfierEntry.getValue()); ofStatsManager.pullStatsForClassifier(createdClassfierEntry.getKey(), createdClassfierEntry.getValue()); } } ResolvedPolicyClassifierListener(DataBroker dataProvider, OFStatisticsManager ofStatsManager); }
ResolvedPolicyClassifierListener extends DataTreeChangeHandler<ResolvedPolicy> { @Override protected void onSubtreeModified(DataObjectModification<ResolvedPolicy> rootNode, InstanceIdentifier<ResolvedPolicy> rootIdentifier) { ResolvedPolicy resolvedPolicyAfter = rootNode.getDataAfter(); ResolvedPolicy resolvedPolicyBefore = rootNode.getDataBefore(); Map<InstanceIdentifier<Classifier>, Classifier> classifierByIidAfter = resolveClassifiers(resolvedPolicyAfter, rootIdentifier); Map<InstanceIdentifier<Classifier>, Classifier> classifierByIidBefore = resolveClassifiers(resolvedPolicyBefore, rootIdentifier); MapDifference<InstanceIdentifier<Classifier>, Classifier> difference = Maps.difference(classifierByIidBefore, classifierByIidAfter); Map<InstanceIdentifier<Classifier>, Classifier> createdClassifierByIid = difference.entriesOnlyOnRight(); for (Entry<InstanceIdentifier<Classifier>, Classifier> createdClassfierEntry : createdClassifierByIid .entrySet()) { LOG.trace("New classifier created: {}\n{}", createdClassfierEntry.getKey(), createdClassfierEntry.getValue()); ofStatsManager.pullStatsForClassifier(createdClassfierEntry.getKey(), createdClassfierEntry.getValue()); } } ResolvedPolicyClassifierListener(DataBroker dataProvider, OFStatisticsManager ofStatsManager); static Map<InstanceIdentifier<Classifier>, Classifier> resolveClassifiers(ResolvedPolicy resolvedPolicy,
            InstanceIdentifier<ResolvedPolicy> resolvedPolicyIid); }
ResolvedPolicyClassifierListener extends DataTreeChangeHandler<ResolvedPolicy> { @Override protected void onSubtreeModified(DataObjectModification<ResolvedPolicy> rootNode, InstanceIdentifier<ResolvedPolicy> rootIdentifier) { ResolvedPolicy resolvedPolicyAfter = rootNode.getDataAfter(); ResolvedPolicy resolvedPolicyBefore = rootNode.getDataBefore(); Map<InstanceIdentifier<Classifier>, Classifier> classifierByIidAfter = resolveClassifiers(resolvedPolicyAfter, rootIdentifier); Map<InstanceIdentifier<Classifier>, Classifier> classifierByIidBefore = resolveClassifiers(resolvedPolicyBefore, rootIdentifier); MapDifference<InstanceIdentifier<Classifier>, Classifier> difference = Maps.difference(classifierByIidBefore, classifierByIidAfter); Map<InstanceIdentifier<Classifier>, Classifier> createdClassifierByIid = difference.entriesOnlyOnRight(); for (Entry<InstanceIdentifier<Classifier>, Classifier> createdClassfierEntry : createdClassifierByIid .entrySet()) { LOG.trace("New classifier created: {}\n{}", createdClassfierEntry.getKey(), createdClassfierEntry.getValue()); ofStatsManager.pullStatsForClassifier(createdClassfierEntry.getKey(), createdClassfierEntry.getValue()); } } ResolvedPolicyClassifierListener(DataBroker dataProvider, OFStatisticsManager ofStatsManager); static Map<InstanceIdentifier<Classifier>, Classifier> resolveClassifiers(ResolvedPolicy resolvedPolicy,
            InstanceIdentifier<ResolvedPolicy> resolvedPolicyIid);  }