当前位置: 首页>>代码示例>>Java>>正文


Java ListenerRegistration类代码示例

本文整理汇总了Java中org.opendaylight.yangtools.concepts.ListenerRegistration的典型用法代码示例。如果您正苦于以下问题:Java ListenerRegistration类的具体用法?Java ListenerRegistration怎么用?Java ListenerRegistration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ListenerRegistration类属于org.opendaylight.yangtools.concepts包,在下文中一共展示了ListenerRegistration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: AbstractDOMDataBroker

import org.opendaylight.yangtools.concepts.ListenerRegistration; //导入依赖的package包/类
protected AbstractDOMDataBroker(final Map<LogicalDatastoreType, DOMStore> datastores) {
    super(datastores);

    boolean treeChange = true;
    for (DOMStore ds : datastores.values()) {
        if (!(ds instanceof DOMStoreTreeChangePublisher)) {
            treeChange = false;
            break;
        }
    }

    if (treeChange) {
        extensions = ImmutableMap.<Class<? extends DOMDataBrokerExtension>, DOMDataBrokerExtension>of(DOMDataTreeChangeService.class, new DOMDataTreeChangeService() {
            @Nonnull
            @Override
            public <L extends DOMDataTreeChangeListener> ListenerRegistration<L> registerDataTreeChangeListener(@Nonnull final DOMDataTreeIdentifier treeId, @Nonnull final L listener) {
                DOMStore publisher = getTxFactories().get(treeId.getDatastoreType());
                checkState(publisher != null, "Requested logical data store is not available.");

                return ((DOMStoreTreeChangePublisher)publisher).registerTreeChangeListener(treeId.getRootIdentifier(), listener);
            }
        });
    } else {
        extensions = Collections.emptyMap();
    }
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:27,代码来源:AbstractDOMDataBroker.java

示例2: deliverNotification

import org.opendaylight.yangtools.concepts.ListenerRegistration; //导入依赖的package包/类
void deliverNotification() {
    LOG.trace("Start delivery of notification {}", notification);
    for (ListenerRegistration<? extends DOMNotificationListener> r : subscribers) {
        final DOMNotificationListener listener = r.getInstance();
        if (listener != null) {
            try {
                LOG.trace("Notifying listener {}", listener);
                listener.onNotification(notification);
                LOG.trace("Listener notification completed");
            } catch (Exception e) {
                LOG.error("Delivery of notification {} caused an error in listener {}", notification, listener, e);
            }
        }
    }
    LOG.trace("Delivery completed");
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:17,代码来源:DOMNotificationRouterEvent.java

示例3: testNotifSubscription

import org.opendaylight.yangtools.concepts.ListenerRegistration; //导入依赖的package包/类
@Test
public void testNotifSubscription() throws InterruptedException {
    final CountDownLatch latch = new CountDownLatch(1);
    final TwoLevelListChanged testData = createTestData();

    final TestNotifListener testNotifListener = new TestNotifListener(latch);
    final ListenerRegistration<TestNotifListener> listenerRegistration = getNotificationService()
            .registerNotificationListener(testNotifListener);
    getNotificationPublishService().putNotification(testData);

    latch.await();
    assertTrue(testNotifListener.getReceivedNotifications().size() == 1);
    assertEquals(testData, testNotifListener.getReceivedNotifications().get(0));

    listenerRegistration.close();
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:17,代码来源:ForwardedNotificationAdapterTest.java

示例4: registerTreeChangeListener

import org.opendaylight.yangtools.concepts.ListenerRegistration; //导入依赖的package包/类
<L extends DOMDataTreeChangeListener> ListenerRegistration<L> registerTreeChangeListener(final YangInstanceIdentifier treeId, final L listener, final DataTreeSnapshot snapshot) {
    final AbstractDOMDataTreeChangeListenerRegistration<L> reg = registerTreeChangeListener(treeId, listener);

    final Optional<NormalizedNode<?, ?>> node = snapshot.readNode(YangInstanceIdentifier.EMPTY);
    if (node.isPresent()) {
        final DataTreeCandidate candidate = DataTreeCandidates.fromNormalizedNode(
                YangInstanceIdentifier.EMPTY, node.get());

        InMemoryDOMStoreTreeChangePublisher publisher =
                new InMemoryDOMStoreTreeChangePublisher(notificationManager);
        publisher.registerTreeChangeListener(treeId, listener);
        publisher.publishChange(candidate);
    }

    return reg;
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:17,代码来源:InMemoryDOMStoreTreeChangePublisher.java

示例5: registerChangeListener

import org.opendaylight.yangtools.concepts.ListenerRegistration; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public <L extends AsyncDataChangeListener<YangInstanceIdentifier, NormalizedNode<?, ?>>>
                                          ListenerRegistration<L> registerChangeListener(
    final YangInstanceIdentifier path, final L listener,
    final AsyncDataBroker.DataChangeScope scope) {

    Preconditions.checkNotNull(path, "path should not be null");
    Preconditions.checkNotNull(listener, "listener should not be null");

    LOG.debug("Registering listener: {} for path: {} scope: {}", listener, path, scope);

    String shardName = actorContext.getShardStrategyFactory().getStrategy(path).findShard(path);

    final DataChangeListenerRegistrationProxy listenerRegistrationProxy =
            new DataChangeListenerRegistrationProxy(shardName, actorContext, listener);
    listenerRegistrationProxy.init(path, scope);

    return listenerRegistrationProxy;
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:21,代码来源:AbstractDataStore.java

示例6: testNotifSubscription2

import org.opendaylight.yangtools.concepts.ListenerRegistration; //导入依赖的package包/类
@Test
public void testNotifSubscription2() throws InterruptedException {
    final CountDownLatch latch = new CountDownLatch(1);
    final TwoLevelListChanged testData = createTestData();

    final TestNotifListener testNotifListener = new TestNotifListener(latch);
    final ListenerRegistration<TestNotifListener> listenerRegistration = getNotificationService()
            .registerNotificationListener(testNotifListener);
    try {
        getNotificationPublishService().offerNotification(testData).get(1, TimeUnit.SECONDS);
    } catch (ExecutionException | TimeoutException e) {
        LOG.error("Notification delivery failed", e);
        Assert.fail("notification should be delivered");
    }

    latch.await();
    assertTrue(testNotifListener.getReceivedNotifications().size() == 1);
    assertEquals(testData, testNotifListener.getReceivedNotifications().get(0));

    listenerRegistration.close();
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:22,代码来源:ForwardedNotificationAdapterTest.java

示例7: registerTreeChangeListener

import org.opendaylight.yangtools.concepts.ListenerRegistration; //导入依赖的package包/类
@Override
public void registerTreeChangeListener(YangInstanceIdentifier treeId, DOMDataTreeChangeListener listener,
        Optional<DataTreeCandidate> initialState,
        Consumer<ListenerRegistration<DOMDataTreeChangeListener>> onRegistration) {
    LOG.debug("{}: registerTreeChangeListener: path: {}, listener: {}", logContext, treeId, listener);

    AbstractDOMDataTreeChangeListenerRegistration<org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener>
        registration = super.registerTreeChangeListener(treeId, new ForwardingDOMDataTreeChangeListener(listener));

    onRegistration.accept(
        new org.opendaylight.controller.md.sal.dom.spi.AbstractDOMDataTreeChangeListenerRegistration<
                DOMDataTreeChangeListener>(listener) {
            @Override
            protected void removeRegistration() {
                registration.close();
            }
        });

    if (initialState.isPresent()) {
        notifySingleListener(treeId, listener, initialState.get(), logContext);
    }
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:23,代码来源:DefaultShardDataTreeChangeListenerPublisher.java

示例8: registerDataTreeShard

import org.opendaylight.yangtools.concepts.ListenerRegistration; //导入依赖的package包/类
@Nonnull
@Override
public <T extends DOMDataTreeShard> ListenerRegistration<T> registerDataTreeShard(
        @Nonnull final DOMDataTreeIdentifier prefix,
        @Nonnull final T shard,
        @Nonnull final DOMDataTreeProducer producer)
        throws DOMDataTreeShardingConflictException {

    LOG.debug("Registering shard[{}] at prefix: {}", shard, prefix);

    if (producer instanceof ProxyProducer) {
        return shardedDOMDataTree.registerDataTreeShard(prefix, shard, ((ProxyProducer) producer).delegate());
    }

    return shardedDOMDataTree.registerDataTreeShard(prefix, shard, producer);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:17,代码来源:DistributedShardedDOMDataTree.java

示例9: unsubscribeYnl

import org.opendaylight.yangtools.concepts.ListenerRegistration; //导入依赖的package包/类
@Override
public Future<RpcResult<UnsubscribeYnlOutput>> unsubscribeYnl(final UnsubscribeYnlInput input) {
    LOG.debug("Received unsubscribe-ynl, input: {}", input);

    if (!ynlRegistrations.containsKey(input.getId())) {
        final RpcError rpcError = RpcResultBuilder
                .newError(ErrorType.APPLICATION, "missing-registration", "No ynl listener with this id registered.");
        final RpcResult<UnsubscribeYnlOutput> result =
                RpcResultBuilder.<UnsubscribeYnlOutput>failed().withRpcError(rpcError).build();
        return Futures.immediateFuture(result);
    }

    final ListenerRegistration<YnlListener> registration = ynlRegistrations.remove(input.getId());
    final UnsubscribeYnlOutput output = registration.getInstance().getOutput();

    registration.close();

    return Futures.immediateFuture(RpcResultBuilder.<UnsubscribeYnlOutput>success().withResult(output).build());
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:20,代码来源:MdsalLowLevelTestProvider.java

示例10: registerDataTreeChangeListener

import org.opendaylight.yangtools.concepts.ListenerRegistration; //导入依赖的package包/类
@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<>(
                            codec, (ClusteredDataTreeChangeListener) listener, treeId.getDatastoreType()) :
                    new BindingDOMDataTreeChangeListenerAdapter<>(codec, listener, treeId.getDatastoreType());

    final ListenerRegistration<BindingDOMDataTreeChangeListenerAdapter<T>> domReg =
            dataTreeChangeService.registerDataTreeChangeListener(domIdentifier, domListener);
    return new BindingDataTreeChangeListenerRegistration<>(listener,domReg);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:17,代码来源:BindingDOMDataTreeChangeServiceAdapter.java

示例11: getDataChangeCount

import org.opendaylight.yangtools.concepts.ListenerRegistration; //导入依赖的package包/类
public long getDataChangeCount() {
    long dataChanges = 0;

    for (ListenerRegistration<DsbenchmarkListener> listenerRegistration : listeners) {
        dataChanges += listenerRegistration.getInstance().getNumDataChanges();
    }
    LOG.debug("DsbenchmarkListenerProvider , total data changes {}", dataChanges);
    return dataChanges;
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:10,代码来源:DsbenchmarkListenerProvider.java

示例12: registerDataChangeListener

import org.opendaylight.yangtools.concepts.ListenerRegistration; //导入依赖的package包/类
@Override
public ListenerRegistration<DOMDataChangeListener> registerDataChangeListener(final LogicalDatastoreType store,
        final YangInstanceIdentifier path, final DOMDataChangeListener listener, final DataChangeScope triggeringScope) {

    DOMStore potentialStore = getTxFactories().get(store);
    checkState(potentialStore != null, "Requested logical data store is not available.");
    return potentialStore.registerChangeListener(path, listener, triggeringScope);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:9,代码来源:AbstractDOMDataBroker.java

示例13: registerDataChangeListener

import org.opendaylight.yangtools.concepts.ListenerRegistration; //导入依赖的package包/类
@Override
public ListenerRegistration<DOMDataChangeListener> registerDataChangeListener(final LogicalDatastoreType store,
                                                                              final YangInstanceIdentifier path,
                                                                              final DOMDataChangeListener listener,
                                                                              final DataChangeScope triggeringScope) {
    throw new UnsupportedOperationException("Registering data change listeners is not supported in " +
            "md-sal forwarding data broker");

}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:10,代码来源:LegacyShardedDOMDataBrokerAdapter.java

示例14: registerDataTreeShard

import org.opendaylight.yangtools.concepts.ListenerRegistration; //导入依赖的package包/类
@Override
public <T extends DOMDataTreeShard> ListenerRegistration<T> registerDataTreeShard(final DOMDataTreeIdentifier prefix, final T shard) throws DOMDataTreeShardingConflictException {
    final ShardRegistration<T> reg;
    final ShardRegistration<?> parentReg;

    synchronized (this) {
        /*
         * Lookup the parent shard (e.g. the one which currently matches the prefix),
         * and if it exists, check if its registration prefix does not collide with
         * this registration.
         */
        final ShardingTableEntry parent = lookupShard(prefix);
        parentReg = parent.getRegistration();
        if (parentReg != null && prefix.equals(parentReg.getPrefix())) {
            throw new DOMDataTreeShardingConflictException(String.format("Prefix %s is already occupied by shard %s", prefix, parentReg.getInstance()));
        }

        // FIXME: wrap the shard in a proper adaptor based on implemented interface

        reg = new ShardRegistration<>(this, prefix, shard);

        storeShard(prefix, reg);

        // FIXME: update any producers/registrations
    }

    // Notify the parent shard
    if (parentReg != null) {
        parentReg.getInstance().onChildAttached(prefix, shard);
    }

    return reg;
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:34,代码来源:ShardedDOMDataTree.java

示例15: registerRpcListener

import org.opendaylight.yangtools.concepts.ListenerRegistration; //导入依赖的package包/类
@Override
public synchronized <T extends DOMRpcAvailabilityListener> ListenerRegistration<T> registerRpcListener(
        final T listener) {
    final Registration<T> ret = new Registration<>(this, listener, routingTable.getRpcs(listener));
    final Builder<Registration<?>> b = ImmutableList.builder();
    b.addAll(listeners);
    b.add(ret);
    listeners = b.build();

    listenerNotifier.execute(ret::initialTable);
    return ret;
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:13,代码来源:DOMRpcRouter.java


注:本文中的org.opendaylight.yangtools.concepts.ListenerRegistration类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。