本文整理汇总了Java中org.opendaylight.yangtools.concepts.ListenerRegistration.close方法的典型用法代码示例。如果您正苦于以下问题:Java ListenerRegistration.close方法的具体用法?Java ListenerRegistration.close怎么用?Java ListenerRegistration.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.opendaylight.yangtools.concepts.ListenerRegistration
的用法示例。
在下文中一共展示了ListenerRegistration.close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: registerSchemaContextListener
import org.opendaylight.yangtools.concepts.ListenerRegistration; //导入方法依赖的package包/类
@Override
public ListenerRegistration<SchemaContextListener> registerSchemaContextListener(
final SchemaContextListener listener) {
synchronized (lock) {
final ListenerRegistration<SchemaContextListener> reg = schemaService.registerSchemaContextListener(
listener);
final ListenerRegistration<SchemaContextListener> ret =
new AbstractListenerRegistration<SchemaContextListener>(listener) {
@Override
protected void removeRegistration() {
synchronized (lock) {
listeners.remove(this);
}
reg.close();
}
};
listeners.add(ret);
return ret;
}
}
示例2: 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();
}
示例3: 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();
}
示例4: testNotifSubscription3
import org.opendaylight.yangtools.concepts.ListenerRegistration; //导入方法依赖的package包/类
@Test
public void testNotifSubscription3() 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);
assertNotSame(NotificationPublishService.REJECTED,
getNotificationPublishService().offerNotification(testData, 5, TimeUnit.SECONDS));
latch.await();
assertTrue(testNotifListener.getReceivedNotifications().size() == 1);
assertEquals(testData, testNotifListener.getReceivedNotifications().get(0));
listenerRegistration.close();
}
示例5: 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());
}
示例6: getEventCountAndDestroyListeners
import org.opendaylight.yangtools.concepts.ListenerRegistration; //导入方法依赖的package包/类
public long getEventCountAndDestroyListeners() {
long totalEvents = 0;
for (ListenerRegistration<DsbenchmarkListener> listenerRegistration : listeners) {
totalEvents += listenerRegistration.getInstance().getNumEvents();
listenerRegistration.close();
}
listeners.clear();
LOG.debug("DsbenchmarkListenerProvider destroyed listeneres, total events {}", totalEvents);
return totalEvents;
}
示例7: writeContainerEmptyTreeTest
import org.opendaylight.yangtools.concepts.ListenerRegistration; //导入方法依赖的package包/类
@Test
public void writeContainerEmptyTreeTest() throws InterruptedException {
CountDownLatch latch = new CountDownLatch(1);
DOMDataTreeChangeService dataTreeChangeService = getDOMDataTreeChangeService();
assertNotNull("DOMDataTreeChangeService not found, cannot continue with test!",
dataTreeChangeService);
final TestDataTreeListener listener = new TestDataTreeListener(latch);
final ListenerRegistration<TestDataTreeListener> listenerReg =
dataTreeChangeService.registerDataTreeChangeListener(ROOT_DATA_TREE_ID, listener);
final DOMDataWriteTransaction writeTx = domBroker.newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH, TEST_CONTAINER);
writeTx.submit();
latch.await(5, TimeUnit.SECONDS);
assertEquals(1, listener.getReceivedChanges().size());
final Collection<DataTreeCandidate> changes = listener.getReceivedChanges().get(0);
assertEquals(1, changes.size());
DataTreeCandidate candidate = changes.iterator().next();
assertNotNull(candidate);
DataTreeCandidateNode candidateRoot = candidate.getRootNode();
checkChange(null, TEST_CONTAINER, ModificationType.WRITE, candidateRoot);
listenerReg.close();
}
示例8: replaceContainerContainerInTreeTest
import org.opendaylight.yangtools.concepts.ListenerRegistration; //导入方法依赖的package包/类
@Test
public void replaceContainerContainerInTreeTest() throws InterruptedException, TransactionCommitFailedException {
CountDownLatch latch = new CountDownLatch(2);
DOMDataTreeChangeService dataTreeChangeService = getDOMDataTreeChangeService();
assertNotNull("DOMDataTreeChangeService not found, cannot continue with test!",
dataTreeChangeService);
DOMDataWriteTransaction writeTx = domBroker.newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH, TEST_CONTAINER);
writeTx.submit().checkedGet();
final TestDataTreeListener listener = new TestDataTreeListener(latch);
final ListenerRegistration<TestDataTreeListener> listenerReg =
dataTreeChangeService.registerDataTreeChangeListener(ROOT_DATA_TREE_ID, listener);
writeTx = domBroker.newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH, TEST_CONTAINER_2);
writeTx.submit();
latch.await(5, TimeUnit.SECONDS);
assertEquals(2, listener.getReceivedChanges().size());
Collection<DataTreeCandidate> changes = listener.getReceivedChanges().get(0);
assertEquals(1, changes.size());
DataTreeCandidate candidate = changes.iterator().next();
assertNotNull(candidate);
DataTreeCandidateNode candidateRoot = candidate.getRootNode();
checkChange(null, TEST_CONTAINER, ModificationType.WRITE, candidateRoot);
changes = listener.getReceivedChanges().get(1);
assertEquals(1, changes.size());
candidate = changes.iterator().next();
assertNotNull(candidate);
candidateRoot = candidate.getRootNode();
checkChange(TEST_CONTAINER, TEST_CONTAINER_2, ModificationType.WRITE, candidateRoot);
listenerReg.close();
}
示例9: deleteContainerContainerInTreeTest
import org.opendaylight.yangtools.concepts.ListenerRegistration; //导入方法依赖的package包/类
@Test
public void deleteContainerContainerInTreeTest() throws InterruptedException, TransactionCommitFailedException {
CountDownLatch latch = new CountDownLatch(2);
DOMDataTreeChangeService dataTreeChangeService = getDOMDataTreeChangeService();
assertNotNull("DOMDataTreeChangeService not found, cannot continue with test!",
dataTreeChangeService);
DOMDataWriteTransaction writeTx = domBroker.newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH, TEST_CONTAINER);
writeTx.submit().checkedGet();
final TestDataTreeListener listener = new TestDataTreeListener(latch);
final ListenerRegistration<TestDataTreeListener> listenerReg =
dataTreeChangeService.registerDataTreeChangeListener(ROOT_DATA_TREE_ID, listener);
writeTx = domBroker.newWriteOnlyTransaction();
writeTx.delete(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH);
writeTx.submit();
latch.await(5, TimeUnit.SECONDS);
assertEquals(2, listener.getReceivedChanges().size());
Collection<DataTreeCandidate> changes = listener.getReceivedChanges().get(0);
assertEquals(1, changes.size());
DataTreeCandidate candidate = changes.iterator().next();
assertNotNull(candidate);
DataTreeCandidateNode candidateRoot = candidate.getRootNode();
checkChange(null, TEST_CONTAINER, ModificationType.WRITE, candidateRoot);
changes = listener.getReceivedChanges().get(1);
assertEquals(1, changes.size());
candidate = changes.iterator().next();
assertNotNull(candidate);
candidateRoot = candidate.getRootNode();
checkChange(TEST_CONTAINER, null, ModificationType.DELETE, candidateRoot);
listenerReg.close();
}
示例10: rootModificationChildListenerTest
import org.opendaylight.yangtools.concepts.ListenerRegistration; //导入方法依赖的package包/类
@Test
public void rootModificationChildListenerTest() throws InterruptedException, TransactionCommitFailedException {
CountDownLatch latch = new CountDownLatch(2);
DOMDataTreeChangeService dataTreeChangeService = getDOMDataTreeChangeService();
assertNotNull("DOMDataTreeChangeService not found, cannot continue with test!",
dataTreeChangeService);
DOMDataWriteTransaction writeTx = domBroker.newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH, TEST_CONTAINER);
writeTx.submit().checkedGet();
final TestDataTreeListener listener = new TestDataTreeListener(latch);
final ListenerRegistration<TestDataTreeListener> listenerReg =
dataTreeChangeService.registerDataTreeChangeListener(OUTER_LIST_DATA_TREE_ID, listener);
writeTx = domBroker.newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH, TEST_CONTAINER_2);
writeTx.submit().checkedGet();
latch.await(1, TimeUnit.SECONDS);
assertEquals(2, listener.getReceivedChanges().size());
Collection<DataTreeCandidate> changes = listener.getReceivedChanges().get(0);
assertEquals(1, changes.size());
DataTreeCandidate candidate = changes.iterator().next();
assertNotNull(candidate);
DataTreeCandidateNode candidateRoot = candidate.getRootNode();
checkChange(null, OUTER_LIST, ModificationType.WRITE, candidateRoot);
changes = listener.getReceivedChanges().get(1);
assertEquals(1, changes.size());
candidate = changes.iterator().next();
assertNotNull(candidate);
candidateRoot = candidate.getRootNode();
checkChange(OUTER_LIST, OUTER_LIST_2, ModificationType.WRITE, candidateRoot);
listenerReg.close();
}
示例11: close
import org.opendaylight.yangtools.concepts.ListenerRegistration; //导入方法依赖的package包/类
@Override
public void close() {
synchronized (lock) {
for (ListenerRegistration<?> l : listeners) {
l.close();
}
listeners.clear();
}
}
示例12: run
import org.opendaylight.yangtools.concepts.ListenerRegistration; //导入方法依赖的package包/类
public void run() throws InterruptedException, ExecutionException, TimeoutException {
if (setup != null) {
execute(setup);
}
ListenerRegistration<ChangeEventListener> registration = null;
if (changePath != null) {
registration = store.registerChangeListener(changePath, internalListener, changeScope);
}
Preconditions.checkState(write != null, "Write Transaction must be set.");
postSetup = true;
dclExecutorService.afterTestSetup();
execute(write);
if (registration != null) {
registration.close();
}
if (changeListener != null) {
changeListener.onDataChanged(getChangeEvent());
}
if (read != null) {
read.verify(store.newReadOnlyTransaction());
}
if (cleanup != null) {
execute(cleanup);
}
}
示例13: unregisterLoggingDtcls
import org.opendaylight.yangtools.concepts.ListenerRegistration; //导入方法依赖的package包/类
@Override
public Future<RpcResult<java.lang.Void>> unregisterLoggingDtcls() {
LOG_CAR_PROVIDER.info("Unregistering the CarDataTreeChangeListener(s)");
synchronized (carsDtclRegistrations) {
int numListeners = 0;
for (ListenerRegistration<CarDataTreeChangeListener> carsDtclRegistration : carsDtclRegistrations) {
carsDtclRegistration.close();
numListeners++;
}
carsDtclRegistrations.clear();
LOG_CAR_PROVIDER.info("Unregistered {} CaraDataTreeChangeListener(s)", numListeners);
}
return RpcResultBuilder.<Void>success().buildFuture();
}
示例14: writeNodeListenAugment
import org.opendaylight.yangtools.concepts.ListenerRegistration; //导入方法依赖的package包/类
@Test
public void writeNodeListenAugment() throws Exception {
final SettableFuture<AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject>> event = SettableFuture.create();
DataBroker dataBroker = testContext.getDataBroker();
ListenerRegistration<org.opendaylight.controller.md.sal.binding.api.DataChangeListener> dclRegistration =
dataBroker.registerDataChangeListener(LogicalDatastoreType.OPERATIONAL, AUGMENT_WILDCARDED_PATH,
change -> event.set(change), DataChangeScope.SUBTREE);
final WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
TopLevelList tll = new TopLevelListBuilder() //
.setKey(TLL_KEY) //
.addAugmentation(TreeComplexUsesAugment.class, treeComplexUsesAugment("one")).build();
transaction.put(LogicalDatastoreType.OPERATIONAL, TLL_INSTANCE_ID_BA, tll, true);
transaction.submit().get(5, TimeUnit.SECONDS);
AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> receivedEvent = event.get(1000, TimeUnit.MILLISECONDS);
assertTrue(receivedEvent.getCreatedData().containsKey(AUGMENT_TLL_PATH));
dclRegistration.close();
final WriteTransaction transaction2 = dataBroker.newWriteOnlyTransaction();
transaction2.put(LogicalDatastoreType.OPERATIONAL, AUGMENT_TLL_PATH, treeComplexUsesAugment("two"));
transaction2.submit().get(5, TimeUnit.SECONDS);
TreeComplexUsesAugment readedAug = dataBroker.newReadOnlyTransaction().read(
LogicalDatastoreType.OPERATIONAL, AUGMENT_TLL_PATH).checkedGet(5, TimeUnit.SECONDS).get();
assertEquals("two", readedAug.getContainerWithUses().getLeafFromGrouping());
}
示例15: registerNotificationListener
import org.opendaylight.yangtools.concepts.ListenerRegistration; //导入方法依赖的package包/类
@Override
public <T extends Notification> ListenerRegistration<NotificationListener<T>> registerNotificationListener(
final Class<T> type, final NotificationListener<T> listener) {
final FunctionalNotificationListenerAdapter<T> adapter = new FunctionalNotificationListenerAdapter<>(codec, type, listener);
final SchemaPath domType = SchemaPath.create(true, BindingReflections.findQName(type));
final ListenerRegistration<?> domReg = domService.registerNotificationListener(adapter, domType);
return new AbstractListenerRegistration<NotificationListener<T>>(listener) {
@Override
protected void removeRegistration() {
domReg.close();
}
};
}
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:16,代码来源:HeliumNotificationProviderServiceWithInterestListeners.java