public NeutronPortPairGroupListener(DataBroker db) { super(db,new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, portPairGroupIid)); }
private void unregisterOnTrue(boolean _true) { if (_true) { LOG.debug("Unregistering listener for path {}", iid.getRootIdentifier()); if (registeredListener != null) { registeredListener.close(); } } } }
private DOMDataTreeIdentifier toDomTreeIdentifier(final DataTreeIdentifier<?> treeId) { final YangInstanceIdentifier domPath = codec.toYangInstanceIdentifierBlocking(treeId.getRootIdentifier()); return new DOMDataTreeIdentifier(treeId.getDatastoreType(), domPath); } }
private <T extends DataObject> void formatChanges(@Nonnull final StringBuilder messageBuilder, @Nonnull final Collection<DataTreeModification<T>> changes) { for (DataTreeModification<T> modification : changes) { final DataTreeIdentifier<T> identifier = modification.getRootPath(); final LogicalDatastoreType datastoreType = identifier.getDatastoreType(); if (datastoreType == LogicalDatastoreType.OPERATIONAL) { messageBuilder.append("OPERATIONAL: "); } else { messageBuilder.append("CONFIGURATION: "); } final DataObjectModification<T> objectModification = modification.getRootNode(); formatModification(messageBuilder, objectModification); } }
@Override public <T extends DataObject, L extends DataTreeChangeListener<T>> ListenerRegistration<L> registerDataTreeChangeListener( final DataTreeIdentifier<T> treeId, final L listener) { final DOMDataTreeIdentifier domIdentifier = toDomTreeIdentifier(treeId); @SuppressWarnings({ "rawtypes", "unchecked" }) final BindingDOMDataTreeChangeListenerAdapter<T> domListener = listener instanceof ClusteredDataTreeChangeListener ? new BindingClusteredDOMDataTreeChangeListenerAdapter<T>( codec, (ClusteredDataTreeChangeListener)listener, treeId.getDatastoreType()) : new BindingDOMDataTreeChangeListenerAdapter<T>(codec, listener, treeId.getDatastoreType()); final ListenerRegistration<BindingDOMDataTreeChangeListenerAdapter<T>> domReg = dataTreeChangeService.registerDataTreeChangeListener(domIdentifier, domListener); return new BindingDataTreeChangeListenerRegistration<>(listener,domReg); }
public void registerDataChangeListener() { final DataTreeIdentifier<T> configDataTreeIdentifier = new DataTreeIdentifier<>( LogicalDatastoreType.CONFIGURATION, path); final DataTreeIdentifier<T> operDataTreeIdentifier = new DataTreeIdentifier<>( LogicalDatastoreType.OPERATIONAL, path); configRegistration = broker.registerDataTreeChangeListener(configDataTreeIdentifier, this); operRegistration = broker.registerDataTreeChangeListener(operDataTreeIdentifier, this); }
private InstanceIdentifier<ForwardingConstruct> getFcIid(DataTreeModification<ForwardingConstruct> fcModification) { return fcModification.getRootPath().getRootIdentifier(); }
public Onem2mSimpleAdapterManager(DataBroker dataBroker, Onem2mService onem2mService) { this.dataBroker = dataBroker; // listen for changes to simple adapter descriptors dcReg = dataBroker.registerDataTreeChangeListener(new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, ONEM2M_SIMPLE_ADAPTER_DESC_IID), this); // cache each of the simple adapter descriptors simpleAdapterMap = new HashMap<String,SimpleAdapterDesc>(); this.onem2mService = onem2mService; LOG.info("Created Onem2mSimpleAdapterManager"); }
private ListenableFutureSetter(DataBroker dataProvider, SettableFuture<Void> future, DataTreeIdentifier<T> iid, ModificationType modificationForFutureSet) { this.future = Preconditions.checkNotNull(future); Preconditions.checkArgument(!future.isDone()); this.modificationForFutureSet = Preconditions.checkNotNull(modificationForFutureSet); this.iid = Preconditions.checkNotNull(iid); registeredListener = dataProvider.registerDataTreeChangeListener(iid, this); LOG.debug("Registered listener for path {}", iid.getRootIdentifier()); }
public SflowClientSettingsListener(DataBroker dataprovider, ScheduledExecutorService executor, StatisticsManager statisticsManager) { super(dataprovider); this.statisticsManager = Preconditions.checkNotNull(statisticsManager); this.executor = Preconditions.checkNotNull(executor); registerDataTreeChangeListener(new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, IID)); }
@Override public void onDataTreeChanged(Collection<DataTreeModification<T>> changes) { changes.forEach(modif -> { DataObjectModification<T> rootNode = modif.getRootNode(); ModificationType modificationType = rootNode.getModificationType(); if (modificationType == modificationForFutureSet) { LOG.debug("{} in OPER DS: {}", modificationType.name(), iid.getRootIdentifier()); unregisterOnTrue(future.set(null)); } }); }
/** * Registers this instance as OPERATIONAL datastore listener via provided dataBroker * @param dataBroker data broker * @return listener registration */ ListenerRegistration<OperationalDatastoreListener<T>> registerOnChanges(DataBroker dataBroker) { DataTreeIdentifier<T> id = new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, instanceIdentifier); return dataBroker.registerDataTreeChangeListener(id, this); }
/** * Extract all the modifications affecting instances of {@code clazz} which are present in the given set of * modifications and satisfy the given filter. * * @param changes The changes to process. * @param clazz The class we're interested in. * @param filter The filter the changes must satisfy. * @param <T> The type of changes we're interested in. * @param <U> The type of changes to process. * @return The modifications, mapped by instance identifier. */ private static <T extends DataObject, U extends DataObject> Map<InstanceIdentifier<T>, DataObjectModification<T>> extractDataObjectModifications(Collection<DataTreeModification<U>> changes, Class<T> clazz, Predicate<DataObjectModification<T>> filter) { List<DataObjectModification<? extends DataObject>> dataObjectModifications = new ArrayList<>(); List<InstanceIdentifier<? extends DataObject>> paths = new ArrayList<>(); if (changes != null) { for (DataTreeModification<? extends DataObject> change : changes) { dataObjectModifications.add(change.getRootNode()); paths.add(change.getRootPath().getRootIdentifier()); } } return extractDataObjectModifications(dataObjectModifications, paths, clazz, filter); }
public TsdrTargetDescDataStoreChangeHandler(DataBroker dataBroker) { this.dataBroker = dataBroker; dcReg = dataBroker.registerDataTreeChangeListener(new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, TARGET_IID), this); }
/** * Extract all the modifications affecting instances of {@code clazz} which are present in the given set of * modifications and satisfy the given filter. * * @param changes The changes to process. * @param clazz The class we're interested in. * @param filter The filter the changes must satisfy. * @param <T> The type of changes we're interested in. * @param <U> The type of changes to process. * @return The modifications, mapped by instance identifier. */ private static <T extends DataObject, U extends DataObject> Map<InstanceIdentifier<T>, DataObjectModification<T>> extractDataObjectModifications(Collection<DataTreeModification<U>> changes, Class<T> clazz, Predicate<DataObjectModification<T>> filter) { List<DataObjectModification<? extends DataObject>> dataObjectModifications = new ArrayList<>(); List<InstanceIdentifier<? extends DataObject>> paths = new ArrayList<>(); if (changes != null) { for (DataTreeModification<? extends DataObject> change : changes) { dataObjectModifications.add(change.getRootNode()); paths.add(change.getRootPath().getRootIdentifier()); } } return extractDataObjectModifications(dataObjectModifications, paths, clazz, filter); }
public TsdrConfigDataStoreChangeHandler(DataBroker dataBroker) { this.dataBroker = dataBroker; dcReg = dataBroker.registerDataTreeChangeListener(new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, CONFIG_IID), this); }
@Override public void onDataTreeChanged(@Nonnull Collection<DataTreeModification<Node>> changes) { LOG.debug("Topology Node changed. Changes {}", changes); for (DataTreeModification<Node> modification : changes) { DataObjectModification<Node> rootNode = modification.getRootNode(); Node dataAfter = rootNode.getDataAfter(); Node dataBefore = rootNode.getDataBefore(); NodeOperEvent event = new NodeOperEvent(modification.getRootPath().getRootIdentifier(), dataBefore, dataAfter); eventBus.post(event); nodeManager.syncNodes(dataAfter, dataBefore); } }
public Onem2mDatastoreListener(DataBroker dataBroker) { this.dataBroker = dataBroker; dcReg = dataBroker.registerDataTreeChangeListener(new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, RESOURCE_IID), this); }
private void processRemovedNode(final DataTreeModification<FlowCapableNode> modification) { final InstanceIdentifier<FlowCapableNode> iiToNodeInInventory = modification.getRootPath().getRootIdentifier(); final NodeId nodeId = provideTopologyNodeId(iiToNodeInInventory); final InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node> iiToTopologyRemovedNode = provideIIToTopologyNode(nodeId); if (iiToTopologyRemovedNode != null) { operationProcessor.enqueueOperation(new TopologyOperation() { @Override public void applyOperation(final ReadWriteTransaction transaction) { transaction.delete(LogicalDatastoreType.OPERATIONAL, iiToTopologyRemovedNode); TopologyManagerUtil.removeAffectedLinks(nodeId, transaction, II_TO_TOPOLOGY); } }); } else { LOG.debug("Instance identifier to inventory wasn't translated to topology while deleting node."); } }
public NeutronFlowClassifierListener(DataBroker db) { super(db, new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION,flowClassifiersIid)); sfcMdsalHelper = new SfcMdsalHelper(db); }