Exemple #1
0
  @Override
  public <L extends AsyncDataChangeListener<YangInstanceIdentifier, NormalizedNode<?, ?>>>
      ListenerRegistration<L> registerChangeListener(
          final YangInstanceIdentifier path, final L listener, final DataChangeScope scope) {

    /*
     * Make sure commit is not occurring right now. Listener has to be
     * registered and its state capture enqueued at a consistent point.
     *
     * FIXME: improve this to read-write lock, such that multiple listener
     * registrations can occur simultaneously
     */
    final DataChangeListenerRegistration<L> reg;
    synchronized (this) {
      LOG.debug("{}: Registering data change listener {} for {}", name, listener, path);

      reg = listenerTree.registerDataChangeListener(path, listener, scope);

      Optional<NormalizedNode<?, ?>> currentState = dataTree.takeSnapshot().readNode(path);
      if (currentState.isPresent()) {
        final NormalizedNode<?, ?> data = currentState.get();

        final DOMImmutableDataChangeEvent event =
            DOMImmutableDataChangeEvent.builder(DataChangeScope.BASE) //
                .setAfter(data) //
                .addCreated(path, data) //
                .build();
        executor.submit(new ChangeListenerNotifyTask(Collections.singletonList(reg), event));
      }
    }

    return new AbstractListenerRegistration<L>(listener) {
      @Override
      protected void removeRegistration() {
        synchronized (InMemoryDOMDataStore.this) {
          reg.close();
        }
      }
    };
  }
Exemple #2
0
 @Override
 public DOMStoreWriteTransaction newWriteOnlyTransaction() {
   return new SnapshotBackedWriteTransaction(nextIdentifier(), dataTree.takeSnapshot(), this);
 }
Exemple #3
0
 @Override
 public DOMStoreReadTransaction newReadOnlyTransaction() {
   return new SnapshotBackedReadTransaction(nextIdentifier(), dataTree.takeSnapshot());
 }
Exemple #4
0
 @Override
 public synchronized void onGlobalContextUpdated(final SchemaContext ctx) {
   dataTree.setSchemaContext(ctx);
 }