From 2611e6a728e586ea34dd891f30a473bf54d6cbd8 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Fri, 21 Feb 2020 06:41:50 +0100 Subject: [PATCH] Remove deprecated MD-SAL APIs The APIs in controller have been deprecated for removal and cannot sustain an upgrade to Guava-28+. Remove them along with all supporting implementations. JIRA: CONTROLLER-1903 Change-Id: I213797b7045cfd7bef744e249614e2b1f6169c1c Signed-off-by: Robert Varga --- benchmark/rpcbenchmark/pom.xml | 12 +- .../impl/GlobalBindingRTCClient.java | 2 +- .../impl/RoutedBindingRTClient.java | 23 +- .../impl/RpcbenchmarkProvider.java | 37 +- .../OSGI-INF/blueprint/rpcbenchmark.xml | 6 +- docs/pom.xml | 70 -- .../config-netty/odl-config-netty/pom.xml | 6 - features/mdsal/features-mdsal/pom.xml | 21 - .../mdsal/odl-controller-binding-api/pom.xml | 68 -- .../src/main/feature/feature.xml | 13 - .../mdsal/odl-controller-blueprint/pom.xml | 18 +- .../src/main/feature/feature.xml | 3 + features/mdsal/odl-controller-dom-api/pom.xml | 72 --- .../src/main/feature/feature.xml | 13 - .../mdsal/odl-controller-mdsal-common/pom.xml | 10 - features/mdsal/odl-mdsal-broker-local/pom.xml | 12 +- features/mdsal/odl-mdsal-broker/pom.xml | 9 - features/mdsal/odl-mdsal-clustering/pom.xml | 34 - features/mdsal/pom.xml | 3 - opendaylight/blueprint/pom.xml | 12 - .../ext/OpendaylightNamespaceHandler.java | 25 - .../blueprint/ext/RoutedRpcMetadata.java | 115 ---- .../ext/RoutedRpcRegistrationConverter.java | 34 - .../opendaylight-blueprint-ext-1.0.0.xsd | 11 - opendaylight/md-sal/mdsal-artifacts/pom.xml | 101 --- opendaylight/md-sal/mdsal-it-base/pom.xml | 11 +- opendaylight/md-sal/mdsal-trace/api/pom.xml | 56 -- .../sal/trace/api/TracingDOMDataBroker.java | 26 - .../resources/initial/mdsaltrace_config.xml | 21 - .../api/src/main/yang/mdsaltrace.yang | 38 -- .../md-sal/mdsal-trace/binding-impl/pom.xml | 67 -- .../impl/TracingBindingBrokerWiring.java | 41 -- .../OSGI-INF/blueprint/impl-blueprint.xml | 40 -- opendaylight/md-sal/mdsal-trace/cli/pom.xml | 56 -- .../cli/PrintOpenTransactionsCommand.java | 56 -- .../md-sal/mdsal-trace/deploy-site.xml | 50 -- .../md-sal/mdsal-trace/dom-impl/pom.xml | 89 --- .../impl/AbstractCloseTracked.java | 39 -- .../trace/closetracker/impl/CloseTracked.java | 32 - .../impl/CloseTrackedRegistry.java | 114 ---- .../impl/CloseTrackedRegistryReportEntry.java | 52 -- .../closetracker/impl/CloseTrackedTrait.java | 65 -- .../trace/closetracker/impl/package-info.java | 15 - .../impl/AbstractTracingWriteTransaction.java | 138 ---- .../md/sal/trace/dom/impl/TracingBroker.java | 444 ------------- .../dom/impl/TracingReadOnlyTransaction.java | 73 --- .../dom/impl/TracingReadWriteTransaction.java | 71 -- .../dom/impl/TracingTransactionChain.java | 95 --- .../dom/impl/TracingWriteTransaction.java | 51 -- .../OSGI-INF/blueprint/impl-blueprint.xml | 61 -- .../trace/tests/CloseTrackedRegistryTest.java | 96 --- .../md/sal/trace/tests/TracingBrokerTest.java | 94 --- .../features/features-mdsal-trace/pom.xml | 26 - .../features/odl-mdsal-trace/pom.xml | 60 -- .../src/main/feature/feature.xml | 6 - .../md-sal/mdsal-trace/features/pom.xml | 28 - opendaylight/md-sal/mdsal-trace/pom.xml | 86 --- .../app/impl/EventSourceTopologyTest.java | 4 +- opendaylight/md-sal/messagebus-util/pom.xml | 8 +- .../app/util/TopicDOMNotification.java | 3 +- opendaylight/md-sal/pom.xml | 22 - .../md-sal/sal-binding-api/.gitignore | 1 - opendaylight/md-sal/sal-binding-api/pom.xml | 51 -- .../binding/api/ActionProviderService.java | 22 - .../md/sal/binding/api/ActionService.java | 21 - .../md/sal/binding/api/BindingService.java | 33 - .../binding/api/BindingTransactionChain.java | 36 -- .../api/ClusteredDataTreeChangeListener.java | 30 - .../md/sal/binding/api/DataBroker.java | 43 -- .../binding/api/DataObjectModification.java | 198 ------ .../binding/api/DataTreeChangeListener.java | 51 -- .../binding/api/DataTreeChangeService.java | 61 -- .../sal/binding/api/DataTreeIdentifier.java | 91 --- .../sal/binding/api/DataTreeModification.java | 37 -- .../sal/binding/api/ForwardingDataBroker.java | 54 -- .../api/ForwardingReadOnlyTransaction.java | 59 -- .../api/ForwardingReadWriteTransaction.java | 95 --- .../api/ForwardingWriteTransaction.java | 78 --- .../md/sal/binding/api/MountPoint.java | 17 - .../md/sal/binding/api/MountPointService.java | 36 -- .../api/NotificationPublishService.java | 98 --- .../api/NotificationRejectedException.java | 32 - .../sal/binding/api/NotificationService.java | 86 --- .../sal/binding/api/ReadOnlyTransaction.java | 26 - .../md/sal/binding/api/ReadTransaction.java | 82 --- .../sal/binding/api/ReadWriteTransaction.java | 25 - .../sal/binding/api/TransactionFactory.java | 24 - .../md/sal/binding/api/WriteTransaction.java | 127 ---- .../api/AbstractBindingAwareConsumer.java | 19 - .../api/AbstractBindingAwareProvider.java | 19 - .../api/AbstractBrokerAwareActivator.java | 119 ---- .../sal/binding/api/BindingAwareBroker.java | 209 ------ .../sal/binding/api/BindingAwareConsumer.java | 93 --- .../sal/binding/api/BindingAwareProvider.java | 123 ---- .../sal/binding/api/BindingAwareService.java | 38 -- .../sal/binding/api/NotificationListener.java | 33 - .../api/NotificationProviderService.java | 73 --- .../sal/binding/api/NotificationService.java | 128 ---- .../binding/api/RpcAvailabilityListener.java | 13 - .../sal/binding/api/RpcConsumerRegistry.java | 63 -- .../sal/binding/api/RpcProviderRegistry.java | 293 --------- .../sal/binding/api/package-info.java | 9 - .../binding/api/rpc/RpcContextIdentifier.java | 79 --- .../binding/api/rpc/RpcRoutingContext.java | 19 - .../md-sal/sal-binding-broker/pom.xml | 165 ----- .../sal-binding-broker/src/main/.gitignore | 1 - ...tractNotificationListenerRegistration.java | 44 -- ...gatedNotificationListenerRegistration.java | 61 -- .../CompositeRoutedRpcRegistration.java | 82 --- .../compat/DelegatedRootRpcRegistration.java | 40 -- ...FunctionalNotificationListenerAdapter.java | 42 -- ...iumNotificationProviderServiceAdapter.java | 60 -- ...nProviderServiceWithInterestListeners.java | 126 ---- .../HeliumNotificationServiceAdapter.java | 42 -- .../compat/HeliumRpcProviderRegistry.java | 58 -- .../binding/compat/ListenerMapGeneration.java | 102 --- .../binding/compat/NotificationInvoker.java | 96 --- .../NotificationListenerRegistration.java | 37 -- .../impl/AbstractForwardedDataBroker.java | 107 --- .../impl/AbstractForwardedTransaction.java | 82 --- .../impl/AbstractReadWriteTransaction.java | 64 -- .../impl/AbstractWriteTransaction.java | 139 ---- .../sal/binding/impl/BindingBrokerWiring.java | 147 ----- ...teredDOMDataTreeChangeListenerAdapter.java | 29 - .../impl/BindingDOMAdapterBuilder.java | 39 -- .../binding/impl/BindingDOMAdapterLoader.java | 52 -- .../impl/BindingDOMDataBrokerAdapter.java | 105 --- ...ndingDOMDataTreeChangeListenerAdapter.java | 50 -- ...indingDOMDataTreeChangeServiceAdapter.java | 70 -- .../BindingDOMMountPointListenerAdapter.java | 78 --- .../BindingDOMMountPointServiceAdapter.java | 64 -- ...BindingDOMNotificationListenerAdapter.java | 94 --- ...gDOMNotificationPublishServiceAdapter.java | 90 --- .../BindingDOMNotificationServiceAdapter.java | 82 --- .../BindingDOMReadTransactionAdapter.java | 44 -- ...BindingDOMReadWriteTransactionAdapter.java | 39 -- .../BindingDOMRpcAdapterRegistration.java | 28 - .../BindingDOMRpcImplementationAdapter.java | 94 --- .../BindingDOMRpcProviderServiceAdapter.java | 78 --- .../impl/BindingDOMRpcServiceAdapter.java | 72 --- .../BindingDOMTransactionChainAdapter.java | 154 ----- .../BindingDOMWriteTransactionAdapter.java | 79 --- ...ingDataTreeChangeListenerRegistration.java | 31 - .../impl/BindingMountPointAdapter.java | 52 -- .../impl/BindingRpcAdapterRegistration.java | 28 - .../impl/BindingToDOMAdapterFactory.java | 32 - .../impl/BindingToNormalizedNodeCodec.java | 99 --- .../impl/ContextReferenceExtractor.java | 106 --- ...ontrollerActionProviderServiceAdapter.java | 58 -- .../impl/ControllerActionServiceAdapter.java | 53 -- .../DirectGetterRouteContextExtractor.java | 44 -- .../impl/GetValueRouteContextExtractor.java | 52 -- .../binding/impl/LazyDOMRpcResultFuture.java | 127 ---- .../impl/LazyDataObjectModification.java | 297 --------- .../impl/LazyDataTreeModification.java | 74 --- .../impl/LazySerializedContainerNode.java | 112 ---- .../impl/LazySerializedDOMNotification.java | 62 -- .../sal/binding/impl/RpcServiceAdapter.java | 225 ------- .../md/sal/binding/spi/AdapterBuilder.java | 41 -- .../md/sal/binding/spi/AdapterFactory.java | 27 - .../md/sal/binding/spi/AdapterLoader.java | 38 -- .../binding/impl/RootBindingAwareBroker.java | 200 ------ .../OSGI-INF/blueprint/binding-broker.xml | 114 ---- ...ngDOMDataTreeChangeServiceAdapterTest.java | 116 ---- ...indingDOMMountPointServiceAdapterTest.java | 73 --- .../impl/BindingNormalizedCodecTest.java | 190 ------ .../binding/impl/ContextExtractorTest.java | 74 --- ...wardsCompatibleNotificationBrokerTest.java | 93 --- .../test/BindingDOMDataBrokerAdapterTest.java | 96 --- .../impl/test/Bug1125RegressionTest.java | 91 --- .../test/Bug1333DataChangeListenerTest.java | 118 ---- .../impl/test/Bug1418AugmentationTest.java | 148 ----- .../Bug2562DeserializedUnkeyedListTest.java | 52 -- .../impl/test/Bug3090MultiKeyList.java | 75 --- .../md/sal/binding/impl/test/Bug4494Test.java | 48 -- .../md/sal/binding/impl/test/Bug4513Test.java | 71 -- .../impl/test/DataTreeChangeListenerTest.java | 205 ------ .../ForwardedNotificationAdapterTest.java | 130 ---- .../ListInsertionDataChangeListenerTest.java | 175 ----- .../impl/test/WriteTransactionTest.java | 89 --- .../test/AbstractBaseDataBrokerTest.java | 63 -- .../AbstractConcurrentDataBrokerTest.java | 38 -- .../binding/test/AbstractDataBrokerTest.java | 47 -- .../AbstractDataBrokerTestCustomizer.java | 121 ---- .../AbstractDataTreeChangeListenerTest.java | 146 ----- .../test/AbstractNotificationBrokerTest.java | 53 -- .../binding/test/AbstractSchemaAwareTest.java | 60 -- .../sal/binding/test/AssertCollections.java | 52 -- .../ConcurrentDataBrokerTestCustomizer.java | 45 -- .../ConstantSchemaAbstractDataBrokerTest.java | 36 -- .../test/DataBrokerTestCustomizer.java | 26 - .../binding/test/DataBrokerTestModule.java | 67 -- .../binding/test/SchemaContextSingleton.java | 42 -- .../tests/AbstractDataBrokerTestTest.java | 80 --- .../test/tests/DataBrokerTestModuleTest.java | 42 -- .../binding/test/AbstractDataServiceTest.java | 34 - .../binding/test/AugmentationVerifier.java | 39 -- .../binding/test/BindingTestUtilities.java | 13 - .../sal/binding/test/mock/BarListener.java | 19 - .../sal/binding/test/mock/BarUpdate.java | 17 - .../binding/test/mock/CompositeListener.java | 13 - .../sal/binding/test/mock/FlowDelete.java | 15 - .../sal/binding/test/mock/FooListener.java | 17 - .../sal/binding/test/mock/FooService.java | 23 - .../sal/binding/test/mock/FooUpdate.java | 15 - .../sal/binding/test/mock/Grouping.java | 19 - .../test/mock/InheritedContextInput.java | 13 - .../binding/test/mock/ReferencableObject.java | 18 - .../test/mock/ReferencableObjectKey.java | 57 -- .../sal/binding/test/mock/SimpleInput.java | 21 - .../test/util/BindingBrokerTestFactory.java | 44 -- .../binding/test/util/BindingTestContext.java | 255 -------- .../binding/test/util/MockSchemaService.java | 59 -- .../md-sal/sal-binding-dom-it/pom.xml | 122 ---- .../data/ConcurrentImplicitCreateTest.java | 46 -- .../WildcardedDataChangeListenerTest.java | 155 ----- ...eteNestedAugmentationListenParentTest.java | 89 --- .../bugfix/WriteParentListenAugmentTest.java | 84 --- .../test/bugfix/WriteParentReadChildTest.java | 83 --- .../sal/binding/test/bugfix/package-info.java | 13 - .../connect/dom/BrokerIntegrationTest.java | 86 --- .../dom/CrossBrokerMountPointTest.java | 227 ------- .../test/connect/dom/CrossBrokerRpcTest.java | 223 ------- .../dom/DOMRpcServiceTestBugfix560.java | 155 ----- .../dom/MessageCapturingFlowService.java | 83 --- .../sal/binding/it/AbstractTestProvider.java | 15 - .../test/sal/binding/it/DataServiceIT.java | 12 +- .../test/sal/binding/it/NotificationIT.java | 24 +- .../test/sal/binding/it/RoutedServiceIT.java | 48 +- opendaylight/md-sal/sal-binding-util/pom.xml | 30 - .../AbstractBindingSalConsumerInstance.java | 64 -- .../AbstractBindingSalProviderInstance.java | 65 -- .../sal/binding/util/BindingContextUtils.java | 135 ---- .../sal/binding/util/TypeSafeDataReader.java | 50 -- .../md-sal/sal-cluster-admin-impl/pom.xml | 4 +- opendaylight/md-sal/sal-common-api/pom.xml | 55 -- .../sal/common/api/MappingCheckedFuture.java | 95 --- .../sal/common/api/RegistrationListener.java | 19 - .../data/AsyncConfigurationCommitCohort.java | 67 -- .../AsyncConfigurationCommitCoordinator.java | 36 -- .../data/AsyncConfigurationCommitHandler.java | 122 ---- .../sal/common/api/data/AsyncDataBroker.java | 65 -- .../api/data/AsyncDataTransactionFactory.java | 121 ---- .../api/data/AsyncReadOnlyTransaction.java | 32 - .../common/api/data/AsyncReadTransaction.java | 62 -- .../api/data/AsyncReadWriteTransaction.java | 142 ---- .../sal/common/api/data/AsyncTransaction.java | 38 -- .../api/data/AsyncWriteTransaction.java | 391 ----------- .../md/sal/common/api/data/DataReader.java | 35 - .../data/DataStoreUnavailableException.java | 23 - .../data/DataValidationFailedException.java | 61 -- .../common/api/data/LogicalDatastoreType.java | 69 -- .../data/OptimisticLockFailedException.java | 43 -- .../common/api/data/ReadFailedException.java | 40 -- .../sal/common/api/data/TransactionChain.java | 133 ---- .../data/TransactionChainClosedException.java | 24 - .../api/data/TransactionChainFactory.java | 28 - .../api/data/TransactionChainListener.java | 35 - .../TransactionCommitDeadlockException.java | 43 -- .../TransactionCommitFailedException.java | 31 - .../notify/NotificationPublishService.java | 75 --- .../NotificationSubscriptionService.java | 17 - .../sal/common/api/routing/RouteChange.java | 47 -- .../api/routing/RouteChangeListener.java | 30 - .../api/routing/RouteChangePublisher.java | 22 - .../api/routing/RoutedRegistration.java | 43 -- .../sal/common/api/routing/RoutingTable.java | 23 - .../common/api/MappingCheckedFutureTest.java | 241 ------- opendaylight/md-sal/sal-common-impl/pom.xml | 67 -- .../compat/DataNormalizationException.java | 21 - .../compat/DataNormalizationOperation.java | 607 ------------------ .../impl/util/compat/DataNormalizer.java | 84 --- .../util/compat/DataSchemaContainerProxy.java | 60 -- .../test/resources/normalization-test.yang | 74 --- opendaylight/md-sal/sal-common-util/pom.xml | 4 - .../md-sal/sal-distributed-datastore/pom.xml | 26 +- .../compat/LegacyDOMStoreAdapter.java | 186 ------ .../RegisterDataTreeChangeListener.java | 3 +- .../blueprint/clustered-datastore.xml | 7 - opendaylight/md-sal/sal-dom-api/.gitignore | 1 - opendaylight/md-sal/sal-dom-api/pom.xml | 55 -- .../ClusteredDOMDataTreeChangeListener.java | 25 - .../sal/dom/api/DOMActionProviderService.java | 21 - .../md/sal/dom/api/DOMActionService.java | 21 - .../md/sal/dom/api/DOMDataBroker.java | 43 -- .../sal/dom/api/DOMDataBrokerExtension.java | 18 - .../dom/api/DOMDataReadOnlyTransaction.java | 18 - .../sal/dom/api/DOMDataReadTransaction.java | 77 --- .../dom/api/DOMDataReadWriteTransaction.java | 17 - .../dom/api/DOMDataTreeChangeListener.java | 53 -- .../sal/dom/api/DOMDataTreeChangeService.java | 60 -- .../api/DOMDataTreeCommitCohortRegistry.java | 22 - .../md/sal/dom/api/DOMDataTreeIdentifier.java | 137 ---- .../sal/dom/api/DOMDataWriteTransaction.java | 72 --- .../controller/md/sal/dom/api/DOMEvent.java | 35 - .../md/sal/dom/api/DOMExtensibleService.java | 34 - .../md/sal/dom/api/DOMMountPoint.java | 21 - .../md/sal/dom/api/DOMMountPointService.java | 39 -- .../md/sal/dom/api/DOMNotification.java | 19 - .../sal/dom/api/DOMNotificationListener.java | 26 - .../api/DOMNotificationPublishService.java | 122 ---- .../api/DOMNotificationRejectedException.java | 29 - .../sal/dom/api/DOMNotificationService.java | 57 -- .../dom/api/DOMRpcAvailabilityListener.java | 81 --- .../md/sal/dom/api/DOMRpcException.java | 41 -- .../md/sal/dom/api/DOMRpcIdentifier.java | 139 ---- .../md/sal/dom/api/DOMRpcImplementation.java | 44 -- ...pcImplementationNotAvailableException.java | 35 - .../api/DOMRpcImplementationRegistration.java | 23 - .../md/sal/dom/api/DOMRpcProviderService.java | 60 -- .../md/sal/dom/api/DOMRpcResult.java | 20 - .../md/sal/dom/api/DOMRpcService.java | 60 -- .../controller/md/sal/dom/api/DOMService.java | 22 - .../md/sal/dom/api/DOMServiceExtension.java | 21 - .../md/sal/dom/api/DOMTransactionChain.java | 38 -- .../sal/dom/api/DefaultDOMRpcException.java | 23 - opendaylight/md-sal/sal-dom-broker/pom.xml | 121 ---- .../broker/impl/AbstractDOMDataBroker.java | 116 ---- ...tractDOMForwardedCompositeTransaction.java | 107 --- ...bstractDOMForwardedTransactionFactory.java | 263 -------- .../impl/AbstractDOMRpcRoutingTableEntry.java | 119 ---- .../broker/impl/CommitCoordinationTask.java | 280 -------- .../DOMDataBrokerTransactionChainImpl.java | 151 ----- .../impl/DOMForwardedReadOnlyTransaction.java | 53 -- .../DOMForwardedReadWriteTransaction.java | 60 -- .../impl/DOMForwardedWriteTransaction.java | 164 ----- .../broker/impl/DOMNotificationRouter.java | 110 ---- .../impl/DOMNotificationRouterEvent.java | 68 -- .../md/sal/dom/broker/impl/DOMRpcRouter.java | 152 ----- .../dom/broker/impl/DOMRpcRoutingTable.java | 192 ------ .../impl/GlobalDOMRpcRoutingTableEntry.java | 51 -- .../dom/broker/impl/PingPongDataBroker.java | 75 --- .../dom/broker/impl/PingPongTransaction.java | 72 --- .../broker/impl/PingPongTransactionChain.java | 482 -------------- .../impl/RoutedDOMRpcRoutingTableEntry.java | 96 --- .../broker/impl/SerializedDOMDataBroker.java | 85 --- ...ransactionCommitFailedExceptionMapper.java | 46 -- .../impl/UnknownDOMRpcRoutingTableEntry.java | 43 -- .../LegacyShardedDOMDataBrokerAdapter.java | 87 --- ...OMDataBrokerDelegatingReadTransaction.java | 66 -- ...aBrokerDelegatingReadWriteTransaction.java | 240 ------- ...MDataBrokerDelegatingTransactionChain.java | 113 ---- ...MDataBrokerDelegatingWriteTransaction.java | 62 -- .../impl/mount/DOMMountPointServiceImpl.java | 182 ------ .../broker/impl/SchemaContextProviders.java | 52 -- .../dom/broker/util/ProxySchemaContext.java | 166 ----- .../OSGI-INF/blueprint/dom-broker.xml | 86 --- .../BlockingTransactionChainListener.java | 48 -- .../broker/impl/DOMBrokerPerformanceTest.java | 221 ------- .../md/sal/dom/broker/impl/DOMBrokerTest.java | 235 ------- .../broker/impl/DOMDataTreeListenerTest.java | 445 ------------- .../DOMForwardedWriteTransactionTest.java | 77 --- .../impl/DOMNotificationRouterTest.java | 272 -------- .../sal/dom/broker/impl/DOMRpcRouterTest.java | 362 ----------- .../broker/impl/DOMTransactionChainTest.java | 196 ------ .../broker/impl/MountPointServiceTest.java | 46 -- ...kerDelegatingReadWriteTransactionTest.java | 111 ---- ...aBrokerDelegatingTransactionChainTest.java | 154 ----- .../md/sal/dom/store/impl/TestModel.java | 42 -- .../test/resources/odl-datastore-test.yang | 70 -- opendaylight/md-sal/sal-dom-compat/pom.xml | 44 -- .../AbstractDOMRpcResultFutureAdapter.java | 103 --- .../AbstractLegacyDOMDataBrokerAdapter.java | 376 ----------- .../sal/core/compat/DOMDataBrokerAdapter.java | 86 --- .../DOMDataTreeChangeServiceAdapter.java | 55 -- .../DOMDataTreeReadTransactionAdapter.java | 54 -- ...OMDataTreeReadWriteTransactionAdapter.java | 78 --- .../DOMDataTreeWriteTransactionAdapter.java | 66 -- .../sal/core/compat/DOMMountPointAdapter.java | 130 ---- .../compat/DOMNotificationServiceAdapter.java | 56 -- .../sal/core/compat/DOMRpcServiceAdapter.java | 71 -- .../sal/core/compat/DOMStoreAdapter.java | 60 -- .../DOMStoreReadTransactionAdapter.java | 57 -- .../DOMStoreReadWriteTransactionAdapter.java | 43 -- ...DOMStoreThreePhaseCommitCohortAdapter.java | 49 -- .../DOMStoreTransactionChainAdapter.java | 51 -- .../DOMStoreWriteTransactionAdapter.java | 61 -- .../compat/DOMTransactionChainAdapter.java | 110 ---- .../compat/LegacyDOMActionServiceAdapter.java | 45 -- .../compat/LegacyDOMDataBrokerAdapter.java | 28 - .../LegacyDOMNotificationServiceAdapter.java | 105 --- .../LegacyDOMRpcResultFutureAdapter.java | 72 --- .../compat/LegacyDOMRpcServiceAdapter.java | 57 -- .../LegacyPingPongDOMDataBrokerAdapter.java | 27 - .../MdsalDOMRpcResultFutureAdapter.java | 46 -- .../compat/ReadFailedExceptionAdapter.java | 34 - .../RpcAvailabilityListenerAdapter.java | 47 -- .../sal/core/compat/TransactionUtils.java | 52 -- .../sal/core/compat/package-info.java | 13 - .../core/compat/DOMMountPointAdapterTest.java | 86 --- .../LegacyDOMDataBrokerAdapterTest.java | 530 --------------- opendaylight/md-sal/sal-dom-spi/pom.xml | 34 - .../broker/spi/mount/SimpleDOMMountPoint.java | 73 --- .../broker/spi/rpc/RpcRoutingStrategy.java | 131 ---- ...DOMDataTreeChangeListenerRegistration.java | 26 - ...tractDOMRpcImplementationRegistration.java | 24 - .../spi/AbstractDOMRpcProviderService.java | 27 - .../DOMNotificationSubscriptionListener.java | 25 - ...ificationSubscriptionListenerRegistry.java | 25 - .../md/sal/dom/spi/DefaultDOMRpcResult.java | 108 ---- .../sal/dom/spi/ForwardingDOMDataBroker.java | 56 -- .../ForwardingDOMDataReadOnlyTransaction.java | 53 -- ...ForwardingDOMDataReadWriteTransaction.java | 77 --- .../ForwardingDOMDataWriteTransaction.java | 61 -- ...rwardingDOMNotificationPublishService.java | 43 -- .../spi/ForwardingDOMNotificationService.java | 39 -- .../spi/ForwardingDOMRpcImplementation.java | 35 - .../spi/ForwardingDOMRpcProviderService.java | 40 -- .../sal/dom/spi/ForwardingDOMRpcResult.java | 37 -- .../sal/dom/spi/ForwardingDOMRpcService.java | 41 -- .../spi/ForwardingDOMTransactionChain.java | 47 -- .../spi/data/AbstractDOMStoreTransaction.java | 75 --- .../AbstractDOMStoreTreeChangePublisher.java | 150 ----- ...bstractSnapshotBackedTransactionChain.java | 305 --------- .../sal/core/spi/data/DOMStore.java | 41 -- .../spi/data/DOMStoreReadTransaction.java | 59 -- .../data/DOMStoreReadWriteTransaction.java | 18 - .../data/DOMStoreThreePhaseCommitCohort.java | 67 -- .../core/spi/data/DOMStoreTransaction.java | 30 - .../spi/data/DOMStoreTransactionChain.java | 89 --- .../spi/data/DOMStoreTransactionFactory.java | 64 -- .../spi/data/DOMStoreTreeChangePublisher.java | 63 -- .../spi/data/DOMStoreWriteTransaction.java | 64 -- ...wardingDOMStoreThreePhaseCommitCohort.java | 46 -- .../data/SnapshotBackedReadTransaction.java | 129 ---- .../SnapshotBackedReadWriteTransaction.java | 71 -- .../spi/data/SnapshotBackedTransactions.java | 83 --- .../data/SnapshotBackedWriteTransaction.java | 213 ------ .../sal/core/spi/data/package-info.java | 8 - .../data/statistics/DOMStoreStatsTracker.java | 43 -- .../md-sal/sal-inmemory-datastore/pom.xml | 132 ---- .../dom/store/impl/InMemoryDOMDataStore.java | 73 --- .../InMemoryDOMDataStoreConfigProperties.java | 108 ---- .../impl/InMemoryDOMDataStoreFactory.java | 86 --- .../InMemoryDOMStoreTreeChangePublisher.java | 93 --- .../impl/jmx/InMemoryDataStoreStats.java | 54 -- .../AbstractDataTreeChangeListenerTest.java | 180 ------ .../sal/dom/store/impl/DatastoreTestTask.java | 245 ------- ...efaultDataTreeChangeListenerTestSuite.java | 128 ---- .../dom/store/impl/InMemoryDataStoreTest.java | 480 -------------- .../dom/store/impl/RootScopeSubtreeTest.java | 96 --- .../impl/SchemaUpdateForTransactionTest.java | 80 --- .../store/impl/TestDCLExecutorService.java | 42 -- .../md/sal/dom/store/impl/TestModel.java | 48 -- .../store/impl/WildcardedScopeBaseTest.java | 101 --- .../test/resources/odl-datastore-test.yang | 56 -- .../md-sal/sal-remoterpc-connector/pom.xml | 4 - .../clustering-test-app/provider/pom.xml | 8 +- .../it/listener/PeopleCarListener.java | 13 +- .../it/provider/BasicRpcTestProvider.java | 14 +- .../provider/CarDataTreeChangeListener.java | 16 +- .../clustering/it/provider/CarProvider.java | 29 +- .../provider/MdsalLowLevelTestProvider.java | 52 +- .../it/provider/PeopleProvider.java | 34 +- .../it/provider/PurchaseCarProvider.java | 24 +- .../impl/AbstractTransactionHandler.java | 11 +- .../it/provider/impl/GetConstantService.java | 57 +- .../it/provider/impl/IdIntsListener.java | 6 +- .../impl/PublishNotificationsTask.java | 2 +- .../impl/RoutedGetConstantService.java | 56 +- .../impl/SingletonGetConstantService.java | 61 +- .../impl/WriteTransactionsHandler.java | 65 +- .../OSGI-INF/blueprint/cluster-test-app.xml | 19 +- .../md-sal/samples/toaster-consumer/pom.xml | 4 +- 464 files changed, 343 insertions(+), 34543 deletions(-) delete mode 100644 features/mdsal/odl-controller-binding-api/pom.xml delete mode 100644 features/mdsal/odl-controller-binding-api/src/main/feature/feature.xml delete mode 100644 features/mdsal/odl-controller-dom-api/pom.xml delete mode 100644 features/mdsal/odl-controller-dom-api/src/main/feature/feature.xml delete mode 100644 features/mdsal/odl-mdsal-clustering/pom.xml delete mode 100644 opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/RoutedRpcMetadata.java delete mode 100644 opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/RoutedRpcRegistrationConverter.java delete mode 100644 opendaylight/md-sal/mdsal-trace/api/pom.xml delete mode 100644 opendaylight/md-sal/mdsal-trace/api/src/main/java/org/opendaylight/controller/md/sal/trace/api/TracingDOMDataBroker.java delete mode 100644 opendaylight/md-sal/mdsal-trace/api/src/main/resources/initial/mdsaltrace_config.xml delete mode 100644 opendaylight/md-sal/mdsal-trace/api/src/main/yang/mdsaltrace.yang delete mode 100644 opendaylight/md-sal/mdsal-trace/binding-impl/pom.xml delete mode 100644 opendaylight/md-sal/mdsal-trace/binding-impl/src/main/java/org/opendaylight/controller/md/sal/trace/binding/impl/TracingBindingBrokerWiring.java delete mode 100644 opendaylight/md-sal/mdsal-trace/binding-impl/src/main/resources/OSGI-INF/blueprint/impl-blueprint.xml delete mode 100644 opendaylight/md-sal/mdsal-trace/cli/pom.xml delete mode 100644 opendaylight/md-sal/mdsal-trace/cli/src/main/java/org/opendaylight/controller/md/sal/trace/cli/PrintOpenTransactionsCommand.java delete mode 100644 opendaylight/md-sal/mdsal-trace/deploy-site.xml delete mode 100644 opendaylight/md-sal/mdsal-trace/dom-impl/pom.xml delete mode 100644 opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/closetracker/impl/AbstractCloseTracked.java delete mode 100644 opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/closetracker/impl/CloseTracked.java delete mode 100644 opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/closetracker/impl/CloseTrackedRegistry.java delete mode 100644 opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/closetracker/impl/CloseTrackedRegistryReportEntry.java delete mode 100644 opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/closetracker/impl/CloseTrackedTrait.java delete mode 100644 opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/closetracker/impl/package-info.java delete mode 100644 opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/dom/impl/AbstractTracingWriteTransaction.java delete mode 100644 opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/dom/impl/TracingBroker.java delete mode 100644 opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/dom/impl/TracingReadOnlyTransaction.java delete mode 100644 opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/dom/impl/TracingReadWriteTransaction.java delete mode 100644 opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/dom/impl/TracingTransactionChain.java delete mode 100644 opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/dom/impl/TracingWriteTransaction.java delete mode 100644 opendaylight/md-sal/mdsal-trace/dom-impl/src/main/resources/OSGI-INF/blueprint/impl-blueprint.xml delete mode 100644 opendaylight/md-sal/mdsal-trace/dom-impl/src/test/java/org/opendaylight/controller/md/sal/trace/tests/CloseTrackedRegistryTest.java delete mode 100644 opendaylight/md-sal/mdsal-trace/dom-impl/src/test/java/org/opendaylight/controller/md/sal/trace/tests/TracingBrokerTest.java delete mode 100644 opendaylight/md-sal/mdsal-trace/features/features-mdsal-trace/pom.xml delete mode 100644 opendaylight/md-sal/mdsal-trace/features/odl-mdsal-trace/pom.xml delete mode 100644 opendaylight/md-sal/mdsal-trace/features/odl-mdsal-trace/src/main/feature/feature.xml delete mode 100644 opendaylight/md-sal/mdsal-trace/features/pom.xml delete mode 100644 opendaylight/md-sal/mdsal-trace/pom.xml delete mode 100644 opendaylight/md-sal/sal-binding-api/.gitignore delete mode 100644 opendaylight/md-sal/sal-binding-api/pom.xml delete mode 100644 opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/ActionProviderService.java delete mode 100644 opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/ActionService.java delete mode 100644 opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/BindingService.java delete mode 100644 opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/BindingTransactionChain.java delete mode 100644 opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/ClusteredDataTreeChangeListener.java delete mode 100644 opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/DataBroker.java delete mode 100644 opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/DataObjectModification.java delete mode 100644 opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/DataTreeChangeListener.java delete mode 100644 opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/DataTreeChangeService.java delete mode 100644 opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/DataTreeIdentifier.java delete mode 100644 opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/DataTreeModification.java delete mode 100644 opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/ForwardingDataBroker.java delete mode 100644 opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/ForwardingReadOnlyTransaction.java delete mode 100644 opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/ForwardingReadWriteTransaction.java delete mode 100644 opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/ForwardingWriteTransaction.java delete mode 100644 opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/MountPoint.java delete mode 100644 opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/MountPointService.java delete mode 100644 opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/NotificationPublishService.java delete mode 100644 opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/NotificationRejectedException.java delete mode 100644 opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/NotificationService.java delete mode 100644 opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/ReadOnlyTransaction.java delete mode 100644 opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/ReadTransaction.java delete mode 100644 opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/ReadWriteTransaction.java delete mode 100644 opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/TransactionFactory.java delete mode 100644 opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/WriteTransaction.java delete mode 100644 opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/AbstractBindingAwareConsumer.java delete mode 100644 opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/AbstractBindingAwareProvider.java delete mode 100644 opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/AbstractBrokerAwareActivator.java delete mode 100644 opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/BindingAwareBroker.java delete mode 100644 opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/BindingAwareConsumer.java delete mode 100644 opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/BindingAwareProvider.java delete mode 100644 opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/BindingAwareService.java delete mode 100644 opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/NotificationListener.java delete mode 100644 opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/NotificationProviderService.java delete mode 100644 opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/NotificationService.java delete mode 100644 opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/RpcAvailabilityListener.java delete mode 100644 opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/RpcConsumerRegistry.java delete mode 100644 opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/RpcProviderRegistry.java delete mode 100644 opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/package-info.java delete mode 100644 opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/rpc/RpcContextIdentifier.java delete mode 100644 opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/rpc/RpcRoutingContext.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/pom.xml delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/main/.gitignore delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/AbstractNotificationListenerRegistration.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/AggregatedNotificationListenerRegistration.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/CompositeRoutedRpcRegistration.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/DelegatedRootRpcRegistration.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/FunctionalNotificationListenerAdapter.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/HeliumNotificationProviderServiceAdapter.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/HeliumNotificationProviderServiceWithInterestListeners.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/HeliumNotificationServiceAdapter.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/HeliumRpcProviderRegistry.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/ListenerMapGeneration.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/NotificationInvoker.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/NotificationListenerRegistration.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/AbstractForwardedDataBroker.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/AbstractForwardedTransaction.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/AbstractReadWriteTransaction.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/AbstractWriteTransaction.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingBrokerWiring.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingClusteredDOMDataTreeChangeListenerAdapter.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMAdapterBuilder.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMAdapterLoader.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMDataBrokerAdapter.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMDataTreeChangeListenerAdapter.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMDataTreeChangeServiceAdapter.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMMountPointListenerAdapter.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMMountPointServiceAdapter.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMNotificationListenerAdapter.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMNotificationPublishServiceAdapter.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMNotificationServiceAdapter.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMReadTransactionAdapter.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMReadWriteTransactionAdapter.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMRpcAdapterRegistration.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMRpcImplementationAdapter.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMRpcProviderServiceAdapter.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMRpcServiceAdapter.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMTransactionChainAdapter.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMWriteTransactionAdapter.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDataTreeChangeListenerRegistration.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingMountPointAdapter.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingRpcAdapterRegistration.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingToDOMAdapterFactory.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingToNormalizedNodeCodec.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/ContextReferenceExtractor.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/ControllerActionProviderServiceAdapter.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/ControllerActionServiceAdapter.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/DirectGetterRouteContextExtractor.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/GetValueRouteContextExtractor.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/LazyDOMRpcResultFuture.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/LazyDataObjectModification.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/LazyDataTreeModification.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/LazySerializedContainerNode.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/LazySerializedDOMNotification.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/RpcServiceAdapter.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/spi/AdapterBuilder.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/spi/AdapterFactory.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/spi/AdapterLoader.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/RootBindingAwareBroker.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/main/resources/OSGI-INF/blueprint/binding-broker.xml delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMDataTreeChangeServiceAdapterTest.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMMountPointServiceAdapterTest.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/BindingNormalizedCodecTest.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/ContextExtractorTest.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/BackwardsCompatibleNotificationBrokerTest.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/BindingDOMDataBrokerAdapterTest.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/Bug1125RegressionTest.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/Bug1333DataChangeListenerTest.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/Bug1418AugmentationTest.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/Bug2562DeserializedUnkeyedListTest.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/Bug3090MultiKeyList.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/Bug4494Test.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/Bug4513Test.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/DataTreeChangeListenerTest.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/ForwardedNotificationAdapterTest.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/ListInsertionDataChangeListenerTest.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/WriteTransactionTest.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/AbstractBaseDataBrokerTest.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/AbstractConcurrentDataBrokerTest.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/AbstractDataBrokerTest.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/AbstractDataBrokerTestCustomizer.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/AbstractDataTreeChangeListenerTest.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/AbstractNotificationBrokerTest.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/AbstractSchemaAwareTest.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/AssertCollections.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/ConcurrentDataBrokerTestCustomizer.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/ConstantSchemaAbstractDataBrokerTest.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/DataBrokerTestCustomizer.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/DataBrokerTestModule.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/SchemaContextSingleton.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/tests/AbstractDataBrokerTestTest.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/tests/DataBrokerTestModuleTest.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/AbstractDataServiceTest.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/AugmentationVerifier.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/BindingTestUtilities.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/BarListener.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/BarUpdate.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/CompositeListener.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/FlowDelete.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/FooListener.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/FooService.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/FooUpdate.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/Grouping.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/InheritedContextInput.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/ReferencableObject.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/ReferencableObjectKey.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/SimpleInput.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/util/BindingBrokerTestFactory.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/util/BindingTestContext.java delete mode 100644 opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/util/MockSchemaService.java delete mode 100644 opendaylight/md-sal/sal-binding-dom-it/pom.xml delete mode 100644 opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/md/sal/binding/data/ConcurrentImplicitCreateTest.java delete mode 100644 opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/md/sal/binding/data/WildcardedDataChangeListenerTest.java delete mode 100644 opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/DeleteNestedAugmentationListenParentTest.java delete mode 100644 opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/WriteParentListenAugmentTest.java delete mode 100644 opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/WriteParentReadChildTest.java delete mode 100644 opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/package-info.java delete mode 100644 opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/BrokerIntegrationTest.java delete mode 100644 opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/CrossBrokerMountPointTest.java delete mode 100644 opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/CrossBrokerRpcTest.java delete mode 100644 opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/DOMRpcServiceTestBugfix560.java delete mode 100644 opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/MessageCapturingFlowService.java delete mode 100644 opendaylight/md-sal/sal-binding-it/src/test/java/org/opendaylight/controller/test/sal/binding/it/AbstractTestProvider.java delete mode 100644 opendaylight/md-sal/sal-binding-util/pom.xml delete mode 100644 opendaylight/md-sal/sal-binding-util/src/main/java/org/opendaylight/controller/md/sal/binding/util/AbstractBindingSalConsumerInstance.java delete mode 100644 opendaylight/md-sal/sal-binding-util/src/main/java/org/opendaylight/controller/md/sal/binding/util/AbstractBindingSalProviderInstance.java delete mode 100644 opendaylight/md-sal/sal-binding-util/src/main/java/org/opendaylight/controller/md/sal/binding/util/BindingContextUtils.java delete mode 100644 opendaylight/md-sal/sal-binding-util/src/main/java/org/opendaylight/controller/md/sal/binding/util/TypeSafeDataReader.java delete mode 100644 opendaylight/md-sal/sal-common-api/pom.xml delete mode 100644 opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/MappingCheckedFuture.java delete mode 100644 opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/RegistrationListener.java delete mode 100644 opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncConfigurationCommitCohort.java delete mode 100644 opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncConfigurationCommitCoordinator.java delete mode 100644 opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncConfigurationCommitHandler.java delete mode 100644 opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncDataBroker.java delete mode 100644 opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncDataTransactionFactory.java delete mode 100644 opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncReadOnlyTransaction.java delete mode 100644 opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncReadTransaction.java delete mode 100644 opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncReadWriteTransaction.java delete mode 100644 opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncTransaction.java delete mode 100644 opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncWriteTransaction.java delete mode 100644 opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/DataReader.java delete mode 100644 opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/DataStoreUnavailableException.java delete mode 100644 opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/DataValidationFailedException.java delete mode 100644 opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/LogicalDatastoreType.java delete mode 100644 opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/OptimisticLockFailedException.java delete mode 100644 opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/ReadFailedException.java delete mode 100644 opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/TransactionChain.java delete mode 100644 opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/TransactionChainClosedException.java delete mode 100644 opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/TransactionChainFactory.java delete mode 100644 opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/TransactionChainListener.java delete mode 100644 opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/TransactionCommitDeadlockException.java delete mode 100644 opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/TransactionCommitFailedException.java delete mode 100644 opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/notify/NotificationPublishService.java delete mode 100644 opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/notify/NotificationSubscriptionService.java delete mode 100644 opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/routing/RouteChange.java delete mode 100644 opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/routing/RouteChangeListener.java delete mode 100644 opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/routing/RouteChangePublisher.java delete mode 100644 opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/routing/RoutedRegistration.java delete mode 100644 opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/routing/RoutingTable.java delete mode 100644 opendaylight/md-sal/sal-common-api/src/test/java/org/opendaylight/controller/md/sal/common/api/MappingCheckedFutureTest.java delete mode 100644 opendaylight/md-sal/sal-common-impl/pom.xml delete mode 100644 opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/util/compat/DataNormalizationException.java delete mode 100644 opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/util/compat/DataNormalizationOperation.java delete mode 100644 opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/util/compat/DataNormalizer.java delete mode 100644 opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/util/compat/DataSchemaContainerProxy.java delete mode 100644 opendaylight/md-sal/sal-common-impl/src/test/resources/normalization-test.yang delete mode 100644 opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/compat/LegacyDOMStoreAdapter.java delete mode 100644 opendaylight/md-sal/sal-dom-api/.gitignore delete mode 100644 opendaylight/md-sal/sal-dom-api/pom.xml delete mode 100644 opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/ClusteredDOMDataTreeChangeListener.java delete mode 100644 opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMActionProviderService.java delete mode 100644 opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMActionService.java delete mode 100644 opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataBroker.java delete mode 100644 opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataBrokerExtension.java delete mode 100644 opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataReadOnlyTransaction.java delete mode 100644 opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataReadTransaction.java delete mode 100644 opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataReadWriteTransaction.java delete mode 100644 opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataTreeChangeListener.java delete mode 100644 opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataTreeChangeService.java delete mode 100644 opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataTreeCommitCohortRegistry.java delete mode 100644 opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataTreeIdentifier.java delete mode 100644 opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataWriteTransaction.java delete mode 100644 opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMEvent.java delete mode 100644 opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMExtensibleService.java delete mode 100644 opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMMountPoint.java delete mode 100644 opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMMountPointService.java delete mode 100644 opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMNotification.java delete mode 100644 opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMNotificationListener.java delete mode 100644 opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMNotificationPublishService.java delete mode 100644 opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMNotificationRejectedException.java delete mode 100644 opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMNotificationService.java delete mode 100644 opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMRpcAvailabilityListener.java delete mode 100644 opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMRpcException.java delete mode 100644 opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMRpcIdentifier.java delete mode 100644 opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMRpcImplementation.java delete mode 100644 opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMRpcImplementationNotAvailableException.java delete mode 100644 opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMRpcImplementationRegistration.java delete mode 100644 opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMRpcProviderService.java delete mode 100644 opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMRpcResult.java delete mode 100644 opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMRpcService.java delete mode 100644 opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMService.java delete mode 100644 opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMServiceExtension.java delete mode 100644 opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMTransactionChain.java delete mode 100644 opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DefaultDOMRpcException.java delete mode 100644 opendaylight/md-sal/sal-dom-broker/pom.xml delete mode 100755 opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/AbstractDOMDataBroker.java delete mode 100644 opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/AbstractDOMForwardedCompositeTransaction.java delete mode 100644 opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/AbstractDOMForwardedTransactionFactory.java delete mode 100644 opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/AbstractDOMRpcRoutingTableEntry.java delete mode 100644 opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/CommitCoordinationTask.java delete mode 100755 opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMDataBrokerTransactionChainImpl.java delete mode 100644 opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMForwardedReadOnlyTransaction.java delete mode 100644 opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMForwardedReadWriteTransaction.java delete mode 100644 opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMForwardedWriteTransaction.java delete mode 100644 opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMNotificationRouter.java delete mode 100644 opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMNotificationRouterEvent.java delete mode 100644 opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMRpcRouter.java delete mode 100644 opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMRpcRoutingTable.java delete mode 100644 opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/GlobalDOMRpcRoutingTableEntry.java delete mode 100644 opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/PingPongDataBroker.java delete mode 100644 opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/PingPongTransaction.java delete mode 100644 opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/PingPongTransactionChain.java delete mode 100644 opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/RoutedDOMRpcRoutingTableEntry.java delete mode 100644 opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/SerializedDOMDataBroker.java delete mode 100644 opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/TransactionCommitFailedExceptionMapper.java delete mode 100644 opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/UnknownDOMRpcRoutingTableEntry.java delete mode 100644 opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/legacy/sharded/adapter/LegacyShardedDOMDataBrokerAdapter.java delete mode 100644 opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/legacy/sharded/adapter/ShardedDOMDataBrokerDelegatingReadTransaction.java delete mode 100644 opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/legacy/sharded/adapter/ShardedDOMDataBrokerDelegatingReadWriteTransaction.java delete mode 100644 opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/legacy/sharded/adapter/ShardedDOMDataBrokerDelegatingTransactionChain.java delete mode 100644 opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/legacy/sharded/adapter/ShardedDOMDataBrokerDelegatingWriteTransaction.java delete mode 100644 opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/mount/DOMMountPointServiceImpl.java delete mode 100644 opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/SchemaContextProviders.java delete mode 100644 opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/util/ProxySchemaContext.java delete mode 100644 opendaylight/md-sal/sal-dom-broker/src/main/resources/OSGI-INF/blueprint/dom-broker.xml delete mode 100644 opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/BlockingTransactionChainListener.java delete mode 100644 opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMBrokerPerformanceTest.java delete mode 100644 opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMBrokerTest.java delete mode 100644 opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMDataTreeListenerTest.java delete mode 100644 opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMForwardedWriteTransactionTest.java delete mode 100644 opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMNotificationRouterTest.java delete mode 100644 opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMRpcRouterTest.java delete mode 100644 opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMTransactionChainTest.java delete mode 100644 opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/MountPointServiceTest.java delete mode 100644 opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/legacy/sharded/adapter/ShardedDOMDataBrokerDelegatingReadWriteTransactionTest.java delete mode 100644 opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/legacy/sharded/adapter/ShardedDOMDataBrokerDelegatingTransactionChainTest.java delete mode 100644 opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/TestModel.java delete mode 100644 opendaylight/md-sal/sal-dom-broker/src/test/resources/odl-datastore-test.yang delete mode 100644 opendaylight/md-sal/sal-dom-compat/pom.xml delete mode 100644 opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/AbstractDOMRpcResultFutureAdapter.java delete mode 100644 opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/AbstractLegacyDOMDataBrokerAdapter.java delete mode 100644 opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMDataBrokerAdapter.java delete mode 100644 opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMDataTreeChangeServiceAdapter.java delete mode 100644 opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMDataTreeReadTransactionAdapter.java delete mode 100644 opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMDataTreeReadWriteTransactionAdapter.java delete mode 100644 opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMDataTreeWriteTransactionAdapter.java delete mode 100644 opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMMountPointAdapter.java delete mode 100644 opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMNotificationServiceAdapter.java delete mode 100644 opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMRpcServiceAdapter.java delete mode 100644 opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMStoreAdapter.java delete mode 100644 opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMStoreReadTransactionAdapter.java delete mode 100644 opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMStoreReadWriteTransactionAdapter.java delete mode 100644 opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMStoreThreePhaseCommitCohortAdapter.java delete mode 100644 opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMStoreTransactionChainAdapter.java delete mode 100644 opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMStoreWriteTransactionAdapter.java delete mode 100644 opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMTransactionChainAdapter.java delete mode 100644 opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/LegacyDOMActionServiceAdapter.java delete mode 100644 opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/LegacyDOMDataBrokerAdapter.java delete mode 100644 opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/LegacyDOMNotificationServiceAdapter.java delete mode 100644 opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/LegacyDOMRpcResultFutureAdapter.java delete mode 100644 opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/LegacyDOMRpcServiceAdapter.java delete mode 100644 opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/LegacyPingPongDOMDataBrokerAdapter.java delete mode 100644 opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/MdsalDOMRpcResultFutureAdapter.java delete mode 100644 opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/ReadFailedExceptionAdapter.java delete mode 100644 opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/RpcAvailabilityListenerAdapter.java delete mode 100644 opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/TransactionUtils.java delete mode 100644 opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/package-info.java delete mode 100644 opendaylight/md-sal/sal-dom-compat/src/test/java/org/opendaylight/controller/sal/core/compat/DOMMountPointAdapterTest.java delete mode 100644 opendaylight/md-sal/sal-dom-compat/src/test/java/org/opendaylight/controller/sal/core/compat/LegacyDOMDataBrokerAdapterTest.java delete mode 100644 opendaylight/md-sal/sal-dom-spi/pom.xml delete mode 100644 opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/broker/spi/mount/SimpleDOMMountPoint.java delete mode 100644 opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/broker/spi/rpc/RpcRoutingStrategy.java delete mode 100644 opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/AbstractDOMDataTreeChangeListenerRegistration.java delete mode 100644 opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/AbstractDOMRpcImplementationRegistration.java delete mode 100644 opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/AbstractDOMRpcProviderService.java delete mode 100644 opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/DOMNotificationSubscriptionListener.java delete mode 100644 opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/DOMNotificationSubscriptionListenerRegistry.java delete mode 100644 opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/DefaultDOMRpcResult.java delete mode 100644 opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMDataBroker.java delete mode 100644 opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMDataReadOnlyTransaction.java delete mode 100644 opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMDataReadWriteTransaction.java delete mode 100644 opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMDataWriteTransaction.java delete mode 100644 opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMNotificationPublishService.java delete mode 100644 opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMNotificationService.java delete mode 100644 opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMRpcImplementation.java delete mode 100644 opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMRpcProviderService.java delete mode 100644 opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMRpcResult.java delete mode 100644 opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMRpcService.java delete mode 100644 opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMTransactionChain.java delete mode 100644 opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/AbstractDOMStoreTransaction.java delete mode 100644 opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/AbstractDOMStoreTreeChangePublisher.java delete mode 100644 opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/AbstractSnapshotBackedTransactionChain.java delete mode 100644 opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/DOMStore.java delete mode 100644 opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/DOMStoreReadTransaction.java delete mode 100644 opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/DOMStoreReadWriteTransaction.java delete mode 100644 opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/DOMStoreThreePhaseCommitCohort.java delete mode 100644 opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/DOMStoreTransaction.java delete mode 100644 opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/DOMStoreTransactionChain.java delete mode 100644 opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/DOMStoreTransactionFactory.java delete mode 100644 opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/DOMStoreTreeChangePublisher.java delete mode 100644 opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/DOMStoreWriteTransaction.java delete mode 100644 opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/ForwardingDOMStoreThreePhaseCommitCohort.java delete mode 100644 opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/SnapshotBackedReadTransaction.java delete mode 100644 opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/SnapshotBackedReadWriteTransaction.java delete mode 100644 opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/SnapshotBackedTransactions.java delete mode 100644 opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/SnapshotBackedWriteTransaction.java delete mode 100644 opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/package-info.java delete mode 100644 opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/statistics/DOMStoreStatsTracker.java delete mode 100644 opendaylight/md-sal/sal-inmemory-datastore/pom.xml delete mode 100644 opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStore.java delete mode 100644 opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStoreConfigProperties.java delete mode 100644 opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStoreFactory.java delete mode 100644 opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMStoreTreeChangePublisher.java delete mode 100644 opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/jmx/InMemoryDataStoreStats.java delete mode 100644 opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/AbstractDataTreeChangeListenerTest.java delete mode 100644 opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/DatastoreTestTask.java delete mode 100644 opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/DefaultDataTreeChangeListenerTestSuite.java delete mode 100644 opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDataStoreTest.java delete mode 100644 opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/RootScopeSubtreeTest.java delete mode 100644 opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/SchemaUpdateForTransactionTest.java delete mode 100644 opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/TestDCLExecutorService.java delete mode 100644 opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/TestModel.java delete mode 100644 opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/WildcardedScopeBaseTest.java delete mode 100644 opendaylight/md-sal/sal-inmemory-datastore/src/test/resources/odl-datastore-test.yang diff --git a/benchmark/rpcbenchmark/pom.xml b/benchmark/rpcbenchmark/pom.xml index a079b1e757..21d2427600 100644 --- a/benchmark/rpcbenchmark/pom.xml +++ b/benchmark/rpcbenchmark/pom.xml @@ -40,17 +40,13 @@ and is available at http://www.eclipse.org/legal/epl-v10.html benchmark-api ${project.version} - - org.opendaylight.controller - sal-binding-api - - - org.opendaylight.controller - sal-core-api - org.opendaylight.yangtools yang-data-impl + + org.opendaylight.mdsal + mdsal-binding-api + diff --git a/benchmark/rpcbenchmark/src/main/java/rpcbenchmark/impl/GlobalBindingRTCClient.java b/benchmark/rpcbenchmark/src/main/java/rpcbenchmark/impl/GlobalBindingRTCClient.java index f09bd7fc15..692bdf7d09 100644 --- a/benchmark/rpcbenchmark/src/main/java/rpcbenchmark/impl/GlobalBindingRTCClient.java +++ b/benchmark/rpcbenchmark/src/main/java/rpcbenchmark/impl/GlobalBindingRTCClient.java @@ -12,7 +12,7 @@ import java.util.List; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; import java.util.concurrent.atomic.AtomicLong; -import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry; +import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry; import org.opendaylight.yang.gen.v1.rpcbench.payload.rev150702.GlobalRpcBenchInput; import org.opendaylight.yang.gen.v1.rpcbench.payload.rev150702.GlobalRpcBenchInputBuilder; import org.opendaylight.yang.gen.v1.rpcbench.payload.rev150702.GlobalRpcBenchOutput; diff --git a/benchmark/rpcbenchmark/src/main/java/rpcbenchmark/impl/RoutedBindingRTClient.java b/benchmark/rpcbenchmark/src/main/java/rpcbenchmark/impl/RoutedBindingRTClient.java index cc388a33cd..ab03fb2a5e 100644 --- a/benchmark/rpcbenchmark/src/main/java/rpcbenchmark/impl/RoutedBindingRTClient.java +++ b/benchmark/rpcbenchmark/src/main/java/rpcbenchmark/impl/RoutedBindingRTClient.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package rpcbenchmark.impl; import java.util.ArrayList; @@ -14,7 +13,7 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.atomic.AtomicLong; -import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry; +import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry; import org.opendaylight.yang.gen.v1.rpcbench.payload.rev150702.RoutedRpcBenchInput; import org.opendaylight.yang.gen.v1.rpcbench.payload.rev150702.RoutedRpcBenchInputBuilder; import org.opendaylight.yang.gen.v1.rpcbench.payload.rev150702.RoutedRpcBenchOutput; @@ -34,16 +33,6 @@ public class RoutedBindingRTClient implements RTCClient { private final List inVal; private final int inSize; - @Override - public long getRpcOk() { - return rpcOk.get(); - } - - @Override - public long getRpcError() { - return rpcError.get(); - } - public RoutedBindingRTClient(final RpcConsumerRegistry registry, final int inSize, final List> routeIid) { if (registry != null) { @@ -65,6 +54,16 @@ public class RoutedBindingRTClient implements RTCClient { } + @Override + public long getRpcOk() { + return rpcOk.get(); + } + + @Override + public long getRpcError() { + return rpcError.get(); + } + @Override public void runTest(final int iterations) { int ok = 0; diff --git a/benchmark/rpcbenchmark/src/main/java/rpcbenchmark/impl/RpcbenchmarkProvider.java b/benchmark/rpcbenchmark/src/main/java/rpcbenchmark/impl/RpcbenchmarkProvider.java index 6f2e924f44..0c9a54b8e9 100644 --- a/benchmark/rpcbenchmark/src/main/java/rpcbenchmark/impl/RpcbenchmarkProvider.java +++ b/benchmark/rpcbenchmark/src/main/java/rpcbenchmark/impl/RpcbenchmarkProvider.java @@ -12,13 +12,13 @@ import static com.google.common.base.Verify.verifyNotNull; import com.google.common.util.concurrent.ListenableFuture; import java.util.ArrayList; import java.util.List; +import java.util.Set; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration; -import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; -import org.opendaylight.yang.gen.v1.rpcbench.payload.rev150702.NodeContext; +import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry; +import org.opendaylight.mdsal.binding.api.RpcProviderService; import org.opendaylight.yang.gen.v1.rpcbench.payload.rev150702.RpcbenchPayloadService; import org.opendaylight.yang.gen.v1.rpcbench.payload.rev150702.RpcbenchRpcRoutes; import org.opendaylight.yang.gen.v1.rpcbench.payload.rev150702.rpcbench.rpc.routes.RpcRoute; @@ -31,6 +31,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rpcbench import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rpcbenchmark.rev150702.TestStatusOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rpcbenchmark.rev150702.TestStatusOutput.ExecStatus; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rpcbenchmark.rev150702.TestStatusOutputBuilder; +import org.opendaylight.yangtools.concepts.ObjectRegistration; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcResult; @@ -46,10 +47,13 @@ public class RpcbenchmarkProvider implements AutoCloseable, RpcbenchmarkService private final GlobalBindingRTCServer globalServer; private final AtomicReference execStatus = new AtomicReference<>(ExecStatus.Idle); - private final RpcProviderRegistry providerRegistry; + private final RpcProviderService providerRegistry; + private final RpcConsumerRegistry consumerRegistry; - public RpcbenchmarkProvider(final RpcProviderRegistry providerRegistry, final GlobalBindingRTCServer globalServer) { + public RpcbenchmarkProvider(final RpcProviderService providerRegistry, final RpcConsumerRegistry consumerRegistry, + final GlobalBindingRTCServer globalServer) { this.providerRegistry = providerRegistry; + this.consumerRegistry = consumerRegistry; this.globalServer = globalServer; } @@ -67,30 +71,29 @@ public class RpcbenchmarkProvider implements AutoCloseable, RpcbenchmarkService LOG.debug("startTest {}", input); final RTCClient client; - final List> rpcRegs = new ArrayList<>(); + final List> rpcRegs = new ArrayList<>(); switch (input.getOperation()) { case ROUTEDRTC: List> routeIid = new ArrayList<>(); for (int i = 0; i < input.getNumServers().intValue(); i++) { GlobalBindingRTCServer server = new GlobalBindingRTCServer(); - RoutedRpcRegistration routedReg = - providerRegistry.addRoutedRpcImplementation(RpcbenchPayloadService.class, server); - KeyedInstanceIdentifier iid = - InstanceIdentifier - .create(RpcbenchRpcRoutes.class) - .child(RpcRoute.class, new RpcRouteKey(Integer.toString(i))); + InstanceIdentifier.create(RpcbenchRpcRoutes.class) + .child(RpcRoute.class, new RpcRouteKey(Integer.toString(i))); routeIid.add(iid); - routedReg.registerPath(NodeContext.class, iid); + + ObjectRegistration routedReg = providerRegistry.registerRpcImplementation( + RpcbenchPayloadService.class, server, Set.of(iid)); + rpcRegs.add(routedReg); } - client = new RoutedBindingRTClient(providerRegistry, input.getPayloadSize().intValue(), routeIid); + client = new RoutedBindingRTClient(consumerRegistry, input.getPayloadSize().intValue(), routeIid); break; case GLOBALRTC: - client = new GlobalBindingRTCClient(providerRegistry, input.getPayloadSize().intValue()); + client = new GlobalBindingRTCClient(consumerRegistry, input.getPayloadSize().intValue()); break; default: @@ -133,9 +136,7 @@ public class RpcbenchmarkProvider implements AutoCloseable, RpcbenchmarkService .build(); return RpcResultBuilder.success(output).buildFuture(); } finally { - for (RoutedRpcRegistration routedRpcRegistration : rpcRegs) { - routedRpcRegistration.close(); - } + rpcRegs.forEach(ObjectRegistration::close); } } diff --git a/benchmark/rpcbenchmark/src/main/resources/OSGI-INF/blueprint/rpcbenchmark.xml b/benchmark/rpcbenchmark/src/main/resources/OSGI-INF/blueprint/rpcbenchmark.xml index 96611d36ba..3c666e4c3f 100644 --- a/benchmark/rpcbenchmark/src/main/resources/OSGI-INF/blueprint/rpcbenchmark.xml +++ b/benchmark/rpcbenchmark/src/main/resources/OSGI-INF/blueprint/rpcbenchmark.xml @@ -12,11 +12,13 @@ - + + - + + diff --git a/docs/pom.xml b/docs/pom.xml index 022deb54b7..ef2e18bdd5 100644 --- a/docs/pom.xml +++ b/docs/pom.xml @@ -69,64 +69,6 @@ threadpool-config-impl - - - org.opendaylight.controller - sal-common-api - - - org.opendaylight.controller - sal-common-impl - - - org.opendaylight.controller - sal-common-util - - - org.opendaylight.controller - sal-core-api - - - org.opendaylight.controller - sal-core-spi - - - org.opendaylight.controller - sal-core-compat - - - org.opendaylight.controller - sal-broker-impl - - - org.opendaylight.controller - sal-binding-api - - - org.opendaylight.controller - sal-binding-broker-impl - - - org.opendaylight.controller - sal-binding-util - - - org.opendaylight.controller - sal-inmemory-datastore - - - org.opendaylight.controller - mdsal-trace-api - - - org.opendaylight.controller - mdsal-trace-dom-impl - - - org.opendaylight.controller - mdsal-trace-binding-impl - - org.opendaylight.controller.model @@ -315,18 +257,6 @@ Distributed Datastore DOM API extensions org.opendaylight.controller.cluster.dom.api - - MD-SAL Common API (deprecated) - org.opendaylight.controller.md.sal.common.* - - - MD-SAL Low-level (DOM) API (deprecated) - org.opendaylight.controller.md.sal.dom.api:org.opendaylight.controller.md.sal.dom.spi:org.opendaylight.controller.sal.core.* - - - MD-SAL Binding API (deprecated) - org.opendaylight.controller.sal.binding.api*:org.opendaylight.controller.md.sal.binding.api*:org.opendaylight.controller.md.sal.binding.spi:org.opendaylight.controller.md.sal.binding.compat:org.opendaylight.controller.md.sal.binding.util - Akka RAFT implementation org.opendaylight.controller.cluster.raft* diff --git a/features/config-netty/odl-config-netty/pom.xml b/features/config-netty/odl-config-netty/pom.xml index a45967dc66..90c22aed92 100644 --- a/features/config-netty/odl-config-netty/pom.xml +++ b/features/config-netty/odl-config-netty/pom.xml @@ -55,12 +55,6 @@ xml features - - org.opendaylight.controller - odl-controller-dom-api - xml - features - ${project.groupId} netty-event-executor-config diff --git a/features/mdsal/features-mdsal/pom.xml b/features/mdsal/features-mdsal/pom.xml index ebbf9c90c5..96a009fee2 100644 --- a/features/mdsal/features-mdsal/pom.xml +++ b/features/mdsal/features-mdsal/pom.xml @@ -43,13 +43,6 @@ xml features - - ${project.groupId} - odl-mdsal-clustering - ${project.version} - xml - features - ${project.groupId} odl-mdsal-clustering-commons @@ -64,20 +57,6 @@ xml features - - ${project.groupId} - odl-controller-binding-api - ${project.version} - xml - features - - - ${project.groupId} - odl-controller-dom-api - ${project.version} - xml - features - ${project.groupId} odl-mdsal-distributed-datastore diff --git a/features/mdsal/odl-controller-binding-api/pom.xml b/features/mdsal/odl-controller-binding-api/pom.xml deleted file mode 100644 index d4926e25d1..0000000000 --- a/features/mdsal/odl-controller-binding-api/pom.xml +++ /dev/null @@ -1,68 +0,0 @@ - - - - 4.0.0 - - - org.opendaylight.odlparent - single-feature-parent - 6.0.4 - - - - org.opendaylight.controller - odl-controller-binding-api - 1.12.0-SNAPSHOT - feature - - OpenDaylight :: Controller :: Binding API - Controller Java Binding APIs - - - - - org.opendaylight.mdsal - mdsal-artifacts - 5.0.9 - pom - import - - - ${project.groupId} - mdsal-artifacts - ${project.version} - pom - import - - - - - - - org.opendaylight.mdsal - odl-mdsal-binding-api - xml - features - - - org.opendaylight.controller - odl-controller-mdsal-common - xml - features - - - ${project.groupId} - sal-binding-api - - - ${project.groupId} - sal-binding-util - - - diff --git a/features/mdsal/odl-controller-binding-api/src/main/feature/feature.xml b/features/mdsal/odl-controller-binding-api/src/main/feature/feature.xml deleted file mode 100644 index 815e9a5100..0000000000 --- a/features/mdsal/odl-controller-binding-api/src/main/feature/feature.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - odl-mdsal-binding-api - - diff --git a/features/mdsal/odl-controller-blueprint/pom.xml b/features/mdsal/odl-controller-blueprint/pom.xml index 086eacda73..7363c3cc4d 100644 --- a/features/mdsal/odl-controller-blueprint/pom.xml +++ b/features/mdsal/odl-controller-blueprint/pom.xml @@ -38,9 +38,9 @@ import - org.opendaylight.controller + org.opendaylight.mdsal mdsal-artifacts - 1.12.0-SNAPSHOT + 5.0.9 pom import @@ -55,14 +55,20 @@ features - org.opendaylight.controller - odl-controller-binding-api + org.opendaylight.mdsal + odl-mdsal-binding-api xml features - org.opendaylight.controller - odl-controller-dom-api + org.opendaylight.mdsal + odl-mdsal-binding-runtime + xml + features + + + org.opendaylight.mdsal + odl-mdsal-dom-api xml features diff --git a/features/mdsal/odl-controller-blueprint/src/main/feature/feature.xml b/features/mdsal/odl-controller-blueprint/src/main/feature/feature.xml index 78feb3ea46..7853ff01d4 100644 --- a/features/mdsal/odl-controller-blueprint/src/main/feature/feature.xml +++ b/features/mdsal/odl-controller-blueprint/src/main/feature/feature.xml @@ -9,6 +9,9 @@ odl-yangtools-codec + odl-mdsal-binding-api + odl-mdsal-binding-runtime + odl-mdsal-dom-api mvn:org.opendaylight.controller/blueprint/${blueprint.version} diff --git a/features/mdsal/odl-controller-dom-api/pom.xml b/features/mdsal/odl-controller-dom-api/pom.xml deleted file mode 100644 index 8a396439dc..0000000000 --- a/features/mdsal/odl-controller-dom-api/pom.xml +++ /dev/null @@ -1,72 +0,0 @@ - - - - 4.0.0 - - - org.opendaylight.odlparent - single-feature-parent - 6.0.4 - - - - org.opendaylight.controller - odl-controller-dom-api - 1.12.0-SNAPSHOT - feature - - OpenDaylight :: Controller :: DOM API and SPI - Controller DOM APIs - - - - - org.opendaylight.mdsal - mdsal-artifacts - 5.0.9 - pom - import - - - ${project.groupId} - mdsal-artifacts - ${project.version} - pom - import - - - - - - - org.opendaylight.mdsal - odl-mdsal-dom-api - xml - features - - - org.opendaylight.controller - odl-controller-mdsal-common - xml - features - - - ${project.groupId} - sal-core-api - - - ${project.groupId} - sal-core-spi - - - ${project.groupId} - sal-core-compat - - - diff --git a/features/mdsal/odl-controller-dom-api/src/main/feature/feature.xml b/features/mdsal/odl-controller-dom-api/src/main/feature/feature.xml deleted file mode 100644 index b6c03f124b..0000000000 --- a/features/mdsal/odl-controller-dom-api/src/main/feature/feature.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - odl-mdsal-dom-api - - diff --git a/features/mdsal/odl-controller-mdsal-common/pom.xml b/features/mdsal/odl-controller-mdsal-common/pom.xml index 22ceb1e9ae..24b213cffc 100644 --- a/features/mdsal/odl-controller-mdsal-common/pom.xml +++ b/features/mdsal/odl-controller-mdsal-common/pom.xml @@ -48,16 +48,6 @@ xml features - - ${project.groupId} - sal-common-api - ${project.version} - - - ${project.groupId} - sal-common-impl - ${project.version} - ${project.groupId} sal-common-util diff --git a/features/mdsal/odl-mdsal-broker-local/pom.xml b/features/mdsal/odl-mdsal-broker-local/pom.xml index c31d27e38a..52be60bd37 100644 --- a/features/mdsal/odl-mdsal-broker-local/pom.xml +++ b/features/mdsal/odl-mdsal-broker-local/pom.xml @@ -99,16 +99,8 @@ - ${project.groupId} - sal-broker-impl - - - ${project.groupId} - sal-binding-broker-impl - - - ${project.groupId} - sal-inmemory-datastore + org.opendaylight.mdsal + mdsal-dom-inmemory-datastore diff --git a/features/mdsal/odl-mdsal-broker/pom.xml b/features/mdsal/odl-mdsal-broker/pom.xml index 7da55801db..c080cafedf 100644 --- a/features/mdsal/odl-mdsal-broker/pom.xml +++ b/features/mdsal/odl-mdsal-broker/pom.xml @@ -77,14 +77,5 @@ xml features - - - ${project.groupId} - sal-broker-impl - - - ${project.groupId} - sal-binding-broker-impl - diff --git a/features/mdsal/odl-mdsal-clustering/pom.xml b/features/mdsal/odl-mdsal-clustering/pom.xml deleted file mode 100644 index ae330d288b..0000000000 --- a/features/mdsal/odl-mdsal-clustering/pom.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - 4.0.0 - - - org.opendaylight.odlparent - single-feature-parent - 6.0.4 - - - - org.opendaylight.controller - odl-mdsal-clustering - 1.12.0-SNAPSHOT - feature - - - - ${project.groupId} - odl-mdsal-broker - ${project.version} - xml - features - - - - diff --git a/features/mdsal/pom.xml b/features/mdsal/pom.xml index bd6040b224..aa189ff938 100644 --- a/features/mdsal/pom.xml +++ b/features/mdsal/pom.xml @@ -26,14 +26,11 @@ odl-clustering-test-app odl-controller-mdsal-common - odl-controller-binding-api - odl-controller-dom-api odl-mdsal-clustering-commons odl-controller-blueprint odl-mdsal-broker odl-mdsal-broker-local - odl-mdsal-clustering odl-mdsal-distributed-datastore odl-mdsal-model-inventory odl-controller-model-topology diff --git a/opendaylight/blueprint/pom.xml b/opendaylight/blueprint/pom.xml index 71951100c8..8b3011f97f 100644 --- a/opendaylight/blueprint/pom.xml +++ b/opendaylight/blueprint/pom.xml @@ -63,18 +63,6 @@ org.apache.aries.util 1.1.3 - - org.opendaylight.controller - sal-binding-api - - - org.opendaylight.controller - sal-core-api - - - org.opendaylight.controller - sal-core-spi - org.opendaylight.mdsal mdsal-dom-spi diff --git a/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/OpendaylightNamespaceHandler.java b/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/OpendaylightNamespaceHandler.java index ff22f1bc30..af26acae0a 100644 --- a/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/OpendaylightNamespaceHandler.java +++ b/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/OpendaylightNamespaceHandler.java @@ -24,7 +24,6 @@ import org.apache.aries.blueprint.mutable.MutableServiceMetadata; import org.apache.aries.blueprint.mutable.MutableServiceReferenceMetadata; import org.apache.aries.blueprint.mutable.MutableValueMetadata; import org.opendaylight.controller.blueprint.BlueprintContainerRestartService; -import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; import org.opendaylight.mdsal.binding.api.NotificationService; import org.opendaylight.mdsal.binding.api.RpcProviderService; import org.opendaylight.mdsal.dom.api.DOMRpcProviderService; @@ -100,8 +99,6 @@ public final class OpendaylightNamespaceHandler implements NamespaceHandler { if (nodeNameEquals(element, RpcImplementationBean.RPC_IMPLEMENTATION)) { return parseRpcImplementation(element, context); - } else if (nodeNameEquals(element, RoutedRpcMetadata.ROUTED_RPC_IMPLEMENTATION)) { - return parseRoutedRpcImplementation(element, context); } else if (nodeNameEquals(element, RPC_SERVICE)) { return parseRpcService(element, context); } else if (nodeNameEquals(element, NotificationListenerBean.NOTIFICATION_LISTENER)) { @@ -277,18 +274,6 @@ public final class OpendaylightNamespaceHandler implements NamespaceHandler { return metadata; } - private static Metadata parseRoutedRpcImplementation(final Element element, final ParserContext context) { - registerRefBean(context, RPC_REGISTRY_NAME, RpcProviderRegistry.class); - registerRoutedRpcRegistrationConverter(context); - - ComponentFactoryMetadata metadata = new RoutedRpcMetadata(getId(context, element), - element.getAttribute(INTERFACE), element.getAttribute(REF_ATTR)); - - LOG.debug("parseRoutedRpcImplementation returning {}", metadata); - - return metadata; - } - private static Metadata parseActionService(final Element element, final ParserContext context) { ComponentFactoryMetadata metadata = new ActionServiceMetadata(getId(context, element), element.getAttribute(INTERFACE)); @@ -307,16 +292,6 @@ public final class OpendaylightNamespaceHandler implements NamespaceHandler { return metadata; } - private static void registerRoutedRpcRegistrationConverter(final ParserContext context) { - ComponentDefinitionRegistry registry = context.getComponentDefinitionRegistry(); - if (registry.getComponentDefinition(ROUTED_RPC_REG_CONVERTER_NAME) == null) { - MutableBeanMetadata metadata = createBeanMetadata(context, ROUTED_RPC_REG_CONVERTER_NAME, - RoutedRpcRegistrationConverter.class, false, false); - metadata.setActivation(ReferenceMetadata.ACTIVATION_LAZY); - registry.registerTypeConverter(metadata); - } - } - private static void registerDomRpcProviderServiceRefBean(final ParserContext context) { registerRefBean(context, DOM_RPC_PROVIDER_SERVICE_NAME, DOMRpcProviderService.class); } diff --git a/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/RoutedRpcMetadata.java b/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/RoutedRpcMetadata.java deleted file mode 100644 index 725e568785..0000000000 --- a/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/RoutedRpcMetadata.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (c) 2016 Brocade Communications Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.blueprint.ext; - -import java.util.Arrays; -import java.util.List; -import org.apache.aries.blueprint.ext.ComponentFactoryMetadata; -import org.apache.aries.blueprint.services.ExtendedBlueprintContainer; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration; -import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; -import org.opendaylight.yangtools.yang.binding.RpcService; -import org.osgi.service.blueprint.container.ComponentDefinitionException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Factory metadata corresponding to the "routed-rpc-implementation" element that registers an RPC - * implementation with the RpcProviderRegistry and provides the RoutedRpcRegistration instance to the - * Blueprint container. - * - * @author Thomas Pantelis - */ -class RoutedRpcMetadata implements ComponentFactoryMetadata { - private static final Logger LOG = LoggerFactory.getLogger(RoutedRpcMetadata.class); - static final String ROUTED_RPC_IMPLEMENTATION = "routed-rpc-implementation"; - - private final String id; - private final String interfaceName; - private final String implementationRefId; - private ExtendedBlueprintContainer container; - - RoutedRpcMetadata(final String id, final String interfaceName, final String implementationRefId) { - this.id = id; - this.interfaceName = interfaceName; - this.implementationRefId = implementationRefId; - } - - @Override - public String getId() { - return id; - } - - @Override - public int getActivation() { - return ACTIVATION_LAZY; - } - - @Override - public List getDependsOn() { - return Arrays.asList(OpendaylightNamespaceHandler.RPC_REGISTRY_NAME, implementationRefId); - } - - @Override - public void init(final ExtendedBlueprintContainer newContainer) { - this.container = newContainer; - - LOG.debug("{}: In init", logName()); - } - - @SuppressWarnings("checkstyle:IllegalCatch") - @Override - public Object create() throws ComponentDefinitionException { - RpcProviderRegistry rpcRegistry = (RpcProviderRegistry) container.getComponentInstance( - OpendaylightNamespaceHandler.RPC_REGISTRY_NAME); - - Object implementation = container.getComponentInstance(implementationRefId); - - try { - if (!RpcService.class.isAssignableFrom(implementation.getClass())) { - throw new ComponentDefinitionException(String.format( - "Implementation \"ref\" instance %s for \"%s\" is not an RpcService", - implementation.getClass(), ROUTED_RPC_IMPLEMENTATION)); - } - - List> rpcInterfaces = RpcImplementationBean.getImplementedRpcServiceInterfaces( - interfaceName, implementation.getClass(), container.getBundleContext().getBundle(), - ROUTED_RPC_IMPLEMENTATION); - - if (rpcInterfaces.size() > 1) { - throw new ComponentDefinitionException(String.format( - "Implementation \"ref\" instance %s for \"%s\" implements more than one RpcService " - + "interface (%s). Please specify the exact \"interface\"", implementation.getClass(), - ROUTED_RPC_IMPLEMENTATION, rpcInterfaces)); - } - - Class rpcInterface = rpcInterfaces.iterator().next(); - - LOG.debug("{}: create - adding routed implementation {} for RpcService {}", logName(), - implementation, rpcInterface); - - return rpcRegistry.addRoutedRpcImplementation(rpcInterface, (RpcService)implementation); - } catch (final ComponentDefinitionException e) { - throw e; - } catch (final Exception e) { - throw new ComponentDefinitionException(String.format( - "Error processing \"%s\" for %s", ROUTED_RPC_IMPLEMENTATION, implementation.getClass()), e); - } - } - - @Override - public void destroy(final Object instance) { - LOG.debug("{}: In destroy: instance: {}", logName(), instance); - - ((RoutedRpcRegistration)instance).close(); - } - - private String logName() { - return (container != null ? container.getBundleContext().getBundle().getSymbolicName() : "") + " (" + id + ")"; - } -} diff --git a/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/RoutedRpcRegistrationConverter.java b/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/RoutedRpcRegistrationConverter.java deleted file mode 100644 index 66174438b2..0000000000 --- a/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/RoutedRpcRegistrationConverter.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2016 Brocade Communications Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.blueprint.ext; - -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration; -import org.osgi.service.blueprint.container.Converter; -import org.osgi.service.blueprint.container.ReifiedType; - -/** - * Implements a Converter that converts RoutedRpcRegistration instances. This is to work around an issue - * when injecting a RoutedRpcRegistration instance into a bean where Aries is not able to convert the instance - * returned from the RpcRegistryProvider to the desired generic RoutedRpcRegistration type specified in the - * bean's setter method. This is because the actual instance class specifies a generic type variable T and, - * even though it extends RpcService and should match, Aries doesn't handle it correctly. - * - * @author Thomas Pantelis - */ -public class RoutedRpcRegistrationConverter implements Converter { - @Override - public boolean canConvert(final Object sourceObject, final ReifiedType targetType) { - return sourceObject instanceof RoutedRpcRegistration - && RoutedRpcRegistration.class.isAssignableFrom(targetType.getRawClass()); - } - - @Override - public Object convert(final Object sourceObject, final ReifiedType targetType) { - return sourceObject; - } -} diff --git a/opendaylight/blueprint/src/main/resources/opendaylight-blueprint-ext-1.0.0.xsd b/opendaylight/blueprint/src/main/resources/opendaylight-blueprint-ext-1.0.0.xsd index 9fade5f1f2..297bbb4394 100644 --- a/opendaylight/blueprint/src/main/resources/opendaylight-blueprint-ext-1.0.0.xsd +++ b/opendaylight/blueprint/src/main/resources/opendaylight-blueprint-ext-1.0.0.xsd @@ -75,17 +75,6 @@ - - - - - - - - diff --git a/opendaylight/md-sal/mdsal-artifacts/pom.xml b/opendaylight/md-sal/mdsal-artifacts/pom.xml index ad9f976a34..e89e1d1ad9 100644 --- a/opendaylight/md-sal/mdsal-artifacts/pom.xml +++ b/opendaylight/md-sal/mdsal-artifacts/pom.xml @@ -26,76 +26,11 @@ - - ${project.groupId} - sal-common-api - ${project.version} - - - ${project.groupId} - sal-common-impl - ${project.version} - ${project.groupId} sal-common-util ${project.version} - - ${project.groupId} - sal-core-api - ${project.version} - - - ${project.groupId} - sal-core-spi - ${project.version} - - - ${project.groupId} - sal-core-compat - ${project.version} - - - ${project.groupId} - sal-broker-impl - ${project.version} - - - ${project.groupId} - sal-binding-api - ${project.version} - - - ${project.groupId} - sal-binding-broker-impl - ${project.version} - - - ${project.groupId} - sal-binding-util - ${project.version} - - - ${project.groupId} - sal-inmemory-datastore - ${project.version} - - - ${project.groupId} - mdsal-trace-api - ${project.version} - - - ${project.groupId} - mdsal-trace-dom-impl - ${project.version} - - - ${project.groupId} - mdsal-trace-binding-impl - ${project.version} - @@ -110,13 +45,6 @@ ${project.version} test - - ${project.groupId} - sal-binding-broker-impl - ${project.version} - test-jar - test - @@ -135,14 +63,6 @@ xml runtime - - ${project.groupId} - features-mdsal-trace - ${project.version} - features - xml - runtime - @@ -328,13 +248,6 @@ xml features - - ${project.groupId} - odl-mdsal-clustering - ${project.version} - xml - features - ${project.groupId} odl-mdsal-clustering-commons @@ -349,20 +262,6 @@ xml features - - ${project.groupId} - odl-controller-binding-api - ${project.version} - xml - features - - - ${project.groupId} - odl-controller-dom-api - ${project.version} - xml - features - ${project.groupId} odl-controller-blueprint diff --git a/opendaylight/md-sal/mdsal-it-base/pom.xml b/opendaylight/md-sal/mdsal-it-base/pom.xml index 34a1b393f2..9754c93f9b 100644 --- a/opendaylight/md-sal/mdsal-it-base/pom.xml +++ b/opendaylight/md-sal/mdsal-it-base/pom.xml @@ -23,6 +23,13 @@ and is available at http://www.eclipse.org/legal/epl-v10.html + + org.opendaylight.mdsal + mdsal-artifacts + 5.0.9 + pom + import + org.opendaylight.controller mdsal-artifacts @@ -40,8 +47,8 @@ and is available at http://www.eclipse.org/legal/epl-v10.html zip - org.opendaylight.controller - sal-binding-api + org.opendaylight.mdsal + mdsal-binding-api diff --git a/opendaylight/md-sal/mdsal-trace/api/pom.xml b/opendaylight/md-sal/mdsal-trace/api/pom.xml deleted file mode 100644 index 6b1510f702..0000000000 --- a/opendaylight/md-sal/mdsal-trace/api/pom.xml +++ /dev/null @@ -1,56 +0,0 @@ - - - - 4.0.0 - - - org.opendaylight.controller - mdsal-parent - 1.12.0-SNAPSHOT - ../../parent - - - org.opendaylight.controller - mdsal-trace-api - 1.12.0-SNAPSHOT - bundle - - - - org.opendaylight.controller - sal-core-api - - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - attach-artifacts - - attach-artifact - - package - - - - ${project.build.directory}/classes/initial/mdsaltrace_config.xml - xml - config - - - - - - - - - diff --git a/opendaylight/md-sal/mdsal-trace/api/src/main/java/org/opendaylight/controller/md/sal/trace/api/TracingDOMDataBroker.java b/opendaylight/md-sal/mdsal-trace/api/src/main/java/org/opendaylight/controller/md/sal/trace/api/TracingDOMDataBroker.java deleted file mode 100644 index 88e2261cae..0000000000 --- a/opendaylight/md-sal/mdsal-trace/api/src/main/java/org/opendaylight/controller/md/sal/trace/api/TracingDOMDataBroker.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2016 Red Hat, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.trace.api; - -import java.io.PrintStream; -import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; - -/** - * Interface so that the tracing broker service can be more explicitly imported. - */ -public interface TracingDOMDataBroker extends DOMDataBroker { - - /** - * Prints a human-readable "report" of all opened but not closed transactions, - * including transactions chains and transactions opened by them, onto the printStream. - * @param minOpenTransactions minimum open number of transactions (leaks with fewer are not printed) - * @return true if there were any open transactions, false if none - */ - boolean printOpenTransactions(PrintStream printStream, int minOpenTransactions); - -} diff --git a/opendaylight/md-sal/mdsal-trace/api/src/main/resources/initial/mdsaltrace_config.xml b/opendaylight/md-sal/mdsal-trace/api/src/main/resources/initial/mdsaltrace_config.xml deleted file mode 100644 index 27c8bddce0..0000000000 --- a/opendaylight/md-sal/mdsal-trace/api/src/main/resources/initial/mdsaltrace_config.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - /this/will/never/exist - - - - /this/will/never/exist - - - - true - diff --git a/opendaylight/md-sal/mdsal-trace/api/src/main/yang/mdsaltrace.yang b/opendaylight/md-sal/mdsal-trace/api/src/main/yang/mdsaltrace.yang deleted file mode 100644 index 60e0d914a9..0000000000 --- a/opendaylight/md-sal/mdsal-trace/api/src/main/yang/mdsaltrace.yang +++ /dev/null @@ -1,38 +0,0 @@ -module mdsaltrace { - yang-version 1; - namespace "urn:opendaylight:params:xml:ns:yang:mdsaltrace"; - prefix "mdsaltrace"; - - organization - "Red Hat, Inc."; - - description - "Copyright (c) 2016 Red Hat, Inc. and others. All rights reserved. - - This program and the accompanying materials are made available under the - terms of the Eclipse Public License v1.0 which accompanies this distribution, - and is available at http://www.eclipse.org/legal/epl-v10.html"; - - revision "2016-09-08" { - description "Initial revision of mdsaltrace model"; - } - - container config { - leaf-list registration-watches { - type string; - } - leaf-list write-watches { - type string; - } - leaf transaction-debug-context-enabled { - default false; - type boolean; - description "Enable or disable transaction context debug. This will preserve the call site trace for - transactions, so that the original caller of un-close'd() transaction can be identified. - NB: This is a different property from the equally named one in etc/org.opendaylight.controller.cluster.datastore.cfg; - that one does something somewhat similar, but serves to include the stack trace on failed transaction submit, - whereas this one is specific to odl-mdsal-trace's trace:transaction leak troubleshooting command."; - // This ^^^ description is also copy/pasted in mdsaltrace_config.xml, and should be kept in line.] - } - } -} diff --git a/opendaylight/md-sal/mdsal-trace/binding-impl/pom.xml b/opendaylight/md-sal/mdsal-trace/binding-impl/pom.xml deleted file mode 100644 index e5b15daaef..0000000000 --- a/opendaylight/md-sal/mdsal-trace/binding-impl/pom.xml +++ /dev/null @@ -1,67 +0,0 @@ - - - - - 4.0.0 - - - org.opendaylight.controller - mdsal-parent - 1.12.0-SNAPSHOT - ../../parent - - - org.opendaylight.controller - mdsal-trace-binding-impl - 1.12.0-SNAPSHOT - bundle - - - - ${project.groupId} - mdsal-trace-api - - - ${project.groupId} - mdsal-trace-dom-impl - - - org.opendaylight.controller - sal-binding-broker-impl - - - - - org.mockito - mockito-core - test - - - - - - - org.apache.felix - maven-bundle-plugin - true - - - - org.opendaylight.controller.md.sal.trace.api, - org.opendaylight.controller.md.sal.dom.api, - org.opendaylight.controller.md.sal.binding.api, - org.opendaylight.controller.md.sal.binding.spi, - * - - - - - - - diff --git a/opendaylight/md-sal/mdsal-trace/binding-impl/src/main/java/org/opendaylight/controller/md/sal/trace/binding/impl/TracingBindingBrokerWiring.java b/opendaylight/md-sal/mdsal-trace/binding-impl/src/main/java/org/opendaylight/controller/md/sal/trace/binding/impl/TracingBindingBrokerWiring.java deleted file mode 100644 index 0876ae0f44..0000000000 --- a/opendaylight/md-sal/mdsal-trace/binding-impl/src/main/java/org/opendaylight/controller/md/sal/trace/binding/impl/TracingBindingBrokerWiring.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2018 Red Hat, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.trace.binding.impl; - -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.spi.AdapterFactory; -import org.opendaylight.controller.md.sal.trace.api.TracingDOMDataBroker; - -/** - * Programmatic "wiring" for dependency injection. - * - *

See org.opendaylight.controller.md.sal.binding.impl.BindingBrokerWiring. - * - * @author Michael Vorburger.ch - */ -public class TracingBindingBrokerWiring { - - private final DataBroker dataBroker; - private final DataBroker pingPongDataBroker; - - public TracingBindingBrokerWiring(TracingDOMDataBroker tracingDOMDataBroker, - TracingDOMDataBroker tracingPingPongDOMDataBroker, AdapterFactory adapterFactory) { - - dataBroker = adapterFactory.createDataBroker(tracingDOMDataBroker); - pingPongDataBroker = adapterFactory.createDataBroker(tracingPingPongDOMDataBroker); - } - - public DataBroker getTracingDataBroker() { - return dataBroker; - } - - public DataBroker getTracingPingPongDataBroker() { - return pingPongDataBroker; - } - -} diff --git a/opendaylight/md-sal/mdsal-trace/binding-impl/src/main/resources/OSGI-INF/blueprint/impl-blueprint.xml b/opendaylight/md-sal/mdsal-trace/binding-impl/src/main/resources/OSGI-INF/blueprint/impl-blueprint.xml deleted file mode 100644 index 30b8a99746..0000000000 --- a/opendaylight/md-sal/mdsal-trace/binding-impl/src/main/resources/OSGI-INF/blueprint/impl-blueprint.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/opendaylight/md-sal/mdsal-trace/cli/pom.xml b/opendaylight/md-sal/mdsal-trace/cli/pom.xml deleted file mode 100644 index 9dd97e63c9..0000000000 --- a/opendaylight/md-sal/mdsal-trace/cli/pom.xml +++ /dev/null @@ -1,56 +0,0 @@ - - - - 4.0.0 - - - org.opendaylight.controller - mdsal-parent - 1.12.0-SNAPSHOT - ../../parent - - - org.opendaylight.controller - mdsal-trace-cli - 1.12.0-SNAPSHOT - bundle - - - - ${project.groupId} - mdsal-trace-api - - - org.apache.karaf.shell - org.apache.karaf.shell.core - - - * - * - - - - - - - - - org.apache.felix - maven-bundle-plugin - true - - - * - - - - - - diff --git a/opendaylight/md-sal/mdsal-trace/cli/src/main/java/org/opendaylight/controller/md/sal/trace/cli/PrintOpenTransactionsCommand.java b/opendaylight/md-sal/mdsal-trace/cli/src/main/java/org/opendaylight/controller/md/sal/trace/cli/PrintOpenTransactionsCommand.java deleted file mode 100644 index 3ebd50657f..0000000000 --- a/opendaylight/md-sal/mdsal-trace/cli/src/main/java/org/opendaylight/controller/md/sal/trace/cli/PrintOpenTransactionsCommand.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2017 Red Hat, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.trace.cli; - -import java.util.List; -import org.apache.karaf.shell.api.action.Action; -import org.apache.karaf.shell.api.action.Argument; -import org.apache.karaf.shell.api.action.Command; -import org.apache.karaf.shell.api.action.lifecycle.Reference; -import org.apache.karaf.shell.api.action.lifecycle.Service; -import org.opendaylight.controller.md.sal.trace.api.TracingDOMDataBroker; - -/** - * Karaf CLI command to dump all open transactions. - * - * @author Michael Vorburger.ch - */ -@Service -@Command(scope = "trace", name = "transactions", - description = "Show all (still) open transactions; including stack trace of creator, " - + "if transaction-debug-context-enabled is true in mdsaltrace_config.xml") -public class PrintOpenTransactionsCommand implements Action { - - @Argument(index = 0, name = "minOpenTransactions", required = false, multiValued = false, - description = "Minimum open number of transactions (leaks with fewer are suppressed)") - Integer minOpenTransactions = 1; - - @Reference - private List tracingDOMDataBrokers; - - // NB: Do NOT have a non-default constructor for injection of @Reference - // Karaf needs a default constructor to create the command - and it works as is. - - @Override - @SuppressWarnings("checkstyle:RegexpSingleLineJava") - public Object execute() { - boolean hasFound = false; - for (TracingDOMDataBroker tracingDOMDataBroker : tracingDOMDataBrokers) { - hasFound |= tracingDOMDataBroker.printOpenTransactions(System.out, minOpenTransactions); - } - if (hasFound) { - System.out.println( - "Actually did find real leaks with more than " + minOpenTransactions + " open transactions"); - } else { - System.out.println( - "Did not find any real leaks with more than " + minOpenTransactions + " open transactions"); - } - return hasFound; - } - -} diff --git a/opendaylight/md-sal/mdsal-trace/deploy-site.xml b/opendaylight/md-sal/mdsal-trace/deploy-site.xml deleted file mode 100644 index 6a7256400a..0000000000 --- a/opendaylight/md-sal/mdsal-trace/deploy-site.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - - - 4.0.0 - - org.opendaylight.mdsal - deploy-site - 0.1.0-SNAPSHOT - pom - - - latest - dav:https://nexus.opendaylight.org/content/sites/site/${project.groupId}/${stream}/ - - - - - - org.apache.maven.wagon - wagon-webdav-jackrabbit - 2.9 - - - - - - org.apache.maven.plugins - maven-site-plugin - 3.4 - - ${project.build.directory}/staged-site - - - - - - - - opendaylight-site - ${nexus.site.url} - - - diff --git a/opendaylight/md-sal/mdsal-trace/dom-impl/pom.xml b/opendaylight/md-sal/mdsal-trace/dom-impl/pom.xml deleted file mode 100644 index adbc95f763..0000000000 --- a/opendaylight/md-sal/mdsal-trace/dom-impl/pom.xml +++ /dev/null @@ -1,89 +0,0 @@ - - - - - 4.0.0 - - - org.opendaylight.controller - mdsal-parent - 1.12.0-SNAPSHOT - ../../parent - - - org.opendaylight.controller - mdsal-trace-dom-impl - 1.12.0-SNAPSHOT - bundle - - - - ${project.groupId} - mdsal-trace-api - - - ${project.groupId} - sal-binding-api - - - ${project.groupId} - sal-core-api - - - ${project.groupId} - sal-broker-impl - - - org.opendaylight.mdsal - mdsal-binding-dom-codec - - - - - ${project.groupId} - sal-binding-broker-impl - ${project.version} - tests - test - - - ${project.groupId} - sal-binding-broker-impl - test - - - org.mockito - mockito-core - test - - - com.google.truth - truth - test - - - - - - org.apache.felix - maven-bundle-plugin - true - - - - org.opendaylight.controller.md.sal.dom.broker.impl, - * - - org.opendaylight.controller.md.sal.trace.dom.impl - - - - - - diff --git a/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/closetracker/impl/AbstractCloseTracked.java b/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/closetracker/impl/AbstractCloseTracked.java deleted file mode 100644 index 9ab4d4965f..0000000000 --- a/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/closetracker/impl/AbstractCloseTracked.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2017 Red Hat, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.trace.closetracker.impl; - -import org.eclipse.jdt.annotation.Nullable; - -/** - * Convenience abstract base class for {@link CloseTracked} implementors. - * - * @author Michael Vorburger.ch - */ -@Deprecated(forRemoval = true) -public abstract class AbstractCloseTracked> implements CloseTracked { - - private final CloseTrackedTrait closeTracker; - - protected AbstractCloseTracked(CloseTrackedRegistry transactionChainRegistry) { - this.closeTracker = new CloseTrackedTrait<>(transactionChainRegistry, this); - } - - protected void removeFromTrackedRegistry() { - closeTracker.removeFromTrackedRegistry(); - } - - @Override - public @Nullable StackTraceElement[] getAllocationContextStackTrace() { - return closeTracker.getAllocationContextStackTrace(); - } - - @Override - public final CloseTracked getRealCloseTracked() { - return this; - } -} diff --git a/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/closetracker/impl/CloseTracked.java b/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/closetracker/impl/CloseTracked.java deleted file mode 100644 index 1787ba0ceb..0000000000 --- a/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/closetracker/impl/CloseTracked.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2017 Red Hat, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.trace.closetracker.impl; - -import org.eclipse.jdt.annotation.Nullable; - -/** - * Object which can track where something has been created, and if it has been correctly "closed". - * - *

Includes preserving the context of the call stack which created an object, and the instant it was created. - * - * @author Michael Vorburger.ch - */ -@Deprecated(forRemoval = true) -public interface CloseTracked> { - - /** - * This returns the allocation context as {@link StackTraceElement}s. NB that - * this is a relatively EXPENSIVE operation! You should only ever call - * this when you really need to, e.g. when you actually produce output for - * humans, but not too early. - */ - // TODO When we're on Java 9, then instead return a StackWalker.StackFrame[] here? - @Nullable StackTraceElement[] getAllocationContextStackTrace(); - - CloseTracked getRealCloseTracked(); -} diff --git a/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/closetracker/impl/CloseTrackedRegistry.java b/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/closetracker/impl/CloseTrackedRegistry.java deleted file mode 100644 index 5c9ae3e9bf..0000000000 --- a/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/closetracker/impl/CloseTrackedRegistry.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (c) 2017 Red Hat, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.trace.closetracker.impl; - -import static java.util.Arrays.asList; -import static java.util.Collections.emptyList; - -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; -import java.util.Arrays; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ConcurrentSkipListSet; - -/** - * Registry of {@link CloseTracked} instances. This class is thread-safe. - * - * @author Michael Vorburger.ch - */ -@Deprecated(forRemoval = true) -public class CloseTrackedRegistry> { - - private final Object anchor; - private final String createDescription; - - private final Set> tracked = - new ConcurrentSkipListSet<>(Comparator.comparingInt(System::identityHashCode)); - - private final boolean isDebugContextEnabled; - - /** - * Constructor. - * - * @param anchor - * object where this registry is stored in, used for human output in - * logging and other output - * @param createDescription - * description of creator of instances of this registry, typically - * e.g. name of method in the anchor class - * @param isDebugContextEnabled - * whether or not the call stack should be preserved; this is (of - * course) an expensive operation, and should only be used during - * troubleshooting - */ - public CloseTrackedRegistry(Object anchor, String createDescription, boolean isDebugContextEnabled) { - this.anchor = anchor; - this.createDescription = createDescription; - this.isDebugContextEnabled = isDebugContextEnabled; - } - - public boolean isDebugContextEnabled() { - return isDebugContextEnabled; - } - - public Object getAnchor() { - return anchor; - } - - public String getCreateDescription() { - return createDescription; - } - - // package protected, not public; only CloseTrackedTrait invokes this - void add(CloseTracked closeTracked) { - tracked.add(closeTracked); - } - - // package protected, not public; only CloseTrackedTrait invokes this - void remove(CloseTracked closeTracked) { - tracked.remove(closeTracked); - } - - /** - * Creates and returns a "report" of (currently) tracked but not (yet) closed - * instances. - * - * @return Set of CloseTrackedRegistryReportEntry, of which each the stack trace - * element identifies a unique allocation context (or an empty List if - * debugContextEnabled is false), and value is the number of open - * instances created at that place in the code. - */ - // For some reason, FB sees 'map' as useless but it clearly isn't. - @SuppressFBWarnings("UC_USELESS_OBJECT") - public Set> getAllUnique() { - Map, Long> map = new HashMap<>(); - Set> copyOfTracked = new HashSet<>(tracked); - for (CloseTracked closeTracked : copyOfTracked) { - final StackTraceElement[] stackTraceArray = closeTracked.getAllocationContextStackTrace(); - List stackTraceElements = - stackTraceArray != null ? Arrays.asList(stackTraceArray) : Collections.emptyList(); - map.merge(stackTraceElements, 1L, (oldValue, value) -> oldValue + 1); - } - - Set> report = new HashSet<>(); - map.forEach((stackTraceElements, number) -> copyOfTracked.stream().filter(closeTracked -> { - StackTraceElement[] closeTrackedStackTraceArray = closeTracked.getAllocationContextStackTrace(); - List closeTrackedStackTraceElements = - closeTrackedStackTraceArray != null ? asList(closeTrackedStackTraceArray) : emptyList(); - return closeTrackedStackTraceElements.equals(stackTraceElements); - }).findAny().ifPresent(exampleCloseTracked -> report.add( - new CloseTrackedRegistryReportEntry<>(exampleCloseTracked, number, stackTraceElements)))); - return report; - } - -} diff --git a/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/closetracker/impl/CloseTrackedRegistryReportEntry.java b/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/closetracker/impl/CloseTrackedRegistryReportEntry.java deleted file mode 100644 index 19070beba8..0000000000 --- a/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/closetracker/impl/CloseTrackedRegistryReportEntry.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2017 Red Hat, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.trace.closetracker.impl; - -import static java.util.Objects.requireNonNull; - -import java.util.List; - -/** - * Element of a "report" created by a {@link CloseTrackedRegistry}. - * - * @author Michael Vorburger.ch - */ -@Deprecated(forRemoval = true) -public class CloseTrackedRegistryReportEntry> { - - private final CloseTracked exampleCloseTracked; - private final long numberAddedNotRemoved; - private final List stackTraceElements; - - public CloseTrackedRegistryReportEntry(CloseTracked exampleCloseTracked, long numberAddedNotRemoved, - List stackTraceElements) { - this.exampleCloseTracked = requireNonNull(exampleCloseTracked, "closeTracked"); - this.numberAddedNotRemoved = requireNonNull(numberAddedNotRemoved, "numberAddedNotRemoved"); - this.stackTraceElements = requireNonNull(stackTraceElements, "stackTraceElements"); - } - - public long getNumberAddedNotRemoved() { - return numberAddedNotRemoved; - } - - public CloseTracked getExampleCloseTracked() { - return exampleCloseTracked; - } - - public List getStackTraceElements() { - return stackTraceElements; - } - - @Override - public String toString() { - return "CloseTrackedRegistryReportEntry [numberAddedNotRemoved=" + numberAddedNotRemoved + ", closeTracked=" - + exampleCloseTracked + ", stackTraceElements.size=" + stackTraceElements.size() + "]"; - } - - -} diff --git a/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/closetracker/impl/CloseTrackedTrait.java b/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/closetracker/impl/CloseTrackedTrait.java deleted file mode 100644 index 809cdc4f5b..0000000000 --- a/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/closetracker/impl/CloseTrackedTrait.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2017 Red Hat, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.trace.closetracker.impl; - -import static java.util.Objects.requireNonNull; - -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; -import org.eclipse.jdt.annotation.Nullable; - -/** - * Implementation of {@link CloseTracked} which can be used as a field in - * another class which implements {@link CloseTracked} and delegates its methods - * to this. - * - *

This is useful if that class already has another parent class. - * If it does not, then it's typically more convenient to just extend AbstractCloseTracked. - * - * @author Michael Vorburger.ch - */ -@Deprecated(forRemoval = true) -public class CloseTrackedTrait> implements CloseTracked { - - // NB: It's important that we keep a Throwable here, and not directly the StackTraceElement[] ! - // This is because creating a new Throwable() is a lot less expensive in terms of runtime overhead - // than actually calling its getStackTrace(), which we can delay until we really need to. - // see also e.g. https://stackoverflow.com/a/26122232/421602 - private final @Nullable Throwable allocationContext; - private final CloseTrackedRegistry closeTrackedRegistry; - private final CloseTracked realCloseTracked; - - @SuppressFBWarnings(value = "NP_STORE_INTO_NONNULL_FIELD", justification = "SpotBugs and JDT annotations") - public CloseTrackedTrait(CloseTrackedRegistry transactionChainRegistry, CloseTracked realCloseTracked) { - if (transactionChainRegistry.isDebugContextEnabled()) { - // NB: We're NOT doing the (expensive) getStackTrace() here just yet (only below) - // TODO When we're on Java 9, then instead use the new java.lang.StackWalker API.. - this.allocationContext = new Throwable(); - } else { - this.allocationContext = null; - } - this.realCloseTracked = requireNonNull(realCloseTracked, "realCloseTracked"); - this.closeTrackedRegistry = requireNonNull(transactionChainRegistry, "transactionChainRegistry"); - this.closeTrackedRegistry.add(this); - } - - @Override - @SuppressFBWarnings("PZLA_PREFER_ZERO_LENGTH_ARRAYS") - public StackTraceElement[] getAllocationContextStackTrace() { - return allocationContext != null ? allocationContext.getStackTrace() : null; - } - - public void removeFromTrackedRegistry() { - closeTrackedRegistry.remove(this); - } - - @Override - public CloseTracked getRealCloseTracked() { - return realCloseTracked; - } - -} diff --git a/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/closetracker/impl/package-info.java b/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/closetracker/impl/package-info.java deleted file mode 100644 index c0360c05c4..0000000000 --- a/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/closetracker/impl/package-info.java +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright (c) 2017 Red Hat, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -/** - * Utilities to track (non) "closing" of objects. - */ -// This generic infra may be moved somewhere else, later -@org.eclipse.jdt.annotation.NonNullByDefault -@Deprecated(forRemoval = true) -package org.opendaylight.controller.md.sal.trace.closetracker.impl; diff --git a/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/dom/impl/AbstractTracingWriteTransaction.java b/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/dom/impl/AbstractTracingWriteTransaction.java deleted file mode 100644 index 9064baa36a..0000000000 --- a/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/dom/impl/AbstractTracingWriteTransaction.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright (c) 2016 Red Hat, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.trace.dom.impl; - -import static java.util.Objects.requireNonNull; - -import com.google.common.collect.ImmutableSet; -import com.google.common.util.concurrent.FluentFuture; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction; -import org.opendaylight.mdsal.common.api.CommitInfo; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; - -@Deprecated(forRemoval = true) -abstract class AbstractTracingWriteTransaction implements DOMDataWriteTransaction { - - private final DOMDataWriteTransaction delegate; - private final TracingBroker tracingBroker; - private final List logs = new ArrayList<>(); - - AbstractTracingWriteTransaction(DOMDataWriteTransaction delegate, TracingBroker tracingBroker) { - this.delegate = requireNonNull(delegate); - this.tracingBroker = requireNonNull(tracingBroker); - recordOp(null, null, "instantiate", null); - } - - private void recordOp(LogicalDatastoreType store, YangInstanceIdentifier yiid, String method, - NormalizedNode node) { - if (yiid != null && !tracingBroker.isWriteWatched(yiid, store)) { - return; - } - - final Object value = node != null ? node.getValue() : null; - - if (value != null && value instanceof ImmutableSet && ((Set)value).isEmpty()) { - if (TracingBroker.LOG.isDebugEnabled()) { - TracingBroker.LOG.debug("Empty data set write to {}", tracingBroker.toPathString(yiid)); - } - } else { - StringBuilder sb = new StringBuilder(); - sb.append("Method \"").append(method).append('"'); - if (store != null) { - sb.append(" to ").append(store); - } - if (yiid != null) { - sb.append(" at ").append(tracingBroker.toPathString(yiid)); - } - sb.append('.'); - if (yiid != null) { - // If we don’t have an id, we don’t expect data either - sb.append(" Data: "); - if (node != null) { - sb.append(node.getValue()); - } else { - sb.append("null"); - } - } - sb.append(" Stack:").append(tracingBroker.getStackSummary()); - synchronized (this) { - logs.add(sb.toString()); - } - } - } - - private synchronized void logOps() { - synchronized (this) { - if (TracingBroker.LOG.isWarnEnabled()) { - TracingBroker.LOG.warn("Transaction {} contains the following operations:", getIdentifier()); - logs.forEach(TracingBroker.LOG::warn); - } - logs.clear(); - } - } - - @Override - public void put(LogicalDatastoreType store, YangInstanceIdentifier yiid, NormalizedNode node) { - recordOp(store, yiid, "put", node); - delegate.put(store, yiid, node); - } - - @Override - public void merge(LogicalDatastoreType store, YangInstanceIdentifier yiid, NormalizedNode node) { - recordOp(store, yiid, "merge", node); - delegate.merge(store, yiid, node); - } - - @Override - public boolean cancel() { - synchronized (this) { - logs.clear(); - } - return delegate.cancel(); - } - - @Override - public void delete(LogicalDatastoreType store, YangInstanceIdentifier yiid) { - recordOp(store, yiid, "delete", null); - delegate.delete(store, yiid); - } - - @Override - public FluentFuture commit() { - recordOp(null, null, "commit", null); - logOps(); - return delegate.commit(); - } - - @Override - public Object getIdentifier() { - return delegate.getIdentifier(); - } - - // https://jira.opendaylight.org/browse/CONTROLLER-1792 - - @Override - public final boolean equals(Object object) { - return object == this || delegate.equals(object); - } - - @Override - public final int hashCode() { - return delegate.hashCode(); - } - - @Override - public final String toString() { - return getClass().getName() + "; delegate=" + delegate; - } -} diff --git a/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/dom/impl/TracingBroker.java b/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/dom/impl/TracingBroker.java deleted file mode 100644 index 45e9c6503b..0000000000 --- a/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/dom/impl/TracingBroker.java +++ /dev/null @@ -1,444 +0,0 @@ -/* - * Copyright (c) 2016 Red Hat, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.trace.dom.impl; - -import static java.util.Objects.requireNonNull; - -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; -import java.io.PrintStream; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener; -import org.opendaylight.controller.md.sal.dom.api.ClusteredDOMDataTreeChangeListener; -import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; -import org.opendaylight.controller.md.sal.dom.api.DOMDataBrokerExtension; -import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction; -import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction; -import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener; -import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeService; -import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeIdentifier; -import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction; -import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain; -import org.opendaylight.controller.md.sal.trace.api.TracingDOMDataBroker; -import org.opendaylight.controller.md.sal.trace.closetracker.impl.CloseTracked; -import org.opendaylight.controller.md.sal.trace.closetracker.impl.CloseTrackedRegistry; -import org.opendaylight.controller.md.sal.trace.closetracker.impl.CloseTrackedRegistryReportEntry; -import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsaltrace.rev160908.Config; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@SuppressWarnings("checkstyle:JavadocStyle") -//...because otherwise it whines about the elements in the @code block even though it's completely valid Javadoc - -/** - * TracingBroker logs "write" operations and listener registrations to the md-sal. It logs the instance identifier path, - * the objects themselves, as well as the stack trace of the call invoking the registration or write operation. - * It works by operating as a "bump on the stack" between the application and actual DataBroker, intercepting write - * and registration calls and writing to the log. - * - *

In addition, it (optionally) can also keep track of the stack trace of all new transaction allocations - * (including TransactionChains, and transactions created in turn from them), in order to detect and report leaks - * from transactions which were not closed. - * - *

Wiring:

- * TracingBroker is designed to be easy to use. In fact, for bundles using Blueprint to inject their DataBroker - * TracingBroker can be used without modifying your code at all in two simple steps: - *
    - *
  1. - * Simply add the dependency "mdsaltrace-features" to - * your Karaf pom: - *
    - * {@code
    - *  
    - *    org.opendaylight.controller
    - *    features-mdsal-trace
    - *    1.7.0-SNAPSHOT
    - *    features
    - *    xml
    - *    runtime
    - *  
    - * }
    - * 
    - *
  2. - *
  3. - * Then just "feature:install odl-mdsal-trace" before you install your "real" feature(s) and you're done. - * Beware that with Karaf 4 due to Bug 9068 - * you'll probably have to use feature:install's --no-auto-refresh flag when installing your "real" feature. - *
  4. - *
- * This works because the mdsaltrace-impl bundle registers its service implementing DOMDataBroker with a higher - * rank than sal-binding-broker. As such, any OSGi service lookup for DataBroker will receive the TracingBroker. - *

- *

Avoiding log bloat:

- * TracingBroker can be configured to only print registrations or write ops pertaining to certain subtrees of the - * md-sal. This can be done in the code via the methods of this class or via a config file. TracingBroker uses a more - * convenient but non-standard representation of the instance identifiers. Each instance identifier segment's - * class.getSimpleName() is used separated by a '/'. - *

- *

Known issues

- *
    - *
  • - * Filtering by paths. For some registrations the codec that converts back from the DOM to binding paths is - * busted. As such, an aproximated path is used in the output. For now it is recommended not to use - * watchRegistrations and allow all registrations to be logged. - *
  • - *
- * - */ -@Deprecated(forRemoval = true) -public class TracingBroker implements TracingDOMDataBroker { - @SuppressFBWarnings("SLF4J_LOGGER_SHOULD_BE_PRIVATE") - static final Logger LOG = LoggerFactory.getLogger(TracingBroker.class); - - private static final int STACK_TRACE_FIRST_RELEVANT_FRAME = 2; - - private final String type; // "default" VS "pingpong" - private final BindingNormalizedNodeSerializer codec; - private final DOMDataBroker delegate; - private final List registrationWatches = new ArrayList<>(); - private final List writeWatches = new ArrayList<>(); - - private final boolean isDebugging; - private final CloseTrackedRegistry transactionChainsRegistry; - private final CloseTrackedRegistry readOnlyTransactionsRegistry; - private final CloseTrackedRegistry writeTransactionsRegistry; - private final CloseTrackedRegistry readWriteTransactionsRegistry; - - private class Watch { - final String iidString; - final LogicalDatastoreType store; - - Watch(String iidString, LogicalDatastoreType storeOrNull) { - this.store = storeOrNull; - this.iidString = iidString; - } - - private String toIidCompString(YangInstanceIdentifier iid) { - StringBuilder builder = new StringBuilder(); - toPathString(iid, builder); - builder.append('/'); - return builder.toString(); - } - - private boolean isParent(String parent, String child) { - int parentOffset = 0; - if (parent.length() > 0 && parent.charAt(0) == '<') { - parentOffset = parent.indexOf('>') + 1; - } - - int childOffset = 0; - if (child.length() > 0 && child.charAt(0) == '<') { - childOffset = child.indexOf('>') + 1; - } - - return child.startsWith(parent.substring(parentOffset), childOffset); - } - - @SuppressWarnings({ "checkstyle:hiddenField", "hiding" }) - public boolean subtreesOverlap(YangInstanceIdentifier iid, LogicalDatastoreType store) { - if (this.store != null && !this.store.equals(store)) { - return false; - } - - String otherIidString = toIidCompString(iid); - return isParent(iidString, otherIidString) || isParent(otherIidString, iidString); - } - - @SuppressWarnings({ "checkstyle:hiddenField", "hiding" }) - public boolean eventIsOfInterest(YangInstanceIdentifier iid, LogicalDatastoreType store) { - if (this.store != null && !this.store.equals(store)) { - return false; - } - - return isParent(iidString, toPathString(iid)); - } - } - - public TracingBroker(String type, DOMDataBroker delegate, Config config, BindingNormalizedNodeSerializer codec) { - this.type = requireNonNull(type, "type"); - this.delegate = requireNonNull(delegate, "delegate"); - this.codec = requireNonNull(codec, "codec"); - configure(config); - - if (config.isTransactionDebugContextEnabled() != null) { - this.isDebugging = config.isTransactionDebugContextEnabled(); - } else { - this.isDebugging = false; - } - final String db = "DataBroker"; - this.transactionChainsRegistry = new CloseTrackedRegistry<>(db, "createTransactionChain()", isDebugging); - this.readOnlyTransactionsRegistry = new CloseTrackedRegistry<>(db, "newReadOnlyTransaction()", isDebugging); - this.writeTransactionsRegistry = new CloseTrackedRegistry<>(db, "newWriteOnlyTransaction()", isDebugging); - this.readWriteTransactionsRegistry = new CloseTrackedRegistry<>(db, "newReadWriteTransaction()", isDebugging); - } - - private void configure(Config config) { - registrationWatches.clear(); - List paths = config.getRegistrationWatches(); - if (paths != null) { - for (String path : paths) { - watchRegistrations(path, null); - } - } - - writeWatches.clear(); - paths = config.getWriteWatches(); - if (paths != null) { - for (String path : paths) { - watchWrites(path, null); - } - } - } - - /** - * Log registrations to this subtree of the md-sal. - * @param iidString the iid path of the root of the subtree - * @param store Which LogicalDataStore? or null for both - */ - public void watchRegistrations(String iidString, LogicalDatastoreType store) { - LOG.info("Watching registrations to {} in {}", iidString, store); - registrationWatches.add(new Watch(iidString, store)); - } - - /** - * Log writes to this subtree of the md-sal. - * @param iidString the iid path of the root of the subtree - * @param store Which LogicalDataStore? or null for both - */ - public void watchWrites(String iidString, LogicalDatastoreType store) { - LOG.info("Watching writes to {} in {}", iidString, store); - Watch watch = new Watch(iidString, store); - writeWatches.add(watch); - } - - @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", - justification = "https://github.com/spotbugs/spotbugs/issues/811") - private boolean isRegistrationWatched(YangInstanceIdentifier iid, LogicalDatastoreType store) { - if (registrationWatches.isEmpty()) { - return true; - } - - for (Watch regInterest : registrationWatches) { - if (regInterest.subtreesOverlap(iid, store)) { - return true; - } - } - - return false; - } - - boolean isWriteWatched(YangInstanceIdentifier iid, LogicalDatastoreType store) { - if (writeWatches.isEmpty()) { - return true; - } - - for (Watch watch : writeWatches) { - if (watch.eventIsOfInterest(iid, store)) { - return true; - } - } - - return false; - } - - static void toPathString(InstanceIdentifier iid, StringBuilder builder) { - for (InstanceIdentifier.PathArgument pathArg : iid.getPathArguments()) { - builder.append('/').append(pathArg.getType().getSimpleName()); - } - } - - String toPathString(YangInstanceIdentifier yiid) { - StringBuilder sb = new StringBuilder(); - toPathString(yiid, sb); - return sb.toString(); - } - - - private void toPathString(YangInstanceIdentifier yiid, StringBuilder sb) { - InstanceIdentifier iid = codec.fromYangInstanceIdentifier(yiid); - if (null == iid) { - reconstructIidPathString(yiid, sb); - } else { - toPathString(iid, sb); - } - } - - private static void reconstructIidPathString(YangInstanceIdentifier yiid, StringBuilder sb) { - sb.append(""); - for (YangInstanceIdentifier.PathArgument pathArg : yiid.getPathArguments()) { - if (pathArg instanceof YangInstanceIdentifier.AugmentationIdentifier) { - sb.append('/').append("AUGMENTATION"); - continue; - } - sb.append('/').append(pathArg.getNodeType().getLocalName()); - } - } - - String getStackSummary() { - StackTraceElement[] stack = Thread.currentThread().getStackTrace(); - - StringBuilder sb = new StringBuilder(); - for (int i = STACK_TRACE_FIRST_RELEVANT_FRAME; i < stack.length; i++) { - StackTraceElement frame = stack[i]; - sb.append("\n\t(TracingBroker)\t").append(frame.getClassName()).append('.').append(frame.getMethodName()); - } - - return sb.toString(); - } - - @Override - public DOMDataReadWriteTransaction newReadWriteTransaction() { - return new TracingReadWriteTransaction(delegate.newReadWriteTransaction(), this, readWriteTransactionsRegistry); - } - - @Override - public DOMDataWriteTransaction newWriteOnlyTransaction() { - return new TracingWriteTransaction(delegate.newWriteOnlyTransaction(), this, writeTransactionsRegistry); - } - - @Override - public DOMTransactionChain createTransactionChain(TransactionChainListener transactionChainListener) { - return new TracingTransactionChain( - delegate.createTransactionChain(transactionChainListener), this, transactionChainsRegistry); - } - - @Override - public DOMDataReadOnlyTransaction newReadOnlyTransaction() { - return new TracingReadOnlyTransaction(delegate.newReadOnlyTransaction(), readOnlyTransactionsRegistry); - } - - @Override - public Map, DOMDataBrokerExtension> getSupportedExtensions() { - Map, DOMDataBrokerExtension> res = delegate.getSupportedExtensions(); - DOMDataTreeChangeService treeChangeSvc = (DOMDataTreeChangeService) res.get(DOMDataTreeChangeService.class); - if (treeChangeSvc == null) { - return res; - } - - res = new HashMap<>(res); - - res.put(DOMDataTreeChangeService.class, new DOMDataTreeChangeService() { - @Override - public ListenerRegistration registerDataTreeChangeListener( - DOMDataTreeIdentifier domDataTreeIdentifier, L listener) { - if (isRegistrationWatched(domDataTreeIdentifier.getRootIdentifier(), - domDataTreeIdentifier.getDatastoreType())) { - LOG.warn("{} registration (registerDataTreeChangeListener) for {} from {}.", - listener instanceof ClusteredDOMDataTreeChangeListener ? "Clustered" : "Non-clustered", - toPathString(domDataTreeIdentifier.getRootIdentifier()), getStackSummary()); - } - return treeChangeSvc.registerDataTreeChangeListener(domDataTreeIdentifier, listener); - } - }); - - return res; - } - - @Override - public boolean printOpenTransactions(PrintStream ps, int minOpenTXs) { - if (transactionChainsRegistry.getAllUnique().isEmpty() - && readOnlyTransactionsRegistry.getAllUnique().isEmpty() - && writeTransactionsRegistry.getAllUnique().isEmpty() - && readWriteTransactionsRegistry.getAllUnique().isEmpty()) { - - ps.println(type + ": No open transactions, great!"); - return false; - } - - ps.println(type + ": " + getClass().getSimpleName() - + " found some not yet (or never..) closed transaction[chain]s!"); - ps.println("[NB: If no stack traces are shown below, then " - + "enable transaction-debug-context-enabled in mdsaltrace_config.xml]"); - ps.println(); - // Flag to track if we really found any real leaks with more (or equal) to minOpenTXs - boolean hasFound = print(readOnlyTransactionsRegistry, ps, " ", minOpenTXs); - hasFound |= print(writeTransactionsRegistry, ps, " ", minOpenTXs); - hasFound |= print(readWriteTransactionsRegistry, ps, " ", minOpenTXs); - - // Now print details for each non-closed TransactionChain - // incl. in turn each ones own read/Write[Only]TransactionsRegistry - Set> - entries = transactionChainsRegistry.getAllUnique(); - if (!entries.isEmpty()) { - ps.println(" " + transactionChainsRegistry.getAnchor() + " : " - + transactionChainsRegistry.getCreateDescription()); - } - for (CloseTrackedRegistryReportEntry entry : entries) { - ps.println(" " + entry.getNumberAddedNotRemoved() + "x TransactionChains opened but not closed here:"); - printStackTraceElements(ps, " ", entry.getStackTraceElements()); - @SuppressWarnings("resource") - TracingTransactionChain txChain = (TracingTransactionChain) entry - .getExampleCloseTracked().getRealCloseTracked(); - hasFound |= print(txChain.getReadOnlyTransactionsRegistry(), ps, " ", minOpenTXs); - hasFound |= print(txChain.getWriteTransactionsRegistry(), ps, " ", minOpenTXs); - hasFound |= print(txChain.getReadWriteTransactionsRegistry(), ps, " ", minOpenTXs); - } - ps.println(); - - return hasFound; - } - - private > boolean print( - CloseTrackedRegistry registry, PrintStream ps, String indent, int minOpenTransactions) { - Set> unsorted = registry.getAllUnique(); - if (unsorted.size() < minOpenTransactions) { - return false; - } - - List> entries = new ArrayList<>(unsorted); - entries.sort((o1, o2) -> Long.compare(o2.getNumberAddedNotRemoved(), o1.getNumberAddedNotRemoved())); - - if (!entries.isEmpty()) { - ps.println(indent + registry.getAnchor() + " : " + registry.getCreateDescription()); - } - entries.forEach(entry -> { - ps.println(indent + " " + entry.getNumberAddedNotRemoved() - + "x transactions opened here, which are not closed:"); - printStackTraceElements(ps, indent + " ", entry.getStackTraceElements()); - }); - if (!entries.isEmpty()) { - ps.println(); - } - return true; - } - - private void printStackTraceElements(PrintStream ps, String indent, List stackTraceElements) { - boolean ellipsis = false; - for (final StackTraceElement stackTraceElement : stackTraceElements) { - if (isStackTraceElementInteresting(stackTraceElement)) { - ps.println(indent + stackTraceElement); - ellipsis = false; - } else if (!ellipsis) { - ps.println(indent + "(...)"); - ellipsis = true; - } - } - } - - private boolean isStackTraceElementInteresting(StackTraceElement element) { - final String className = element.getClassName(); - return !className.startsWith(getClass().getPackage().getName()) - && !className.startsWith(CloseTracked.class.getPackage().getName()) - && !className.startsWith("Proxy") - && !className.startsWith("akka") - && !className.startsWith("scala") - && !className.startsWith("sun.reflect") - && !className.startsWith("java.lang.reflect") - && !className.startsWith("org.apache.aries.blueprint") - && !className.startsWith("org.osgi.util.tracker"); - } -} diff --git a/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/dom/impl/TracingReadOnlyTransaction.java b/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/dom/impl/TracingReadOnlyTransaction.java deleted file mode 100644 index 3b6a1eb00d..0000000000 --- a/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/dom/impl/TracingReadOnlyTransaction.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2017 Red Hat, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.trace.dom.impl; - -import com.google.common.base.Optional; -import com.google.common.util.concurrent.CheckedFuture; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; -import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction; -import org.opendaylight.controller.md.sal.trace.closetracker.impl.AbstractCloseTracked; -import org.opendaylight.controller.md.sal.trace.closetracker.impl.CloseTrackedRegistry; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; - -@Deprecated(forRemoval = true) -class TracingReadOnlyTransaction - extends AbstractCloseTracked - implements DOMDataReadOnlyTransaction { - - private final DOMDataReadOnlyTransaction delegate; - - TracingReadOnlyTransaction(DOMDataReadOnlyTransaction delegate, - CloseTrackedRegistry readOnlyTransactionsRegistry) { - super(readOnlyTransactionsRegistry); - this.delegate = delegate; - } - - @Override - public CheckedFuture>, ReadFailedException> read(LogicalDatastoreType store, - YangInstanceIdentifier path) { - return delegate.read(store, path); - } - - @Override - public CheckedFuture exists(LogicalDatastoreType store, YangInstanceIdentifier path) { - return delegate.exists(store, path); - } - - @Override - public Object getIdentifier() { - return delegate.getIdentifier(); - } - - @Override - public void close() { - delegate.close(); - super.removeFromTrackedRegistry(); - } - - - // https://jira.opendaylight.org/browse/CONTROLLER-1792 - - @Override - public final boolean equals(Object object) { - return object == this || delegate.equals(object); - } - - @Override - public final int hashCode() { - return delegate.hashCode(); - } - - @Override - public final String toString() { - return getClass().getName() + "; delegate=" + delegate; - } - -} diff --git a/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/dom/impl/TracingReadWriteTransaction.java b/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/dom/impl/TracingReadWriteTransaction.java deleted file mode 100644 index ae331cb396..0000000000 --- a/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/dom/impl/TracingReadWriteTransaction.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2016 Red Hat, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.trace.dom.impl; - -import com.google.common.base.Optional; -import com.google.common.util.concurrent.CheckedFuture; -import com.google.common.util.concurrent.FluentFuture; -import java.util.Objects; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; -import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction; -import org.opendaylight.controller.md.sal.trace.closetracker.impl.CloseTracked; -import org.opendaylight.controller.md.sal.trace.closetracker.impl.CloseTrackedRegistry; -import org.opendaylight.controller.md.sal.trace.closetracker.impl.CloseTrackedTrait; -import org.opendaylight.mdsal.common.api.CommitInfo; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; - -@Deprecated(forRemoval = true) -class TracingReadWriteTransaction - extends AbstractTracingWriteTransaction - implements DOMDataReadWriteTransaction, CloseTracked { - - private final CloseTrackedTrait closeTracker; - private final DOMDataReadWriteTransaction delegate; - - TracingReadWriteTransaction(DOMDataReadWriteTransaction delegate, TracingBroker tracingBroker, - CloseTrackedRegistry readWriteTransactionsRegistry) { - super(delegate, tracingBroker); - this.closeTracker = new CloseTrackedTrait<>(readWriteTransactionsRegistry, this); - this.delegate = Objects.requireNonNull(delegate); - } - - @Override - public CheckedFuture>, ReadFailedException> read( - LogicalDatastoreType store, YangInstanceIdentifier yiid) { - return delegate.read(store, yiid); - } - - @Override - public CheckedFuture exists(LogicalDatastoreType store, YangInstanceIdentifier yiid) { - return delegate.exists(store, yiid); - } - - @Override - public FluentFuture commit() { - closeTracker.removeFromTrackedRegistry(); - return super.commit(); - } - - @Override - public boolean cancel() { - closeTracker.removeFromTrackedRegistry(); - return super.cancel(); - } - - @Override - public StackTraceElement[] getAllocationContextStackTrace() { - return closeTracker.getAllocationContextStackTrace(); - } - - @Override - public CloseTracked getRealCloseTracked() { - return this; - } -} diff --git a/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/dom/impl/TracingTransactionChain.java b/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/dom/impl/TracingTransactionChain.java deleted file mode 100644 index 21a4c3f4b5..0000000000 --- a/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/dom/impl/TracingTransactionChain.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2017 Red Hat, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.trace.dom.impl; - -import java.util.Objects; -import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction; -import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction; -import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction; -import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain; -import org.opendaylight.controller.md.sal.trace.closetracker.impl.AbstractCloseTracked; -import org.opendaylight.controller.md.sal.trace.closetracker.impl.CloseTrackedRegistry; - -@Deprecated(forRemoval = true) -class TracingTransactionChain extends AbstractCloseTracked implements DOMTransactionChain { - - private final DOMTransactionChain delegate; - private final TracingBroker tracingBroker; - private final CloseTrackedRegistry readOnlyTransactionsRegistry; - private final CloseTrackedRegistry writeTransactionsRegistry; - private final CloseTrackedRegistry readWriteTransactionsRegistry; - - TracingTransactionChain(DOMTransactionChain delegate, TracingBroker tracingBroker, - CloseTrackedRegistry transactionChainsRegistry) { - super(transactionChainsRegistry); - this.delegate = Objects.requireNonNull(delegate); - this.tracingBroker = Objects.requireNonNull(tracingBroker); - - final boolean isDebug = transactionChainsRegistry.isDebugContextEnabled(); - String anchor = "TransactionChain@" + Integer.toHexString(hashCode()); - this.readOnlyTransactionsRegistry = new CloseTrackedRegistry<>(anchor, "newReadOnlyTransaction()", isDebug); - this.writeTransactionsRegistry = new CloseTrackedRegistry<>(anchor, "newWriteOnlyTransaction()", isDebug); - this.readWriteTransactionsRegistry = new CloseTrackedRegistry<>(anchor, "newReadWriteTransaction()", isDebug); - } - - @Override - @SuppressWarnings("resource") - public DOMDataReadOnlyTransaction newReadOnlyTransaction() { - final DOMDataReadOnlyTransaction tx = delegate.newReadOnlyTransaction(); - return new TracingReadOnlyTransaction(tx, readOnlyTransactionsRegistry); - } - - @Override - public DOMDataReadWriteTransaction newReadWriteTransaction() { - return new TracingReadWriteTransaction(delegate.newReadWriteTransaction(), tracingBroker, - readWriteTransactionsRegistry); - } - - @Override - public DOMDataWriteTransaction newWriteOnlyTransaction() { - final DOMDataWriteTransaction tx = delegate.newWriteOnlyTransaction(); - return new TracingWriteTransaction(tx, tracingBroker, writeTransactionsRegistry); - } - - @Override - public void close() { - delegate.close(); - super.removeFromTrackedRegistry(); - } - - public CloseTrackedRegistry getReadOnlyTransactionsRegistry() { - return readOnlyTransactionsRegistry; - } - - public CloseTrackedRegistry getReadWriteTransactionsRegistry() { - return readWriteTransactionsRegistry; - } - - public CloseTrackedRegistry getWriteTransactionsRegistry() { - return writeTransactionsRegistry; - } - - - // https://jira.opendaylight.org/browse/CONTROLLER-1792 - - @Override - public final boolean equals(Object object) { - return object == this || delegate.equals(object); - } - - @Override - public final int hashCode() { - return delegate.hashCode(); - } - - @Override - public final String toString() { - return getClass().getName() + "; delegate=" + delegate; - } - -} diff --git a/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/dom/impl/TracingWriteTransaction.java b/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/dom/impl/TracingWriteTransaction.java deleted file mode 100644 index 8f5d1f1f3c..0000000000 --- a/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/dom/impl/TracingWriteTransaction.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2017 Red Hat, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.trace.dom.impl; - -import com.google.common.util.concurrent.FluentFuture; -import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction; -import org.opendaylight.controller.md.sal.trace.closetracker.impl.CloseTracked; -import org.opendaylight.controller.md.sal.trace.closetracker.impl.CloseTrackedRegistry; -import org.opendaylight.controller.md.sal.trace.closetracker.impl.CloseTrackedTrait; -import org.opendaylight.mdsal.common.api.CommitInfo; - -@Deprecated(forRemoval = true) -class TracingWriteTransaction extends AbstractTracingWriteTransaction - implements CloseTracked { - - private final CloseTrackedTrait closeTracker; - - TracingWriteTransaction(DOMDataWriteTransaction delegate, TracingBroker tracingBroker, - CloseTrackedRegistry writeTransactionsRegistry) { - super(delegate, tracingBroker); - this.closeTracker = new CloseTrackedTrait<>(writeTransactionsRegistry, this); - } - - @Override - public FluentFuture commit() { - closeTracker.removeFromTrackedRegistry(); - return super.commit(); - } - - @Override - public boolean cancel() { - closeTracker.removeFromTrackedRegistry(); - return super.cancel(); - } - - @Override - public StackTraceElement[] getAllocationContextStackTrace() { - return closeTracker.getAllocationContextStackTrace(); - } - - @Override - public CloseTracked getRealCloseTracked() { - return this; - } - -} diff --git a/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/resources/OSGI-INF/blueprint/impl-blueprint.xml b/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/resources/OSGI-INF/blueprint/impl-blueprint.xml deleted file mode 100644 index 95f4e1fa57..0000000000 --- a/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/resources/OSGI-INF/blueprint/impl-blueprint.xml +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - org.opendaylight.controller.md.sal.dom.api.DOMDataBroker - org.opendaylight.controller.md.sal.trace.api.TracingDOMDataBroker - - - - - - - - - - - - - - - - - org.opendaylight.controller.md.sal.dom.api.DOMDataBroker - org.opendaylight.controller.md.sal.trace.api.TracingDOMDataBroker - - - diff --git a/opendaylight/md-sal/mdsal-trace/dom-impl/src/test/java/org/opendaylight/controller/md/sal/trace/tests/CloseTrackedRegistryTest.java b/opendaylight/md-sal/mdsal-trace/dom-impl/src/test/java/org/opendaylight/controller/md/sal/trace/tests/CloseTrackedRegistryTest.java deleted file mode 100644 index f7a1e777be..0000000000 --- a/opendaylight/md-sal/mdsal-trace/dom-impl/src/test/java/org/opendaylight/controller/md/sal/trace/tests/CloseTrackedRegistryTest.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 2017 Red Hat, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.trace.tests; - -import static com.google.common.truth.Truth.assertThat; -import static org.junit.Assert.fail; - -import java.util.Set; -import java.util.function.Predicate; -import org.junit.Test; -import org.opendaylight.controller.md.sal.trace.closetracker.impl.AbstractCloseTracked; -import org.opendaylight.controller.md.sal.trace.closetracker.impl.CloseTrackedRegistry; -import org.opendaylight.controller.md.sal.trace.closetracker.impl.CloseTrackedRegistryReportEntry; - -@Deprecated -public class CloseTrackedRegistryTest { - - private static class SomethingClosable extends AbstractCloseTracked implements AutoCloseable { - SomethingClosable(CloseTrackedRegistry transactionChainRegistry) { - super(transactionChainRegistry); - } - - @Override - public void close() { - removeFromTrackedRegistry(); - } - } - - @Test - public void testDuplicateAllocationContexts() { - final CloseTrackedRegistry registry = - new CloseTrackedRegistry<>(this, "testDuplicateAllocationContexts", true); - - for (int i = 0; i < 100; i++) { - SomethingClosable isClosedManyTimes = new SomethingClosable(registry); - isClosedManyTimes.close(); - someOtherMethodWhichDoesNotClose(registry); - } - @SuppressWarnings({ "resource", "unused" }) - SomethingClosable forgotToCloseOnce = new SomethingClosable(registry); - - Set> uniqueNonClosed = registry.getAllUnique(); - assertThat(uniqueNonClosed).hasSize(2); - assertThatIterableContains(uniqueNonClosed, entry -> - entry.getNumberAddedNotRemoved() == 100 || entry.getNumberAddedNotRemoved() == 1); - uniqueNonClosed.forEach(entry -> { - if (entry.getNumberAddedNotRemoved() == 100) { - assertThatIterableContains(entry.getStackTraceElements(), - element -> element.getMethodName().equals("someOtherMethodWhichDoesNotClose")); - } else if (entry.getNumberAddedNotRemoved() == 1) { - assertThatIterableContains(entry.getStackTraceElements(), - element -> element.getMethodName().equals("testDuplicateAllocationContexts")); - } else { - fail("Unexpected number of added, not removed: " + entry.getNumberAddedNotRemoved()); - } - }); - } - - // Something like this really should be in Google Truth... - private void assertThatIterableContains(Iterable iterable, Predicate predicate) { - for (T element : iterable) { - if (predicate.test(element)) { - return; - } - } - fail("Iterable did not contain any element matching predicate"); - } - - @SuppressWarnings({ "resource", "unused" }) - private void someOtherMethodWhichDoesNotClose(CloseTrackedRegistry registry) { - new SomethingClosable(registry); - } - - @Test - @SuppressWarnings({ "unused", "resource" }) - public void testDebugContextDisabled() { - final CloseTrackedRegistry debugContextDisabledRegistry = - new CloseTrackedRegistry<>(this, "testDebugContextDisabled", false); - - SomethingClosable forgotToCloseOnce = new SomethingClosable(debugContextDisabledRegistry); - - Set> - closeRegistryReport = debugContextDisabledRegistry.getAllUnique(); - assertThat(closeRegistryReport).hasSize(1); - - CloseTrackedRegistryReportEntry - closeRegistryReportEntry1 = closeRegistryReport.iterator().next(); - assertThat(closeRegistryReportEntry1.getNumberAddedNotRemoved()).isEqualTo(1); - assertThat(closeRegistryReportEntry1.getStackTraceElements()).isEmpty(); - } -} diff --git a/opendaylight/md-sal/mdsal-trace/dom-impl/src/test/java/org/opendaylight/controller/md/sal/trace/tests/TracingBrokerTest.java b/opendaylight/md-sal/mdsal-trace/dom-impl/src/test/java/org/opendaylight/controller/md/sal/trace/tests/TracingBrokerTest.java deleted file mode 100644 index 0a0d7b3a64..0000000000 --- a/opendaylight/md-sal/mdsal-trace/dom-impl/src/test/java/org/opendaylight/controller/md/sal/trace/tests/TracingBrokerTest.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2017 Red Hat, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.trace.tests; - -import static com.google.common.truth.Truth.assertThat; -import static java.nio.charset.StandardCharsets.UTF_8; -import static java.util.Collections.singletonList; -import static org.mockito.Mockito.RETURNS_DEEP_STUBS; -import static org.mockito.Mockito.mock; - -import java.io.ByteArrayOutputStream; -import java.io.PrintStream; -import org.junit.Test; -import org.opendaylight.controller.md.sal.binding.test.DataBrokerTestModule; -import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; -import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction; -import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain; -import org.opendaylight.controller.md.sal.trace.dom.impl.TracingBroker; -import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsaltrace.rev160908.Config; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsaltrace.rev160908.ConfigBuilder; - -/** - * Test of {@link TracingBroker}. - * - * @author Michael Vorburger.ch - */ -@Deprecated -public class TracingBrokerTest { - - @Test - public void testEnd2End() { - DataBrokerTestModule wiring = new DataBrokerTestModule(true); - wiring.getDataBroker(); // required so DataBrokerTestModule creates the DOMDataBroker - DOMDataBroker realDomBroker = wiring.getDOMDataBroker(); - TracingBroker tracingDomBroker = new TracingBroker("Test", realDomBroker, new ConfigBuilder() - // CONTROLLER-1877: configure it like the default/initial mdsaltrace_config.xml in mdsal-trace-api - .setTransactionDebugContextEnabled(true) - .setWriteWatches(singletonList("/this/will/never/exist")) - .setRegistrationWatches(singletonList("/this/will/never/exist")) - .build(), - wiring.getBindingToNormalizedNodeCodec()); - tracingDomBroker.newWriteOnlyTransaction().cancel(); - } - - @Test - @SuppressWarnings({ "resource", "unused" }) // Finding resource leaks is the point of this test - public void testPrintOpenTransactions() { - DOMDataBroker domDataBroker = mock(DOMDataBroker.class, RETURNS_DEEP_STUBS); - Config config = new ConfigBuilder().setTransactionDebugContextEnabled(true).build(); - BindingNormalizedNodeSerializer codec = mock(BindingNormalizedNodeSerializer.class); - TracingBroker tracingBroker = new TracingBroker("mock", domDataBroker, config, codec); - - for (int i = 0; i < 3; i++) { - DOMDataReadWriteTransaction tx = tracingBroker.newReadWriteTransaction(); - } - DOMDataReadWriteTransaction anotherTx = tracingBroker.newReadWriteTransaction(); - - DOMTransactionChain txChain = tracingBroker.createTransactionChain(null); - DOMDataReadWriteTransaction txFromChain = txChain.newReadWriteTransaction(); - - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - PrintStream ps = new PrintStream(baos); - boolean printReturnValue = tracingBroker.printOpenTransactions(ps, 1); - String output = new String(baos.toByteArray(), UTF_8); - - assertThat(printReturnValue).isTrue(); - // Assert expectations about stack trace - assertThat(output).contains("testPrintOpenTransactions(TracingBrokerTest.java"); - assertThat(output).doesNotContain(TracingBroker.class.getName()); - - String previousLine = ""; - for (String line : output.split("\n")) { - if (line.contains("(...")) { - assertThat(previousLine.contains("(...)")).isFalse(); - } - previousLine = line; - } - - // assert that the sorting works - the x3 is shown before the x1 - assertThat(output).contains(" DataBroker : newReadWriteTransaction()\n 3x"); - - // We don't do any verify/times on the mocks, - // because the main point of the test is just to verify that - // printOpenTransactions runs through without any exceptions - // (e.g. it used to have a ClassCastException). - } - -} diff --git a/opendaylight/md-sal/mdsal-trace/features/features-mdsal-trace/pom.xml b/opendaylight/md-sal/mdsal-trace/features/features-mdsal-trace/pom.xml deleted file mode 100644 index a3b1b895fe..0000000000 --- a/opendaylight/md-sal/mdsal-trace/features/features-mdsal-trace/pom.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - 4.0.0 - - - org.opendaylight.odlparent - feature-repo-parent - 6.0.4 - - - - org.opendaylight.controller - features-mdsal-trace - 1.12.0-SNAPSHOT - OpenDaylight :: TracingBroker - feature - - - org.opendaylight.controller - odl-mdsal-trace - ${project.version} - xml - features - - - diff --git a/opendaylight/md-sal/mdsal-trace/features/odl-mdsal-trace/pom.xml b/opendaylight/md-sal/mdsal-trace/features/odl-mdsal-trace/pom.xml deleted file mode 100644 index 2be4f82a28..0000000000 --- a/opendaylight/md-sal/mdsal-trace/features/odl-mdsal-trace/pom.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - 4.0.0 - - - org.opendaylight.odlparent - single-feature-parent - 6.0.4 - - - - org.opendaylight.controller - odl-mdsal-trace - 1.12.0-SNAPSHOT - OpenDaylight :: TracingBroker - feature - - - - - org.opendaylight.controller - mdsal-artifacts - ${project.version} - pom - import - - - - - - - - org.opendaylight.controller - odl-mdsal-broker - ${project.version} - xml - features - - - org.opendaylight.controller - mdsal-trace-api - ${project.version} - - - org.opendaylight.controller - mdsal-trace-dom-impl - ${project.version} - - - org.opendaylight.controller - mdsal-trace-binding-impl - ${project.version} - - - org.opendaylight.controller - mdsal-trace-cli - ${project.version} - - - diff --git a/opendaylight/md-sal/mdsal-trace/features/odl-mdsal-trace/src/main/feature/feature.xml b/opendaylight/md-sal/mdsal-trace/features/odl-mdsal-trace/src/main/feature/feature.xml deleted file mode 100644 index 8e6070ba78..0000000000 --- a/opendaylight/md-sal/mdsal-trace/features/odl-mdsal-trace/src/main/feature/feature.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - mvn:org.opendaylight.controller/mdsal-trace-api/${project.version}/xml/config - - diff --git a/opendaylight/md-sal/mdsal-trace/features/pom.xml b/opendaylight/md-sal/mdsal-trace/features/pom.xml deleted file mode 100644 index 153917073c..0000000000 --- a/opendaylight/md-sal/mdsal-trace/features/pom.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - 4.0.0 - - - org.opendaylight.odlparent - odlparent-lite - 6.0.4 - - - - org.opendaylight.controller - mdsal-trace-feature-aggregator - 1.12.0-SNAPSHOT - pom - - - features-mdsal-trace - odl-mdsal-trace - - diff --git a/opendaylight/md-sal/mdsal-trace/pom.xml b/opendaylight/md-sal/mdsal-trace/pom.xml deleted file mode 100644 index 55ea941086..0000000000 --- a/opendaylight/md-sal/mdsal-trace/pom.xml +++ /dev/null @@ -1,86 +0,0 @@ - - - - 4.0.0 - - - org.opendaylight.odlparent - odlparent-lite - 6.0.4 - - - - org.opendaylight.controller - mdsal-trace-aggregator - 1.12.0-SNAPSHOT - mdsaltrace - pom - - - api - dom-impl - binding-impl - cli - features - - - - - - - org.apache.maven.plugins - maven-deploy-plugin - - true - - - - org.apache.maven.plugins - maven-install-plugin - - true - - - - - - - - - maven-site - - - ${user.dir}/deploy-site.xml - - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - false - - - aggregate - - aggregate - - package - - - - - - - - - diff --git a/opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/messagebus/app/impl/EventSourceTopologyTest.java b/opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/messagebus/app/impl/EventSourceTopologyTest.java index 79a7a558de..ce3e52de2b 100644 --- a/opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/messagebus/app/impl/EventSourceTopologyTest.java +++ b/opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/messagebus/app/impl/EventSourceTopologyTest.java @@ -25,7 +25,6 @@ import java.util.Set; import org.junit.Before; import org.junit.Test; import org.opendaylight.controller.messagebus.spi.EventSource; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; import org.opendaylight.mdsal.binding.api.DataBroker; import org.opendaylight.mdsal.binding.api.DataTreeIdentifier; import org.opendaylight.mdsal.binding.api.ReadTransaction; @@ -181,8 +180,7 @@ public class EventSourceTopologyTest { Map localMap = eventSourceTopology.getRoutedRpcRegistrations(); NodeKey nodeKeyMock = mock(NodeKey.class); doReturn(nodeKeyMock).when(eventSourceMock).getSourceNodeKey(); - BindingAwareBroker.RoutedRpcRegistration routedRpcRegistrationMock = - mock(BindingAwareBroker.RoutedRpcRegistration.class); + ObjectRegistration routedRpcRegistrationMock = mock(ObjectRegistration.class); localMap.put(nodeKeyMock, routedRpcRegistrationMock); eventSourceTopology.unRegister(eventSourceMock); verify(routedRpcRegistrationMock, times(1)).close(); diff --git a/opendaylight/md-sal/messagebus-util/pom.xml b/opendaylight/md-sal/messagebus-util/pom.xml index 05b497fe0f..9002dbf98d 100644 --- a/opendaylight/md-sal/messagebus-util/pom.xml +++ b/opendaylight/md-sal/messagebus-util/pom.xml @@ -26,12 +26,12 @@ and is available at http://www.eclipse.org/legal/epl-v10.html - org.opendaylight.controller - sal-core-api + org.opendaylight.mdsal + mdsal-binding-api - org.opendaylight.controller - sal-binding-api + org.opendaylight.mdsal + mdsal-dom-api org.opendaylight.controller diff --git a/opendaylight/md-sal/messagebus-util/src/main/java/org/opendaylight/controller/messagebus/app/util/TopicDOMNotification.java b/opendaylight/md-sal/messagebus-util/src/main/java/org/opendaylight/controller/messagebus/app/util/TopicDOMNotification.java index b6c6cdf8ab..69a8b2795a 100644 --- a/opendaylight/md-sal/messagebus-util/src/main/java/org/opendaylight/controller/messagebus/app/util/TopicDOMNotification.java +++ b/opendaylight/md-sal/messagebus-util/src/main/java/org/opendaylight/controller/messagebus/app/util/TopicDOMNotification.java @@ -5,10 +5,9 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.controller.messagebus.app.util; -import org.opendaylight.controller.md.sal.dom.api.DOMNotification; +import org.opendaylight.mdsal.dom.api.DOMNotification; import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.TopicNotification; import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; import org.opendaylight.yangtools.yang.model.api.SchemaPath; diff --git a/opendaylight/md-sal/pom.xml b/opendaylight/md-sal/pom.xml index 3f38c9fa24..cd65701bcb 100644 --- a/opendaylight/md-sal/pom.xml +++ b/opendaylight/md-sal/pom.xml @@ -19,31 +19,14 @@ parent - sal-common-api - sal-common-impl sal-common-util - - sal-dom-api - sal-dom-broker - sal-dom-spi - sal-dom-compat - - - sal-binding-api - sal-binding-broker - - sal-binding-util - samples sal-akka-raft sal-akka-raft-example - - sal-inmemory-datastore - sal-clustering-commons cds-access-api cds-access-client @@ -74,15 +57,10 @@ sal-binding-it - sal-binding-dom-it mdsal-it-base mdsal-it-parent - - - mdsal-trace - diff --git a/opendaylight/md-sal/sal-binding-api/.gitignore b/opendaylight/md-sal/sal-binding-api/.gitignore deleted file mode 100644 index ea8c4bf7f3..0000000000 --- a/opendaylight/md-sal/sal-binding-api/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/target diff --git a/opendaylight/md-sal/sal-binding-api/pom.xml b/opendaylight/md-sal/sal-binding-api/pom.xml deleted file mode 100644 index 71fa207b7b..0000000000 --- a/opendaylight/md-sal/sal-binding-api/pom.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - 4.0.0 - - org.opendaylight.controller - mdsal-parent - 1.12.0-SNAPSHOT - ../parent - - - org.opendaylight.controller - sal-binding-api - 1.12.0-SNAPSHOT - bundle - - - - org.opendaylight.controller - sal-common-api - - - org.opendaylight.mdsal - mdsal-binding-api - - - org.opendaylight.yangtools - concepts - - - org.opendaylight.mdsal - yang-binding - - - org.opendaylight.yangtools - yang-common - - - org.osgi - org.osgi.core - provided - - - - - scm:git:http://git.opendaylight.org/gerrit/controller.git - scm:git:ssh://git.opendaylight.org:29418/controller.git - HEAD - https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL - - - diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/ActionProviderService.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/ActionProviderService.java deleted file mode 100644 index 0c53067744..0000000000 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/ActionProviderService.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.api; - -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; - -/** - * Bridge to action registration. - * - * @deprecated Use {@link org.opendaylight.mdsal.binding.api.ActionProviderService} instead - */ -@Deprecated(forRemoval = true) -@SuppressFBWarnings(value = "NM_SAME_SIMPLE_NAME_AS_INTERFACE", justification = "Migration") -public interface ActionProviderService - extends BindingService, org.opendaylight.mdsal.binding.api.ActionProviderService { - -} diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/ActionService.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/ActionService.java deleted file mode 100644 index 0b396e6cc8..0000000000 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/ActionService.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.api; - -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; - -/** - * Bridge to action invocation. - * - * @deprecated Use {@link org.opendaylight.mdsal.binding.api.ActionService} instead - */ -@Deprecated(forRemoval = true) -@SuppressFBWarnings(value = "NM_SAME_SIMPLE_NAME_AS_INTERFACE", justification = "Migration") -public interface ActionService extends BindingService, org.opendaylight.mdsal.binding.api.ActionService { - -} diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/BindingService.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/BindingService.java deleted file mode 100644 index ffcada20cc..0000000000 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/BindingService.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.api; - -import org.opendaylight.controller.sal.binding.api.BindingAwareService; - -/** - * Marker interface for MD-SAL services which are available for users of MD-SAL. - * - *

- * BindingService is marker interface for infrastructure services provided by - * the SAL. These services may be session-specific, and wrapped by custom - * delegator patterns in order to introduce additional semantics / checks - * to the system. - * - *

- * This interface extends {@link BindingAwareService}, order to be make - * new services available via - * {@link org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext} - * and via - * {@link org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext} - * - * @deprecated Use {@link BindingService} instead. - */ -@Deprecated(forRemoval = true) -public interface BindingService extends BindingAwareService { - -} diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/BindingTransactionChain.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/BindingTransactionChain.java deleted file mode 100644 index 02b9dfb0d1..0000000000 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/BindingTransactionChain.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.api; - -import org.opendaylight.controller.md.sal.common.api.data.TransactionChain; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -/** - * A chain of transactions. - * - *

- * For more information about transaction chaining and transaction chains - * see {@link TransactionChain}. - * - * @see TransactionChain - * - * @deprecated Use {@link org.opendaylight.mdsal.binding.api.TransactionChain} instead. - */ -@Deprecated(forRemoval = true) -public interface BindingTransactionChain extends TransactionFactory, - TransactionChain, DataObject> { - @Override - ReadOnlyTransaction newReadOnlyTransaction(); - - @Override - ReadWriteTransaction newReadWriteTransaction(); - - @Override - WriteTransaction newWriteOnlyTransaction(); -} diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/ClusteredDataTreeChangeListener.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/ClusteredDataTreeChangeListener.java deleted file mode 100644 index 8a302cb5b3..0000000000 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/ClusteredDataTreeChangeListener.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2015 Brocade Communications Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.api; - -import org.opendaylight.yangtools.yang.binding.DataObject; - -/** - * ClusteredDataTreeChangeListener is a marker interface to enable data tree change notifications on all - * instances in a cluster where this listener is registered. - * - *

- * Applications should implement ClusteredDataTreeChangeListener instead of {@link DataTreeChangeListener}, - * if they want to listen for data tree change notifications on any node of a clustered data store. - * {@link DataTreeChangeListener} enables notifications only at the leader of the data store. - * - * @author Thomas Pantelis - * - * @param the DataObject type - * - * @deprecated Use {@link org.opendaylight.mdsal.binding.api.ClusteredDataTreeChangeListener} instead. - */ -@Deprecated(forRemoval = true) -public interface ClusteredDataTreeChangeListener extends DataTreeChangeListener { - -} diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/DataBroker.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/DataBroker.java deleted file mode 100644 index bd0de1f6f7..0000000000 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/DataBroker.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.api; - -import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker; -import org.opendaylight.controller.md.sal.common.api.data.TransactionChainFactory; -import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -/** - * Provides access to a conceptual data tree store and also provides the ability to - * subscribe for changes to data under a given branch of the tree. - * - *

- * For more information on usage, please see the documentation in {@link AsyncDataBroker}. - * - * @see AsyncDataBroker - * @see TransactionChainFactory - * - * @deprecated Use {@link org.opendaylight.mdsal.binding.api.DataBroker} instead - */ -@Deprecated(forRemoval = true) -public interface DataBroker extends AsyncDataBroker, DataObject>, - TransactionChainFactory, DataObject>, TransactionFactory, BindingService, - DataTreeChangeService { - @Override - ReadOnlyTransaction newReadOnlyTransaction(); - - @Override - ReadWriteTransaction newReadWriteTransaction(); - - @Override - WriteTransaction newWriteOnlyTransaction(); - - @Override - BindingTransactionChain createTransactionChain(TransactionChainListener listener); -} diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/DataObjectModification.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/DataObjectModification.java deleted file mode 100644 index c9df98bf04..0000000000 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/DataObjectModification.java +++ /dev/null @@ -1,198 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.api; - -import com.google.common.collect.Collections2; -import java.util.Collection; -import org.eclipse.jdt.annotation.NonNull; -import org.eclipse.jdt.annotation.Nullable; -import org.opendaylight.yangtools.yang.binding.Augmentation; -import org.opendaylight.yangtools.yang.binding.ChildOf; -import org.opendaylight.yangtools.yang.binding.ChoiceIn; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.Identifiable; -import org.opendaylight.yangtools.yang.binding.Identifier; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.IdentifiableItem; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.Item; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument; - -/** - * Represents a modification of DataObject. - * - * @deprecated Use {@link org.opendaylight.mdsal.binding.api.DataObjectModification} instead. - */ -@Deprecated(forRemoval = true) -public interface DataObjectModification - extends org.opendaylight.yangtools.concepts.Identifiable { - - enum ModificationType { - /** - * Child node (direct or indirect) was modified. - * - */ - SUBTREE_MODIFIED, - - /** - * Node was explicitly created / overwritten. - * - */ - - WRITE, - /** - * Node was deleted. - * - */ - DELETE - } - - @Override - PathArgument getIdentifier(); - - /** - * Returns type of modified object. - * - * @return type of modified object. - */ - @NonNull Class getDataType(); - - /** - * Returns type of modification. - * - * @return type Type of performed modification. - */ - @NonNull ModificationType getModificationType(); - - /** - * Returns before-state of top level container. Implementations are encouraged, - * but not required to provide this state. - * - * @return State of object before modification. Null if subtree was not present, - * or the implementation cannot provide the state. - */ - @Nullable T getDataBefore(); - - /** - * Returns after-state of top level container. - * - * @return State of object after modification. Null if subtree is not present. - */ - @Nullable T getDataAfter(); - - /** - * Returns unmodifiable collection of modified direct children. - * - * @return unmodifiable collection of modified direct children. - */ - @NonNull Collection> getModifiedChildren(); - - /** - * Returns child list item modification if {@code child} was modified by this modification. This method should be - * used if the child is defined in a grouping brought into a case inside this object. - * - * @param caseType Case type class - * @param childType Type of list item - must be list item with key - * @return Modification of {@code child} if {@code child} was modified, null otherwise. - * @throws IllegalArgumentException If supplied {@code childType} class is not valid child according - * to generated model. - */ - default & DataObject, C extends ChildOf> - Collection> getModifiedChildren(final @NonNull Class caseType, - final @NonNull Class childType) { - final Item item = Item.of(caseType, childType); - return (Collection>) Collections2.filter(getModifiedChildren(), - mod -> item.equals(mod.getIdentifier())); - } - - /** - * Returns container child modification if {@code child} was modified by this modification. This method should be - * used if the child is defined in a grouping brought into a case inside this object. - * - *

- * For accessing all modified list items consider iterating over {@link #getModifiedChildren()}. - * - * @param caseType Case type class - * @param child Type of child - must be only container - * @return Modification of {@code child} if {@code child} was modified, null otherwise. - * @throws IllegalArgumentException If supplied {@code child} class is not valid child according - * to generated model. - */ - default @Nullable & DataObject, C extends ChildOf> - DataObjectModification getModifiedChildContainer(final @NonNull Class caseType, - final @NonNull Class child) { - return (DataObjectModification) getModifiedChild(Item.of(caseType, child)); - } - - /** - * Returns container child modification if {@code child} was modified by this modification. - * - *

- * For accessing all modified list items consider iterating over {@link #getModifiedChildren()}. - * - * @param child Type of child - must be only container - * @return Modification of {@code child} if {@code child} was modified, null otherwise. - * @throws IllegalArgumentException If supplied {@code child} class is not valid child according - * to generated model. - */ - @Nullable > DataObjectModification getModifiedChildContainer( - @NonNull Class child); - - /** - * Returns augmentation child modification if {@code augmentation} was modified by this modification. - * - *

- * For accessing all modified list items consider iterating over {@link #getModifiedChildren()}. - * - * @param augmentation Type of augmentation - must be only container - * @return Modification of {@code augmentation} if {@code augmentation} was modified, null otherwise. - * @throws IllegalArgumentException If supplied {@code augmentation} class is not valid augmentation - * according to generated model. - */ - @Nullable & DataObject> DataObjectModification getModifiedAugmentation( - @NonNull Class augmentation); - - /** - * Returns child list item modification if {@code child} was modified by this modification. - * - * @param listItem Type of list item - must be list item with key - * @param listKey List item key - * @return Modification of {@code child} if {@code child} was modified, null otherwise. - * @throws IllegalArgumentException If supplied {@code listItem} class is not valid child according - * to generated model. - */ - & ChildOf, K extends Identifier> DataObjectModification - getModifiedChildListItem(@NonNull Class listItem, @NonNull K listKey); - - /** - * Returns child list item modification if {@code child} was modified by this modification. - * - * @param caseType Case type class - * @param listItem Type of list item - must be list item with key - * @param listKey List item key - * @return Modification of {@code child} if {@code child} was modified, null otherwise. - * @throws IllegalArgumentException If supplied {@code listItem} class is not valid child according - * to generated model. - */ - default & DataObject, C extends Identifiable & ChildOf, - K extends Identifier> DataObjectModification getModifiedChildListItem( - final @NonNull Class caseType, final @NonNull Class listItem, final @NonNull K listKey) { - return (DataObjectModification) getModifiedChild(IdentifiableItem.of(caseType, listItem, listKey)); - } - - /** - * Returns a child modification if a node identified by {@code childArgument} was modified by - * this modification. - * - * @param childArgument Path Argument of child node - * @return Modification of child identified by {@code childArgument} if {@code childArgument} - * was modified, null otherwise. - * @throws IllegalArgumentException If supplied path argument is not valid child according to - * generated model. - * - */ - @Nullable DataObjectModification getModifiedChild(PathArgument childArgument); -} diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/DataTreeChangeListener.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/DataTreeChangeListener.java deleted file mode 100644 index deddca5f96..0000000000 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/DataTreeChangeListener.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.api; - -import java.util.Collection; -import java.util.EventListener; -import org.eclipse.jdt.annotation.NonNull; -import org.opendaylight.yangtools.yang.binding.DataObject; - -/** - * Interface implemented by classes interested in receiving notifications about - * data tree changes. This interface provides a cursor-based view of the change, which has potentially - * lower overhead and allow more flexible consumption of change event. - * - *

- * Note: this interface enables notifications only at the leader of the data store, if clustered. If you want - * notifications on all instances in a cluster, use the {@link ClusteredDataTreeChangeListener}. - * - * @deprecated Use {@link org.opendaylight.mdsal.binding.api.DataTreeChangeListener} instead. - */ -@Deprecated(forRemoval = true) -public interface DataTreeChangeListener extends EventListener { - /** - * Invoked when there was data change for the supplied path, which was used - * to register this listener. - * - *

- * This method may be also invoked during registration of the listener if - * there is any pre-existing data in the conceptual data tree for supplied - * path. This initial event will contain all pre-existing data as created. - * - *

- * A data change event may be triggered spuriously, e.g. such that data before - * and after compare as equal. Implementations of this interface are expected - * to recover from such events. Event producers are expected to exert reasonable - * effort to suppress such events. - * - *

- * In other words, it is completely acceptable to observe - * a {@link DataObjectModification}, while the state observed before and - * after- data items compare as equal. - * - * @param changes Collection of change events, may not be null or empty. - */ - void onDataTreeChanged(@NonNull Collection> changes); -} diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/DataTreeChangeService.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/DataTreeChangeService.java deleted file mode 100644 index 3af195c6d7..0000000000 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/DataTreeChangeService.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.api; - -import org.eclipse.jdt.annotation.NonNull; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.binding.DataObject; - -/** - * A {@link BindingService} which allows users to register for changes to a subtree. - * - * @deprecated Use {@link org.opendaylight.mdsal.binding.api.DataTreeChangeService} instead. - */ -@Deprecated(forRemoval = true) -public interface DataTreeChangeService extends BindingService { - /** - * Registers a {@link DataTreeChangeListener} to receive - * notifications when data changes under a given path in the conceptual data - * tree. - * - *

- * You are able to register for notifications for any node or subtree - * which can be represented using {@link DataTreeIdentifier}. - * - *

- * You are able to register for data change notifications for a subtree or leaf - * even if it does not exist. You will receive notification once that node is - * created. - * - *

- * If there is any pre-existing data in the data tree for the path for which you are - * registering, you will receive an initial data change event, which will - * contain all pre-existing data, marked as created. - * - *

- * This method returns a {@link ListenerRegistration} object. To - * "unregister" your listener for changes call the {@link ListenerRegistration#close()} - * method on the returned object. - * - *

- * You MUST explicitly unregister your listener when you no longer want to receive - * notifications. This is especially true in OSGi environments, where failure to - * do so during bundle shutdown can lead to stale listeners being still registered. - * - * @param treeId - * Data tree identifier of the subtree which should be watched for - * changes. - * @param listener - * Listener instance which is being registered - * @return Listener registration object, which may be used to unregister - * your listener using {@link ListenerRegistration#close()} to stop - * delivery of change events. - */ - > @NonNull ListenerRegistration - registerDataTreeChangeListener(@NonNull DataTreeIdentifier treeId, @NonNull L listener); -} diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/DataTreeIdentifier.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/DataTreeIdentifier.java deleted file mode 100644 index 8e7180aff8..0000000000 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/DataTreeIdentifier.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.api; - -import static java.util.Objects.requireNonNull; - -import java.io.Serializable; -import org.eclipse.jdt.annotation.NonNull; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.yangtools.concepts.Immutable; -import org.opendaylight.yangtools.concepts.Path; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -/** - * A unique identifier for a particular subtree. It is composed of the logical - * data store type and the instance identifier of the root node. - * - * @deprecated Use {@link org.opendaylight.mdsal.binding.api.DataTreeIdentifier} instead. - */ -@Deprecated(forRemoval = true) -public final class DataTreeIdentifier implements Immutable, - Path>, Serializable { - private static final long serialVersionUID = 1L; - - private final @NonNull InstanceIdentifier rootIdentifier; - private final @NonNull LogicalDatastoreType datastoreType; - - public DataTreeIdentifier(final LogicalDatastoreType datastoreType, final InstanceIdentifier rootIdentifier) { - this.datastoreType = requireNonNull(datastoreType); - this.rootIdentifier = requireNonNull(rootIdentifier); - } - - /** - * Return the logical data store type. - * - * @return Logical data store type. Guaranteed to be non-null. - */ - public @NonNull LogicalDatastoreType getDatastoreType() { - return datastoreType; - } - - /** - * Return the {@link InstanceIdentifier} of the root node. - * - * @return Instance identifier corresponding to the root node. - */ - public @NonNull InstanceIdentifier getRootIdentifier() { - return rootIdentifier; - } - - @Override - public boolean contains(final DataTreeIdentifier other) { - return datastoreType == other.datastoreType && rootIdentifier.contains(other.rootIdentifier); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + datastoreType.hashCode(); - result = prime * result + rootIdentifier.hashCode(); - return result; - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) { - return true; - } - if (!(obj instanceof DataTreeIdentifier)) { - return false; - } - final DataTreeIdentifier other = (DataTreeIdentifier) obj; - if (datastoreType != other.datastoreType) { - return false; - } - return rootIdentifier.equals(other.rootIdentifier); - } - - @Override - public String toString() { - return getClass().getSimpleName() + "{datastoreType = " + datastoreType + ", rootIdentifier = " - + rootIdentifier + "}"; - } -} diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/DataTreeModification.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/DataTreeModification.java deleted file mode 100644 index 0b6c6a95c6..0000000000 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/DataTreeModification.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.api; - -import org.eclipse.jdt.annotation.NonNull; -import org.opendaylight.yangtools.yang.binding.DataObject; - -/** - * Represent root of modification. - * - * @author Tony Tkacik <ttkacik@cisco.com> - * - * @deprecated Use {@link org.opendaylight.mdsal.binding.api.DataTreeModification} instead. - */ -@Deprecated(forRemoval = true) -public interface DataTreeModification { - - /** - * Get the modification root path. This is the path of the root node - * relative to the root of InstanceIdentifier namespace. - * - * @return absolute path of the root node - */ - @NonNull DataTreeIdentifier getRootPath(); - - /** - * Get the modification root node. - * - * @return modification root node - */ - @NonNull DataObjectModification getRootNode(); -} diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/ForwardingDataBroker.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/ForwardingDataBroker.java deleted file mode 100644 index fc76293477..0000000000 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/ForwardingDataBroker.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2017 Red Hat, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.api; - -import com.google.common.collect.ForwardingObject; -import org.eclipse.jdt.annotation.NonNull; -import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.binding.DataObject; - -/** - * Utility {@link DataBroker} implementation which forwards all interface method - * invocation to a delegate instance. - * - * @deprecated Use org.opendaylight.mdsal.binding.spi.ForwardingDataBroker instead. - */ -@Deprecated(forRemoval = true) -public abstract class ForwardingDataBroker extends ForwardingObject implements DataBroker { - - @Override - protected abstract @NonNull DataBroker delegate(); - - @Override - public ReadOnlyTransaction newReadOnlyTransaction() { - return delegate().newReadOnlyTransaction(); - } - - @Override - public ReadWriteTransaction newReadWriteTransaction() { - return delegate().newReadWriteTransaction(); - } - - @Override - public WriteTransaction newWriteOnlyTransaction() { - return delegate().newWriteOnlyTransaction(); - } - - @Override - public > ListenerRegistration - registerDataTreeChangeListener(DataTreeIdentifier treeId, L listener) { - return delegate().registerDataTreeChangeListener(treeId, listener); - } - - @Override - public BindingTransactionChain createTransactionChain(TransactionChainListener listener) { - return delegate().createTransactionChain(listener); - } - -} diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/ForwardingReadOnlyTransaction.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/ForwardingReadOnlyTransaction.java deleted file mode 100644 index 8387473a7b..0000000000 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/ForwardingReadOnlyTransaction.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2017 Red Hat, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.api; - -import com.google.common.base.Optional; -import com.google.common.collect.ForwardingObject; -import com.google.common.util.concurrent.CheckedFuture; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -/** - * Utility {@link ReadOnlyTransaction} implementation which forwards all interface method - * invocation to a delegate instance. - * - * @deprecated Use org.opendaylight.mdsal.binding.spi.ForwardingReadTransaction instead. - */ -@Deprecated(forRemoval = true) -public class ForwardingReadOnlyTransaction extends ForwardingObject implements ReadOnlyTransaction { - - private final ReadOnlyTransaction delegate; - - protected ForwardingReadOnlyTransaction(final ReadOnlyTransaction delegate) { - this.delegate = delegate; - } - - @Override - protected ReadTransaction delegate() { - return delegate; - } - - @Override - public CheckedFuture, ReadFailedException> read(final LogicalDatastoreType store, - final InstanceIdentifier path) { - return delegate.read(store, path); - } - - @Override - public CheckedFuture exists(final LogicalDatastoreType store, - final InstanceIdentifier path) { - return delegate.exists(store, path); - } - - @Override - public Object getIdentifier() { - return delegate.getIdentifier(); - } - - @Override - public void close() { - delegate.close(); - } -} diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/ForwardingReadWriteTransaction.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/ForwardingReadWriteTransaction.java deleted file mode 100644 index 450f463fae..0000000000 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/ForwardingReadWriteTransaction.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2017 Red Hat, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.api; - -import com.google.common.base.Optional; -import com.google.common.collect.ForwardingObject; -import com.google.common.util.concurrent.CheckedFuture; -import com.google.common.util.concurrent.FluentFuture; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; -import org.opendaylight.mdsal.common.api.CommitInfo; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -/** - * Utility {@link ReadWriteTransaction} implementation which forwards all interface method - * invocation to a delegate instance. - * - * @deprecated Use org.opendaylight.mdsal.binding.spi.ForwardingReadWriteTransaction instead. - */ -@Deprecated(forRemoval = true) -public class ForwardingReadWriteTransaction extends ForwardingObject implements ReadWriteTransaction { - - private final ReadWriteTransaction delegate; - - protected ForwardingReadWriteTransaction(final ReadWriteTransaction delegate) { - this.delegate = delegate; - } - - @Override - protected ReadWriteTransaction delegate() { - return delegate; - } - - @Override - public void put(final LogicalDatastoreType store, final InstanceIdentifier path, - final T data) { - delegate.put(store, path, data); - } - - @Override - public void put(final LogicalDatastoreType store, final InstanceIdentifier path, - final T data, final boolean createMissingParents) { - delegate.put(store, path, data, createMissingParents); - } - - @Override - public CheckedFuture, ReadFailedException> read(final LogicalDatastoreType store, - final InstanceIdentifier path) { - return delegate.read(store, path); - } - - @Override - public CheckedFuture exists(final LogicalDatastoreType store, - final InstanceIdentifier path) { - return delegate.exists(store, path); - } - - @Override - public Object getIdentifier() { - return delegate.getIdentifier(); - } - - @Override - public boolean cancel() { - return delegate.cancel(); - } - - @Override - public void merge(final LogicalDatastoreType store, final InstanceIdentifier path, - final T data) { - delegate.merge(store, path, data); - } - - @Override - public void merge(final LogicalDatastoreType store, final InstanceIdentifier path, - final T data, final boolean createMissingParents) { - delegate.merge(store, path, data, createMissingParents); - } - - @Override - public FluentFuture commit() { - return delegate.commit(); - } - - @Override - public void delete(final LogicalDatastoreType store, final InstanceIdentifier path) { - delegate.delete(store, path); - } -} diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/ForwardingWriteTransaction.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/ForwardingWriteTransaction.java deleted file mode 100644 index f3b42bd85f..0000000000 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/ForwardingWriteTransaction.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2017 Red Hat, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.api; - -import com.google.common.collect.ForwardingObject; -import com.google.common.util.concurrent.FluentFuture; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.mdsal.common.api.CommitInfo; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -/** - * Utility {@link WriteTransaction} implementation which forwards all interface method - * invocation to a delegate instance. - * - * @deprecated Use org.opendaylight.mdsal.binding.spi.ForwardingWriteTransaction instead. - */ -@Deprecated(forRemoval = true) -public class ForwardingWriteTransaction extends ForwardingObject implements WriteTransaction { - - private final WriteTransaction delegate; - - protected ForwardingWriteTransaction(WriteTransaction delegate) { - this.delegate = delegate; - } - - @Override - protected WriteTransaction delegate() { - return delegate; - } - - @Override - public void put(LogicalDatastoreType store, InstanceIdentifier path, T data) { - delegate.put(store, path, data); - } - - @Override - public void put(LogicalDatastoreType store, InstanceIdentifier path, T data, - boolean createMissingParents) { - delegate.put(store, path, data, createMissingParents); - } - - @Override - public void merge(LogicalDatastoreType store, InstanceIdentifier path, T data) { - delegate.merge(store, path, data); - } - - @Override - public void merge(LogicalDatastoreType store, InstanceIdentifier path, T data, - boolean createMissingParents) { - delegate.merge(store, path, data, createMissingParents); - } - - @Override - public void delete(LogicalDatastoreType store, InstanceIdentifier path) { - delegate.delete(store, path); - } - - @Override - public boolean cancel() { - return delegate.cancel(); - } - - @Override - public FluentFuture commit() { - return delegate.commit(); - } - - @Override - public Object getIdentifier() { - return delegate.getIdentifier(); - } -} diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/MountPoint.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/MountPoint.java deleted file mode 100644 index 2d8fe7cf23..0000000000 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/MountPoint.java +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.api; - -import com.google.common.base.Optional; -import org.opendaylight.yangtools.concepts.Identifiable; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -@Deprecated(forRemoval = true) -public interface MountPoint extends Identifiable> { - Optional getService(Class service); -} diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/MountPointService.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/MountPointService.java deleted file mode 100644 index f9140c761e..0000000000 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/MountPointService.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.api; - -import com.google.common.base.Optional; -import java.util.EventListener; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -/** - * Deprecated. - * - * @deprecated Use {@link org.opendaylight.mdsal.binding.api.MountPointService} instead - */ -@Deprecated(forRemoval = true) -public interface MountPointService extends BindingService { - - Optional getMountPoint(InstanceIdentifier mountPoint); - - ListenerRegistration registerListener(InstanceIdentifier path, T listener); - - - interface MountPointListener extends EventListener { - - void onMountPointCreated(InstanceIdentifier path); - - void onMountPointRemoved(InstanceIdentifier path); - - } - -} diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/NotificationPublishService.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/NotificationPublishService.java deleted file mode 100644 index 52170ac288..0000000000 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/NotificationPublishService.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.api; - -import com.google.common.util.concurrent.Futures; -import com.google.common.util.concurrent.ListenableFuture; -import java.util.concurrent.TimeUnit; -import org.opendaylight.yangtools.yang.binding.Notification; - -/** - * A {@link NotificationService} which also allows its users to - * submit YANG-modeled notifications for delivery. There are three - * methods of submission, following the patters from {@link java.util.concurrent.BlockingQueue}: - * - {@link #putNotification(Notification)}, which may block indefinitely - * if the implementation cannot allocate resources to accept the notification, - * - {@link #offerNotification(Notification)}, which does not block if face - * of resource starvation, - * - {@link #offerNotification(Notification, int, TimeUnit)}, which may block - * for specified time if resources are thin. - * - *

- * The actual delivery to listeners is asynchronous and implementation-specific. - * Users of this interface should not make any assumptions as to whether the - * notification has or has not been seen. - * - * @deprecated Use {@link org.opendaylight.mdsal.binding.api.NotificationPublishService} instead - */ -@Deprecated(forRemoval = true) -public interface NotificationPublishService extends BindingService { - - /** - * Well-known value indicating that the binding-aware implementation is currently not - * able to accept a notification. - */ - ListenableFuture REJECTED = Futures.immediateFailedFuture(new NotificationRejectedException( - "Rejected due to resource constraints.")); - - /** - * Publishes a notification to subscribed listeners. This initiates - * the process of sending the notification, but delivery to the - * listeners can happen asynchronously, potentially after a call to - * this method returns. - * - * Note: This call will block when the notification queue is full. - * - * @param notification - * the notification to publish. - * @throws InterruptedException if interrupted while waiting - * @throws NullPointerException if the notification is null - */ - void putNotification(Notification notification) throws InterruptedException; - - /** - * Publishes a notification to subscribed listeners. This initiates - * the process of sending the notification, but delivery to the - * listeners can happen asynchronously, potentially after a call to - * this method returns. - * - *

- * Still guaranteed not to block. Returns Listenable Future which will complete once. - * - * @param notification - * the notification to publish. - * @return A listenable future which will report completion when the service has finished - * propagating the notification to its immediate registrants, or {@link #REJECTED} if resource - * constraints prevent - * @throws NullPointerException if the notification is null - */ - ListenableFuture offerNotification(Notification notification); - - /** - * Publishes a notification to subscribed listeners. This initiates - * the process of sending the notification, but delivery to the - * listeners can happen asynchronously, potentially after a call to - * this method returns. This method is guaranteed not to block more - * than the specified timeout. - * - * @param notification - * the notification to publish. - * @param timeout how long to wait before giving up, in units of unit - * @param unit a TimeUnit determining how to interpret the - * timeout parameter - * @return A listenable future which will report completion when the service has finished - * propagating the notification to its immediate registrants, or {@link #REJECTED} if resource - * constraints prevent - * @throws InterruptedException if interrupted while waiting - * @throws NullPointerException if the notification or unit is null - * @throws IllegalArgumentException if timeout is negative. - */ - ListenableFuture offerNotification(Notification notification, int timeout, TimeUnit unit) - throws InterruptedException; - -} diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/NotificationRejectedException.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/NotificationRejectedException.java deleted file mode 100644 index b6143238b5..0000000000 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/NotificationRejectedException.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.api; - -/** - *

- * This exception indicates that given notification can not be processed by corresponding mechanism. - * More info can be provided in message. - *

- *

- * Expected use: {@link NotificationPublishService} - *

- * - * @deprecated Use {@link org.opendaylight.mdsal.binding.api.NotificationRejectedException} instead. - */ -@Deprecated(forRemoval = true) -public class NotificationRejectedException extends Exception { - private static final long serialVersionUID = 1L; - - public NotificationRejectedException(final String message) { - super(message); - } - - public NotificationRejectedException(final String message, final Throwable cause) { - super(message, cause); - } -} diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/NotificationService.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/NotificationService.java deleted file mode 100644 index e784223334..0000000000 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/NotificationService.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.api; - -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.binding.NotificationListener; - -/** - * Notification broker which allows clients to subscribe for and publish YANG-modeled notifications. - * - *

- * Each YANG module which defines notifications results in a generated interface {ModuleName}Listener - * which handles all the notifications defined in the YANG model. Each notification type translates to - * a specific method of the form on{NotificationType} on the generated interface. - * The generated interface also extends the - * {@link org.opendaylight.yangtools.yang.binding.NotificationListener} interface and implementations - * are registered using - * {@link #registerNotificationListener(org.opendaylight.yangtools.yang.binding.NotificationListener)} method. - * - *

Dispatch Listener Example

- * - *

- * Lets assume we have following YANG model: - * - *

- * module example {
- *      ...
- *
- *      notification start {
- *          ...
- *      }
- *
- *      notification stop {
- *           ...
- *      }
- * }
- * 
- * - *

- * The generated interface will be: - * {@code - * public interface ExampleListener extends NotificationListener { - * void onStart(Start notification); - * void onStop(Stop notification); - * } - * } - * The following defines an implementation of the generated interface: - * {@code - * public class MyExampleListener implements ExampleListener { - * public void onStart(Start notification) { - * // do something - * } - * - * public void onStop(Stop notification) { - * // do something - * } - * } - * } - * The implementation is registered as follows: - * {@code - * MyExampleListener listener = new MyExampleListener(); - * ListenerRegistration reg = service.registerNotificationListener( listener ); - * } - * The onStart method will be invoked when someone publishes a Start notification and - * the onStop method will be invoked when someone publishes a Stop notification. - * - * @deprecated Use {@link org.opendaylight.mdsal.binding.api.NotificationService} instead - */ -@Deprecated(forRemoval = true) -public interface NotificationService extends BindingService { - /** - * Registers a listener which implements a YANG-generated notification interface derived from - * {@link NotificationListener}. The listener is registered for all notifications present in - * the implemented interface. - * - * @param listener the listener implementation that will receive notifications. - * @return a {@link ListenerRegistration} instance that should be used to unregister the listener - * by invoking the {@link ListenerRegistration#close()} method when no longer needed. - */ - ListenerRegistration registerNotificationListener(T listener); -} diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/ReadOnlyTransaction.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/ReadOnlyTransaction.java deleted file mode 100644 index b1bc940117..0000000000 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/ReadOnlyTransaction.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.api; - -import org.opendaylight.controller.md.sal.common.api.data.AsyncReadOnlyTransaction; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -/** - * A transaction that provides a stateful read-only view of the data tree. - * - *

- * For more information on usage and examples, please see the documentation in - * {@link org.opendaylight.controller.md.sal.common.api.data.AsyncReadTransaction}. - * - * @deprecated Use {@link org.opendaylight.mdsal.binding.api.ReadTransaction} instead. - */ -@Deprecated(forRemoval = true) -public interface ReadOnlyTransaction extends ReadTransaction, AsyncReadOnlyTransaction, - DataObject> { -} diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/ReadTransaction.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/ReadTransaction.java deleted file mode 100644 index 5dad491754..0000000000 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/ReadTransaction.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.api; - -import com.google.common.base.Optional; -import com.google.common.util.concurrent.CheckedFuture; -import com.google.common.util.concurrent.Futures; -import com.google.common.util.concurrent.MoreExecutors; -import org.opendaylight.controller.md.sal.common.api.MappingCheckedFuture; -import org.opendaylight.controller.md.sal.common.api.data.AsyncReadTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -/** - * A transaction that provides read access to a logical data store. - * - *

- * For more information on usage and examples, please see the documentation in {@link AsyncReadTransaction}. - * - * @deprecated Use {@link org.opendaylight.mdsal.binding.api.ReadTransaction} instead. - */ -@Deprecated(forRemoval = true) -public interface ReadTransaction extends AsyncReadTransaction, DataObject> { - /** - * Reads data from the provided logical data store located at the provided path. - * - *

- * If the target is a subtree, then the whole subtree is read (and will be accessible from the returned data - * object). - * - * @param store Logical data store from which read should occur. - * @param path Path which uniquely identifies subtree which client want to read - * @return a CheckFuture containing the result of the read. The Future blocks until the - * commit operation is complete. Once complete: - *

    - *
  • If the data at the supplied path exists, the Future returns an Optional object - * containing the data.
  • - *
  • If the data at the supplied path does not exist, the Future returns - * Optional#absent().
  • - *
  • If the read of the data fails, the Future will fail with a - * {@link ReadFailedException} or an exception derived from ReadFailedException.
  • - *
- */ - CheckedFuture, ReadFailedException> read( - LogicalDatastoreType store, InstanceIdentifier path); - - /** - * Checks if data is available in the logical data store located at provided path. - * - *

- * Note: a successful result from this method makes no guarantee that a subsequent call to {@link #read} - * will succeed. It is possible that the data resides in a data store on a remote node and, if that - * node goes down or a network failure occurs, a subsequent read would fail. Another scenario is if - * the data is deleted in between the calls to exists and read - * - *

- * Default implementation delegates to {@link #read(LogicalDatastoreType, InstanceIdentifier)}, implementations - * are advised to provide a more efficient override. - * - * @param store Logical data store from which read should occur. - * @param path Path which uniquely identifies subtree which client want to check existence of - * @return a CheckFuture containing the result of the check. - *

    - *
  • If the data at the supplied path exists, the Future returns a Boolean - * whose value is true, false otherwise
  • - *
  • If checking for the data fails, the Future will fail with a - * {@link ReadFailedException} or an exception derived from ReadFailedException.
  • - *
- */ - default CheckedFuture exists(final LogicalDatastoreType store, - final InstanceIdentifier path) { - return MappingCheckedFuture.create(Futures.transform(read(store, path), Optional::isPresent, - MoreExecutors.directExecutor()), ReadFailedException.MAPPER); - } -} diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/ReadWriteTransaction.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/ReadWriteTransaction.java deleted file mode 100644 index e8d2ad1891..0000000000 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/ReadWriteTransaction.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.api; - -import org.opendaylight.controller.md.sal.common.api.data.AsyncReadWriteTransaction; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -/** - * A transaction that enables combined read/write capabilities. - * - *

- * For more information on usage and examples, please see the documentation in {@link AsyncReadWriteTransaction}. - * - * @deprecated Use {@link org.opendaylight.mdsal.binding.api.ReadWriteTransaction} instead. - */ -@Deprecated(forRemoval = true) -public interface ReadWriteTransaction extends ReadTransaction, WriteTransaction, - AsyncReadWriteTransaction, DataObject> { -} diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/TransactionFactory.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/TransactionFactory.java deleted file mode 100644 index 23845e0d86..0000000000 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/TransactionFactory.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.api; - -import org.opendaylight.controller.md.sal.common.api.data.AsyncDataTransactionFactory; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -@Deprecated(forRemoval = true) -public interface TransactionFactory extends AsyncDataTransactionFactory, DataObject> { - @Override - ReadOnlyTransaction newReadOnlyTransaction(); - - @Override - ReadWriteTransaction newReadWriteTransaction(); - - @Override - WriteTransaction newWriteOnlyTransaction(); -} diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/WriteTransaction.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/WriteTransaction.java deleted file mode 100644 index f23466a829..0000000000 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/WriteTransaction.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.api; - -import org.opendaylight.controller.md.sal.common.api.data.AsyncWriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -/** - * A transaction that provides mutation capabilities on a data tree. - * - *

- * For more information on usage and examples, please see the documentation in {@link AsyncWriteTransaction}. - * - * @deprecated Use {@link org.opendaylight.mdsal.binding.api.WriteTransaction} instead. - */ -@Deprecated(forRemoval = true) -public interface WriteTransaction extends AsyncWriteTransaction, DataObject> { - /** - * Stores a piece of data at the specified path. This acts as an add / replace operation, which is to say that whole - * subtree will be replaced by the specified data. - * - *

- * This method does not automatically create missing parent nodes. It is equivalent to invoking - * {@link #put(LogicalDatastoreType, InstanceIdentifier, DataObject, boolean)} with {@code createMissingParents} set - * to false. - * - *

- * For more information on usage and examples, please see the documentation in {@link AsyncWriteTransaction}. - * - *

- * If you need to make sure that a parent object exists but you do not want modify its pre-existing state by using - * put, consider using {@link #merge} instead. - * - * @param store the logical data store which should be modified - * @param path the data object path - * @param data the data object to be written to the specified path - * @throws IllegalStateException if the transaction has already been submitted - */ - void put(LogicalDatastoreType store, InstanceIdentifier path, T data); - - /** - * Stores a piece of data at the specified path. This acts as an add / replace operation, which is to say that whole - * subtree will be replaced by the specified data. - * - *

- * For more information on usage and examples, please see the documentation in {@link AsyncWriteTransaction}. - * - *

- * If you need to make sure that a parent object exists but you do not want modify its pre-existing state by using - * put, consider using {@link #merge} instead. - * - *

- * Note: Using createMissingParents with value true, may introduce garbage in data store, or recreate - * nodes, which were deleted by previous transaction. - * - * @param store the logical data store which should be modified - * @param path the data object path - * @param data the data object to be written to the specified path - * @param createMissingParents if {@link #CREATE_MISSING_PARENTS} ({@code true}), any missing parent nodes will be - * automatically created using a merge operation. - * @throws IllegalStateException if the transaction has already been submitted - */ - void put(LogicalDatastoreType store, InstanceIdentifier path, T data, - boolean createMissingParents); - - /** - * Merges a piece of data with the existing data at a specified path. Any pre-existing data which is not explicitly - * overwritten will be preserved. This means that if you store a container, its child lists will be merged. - * - *

- * This method does not automatically create missing parent nodes. It is equivalent to invoking - * {@link #merge(LogicalDatastoreType, InstanceIdentifier, DataObject, boolean)} with {@code createMissingParents} - * set to false. - * - *

- * For more information on usage and examples, please see the documentation in {@link AsyncWriteTransaction}. - * - *

- * If you require an explicit replace operation, use {@link #put} instead. - * - * @param store the logical data store which should be modified - * @param path the data object path - * @param data the data object to be merged to the specified path - * @throws IllegalStateException if the transaction has already been submitted - */ - void merge(LogicalDatastoreType store, InstanceIdentifier path, T data); - - /** - * Merges a piece of data with the existing data at a specified path. Any pre-existing data which is not explicitly - * overwritten will be preserved. This means that if you store a container, its child lists will be merged. - * - *

- * For more information on usage and examples, please see the documentation in {@link AsyncWriteTransaction}. - * - *

- * If you require an explicit replace operation, use {@link #put} instead. - * - * @param store the logical data store which should be modified - * @param path the data object path - * @param data the data object to be merged to the specified path - * @param createMissingParents if {@link #CREATE_MISSING_PARENTS} ({@code true}), any missing parent nodes will be - * automatically created using a merge operation. - * @throws IllegalStateException if the transaction has already been submitted - */ - void merge(LogicalDatastoreType store, InstanceIdentifier path, T data, - boolean createMissingParents); - - @Override - void delete(LogicalDatastoreType store, InstanceIdentifier path); - - /** - * Flag value indicating that missing parents should be created. - */ - boolean CREATE_MISSING_PARENTS = true; - - /** - * Flag value indicating that missing parents should cause an error. - */ - boolean FAIL_ON_MISSING_PARENTS = false; -} diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/AbstractBindingAwareConsumer.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/AbstractBindingAwareConsumer.java deleted file mode 100644 index f740bd595c..0000000000 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/AbstractBindingAwareConsumer.java +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.binding.api; - -import org.osgi.framework.BundleContext; - -@Deprecated(forRemoval = true) -public abstract class AbstractBindingAwareConsumer extends AbstractBrokerAwareActivator - implements BindingAwareConsumer { - @Override - protected final void onBrokerAvailable(BindingAwareBroker broker, BundleContext context) { - broker.registerConsumer(this, context); - } -} diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/AbstractBindingAwareProvider.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/AbstractBindingAwareProvider.java deleted file mode 100644 index fdff997467..0000000000 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/AbstractBindingAwareProvider.java +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.binding.api; - -import org.osgi.framework.BundleContext; - -@Deprecated(forRemoval = true) -public abstract class AbstractBindingAwareProvider extends AbstractBrokerAwareActivator - implements BindingAwareProvider { - @Override - protected final void onBrokerAvailable(BindingAwareBroker broker, BundleContext context) { - broker.registerProvider(this, context); - } -} diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/AbstractBrokerAwareActivator.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/AbstractBrokerAwareActivator.java deleted file mode 100644 index b169ac4d1a..0000000000 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/AbstractBrokerAwareActivator.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.binding.api; - -import static java.util.Objects.requireNonNull; - -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext; -import org.osgi.framework.BundleActivator; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceReference; -import org.osgi.util.tracker.ServiceTracker; -import org.osgi.util.tracker.ServiceTrackerCustomizer; - -@Deprecated(forRemoval = true) -public abstract class AbstractBrokerAwareActivator implements BundleActivator { - private final class Customizer implements ServiceTrackerCustomizer { - private final BundleContext context; - - Customizer(final BundleContext context) { - this.context = requireNonNull(context); - } - - @Override - public BindingAwareBroker addingService(final ServiceReference reference) { - final BindingAwareBroker broker = context.getService(reference); - MD_ACTIVATION_POOL.execute(() -> onBrokerAvailable(broker, context)); - return broker; - } - - @Override - public void modifiedService(final ServiceReference reference, - final BindingAwareBroker service) { - removedService(reference, service); - addingService(reference); - } - - @Override - public void removedService(final ServiceReference reference, - final BindingAwareBroker service) { - final BindingAwareBroker broker = context.getService(reference); - MD_ACTIVATION_POOL.execute(() -> onBrokerRemoved(broker, context)); - } - } - - private static final ExecutorService MD_ACTIVATION_POOL = Executors.newCachedThreadPool(); - - private ServiceTracker tracker; - - @Override - public final void start(final BundleContext bundleContext) { - startImpl(bundleContext); - tracker = new ServiceTracker<>(bundleContext, BindingAwareBroker.class, new Customizer(bundleContext)); - tracker.open(); - } - - @Override - public final void stop(final BundleContext bundleContext) { - if (tracker != null) { - tracker.close(); - } - stopImpl(bundleContext); - } - - /** - * Called when this bundle is started (before - * {@link BindingAwareProvider#onSessionInitiated(ProviderContext)} so the Framework can perform - * the bundle-specific activities necessary to start this bundle. This - * method can be used to register services or to allocate any resources that - * this bundle needs. - * - *

- * This method must complete and return to its caller in a timely manner. - * - * @param bundleContext - * The execution context of the bundle being started. - * @throws RuntimeException - * If this method throws an exception, this bundle is marked as - * stopped and the Framework will remove this bundle's - * listeners, unregister all services registered by this bundle, - * and release all services used by this bundle. - */ - protected void startImpl(final BundleContext bundleContext) { - // NOOP - } - - /** - * Called when this bundle is stopped so the Framework can perform the - * bundle-specific activities necessary to stop the bundle. In general, this - * method should undo the work that the {@code BundleActivator.start} method - * started. There should be no active threads that were started by this - * bundle when this bundle returns. A stopped bundle must not call any - * Framework objects. - * - *

- * This method must complete and return to its caller in a timely manner. - * - * @param bundleContext The execution context of the bundle being stopped. - * @throws RuntimeException If this method throws an exception, the bundle is still - * marked as stopped, and the Framework will remove the bundle's - * listeners, unregister all services registered by the bundle, and - * release all services used by the bundle. - */ - protected void stopImpl(final BundleContext bundleContext) { - // NOOP - } - - protected abstract void onBrokerAvailable(BindingAwareBroker bindingBroker, BundleContext bundleContext); - - protected void onBrokerRemoved(final BindingAwareBroker bindingBroker, final BundleContext bundleContext) { - stopImpl(bundleContext); - } -} diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/BindingAwareBroker.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/BindingAwareBroker.java deleted file mode 100644 index 32984ef334..0000000000 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/BindingAwareBroker.java +++ /dev/null @@ -1,209 +0,0 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.binding.api; - -import org.opendaylight.controller.md.sal.common.api.routing.RoutedRegistration; -import org.opendaylight.yangtools.concepts.ObjectRegistration; -import org.opendaylight.yangtools.yang.binding.BaseIdentity; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.binding.RpcService; -import org.osgi.framework.BundleContext; - -/** - * Binding-aware core of the SAL layer responsible for wiring the SAL consumers. - * - *

- * The responsibility of the broker is to maintain registration of SAL - * functionality Consumers and Providers, store provider and - * consumer specific context and functionality registration via - * {@link ConsumerContext} and provide access to infrastructure services, which - * removes direct dependencies between providers and consumers. - * - *

- * The Binding-aware broker is also responsible for translation from Java - * classes modeling the functionality and data to binding-independent form which - * is used in SAL Core. - * - *

Infrastructure services

Some examples of infrastructure services: - * - *
    - *
  • YANG Module service - see {@link ConsumerContext#getRpcService(Class)}, - * {@link ProviderContext} - *
  • Notification Service - see {@link NotificationService} and - * {@link NotificationProviderService} - *
- * - *

- * The services are exposed via session. - * - *

Session-based access

- * - *

- * The providers and consumers needs to register in order to use the - * binding-independent SAL layer and to expose functionality via SAL layer. - * - *

- * For more information about session-based access see {@link ConsumerContext} - * and {@link ProviderContext} - */ -@Deprecated(forRemoval = true) -public interface BindingAwareBroker { - @Deprecated - ConsumerContext registerConsumer(BindingAwareConsumer consumer, BundleContext ctx); - - /** - * Registers the {@link BindingAwareConsumer}, which will use the SAL layer. - * - *

- * Note that consumer could register additional functionality at later point - * by using service and functionality specific APIs. - * - *

- * The consumer is required to use returned session for all communication - * with broker or one of the broker services. The session is announced to - * the consumer by invoking - * {@link BindingAwareConsumer#onSessionInitialized(ConsumerContext)}. - * - * @param consumer - * Consumer to be registered. - * @return a session specific to consumer registration - * @throws IllegalArgumentException - * If the consumer is null. - * @throws IllegalStateException - * If the consumer is already registered. - */ - @Deprecated - ConsumerContext registerConsumer(BindingAwareConsumer consumer); - - /* - * @deprecated Use registerProvider(BindingAwareProvider prov) instead (BundleContext is no longer used) - */ - @Deprecated - ProviderContext registerProvider(BindingAwareProvider provider, BundleContext ctx); - - /** - * Registers the {@link BindingAwareProvider}, which will use the SAL layer. - * - *

- * During the registration, the broker obtains the initial functionality - * from consumer, using the - * BindingAwareProvider#getImplementations(), and register that - * functionality into system and concrete infrastructure services. - * - *

- * Note that provider could register additional functionality at later point - * by using service and functionality specific APIs. - * - *

- * The consumer is required to use returned session for all - * communication with broker or one of the broker services. The session is - * announced to the consumer by invoking - * {@link BindingAwareProvider#onSessionInitiated(ProviderContext)}. - * - * - * @param provider - * Provider to be registered. - * @return a session unique to the provider registration. - * @throws IllegalArgumentException - * If the provider is null. - * @throws IllegalStateException - * If the consumer is already registered. - */ - @Deprecated - ProviderContext registerProvider(BindingAwareProvider provider); - - /** - * {@link BindingAwareConsumer} specific access to the SAL functionality. - * - *

- * ConsumerSession is {@link BindingAwareConsumer}-specific access to the - * SAL functionality and infrastructure services. - * - *

- * The session serves to store SAL context (e.g. registration of - * functionality) for the consumer and provides access to the SAL - * infrastructure services and other functionality provided by - * {@link BindingAwareProvider}s. - */ - @Deprecated - interface ConsumerContext extends RpcConsumerRegistry { - - /** - * Returns a session specific instance (implementation) of requested binding-aware infrastructure service. - * - * @param service - * Broker service - * @return Session specific implementation of service - */ - T getSALService(Class service); - } - - /** - * {@link BindingAwareProvider} specific access to the SAL functionality. - * - *

- * ProviderSession is {@link BindingAwareProvider}-specific access to the - * SAL functionality and infrastructure services, which also allows for - * exposing the provider's functionality to the other - * {@link BindingAwareConsumer}s. - * - *

- * The session serves to store SAL context (e.g. registration of - * functionality) for the providers and exposes access to the SAL - * infrastructure services, dynamic functionality registration and any other - * functionality provided by other {@link BindingAwareConsumer}s. - * - */ - @Deprecated - interface ProviderContext extends ConsumerContext, RpcProviderRegistry { - - } - - /** - * Represents an RPC implementation registration. Users should call the - * {@link ObjectRegistration#close close} method when the registration is no longer needed. - * - * @param the implemented RPC service interface - */ - interface RpcRegistration extends ObjectRegistration { - - /** - * Returns the implemented RPC service interface. - */ - Class getServiceType(); - - @Override - void close(); - } - - /** - * Represents a routed RPC implementation registration. Users should call the - * {@link RoutedRegistration#close close} method when the registration is no longer needed. - * - * @param the implemented RPC service interface - */ - interface RoutedRpcRegistration extends RpcRegistration, - RoutedRegistration, InstanceIdentifier, T> { - - /** - * Register particular instance identifier to be processed by this RpcService. - * - * @deprecated in favor of RoutedRegistration#registerPath(Object, Object). - */ - @Deprecated - void registerInstance(Class context, InstanceIdentifier instance); - - /** - * Unregister particular instance identifier to be processed by this RpcService. - * - * @deprecated in favor of RoutedRegistration#unregisterPath(Class, InstanceIdentifier). - */ - @Deprecated - void unregisterInstance(Class context, InstanceIdentifier instance); - } -} diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/BindingAwareConsumer.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/BindingAwareConsumer.java deleted file mode 100644 index 7d364958d8..0000000000 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/BindingAwareConsumer.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.binding.api; - -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext; - -/** - * A developer implemented component that gets registered with the Broker. - * - *

- * Semantically, a consumer may: - * - *

    - *
  1. Subscribe for Notifications
  2. - *
  3. Invoke RPCs
  4. - *
  5. Read from either the operational or config data tree
  6. - *
  7. Write to the config data tree
  8. - *
- * If you need to: - *
    - *
  1. Emit Notifications
  2. - *
  3. Provide the implementation of RPCs
  4. - *
  5. Write to the operational data tree
  6. - *
- * - *

- * Consider using a BindingAwareProvider - * - *

- * Examples: - * - *

- * To get a NotificationService: - * - *

- * {code - * public void onSessionInitiated(ProviderContext session) { - * NotificationProviderService notificationService = session.getSALService(NotificationProviderService.class); - * notificationService.publish(notification) - * } - * where notification is an instance of a modeled Notification. - * For more information on sending notifications via the NotificationProviderService - * see org.opendaylight.controller.sal.binding.api.NotificationProviderService - * - *

- * A consumer can *invoke* and RPC ( ie, call foo(fooArgs)) but it cannot register an RPC - * implementation with the MD-SAL that others can invoke(call). - * To get an invokable RPC: - * - *

- * {code - * public void onSessionInitiated(ProviderContext session) { - * MyService rpcFlowSalService = session.getRpcService(MyService.class); - * } - * - *

- * Where MyService.class is a Service interface generated from a yang model with RPCs modeled in it. The returned - * rpcFlowSalService can be used like any other object by invoking its methods. Note, nothing special needs to be done - * for RoutedRPCs. They just work. - * - *

- * To get a DataBroker to allow access to the data tree: - * - *

- * {code - * public void onSessionInitiated(final ProviderContext session) { - * DataBroker databroker = session.getSALService(BindingDataBroker.class); - * } - * } -*/ -@Deprecated(forRemoval = true) -public interface BindingAwareConsumer { - - /** - * Callback signaling initialization of the consumer session to the SAL. - * - *

- * The consumer MUST use the session for all communication with SAL or - * retrieving SAL infrastructure services. - * - *

- * This method is invoked by {@link BindingAwareBroker#registerConsumer(BindingAwareConsumer)} - * - * @param session - * Unique session between consumer and SAL. - */ - void onSessionInitialized(ConsumerContext session); -} diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/BindingAwareProvider.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/BindingAwareProvider.java deleted file mode 100644 index 399eda53ee..0000000000 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/BindingAwareProvider.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.binding.api; - -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext; - -/** - * A developer implemented component that gets registered with the Broker. - * - *

- * Semantically, a provider may: - * - *

    - *
  1. Emit Notifications
  2. - *
  3. Provide the implementation of RPCs
  4. - *
  5. Write to the operational data tree
  6. - *
- * - *

- * If a class is not doing at least one of those three, consider using - * a BindingAwareConsumer instead: - * see {@link org.opendaylight.controller.sal.binding.api.BindingAwareConsumer} - * - *

- * In addition, a BindingAwareProvider can in pursuit of its goals: - *

    - *
  1. Subscribe for Notifications
  2. - *
  3. Invoke RPCs
  4. - *
  5. Read from either the operational or config data tree
  6. - *
  7. Write to the config data tree
  8. - *
- * (All of the above are things a Consumer can also do). - * - *

- * Examples: - * - *

- * To get a NotificationService: - * - * {@code - * public void onSessionInitiated(ProviderContext session) { - * NotificationProviderService notificationService = session.getSALService(NotificationProviderService.class); - * } - * } - * For more information on sending notifications via the NotificationProviderService - * see {@link org.opendaylight.controller.sal.binding.api.NotificationProviderService} - * - *

- * To register an RPC implementation: - * - * {@code - * public void onSessionInitiated(ProviderContext session) { - * RpcRegistration registration = session.addRpcImplementation(MyService.class, myImplementationInstance); - * } - * } - * - *

- * Where MyService.class is a Service interface generated from a yang model with RPCs modeled in it and - * myImplementationInstance is an instance of a class that implements MyService. - * - *

- * To register a Routed RPC Implementation: - * {@code - * public void onSessionInitiated(ProviderContext session) { - * RoutedRpcRegistration flowRegistration = session.addRoutedRpcImplementation(SalFlowService.class, - * salFlowServiceImplementationInstance); - flowRegistration.registerPath(NodeContext.class, nodeInstanceId); - * } - * } - * - *

- * Where SalFlowService.class is a Service interface generated from a yang model with RPCs modeled in it and - * salFlowServiceImplementationInstance is an instance of a class that implements SalFlowService. - * - *

- * The line: - * {@code - * flowRegistration.registerPath(NodeContext.class, nodeInstanceId); - * } - * Is indicating that the RPC implementation is registered to handle RPC invocations that have their NodeContext - * pointing to the node with instance id nodeInstanceId. This bears a bit of further explanation. RoutedRPCs can be - * 'routed' to an implementation based upon 'context'. 'context' is a pointer (instanceId) to some place in the data - * tree. In this example, the 'context' is a pointer to a Node. In this way, a provider can register its ability to - * provide a service for a particular Node, but not *all* Nodes. The Broker routes the RPC by 'context' to the correct - * implementation, without the caller having to do extra work. Because of this when a RoutedRPC is registered, it - * needs to also be able to indicate for which 'contexts' it is providing an implementation. - * - *

- * An example of a Routed RPC would be an updateFlow(node, flow) that would be routed based on node to the provider - * which had registered to provide it *for that node*. - * - *

- * To get a DataBroker to allow access to the data tree: - * - * {@code - * public void onSessionInitiated(final ProviderContext session) { - * DataBroker databroker = session.getSALService(BindingDataBroker.class); - * } - * } - */ -@Deprecated(forRemoval = true) -public interface BindingAwareProvider { - - /** - * Callback signaling initialization of the consumer session to the SAL. - * - *

- * The consumer MUST use the session for all communication with SAL or - * retrieving SAL infrastructure services. - * - *

- * This method is invoked by - * {@link BindingAwareBroker#registerProvider(BindingAwareProvider)} - * - * @param session Unique session between consumer and SAL. - */ - void onSessionInitiated(ProviderContext session); -} diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/BindingAwareService.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/BindingAwareService.java deleted file mode 100644 index 4f0ec6b039..0000000000 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/BindingAwareService.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.binding.api; - -import org.opendaylight.controller.md.sal.binding.api.BindingService; - -/** - * Session-specific instance of the broker functionality. - * - *

- * BindingAwareService is marker interface for infrastructure services provided - * by the SAL. These services are session-specific, each - * {@link BindingAwareConsumer} and {@link BindingAwareProvider} usually has own - * instance of the service with it's own context. - * - *

- * The consumer's (or provider's) instance of specific service could be obtained by invoking - * {@link org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext#getSALService(Class)} - * method on session assigned to the consumer. - * - *

- * {@link org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext} - * and {@link BindingAwareProvider} may seem similar, but provider provides YANG model-based functionality and - * {@link BindingAwareProvider} exposes the necessary supporting functionality - * to implement specific functionality of YANG and to reuse it in the - * development of {@link BindingAwareConsumer}s and {@link BindingAwareProvider}s. - * - * @deprecated Use {@link BindingService} instead. - */ -@Deprecated(forRemoval = true) -public interface BindingAwareService { - -} diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/NotificationListener.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/NotificationListener.java deleted file mode 100644 index 5c9d6bbafc..0000000000 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/NotificationListener.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.binding.api; - -import java.util.EventListener; -import org.opendaylight.yangtools.yang.binding.Notification; - -/** - * Interface for a generic listener that is interested in receiving YANG modeled notifications. - * This interface acts as a base interface for specific listeners which usually are a type - * capture of this interface. - * - * @param the interested notification type - * @deprecated Deprecated unused API. - */ -@Deprecated(forRemoval = true) -public interface NotificationListener extends EventListener { - /** - * Invoked to deliver a notification. - * - *

- * Note that this method may be invoked from a shared thread pool, so implementations SHOULD NOT - * perform CPU-intensive operations and MUST NOT invoke any potentially blocking operations. - * - * @param notification the notification. - */ - void onNotification(T notification); -} diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/NotificationProviderService.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/NotificationProviderService.java deleted file mode 100644 index ac2bb64776..0000000000 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/NotificationProviderService.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.binding.api; - -import java.util.EventListener; -import java.util.concurrent.ExecutorService; -import org.opendaylight.controller.md.sal.common.api.notify.NotificationPublishService; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.binding.Notification; - -/** - * Interface for a notification service that provides publish/subscribe capabilities for YANG - * modeled notifications. This interface is a combination of the {@link NotificationService} and - * {@link NotificationPublishService} interfaces. - * - * @deprecated Please use {@link org.opendaylight.mdsal.binding.api.NotificationPublishService}. - */ -@Deprecated(forRemoval = true) -public interface NotificationProviderService extends NotificationService, NotificationPublishService { - - @Override - void publish(Notification notification); - - @Override - void publish(Notification notification, ExecutorService executor); - - /** - * Registers a listener to be notified about notification subscriptions. This - * enables a component to know when there is a notification listener subscribed - * for a particular notification type. - * - *

- * On registration of this listener, the - * {@link NotificationInterestListener#onNotificationSubscribtion(Class)} method - * will be invoked for every notification type that currently has a notification listener - * subscribed. - * - * @param interestListener the listener that will be notified when subscriptions - * for new notification types occur. - * @return a {@link ListenerRegistration} instance that should be used to unregister the listener - * by invoking the {@link ListenerRegistration#close()} method when no longer needed. - */ - ListenerRegistration registerInterestListener( - NotificationInterestListener interestListener); - - /** - * Interface for a listener interested in being notified about notification subscriptions. - */ - interface NotificationInterestListener extends EventListener { - - /** - * Callback that is invoked when a notification listener subscribes for a particular notification type. - * - *

- * This method is only called for the first subscription that occurs for a - * particular notification type. Subsequent subscriptions for the same - * notification type do not trigger invocation of this method. - * - *

- * Note:This callback is delivered from thread not owned by this listener, - * all processing should be as fast as possible and implementations should - * not do any blocking calls or block this thread. - * - * @param notificationType the notification type for the subscription that occurred. - */ - void onNotificationSubscribtion(Class notificationType); - } -} diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/NotificationService.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/NotificationService.java deleted file mode 100644 index c7b125719f..0000000000 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/NotificationService.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.binding.api; - -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.binding.Notification; - -/** - * Notification broker which allows clients to subscribe for and publish YANG-modeled notifications. - * - *

- * Two styles of listeners are supported: - *

    - *
  • Generic listener
  • - *
  • Dispatch listener - listener, which implements {ModelName}Listener interface, - * which has dispatch methods for each defined notification. Methods are invoked based on notification type (class). - *
  • - *
- * - *

Generic Listener

- * - *

- * A generic listener implements the {@link NotificationListener} interface which has one callback method - * onNotification that is invoked for any notification type the listener is subscribed to. - * - *

- * A generic listener is subscribed using the {@link #registerNotificationListener(Class, NotificationListener)} - * method by which you specify the type of notification to receive. A generic listener may be registered for - * multiple notification types via multiple subscriptions. - * - *

- * Generic listeners allow for a more flexible approach, allowing you to subscribe for just - * one type of notification from a YANG model. You could also have a general subscription - * for all notification in the system via - *

- *   service.registerNotificationListener(Notification.class, listener);
- * 
- * - *

Dispatch Listener

- * - *

- * A dispatch listener implements a YANG-generated module interface {ModuleName}Listener - * which handles all the notifications defined in the YANG model. Each notification type translates to - * a specific method of the form on{NotificationType} on the generated interface. - * The generated interface also extends the - * {@link org.opendaylight.yangtools.yang.binding.NotificationListener} interface and implementations - * are registered using - * {@link #registerNotificationListener(org.opendaylight.yangtools.yang.binding.NotificationListener)} method. - * - *

Dispatch Listener Example

- * - *

- * Lets assume we have following YANG model: - * - * {@code - * module example { - * ... - * - * notification start { - * ... - * } - * - * notification stop { - * ... - * } - * } - * } - * - *

- * The generated interface will be: - * {@code - * public interface ExampleListener extends NotificationListener { - * void onStart(Start notification); - * void onStop(Stop notification); - * } - * } - * The following defines an implementation of the generated interface: - * {@code - * public class MyExampleListener implements ExampleListener { - * public void onStart(Start notification) { - * // do something - * } - * - * public void onStop(Stop notification) { - * // do something - * } - * } - * } - * The implementation is registered as follows: - * {@code - * MyExampleListener listener = new MyExampleListener(); - * ListenerRegistration reg = service.registerNotificationListener( listener ); - * } - * The onStart method will be invoked when someone publishes a Start notification and - * the onStop method will be invoked when someone publishes a Stop notification. - * - * @deprecated Please use {@link org.opendaylight.mdsal.binding.api.NotificationService} instead. - */ -@Deprecated(forRemoval = true) -public interface NotificationService extends BindingAwareService { - /** - * Registers a generic listener implementation for a specified notification type. - * - * @param notificationType the YANG-generated interface of the notification type. - * @param listener the listener implementation that will receive notifications. - * @return a {@link ListenerRegistration} instance that should be used to unregister the listener - * by invoking the {@link ListenerRegistration#close()} method when no longer needed. - */ - ListenerRegistration> registerNotificationListener( - Class notificationType, NotificationListener listener); - - /** - * Registers a listener which implements a YANG-generated notification interface derived from - * {@link org.opendaylight.yangtools.yang.binding.NotificationListener}. - * The listener is registered for all notifications present in the implemented interface. - * - * @param listener the listener implementation that will receive notifications. - * @return a {@link ListenerRegistration} instance that should be used to unregister the listener - * by invoking the {@link ListenerRegistration#close()} method when no longer needed. - */ - ListenerRegistration registerNotificationListener( - org.opendaylight.yangtools.yang.binding.NotificationListener listener); -} diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/RpcAvailabilityListener.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/RpcAvailabilityListener.java deleted file mode 100644 index fde1c482f6..0000000000 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/RpcAvailabilityListener.java +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.binding.api; - -@Deprecated(forRemoval = true) -public interface RpcAvailabilityListener { - -} diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/RpcConsumerRegistry.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/RpcConsumerRegistry.java deleted file mode 100644 index e0603602b7..0000000000 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/RpcConsumerRegistry.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.binding.api; - -import org.opendaylight.controller.md.sal.binding.api.BindingService; -import org.opendaylight.yangtools.yang.binding.RpcService; - -/** - * Provides access to registered Remote Procedure Call (RPC) service implementations. The RPCs are - * defined in YANG models. - * - *

- * RPC implementations are registered using the {@link RpcProviderRegistry}. - * - * @deprecated Use {@link org.opendaylight.mdsal.binding.api.RpcConsumerRegistry} instead - */ -@Deprecated(forRemoval = true) -public interface RpcConsumerRegistry extends BindingAwareService, BindingService { - /** - * Returns an implementation of a requested RPC service. - * - *

- * The returned instance is not an actual implementation of the RPC service interface, but a proxy implementation - * of the interface that forwards to an actual implementation, if any. - * - *

- * The following describes the behavior of the proxy when invoking RPC methods: - *

    - *
  • If an actual implementation is registered with the MD-SAL, all invocations are - * forwarded to the registered implementation.
  • - *
  • If no actual implementation is registered, all invocations will fail by - * throwing {@link IllegalStateException}.
  • - *
  • Prior to invoking the actual implementation, the method arguments are are validated. - * If any are invalid, an {@link IllegalArgumentException} is thrown. - *
- * - *

- * The returned proxy is automatically updated with the most recent registered implementation. - * {@code - * final Future> future = someRpcService.someRpc( ... ); - * Futures.addCallback(future, - * new FutureCallback>() { - * public void onSuccess(RpcResult result) { - * // process result ... - * } - * - * public void onFailure(Throwable t) { - * // RPC failed - * } - * }); - * } - * - * @param serviceInterface the interface of the RPC Service. Typically this is an interface generated - * from a YANG model. - * @return the proxy for the requested RPC service. This method never returns null. - */ - T getRpcService(Class serviceInterface); -} diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/RpcProviderRegistry.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/RpcProviderRegistry.java deleted file mode 100644 index a501c02197..0000000000 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/RpcProviderRegistry.java +++ /dev/null @@ -1,293 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.binding.api; - -import org.opendaylight.controller.md.sal.common.api.routing.RouteChangePublisher; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration; -import org.opendaylight.controller.sal.binding.api.rpc.RpcContextIdentifier; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.binding.RpcService; - -/** - * Provides a registry for Remote Procedure Call (RPC) service implementations. The RPCs are - * defined in YANG models. - * - *

- * There are 2 types of RPCs: - *

    - *
  • Global
  • - *
  • Routed
  • - *
- * - *

Global RPC

- * - *

- * An RPC is global if there is intended to be only 1 registered implementation. A global RPC is not - * explicitly declared as such, essentially any RPC that is not defined to be routed is considered global. - * - *

- * Global RPCs are registered using the - * {@link #addRpcImplementation(Class, RpcService)} method. - * - *

Routed RPC

- * - *

- * MD-SAL supports routing of RPC between multiple implementations where the appropriate - * implementation is selected at run time based on the content of the RPC message as described in - * YANG model. - * - *

- * RPC routing is based on: - *

    - *
  • Route identifier - - * An {@link org.opendaylight.yangtools.yang.binding.InstanceIdentifier InstanceIdentifier} value - * which is part of the RPC input. This value is used to select the correct - * implementation at run time.
  • - *
  • Context Type - A YANG-defined construct which constrains the subset of - * valid route identifiers for a particular RPC.
  • - *
- * - *

Context type

- * - *

- * A context type is modeled in YANG using a combination of a YANG identity - * and Opendaylight specific extensions from yang-ext module. These extensions are: - *

    - *
  • context-instance - This is used in the data tree part of a YANG model to - * define a context type that associates nodes with a specified context identity. - * Instance identifiers that reference these nodes are valid route identifiers for RPCs that - * reference this context type.
  • - *
  • context-reference - This is used in RPC input to mark a leaf of type - * instance-identifier as a reference to the particular context type defined by the - * specified context identity. The value of this - * leaf is used by the RPC broker at run time to route the RPC request to the correct implementation. - * Note that context-reference may only be used on leaf elements of type - * instance-identifier or a type derived from instance-identifier.
  • - *
- * - *


- *

1. Defining a Context Type

- * - *

- * The following snippet declares a simple YANG identity named example-context: - * - * {@code - * module example { - * ... - * identity example-context { - * description "Identity used to define an example-context type"; - * } - * ... - * } - * } - * - *

- * We then use the declared identity to define a context type by using it in combination - * with the context-instance YANG extension. We'll associate the context type - * with a list element in the data tree. This defines the set of nodes whose instance - * identifiers are valid for the example-context context type. - * - *

- * The following YANG snippet imports the yang-ext module and defines the list - * element named item inside a container named foo: - * - * {@code - * module foo { - * ... - * import yang-ext {prefix ext;} - * ... - * container foo { - * list item { - * key "id"; - * leaf id {type string;} - * ext:context-instance "example-context"; - * } - * } - * ... - * } - * } - * - *

- * The statement ext:context-instance "example-context"; inside the list element - * declares that any instance identifier referencing item in the data - * tree is valid for example-context. For example, the following instance - * identifier: - *

- *     InstanceIdentifier.create(Foo.class).child(Item.class,new ItemKey("Foo"))
- * 
- * is valid for example-context. However the following: - *
- *     InstanceIdentifier.create(Example.class)
- * 
- * is not valid. - * - *

- * So using an identity in combination with context-instance we - * have effectively defined a context type that can be referenced in a YANG RPC input. - * - *

- *

2. Defining an RPC to use the Context Type
- * - *

- * To define an RPC to be routed based on the context type we need to add an input leaf element - * that references the context type which will hold an instance identifier value to be - * used to route the RPC. - * - *

- * The following snippet defines an RPC named show-item with 2 leaf elements - * as input: item of type instance-identifier and description: - * - *

- * module foo {
- *      ...
- *      import yang-ext {prefix ext;}
- *      ...
- *      rpc show-item {
- *          input {
- *              leaf item {
- *                  type instance-identifier;
- *                  ext:context-reference example-context;
- *              }
- *              leaf description {
- *                  type "string";
- *              }
- *          }
- *      }
- * }
- * 
- * - *

- * We mark the item leaf with a context-reference statement that - * references the example-context context type. RPC calls will then be routed - * based on the instance identifier value contained in item. Only instance - * identifiers that point to a foo/item node are valid as input. - * - *

- * The generated RPC Service interface for the module is: - * - *

- * interface FooService implements RpcService {
- *      Future<RpcResult<Void>> showItem(ShowItemInput input);
- * }
- * 
- * - *

- * For constructing the RPC input, there are generated classes ShowItemInput and ShowItemInputBuilder. - * - *

3. Registering a routed RPC implementation
- * - *

- * To register a routed implementation for the show-item RPC, we must use the - * {@link #addRoutedRpcImplementation(Class, RpcService)} method. This - * will return a {@link RoutedRpcRegistration} instance which can then be used to register / - * unregister routed paths associated with the registered implementation. - * - *

- * The following snippet registers myImpl as the RPC implementation for an - * item with key "foo": - *

- * // Create the instance identifier path for item "foo"
- * InstanceIdentifier path = InstanceIdentifier.create(Foo.class).child(Item.class, new ItemKey("foo"));
- *
- * // Register myImpl as the implementation for the FooService RPC interface
- * RoutedRpcRegistration reg = rpcRegistry.addRoutedRpcImplementation(FooService.class, myImpl);
- *
- * // Now register for the context type and specific path ID. The context type is specified by the
- * // YANG-generated class for the example-context identity.
- * reg.registerPath(ExampleContext.class, path);
- * 
- * - *

- * It is also possible to register the same implementation for multiple paths: - * - *

- * InstanceIdentifier one = InstanceIdentifier.create(Foo.class).child(Item.class, new ItemKey("One"));
- * InstanceIdentifier two = InstanceIdentifier.create(Foo.class).child(Item.class, new ItemKey("Two"));
- *
- * RoutedRpcRegistration reg = rpcRegistry.addRoutedRpcImplementation(FooService.class, myImpl);
- * reg.registerPath(ExampleContext.class, one);
- * reg.registerPath(ExampleContext.class, two);
- * 
- * - *

- * When another client invokes the showItem(ShowItemInput) method on the proxy instance - * retrieved via {@link RpcConsumerRegistry#getRpcService(Class)}, the proxy will inspect the - * arguments in ShowItemInput, extract the InstanceIdentifier value of the item leaf and select - * the implementation whose registered path matches the InstanceIdentifier value of the item leaf. - * - *


- *

Notes for RPC Implementations

- * - *

- *

RpcResult

- * - *

- * The generated interfaces require implementors to return - * {@link java.util.concurrent.Future Future}<{@link org.opendaylight.yangtools.yang.common.RpcResult RpcResult} - * <{RpcName}Output>> instances. - * - *

- * Implementations should do processing of RPC calls asynchronously and update the - * returned {@link java.util.concurrent.Future Future} instance when processing is complete. - * However using {@link com.google.common.util.concurrent.Futures#immediateFuture(Object) Futures.immediateFuture} - * is valid only if the result is immediately available and asynchronous processing is unnecessary and - * would only introduce additional complexity. - * - *

- * The {@link org.opendaylight.yangtools.yang.common.RpcResult RpcResult} is a generic - * wrapper for the RPC output payload, if any, and also allows for attaching error or - * warning information (possibly along with the payload) should the RPC processing partially - * or completely fail. This is intended to provide additional human readable information - * for users of the API and to transfer warning / error information across the system - * so it may be visible via other external APIs such as Restconf. - * - *

- * It is recommended to use the {@link org.opendaylight.yangtools.yang.common.RpcResult RpcResult} - * for conveying appropriate error information - * on failure rather than purposely throwing unchecked exceptions if at all possible. - * While unchecked exceptions will fail the returned {@link java.util.concurrent.Future Future}, - * using the intended RpcResult to convey the error information is more user-friendly. - * - * @deprecated Use {@link org.opendaylight.mdsal.binding.api.RpcProviderService} instead - */ -@Deprecated(forRemoval = true) -public interface RpcProviderRegistry extends RpcConsumerRegistry, - RouteChangePublisher> { - /** - * Registers a global implementation of the provided RPC service interface. - * All methods of the interface are required to be implemented. - * - * @param serviceInterface the YANG-generated interface of the RPC Service for which to register. - * @param implementation "the implementation of the RPC service interface. - * @return an RpcRegistration instance that should be used to unregister the RPC implementation - * when no longer needed by calling {@link RpcRegistration#close()}. - * - * @throws IllegalStateException - * if the supplied RPC interface is a routed RPC type. - */ - RpcRegistration addRpcImplementation(Class serviceInterface, T implementation) - throws IllegalStateException; - - /** - * Registers an implementation of the given routed RPC service interface. - * - *

- * See the {@link RpcProviderRegistry class} documentation for information and example on how to use routed RPCs. - * - * @param serviceInterface the YANG-generated interface of the RPC Service for which to register. - * @param implementation the implementation instance to register. - * @return a RoutedRpcRegistration instance which can be used to register paths for the RPC - * implementation via invoking RoutedRpcRegistration#registerPath(Class, InstanceIdentifer). - * {@link RoutedRpcRegistration#close()} should be called to unregister the implementation - * and all previously registered paths when no longer needed. - * @throws IllegalStateException if the supplied RPC interface is not a routed RPC type. - */ - RoutedRpcRegistration addRoutedRpcImplementation(Class serviceInterface, - T implementation) throws IllegalStateException; -} diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/package-info.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/package-info.java deleted file mode 100644 index 31eec6b5e8..0000000000 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/package-info.java +++ /dev/null @@ -1,9 +0,0 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.binding.api; - diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/rpc/RpcContextIdentifier.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/rpc/RpcContextIdentifier.java deleted file mode 100644 index 0f0eb119f7..0000000000 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/rpc/RpcContextIdentifier.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.binding.api.rpc; - -import org.opendaylight.yangtools.concepts.Immutable; -import org.opendaylight.yangtools.yang.binding.BaseIdentity; -import org.opendaylight.yangtools.yang.binding.RpcService; - -@Deprecated(forRemoval = true) -public final class RpcContextIdentifier implements Immutable { - - public final Class rpcService; - public final Class routingContext; - - private RpcContextIdentifier(Class rpcService, Class routingContext) { - this.rpcService = rpcService; - this.routingContext = routingContext; - } - - public Class getRpcService() { - return rpcService; - } - - public Class getRoutingContext() { - return routingContext; - } - - public static RpcContextIdentifier contextForGlobalRpc(Class serviceType) { - return new RpcContextIdentifier(serviceType, null); - } - - public static RpcContextIdentifier contextFor(Class serviceType, - Class routingContext) { - return new RpcContextIdentifier(serviceType, routingContext); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + (routingContext == null ? 0 : routingContext.hashCode()); - result = prime * result + (rpcService == null ? 0 : rpcService.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - RpcContextIdentifier other = (RpcContextIdentifier) obj; - if (routingContext == null) { - if (other.routingContext != null) { - return false; - } - } else if (!routingContext.equals(other.routingContext)) { - return false; - } - if (rpcService == null) { - if (other.rpcService != null) { - return false; - } - } else if (!rpcService.equals(other.rpcService)) { - return false; - } - return true; - } -} diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/rpc/RpcRoutingContext.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/rpc/RpcRoutingContext.java deleted file mode 100644 index 3f30cefc93..0000000000 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/rpc/RpcRoutingContext.java +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.binding.api.rpc; - -import org.opendaylight.yangtools.yang.binding.BaseIdentity; -import org.opendaylight.yangtools.yang.binding.RpcService; - -@Deprecated(forRemoval = true) -public interface RpcRoutingContext { - - Class getContextType(); - - Class getServiceType(); -} diff --git a/opendaylight/md-sal/sal-binding-broker/pom.xml b/opendaylight/md-sal/sal-binding-broker/pom.xml deleted file mode 100644 index da60d334b8..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/pom.xml +++ /dev/null @@ -1,165 +0,0 @@ - - - 4.0.0 - - org.opendaylight.controller - mdsal-parent - 1.12.0-SNAPSHOT - ../parent - - - org.opendaylight.controller - sal-binding-broker-impl - 1.12.0-SNAPSHOT - bundle - - - - org.opendaylight.controller - sal-binding-api - - - org.opendaylight.controller - sal-binding-util - - - org.opendaylight.controller - sal-broker-impl - compile - - - org.opendaylight.controller - sal-common-impl - - - org.opendaylight.controller - sal-common-util - - - org.opendaylight.controller - sal-core-api - - - org.opendaylight.mdsal - mdsal-binding-generator-impl - - - org.opendaylight.mdsal - mdsal-binding-dom-codec - - - org.opendaylight.mdsal - mdsal-binding-dom-adapter - - - org.opendaylight.yangtools - yang-data-impl - - - org.opendaylight.yangtools - yang-model-util - - - - - javax.inject - javax.inject - provided - true - - - - org.opendaylight.controller - sal-inmemory-datastore - - - - org.slf4j - slf4j-api - - - org.osgi - org.osgi.core - provided - - - org.mockito - mockito-core - test - - - com.google.truth - truth - test - - - - org.opendaylight.controller - sal-test-model - test - - - org.slf4j - slf4j-simple - test - - - - - - - - org.apache.felix - maven-bundle-plugin - true - - - ${project.groupId}.${project.artifactId} - - org.opendaylight.controller.sal.binding.impl, - org.opendaylight.controller.md.sal.binding.impl, - org.opendaylight.controller.md.sal.binding.compat, - org.opendaylight.controller.md.sal.binding.spi, - org.opendaylight.controller.sal.binding.codegen.impl, - - - - - - - org.apache.maven.plugins - maven-jar-plugin - - - - test-jar - - - - - - org.apache.maven.plugins - maven-source-plugin - - - attach-sources - verify - - test-jar - - - - - - - - - scm:git:http://git.opendaylight.org/gerrit/controller.git - scm:git:ssh://git.opendaylight.org:29418/controller.git - HEAD - https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL - - - diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/.gitignore b/opendaylight/md-sal/sal-binding-broker/src/main/.gitignore deleted file mode 100644 index 04b73cb01e..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/xtend-gen diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/AbstractNotificationListenerRegistration.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/AbstractNotificationListenerRegistration.java deleted file mode 100644 index 1cfe9c4591..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/AbstractNotificationListenerRegistration.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.compat; - -import static java.util.Objects.requireNonNull; - -import org.opendaylight.controller.sal.binding.api.NotificationListener; -import org.opendaylight.yangtools.concepts.AbstractListenerRegistration; -import org.opendaylight.yangtools.yang.binding.Notification; - -/** - * Abstract implementation of {@link NotificationListenerRegistration}. - * - * @param Notification type - */ -@Deprecated(forRemoval = true) -abstract class AbstractNotificationListenerRegistration - extends AbstractListenerRegistration> implements NotificationListenerRegistration { - private final Class type; - - protected AbstractNotificationListenerRegistration(final Class type, - final NotificationListener listener) { - super(listener); - this.type = requireNonNull(type); - } - - @Override - public Class getType() { - return type; - } - - @Override - @SuppressWarnings("unchecked") - public void notify(final Notification notification) { - if (!isClosed()) { - getInstance().onNotification((T)notification); - } - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/AggregatedNotificationListenerRegistration.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/AggregatedNotificationListenerRegistration.java deleted file mode 100644 index 1979b222c8..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/AggregatedNotificationListenerRegistration.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.compat; - -import static java.util.Objects.requireNonNull; - -import org.opendaylight.controller.sal.binding.api.NotificationListener; -import org.opendaylight.yangtools.yang.binding.Notification; - -/** - * An aggregated listener registration. This is a result of registering an invoker which can handle multiple - * interfaces at the same time. In order to support correct delivery, we need to maintain per-type registrations - * which get squashed if a notification which implements multiple interfaces is encountered. - * - *

- * We take care of that by implementing alternate {@link #hashCode()}/{@link #equals(Object)}, which resolve - * to the backing aggregator. - * - * @param Notification type - * @param Aggregator type - */ -@Deprecated(forRemoval = true) -abstract class AggregatedNotificationListenerRegistration - extends AbstractNotificationListenerRegistration { - private final A aggregator; - - protected AggregatedNotificationListenerRegistration(final Class type, - final NotificationListener listener, final A aggregator) { - super(type, listener); - this.aggregator = requireNonNull(aggregator); - } - - protected A getAggregator() { - return aggregator; - } - - @Override - public int hashCode() { - return aggregator.hashCode(); - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (!this.getClass().equals(obj.getClass())) { - return false; - } - - return aggregator.equals(((AggregatedNotificationListenerRegistration)obj).aggregator); - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/CompositeRoutedRpcRegistration.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/CompositeRoutedRpcRegistration.java deleted file mode 100644 index c889b17a6c..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/CompositeRoutedRpcRegistration.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.compat; - -import com.google.common.collect.ImmutableSet; -import java.util.HashMap; -import java.util.Map; -import org.opendaylight.controller.md.sal.binding.impl.BindingDOMRpcProviderServiceAdapter; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration; -import org.opendaylight.yangtools.concepts.ObjectRegistration; -import org.opendaylight.yangtools.yang.binding.BaseIdentity; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.binding.RpcService; - -@Deprecated(forRemoval = true) -final class CompositeRoutedRpcRegistration implements RoutedRpcRegistration { - - private final Class type; - private final T instance; - private final BindingDOMRpcProviderServiceAdapter adapter; - private final Map, ObjectRegistration> registrations = new HashMap<>(2); - - CompositeRoutedRpcRegistration(final Class type, final T impl, - final BindingDOMRpcProviderServiceAdapter providerAdapter) { - this.type = type; - this.instance = impl; - this.adapter = providerAdapter; - } - - @Override - public Class getServiceType() { - return type; - } - - @Override - public T getInstance() { - return instance; - } - - @Deprecated - @Override - public void registerInstance(final Class context, final InstanceIdentifier path) { - registerPath(context, path); - } - - @Override - public synchronized void registerPath(final Class context, - final InstanceIdentifier path) { - if (!registrations.containsKey(path)) { - registrations.put(path, - adapter.registerRpcImplementation(type, instance, ImmutableSet.>of(path))); - } - } - - - @Override - @Deprecated - public void unregisterInstance(final Class context, final InstanceIdentifier path) { - unregisterPath(context, path); - } - - @Override - public synchronized void unregisterPath(final Class context, - final InstanceIdentifier path) { - final ObjectRegistration reg = registrations.remove(path); - if (reg != null) { - reg.close(); - } - } - - @Override - public synchronized void close() { - for (final ObjectRegistration reg : registrations.values()) { - reg.close(); - } - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/DelegatedRootRpcRegistration.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/DelegatedRootRpcRegistration.java deleted file mode 100644 index 52d4425921..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/DelegatedRootRpcRegistration.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.compat; - -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration; -import org.opendaylight.yangtools.concepts.ObjectRegistration; -import org.opendaylight.yangtools.yang.binding.RpcService; - -@Deprecated(forRemoval = true) -final class DelegatedRootRpcRegistration implements RpcRegistration { - - private final ObjectRegistration delegate; - private final Class type; - - DelegatedRootRpcRegistration(final Class type, final ObjectRegistration impl) { - this.delegate = impl; - this.type = type; - } - - - @Override - public void close() { - delegate.close(); - } - - @Override - public T getInstance() { - return delegate.getInstance(); - } - - @Override - public Class getServiceType() { - return type; - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/FunctionalNotificationListenerAdapter.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/FunctionalNotificationListenerAdapter.java deleted file mode 100644 index 49734f6bd3..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/FunctionalNotificationListenerAdapter.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.compat; - -import org.opendaylight.controller.md.sal.binding.impl.LazySerializedDOMNotification; -import org.opendaylight.controller.md.sal.dom.api.DOMNotification; -import org.opendaylight.controller.md.sal.dom.api.DOMNotificationListener; -import org.opendaylight.controller.sal.binding.api.NotificationListener; -import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer; -import org.opendaylight.yangtools.yang.binding.Notification; - -@Deprecated(forRemoval = true) -final class FunctionalNotificationListenerAdapter implements DOMNotificationListener { - - private final BindingNormalizedNodeSerializer codec; - private final NotificationListener delegate; - private final Class type; - - FunctionalNotificationListenerAdapter(final BindingNormalizedNodeSerializer codec, final Class type, - final NotificationListener delegate) { - this.codec = codec; - this.type = type; - this.delegate = delegate; - } - - @Override - public void onNotification(final DOMNotification notification) { - delegate.onNotification(type.cast(deserialize(notification))); - } - - private Notification deserialize(final DOMNotification notification) { - if (notification instanceof LazySerializedDOMNotification) { - return ((LazySerializedDOMNotification) notification).getBindingData(); - } - return codec.fromNormalizedNodeNotification(notification.getType(), notification.getBody()); - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/HeliumNotificationProviderServiceAdapter.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/HeliumNotificationProviderServiceAdapter.java deleted file mode 100644 index 3a2812d63d..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/HeliumNotificationProviderServiceAdapter.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.compat; - -import java.util.concurrent.ExecutorService; -import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; -import org.opendaylight.controller.md.sal.binding.api.NotificationService; -import org.opendaylight.controller.sal.binding.api.NotificationProviderService; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.binding.Notification; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@Deprecated(forRemoval = true) -public class HeliumNotificationProviderServiceAdapter extends HeliumNotificationServiceAdapter - implements NotificationProviderService { - private static final Logger LOG = LoggerFactory.getLogger(HeliumNotificationProviderServiceAdapter.class); - - private final NotificationPublishService notificationPublishService; - - public HeliumNotificationProviderServiceAdapter(final NotificationPublishService notificationPublishService, - final NotificationService notificationService) { - super(notificationService); - this.notificationPublishService = notificationPublishService; - } - - @Override - public void publish(final Notification notification) { - try { - notificationPublishService.putNotification(notification); - } catch (InterruptedException e) { - LOG.error("Notification publication was interupted", e); - } - } - - @Override - public void publish(final Notification notification, final ExecutorService executor) { - try { - notificationPublishService.putNotification(notification); - } catch (InterruptedException e) { - LOG.error("Notification publication was interupted", e); - } - } - - @Override - public ListenerRegistration registerInterestListener( - final NotificationInterestListener interestListener) { - throw new UnsupportedOperationException("InterestListener is not supported."); - } - - @Override - public void close() { - - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/HeliumNotificationProviderServiceWithInterestListeners.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/HeliumNotificationProviderServiceWithInterestListeners.java deleted file mode 100644 index 88ba4ea482..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/HeliumNotificationProviderServiceWithInterestListeners.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.compat; - -import com.google.common.collect.Sets; -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; -import java.util.Collections; -import java.util.Iterator; -import java.util.Set; -import org.opendaylight.controller.md.sal.binding.impl.BindingDOMNotificationPublishServiceAdapter; -import org.opendaylight.controller.md.sal.binding.impl.BindingDOMNotificationServiceAdapter; -import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec; -import org.opendaylight.controller.md.sal.dom.api.DOMNotificationService; -import org.opendaylight.controller.md.sal.dom.spi.DOMNotificationSubscriptionListener; -import org.opendaylight.controller.md.sal.dom.spi.DOMNotificationSubscriptionListenerRegistry; -import org.opendaylight.controller.sal.binding.api.NotificationListener; -import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections; -import org.opendaylight.yangtools.concepts.AbstractListenerRegistration; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.util.ListenerRegistry; -import org.opendaylight.yangtools.yang.binding.Notification; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@Deprecated(forRemoval = true) -public class HeliumNotificationProviderServiceWithInterestListeners extends HeliumNotificationProviderServiceAdapter { - - private static final Logger LOG = LoggerFactory.getLogger( - HeliumNotificationProviderServiceWithInterestListeners.class); - - private final ListenerRegistry interestListeners = ListenerRegistry.create(); - private final ListenerRegistration domListener; - private final DOMNotificationService domService; - private final BindingToNormalizedNodeCodec codec; - - public HeliumNotificationProviderServiceWithInterestListeners( - final BindingDOMNotificationPublishServiceAdapter publishService, - final BindingDOMNotificationServiceAdapter listenService, - final DOMNotificationSubscriptionListenerRegistry registry) { - super(publishService, listenService); - this.codec = publishService.getCodecRegistry(); - this.domListener = registry.registerSubscriptionListener(new Listener()); - this.domService = listenService.getDomService(); - } - - @Override - public ListenerRegistration registerInterestListener( - final NotificationInterestListener listener) { - notifyListener(listener, translate(domListener.getInstance().getAllObserved())); - return interestListeners.register(listener); - } - - private Set> translate(final Set added) { - return codec.getNotificationClasses(added); - } - - @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", - justification = "https://github.com/spotbugs/spotbugs/issues/811") - @SuppressWarnings("checkstyle:IllegalCatch") - private void notifyAllListeners(final Set added) { - final Iterator> listeners = - interestListeners.getRegistrations().iterator(); - if (listeners.hasNext()) { - final Set> baEvent = translate(added); - while (listeners.hasNext()) { - final NotificationInterestListener listenerRef = listeners.next().getInstance(); - try { - notifyListener(listenerRef, baEvent); - } catch (RuntimeException e) { - LOG.warn("Unhandled exception during invoking listener {}", listenerRef, e); - } - } - } - } - - @Override - public ListenerRegistration> registerNotificationListener( - final Class type, final NotificationListener listener) { - - final FunctionalNotificationListenerAdapter 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>(listener) { - @Override - protected void removeRegistration() { - domReg.close(); - } - }; - } - - private static void notifyListener(final NotificationInterestListener listener, - final Set> baEvent) { - for (final Class event: baEvent) { - listener.onNotificationSubscribtion(event); - } - } - - private final class Listener implements DOMNotificationSubscriptionListener { - - private volatile Set allObserved = Collections.emptySet(); - - @Override - public void onSubscriptionChanged(final Set currentTypes) { - final Set added = Sets.difference(currentTypes, allObserved).immutableCopy(); - notifyAllListeners(added); - allObserved = Sets.union(allObserved, added).immutableCopy(); - } - - Set getAllObserved() { - return allObserved; - } - } - - @Override - public void close() { - super.close(); - domListener.close(); - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/HeliumNotificationServiceAdapter.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/HeliumNotificationServiceAdapter.java deleted file mode 100644 index c0c898926a..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/HeliumNotificationServiceAdapter.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.compat; - -import org.opendaylight.controller.md.sal.binding.api.NotificationService; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.binding.Notification; -import org.opendaylight.yangtools.yang.binding.NotificationListener; - -@Deprecated(forRemoval = true) -public class HeliumNotificationServiceAdapter - implements org.opendaylight.controller.sal.binding.api.NotificationService, AutoCloseable { - - private final NotificationService notificationService; - - public HeliumNotificationServiceAdapter(NotificationService notificationService) { - this.notificationService = notificationService; - } - - @Override - public ListenerRegistration< - org.opendaylight.controller.sal.binding.api.NotificationListener> registerNotificationListener( - final Class notificationType, - final org.opendaylight.controller.sal.binding.api.NotificationListener listener) { - throw new UnsupportedOperationException("Not supported type of listener."); - } - - @Override - public ListenerRegistration registerNotificationListener( - final NotificationListener listener) { - return notificationService.registerNotificationListener(listener); - } - - @Override - public void close() throws Exception { - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/HeliumRpcProviderRegistry.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/HeliumRpcProviderRegistry.java deleted file mode 100644 index 4f08a17305..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/HeliumRpcProviderRegistry.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.compat; - -import org.opendaylight.controller.md.sal.binding.impl.BindingDOMRpcProviderServiceAdapter; -import org.opendaylight.controller.md.sal.common.api.routing.RouteChangeListener; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration; -import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry; -import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; -import org.opendaylight.controller.sal.binding.api.rpc.RpcContextIdentifier; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.concepts.ObjectRegistration; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.binding.RpcService; - -@Deprecated(forRemoval = true) -public class HeliumRpcProviderRegistry implements RpcProviderRegistry { - - private final RpcConsumerRegistry consumerRegistry; - private final BindingDOMRpcProviderServiceAdapter providerAdapter; - - public HeliumRpcProviderRegistry(final RpcConsumerRegistry consumerRegistry, - final BindingDOMRpcProviderServiceAdapter providerAdapter) { - this.consumerRegistry = consumerRegistry; - this.providerAdapter = providerAdapter; - } - - @Override - public RoutedRpcRegistration addRoutedRpcImplementation(final Class type, final T impl) - throws IllegalStateException { - return new CompositeRoutedRpcRegistration<>(type,impl,providerAdapter); - } - - @Override - public RpcRegistration addRpcImplementation(final Class type, final T impl) - throws IllegalStateException { - final ObjectRegistration reg = providerAdapter.registerRpcImplementation(type, impl); - return new DelegatedRootRpcRegistration<>(type,reg); - } - - @Override - public T getRpcService(final Class type) { - return consumerRegistry.getRpcService(type); - } - - @Override - public >> ListenerRegistration - registerRouteChangeListener(final L listener) { - // FIXME: Implement this only if necessary - return null; - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/ListenerMapGeneration.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/ListenerMapGeneration.java deleted file mode 100644 index 7b56408342..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/ListenerMapGeneration.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.compat; - -import com.google.common.cache.CacheBuilder; -import com.google.common.cache.CacheLoader; -import com.google.common.cache.LoadingCache; -import com.google.common.collect.ImmutableMultimap; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Multimap; -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; -import java.util.stream.Collectors; -import org.opendaylight.yangtools.yang.binding.Notification; - -/** - * An immutable view of the current generation of listeners. - */ -@Deprecated(forRemoval = true) -final class ListenerMapGeneration { - private static final int CACHE_MAX_ENTRIES = 1000; - - /** - * Constant map of notification type to subscribed listeners. - */ - private final Multimap, NotificationListenerRegistration> typeToListeners; - - /** - * Dynamic cache of notification implementation to matching listeners. This cache loads entries based on - * the contents of the {@link #typeToListeners} map. - */ - private final LoadingCache, Iterable>> implementationToListeners = - CacheBuilder.newBuilder() - .weakKeys() - .maximumSize(CACHE_MAX_ENTRIES) - .build(new CacheLoader, Iterable>>() { - @Override - public Iterable> load(final Class key) { - final Set> regs = new HashSet<>(); - - for (final Class type : getNotificationTypes(key)) { - @SuppressWarnings("unchecked") - final Collection> l = - typeToListeners.get((Class) type); - if (l != null) { - regs.addAll(l); - } - } - - return ImmutableSet.copyOf(regs); - } - }); - - ListenerMapGeneration() { - typeToListeners = ImmutableMultimap.of(); - } - - ListenerMapGeneration(final Multimap, - NotificationListenerRegistration> listeners) { - this.typeToListeners = ImmutableMultimap.copyOf(listeners); - } - - /** - * Current listeners. Exposed for creating the next generation. - * - * @return Current type-to-listener map. - */ - Multimap, NotificationListenerRegistration> getListeners() { - return typeToListeners; - } - - /** - * Look up the listeners which need to see this notification delivered. - * - * @param notification Notification object - * @return Iterable of listeners, guaranteed to be nonnull. - */ - public Iterable> listenersFor(final Notification notification) { - // Safe to use, as our loader does not throw checked exceptions - return implementationToListeners.getUnchecked(notification.getClass()); - } - - public Iterable> getKnownTypes() { - return typeToListeners.keySet(); - } - - @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", - justification = "https://github.com/spotbugs/spotbugs/issues/811") - private static Iterable> getNotificationTypes(final Class cls) { - return Arrays.stream(cls.getInterfaces()) - .filter(input -> !Notification.class.equals(input) && Notification.class.isAssignableFrom(input)) - .collect(Collectors.toList()); - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/NotificationInvoker.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/NotificationInvoker.java deleted file mode 100644 index 6f60ef44f0..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/NotificationInvoker.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.compat; - -import com.google.common.collect.ImmutableMap; -import com.google.common.reflect.TypeToken; -import java.lang.reflect.Method; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import org.opendaylight.mdsal.binding.dom.adapter.invoke.NotificationListenerInvoker; -import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections; -import org.opendaylight.yangtools.yang.binding.Notification; -import org.opendaylight.yangtools.yang.binding.NotificationListener; -import org.opendaylight.yangtools.yang.common.QName; - -@Deprecated(forRemoval = true) -final class NotificationInvoker - implements org.opendaylight.controller.sal.binding.api.NotificationListener { - - private final NotificationListener delegate; - private final Map,InvokerContext> invokers; - - - private NotificationInvoker(final NotificationListener listener) { - delegate = listener; - final Map, InvokerContext> builder = new HashMap<>(); - for (final TypeToken ifaceToken : TypeToken.of(listener.getClass()).getTypes().interfaces()) { - final Class iface = ifaceToken.getRawType(); - if (NotificationListener.class.isAssignableFrom(iface) && BindingReflections.isBindingClass(iface)) { - @SuppressWarnings("unchecked") - final Class listenerType = - (Class) iface; - final NotificationListenerInvoker invoker = NotificationListenerInvoker.from(listenerType); - for (final Class type : getNotificationTypes(listenerType)) { - builder.put(type, new InvokerContext(BindingReflections.findQName(type), invoker)); - } - } - } - invokers = ImmutableMap.copyOf(builder); - } - - public static NotificationInvoker invokerFor(final NotificationListener listener) { - return new NotificationInvoker(listener); - } - - public Set> getSupportedNotifications() { - return invokers.keySet(); - } - - @Override - public void onNotification(final Notification notification) { - getContext(notification.implementedInterface()).invoke(notification); - } - - private InvokerContext getContext(final Class type) { - return invokers.get(type); - } - - @SuppressWarnings("unchecked") - private static Set> getNotificationTypes( - final Class type) { - // TODO: Investigate possibility and performance impact if we cache this or expose - // it from NotificationListenerInvoker - final Set> ret = new HashSet<>(); - for (final Method method : type.getMethods()) { - if (BindingReflections.isNotificationCallback(method)) { - final Class notification = - (Class) method.getParameterTypes()[0]; - ret.add(notification); - } - } - return ret; - } - - private final class InvokerContext { - - private final QName name; - private final NotificationListenerInvoker invoker; - - private InvokerContext(final QName name, final NotificationListenerInvoker invoker) { - this.name = name; - this.invoker = invoker; - } - - public void invoke(final Notification notification) { - invoker.invokeNotification(delegate, name, notification); - } - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/NotificationListenerRegistration.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/NotificationListenerRegistration.java deleted file mode 100644 index 86279b410d..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/NotificationListenerRegistration.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.compat; - -import org.opendaylight.controller.sal.binding.api.NotificationListener; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.binding.Notification; - -/** - * A registration of a {@link NotificationListener}. Allows query of the type - * of the notification and dispatching the notification atomically with regard - * to unregistration. - * - * @param Type of notification - */ -@Deprecated(forRemoval = true) -interface NotificationListenerRegistration - extends ListenerRegistration> { - /** - * Return the interface class of the notification type. - * - * @return Notification type. - */ - Class getType(); - - /** - * Dispatch a notification to the listener. - * - * @param notification Notification to be dispatched - */ - void notify(Notification notification); -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/AbstractForwardedDataBroker.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/AbstractForwardedDataBroker.java deleted file mode 100644 index 03b7bae3f5..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/AbstractForwardedDataBroker.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.impl; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Optional; -import java.util.Set; -import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; -import org.opendaylight.mdsal.dom.api.DOMSchemaService; -import org.opendaylight.yangtools.concepts.Delegator; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.data.impl.codec.DeserializationException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@Deprecated(forRemoval = true) -public abstract class AbstractForwardedDataBroker implements Delegator, AutoCloseable { - - private static final Logger LOG = LoggerFactory.getLogger(AbstractForwardedDataBroker.class); - // The Broker to whom we do all forwarding - private final DOMDataBroker domDataBroker; - - private final BindingToNormalizedNodeCodec codec; - - protected AbstractForwardedDataBroker(final DOMDataBroker domDataBroker, final BindingToNormalizedNodeCodec codec, - final DOMSchemaService schemaService) { - this.domDataBroker = domDataBroker; - this.codec = codec; - } - - protected AbstractForwardedDataBroker(final DOMDataBroker domDataBroker, final BindingToNormalizedNodeCodec codec) { - this.domDataBroker = domDataBroker; - this.codec = codec; - } - - protected BindingToNormalizedNodeCodec getCodec() { - return codec; - } - - @Override - public DOMDataBroker getDelegate() { - return domDataBroker; - } - - protected Map, DataObject> toBinding(final InstanceIdentifier path, - final Map> normalized) { - final Map, DataObject> newMap = new HashMap<>(); - - for (final Map.Entry> entry : normalized.entrySet()) { - try { - final Optional, DataObject>> potential = - getCodec().toBinding(entry); - if (potential.isPresent()) { - final Entry, DataObject> binding = potential.get(); - newMap.put(binding.getKey(), binding.getValue()); - } - } catch (final DeserializationException e) { - LOG.warn("Failed to transform {}, omitting it", entry, e); - } - } - return newMap; - } - - protected Set> toBinding(final InstanceIdentifier path, - final Set normalized) { - final Set> hashSet = new HashSet<>(); - for (final YangInstanceIdentifier normalizedPath : normalized) { - try { - final Optional> potential = - getCodec().toBinding(normalizedPath); - if (potential.isPresent()) { - final InstanceIdentifier binding = potential.get(); - hashSet.add(binding); - } else if (normalizedPath.getLastPathArgument() - instanceof YangInstanceIdentifier.AugmentationIdentifier) { - hashSet.add(path); - } - } catch (final DeserializationException e) { - LOG.warn("Failed to transform {}, omitting it", normalizedPath, e); - } - } - return hashSet; - } - - protected Optional toBindingData(final InstanceIdentifier path, final NormalizedNode data) { - if (path.isWildcarded()) { - return Optional.empty(); - } - return (Optional) getCodec().deserializeFunction(path) - .apply(Optional.>of(data)); - } - - @Override - public void close() { - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/AbstractForwardedTransaction.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/AbstractForwardedTransaction.java deleted file mode 100644 index 328790b418..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/AbstractForwardedTransaction.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.impl; - -import static java.util.Objects.requireNonNull; - -import com.google.common.base.Optional; -import com.google.common.base.Preconditions; -import com.google.common.util.concurrent.CheckedFuture; -import com.google.common.util.concurrent.Futures; -import com.google.common.util.concurrent.MoreExecutors; -import org.opendaylight.controller.md.sal.common.api.MappingCheckedFuture; -import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; -import org.opendaylight.controller.md.sal.dom.api.DOMDataReadTransaction; -import org.opendaylight.yangtools.concepts.Delegator; -import org.opendaylight.yangtools.concepts.Identifiable; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; - -@Deprecated(forRemoval = true) -abstract class AbstractForwardedTransaction>> - implements Delegator, Identifiable { - - private final T delegate; - private final BindingToNormalizedNodeCodec codec; - - AbstractForwardedTransaction(final T delegateTx, final BindingToNormalizedNodeCodec codec) { - this.delegate = requireNonNull(delegateTx, "Delegate must not be null"); - this.codec = requireNonNull(codec, "Codec must not be null"); - } - - @Override - public final Object getIdentifier() { - return delegate.getIdentifier(); - } - - @Override - public final T getDelegate() { - return delegate; - } - - @SuppressWarnings("unchecked") - protected final >> - S getDelegateChecked(final Class txType) { - Preconditions.checkState(txType.isInstance(delegate)); - return (S) delegate; - } - - protected final BindingToNormalizedNodeCodec getCodec() { - return codec; - } - - protected final CheckedFuture, ReadFailedException> doRead( - final DOMDataReadTransaction readTx, final LogicalDatastoreType store, - final InstanceIdentifier path) { - Preconditions.checkArgument(!path.isWildcarded(), "Invalid read of wildcarded path %s", path); - - return MappingCheckedFuture.create( - Futures.transform(readTx.read(store, codec.toYangInstanceIdentifierBlocking(path)), - result -> Optional.fromJavaUtil(codec.deserializeFunction(path).apply(result.toJavaUtil())), - MoreExecutors.directExecutor()), - ReadFailedException.MAPPER); - } - - protected final CheckedFuture doExists( - final DOMDataReadTransaction readTx, final LogicalDatastoreType store, - final InstanceIdentifier path) { - Preconditions.checkArgument(!path.isWildcarded(), "Invalid read of wildcarded path %s", path); - - return MappingCheckedFuture.create(readTx.exists(store, codec.toYangInstanceIdentifierBlocking(path)), - ReadFailedException.MAPPER); - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/AbstractReadWriteTransaction.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/AbstractReadWriteTransaction.java deleted file mode 100644 index 67dfd82fcf..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/AbstractReadWriteTransaction.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.impl; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; -import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizationException; -import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizationOperation; -import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@Deprecated(forRemoval = true) -public class AbstractReadWriteTransaction extends AbstractWriteTransaction { - - private static final Logger LOG = LoggerFactory.getLogger(AbstractReadWriteTransaction.class); - - public AbstractReadWriteTransaction(final DOMDataReadWriteTransaction delegate, - final BindingToNormalizedNodeCodec codec) { - super(delegate, codec); - } - - @Override - protected final void ensureParentsByMerge(final LogicalDatastoreType store, - final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier normalizedPath, - final InstanceIdentifier path) { - List currentArguments = new ArrayList<>(); - DataNormalizationOperation currentOp = getCodec().getDataNormalizer().getRootOperation(); - Iterator iterator = normalizedPath.getPathArguments().iterator(); - while (iterator.hasNext()) { - PathArgument currentArg = iterator.next(); - try { - currentOp = currentOp.getChild(currentArg); - } catch (DataNormalizationException e) { - throw new IllegalArgumentException(String.format("Invalid child encountered in path %s", path), e); - } - currentArguments.add(currentArg); - org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier currentPath = - org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.create(currentArguments); - - final Boolean exists; - try { - exists = getDelegate().exists(store, currentPath).checkedGet(); - } catch (ReadFailedException e) { - LOG.error("Failed to read pre-existing data from store {} path {}", store, currentPath, e); - throw new IllegalStateException("Failed to read pre-existing data", e); - } - - if (!exists && iterator.hasNext()) { - getDelegate().merge(store, currentPath, currentOp.createDefault(currentArg)); - } - } - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/AbstractWriteTransaction.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/AbstractWriteTransaction.java deleted file mode 100644 index a01b927f86..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/AbstractWriteTransaction.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.impl; - -import static com.google.common.base.Preconditions.checkArgument; - -import com.google.common.base.Optional; -import com.google.common.util.concurrent.FluentFuture; -import java.util.Map.Entry; -import org.gaul.modernizer_maven_annotations.SuppressModernizer; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction; -import org.opendaylight.mdsal.common.api.CommitInfo; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.Identifiable; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; - -/** - * Abstract Base Transaction for transactions which are backed by {@link DOMDataWriteTransaction}. - */ -@Deprecated(forRemoval = true) -public abstract class AbstractWriteTransaction extends - AbstractForwardedTransaction { - - protected AbstractWriteTransaction(final T delegate, final BindingToNormalizedNodeCodec codec) { - super(delegate, codec); - } - - public final void put(final LogicalDatastoreType store, - final InstanceIdentifier path, final U data, final boolean createParents) { - checkArgument(!path.isWildcarded(), "Cannot put data into wildcarded path %s", path); - - final Entry> normalized = getCodec().toNormalizedNode(path, data); - if (createParents) { - ensureParentsByMerge(store, normalized.getKey(), path); - } else { - ensureListParentIfNeeded(store,path,normalized); - } - - getDelegate().put(store, normalized.getKey(), normalized.getValue()); - } - - public final void merge(final LogicalDatastoreType store, - final InstanceIdentifier path, final U data,final boolean createParents) { - checkArgument(!path.isWildcarded(), "Cannot merge data into wildcarded path %s", path); - - final Entry> normalized = getCodec().toNormalizedNode(path, data); - if (createParents) { - ensureParentsByMerge(store, normalized.getKey(), path); - } else { - ensureListParentIfNeeded(store,path,normalized); - } - - getDelegate().merge(store, normalized.getKey(), normalized.getValue()); - } - - /** - * Ensures list parent if item is list, otherwise noop. - * - *

- * One of properties of binding specification is that it is imposible - * to represent list as a whole and thus it is impossible to write - * empty variation of MapNode without creating parent node, with - * empty list. - * - *

- * This actually makes writes such as - *

-     * put("Nodes", new NodesBuilder().build());
-     * put("Nodes/Node[key]", new NodeBuilder().setKey("key").build());
-     * 
- * To result in three DOM operations: - *
-     * put("/nodes",domNodes);
-     * merge("/nodes/node",domNodeList);
-     * put("/nodes/node/node[key]",domNode);
-     * 
- * - *

- * In order to allow that to be inserted if necessary, if we know - * item is list item, we will try to merge empty MapNode or OrderedNodeMap - * to ensure list exists. - * - * @param store Data Store type - * @param path Path to data (Binding Aware) - * @param normalized Normalized version of data to be written - */ - private void ensureListParentIfNeeded(final LogicalDatastoreType store, final InstanceIdentifier path, - final Entry> normalized) { - if (Identifiable.class.isAssignableFrom(path.getTargetType())) { - YangInstanceIdentifier parentMapPath = normalized.getKey().getParent(); - checkArgument(parentMapPath != null, "Map path %s does not have a parent", path); - - NormalizedNode emptyParent = getCodec().getDefaultNodeFor(parentMapPath); - getDelegate().merge(store, parentMapPath, emptyParent); - } - } - - /** - * Deprecated. - * - * @deprecated Use {@link YangInstanceIdentifier#getParent()} instead. - */ - @Deprecated - @SuppressModernizer - protected static Optional getParent(final YangInstanceIdentifier child) { - return Optional.fromNullable(child.getParent()); - } - - /** - * Subclasses of this class are required to implement creation of parent - * nodes based on behaviour of their underlying transaction. - */ - protected abstract void ensureParentsByMerge(LogicalDatastoreType store, - YangInstanceIdentifier key, InstanceIdentifier path); - - protected final void doDelete(final LogicalDatastoreType store, - final InstanceIdentifier path) { - checkArgument(!path.isWildcarded(), "Cannot delete wildcarded path %s", path); - - final YangInstanceIdentifier normalized = getCodec().toYangInstanceIdentifierBlocking(path); - getDelegate().delete(store, normalized); - } - - protected final FluentFuture doCommit() { - return getDelegate().commit(); - } - - protected final boolean doCancel() { - return getDelegate().cancel(); - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingBrokerWiring.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingBrokerWiring.java deleted file mode 100644 index ceb1041901..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingBrokerWiring.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright (c) 2018 Red Hat, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.impl; - -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.MountPointService; -import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; -import org.opendaylight.controller.md.sal.binding.api.NotificationService; -import org.opendaylight.controller.md.sal.binding.compat.HeliumNotificationProviderServiceWithInterestListeners; -import org.opendaylight.controller.md.sal.binding.compat.HeliumRpcProviderRegistry; -import org.opendaylight.controller.md.sal.binding.spi.AdapterFactory; -import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; -import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService; -import org.opendaylight.controller.md.sal.dom.api.DOMNotificationPublishService; -import org.opendaylight.controller.md.sal.dom.api.DOMNotificationService; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcProviderService; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcService; -import org.opendaylight.controller.md.sal.dom.spi.DOMNotificationSubscriptionListenerRegistry; -import org.opendaylight.controller.sal.binding.api.NotificationProviderService; -import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; -import org.opendaylight.mdsal.binding.dom.codec.impl.BindingNormalizedNodeCodecRegistry; -import org.opendaylight.mdsal.binding.generator.api.ClassLoadingStrategy; -import org.opendaylight.mdsal.dom.api.DOMSchemaService; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.model.api.SchemaContextListener; - -/** - * Provides the implementations of the APIs. - * - *

Intended to be usable in a standalone environment (non-OSGi/Karaf). Also - * internally used by the Blueprint XML to expose the same as OSGi services. - * This class does not require (depend on) the Guice dependency injection - * framework, but can we used with it. - * - * @author Michael Vorburger.ch, partially based on refactored code originally by Thomas Pantelis - */ -@Deprecated(forRemoval = true) -public class BindingBrokerWiring implements AutoCloseable { - - private final BindingToNormalizedNodeCodec bindingToNormalizedNodeCodec; - private final ListenerRegistration mappingCodecListenerReg; - private final RpcProviderRegistry rpcProviderRegistry; - private final MountPointService mountPointService; - private final NotificationService notificationService; - private final NotificationPublishService notificationPublishService; - private final HeliumNotificationProviderServiceWithInterestListeners notificationAndProviderService; - private final AdapterFactory adapterFactory; - private final DataBroker dataBroker; - private final DataBroker pingPongDataBroker; - - public BindingBrokerWiring(ClassLoadingStrategy classLoadingStrategy, DOMSchemaService schemaService, - DOMRpcService domRpcService, DOMRpcProviderService domRpcProviderService, - DOMMountPointService domMountPointService, DOMNotificationService domNotificationService, - DOMNotificationPublishService domNotificationPublishService, - DOMNotificationSubscriptionListenerRegistry domNotificationListenerRegistry, DOMDataBroker domDataBroker, - DOMDataBroker domPingPongDataBroker) { - // Runtime binding/normalized mapping service - BindingNormalizedNodeCodecRegistry codecRegistry = new BindingNormalizedNodeCodecRegistry(); - bindingToNormalizedNodeCodec = new BindingToNormalizedNodeCodec(classLoadingStrategy, codecRegistry, true); - - // Register the BindingToNormalizedNodeCodec with the SchemaService as a SchemaContextListener - mappingCodecListenerReg = schemaService.registerSchemaContextListener(bindingToNormalizedNodeCodec); - - // Binding RPC Registry Service - BindingDOMRpcServiceAdapter bindingDOMRpcServiceAdapter - = new BindingDOMRpcServiceAdapter(domRpcService, bindingToNormalizedNodeCodec); - BindingDOMRpcProviderServiceAdapter bindingDOMRpcProviderServiceAdapter - = new BindingDOMRpcProviderServiceAdapter(domRpcProviderService, bindingToNormalizedNodeCodec); - rpcProviderRegistry - = new HeliumRpcProviderRegistry(bindingDOMRpcServiceAdapter, bindingDOMRpcProviderServiceAdapter); - - // Binding MountPoint Service - mountPointService = new BindingDOMMountPointServiceAdapter(domMountPointService, bindingToNormalizedNodeCodec); - - // Binding Notification Service - BindingDOMNotificationServiceAdapter notificationServiceImpl = new BindingDOMNotificationServiceAdapter( - bindingToNormalizedNodeCodec.getCodecRegistry(), domNotificationService); - notificationService = notificationServiceImpl; - BindingDOMNotificationPublishServiceAdapter notificationPublishServiceImpl = - new BindingDOMNotificationPublishServiceAdapter( - bindingToNormalizedNodeCodec, domNotificationPublishService); - notificationPublishService = notificationPublishServiceImpl; - notificationAndProviderService = new HeliumNotificationProviderServiceWithInterestListeners( - notificationPublishServiceImpl, notificationServiceImpl, domNotificationListenerRegistry); - - adapterFactory = new BindingToDOMAdapterFactory(bindingToNormalizedNodeCodec); - - // Binding DataBroker - dataBroker = adapterFactory.createDataBroker(domDataBroker); - - // Binding PingPong DataBroker - pingPongDataBroker = adapterFactory.createDataBroker(domPingPongDataBroker); - } - - @Override - public void close() throws Exception { - mappingCodecListenerReg.close(); - } - - public BindingToNormalizedNodeCodec getBindingToNormalizedNodeCodec() { - return bindingToNormalizedNodeCodec; - } - - public AdapterFactory getAdapterFactory() { - return adapterFactory; - } - - public RpcProviderRegistry getRpcProviderRegistry() { - return rpcProviderRegistry; - } - - public MountPointService getMountPointService() { - return mountPointService; - } - - public NotificationService getNotificationService() { - return notificationService; - } - - public NotificationPublishService getNotificationPublishService() { - return notificationPublishService; - } - - @Deprecated - public NotificationProviderService getNotificationProviderService() { - return notificationAndProviderService; - } - - @Deprecated - public org.opendaylight.controller.sal.binding.api.NotificationService getDeprecatedNotificationService() { - return notificationAndProviderService; - } - - public DataBroker getDataBroker() { - return dataBroker; - } - - public DataBroker getPingPongDataBroker() { - return pingPongDataBroker; - } - -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingClusteredDOMDataTreeChangeListenerAdapter.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingClusteredDOMDataTreeChangeListenerAdapter.java deleted file mode 100644 index fc6d50c791..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingClusteredDOMDataTreeChangeListenerAdapter.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2015 Brocade Communications Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.impl; - -import org.opendaylight.controller.md.sal.binding.api.ClusteredDataTreeChangeListener; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.dom.api.ClusteredDOMDataTreeChangeListener; -import org.opendaylight.yangtools.yang.binding.DataObject; - -/** - * Adapter wrapping Binding {@link ClusteredDataTreeChangeListener} and exposing - * it as {@link ClusteredDOMDataTreeChangeListener} and translated DOM events - * to their Binding equivalent. - * - * @author Thomas Pantelis - */ -@Deprecated(forRemoval = true) -final class BindingClusteredDOMDataTreeChangeListenerAdapter - extends BindingDOMDataTreeChangeListenerAdapter implements ClusteredDOMDataTreeChangeListener { - BindingClusteredDOMDataTreeChangeListenerAdapter(BindingToNormalizedNodeCodec codec, - ClusteredDataTreeChangeListener listener, LogicalDatastoreType store) { - super(codec, listener, store); - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMAdapterBuilder.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMAdapterBuilder.java deleted file mode 100644 index eba1f6c8f4..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMAdapterBuilder.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.impl; - -import com.google.common.base.Preconditions; -import com.google.common.collect.ClassToInstanceMap; -import org.opendaylight.controller.md.sal.binding.api.BindingService; -import org.opendaylight.controller.md.sal.binding.spi.AdapterBuilder; -import org.opendaylight.controller.md.sal.dom.api.DOMService; - -@Deprecated(forRemoval = true) -abstract class BindingDOMAdapterBuilder extends AdapterBuilder { - - interface Factory { - - BindingDOMAdapterBuilder newBuilder(); - - } - - private BindingToNormalizedNodeCodec codec; - - public void setCodec(final BindingToNormalizedNodeCodec codec) { - this.codec = codec; - } - - @Override - protected final T createInstance(final ClassToInstanceMap delegates) { - Preconditions.checkState(codec != null); - return createInstance(codec,delegates); - } - - protected abstract T createInstance(BindingToNormalizedNodeCodec codec2, ClassToInstanceMap delegates); - -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMAdapterLoader.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMAdapterLoader.java deleted file mode 100644 index 17d5054709..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMAdapterLoader.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.impl; - -import com.google.common.base.Preconditions; -import com.google.common.collect.ImmutableMap; -import java.util.Map; -import org.opendaylight.controller.md.sal.binding.api.ActionProviderService; -import org.opendaylight.controller.md.sal.binding.api.ActionService; -import org.opendaylight.controller.md.sal.binding.api.BindingService; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; -import org.opendaylight.controller.md.sal.binding.api.NotificationService; -import org.opendaylight.controller.md.sal.binding.impl.BindingDOMAdapterBuilder.Factory; -import org.opendaylight.controller.md.sal.binding.spi.AdapterBuilder; -import org.opendaylight.controller.md.sal.binding.spi.AdapterLoader; -import org.opendaylight.controller.md.sal.dom.api.DOMService; -import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry; - -@Deprecated(forRemoval = true) -public abstract class BindingDOMAdapterLoader extends AdapterLoader { - private static final Map, BindingDOMAdapterBuilder.Factory> FACTORIES = - ImmutableMap., BindingDOMAdapterBuilder.Factory>builder() - .put(NotificationService.class, BindingDOMNotificationServiceAdapter.BUILDER_FACTORY) - .put(NotificationPublishService.class, BindingDOMNotificationPublishServiceAdapter.BUILDER_FACTORY) - .put(DataBroker.class, BindingDOMDataBrokerAdapter.BUILDER_FACTORY) - .put(RpcConsumerRegistry.class, BindingDOMRpcServiceAdapter.BUILDER_FACTORY) - .put(ActionProviderService.class, ControllerActionProviderServiceAdapter.BUILDER_FACTORY) - .put(ActionService.class, ControllerActionServiceAdapter.BUILDER_FACTORY) - .build(); - - private final BindingToNormalizedNodeCodec codec; - - public BindingDOMAdapterLoader(final BindingToNormalizedNodeCodec codec) { - this.codec = codec; - } - - @Override - protected final AdapterBuilder createBuilder( - final Class key) { - final Factory factory = FACTORIES.get(key); - Preconditions.checkArgument(factory != null, "Unsupported service type %s", key); - final BindingDOMAdapterBuilder builder = factory.newBuilder(); - builder.setCodec(codec); - return builder; - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMDataBrokerAdapter.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMDataBrokerAdapter.java deleted file mode 100644 index 0864bcda06..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMDataBrokerAdapter.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.impl; - -import com.google.common.collect.ClassToInstanceMap; -import com.google.common.collect.ImmutableSet; -import java.util.Set; -import org.opendaylight.controller.md.sal.binding.api.BindingTransactionChain; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener; -import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeService; -import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier; -import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; -import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.binding.impl.BindingDOMAdapterBuilder.Factory; -import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener; -import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; -import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeService; -import org.opendaylight.controller.md.sal.dom.api.DOMService; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.binding.DataObject; - -/** - * The DataBrokerImpl simply defers to the DOMDataBroker for all its operations. - * All transactions and listener registrations are wrapped by the DataBrokerImpl - * to allow binding aware components to use the DataBroker transparently. - * - *

- * Besides this the DataBrokerImpl and it's collaborators also cache data that - * is already transformed from the binding independent to binding aware format - */ -@Deprecated(forRemoval = true) -public class BindingDOMDataBrokerAdapter extends AbstractForwardedDataBroker - implements DataBroker, DataTreeChangeService { - static final Factory BUILDER_FACTORY = Builder::new; - private final DataTreeChangeService treeChangeService; - - public BindingDOMDataBrokerAdapter(final DOMDataBroker domDataBroker, final BindingToNormalizedNodeCodec codec) { - super(domDataBroker, codec); - final DOMDataTreeChangeService domTreeChange = (DOMDataTreeChangeService) domDataBroker - .getSupportedExtensions().get(DOMDataTreeChangeService.class); - if (domTreeChange != null) { - treeChangeService = BindingDOMDataTreeChangeServiceAdapter.create(codec, domTreeChange); - } else { - treeChangeService = null; - } - } - - @Override - - public ReadOnlyTransaction newReadOnlyTransaction() { - return new BindingDOMReadTransactionAdapter(getDelegate().newReadOnlyTransaction(),getCodec()); - } - - @Override - public ReadWriteTransaction newReadWriteTransaction() { - return new BindingDOMReadWriteTransactionAdapter(getDelegate().newReadWriteTransaction(),getCodec()); - } - - @Override - public WriteTransaction newWriteOnlyTransaction() { - return new BindingDOMWriteTransactionAdapter<>(getDelegate().newWriteOnlyTransaction(),getCodec()); - } - - @Override - public BindingTransactionChain createTransactionChain(final TransactionChainListener listener) { - return new BindingDOMTransactionChainAdapter(getDelegate(), getCodec(), listener); - } - - @Override - public String toString() { - return "BindingDOMDataBrokerAdapter for " + getDelegate(); - } - - private static class Builder extends BindingDOMAdapterBuilder { - - @Override - public Set> getRequiredDelegates() { - return ImmutableSet.of(DOMDataBroker.class); - } - - @Override - protected DataBroker createInstance(final BindingToNormalizedNodeCodec codec, - final ClassToInstanceMap delegates) { - final DOMDataBroker domDataBroker = delegates.getInstance(DOMDataBroker.class); - return new BindingDOMDataBrokerAdapter(domDataBroker, codec); - } - - } - - @Override - public > ListenerRegistration - registerDataTreeChangeListener(final DataTreeIdentifier treeId, final L listener) { - if (treeChangeService == null) { - throw new UnsupportedOperationException("Underlying data broker does not expose DOMDataTreeChangeService."); - } - return treeChangeService.registerDataTreeChangeListener(treeId, listener); - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMDataTreeChangeListenerAdapter.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMDataTreeChangeListenerAdapter.java deleted file mode 100644 index 1c504700a8..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMDataTreeChangeListenerAdapter.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.impl; - -import static java.util.Objects.requireNonNull; - -import java.util.Collection; -import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener; -import org.opendaylight.controller.md.sal.binding.api.DataTreeModification; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate; - -/** - * Adapter wrapping Binding {@link DataTreeChangeListener} and exposing - * it as {@link DOMDataTreeChangeListener} and translated DOM events - * to their Binding equivalent. - * - */ -@Deprecated(forRemoval = true) -class BindingDOMDataTreeChangeListenerAdapter implements DOMDataTreeChangeListener { - private final BindingToNormalizedNodeCodec codec; - private final DataTreeChangeListener listener; - private final LogicalDatastoreType store; - - BindingDOMDataTreeChangeListenerAdapter(final BindingToNormalizedNodeCodec codec, - final DataTreeChangeListener listener, final LogicalDatastoreType store) { - this.codec = requireNonNull(codec); - this.listener = requireNonNull(listener); - this.store = requireNonNull(store); - } - - @Override - public void onDataTreeChanged(final Collection domChanges) { - final Collection> bindingChanges = - LazyDataTreeModification.from(codec, domChanges, store); - listener.onDataTreeChanged(bindingChanges); - } - - @Override - public String toString() { - return listener.toString(); - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMDataTreeChangeServiceAdapter.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMDataTreeChangeServiceAdapter.java deleted file mode 100644 index 8ed8997ac1..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMDataTreeChangeServiceAdapter.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.impl; - -import static java.util.Objects.requireNonNull; - -import org.opendaylight.controller.md.sal.binding.api.ClusteredDataTreeChangeListener; -import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener; -import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeService; -import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier; -import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeService; -import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeIdentifier; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; - -/** - * Adapter exposing Binding {@link DataTreeChangeService} and wrapping - * {@link DOMDataTreeChangeService} and is responsible for translation - * and instantiation of {@link BindingDOMDataTreeChangeListenerAdapter} - * adapters. - * - *

- * Each registered {@link DataTreeChangeListener} is wrapped using - * adapter and registered directly to DOM service. - */ -@Deprecated(forRemoval = true) -final class BindingDOMDataTreeChangeServiceAdapter implements DataTreeChangeService { - - private final BindingToNormalizedNodeCodec codec; - private final DOMDataTreeChangeService dataTreeChangeService; - - private BindingDOMDataTreeChangeServiceAdapter(final BindingToNormalizedNodeCodec codec, - final DOMDataTreeChangeService dataTreeChangeService) { - this.codec = requireNonNull(codec); - this.dataTreeChangeService = requireNonNull(dataTreeChangeService); - } - - static DataTreeChangeService create(final BindingToNormalizedNodeCodec codec, - final DOMDataTreeChangeService dataTreeChangeService) { - return new BindingDOMDataTreeChangeServiceAdapter(codec, dataTreeChangeService); - } - - @Override - public > ListenerRegistration - registerDataTreeChangeListener(final DataTreeIdentifier treeId, final L listener) { - final DOMDataTreeIdentifier domIdentifier = toDomTreeIdentifier(treeId); - - @SuppressWarnings({ "rawtypes", "unchecked" }) - final BindingDOMDataTreeChangeListenerAdapter domListener = - listener instanceof ClusteredDataTreeChangeListener - ? new BindingClusteredDOMDataTreeChangeListenerAdapter<>( - codec, (ClusteredDataTreeChangeListener) listener, treeId.getDatastoreType()) - : new BindingDOMDataTreeChangeListenerAdapter<>(codec, listener, treeId.getDatastoreType()); - - final ListenerRegistration> domReg = - dataTreeChangeService.registerDataTreeChangeListener(domIdentifier, domListener); - return new BindingDataTreeChangeListenerRegistration<>(listener,domReg); - } - - private DOMDataTreeIdentifier toDomTreeIdentifier(final DataTreeIdentifier treeId) { - final YangInstanceIdentifier domPath = codec.toYangInstanceIdentifierBlocking(treeId.getRootIdentifier()); - return new DOMDataTreeIdentifier(treeId.getDatastoreType(), domPath); - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMMountPointListenerAdapter.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMMountPointListenerAdapter.java deleted file mode 100644 index 45a4c929e2..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMMountPointListenerAdapter.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.impl; - -import java.util.Optional; -import org.opendaylight.controller.md.sal.binding.api.MountPointService.MountPointListener; -import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService; -import org.opendaylight.mdsal.dom.api.DOMMountPointListener; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.impl.codec.DeserializationException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@Deprecated(forRemoval = true) -final class BindingDOMMountPointListenerAdapter - implements ListenerRegistration, DOMMountPointListener { - private static final Logger LOG = LoggerFactory.getLogger(BindingDOMMountPointListenerAdapter.class); - - private final T listener; - private final ListenerRegistration registration; - private final BindingToNormalizedNodeCodec codec; - - BindingDOMMountPointListenerAdapter(final T listener, final BindingToNormalizedNodeCodec codec, - final DOMMountPointService mountService) { - this.listener = listener; - this.codec = codec; - this.registration = mountService.registerProvisionListener(this); - } - - @Override - public T getInstance() { - return listener; - } - - @Override - public void close() { - registration.close(); - } - - @Override - public void onMountPointCreated(final YangInstanceIdentifier path) { - try { - final InstanceIdentifier bindingPath = toBinding(path); - listener.onMountPointCreated(bindingPath); - } catch (final DeserializationException e) { - LOG.error("Unable to translate mountPoint path {}. Omitting event.", path, e); - } - - } - - private InstanceIdentifier toBinding(final YangInstanceIdentifier path) - throws DeserializationException { - final Optional> instanceIdentifierOptional = codec.toBinding(path); - if (instanceIdentifierOptional.isPresent()) { - return instanceIdentifierOptional.get(); - } else { - throw new DeserializationException("Deserialization unsuccessful, " + instanceIdentifierOptional); - } - } - - @Override - public void onMountPointRemoved(final YangInstanceIdentifier path) { - try { - final InstanceIdentifier bindingPath = toBinding(path); - listener.onMountPointRemoved(bindingPath); - } catch (final DeserializationException e) { - LOG.error("Unable to translate mountPoint path {}. Omitting event.", path, e); - } - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMMountPointServiceAdapter.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMMountPointServiceAdapter.java deleted file mode 100644 index 88b1c98b75..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMMountPointServiceAdapter.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.impl; - -import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Optional; -import com.google.common.cache.CacheBuilder; -import com.google.common.cache.CacheLoader; -import com.google.common.cache.LoadingCache; -import org.gaul.modernizer_maven_annotations.SuppressModernizer; -import org.opendaylight.controller.md.sal.binding.api.MountPoint; -import org.opendaylight.controller.md.sal.binding.api.MountPointService; -import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint; -import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@Deprecated(forRemoval = true) -public class BindingDOMMountPointServiceAdapter implements MountPointService { - private static final Logger LOG = LoggerFactory.getLogger(BindingDOMMountPointServiceAdapter.class); - - private final BindingToNormalizedNodeCodec codec; - private final DOMMountPointService mountService; - @VisibleForTesting - final LoadingCache bindingMountpoints = CacheBuilder.newBuilder() - .weakKeys().weakValues().build(new CacheLoader() { - @Override - public BindingMountPointAdapter load(final DOMMountPoint key) { - return new BindingMountPointAdapter(codec, key); - } - }); - - public BindingDOMMountPointServiceAdapter(final DOMMountPointService mountService, - final BindingToNormalizedNodeCodec codec) { - this.codec = codec; - this.mountService = mountService; - } - - @Override - @SuppressModernizer - public Optional getMountPoint(final InstanceIdentifier mountPoint) { - - YangInstanceIdentifier domPath = codec.toYangInstanceIdentifierBlocking(mountPoint); - Optional domMount = mountService.getMountPoint(domPath); - if (domMount.isPresent()) { - return Optional.fromNullable(bindingMountpoints.getUnchecked(domMount.get())); - } - return Optional.absent(); - } - - @Override - public ListenerRegistration registerListener(final InstanceIdentifier path, - final T listener) { - return new BindingDOMMountPointListenerAdapter<>(listener, codec, mountService); - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMNotificationListenerAdapter.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMNotificationListenerAdapter.java deleted file mode 100644 index dc19d2795f..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMNotificationListenerAdapter.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.impl; - -import com.google.common.collect.ImmutableMap; -import com.google.common.reflect.TypeToken; -import java.lang.reflect.Method; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import org.opendaylight.controller.md.sal.dom.api.DOMNotification; -import org.opendaylight.controller.md.sal.dom.api.DOMNotificationListener; -import org.opendaylight.mdsal.binding.dom.adapter.invoke.NotificationListenerInvoker; -import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer; -import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections; -import org.opendaylight.yangtools.yang.binding.Notification; -import org.opendaylight.yangtools.yang.binding.NotificationListener; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; - -@Deprecated(forRemoval = true) -class BindingDOMNotificationListenerAdapter implements DOMNotificationListener { - - private final BindingNormalizedNodeSerializer codec; - private final NotificationListener delegate; - private final Map invokers; - - BindingDOMNotificationListenerAdapter(final BindingNormalizedNodeSerializer codec, - final NotificationListener delegate) { - this.codec = codec; - this.delegate = delegate; - this.invokers = createInvokerMapFor(delegate.getClass()); - } - - @Override - public void onNotification(final DOMNotification notification) { - final Notification baNotification = deserialize(notification); - final QName notificationQName = notification.getType().getLastComponent(); - getInvoker(notification.getType()).invokeNotification(delegate, notificationQName, baNotification); - } - - private Notification deserialize(final DOMNotification notification) { - if (notification instanceof LazySerializedDOMNotification) { - return ((LazySerializedDOMNotification) notification).getBindingData(); - } - return codec.fromNormalizedNodeNotification(notification.getType(), notification.getBody()); - } - - private NotificationListenerInvoker getInvoker(final SchemaPath type) { - return invokers.get(type); - } - - protected Set getSupportedNotifications() { - return invokers.keySet(); - } - - public static Map createInvokerMapFor( - final Class implClz) { - final Map builder = new HashMap<>(); - for (final TypeToken ifaceToken : TypeToken.of(implClz).getTypes().interfaces()) { - Class iface = ifaceToken.getRawType(); - if (NotificationListener.class.isAssignableFrom(iface) && BindingReflections.isBindingClass(iface)) { - @SuppressWarnings("unchecked") - final Class listenerType = - (Class) iface; - final NotificationListenerInvoker invoker = NotificationListenerInvoker.from(listenerType); - for (final SchemaPath path : getNotificationTypes(listenerType)) { - builder.put(path, invoker); - } - } - } - return ImmutableMap.copyOf(builder); - } - - private static Set getNotificationTypes(final Class type) { - // TODO: Investigate possibility and performance impact if we cache this or expose - // it from NotificationListenerInvoker - final Set ret = new HashSet<>(); - for (final Method method : type.getMethods()) { - if (BindingReflections.isNotificationCallback(method)) { - final Class notification = method.getParameterTypes()[0]; - final QName name = BindingReflections.findQName(notification); - ret.add(SchemaPath.create(true, name)); - } - } - return ret; - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMNotificationPublishServiceAdapter.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMNotificationPublishServiceAdapter.java deleted file mode 100644 index 6d7e34112f..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMNotificationPublishServiceAdapter.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.impl; - -import com.google.common.collect.ClassToInstanceMap; -import com.google.common.collect.ImmutableSet; -import com.google.common.util.concurrent.ListenableFuture; -import java.util.Set; -import java.util.concurrent.TimeUnit; -import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; -import org.opendaylight.controller.md.sal.binding.impl.BindingDOMAdapterBuilder.Factory; -import org.opendaylight.controller.md.sal.dom.api.DOMNotification; -import org.opendaylight.controller.md.sal.dom.api.DOMNotificationPublishService; -import org.opendaylight.controller.md.sal.dom.api.DOMService; -import org.opendaylight.yangtools.yang.binding.Notification; - -@Deprecated(forRemoval = true) -public class BindingDOMNotificationPublishServiceAdapter implements NotificationPublishService, AutoCloseable { - - static final Factory BUILDER_FACTORY = Builder::new; - - private final BindingToNormalizedNodeCodec codecRegistry; - private final DOMNotificationPublishService domPublishService; - - public BindingDOMNotificationPublishServiceAdapter(final BindingToNormalizedNodeCodec codec, - final DOMNotificationPublishService domPublishService) { - this.codecRegistry = codec; - this.domPublishService = domPublishService; - } - - public BindingToNormalizedNodeCodec getCodecRegistry() { - return codecRegistry; - } - - public DOMNotificationPublishService getDomPublishService() { - return domPublishService; - } - - @Override - public void putNotification(final Notification notification) throws InterruptedException { - domPublishService.putNotification(toDomNotification(notification)); - } - - @Override - public ListenableFuture offerNotification(final Notification notification) { - ListenableFuture offerResult = domPublishService.offerNotification(toDomNotification(notification)); - return DOMNotificationPublishService.REJECTED.equals(offerResult) - ? NotificationPublishService.REJECTED - : offerResult; - } - - @Override - public ListenableFuture offerNotification(final Notification notification, final int timeout, - final TimeUnit unit) throws InterruptedException { - ListenableFuture offerResult = domPublishService.offerNotification(toDomNotification(notification), - timeout, unit); - return DOMNotificationPublishService.REJECTED.equals(offerResult) - ? NotificationPublishService.REJECTED - : offerResult; - } - - private DOMNotification toDomNotification(final Notification notification) { - return LazySerializedDOMNotification.create(codecRegistry, notification); - } - - @Override - public void close() { - - } - - protected static class Builder extends BindingDOMAdapterBuilder { - - @Override - public Set> getRequiredDelegates() { - return ImmutableSet.>of(DOMNotificationPublishService.class); - } - - @Override - protected NotificationPublishService createInstance(final BindingToNormalizedNodeCodec codec, - final ClassToInstanceMap delegates) { - final DOMNotificationPublishService domPublish = delegates.getInstance(DOMNotificationPublishService.class); - return new BindingDOMNotificationPublishServiceAdapter(codec, domPublish); - } - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMNotificationServiceAdapter.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMNotificationServiceAdapter.java deleted file mode 100644 index 9f5363b0e8..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMNotificationServiceAdapter.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.impl; - -import com.google.common.collect.ClassToInstanceMap; -import com.google.common.collect.ImmutableSet; -import java.util.Set; -import org.opendaylight.controller.md.sal.binding.api.NotificationService; -import org.opendaylight.controller.md.sal.binding.impl.BindingDOMAdapterBuilder.Factory; -import org.opendaylight.controller.md.sal.dom.api.DOMNotificationService; -import org.opendaylight.controller.md.sal.dom.api.DOMService; -import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer; -import org.opendaylight.yangtools.concepts.AbstractListenerRegistration; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.binding.NotificationListener; - -@Deprecated(forRemoval = true) -public class BindingDOMNotificationServiceAdapter implements NotificationService, AutoCloseable { - - public static final Factory BUILDER_FACTORY = Builder::new; - private final BindingNormalizedNodeSerializer codec; - private final DOMNotificationService domNotifService; - - public BindingDOMNotificationServiceAdapter(final BindingNormalizedNodeSerializer codec, - final DOMNotificationService domNotifService) { - this.codec = codec; - this.domNotifService = domNotifService; - } - - @Override - public ListenerRegistration registerNotificationListener(final T listener) { - final BindingDOMNotificationListenerAdapter domListener = - new BindingDOMNotificationListenerAdapter(codec, listener); - final ListenerRegistration domRegistration = - domNotifService.registerNotificationListener(domListener, domListener.getSupportedNotifications()); - return new ListenerRegistrationImpl<>(listener, domRegistration); - } - - @Override - public void close() { - - } - - private static class ListenerRegistrationImpl - extends AbstractListenerRegistration { - private final ListenerRegistration listenerRegistration; - - ListenerRegistrationImpl(final T listener, final ListenerRegistration listenerRegistration) { - super(listener); - this.listenerRegistration = listenerRegistration; - } - - @Override - protected void removeRegistration() { - listenerRegistration.close(); - } - } - - private static class Builder extends BindingDOMAdapterBuilder { - - @Override - protected NotificationService createInstance(final BindingToNormalizedNodeCodec codec, - final ClassToInstanceMap delegates) { - final DOMNotificationService domNotification = delegates.getInstance(DOMNotificationService.class); - return new BindingDOMNotificationServiceAdapter(codec.getCodecRegistry(), domNotification); - } - - @Override - public Set> getRequiredDelegates() { - return ImmutableSet.of(DOMNotificationService.class); - } - } - - public DOMNotificationService getDomService() { - return domNotifService; - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMReadTransactionAdapter.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMReadTransactionAdapter.java deleted file mode 100644 index 3592050f12..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMReadTransactionAdapter.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.impl; - -import com.google.common.base.Optional; -import com.google.common.util.concurrent.CheckedFuture; -import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; -import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -@Deprecated(forRemoval = true) -class BindingDOMReadTransactionAdapter extends AbstractForwardedTransaction implements - ReadOnlyTransaction { - - protected BindingDOMReadTransactionAdapter(final DOMDataReadOnlyTransaction delegate, - final BindingToNormalizedNodeCodec codec) { - super(delegate, codec); - } - - @Override - public CheckedFuture, ReadFailedException> read( - final LogicalDatastoreType store, final InstanceIdentifier path) { - return doRead(getDelegate(),store, path); - } - - @Override - public CheckedFuture exists(final LogicalDatastoreType store, - final InstanceIdentifier path) { - return doExists(getDelegate(), store, path); - } - - @Override - public void close() { - getDelegate().close(); - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMReadWriteTransactionAdapter.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMReadWriteTransactionAdapter.java deleted file mode 100644 index bf1135ab5a..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMReadWriteTransactionAdapter.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.impl; - -import com.google.common.base.Optional; -import com.google.common.util.concurrent.CheckedFuture; -import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; -import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -@Deprecated(forRemoval = true) -class BindingDOMReadWriteTransactionAdapter extends - BindingDOMWriteTransactionAdapter implements ReadWriteTransaction { - - protected BindingDOMReadWriteTransactionAdapter(final DOMDataReadWriteTransaction delegate, - final BindingToNormalizedNodeCodec codec) { - super(delegate, codec); - } - - @Override - public CheckedFuture,ReadFailedException> read( - final LogicalDatastoreType store, final InstanceIdentifier path) { - return doRead(getDelegate(), store, path); - } - - @Override - public CheckedFuture exists(final LogicalDatastoreType store, - final InstanceIdentifier path) { - return doExists(getDelegate(), store, path); - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMRpcAdapterRegistration.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMRpcAdapterRegistration.java deleted file mode 100644 index 11e81c6ead..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMRpcAdapterRegistration.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.impl; - -import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementationRegistration; -import org.opendaylight.yangtools.concepts.AbstractObjectRegistration; -import org.opendaylight.yangtools.yang.binding.RpcService; - -@Deprecated(forRemoval = true) -class BindingDOMRpcAdapterRegistration extends AbstractObjectRegistration { - - private final DOMRpcImplementationRegistration reg; - - BindingDOMRpcAdapterRegistration(T instance, DOMRpcImplementationRegistration reg) { - super(instance); - this.reg = reg; - } - - @Override - protected void removeRegistration() { - reg.close(); - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMRpcImplementationAdapter.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMRpcImplementationAdapter.java deleted file mode 100644 index 1e9306b04b..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMRpcImplementationAdapter.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.impl; - -import static java.util.Objects.requireNonNull; - -import com.google.common.cache.Cache; -import com.google.common.cache.CacheBuilder; -import com.google.common.util.concurrent.CheckedFuture; -import com.google.common.util.concurrent.ListenableFuture; -import java.lang.reflect.Method; -import java.util.HashMap; -import java.util.Map; -import java.util.Map.Entry; -import java.util.concurrent.ExecutionException; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcException; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementation; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult; -import org.opendaylight.mdsal.binding.dom.adapter.BindingDataAware; -import org.opendaylight.mdsal.binding.dom.adapter.invoke.RpcServiceInvoker; -import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer; -import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.RpcService; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.common.RpcResult; -import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; - -@Deprecated(forRemoval = true) -public class BindingDOMRpcImplementationAdapter implements DOMRpcImplementation { - - private static final Cache, RpcServiceInvoker> SERVICE_INVOKERS = - CacheBuilder.newBuilder().weakKeys().build(); - - private final BindingNormalizedNodeSerializer codec; - private final RpcServiceInvoker invoker; - private final RpcService delegate; - private final QName inputQname; - - BindingDOMRpcImplementationAdapter(final BindingNormalizedNodeSerializer codec, - final Class type, final Map localNameToMethod, final T delegate) { - try { - this.invoker = SERVICE_INVOKERS.get(type, () -> { - final Map map = new HashMap<>(); - for (Entry e : localNameToMethod.entrySet()) { - map.put(e.getKey().getLastComponent(), e.getValue()); - } - - return RpcServiceInvoker.from(map); - }); - } catch (ExecutionException e) { - throw new IllegalArgumentException("Failed to create invokers for type " + type, e); - } - - this.codec = requireNonNull(codec); - this.delegate = requireNonNull(delegate); - inputQname = QName.create(BindingReflections.getQNameModule(type), "input").intern(); - } - - @Override - public CheckedFuture invokeRpc(final DOMRpcIdentifier rpc, - final NormalizedNode input) { - final SchemaPath schemaPath = rpc.getType(); - final DataObject bindingInput = input != null ? deserialize(rpc.getType(), input) : null; - final ListenableFuture> bindingResult = invoke(schemaPath, bindingInput); - return transformResult(bindingResult); - } - - private DataObject deserialize(final SchemaPath rpcPath, final NormalizedNode input) { - if (input instanceof BindingDataAware) { - return ((BindingDataAware) input).bindingData(); - } - final SchemaPath inputSchemaPath = rpcPath.createChild(inputQname); - return codec.fromNormalizedNodeRpcData(inputSchemaPath, (ContainerNode) input); - } - - private ListenableFuture> invoke(final SchemaPath schemaPath, final DataObject input) { - return invoker.invokeRpc(delegate, schemaPath.getLastComponent(), input); - } - - private CheckedFuture transformResult( - final ListenableFuture> bindingResult) { - return LazyDOMRpcResultFuture.create(codec, bindingResult); - } - -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMRpcProviderServiceAdapter.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMRpcProviderServiceAdapter.java deleted file mode 100644 index bd5aec9668..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMRpcProviderServiceAdapter.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.impl; - -import com.google.common.collect.ImmutableSet; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementationRegistration; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcProviderService; -import org.opendaylight.yangtools.concepts.ObjectRegistration; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.binding.RpcService; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; - -@Deprecated(forRemoval = true) -public class BindingDOMRpcProviderServiceAdapter { - - private static final Set GLOBAL = ImmutableSet.of(YangInstanceIdentifier.empty()); - private final BindingToNormalizedNodeCodec codec; - private final DOMRpcProviderService domRpcRegistry; - - public BindingDOMRpcProviderServiceAdapter(final DOMRpcProviderService domRpcRegistry, - final BindingToNormalizedNodeCodec codec) { - this.codec = codec; - this.domRpcRegistry = domRpcRegistry; - } - - public ObjectRegistration registerRpcImplementation(final Class type, - final T implementation) { - return register(type, implementation, GLOBAL); - } - - public ObjectRegistration registerRpcImplementation(final Class type, - final T implementation, final Set> paths) { - return register(type, implementation, toYangInstanceIdentifiers(paths)); - } - - private ObjectRegistration register(final Class type, - final T implementation, final Collection rpcContextPaths) { - final Map rpcs = codec.getRpcMethodToSchemaPath(type).inverse(); - - final BindingDOMRpcImplementationAdapter adapter = new BindingDOMRpcImplementationAdapter( - codec.getCodecRegistry(), type, rpcs, implementation); - final Set domRpcs = createDomRpcIdentifiers(rpcs.keySet(), rpcContextPaths); - final DOMRpcImplementationRegistration domReg = domRpcRegistry.registerRpcImplementation(adapter, domRpcs); - return new BindingRpcAdapterRegistration<>(implementation, domReg); - } - - private static Set createDomRpcIdentifiers(final Set rpcs, - final Collection paths) { - final Set ret = new HashSet<>(); - for (final YangInstanceIdentifier path : paths) { - for (final SchemaPath rpc : rpcs) { - ret.add(DOMRpcIdentifier.create(rpc, path)); - } - } - return ret; - } - - private Collection toYangInstanceIdentifiers(final Set> identifiers) { - final Collection ret = new ArrayList<>(identifiers.size()); - for (final InstanceIdentifier binding : identifiers) { - ret.add(codec.toYangInstanceIdentifierCached(binding)); - } - return ret; - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMRpcServiceAdapter.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMRpcServiceAdapter.java deleted file mode 100644 index 9e4bb4daea..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMRpcServiceAdapter.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.impl; - -import static com.google.common.base.Preconditions.checkArgument; - -import com.google.common.cache.CacheBuilder; -import com.google.common.cache.CacheLoader; -import com.google.common.cache.LoadingCache; -import com.google.common.collect.ClassToInstanceMap; -import com.google.common.collect.ImmutableSet; -import java.util.Set; -import org.opendaylight.controller.md.sal.binding.impl.BindingDOMAdapterBuilder.Factory; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcService; -import org.opendaylight.controller.md.sal.dom.api.DOMService; -import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry; -import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections; -import org.opendaylight.yangtools.yang.binding.RpcService; - -@Deprecated(forRemoval = true) -public class BindingDOMRpcServiceAdapter implements RpcConsumerRegistry { - - protected static final Factory BUILDER_FACTORY = Builder::new; - - private final LoadingCache, RpcServiceAdapter> proxies = CacheBuilder.newBuilder() - .weakKeys() - .build(new CacheLoader, RpcServiceAdapter>() { - - @Override - public RpcServiceAdapter load(final Class key) { - checkArgument(BindingReflections.isBindingClass(key)); - checkArgument(key.isInterface(), "Supplied RPC service type must be interface."); - return new RpcServiceAdapter(key, codec, domService); - } - - }); - - private final DOMRpcService domService; - private final BindingToNormalizedNodeCodec codec; - - public BindingDOMRpcServiceAdapter(final DOMRpcService domService, final BindingToNormalizedNodeCodec codec) { - this.domService = domService; - this.codec = codec; - } - - @SuppressWarnings("unchecked") - @Override - public T getRpcService(final Class rpcService) { - checkArgument(rpcService != null, "Rpc Service needs to be specied."); - return (T) proxies.getUnchecked(rpcService).getProxy(); - } - - private static final class Builder extends BindingDOMAdapterBuilder { - - @Override - protected RpcConsumerRegistry createInstance(final BindingToNormalizedNodeCodec codec, - final ClassToInstanceMap delegates) { - final DOMRpcService domRpc = delegates.getInstance(DOMRpcService.class); - return new BindingDOMRpcServiceAdapter(domRpc , codec); - } - - @Override - public Set> getRequiredDelegates() { - return ImmutableSet.of(DOMRpcService.class); - } - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMTransactionChainAdapter.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMTransactionChainAdapter.java deleted file mode 100644 index 6d7b11d414..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMTransactionChainAdapter.java +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.impl; - -import static com.google.common.base.Preconditions.checkState; -import static java.util.Objects.requireNonNull; - -import com.google.common.util.concurrent.FluentFuture; -import com.google.common.util.concurrent.FutureCallback; -import com.google.common.util.concurrent.MoreExecutors; -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; -import org.opendaylight.controller.md.sal.binding.api.BindingTransactionChain; -import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; -import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction; -import org.opendaylight.controller.md.sal.common.api.data.TransactionChain; -import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener; -import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; -import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction; -import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction; -import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction; -import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain; -import org.opendaylight.mdsal.common.api.CommitInfo; -import org.opendaylight.yangtools.concepts.Delegator; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@Deprecated(forRemoval = true) -final class BindingDOMTransactionChainAdapter implements BindingTransactionChain, Delegator { - - private static final Logger LOG = LoggerFactory.getLogger(BindingDOMTransactionChainAdapter.class); - - private final DOMTransactionChain delegate; - private final BindingToNormalizedNodeCodec codec; - private final DelegateChainListener domListener; - private final TransactionChainListener bindingListener; - - BindingDOMTransactionChainAdapter(final DOMDataBroker chainFactory, - final BindingToNormalizedNodeCodec codec, final TransactionChainListener listener) { - this.domListener = new DelegateChainListener(); - this.bindingListener = listener; - this.delegate = requireNonNull(chainFactory, "DOM Transaction chain factory must not be null") - .createTransactionChain(domListener); - this.codec = codec; - } - - @Override - public DOMTransactionChain getDelegate() { - return delegate; - } - - @Override - public ReadOnlyTransaction newReadOnlyTransaction() { - final DOMDataReadOnlyTransaction delegateTx = delegate.newReadOnlyTransaction(); - return new BindingDOMReadTransactionAdapter(delegateTx, codec); - } - - @Override - public ReadWriteTransaction newReadWriteTransaction() { - final DOMDataReadWriteTransaction delegateTx = delegate.newReadWriteTransaction(); - return new BindingDOMReadWriteTransactionAdapter(delegateTx, codec) { - - @Override - public FluentFuture commit() { - return listenForFailure(this, super.commit()); - } - - }; - } - - @Override - public WriteTransaction newWriteOnlyTransaction() { - final DOMDataWriteTransaction delegateTx = delegate.newWriteOnlyTransaction(); - return new BindingDOMWriteTransactionAdapter(delegateTx, codec) { - - @Override - public FluentFuture commit() { - return listenForFailure(this, super.commit()); - } - - }; - } - - @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", - justification = "https://github.com/spotbugs/spotbugs/issues/811") - private FluentFuture listenForFailure( - final WriteTransaction tx, final FluentFuture future) { - future.addCallback(new FutureCallback() { - @Override - public void onFailure(final Throwable ex) { - failTransactionChain(tx,ex); - } - - @Override - public void onSuccess(final CommitInfo result) { - // Intentionally NOOP - } - }, MoreExecutors.directExecutor()); - - return future; - } - - @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", - justification = "https://github.com/spotbugs/spotbugs/issues/811") - private void failTransactionChain(final WriteTransaction tx, final Throwable ex) { - /* - * We asume correct state change for underlaying transaction - * - * chain, so we are not changing any of our internal state - * to mark that we failed. - */ - this.bindingListener.onTransactionChainFailed(this, tx, ex); - } - - @Override - public void close() { - delegate.close(); - } - - private final class DelegateChainListener implements TransactionChainListener { - @Override - public void onTransactionChainFailed(final TransactionChain chain, - final AsyncTransaction transaction, final Throwable cause) { - checkChain(chain); - /* - * Intentionally NOOP, callback for failure, since we - * are also listening on each transaction future for failure, - * in order to have reference to Binding Transaction (which was seen by client - * of this transaction chain), instead of DOM transaction - * which is known only to this chain, binding transaction implementation - * and underlying transaction chain. - */ - LOG.debug("Transaction chain {} failed. Failed DOM Transaction {}",this,transaction,cause); - } - - @Override - public void onTransactionChainSuccessful(final TransactionChain chain) { - checkChain(chain); - bindingListener.onTransactionChainSuccessful(BindingDOMTransactionChainAdapter.this); - } - - private void checkChain(final TransactionChain chain) { - checkState(delegate.equals(chain), "Illegal state - listener for %s was invoked for incorrect chain %s.", - delegate, chain); - } - } - -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMWriteTransactionAdapter.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMWriteTransactionAdapter.java deleted file mode 100644 index 6868dfdd12..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMWriteTransactionAdapter.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.impl; - -import com.google.common.util.concurrent.FluentFuture; -import java.util.ArrayList; -import java.util.List; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizationException; -import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizationOperation; -import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction; -import org.opendaylight.mdsal.common.api.CommitInfo; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; - -@Deprecated(forRemoval = true) -class BindingDOMWriteTransactionAdapter extends - AbstractWriteTransaction implements WriteTransaction { - - protected BindingDOMWriteTransactionAdapter(final T delegateTx, final BindingToNormalizedNodeCodec codec) { - super(delegateTx, codec); - } - - @Override - public void put(final LogicalDatastoreType store, final InstanceIdentifier path, - final U data) { - put(store, path, data,false); - } - - @Override - public void merge(final LogicalDatastoreType store, final InstanceIdentifier path, - final D data) { - merge(store, path, data,false); - } - - - @Override - protected void ensureParentsByMerge(final LogicalDatastoreType store, - final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier normalizedPath, - final InstanceIdentifier path) { - List currentArguments = new ArrayList<>(); - DataNormalizationOperation currentOp = getCodec().getDataNormalizer().getRootOperation(); - for (PathArgument currentArg : normalizedPath.getPathArguments()) { - try { - currentOp = currentOp.getChild(currentArg); - } catch (DataNormalizationException e) { - throw new IllegalArgumentException(String.format("Invalid child encountered in path %s", path), e); - } - currentArguments.add(currentArg); - YangInstanceIdentifier currentPath = YangInstanceIdentifier.create( - currentArguments); - - getDelegate().merge(store, currentPath, currentOp.createDefault(currentArg)); - } - } - - @Override - public void delete(final LogicalDatastoreType store, final InstanceIdentifier path) { - doDelete(store, path); - } - - @Override - public FluentFuture commit() { - return doCommit(); - } - - @Override - public boolean cancel() { - return doCancel(); - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDataTreeChangeListenerRegistration.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDataTreeChangeListenerRegistration.java deleted file mode 100644 index d86af2b075..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDataTreeChangeListenerRegistration.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.impl; - -import static java.util.Objects.requireNonNull; - -import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener; -import org.opendaylight.yangtools.concepts.AbstractListenerRegistration; -import org.opendaylight.yangtools.concepts.ListenerRegistration; - -@Deprecated(forRemoval = true) -class BindingDataTreeChangeListenerRegistration> - extends AbstractListenerRegistration { - - private final ListenerRegistration domReg; - - BindingDataTreeChangeListenerRegistration(final L listener, final ListenerRegistration domReg) { - super(listener); - this.domReg = requireNonNull(domReg); - } - - @Override - protected void removeRegistration() { - domReg.close(); - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingMountPointAdapter.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingMountPointAdapter.java deleted file mode 100644 index d5c80d8aa0..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingMountPointAdapter.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.impl; - -import com.google.common.base.Optional; -import com.google.common.cache.CacheBuilder; -import com.google.common.cache.LoadingCache; -import org.gaul.modernizer_maven_annotations.SuppressModernizer; -import org.opendaylight.controller.md.sal.binding.api.BindingService; -import org.opendaylight.controller.md.sal.binding.api.MountPoint; -import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint; -import org.opendaylight.controller.md.sal.dom.api.DOMService; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -@Deprecated(forRemoval = true) -public class BindingMountPointAdapter implements MountPoint { - - private final InstanceIdentifier identifier; - private LoadingCache, Optional> services; - - public BindingMountPointAdapter(final BindingToNormalizedNodeCodec codec, final DOMMountPoint domMountPoint) { - identifier = codec.getCodecRegistry().fromYangInstanceIdentifier(domMountPoint.getIdentifier()); - services = CacheBuilder.newBuilder().build(new BindingDOMAdapterLoader(codec) { - - @Override - protected DOMService getDelegate(final Class reqDeleg) { - return domMountPoint.getService(reqDeleg).orNull(); - } - }); - } - - @Override - public InstanceIdentifier getIdentifier() { - return identifier; - } - - @Override - @SuppressModernizer - public Optional getService(final Class service) { - Optional potential = services.getUnchecked(service); - if (potential.isPresent()) { - return Optional.of(service.cast(potential.get())); - } - return Optional.absent(); - } - -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingRpcAdapterRegistration.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingRpcAdapterRegistration.java deleted file mode 100644 index 94b64e9fea..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingRpcAdapterRegistration.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.impl; - -import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementationRegistration; -import org.opendaylight.yangtools.concepts.AbstractObjectRegistration; -import org.opendaylight.yangtools.yang.binding.RpcService; - -@Deprecated(forRemoval = true) -class BindingRpcAdapterRegistration extends AbstractObjectRegistration { - - private final DOMRpcImplementationRegistration reg; - - BindingRpcAdapterRegistration(T instance, DOMRpcImplementationRegistration reg) { - super(instance); - this.reg = reg; - } - - @Override - protected void removeRegistration() { - reg.close(); - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingToDOMAdapterFactory.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingToDOMAdapterFactory.java deleted file mode 100644 index 135b42dad5..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingToDOMAdapterFactory.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.impl; - -import static java.util.Objects.requireNonNull; - -import com.google.common.annotations.Beta; -import org.eclipse.jdt.annotation.NonNullByDefault; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.spi.AdapterFactory; -import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; - -@Beta -@Deprecated(forRemoval = true) -@NonNullByDefault -public final class BindingToDOMAdapterFactory implements AdapterFactory { - private final BindingToNormalizedNodeCodec codec; - - public BindingToDOMAdapterFactory(final BindingToNormalizedNodeCodec codec) { - this.codec = requireNonNull(codec); - } - - @Override - public DataBroker createDataBroker(final DOMDataBroker domBroker) { - return new BindingDOMDataBrokerAdapter(requireNonNull(domBroker), codec); - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingToNormalizedNodeCodec.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingToNormalizedNodeCodec.java deleted file mode 100644 index f994d300c2..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingToNormalizedNodeCodec.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.impl; - -import com.google.common.collect.ImmutableBiMap; -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; -import java.lang.reflect.Method; -import java.util.Iterator; -import java.util.Map; -import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizationException; -import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizationOperation; -import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizer; -import org.opendaylight.mdsal.binding.dom.codec.api.BindingDataObjectCodecTreeNode; -import org.opendaylight.mdsal.binding.dom.codec.impl.BindingNormalizedNodeCodecRegistry; -import org.opendaylight.mdsal.binding.generator.api.ClassLoadingStrategy; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.binding.RpcService; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.model.api.RpcDefinition; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -@Deprecated(forRemoval = true) -@SuppressFBWarnings(value = "NM_SAME_SIMPLE_NAME_AS_SUPERCLASS", justification = "Migration path") -public class BindingToNormalizedNodeCodec - extends org.opendaylight.mdsal.binding.dom.adapter.BindingToNormalizedNodeCodec { - - private DataNormalizer legacyToNormalized = null; - - public BindingToNormalizedNodeCodec(final ClassLoadingStrategy classLoadingStrategy, - final BindingNormalizedNodeCodecRegistry codecRegistry) { - super(classLoadingStrategy, codecRegistry); - } - - public BindingToNormalizedNodeCodec(final ClassLoadingStrategy classLoadingStrategy, - final BindingNormalizedNodeCodecRegistry codecRegistry, final boolean waitForSchema) { - super(classLoadingStrategy, codecRegistry, waitForSchema); - } - - DataNormalizer getDataNormalizer() { - return this.legacyToNormalized; - } - - @Override - public YangInstanceIdentifier toYangInstanceIdentifierBlocking( - final InstanceIdentifier binding) { - return super.toYangInstanceIdentifierBlocking(binding); - } - - @Override - public YangInstanceIdentifier toYangInstanceIdentifierCached(final InstanceIdentifier binding) { - return super.toYangInstanceIdentifierCached(binding); - } - - @Override - public void onGlobalContextUpdated(final SchemaContext schemaContext) { - this.legacyToNormalized = new DataNormalizer(schemaContext); - super.onGlobalContextUpdated(schemaContext); - } - - /** - * Returns an default object according to YANG schema for supplied path. - * - * @param path DOM Path - * @return Node with defaults set on. - */ - @Override - public NormalizedNode getDefaultNodeFor(final YangInstanceIdentifier path) { - final Iterator iterator = path.getPathArguments().iterator(); - DataNormalizationOperation currentOp = this.legacyToNormalized.getRootOperation(); - while (iterator.hasNext()) { - final PathArgument currentArg = iterator.next(); - try { - currentOp = currentOp.getChild(currentArg); - } catch (final DataNormalizationException e) { - throw new IllegalArgumentException(String.format("Invalid child encountered in path %s", path), e); - } - } - return currentOp.createDefault(path.getLastPathArgument()); - } - - @Override - public ImmutableBiMap getRpcMethodToSchema(final Class key) { - return super.getRpcMethodToSchema(key); - } - - @Override - public Map.Entry, BindingDataObjectCodecTreeNode> getSubtreeCodec( - final YangInstanceIdentifier domIdentifier) { - return super.getSubtreeCodec(domIdentifier); - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/ContextReferenceExtractor.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/ContextReferenceExtractor.java deleted file mode 100644 index 214ae3e6d8..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/ContextReferenceExtractor.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.impl; - -import com.google.common.cache.CacheBuilder; -import com.google.common.cache.CacheLoader; -import com.google.common.cache.LoadingCache; -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; -import java.lang.reflect.Method; -import org.eclipse.jdt.annotation.NonNull; -import org.eclipse.jdt.annotation.Nullable; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.binding.annotations.RoutingContext; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@Deprecated(forRemoval = true) -abstract class ContextReferenceExtractor { - private static final Logger LOG = LoggerFactory.getLogger(ContextReferenceExtractor.class); - private static final ContextReferenceExtractor NULL_EXTRACTOR = new ContextReferenceExtractor() { - - @Override - InstanceIdentifier extract(final DataObject obj) { - return null; - } - }; - - private static final LoadingCache, ContextReferenceExtractor> EXTRACTORS = CacheBuilder.newBuilder() - .weakKeys().build(new CacheLoader, ContextReferenceExtractor>() { - - @Override - public ContextReferenceExtractor load(final Class key) { - return create(key); - } - }); - - - private static final String GET_VALUE_NAME = "getValue"; - - static ContextReferenceExtractor from(final Class obj) { - return EXTRACTORS.getUnchecked(obj); - } - - /** - * Extract context-reference (Instance Identifier) from - * Binding DataObject. - * - * @param obj DataObject from which context reference should be extracted. - * - * @return Instance Identifier representing context reference or null, if data object does not contain - * context reference. - */ - abstract @Nullable InstanceIdentifier extract(DataObject obj); - - @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", - justification = "https://github.com/spotbugs/spotbugs/issues/811") - private static @NonNull ContextReferenceExtractor create(final Class key) { - final Method contextGetter = getContextGetter(key); - if (contextGetter == null) { - return NULL_EXTRACTOR; - } - final Class returnType = contextGetter.getReturnType(); - try { - if (InstanceIdentifier.class.isAssignableFrom(returnType)) { - return DirectGetterRouteContextExtractor.create(contextGetter); - } - final Method getValueMethod = findGetValueMethod(returnType, InstanceIdentifier.class); - if (getValueMethod != null) { - return GetValueRouteContextExtractor.create(contextGetter, getValueMethod); - } else { - LOG.warn("Class {} can not be used to determine context, falling back to NULL_EXTRACTOR.", returnType); - } - } catch (final IllegalAccessException e) { - LOG.warn("Class {} does not conform to Binding Specification v1. Falling back to NULL_EXTRACTOR", - returnType, e); - } - return NULL_EXTRACTOR; - } - - private static @Nullable Method findGetValueMethod(final Class type, final Class returnType) { - try { - final Method method = type.getMethod(GET_VALUE_NAME); - if (returnType.equals(method.getReturnType())) { - return method; - } - } catch (final NoSuchMethodException e) { - LOG.warn("Value class {} does not comform to Binding Specification v1.", type, e); - } - return null; - } - - private static Method getContextGetter(final Class key) { - for (final Method method : key.getMethods()) { - if (method.getAnnotation(RoutingContext.class) != null) { - return method; - } - } - return null; - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/ControllerActionProviderServiceAdapter.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/ControllerActionProviderServiceAdapter.java deleted file mode 100644 index 9b59f3d525..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/ControllerActionProviderServiceAdapter.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.impl; - -import static java.util.Objects.requireNonNull; - -import com.google.common.collect.ClassToInstanceMap; -import com.google.common.collect.ImmutableSet; -import java.util.Set; -import org.eclipse.jdt.annotation.NonNull; -import org.opendaylight.controller.md.sal.binding.api.ActionProviderService; -import org.opendaylight.controller.md.sal.binding.impl.BindingDOMAdapterBuilder.Factory; -import org.opendaylight.controller.md.sal.dom.api.DOMActionProviderService; -import org.opendaylight.controller.md.sal.dom.api.DOMService; -import org.opendaylight.mdsal.binding.api.DataTreeIdentifier; -import org.opendaylight.mdsal.binding.dom.adapter.ActionProviderServiceAdapter; -import org.opendaylight.mdsal.common.api.LogicalDatastoreType; -import org.opendaylight.yangtools.concepts.ObjectRegistration; -import org.opendaylight.yangtools.yang.binding.Action; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -@Deprecated(forRemoval = true) -final class ControllerActionProviderServiceAdapter implements ActionProviderService { - private static final class Builder extends BindingDOMAdapterBuilder { - @Override - public Set> getRequiredDelegates() { - return ImmutableSet.of(DOMActionProviderService.class); - } - - @Override - protected ActionProviderService createInstance(BindingToNormalizedNodeCodec codec, - ClassToInstanceMap delegates) { - final DOMActionProviderService domAction = delegates.getInstance(DOMActionProviderService.class); - return new ControllerActionProviderServiceAdapter(requireNonNull(codec), domAction); - } - } - - static final Factory BUILDER_FACTORY = Builder::new; - - private final ActionProviderServiceAdapter delegate; - - ControllerActionProviderServiceAdapter(BindingToNormalizedNodeCodec codec, DOMActionProviderService domService) { - this.delegate = ActionProviderServiceAdapter.create(codec, domService); - } - - @Override - public , T extends @NonNull Action, - S extends T> ObjectRegistration registerImplementation(Class actionInterface, S implementation, - LogicalDatastoreType datastore, Set> validNodes) { - return delegate.registerImplementation(actionInterface, implementation, datastore, validNodes); - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/ControllerActionServiceAdapter.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/ControllerActionServiceAdapter.java deleted file mode 100644 index 1d57d706b5..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/ControllerActionServiceAdapter.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.impl; - -import static java.util.Objects.requireNonNull; - -import com.google.common.collect.ClassToInstanceMap; -import com.google.common.collect.ImmutableSet; -import java.util.Set; -import org.eclipse.jdt.annotation.NonNull; -import org.opendaylight.controller.md.sal.binding.api.ActionService; -import org.opendaylight.controller.md.sal.binding.impl.BindingDOMAdapterBuilder.Factory; -import org.opendaylight.controller.md.sal.dom.api.DOMActionService; -import org.opendaylight.controller.md.sal.dom.api.DOMService; -import org.opendaylight.mdsal.binding.api.DataTreeIdentifier; -import org.opendaylight.mdsal.binding.dom.adapter.ActionServiceAdapter; -import org.opendaylight.yangtools.yang.binding.Action; -import org.opendaylight.yangtools.yang.binding.DataObject; - -@Deprecated(forRemoval = true) -final class ControllerActionServiceAdapter implements ActionService { - private static final class Builder extends BindingDOMAdapterBuilder { - @Override - public Set> getRequiredDelegates() { - return ImmutableSet.of(DOMActionService.class); - } - - @Override - protected ActionService createInstance(final BindingToNormalizedNodeCodec codec, - final ClassToInstanceMap delegates) { - final DOMActionService domAction = delegates.getInstance(DOMActionService.class); - return new ControllerActionServiceAdapter(requireNonNull(codec), domAction); - } - } - - static final Factory BUILDER_FACTORY = Builder::new; - private final ActionServiceAdapter delegate; - - ControllerActionServiceAdapter(final BindingToNormalizedNodeCodec codec, final DOMActionService domService) { - this.delegate = ActionServiceAdapter.create(codec, domService); - } - - @Override - public > T getActionHandle( - final Class actionInterface, final Set> validNodes) { - return delegate.getActionHandle(actionInterface, validNodes); - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/DirectGetterRouteContextExtractor.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/DirectGetterRouteContextExtractor.java deleted file mode 100644 index f0cba52787..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/DirectGetterRouteContextExtractor.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.md.sal.binding.impl; - -import com.google.common.base.Throwables; -import java.lang.invoke.MethodHandle; -import java.lang.invoke.MethodHandles; -import java.lang.invoke.MethodHandles.Lookup; -import java.lang.invoke.MethodType; -import java.lang.reflect.Method; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -@Deprecated(forRemoval = true) -final class DirectGetterRouteContextExtractor extends ContextReferenceExtractor { - - private static final Lookup PUBLIC_LOOKUP = MethodHandles.publicLookup(); - private final MethodHandle handle; - - private DirectGetterRouteContextExtractor(final MethodHandle rawHandle) { - handle = rawHandle.asType(MethodType.methodType(InstanceIdentifier.class, DataObject.class)); - } - - static ContextReferenceExtractor create(final Method getterMethod) throws IllegalAccessException { - final MethodHandle getterHandle = PUBLIC_LOOKUP.unreflect(getterMethod); - return new DirectGetterRouteContextExtractor(getterHandle); - } - - @Override - @SuppressWarnings("checkstyle:IllegalCatch") - InstanceIdentifier extract(final DataObject obj) { - try { - return (InstanceIdentifier) handle.invokeExact(obj); - } catch (Throwable e) { - throw Throwables.propagate(e); - } - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/GetValueRouteContextExtractor.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/GetValueRouteContextExtractor.java deleted file mode 100644 index 5480d1814a..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/GetValueRouteContextExtractor.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.md.sal.binding.impl; - -import com.google.common.base.Throwables; -import java.lang.invoke.MethodHandle; -import java.lang.invoke.MethodHandles; -import java.lang.invoke.MethodHandles.Lookup; -import java.lang.invoke.MethodType; -import java.lang.reflect.Method; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -@Deprecated(forRemoval = true) -final class GetValueRouteContextExtractor extends ContextReferenceExtractor { - - private static final Lookup PUBLIC_LOOKUP = MethodHandles.publicLookup(); - private final MethodHandle contextHandle; - private final MethodHandle valueHandle; - - private GetValueRouteContextExtractor(final MethodHandle rawContextHandle, final MethodHandle rawValueHandle) { - contextHandle = rawContextHandle.asType(MethodType.methodType(Object.class, DataObject.class)); - valueHandle = rawValueHandle.asType(MethodType.methodType(InstanceIdentifier.class, Object.class)); - } - - public static ContextReferenceExtractor create(final Method contextGetter, final Method getValueMethod) - throws IllegalAccessException { - final MethodHandle rawContextHandle = PUBLIC_LOOKUP.unreflect(contextGetter); - final MethodHandle rawValueHandle = PUBLIC_LOOKUP.unreflect(getValueMethod); - return new GetValueRouteContextExtractor(rawContextHandle, rawValueHandle); - } - - @Override - @SuppressWarnings("checkstyle:IllegalCatch") - InstanceIdentifier extract(final DataObject obj) { - try { - final Object ctx = contextHandle.invokeExact(obj); - if (ctx != null) { - return (InstanceIdentifier) valueHandle.invokeExact(ctx); - } - return null; - } catch (Throwable e) { - throw Throwables.propagate(e); - } - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/LazyDOMRpcResultFuture.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/LazyDOMRpcResultFuture.java deleted file mode 100644 index dbdbf1d837..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/LazyDOMRpcResultFuture.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.impl; - -import static java.util.Objects.requireNonNull; - -import com.google.common.base.Throwables; -import com.google.common.util.concurrent.CheckedFuture; -import com.google.common.util.concurrent.ListenableFuture; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.Executor; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcException; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult; -import org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult; -import org.opendaylight.mdsal.binding.dom.adapter.BindingRpcFutureAware; -import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer; -import org.opendaylight.yangtools.yang.binding.DataContainer; -import org.opendaylight.yangtools.yang.common.RpcResult; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; - -@Deprecated(forRemoval = true) -final class LazyDOMRpcResultFuture implements CheckedFuture, BindingRpcFutureAware { - - private final ListenableFuture> bindingFuture; - private final BindingNormalizedNodeSerializer codec; - private volatile DOMRpcResult result; - - private LazyDOMRpcResultFuture(final ListenableFuture> delegate, - final BindingNormalizedNodeSerializer codec) { - this.bindingFuture = requireNonNull(delegate, "delegate"); - this.codec = requireNonNull(codec, "codec"); - } - - static CheckedFuture create(final BindingNormalizedNodeSerializer codec, - final ListenableFuture> bindingResult) { - return new LazyDOMRpcResultFuture(bindingResult, codec); - } - - @Override - public ListenableFuture> getBindingFuture() { - return bindingFuture; - } - - @Override - public boolean cancel(final boolean mayInterruptIfRunning) { - return bindingFuture.cancel(mayInterruptIfRunning); - } - - @Override - public void addListener(final Runnable listener, final Executor executor) { - bindingFuture.addListener(listener, executor); - } - - @Override - public DOMRpcResult get() throws InterruptedException, ExecutionException { - if (result != null) { - return result; - } - return transformIfNecessary(bindingFuture.get()); - } - - @Override - public DOMRpcResult get(final long timeout, final TimeUnit unit) throws InterruptedException, ExecutionException, - TimeoutException { - if (result != null) { - return result; - } - return transformIfNecessary(bindingFuture.get(timeout, unit)); - } - - @Override - public DOMRpcResult checkedGet() { - try { - return get(); - } catch (InterruptedException | ExecutionException e) { - // FIXME: Add exception mapping - throw Throwables.propagate(e); - } - } - - @Override - public DOMRpcResult checkedGet(final long timeout, final TimeUnit unit) throws TimeoutException { - try { - return get(timeout, unit); - } catch (InterruptedException | ExecutionException e) { - // FIXME: Add exception mapping - throw Throwables.propagate(e); - } - } - - @Override - public boolean isCancelled() { - return bindingFuture.isCancelled(); - } - - @Override - public boolean isDone() { - return bindingFuture.isDone(); - } - - private synchronized DOMRpcResult transformIfNecessary(final RpcResult input) { - if (result == null) { - result = transform(input); - } - return result; - } - - private DOMRpcResult transform(final RpcResult input) { - if (input.isSuccessful()) { - final Object inputData = input.getResult(); - if (inputData instanceof DataContainer) { - return new DefaultDOMRpcResult(codec.toNormalizedNodeRpcData((DataContainer) inputData)); - } else { - return new DefaultDOMRpcResult((NormalizedNode) null); - } - } - return new DefaultDOMRpcResult(input.getErrors()); - } - -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/LazyDataObjectModification.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/LazyDataObjectModification.java deleted file mode 100644 index 02ec48e1bb..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/LazyDataObjectModification.java +++ /dev/null @@ -1,297 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.impl; - -import static com.google.common.base.Verify.verify; -import static java.util.Objects.requireNonNull; -import static org.opendaylight.yangtools.yang.data.api.schema.tree.ModificationType.UNMODIFIED; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; -import java.util.Optional; -import java.util.stream.Collectors; -import java.util.stream.Stream; -import org.opendaylight.controller.md.sal.binding.api.DataObjectModification; -import org.opendaylight.mdsal.binding.dom.adapter.BindingStructuralType; -import org.opendaylight.mdsal.binding.dom.codec.api.BindingCodecTreeNode; -import org.opendaylight.mdsal.binding.dom.codec.api.BindingDataObjectCodecTreeNode; -import org.opendaylight.yangtools.yang.binding.Augmentation; -import org.opendaylight.yangtools.yang.binding.ChildOf; -import org.opendaylight.yangtools.yang.binding.ChoiceIn; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.Identifiable; -import org.opendaylight.yangtools.yang.binding.Identifier; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.IdentifiableItem; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.Item; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Lazily translated {@link DataObjectModification} based on {@link DataTreeCandidateNode}. - * - * {@link LazyDataObjectModification} represents Data tree change event, - * but whole tree is not translated or resolved eagerly, but only child nodes - * which are directly accessed by user of data object modification. - * - * @param Type of Binding Data Object - */ -@Deprecated(forRemoval = true) -final class LazyDataObjectModification implements DataObjectModification { - - private static final Logger LOG = LoggerFactory.getLogger(LazyDataObjectModification.class); - - private final BindingDataObjectCodecTreeNode codec; - private final DataTreeCandidateNode domData; - private final PathArgument identifier; - - private volatile Collection> childNodesCache; - private volatile ModificationType modificationType; - - private LazyDataObjectModification(final BindingDataObjectCodecTreeNode codec, - final DataTreeCandidateNode domData) { - this.codec = requireNonNull(codec); - this.domData = requireNonNull(domData); - this.identifier = codec.deserializePathArgument(domData.getIdentifier()); - } - - static LazyDataObjectModification create(final BindingDataObjectCodecTreeNode codec, - final DataTreeCandidateNode domData) { - return new LazyDataObjectModification<>(codec, domData); - } - - private static Collection> from( - final BindingDataObjectCodecTreeNode parentCodec, - final Collection domChildNodes) { - final List> result = new ArrayList<>(domChildNodes.size()); - populateList(result, parentCodec, domChildNodes); - return result; - } - - private static void populateList(final List> result, - final BindingDataObjectCodecTreeNode parentCodec, - final Collection domChildNodes) { - for (final DataTreeCandidateNode domChildNode : domChildNodes) { - if (domChildNode.getModificationType() != UNMODIFIED) { - final BindingStructuralType type = BindingStructuralType.from(domChildNode); - if (type != BindingStructuralType.NOT_ADDRESSABLE) { - /* - * Even if type is UNKNOWN, from perspective of BindingStructuralType - * we try to load codec for it. We will use that type to further specify - * debug log. - */ - try { - final BindingCodecTreeNode childCodec = parentCodec.yangPathArgumentChild( - domChildNode.getIdentifier()); - verify(childCodec instanceof BindingDataObjectCodecTreeNode, "Unhandled codec %s for type %s", - childCodec, type); - populateList(result, type, (BindingDataObjectCodecTreeNode) childCodec, domChildNode); - } catch (final IllegalArgumentException e) { - if (type == BindingStructuralType.UNKNOWN) { - LOG.debug("Unable to deserialize unknown DOM node {}", domChildNode, e); - } else { - LOG.debug("Binding representation for DOM node {} was not found", domChildNode, e); - } - } - } - } - } - } - - private static void populateList(final List> result, - final BindingStructuralType type, final BindingDataObjectCodecTreeNode childCodec, - final DataTreeCandidateNode domChildNode) { - switch (type) { - case INVISIBLE_LIST: - // We use parent codec intentionally. - populateListWithSingleCodec(result, childCodec, domChildNode.getChildNodes()); - break; - case INVISIBLE_CONTAINER: - populateList(result, childCodec, domChildNode.getChildNodes()); - break; - case UNKNOWN: - case VISIBLE_CONTAINER: - result.add(create(childCodec, domChildNode)); - break; - default: - break; - } - } - - private static void populateListWithSingleCodec(final List> result, - final BindingDataObjectCodecTreeNode codec, final Collection childNodes) { - for (final DataTreeCandidateNode child : childNodes) { - if (child.getModificationType() != UNMODIFIED) { - result.add(create(codec, child)); - } - } - } - - @Override - public T getDataBefore() { - return deserialize(domData.getDataBefore()); - } - - @Override - public T getDataAfter() { - return deserialize(domData.getDataAfter()); - } - - @Override - public Class getDataType() { - return codec.getBindingClass(); - } - - @Override - public PathArgument getIdentifier() { - return identifier; - } - - @Override - public ModificationType getModificationType() { - ModificationType localType = modificationType; - if (localType != null) { - return localType; - } - - switch (domData.getModificationType()) { - case APPEARED: - case WRITE: - localType = ModificationType.WRITE; - break; - case DISAPPEARED: - case DELETE: - localType = ModificationType.DELETE; - break; - case SUBTREE_MODIFIED: - localType = resolveSubtreeModificationType(); - break; - default: - // TODO: Should we lie about modification type instead of exception? - throw new IllegalStateException("Unsupported DOM Modification type " + domData.getModificationType()); - } - - modificationType = localType; - return localType; - } - - private ModificationType resolveSubtreeModificationType() { - switch (codec.getChildAddressabilitySummary()) { - case ADDRESSABLE: - // All children are addressable, it is safe to report SUBTREE_MODIFIED - return ModificationType.SUBTREE_MODIFIED; - case UNADDRESSABLE: - // All children are non-addressable, report WRITE - return ModificationType.WRITE; - case MIXED: - // This case is not completely trivial, as we may have NOT_ADDRESSABLE nodes underneath us. If that - // is the case, we need to turn this modification into a WRITE operation, so that the user is able - // to observe those nodes being introduced. This is not efficient, but unfortunately unavoidable, - // as we cannot accurately represent such changes. - for (DataTreeCandidateNode child : domData.getChildNodes()) { - if (BindingStructuralType.recursiveFrom(child) == BindingStructuralType.NOT_ADDRESSABLE) { - // We have a non-addressable child, turn this modification into a write - return ModificationType.WRITE; - } - } - - // No unaddressable children found, proceed in addressed mode - return ModificationType.SUBTREE_MODIFIED; - default: - throw new IllegalStateException("Unsupported child addressability summary " - + codec.getChildAddressabilitySummary()); - } - } - - @Override - public Collection> getModifiedChildren() { - Collection> local = childNodesCache; - if (local == null) { - childNodesCache = local = from(codec, domData.getChildNodes()); - } - return local; - } - - @Override - public & DataObject, C extends ChildOf> - Collection> getModifiedChildren(final Class caseType, - final Class childType) { - return streamModifiedChildren(childType) - .filter(child -> caseType.equals(child.identifier.getCaseType().orElse(null))) - .collect(Collectors.toList()); - } - - @SuppressWarnings("unchecked") - private Stream> streamModifiedChildren( - final Class childType) { - return getModifiedChildren().stream() - .filter(child -> childType.isAssignableFrom(child.getDataType())) - .map(child -> (LazyDataObjectModification) child); - } - - @Override - public DataObjectModification getModifiedChild(final PathArgument arg) { - final List domArgumentList = new ArrayList<>(); - final BindingDataObjectCodecTreeNode childCodec = codec.bindingPathArgumentChild(arg, domArgumentList); - final Iterator toEnter = domArgumentList.iterator(); - DataTreeCandidateNode current = domData; - while (toEnter.hasNext() && current != null) { - current = current.getModifiedChild(toEnter.next()).orElse(null); - } - return current != null && current.getModificationType() != UNMODIFIED ? create(childCodec, current) : null; - } - - @Override - @SuppressWarnings("unchecked") - public & ChildOf, K extends Identifier> DataObjectModification - getModifiedChildListItem(final Class listItem, final K listKey) { - return (DataObjectModification) getModifiedChild(IdentifiableItem.of(listItem, listKey)); - } - - @Override - @SuppressWarnings("unchecked") - public & DataObject, C extends Identifiable & ChildOf, - K extends Identifier> DataObjectModification getModifiedChildListItem(final Class caseType, - final Class listItem, final K listKey) { - return (DataObjectModification) getModifiedChild(IdentifiableItem.of(caseType, listItem, listKey)); - } - - @Override - @SuppressWarnings("unchecked") - public > DataObjectModification getModifiedChildContainer(final Class child) { - return (DataObjectModification) getModifiedChild(Item.of(child)); - } - - @Override - @SuppressWarnings("unchecked") - public & DataObject, C extends ChildOf> DataObjectModification - getModifiedChildContainer(final Class caseType, final Class child) { - return (DataObjectModification) getModifiedChild(Item.of(caseType, child)); - } - - @Override - @SuppressWarnings("unchecked") - public & DataObject> DataObjectModification getModifiedAugmentation( - final Class augmentation) { - return (DataObjectModification) getModifiedChild(Item.of(augmentation)); - } - - private T deserialize(final Optional> dataAfter) { - return dataAfter.map(codec::deserialize).orElse(null); - } - - @Override - public String toString() { - return getClass().getSimpleName() + "{identifier = " + identifier + ", domData = " + domData + "}"; - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/LazyDataTreeModification.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/LazyDataTreeModification.java deleted file mode 100644 index e64d6795ba..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/LazyDataTreeModification.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.impl; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Map.Entry; -import org.opendaylight.controller.md.sal.binding.api.DataObjectModification; -import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier; -import org.opendaylight.controller.md.sal.binding.api.DataTreeModification; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.mdsal.binding.dom.codec.api.BindingDataObjectCodecTreeNode; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate; - -/** - * Lazily translated {@link DataTreeModification} based on {@link DataTreeCandidate}. - * - * {@link DataTreeModification} represents Data tree change event, - * but whole tree is not translated or resolved eagerly, but only child nodes - * which are directly accessed by user of data object modification. - * - */ -@Deprecated(forRemoval = true) -class LazyDataTreeModification implements DataTreeModification { - - private final DataTreeIdentifier path; - private final DataObjectModification rootNode; - - LazyDataTreeModification(final LogicalDatastoreType datastoreType, final InstanceIdentifier path, - final BindingDataObjectCodecTreeNode codec, final DataTreeCandidate domChange) { - this.path = new DataTreeIdentifier<>(datastoreType, path); - this.rootNode = LazyDataObjectModification.create(codec, domChange.getRootNode()); - } - - @Override - public DataObjectModification getRootNode() { - return rootNode; - } - - @Override - public DataTreeIdentifier getRootPath() { - return path; - } - - @SuppressWarnings({"unchecked", "rawtypes"}) - static DataTreeModification create(final BindingToNormalizedNodeCodec codec, - final DataTreeCandidate domChange, final LogicalDatastoreType datastoreType) { - final Entry, BindingDataObjectCodecTreeNode> codecCtx = - codec.getSubtreeCodec(domChange.getRootPath()); - return new LazyDataTreeModification(datastoreType, codecCtx.getKey(), codecCtx.getValue(), domChange); - } - - static Collection> from(final BindingToNormalizedNodeCodec codec, - final Collection domChanges, final LogicalDatastoreType datastoreType) { - final List> result = new ArrayList<>(domChanges.size()); - for (final DataTreeCandidate domChange : domChanges) { - result.add(LazyDataTreeModification.create(codec, domChange, datastoreType)); - } - return result; - } - - @Override - public String toString() { - return getClass().getSimpleName() + "{path = " + path + ", rootNode = " + rootNode + "}"; - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/LazySerializedContainerNode.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/LazySerializedContainerNode.java deleted file mode 100644 index 07fbf05b3d..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/LazySerializedContainerNode.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.impl; - -import java.util.Collection; -import java.util.Optional; -import org.opendaylight.mdsal.binding.dom.adapter.BindingDataAware; -import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; -import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; -import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild; -import org.opendaylight.yangtools.yang.data.api.schema.LeafNode; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; - -// FIXME: Should be this moved to binding-data-codec? -@Deprecated(forRemoval = true) -class LazySerializedContainerNode implements ContainerNode, BindingDataAware { - - private final NodeIdentifier identifier; - private final DataObject bindingData; - - private BindingNormalizedNodeSerializer registry; - private ContainerNode domData; - - private LazySerializedContainerNode(final QName identifier, final DataObject binding, - final BindingNormalizedNodeSerializer registry) { - this.identifier = new NodeIdentifier(identifier); - this.bindingData = binding; - this.registry = registry; - this.domData = null; - } - - static NormalizedNode create(final SchemaPath rpcName, final DataObject data, - final BindingNormalizedNodeSerializer codec) { - return new LazySerializedContainerNode(rpcName.getLastComponent(), data, codec); - } - - static NormalizedNode withContextRef(final SchemaPath rpcName, final DataObject data, - final LeafNode contextRef, final BindingNormalizedNodeSerializer codec) { - return new WithContextRef(rpcName.getLastComponent(), data, contextRef, codec); - } - - private ContainerNode delegate() { - if (domData == null) { - domData = registry.toNormalizedNodeRpcData(bindingData); - registry = null; - } - return domData; - } - - @Override - public final QName getNodeType() { - return identifier.getNodeType(); - } - - @Override - public final Collection> getValue() { - return delegate().getValue(); - } - - @Override - public final NodeIdentifier getIdentifier() { - return identifier; - } - - @Override - public Optional> getChild(final PathArgument child) { - return delegate().getChild(child); - } - - @Override - public final DataObject bindingData() { - return bindingData; - } - - /** - * Lazy Serialized Node with pre-cached serialized leaf holding routing information. - * - */ - private static final class WithContextRef extends LazySerializedContainerNode { - - private final LeafNode contextRef; - - protected WithContextRef(final QName identifier, final DataObject binding, final LeafNode contextRef, - final BindingNormalizedNodeSerializer registry) { - super(identifier, binding, registry); - this.contextRef = contextRef; - } - - @Override - public Optional> getChild(final PathArgument child) { - /* - * Use precached value of routing field and do not run full serialization if we are - * accessing it. - */ - if (contextRef.getIdentifier().equals(child)) { - return Optional.>of(contextRef); - } - return super.getChild(child); - } - } - -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/LazySerializedDOMNotification.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/LazySerializedDOMNotification.java deleted file mode 100644 index 0caa1a7e2f..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/LazySerializedDOMNotification.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.impl; - -import org.opendaylight.controller.md.sal.dom.api.DOMNotification; -import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer; -import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections; -import org.opendaylight.yangtools.yang.binding.Notification; -import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; - -/** - * Lazy serialized implementation of DOM Notification. - * - *

- * This implementation performs serialization of data, only if receiver - * of notification actually accessed data from notification. - * - */ -@Deprecated(forRemoval = true) -public final class LazySerializedDOMNotification implements DOMNotification { - - private final BindingNormalizedNodeSerializer codec; - private final Notification data; - private final SchemaPath type; - - private ContainerNode domBody; - - private LazySerializedDOMNotification(final BindingNormalizedNodeSerializer codec, final Notification data, - final SchemaPath type) { - this.codec = codec; - this.data = data; - this.type = type; - } - - static DOMNotification create(final BindingNormalizedNodeSerializer codec, final Notification data) { - final SchemaPath type = SchemaPath.create(true, BindingReflections.findQName(data.implementedInterface())); - return new LazySerializedDOMNotification(codec, data, type); - } - - @Override - public SchemaPath getType() { - return type; - } - - @Override - public ContainerNode getBody() { - if (domBody == null) { - domBody = codec.toNormalizedNodeNotification(data); - } - return domBody; - } - - public Notification getBindingData() { - return data; - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/RpcServiceAdapter.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/RpcServiceAdapter.java deleted file mode 100644 index 28ac50fb8d..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/RpcServiceAdapter.java +++ /dev/null @@ -1,225 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.impl; - -import static java.util.Objects.requireNonNull; - -import com.google.common.collect.ImmutableMap; -import com.google.common.util.concurrent.CheckedFuture; -import com.google.common.util.concurrent.Futures; -import com.google.common.util.concurrent.ListenableFuture; -import com.google.common.util.concurrent.MoreExecutors; -import java.lang.reflect.InvocationHandler; -import java.lang.reflect.Method; -import java.lang.reflect.Proxy; -import java.util.Collection; -import java.util.Map.Entry; -import java.util.concurrent.Future; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcException; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcService; -import org.opendaylight.controller.md.sal.dom.broker.spi.rpc.RpcRoutingStrategy; -import org.opendaylight.controller.sal.core.compat.LegacyDOMRpcResultFutureAdapter; -import org.opendaylight.mdsal.binding.dom.adapter.BindingRpcFutureAware; -import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer; -import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections; -import org.opendaylight.yangtools.yang.binding.DataContainer; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.binding.RpcService; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.common.RpcError; -import org.opendaylight.yangtools.yang.common.RpcError.ErrorSeverity; -import org.opendaylight.yangtools.yang.common.RpcResult; -import org.opendaylight.yangtools.yang.common.RpcResultBuilder; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; -import org.opendaylight.yangtools.yang.data.api.schema.LeafNode; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; -import org.opendaylight.yangtools.yang.model.api.RpcDefinition; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; - -@Deprecated(forRemoval = true) -class RpcServiceAdapter implements InvocationHandler { - - private final ImmutableMap rpcNames; - private final Class type; - private final BindingToNormalizedNodeCodec codec; - private final DOMRpcService delegate; - private final RpcService proxy; - - RpcServiceAdapter(final Class type, final BindingToNormalizedNodeCodec codec, - final DOMRpcService domService) { - this.type = requireNonNull(type); - this.codec = requireNonNull(codec); - this.delegate = requireNonNull(domService); - final ImmutableMap.Builder rpcBuilder = ImmutableMap.builder(); - for (final Entry rpc : codec.getRpcMethodToSchema(type).entrySet()) { - rpcBuilder.put(rpc.getKey(), createStrategy(rpc.getKey(), rpc.getValue())); - } - rpcNames = rpcBuilder.build(); - proxy = (RpcService) Proxy.newProxyInstance(type.getClassLoader(), new Class[] {type}, this); - } - - ListenableFuture> invoke0(final SchemaPath schemaPath, final NormalizedNode input) { - final CheckedFuture result = delegate.invokeRpc(schemaPath, input); - if (result instanceof BindingRpcFutureAware) { - return ((BindingRpcFutureAware) result).getBindingFuture(); - } else if (result instanceof LegacyDOMRpcResultFutureAdapter) { - Future delegateFuture = - ((LegacyDOMRpcResultFutureAdapter)result).delegate(); - if (delegateFuture instanceof BindingRpcFutureAware) { - return ((BindingRpcFutureAware) delegateFuture).getBindingFuture(); - } - } - - return transformFuture(schemaPath, result, codec.getCodecFactory()); - } - - private RpcInvocationStrategy createStrategy(final Method method, final RpcDefinition schema) { - final RpcRoutingStrategy strategy = RpcRoutingStrategy.from(schema); - if (strategy.isContextBasedRouted()) { - return new RoutedStrategy(schema.getPath(), method, strategy.getLeaf()); - } - return new NonRoutedStrategy(schema.getPath()); - } - - RpcService getProxy() { - return proxy; - } - - @Override - public Object invoke(final Object proxyObj, final Method method, final Object[] args) { - - final RpcInvocationStrategy rpc = rpcNames.get(method); - if (rpc != null) { - if (method.getParameterCount() == 0) { - return rpc.invokeEmpty(); - } - if (args.length != 1) { - throw new IllegalArgumentException("Input must be provided."); - } - return rpc.invoke((DataObject) args[0]); - } - - if (isObjectMethod(method)) { - return callObjectMethod(proxyObj, method, args); - } - throw new UnsupportedOperationException("Method " + method.toString() + "is unsupported."); - } - - private static boolean isObjectMethod(final Method method) { - switch (method.getName()) { - case "toString": - return method.getReturnType().equals(String.class) && method.getParameterCount() == 0; - case "hashCode": - return method.getReturnType().equals(int.class) && method.getParameterCount() == 0; - case "equals": - return method.getReturnType().equals(boolean.class) && method.getParameterCount() == 1 && method - .getParameterTypes()[0] == Object.class; - default: - return false; - } - } - - private Object callObjectMethod(final Object self, final Method method, final Object[] args) { - switch (method.getName()) { - case "toString": - return type.getName() + "$Adapter{delegate=" + delegate.toString() + "}"; - case "hashCode": - return System.identityHashCode(self); - case "equals": - return self == args[0]; - default: - return null; - } - } - - private static ListenableFuture> transformFuture(final SchemaPath rpc, - final ListenableFuture domFuture, final BindingNormalizedNodeSerializer codec) { - return Futures.transform(domFuture, input -> { - final NormalizedNode domData = input.getResult(); - final DataObject bindingResult; - if (domData != null) { - final SchemaPath rpcOutput = rpc.createChild(QName.create(rpc.getLastComponent(), "output")); - bindingResult = codec.fromNormalizedNodeRpcData(rpcOutput, (ContainerNode) domData); - } else { - bindingResult = null; - } - - // DOMRpcResult does not have a notion of success, hence we have to reverse-engineer it by looking - // at reported errors and checking whether they are just warnings. - final Collection errors = input.getErrors(); - return RpcResult.class.cast(RpcResultBuilder.status(errors.stream() - .noneMatch(error -> error.getSeverity() == ErrorSeverity.ERROR)) - .withResult(bindingResult).withRpcErrors(errors).build()); - }, MoreExecutors.directExecutor()); - } - - private abstract class RpcInvocationStrategy { - - private final SchemaPath rpcName; - - protected RpcInvocationStrategy(final SchemaPath path) { - rpcName = path; - } - - final ListenableFuture> invoke(final DataObject input) { - return invoke0(rpcName, serialize(input)); - } - - abstract NormalizedNode serialize(DataObject input); - - final ListenableFuture> invokeEmpty() { - return invoke0(rpcName, null); - } - - final SchemaPath getRpcName() { - return rpcName; - } - } - - private final class NonRoutedStrategy extends RpcInvocationStrategy { - - protected NonRoutedStrategy(final SchemaPath path) { - super(path); - } - - @Override - NormalizedNode serialize(final DataObject input) { - return LazySerializedContainerNode.create(getRpcName(), input, codec.getCodecRegistry()); - } - } - - private final class RoutedStrategy extends RpcInvocationStrategy { - - private final ContextReferenceExtractor refExtractor; - private final NodeIdentifier contextName; - - protected RoutedStrategy(final SchemaPath path, final Method rpcMethod, final QName leafName) { - super(path); - final Class inputType = BindingReflections.resolveRpcInputClass(rpcMethod).get(); - refExtractor = ContextReferenceExtractor.from(inputType); - this.contextName = new NodeIdentifier(leafName); - } - - @Override - NormalizedNode serialize(final DataObject input) { - final InstanceIdentifier bindingII = refExtractor.extract(input); - if (bindingII != null) { - final YangInstanceIdentifier yangII = codec.toYangInstanceIdentifierCached(bindingII); - final LeafNode contextRef = ImmutableNodes.leafNode(contextName, yangII); - return LazySerializedContainerNode.withContextRef(getRpcName(), input, contextRef, - codec.getCodecRegistry()); - } - return LazySerializedContainerNode.create(getRpcName(), input, codec.getCodecRegistry()); - } - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/spi/AdapterBuilder.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/spi/AdapterBuilder.java deleted file mode 100644 index 597900938b..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/spi/AdapterBuilder.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.spi; - -import com.google.common.base.Preconditions; -import com.google.common.collect.ClassToInstanceMap; -import com.google.common.collect.ImmutableClassToInstanceMap; -import com.google.common.collect.MutableClassToInstanceMap; -import java.util.Set; -import org.opendaylight.yangtools.concepts.Builder; - -@Deprecated(forRemoval = true) -public abstract class AdapterBuilder implements Builder { - - private final ClassToInstanceMap delegates = MutableClassToInstanceMap.create(); - - public abstract Set> getRequiredDelegates(); - - protected abstract T createInstance(ClassToInstanceMap classToInstanceMap); - - private void checkAllRequiredServices() { - for (final Class type : getRequiredDelegates()) { - Preconditions.checkState(delegates.get(type) != null, "Requires service %s is not defined.",type); - } - } - - public final void addDelegate(final Class type,final D impl) { - delegates.put(type,impl); - } - - @Override - public final T build() { - checkAllRequiredServices(); - return createInstance(ImmutableClassToInstanceMap.copyOf(delegates)); - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/spi/AdapterFactory.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/spi/AdapterFactory.java deleted file mode 100644 index dfc1a71983..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/spi/AdapterFactory.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.spi; - -import com.google.common.annotations.Beta; -import org.eclipse.jdt.annotation.NonNullByDefault; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; - -@Beta -@Deprecated(forRemoval = true) -@NonNullByDefault -public interface AdapterFactory { - /** - * Return a {@link DataBroker} implementation backed by the specified {@link DOMDataBroker}. - * - * @param domBroker Backing DOMDataBroker - * @return A DataBroker instance. - * @throws NullPointerException if {@code domBroker} is null. - */ - DataBroker createDataBroker(DOMDataBroker domBroker); -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/spi/AdapterLoader.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/spi/AdapterLoader.java deleted file mode 100644 index f3fac3c9fe..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/spi/AdapterLoader.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.spi; - -import com.google.common.base.Optional; -import com.google.common.cache.CacheLoader; -import org.eclipse.jdt.annotation.NonNull; -import org.eclipse.jdt.annotation.Nullable; -import org.gaul.modernizer_maven_annotations.SuppressModernizer; - -@Deprecated(forRemoval = true) -public abstract class AdapterLoader extends CacheLoader, Optional> { - - @Override - @SuppressModernizer - public Optional load(final Class key) { - - final AdapterBuilder builder = createBuilder(key); - for (final Class reqDeleg : builder.getRequiredDelegates()) { - final D deleg = getDelegate(reqDeleg); - if (deleg != null) { - builder.addDelegate(reqDeleg, deleg); - } else { - return Optional.absent(); - } - } - return Optional.of(builder.build()); - } - - protected abstract @Nullable D getDelegate(Class reqDeleg); - - protected abstract @NonNull AdapterBuilder createBuilder(Class key); -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/RootBindingAwareBroker.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/RootBindingAwareBroker.java deleted file mode 100644 index fbcf2167cd..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/RootBindingAwareBroker.java +++ /dev/null @@ -1,200 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.binding.impl; - -import static com.google.common.base.Preconditions.checkState; - -import com.google.common.collect.ImmutableClassToInstanceMap; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.MountPointService; -import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; -import org.opendaylight.controller.md.sal.binding.util.AbstractBindingSalProviderInstance; -import org.opendaylight.controller.md.sal.binding.util.BindingContextUtils; -import org.opendaylight.controller.md.sal.common.api.routing.RouteChangeListener; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; -import org.opendaylight.controller.sal.binding.api.BindingAwareConsumer; -import org.opendaylight.controller.sal.binding.api.BindingAwareProvider; -import org.opendaylight.controller.sal.binding.api.BindingAwareService; -import org.opendaylight.controller.sal.binding.api.NotificationProviderService; -import org.opendaylight.controller.sal.binding.api.NotificationService; -import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry; -import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; -import org.opendaylight.controller.sal.binding.api.rpc.RpcContextIdentifier; -import org.opendaylight.yangtools.concepts.Identifiable; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.concepts.Mutable; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.binding.RpcService; -import org.osgi.framework.BundleContext; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@Deprecated(forRemoval = true) -public class RootBindingAwareBroker implements Mutable, Identifiable, BindingAwareBroker, AutoCloseable, - RpcProviderRegistry { - - private static final Logger LOG = LoggerFactory.getLogger(RootBindingAwareBroker.class); - - RootSalInstance controllerRoot; - - private final String identifier; - - private RpcProviderRegistry rpcBroker; - - private NotificationProviderService notificationBroker; - - private NotificationPublishService notificationPublishService; - - private DataBroker dataBroker; - - private ImmutableClassToInstanceMap supportedConsumerServices; - - private ImmutableClassToInstanceMap supportedProviderServices; - - private MountPointService mountService; - - public RootBindingAwareBroker(final String instanceName) { - this.identifier = instanceName; - } - - @Override - public String getIdentifier() { - return identifier; - } - - public RootSalInstance getRoot() { - return controllerRoot; - } - - public NotificationProviderService getNotificationBroker() { - return this.notificationBroker; - } - - public NotificationPublishService getNotificationPublishService() { - return this.notificationPublishService; - } - - public RpcProviderRegistry getRpcProviderRegistry() { - return this.rpcBroker; - } - - public RpcProviderRegistry getRpcBroker() { - return rpcBroker; - } - - public MountPointService getMountService() { - return mountService; - } - - public void setDataBroker(final DataBroker asyncDataBroker) { - dataBroker = asyncDataBroker; - } - - public void setMountService(final MountPointService mount) { - this.mountService = mount; - } - - public void setRpcBroker(final RpcProviderRegistry rpcBroker) { - this.rpcBroker = rpcBroker; - } - - public void setNotificationBroker(final NotificationProviderService notificationBroker) { - this.notificationBroker = notificationBroker; - } - - public void setNotificationPublishService(final NotificationPublishService notificationPublishService) { - this.notificationPublishService = notificationPublishService; - } - - public void start() { - checkState(controllerRoot == null, "Binding Aware Broker was already started."); - LOG.info("Starting Binding Aware Broker: {}", identifier); - - controllerRoot = new RootSalInstance(getRpcProviderRegistry(), getNotificationBroker()); - - final ImmutableClassToInstanceMap.Builder consBuilder = ImmutableClassToInstanceMap - .builder(); - - consBuilder.put(NotificationService.class, getRoot()); - consBuilder.put(RpcConsumerRegistry.class, getRoot()); - if (dataBroker != null) { - consBuilder.put(DataBroker.class, dataBroker); - } - consBuilder.put(MountPointService.class, mountService); - - supportedConsumerServices = consBuilder.build(); - final ImmutableClassToInstanceMap.Builder provBuilder = ImmutableClassToInstanceMap - .builder(); - provBuilder.putAll(supportedConsumerServices).put(NotificationProviderService.class, getRoot()) - .put(RpcProviderRegistry.class, getRoot()); - if (notificationPublishService != null) { - provBuilder.put(NotificationPublishService.class, notificationPublishService); - } - - supportedProviderServices = provBuilder.build(); - } - - @Override - public ConsumerContext registerConsumer(final BindingAwareConsumer consumer, final BundleContext ctx) { - return registerConsumer(consumer); - } - - @Override - public ConsumerContext registerConsumer(final BindingAwareConsumer consumer) { - checkState(supportedConsumerServices != null, "Broker is not initialized."); - return BindingContextUtils.createConsumerContextAndInitialize(consumer, supportedConsumerServices); - } - - @Override - public ProviderContext registerProvider(final BindingAwareProvider provider, final BundleContext ctx) { - return registerProvider(provider); - } - - @Override - public ProviderContext registerProvider(final BindingAwareProvider provider) { - checkState(supportedProviderServices != null, "Broker is not initialized."); - return BindingContextUtils.createProviderContextAndInitialize(provider, supportedProviderServices); - } - - @Override - public void close() { - // FIXME: Close all sessions - } - - @Override - public RoutedRpcRegistration addRoutedRpcImplementation(final Class type, - final T implementation) throws IllegalStateException { - return getRoot().addRoutedRpcImplementation(type, implementation); - } - - @Override - public RpcRegistration addRpcImplementation(final Class type, final T implementation) - throws IllegalStateException { - return getRoot().addRpcImplementation(type, implementation); - } - - @Override - public T getRpcService(final Class module) { - return getRoot().getRpcService(module); - } - - @Override - public >> ListenerRegistration - registerRouteChangeListener(final L listener) { - return getRoot().registerRouteChangeListener(listener); - } - - public static class RootSalInstance extends - AbstractBindingSalProviderInstance { - - public RootSalInstance(final RpcProviderRegistry rpcRegistry, - final NotificationProviderService notificationBroker) { - super(rpcRegistry, notificationBroker); - } - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/resources/OSGI-INF/blueprint/binding-broker.xml b/opendaylight/md-sal/sal-binding-broker/src/main/resources/OSGI-INF/blueprint/binding-broker.xml deleted file mode 100644 index 899f147a8b..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/resources/OSGI-INF/blueprint/binding-broker.xml +++ /dev/null @@ -1,114 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer - org.opendaylight.mdsal.binding.dom.codec.api.BindingCodecTreeFactory - - - - - - - - - org.opendaylight.controller.md.sal.binding.spi.AdapterFactory - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMDataTreeChangeServiceAdapterTest.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMDataTreeChangeServiceAdapterTest.java deleted file mode 100644 index 0a27f95e58..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMDataTreeChangeServiceAdapterTest.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2015 Brocade Communications Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.impl; - -import static org.mockito.AdditionalMatchers.not; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.isA; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.reset; -import static org.mockito.Mockito.verify; - -import java.util.Collection; -import org.junit.Before; -import org.junit.Test; -import org.mockito.ArgumentMatchers; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.opendaylight.controller.md.sal.binding.api.ClusteredDataTreeChangeListener; -import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener; -import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeService; -import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier; -import org.opendaylight.controller.md.sal.binding.api.DataTreeModification; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.dom.api.ClusteredDOMDataTreeChangeListener; -import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener; -import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeService; -import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeIdentifier; -import org.opendaylight.mdsal.binding.dom.codec.impl.BindingNormalizedNodeCodecRegistry; -import org.opendaylight.mdsal.binding.generator.impl.GeneratedClassLoadingStrategy; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; - -/** - * Unit tests for BindingDOMDataTreeChangeServiceAdapter. - * - * @author Thomas Pantelis - */ -@Deprecated -public class BindingDOMDataTreeChangeServiceAdapterTest { - private static final InstanceIdentifier TOP_PATH = InstanceIdentifier.create(Top.class); - - @Mock - private DOMDataTreeChangeService mockDOMService; - - @Mock - private GeneratedClassLoadingStrategy classLoadingStrategy; - - @Mock - private BindingNormalizedNodeCodecRegistry codecRegistry; - - @Mock - private YangInstanceIdentifier mockYangID; - - @SuppressWarnings("rawtypes") - @Mock - private ListenerRegistration mockDOMReg; - - @Before - public void setUp() { - MockitoAnnotations.initMocks(this); - doReturn(this.mockYangID).when(this.codecRegistry).toYangInstanceIdentifier(TOP_PATH); - } - - @Test - public void testRegisterDataTreeChangeListener() { - final BindingToNormalizedNodeCodec codec = - new BindingToNormalizedNodeCodec(this.classLoadingStrategy, this.codecRegistry); - - final DataTreeChangeService service = BindingDOMDataTreeChangeServiceAdapter.create(codec, this.mockDOMService); - - doReturn(this.mockDOMReg).when(this.mockDOMService).registerDataTreeChangeListener( - domDataTreeIdentifier(this.mockYangID), - any(DOMDataTreeChangeListener.class)); - final DataTreeIdentifier treeId = new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, TOP_PATH); - final TestClusteredDataTreeChangeListener mockClusteredListener = new TestClusteredDataTreeChangeListener(); - service.registerDataTreeChangeListener(treeId , mockClusteredListener); - - verify(this.mockDOMService).registerDataTreeChangeListener(domDataTreeIdentifier(this.mockYangID), - isA(ClusteredDOMDataTreeChangeListener.class)); - - reset(this.mockDOMService); - doReturn(this.mockDOMReg).when(this.mockDOMService).registerDataTreeChangeListener( - domDataTreeIdentifier(this.mockYangID), any(DOMDataTreeChangeListener.class)); - final TestDataTreeChangeListener mockNonClusteredListener = new TestDataTreeChangeListener(); - service.registerDataTreeChangeListener(treeId , mockNonClusteredListener); - - verify(this.mockDOMService).registerDataTreeChangeListener(domDataTreeIdentifier(this.mockYangID), - not(isA(ClusteredDOMDataTreeChangeListener.class))); - } - - static DOMDataTreeIdentifier domDataTreeIdentifier(final YangInstanceIdentifier yangID) { - return ArgumentMatchers.argThat(treeId -> treeId.getDatastoreType() == LogicalDatastoreType.CONFIGURATION - && yangID.equals(treeId.getRootIdentifier())); - } - - @Deprecated - private static class TestClusteredDataTreeChangeListener implements ClusteredDataTreeChangeListener { - @Override - public void onDataTreeChanged(final Collection> changes) { - } - } - - @Deprecated - private static class TestDataTreeChangeListener implements DataTreeChangeListener { - @Override - public void onDataTreeChanged(final Collection> changes) { - } - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMMountPointServiceAdapterTest.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMMountPointServiceAdapterTest.java deleted file mode 100644 index 7c022b065b..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMMountPointServiceAdapterTest.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2019 FRINX and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.impl; - -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.spy; - -import com.google.common.base.Optional; -import com.google.common.cache.LoadingCache; -import org.gaul.modernizer_maven_annotations.SuppressModernizer; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint; -import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService; -import org.opendaylight.mdsal.binding.dom.codec.impl.BindingNormalizedNodeCodecRegistry; -import org.opendaylight.mdsal.binding.generator.api.ClassLoadingStrategy; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; - -@Deprecated -public class BindingDOMMountPointServiceAdapterTest { - - @Mock - private DOMMountPointService mountService; - // Use a real instance of codec, since its getCodecRegistry() method is final and cannot be mocked - private BindingToNormalizedNodeCodec codec; - @Mock - private BindingNormalizedNodeCodecRegistry codecRegistry; - @Mock - private ClassLoadingStrategy classLoadingStrategy; - - @Before - @SuppressModernizer - public void setUp() { - MockitoAnnotations.initMocks(this); - codec = spy(new BindingToNormalizedNodeCodec(classLoadingStrategy, codecRegistry)); - doReturn(Optional.of(mock(DOMMountPoint.class))) - .when(mountService).getMountPoint(any(YangInstanceIdentifier.class)); - doReturn(YangInstanceIdentifier.create(new YangInstanceIdentifier.NodeIdentifier(QName.create("(a)b")))) - .when(codec).toYangInstanceIdentifierBlocking(any(InstanceIdentifier.class)); - doReturn(InstanceIdentifier.create(DataObject.class)) - .when(codecRegistry).fromYangInstanceIdentifier(any(YangInstanceIdentifier.class)); - } - - @Test(timeout = 30 * 1000) - public void testCaching() throws Exception { - BindingDOMMountPointServiceAdapter baService = new BindingDOMMountPointServiceAdapter(mountService, codec); - LoadingCache cache = baService.bindingMountpoints; - - baService.getMountPoint(InstanceIdentifier.create(DataObject.class)); - - while (true) { - cache.cleanUp(); - System.gc(); - Thread.sleep(100); - if (cache.asMap().keySet().size() == 0) { - // Cache has been cleared, the single cache entry was garbage collected - return; - } - } - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/BindingNormalizedCodecTest.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/BindingNormalizedCodecTest.java deleted file mode 100644 index e3af1cf2eb..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/BindingNormalizedCodecTest.java +++ /dev/null @@ -1,190 +0,0 @@ -/* - * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.impl; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import com.google.common.collect.ImmutableBiMap; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ImmutableSetMultimap; -import com.google.common.collect.SetMultimap; -import com.google.common.util.concurrent.Uninterruptibles; -import java.lang.reflect.Method; -import java.net.URI; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicReference; -import org.junit.Test; -import org.opendaylight.controller.md.sal.binding.test.AbstractSchemaAwareTest; -import org.opendaylight.mdsal.binding.dom.codec.impl.BindingNormalizedNodeCodecRegistry; -import org.opendaylight.mdsal.binding.generator.impl.GeneratedClassLoadingStrategy; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.TreeComplexUsesAugment; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.TreeLeafOnlyAugment; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.bi.ba.rpcservice.rev140701.OpendaylightTestRpcServiceService; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListKey; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.common.QNameModule; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; -import org.opendaylight.yangtools.yang.model.api.Module; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; -import org.opendaylight.yangtools.yang.model.util.AbstractSchemaContext; - -@Deprecated -public class BindingNormalizedCodecTest extends AbstractSchemaAwareTest { - - private static final TopLevelListKey TOP_FOO_KEY = new TopLevelListKey("foo"); - private static final InstanceIdentifier BA_TOP_LEVEL_LIST = InstanceIdentifier - .builder(Top.class).child(TopLevelList.class, TOP_FOO_KEY).build(); - private static final InstanceIdentifier BA_TREE_LEAF_ONLY = - BA_TOP_LEVEL_LIST.augmentation(TreeLeafOnlyAugment.class); - private static final InstanceIdentifier BA_TREE_COMPLEX_USES = - BA_TOP_LEVEL_LIST.augmentation(TreeComplexUsesAugment.class); - private static final QName SIMPLE_VALUE_QNAME = QName.create(TreeComplexUsesAugment.QNAME, "simple-value"); - private static final QName NAME_QNAME = QName.create(Top.QNAME, "name"); - private static final YangInstanceIdentifier BI_TOP_LEVEL_LIST = YangInstanceIdentifier.builder() - .node(Top.QNAME).node(TopLevelList.QNAME).nodeWithKey( - TopLevelList.QNAME, NAME_QNAME, TOP_FOO_KEY.getName()).build(); - - - private BindingToNormalizedNodeCodec codec; - private SchemaContext context; - - @Override - protected void setupWithSchema(final SchemaContext schemaContext) { - this.context = schemaContext; - final BindingNormalizedNodeCodecRegistry registry = new BindingNormalizedNodeCodecRegistry(); - this.codec = new BindingToNormalizedNodeCodec(GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy(), - registry, true); - } - - @Test - public void testComplexAugmentationSerialization() { - this.codec.onGlobalContextUpdated(this.context); - final PathArgument lastArg = this.codec.toYangInstanceIdentifier(BA_TREE_COMPLEX_USES).getLastPathArgument(); - assertTrue(lastArg instanceof AugmentationIdentifier); - } - - - @Test - public void testLeafOnlyAugmentationSerialization() { - this.codec.onGlobalContextUpdated(this.context); - final PathArgument leafOnlyLastArg = this.codec.toYangInstanceIdentifier(BA_TREE_LEAF_ONLY) - .getLastPathArgument(); - assertTrue(leafOnlyLastArg instanceof AugmentationIdentifier); - assertTrue(((AugmentationIdentifier) leafOnlyLastArg).getPossibleChildNames().contains(SIMPLE_VALUE_QNAME)); - } - - @Test - @SuppressWarnings("checkstyle:IllegalCatch") - public void testToYangInstanceIdentifierBlocking() { - this.codec.onGlobalContextUpdated(new EmptySchemaContext()); - - final CountDownLatch done = new CountDownLatch(1); - final AtomicReference yangId = new AtomicReference<>(); - final AtomicReference error = new AtomicReference<>(); - - new Thread(() -> { - try { - yangId.set(BindingNormalizedCodecTest.this.codec.toYangInstanceIdentifierBlocking(BA_TOP_LEVEL_LIST)); - } catch (RuntimeException e) { - error.set(e); - } finally { - done.countDown(); - } - }).start(); - - Uninterruptibles.sleepUninterruptibly(500, TimeUnit.MILLISECONDS); - this.codec.onGlobalContextUpdated(this.context); - - assertEquals("toYangInstanceIdentifierBlocking completed", true, - Uninterruptibles.awaitUninterruptibly(done, 3, TimeUnit.SECONDS)); - if (error.get() != null) { - throw error.get(); - } - - assertEquals("toYangInstanceIdentifierBlocking", BI_TOP_LEVEL_LIST, yangId.get()); - } - - @Test - public void testGetRpcMethodToSchemaPathWithNoInitialSchemaContext() { - testGetRpcMethodToSchemaPath(); - } - - @Test - public void testGetRpcMethodToSchemaPathBlocking() { - this.codec.onGlobalContextUpdated(new EmptySchemaContext()); - testGetRpcMethodToSchemaPath(); - } - - @SuppressWarnings("checkstyle:IllegalCatch") - private void testGetRpcMethodToSchemaPath() { - final CountDownLatch done = new CountDownLatch(1); - final AtomicReference> retMap = new AtomicReference<>(); - final AtomicReference error = new AtomicReference<>(); - new Thread(() -> { - try { - retMap.set(BindingNormalizedCodecTest.this.codec.getRpcMethodToSchemaPath( - OpendaylightTestRpcServiceService.class)); - } catch (RuntimeException e) { - error.set(e); - } finally { - done.countDown(); - } - }).start(); - - Uninterruptibles.sleepUninterruptibly(500, TimeUnit.MILLISECONDS); - this.codec.onGlobalContextUpdated(this.context); - - assertEquals("getRpcMethodToSchemaPath completed", true, - Uninterruptibles.awaitUninterruptibly(done, 3, TimeUnit.SECONDS)); - if (error.get() != null) { - throw error.get(); - } - - for (final Method method: retMap.get().keySet()) { - if (method.getName().equals("rockTheHouse")) { - return; - } - } - - fail("rockTheHouse RPC method not found"); - } - - static class EmptySchemaContext extends AbstractSchemaContext { - @Override - public Set getModules() { - return ImmutableSet.of(); - } - - @Override - protected Map getModuleMap() { - return ImmutableMap.of(); - } - - @Override - protected SetMultimap getNamespaceToModules() { - return ImmutableSetMultimap.of(); - } - - @Override - protected SetMultimap getNameToModules() { - return ImmutableSetMultimap.of(); - } - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/ContextExtractorTest.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/ContextExtractorTest.java deleted file mode 100644 index 616c33423d..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/ContextExtractorTest.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.impl; - -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertSame; - -import org.junit.Test; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.bi.ba.rpcservice.rev140701.RockTheHouseInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.bi.ba.rpcservice.rev140701.RockTheHouseInputBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.rpc.routing.rev140701.EncapsulatedRoute; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.rpc.routing.rev140701.EncapsulatedRouteInGrouping; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.rpc.routing.rev140701.RoutedSimpleRouteInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.rpc.routing.rev140701.RoutedSimpleRouteInputBuilder; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -@Deprecated -public final class ContextExtractorTest { - - public interface Transitive extends EncapsulatedRouteInGrouping { - - } - - private static final InstanceIdentifier TEST_ROUTE = InstanceIdentifier.create(Top.class); - private static final Transitive TEST_GROUPING = new Transitive() { - - @Override - public Class implementedInterface() { - return Transitive.class; - } - - @Override - public EncapsulatedRoute getRoute() { - return new EncapsulatedRoute(TEST_ROUTE); - } - }; - - @Test - public void testNonRoutedExtraction() { - final ContextReferenceExtractor extractor = ContextReferenceExtractor.from(RockTheHouseInput.class); - final RockTheHouseInput input = new RockTheHouseInputBuilder().build(); - final InstanceIdentifier extractedValue = extractor.extract(input); - assertNull(extractedValue); - } - - @Test - public void testRoutedSimpleExtraction() { - final ContextReferenceExtractor extractor = ContextReferenceExtractor.from(RoutedSimpleRouteInput.class); - final RoutedSimpleRouteInput input = new RoutedSimpleRouteInputBuilder().setRoute(TEST_ROUTE).build(); - final InstanceIdentifier extractedValue = extractor.extract(input); - assertSame(TEST_ROUTE,extractedValue); - } - - @Test - public void testRoutedEncapsulatedExtraction() { - final ContextReferenceExtractor extractor = ContextReferenceExtractor.from(EncapsulatedRouteInGrouping.class); - final InstanceIdentifier extractedValue = extractor.extract(TEST_GROUPING); - assertSame(TEST_ROUTE,extractedValue); - - } - - @Test - public void testRoutedEncapsulatedTransitiveExtraction() { - final ContextReferenceExtractor extractor = ContextReferenceExtractor.from(Transitive.class); - final InstanceIdentifier extractedValue = extractor.extract(TEST_GROUPING); - assertSame(TEST_ROUTE,extractedValue); - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/BackwardsCompatibleNotificationBrokerTest.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/BackwardsCompatibleNotificationBrokerTest.java deleted file mode 100644 index 394a465af5..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/BackwardsCompatibleNotificationBrokerTest.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.impl.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import com.google.common.collect.ImmutableList; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; -import org.opendaylight.controller.md.sal.binding.api.NotificationService; -import org.opendaylight.controller.md.sal.binding.compat.HeliumNotificationProviderServiceAdapter; -import org.opendaylight.controller.md.sal.binding.test.AbstractNotificationBrokerTest; -import org.opendaylight.controller.sal.binding.api.NotificationProviderService; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.OpendaylightMdsalListTestListener; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.TwoLevelListChanged; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.TwoLevelListChangedBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListKey; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.binding.NotificationListener; - -@Deprecated -public class BackwardsCompatibleNotificationBrokerTest extends AbstractNotificationBrokerTest { - - private NotificationProviderService notificationProviderService; - - @Before - public void initTest() { - final NotificationService notificationService = getNotificationService(); - final NotificationPublishService notificationPublishService = getNotificationPublishService(); - notificationProviderService = new HeliumNotificationProviderServiceAdapter(notificationPublishService, - notificationService); - } - - private static TwoLevelListChanged createTestData() { - final TwoLevelListChangedBuilder tb = new TwoLevelListChangedBuilder(); - tb.setTopLevelList(ImmutableList.of(new TopLevelListBuilder().withKey(new TopLevelListKey("test")).build())); - return tb.build(); - } - - @Test - public void testNotifSubscriptionForwarded() throws InterruptedException { - final CountDownLatch latch = new CountDownLatch(1); - final TwoLevelListChanged testData = createTestData(); - - final NotifTestListenerChild testNotifListener = new NotifTestListenerChild(latch); - final ListenerRegistration listenerRegistration = - notificationProviderService.registerNotificationListener(testNotifListener); - notificationProviderService.publish(testData); - - latch.await(500L, TimeUnit.MILLISECONDS); - assertTrue(testNotifListener.getReceivedNotifications().size() == 1); - assertEquals(testData, testNotifListener.getReceivedNotifications().get(0)); - listenerRegistration.close(); - } - - private static class NotifTestListenerChild extends NotifTestListener { - - NotifTestListenerChild(final CountDownLatch latch) { - super(latch); - } - } - - private static class NotifTestListener implements OpendaylightMdsalListTestListener { - private final List receivedNotifications = new ArrayList<>(); - private final CountDownLatch latch; - - NotifTestListener(final CountDownLatch latch) { - this.latch = latch; - } - - @Override - public void onTwoLevelListChanged(final TwoLevelListChanged notification) { - receivedNotifications.add(notification); - latch.countDown(); - } - - public List getReceivedNotifications() { - return receivedNotifications; - } - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/BindingDOMDataBrokerAdapterTest.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/BindingDOMDataBrokerAdapterTest.java deleted file mode 100644 index 1d842bede8..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/BindingDOMDataBrokerAdapterTest.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.md.sal.binding.impl.test; - -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.verify; - -import com.google.common.collect.ImmutableMap; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.opendaylight.controller.md.sal.binding.api.ClusteredDataTreeChangeListener; -import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier; -import org.opendaylight.controller.md.sal.binding.impl.BindingDOMDataBrokerAdapter; -import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.dom.api.ClusteredDOMDataTreeChangeListener; -import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; -import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener; -import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeService; -import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeIdentifier; -import org.opendaylight.mdsal.binding.dom.codec.impl.BindingNormalizedNodeCodecRegistry; -import org.opendaylight.mdsal.binding.generator.impl.GeneratedClassLoadingStrategy; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; - -@Deprecated -public class BindingDOMDataBrokerAdapterTest { - - @Mock - DOMDataBroker dataBroker; - - @Mock - GeneratedClassLoadingStrategy classLoadingStrategy; - - @Mock - BindingNormalizedNodeCodecRegistry codecRegistry; - - @Mock - DOMDataTreeChangeService dataTreeChangeService; - - @Mock - ListenerRegistration listenerRegistration; - - @Mock - ClusteredDataTreeChangeListener clusteredDataTreeChangeListener; - - private static final InstanceIdentifier TOP_PATH = InstanceIdentifier.create(Top.class); - - @Before - public void setUp() { - MockitoAnnotations.initMocks(this); - } - - @Test - public void testClusteredDataTreeChangeListenerRegisteration() { - - doReturn(YangInstanceIdentifier.of(Top.QNAME)).when(codecRegistry).toYangInstanceIdentifier(TOP_PATH); - - doReturn(listenerRegistration).when(dataTreeChangeService).registerDataTreeChangeListener(any(), any()); - - doReturn(ImmutableMap.of(DOMDataTreeChangeService.class, dataTreeChangeService)) - .when(dataBroker).getSupportedExtensions(); - - final BindingToNormalizedNodeCodec codec = - new BindingToNormalizedNodeCodec(this.classLoadingStrategy, this.codecRegistry); - - try (BindingDOMDataBrokerAdapter bindingDOMDataBrokerAdapter = new BindingDOMDataBrokerAdapter(this.dataBroker, - codec)) { - - ListenerRegistration> bindingListenerReg = - bindingDOMDataBrokerAdapter.registerDataTreeChangeListener( - new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, TOP_PATH), - clusteredDataTreeChangeListener); - - verify(dataTreeChangeService).registerDataTreeChangeListener( - eq(new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.of(Top.QNAME))), - any(ClusteredDOMDataTreeChangeListener.class)); - - bindingListenerReg.close(); - - verify(listenerRegistration).close(); - } - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/Bug1125RegressionTest.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/Bug1125RegressionTest.java deleted file mode 100644 index f3f633469b..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/Bug1125RegressionTest.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.impl.test; - -import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.TOP_FOO_KEY; -import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.path; -import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.topLevelList; - -import com.google.common.collect.ImmutableSet; -import java.util.Set; -import org.junit.Test; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.binding.test.AbstractDataTreeChangeListenerTest; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.TreeComplexUsesAugment; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.TreeComplexUsesAugmentBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.complex.from.grouping.ContainerWithUsesBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.TopBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.binding.YangModuleInfo; - -/** - * Regression test suite for Bug 1125 - Can't detect switch disconnection - * https://bugs.opendaylight.org/show_bug.cgi?id=1125. - */ -@Deprecated -public class Bug1125RegressionTest extends AbstractDataTreeChangeListenerTest { - - private static final InstanceIdentifier TOP_PATH = InstanceIdentifier - .create(Top.class); - private static final InstanceIdentifier TOP_FOO_PATH = TOP_PATH - .child(TopLevelList.class, TOP_FOO_KEY); - - private static final InstanceIdentifier FOO_AUGMENT_PATH = TOP_FOO_PATH - .augmentation(TreeComplexUsesAugment.class); - - private static final InstanceIdentifier WILDCARDED_AUGMENT_PATH = TOP_PATH - .child(TopLevelList.class).augmentation( - TreeComplexUsesAugment.class); - - @Override - protected Set getModuleInfos() throws Exception { - return ImmutableSet.of(BindingReflections.getModuleInfo(Top.class), - BindingReflections.getModuleInfo(TreeComplexUsesAugment.class)); - } - - private TreeComplexUsesAugment writeInitialState() { - WriteTransaction initialTx = getDataBroker().newWriteOnlyTransaction(); - initialTx.put(LogicalDatastoreType.OPERATIONAL, TOP_PATH, - new TopBuilder().build()); - TreeComplexUsesAugment fooAugment = new TreeComplexUsesAugmentBuilder() - .setContainerWithUses( - new ContainerWithUsesBuilder().setLeafFromGrouping( - "foo").build()).build(); - initialTx.put(LogicalDatastoreType.OPERATIONAL, path(TOP_FOO_KEY), - topLevelList(TOP_FOO_KEY, fooAugment)); - assertCommit(initialTx.submit()); - return fooAugment; - } - - private void delete(final InstanceIdentifier path) { - WriteTransaction tx = getDataBroker().newWriteOnlyTransaction(); - tx.delete(LogicalDatastoreType.OPERATIONAL, path); - assertCommit(tx.submit()); - } - - private void deleteAndListenAugment(final InstanceIdentifier path) { - TreeComplexUsesAugment augment = writeInitialState(); - TestListener listener = createListener(LogicalDatastoreType.OPERATIONAL, - WILDCARDED_AUGMENT_PATH, added(FOO_AUGMENT_PATH, augment), deleted(FOO_AUGMENT_PATH, augment)); - delete(path); - listener.verify(); - } - - @Test - public void deleteAndListenAugment() { - deleteAndListenAugment(TOP_PATH); - - deleteAndListenAugment(TOP_FOO_PATH); - - deleteAndListenAugment(FOO_AUGMENT_PATH); - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/Bug1333DataChangeListenerTest.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/Bug1333DataChangeListenerTest.java deleted file mode 100644 index 03ee3880da..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/Bug1333DataChangeListenerTest.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.impl.test; - -import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.CONFIGURATION; -import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.TOP_FOO_KEY; -import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.USES_ONE_KEY; -import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.USES_TWO_KEY; -import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.complexUsesAugment; -import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.path; -import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.top; -import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.topLevelList; - -import com.google.common.collect.ImmutableSet; -import java.util.Set; -import org.junit.Test; -import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; -import org.opendaylight.controller.md.sal.binding.test.AbstractDataTreeChangeListenerTest; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.TreeComplexUsesAugment; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.complex.from.grouping.ListViaUses; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.binding.YangModuleInfo; - -/** - * This testsuite tries to replicate bug 1333 and tests regresion of it - * using test-model with similar construction as one reported. - * - *

- * See https://bugs.opendaylight.org/show_bug.cgi?id=1333 for Bug Description - */ -@Deprecated -public class Bug1333DataChangeListenerTest extends AbstractDataTreeChangeListenerTest { - - private static final InstanceIdentifier TOP_PATH = InstanceIdentifier.create(Top.class); - - private static final InstanceIdentifier AUGMENT_WILDCARD = - TOP_PATH.child(TopLevelList.class).augmentation(TreeComplexUsesAugment.class); - - @Override - protected Set getModuleInfos() throws Exception { - return ImmutableSet.of(BindingReflections.getModuleInfo(Top.class), - BindingReflections.getModuleInfo(TreeComplexUsesAugment.class)); - } - - private static Top topWithListItem() { - return top(topLevelList(TOP_FOO_KEY, complexUsesAugment(USES_ONE_KEY, USES_TWO_KEY))); - } - - public Top writeTopWithListItem(final LogicalDatastoreType store) { - ReadWriteTransaction tx = getDataBroker().newReadWriteTransaction(); - Top topItem = topWithListItem(); - tx.put(store, TOP_PATH, topItem); - assertCommit(tx.submit()); - return topItem; - } - - public void deleteItem(final LogicalDatastoreType store, final InstanceIdentifier path) { - ReadWriteTransaction tx = getDataBroker().newReadWriteTransaction(); - tx.delete(store, path); - assertCommit(tx.submit()); - } - - @Test - public void writeTopWithListItemAugmentedListenTopSubtree() { - TestListener listener = createListener(CONFIGURATION, TOP_PATH, added(TOP_PATH, topWithListItem())); - - writeTopWithListItem(CONFIGURATION); - - listener.verify(); - } - - @Test - public void writeTopWithListItemAugmentedListenAugmentSubtreeWildcarded() { - TestListener listener = createListener(CONFIGURATION, AUGMENT_WILDCARD, - added(path(TOP_FOO_KEY, TreeComplexUsesAugment.class), complexUsesAugment(USES_ONE_KEY, USES_TWO_KEY))); - - writeTopWithListItem(CONFIGURATION); - - listener.verify(); - } - - @Test - public void deleteAugmentChildListenTopSubtree() { - Top top = writeTopWithListItem(CONFIGURATION); - - TestListener listener = createListener(CONFIGURATION, TOP_PATH, added(TOP_PATH, top), - subtreeModified(TOP_PATH, top, top(topLevelList(TOP_FOO_KEY, complexUsesAugment(USES_TWO_KEY))))); - - InstanceIdentifier deletePath = path(TOP_FOO_KEY, USES_ONE_KEY); - deleteItem(CONFIGURATION, deletePath); - - listener.verify(); - } - - @Test - public void deleteAugmentChildListenAugmentSubtreeWildcarded() { - writeTopWithListItem(CONFIGURATION); - - TestListener listener = createListener(CONFIGURATION, AUGMENT_WILDCARD, - added(path(TOP_FOO_KEY, TreeComplexUsesAugment.class), complexUsesAugment(USES_ONE_KEY, USES_TWO_KEY)), - subtreeModified(path(TOP_FOO_KEY, TreeComplexUsesAugment.class), - complexUsesAugment(USES_ONE_KEY, USES_TWO_KEY), complexUsesAugment(USES_TWO_KEY))); - - InstanceIdentifier deletePath = path(TOP_FOO_KEY, USES_ONE_KEY); - deleteItem(CONFIGURATION, deletePath); - - listener.verify(); - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/Bug1418AugmentationTest.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/Bug1418AugmentationTest.java deleted file mode 100644 index 6fad18783f..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/Bug1418AugmentationTest.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.md.sal.binding.impl.test; - -import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.CONFIGURATION; -import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.TOP_FOO_KEY; -import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.complexUsesAugment; -import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.leafOnlyUsesAugment; -import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.path; -import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.top; -import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.topLevelList; - -import com.google.common.collect.ImmutableSet; -import java.util.Set; -import org.junit.Test; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.binding.test.AbstractDataTreeChangeListenerTest; -import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.TreeComplexUsesAugment; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.TreeLeafOnlyUsesAugment; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.complex.from.grouping.ListViaUsesKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListKey; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.binding.YangModuleInfo; - -@Deprecated -public class Bug1418AugmentationTest extends AbstractDataTreeChangeListenerTest { - private static final InstanceIdentifier TOP = InstanceIdentifier.create(Top.class); - private static final InstanceIdentifier TOP_FOO = TOP.child(TopLevelList.class, TOP_FOO_KEY); - private static final InstanceIdentifier SIMPLE_AUGMENT = - TOP.child(TopLevelList.class, TOP_FOO_KEY).augmentation(TreeLeafOnlyUsesAugment.class); - private static final InstanceIdentifier COMPLEX_AUGMENT = - TOP.child(TopLevelList.class, TOP_FOO_KEY).augmentation(TreeComplexUsesAugment.class); - private static final ListViaUsesKey LIST_VIA_USES_KEY = - new ListViaUsesKey("list key"); - private static final ListViaUsesKey LIST_VIA_USES_KEY_MOD = - new ListViaUsesKey("list key modified"); - - @Override - protected Set getModuleInfos() throws Exception { - return ImmutableSet.of(BindingReflections.getModuleInfo(Top.class), - BindingReflections.getModuleInfo(TreeComplexUsesAugment.class), - BindingReflections.getModuleInfo(TreeLeafOnlyUsesAugment.class)); - } - - @Test - public void leafOnlyAugmentationCreatedTest() { - TreeLeafOnlyUsesAugment leafOnlyUsesAugment = leafOnlyUsesAugment("test leaf"); - final TestListener listener = createListener(CONFIGURATION, SIMPLE_AUGMENT, - added(path(TOP_FOO_KEY, TreeLeafOnlyUsesAugment.class), leafOnlyUsesAugment)); - - WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction(); - writeTx.put(CONFIGURATION, TOP, top()); - writeTx.put(CONFIGURATION, TOP_FOO, topLevelList(new TopLevelListKey(TOP_FOO_KEY))); - writeTx.put(CONFIGURATION, SIMPLE_AUGMENT, leafOnlyUsesAugment); - assertCommit(writeTx.submit()); - - listener.verify(); - } - - @Test - public void leafOnlyAugmentationUpdatedTest() { - WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction(); - writeTx.put(CONFIGURATION, TOP, top()); - writeTx.put(CONFIGURATION, TOP_FOO, topLevelList(new TopLevelListKey(TOP_FOO_KEY))); - TreeLeafOnlyUsesAugment leafOnlyUsesAugmentBefore = leafOnlyUsesAugment("test leaf"); - writeTx.put(CONFIGURATION, SIMPLE_AUGMENT, leafOnlyUsesAugmentBefore); - assertCommit(writeTx.submit()); - - TreeLeafOnlyUsesAugment leafOnlyUsesAugmentAfter = leafOnlyUsesAugment("test leaf changed"); - final TestListener listener = createListener(CONFIGURATION, SIMPLE_AUGMENT, - added(path(TOP_FOO_KEY, TreeLeafOnlyUsesAugment.class), leafOnlyUsesAugmentBefore), - replaced(path(TOP_FOO_KEY, TreeLeafOnlyUsesAugment.class), leafOnlyUsesAugmentBefore, - leafOnlyUsesAugmentAfter)); - - writeTx = getDataBroker().newWriteOnlyTransaction(); - writeTx.put(CONFIGURATION, SIMPLE_AUGMENT, leafOnlyUsesAugmentAfter); - assertCommit(writeTx.submit()); - - listener.verify(); - } - - @Test - public void leafOnlyAugmentationDeletedTest() { - WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction(); - writeTx.put(CONFIGURATION, TOP, top()); - writeTx.put(CONFIGURATION, TOP_FOO, topLevelList(new TopLevelListKey(TOP_FOO_KEY))); - TreeLeafOnlyUsesAugment leafOnlyUsesAugment = leafOnlyUsesAugment("test leaf"); - writeTx.put(CONFIGURATION, SIMPLE_AUGMENT, leafOnlyUsesAugment); - assertCommit(writeTx.submit()); - - final TestListener listener = createListener(CONFIGURATION, SIMPLE_AUGMENT, - added(path(TOP_FOO_KEY, TreeLeafOnlyUsesAugment.class), leafOnlyUsesAugment), - deleted(path(TOP_FOO_KEY, TreeLeafOnlyUsesAugment.class), leafOnlyUsesAugment)); - - writeTx = getDataBroker().newWriteOnlyTransaction(); - writeTx.delete(CONFIGURATION, SIMPLE_AUGMENT); - assertCommit(writeTx.submit()); - - listener.verify(); - } - - @Test - public void complexAugmentationCreatedTest() { - TreeComplexUsesAugment complexUsesAugment = complexUsesAugment(LIST_VIA_USES_KEY); - final TestListener listener = createListener(CONFIGURATION, COMPLEX_AUGMENT, - added(path(TOP_FOO_KEY, TreeComplexUsesAugment.class), complexUsesAugment)); - - WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction(); - writeTx.put(CONFIGURATION, TOP, top()); - writeTx.put(CONFIGURATION, TOP_FOO, topLevelList(new TopLevelListKey(TOP_FOO_KEY))); - writeTx.put(CONFIGURATION, COMPLEX_AUGMENT, complexUsesAugment); - assertCommit(writeTx.submit()); - - listener.verify(); - } - - @Test - public void complexAugmentationUpdatedTest() { - WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction(); - writeTx.put(CONFIGURATION, TOP, top()); - writeTx.put(CONFIGURATION, TOP_FOO, topLevelList(new TopLevelListKey(TOP_FOO_KEY))); - TreeComplexUsesAugment complexUsesAugmentBefore = complexUsesAugment(LIST_VIA_USES_KEY); - writeTx.put(CONFIGURATION, COMPLEX_AUGMENT, complexUsesAugmentBefore); - assertCommit(writeTx.submit()); - - TreeComplexUsesAugment complexUsesAugmentAfter = complexUsesAugment(LIST_VIA_USES_KEY_MOD); - - final TestListener listener = createListener(CONFIGURATION, COMPLEX_AUGMENT, - added(path(TOP_FOO_KEY, TreeComplexUsesAugment.class), complexUsesAugmentBefore), - replaced(path(TOP_FOO_KEY, TreeComplexUsesAugment.class), complexUsesAugmentBefore, - complexUsesAugmentAfter)); - - writeTx = getDataBroker().newWriteOnlyTransaction(); - writeTx.put(CONFIGURATION, COMPLEX_AUGMENT, complexUsesAugmentAfter); - assertCommit(writeTx.submit()); - - listener.verify(); - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/Bug2562DeserializedUnkeyedListTest.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/Bug2562DeserializedUnkeyedListTest.java deleted file mode 100644 index 8218ce5c0f..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/Bug2562DeserializedUnkeyedListTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.impl.test; - -import com.google.common.collect.ImmutableSet; -import java.util.Arrays; -import java.util.Set; -import org.junit.Test; -import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; -import org.opendaylight.controller.md.sal.binding.test.AbstractDataTreeChangeListenerTest; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections; -import org.opendaylight.yang.gen.v1.opendaylight.test.bug._2562.namespace.rev160101.Root; -import org.opendaylight.yang.gen.v1.opendaylight.test.bug._2562.namespace.rev160101.RootBuilder; -import org.opendaylight.yang.gen.v1.opendaylight.test.bug._2562.namespace.rev160101.root.Fooroot; -import org.opendaylight.yang.gen.v1.opendaylight.test.bug._2562.namespace.rev160101.root.FoorootBuilder; -import org.opendaylight.yang.gen.v1.opendaylight.test.bug._2562.namespace.rev160101.root.fooroot.Barroot; -import org.opendaylight.yang.gen.v1.opendaylight.test.bug._2562.namespace.rev160101.root.fooroot.BarrootBuilder; -import org.opendaylight.yang.gen.v1.opendaylight.test.bug._2562.namespace.rev160101.root.fooroot.BarrootKey; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.binding.YangModuleInfo; - -@Deprecated -public class Bug2562DeserializedUnkeyedListTest extends AbstractDataTreeChangeListenerTest { - private static final InstanceIdentifier ROOT_PATH = InstanceIdentifier.create(Root.class); - - @Override - protected Set getModuleInfos() throws Exception { - return ImmutableSet.of(BindingReflections.getModuleInfo(Root.class)); - } - - @Test - public void writeListToList2562Root() { - final Barroot barRoot = new BarrootBuilder().setType(2).setValue(2).withKey(new BarrootKey(2)).build(); - final Fooroot fooRoot = new FoorootBuilder().setBarroot(Arrays.asList(barRoot)).build(); - final Root root = new RootBuilder().setFooroot(Arrays.asList(fooRoot)).build(); - - final TestListener listenerRoot = createListener(LogicalDatastoreType.CONFIGURATION, ROOT_PATH, - added(ROOT_PATH, root)); - - final ReadWriteTransaction readWriteTransaction = getDataBroker().newReadWriteTransaction(); - readWriteTransaction.put(LogicalDatastoreType.CONFIGURATION, ROOT_PATH, root); - assertCommit(readWriteTransaction.submit()); - - listenerRoot.verify(); - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/Bug3090MultiKeyList.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/Bug3090MultiKeyList.java deleted file mode 100644 index f782002762..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/Bug3090MultiKeyList.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.impl.test; - -import com.google.common.collect.ImmutableSet; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Objects; -import java.util.Set; -import java.util.function.Function; -import java.util.stream.Collectors; -import org.junit.Test; -import org.opendaylight.controller.md.sal.binding.api.DataObjectModification.ModificationType; -import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; -import org.opendaylight.controller.md.sal.binding.test.AbstractDataTreeChangeListenerTest; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.opendaylight.test.bug._3090.rev160101.Root; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.opendaylight.test.bug._3090.rev160101.RootBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.opendaylight.test.bug._3090.rev160101.root.ListInRoot; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.opendaylight.test.bug._3090.rev160101.root.ListInRootBuilder; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.binding.YangModuleInfo; - -@Deprecated -public class Bug3090MultiKeyList extends AbstractDataTreeChangeListenerTest { - private static final InstanceIdentifier ROOT_PATH = InstanceIdentifier.create(Root.class); - - @Override - protected Set getModuleInfos() throws Exception { - return ImmutableSet.of(BindingReflections.getModuleInfo(Root.class)); - } - - @Test - public void listWithMultiKeyTest() { - final List listInRoots = new ArrayList<>(); - for (int i = 0; i < 10; i++) { - listInRoots.add(new ListInRootBuilder() - .setLeafA("leaf a" + i) - .setLeafC("leaf c" + i) - .setLeafB("leaf b" + i) - .build() - ); - } - - final Root root = new RootBuilder().setListInRoot(listInRoots).build(); - - final TestListener listener = createListener(LogicalDatastoreType.CONFIGURATION, ROOT_PATH, - match(ModificationType.WRITE, ROOT_PATH, Objects::isNull, - (Function) dataAfter -> checkData(root, dataAfter))); - - final ReadWriteTransaction readWriteTransaction = getDataBroker().newReadWriteTransaction(); - readWriteTransaction.put(LogicalDatastoreType.CONFIGURATION, ROOT_PATH, root); - assertCommit(readWriteTransaction.submit()); - - listener.verify(); - } - - private static boolean checkData(final Root expected, final Root actual) { - if (actual == null) { - return false; - } - - Set expListInRoot = new HashSet<>(expected.getListInRoot()); - Set actualListInRoot = actual.getListInRoot().stream() - .map(list -> new ListInRootBuilder(list).build()).collect(Collectors.toSet()); - return expListInRoot.equals(actualListInRoot); - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/Bug4494Test.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/Bug4494Test.java deleted file mode 100644 index 4ca9fbfb98..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/Bug4494Test.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.impl.test; - -import java.util.ArrayList; -import org.junit.Test; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.binding.test.AbstractDataBrokerTest; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.TopBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListKey; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -@Deprecated -public class Bug4494Test extends AbstractDataBrokerTest { - @Test - public void testDelete() throws Exception { - DataBroker dataBroker = getDataBroker(); - WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction(); - ArrayList list = new ArrayList<>(); - list.add(new TopLevelListBuilder().setName("name").build()); - TopBuilder builder = new TopBuilder().setTopLevelList(list); - writeTransaction.put(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(Top.class), builder.build()); - assertCommit(writeTransaction.submit()); - - InstanceIdentifier id = InstanceIdentifier.builder(Top.class) - .child(TopLevelList.class, new TopLevelListKey("name")).build(); - - ReadWriteTransaction writeTransaction1 = dataBroker.newReadWriteTransaction(); - - writeTransaction1.delete(LogicalDatastoreType.OPERATIONAL, id); - assertCommit(writeTransaction1.submit()); - ReadWriteTransaction writeTransaction2 = dataBroker.newReadWriteTransaction(); - - writeTransaction2.delete(LogicalDatastoreType.OPERATIONAL, id); - assertCommit(writeTransaction2.submit()); - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/Bug4513Test.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/Bug4513Test.java deleted file mode 100644 index f4534de964..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/Bug4513Test.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc., Inocybe Technologies and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.impl.test; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.timeout; -import static org.mockito.Mockito.verify; - -import java.util.Arrays; -import java.util.Collection; -import org.junit.Test; -import org.mockito.ArgumentCaptor; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener; -import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier; -import org.opendaylight.controller.md.sal.binding.api.DataTreeModification; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.binding.test.AbstractDataBrokerTest; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.listener.rev150825.ListenerTest; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.listener.rev150825.ListenerTestBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.listener.rev150825.listener.test.ListItem; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.listener.rev150825.listener.test.ListItemBuilder; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.common.Uint32; - -/** - * Regression test suite for https://bugs.opendaylight.org/show_bug.cgi?id=4513 - Change event is empty when - * Homogeneous composite key is used homogeneous composite key is used. - */ -@Deprecated -public class Bug4513Test extends AbstractDataBrokerTest { - - @SuppressWarnings({ "rawtypes", "unchecked" }) - @Test - public void testDataTreeChangeListener() { - DataBroker dataBroker = getDataBroker(); - - DataTreeChangeListener listener = mock(DataTreeChangeListener.class); - InstanceIdentifier wildCard = InstanceIdentifier.builder(ListenerTest.class) - .child(ListItem.class).build(); - ListenerRegistration> reg = dataBroker.registerDataTreeChangeListener( - new DataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, wildCard), listener); - - final ListItem item = writeListItem(); - - ArgumentCaptor captor = ArgumentCaptor.forClass(Collection.class); - - verify(listener, timeout(100)).onDataTreeChanged(captor.capture()); - - Collection> mods = captor.getValue(); - assertEquals("ListItem", item, mods.iterator().next().getRootNode().getDataAfter()); - } - - private ListItem writeListItem() { - WriteTransaction writeTransaction = getDataBroker().newWriteOnlyTransaction(); - final ListItem item = new ListItemBuilder().setSip("name").setOp(Uint32.valueOf(43)).build(); - ListenerTestBuilder builder = new ListenerTestBuilder().setListItem(Arrays.asList(item)); - writeTransaction.put(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.builder( - ListenerTest.class).build(), builder.build()); - assertCommit(writeTransaction.submit()); - return item; - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/DataTreeChangeListenerTest.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/DataTreeChangeListenerTest.java deleted file mode 100644 index bfa7e82725..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/DataTreeChangeListenerTest.java +++ /dev/null @@ -1,205 +0,0 @@ -/* - * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.impl.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.timeout; -import static org.mockito.Mockito.verify; -import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.TOP_BAR_KEY; -import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.TOP_FOO_KEY; -import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.USES_ONE_KEY; -import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.complexUsesAugment; -import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.path; -import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.top; -import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.topLevelList; - -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; -import com.google.common.util.concurrent.SettableFuture; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Set; -import java.util.concurrent.TimeUnit; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Matchers; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.DataObjectModification; -import org.opendaylight.controller.md.sal.binding.api.DataObjectModification.ModificationType; -import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener; -import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier; -import org.opendaylight.controller.md.sal.binding.api.DataTreeModification; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.binding.impl.BindingDOMDataBrokerAdapter; -import org.opendaylight.controller.md.sal.binding.test.AbstractConcurrentDataBrokerTest; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.TreeComplexUsesAugment; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.TopBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.TwoLevelList; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListBuilder; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument; -import org.opendaylight.yangtools.yang.binding.YangModuleInfo; - -@Deprecated -public class DataTreeChangeListenerTest extends AbstractConcurrentDataBrokerTest { - - private static final InstanceIdentifier TOP_PATH = InstanceIdentifier.create(Top.class); - private static final PathArgument TOP_ARGUMENT = TOP_PATH.getPathArguments().iterator().next(); - private static final InstanceIdentifier FOO_PATH = path(TOP_FOO_KEY); - private static final PathArgument FOO_ARGUMENT = Iterables.getLast(FOO_PATH.getPathArguments()); - private static final TopLevelList FOO_DATA = topLevelList(TOP_FOO_KEY, complexUsesAugment(USES_ONE_KEY)); - private static final InstanceIdentifier BAR_PATH = path(TOP_BAR_KEY); - private static final PathArgument BAR_ARGUMENT = Iterables.getLast(BAR_PATH.getPathArguments()); - private static final TopLevelList BAR_DATA = topLevelList(TOP_BAR_KEY); - private static final DataTreeIdentifier TOP_IDENTIFIER = - new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, TOP_PATH); - - private static final Top TOP_INITIAL_DATA = top(FOO_DATA); - - private BindingDOMDataBrokerAdapter dataBrokerImpl; - - private static final class EventCapturingListener implements DataTreeChangeListener { - - private SettableFuture>> changes = SettableFuture.create(); - - @Override - public void onDataTreeChanged(final Collection> modification) { - this.changes.set(modification); - - } - - Collection> nextEvent() throws Exception { - final Collection> result = changes.get(200,TimeUnit.MILLISECONDS); - changes = SettableFuture.create(); - return result; - } - } - - @Override - protected Set getModuleInfos() throws Exception { - return ImmutableSet.of( - BindingReflections.getModuleInfo(TwoLevelList.class), - BindingReflections.getModuleInfo(TreeComplexUsesAugment.class) - ); - } - - @Before - public void setupWithDataBroker() { - dataBrokerImpl = (BindingDOMDataBrokerAdapter) getDataBroker(); - } - - @Test - public void testTopLevelListener() throws Exception { - final EventCapturingListener listener = new EventCapturingListener<>(); - dataBrokerImpl.registerDataTreeChangeListener(TOP_IDENTIFIER, listener); - - createAndVerifyTop(listener); - - putTx(BAR_PATH, BAR_DATA).submit().checkedGet(); - final DataObjectModification afterBarPutEvent = Iterables.getOnlyElement(listener.nextEvent()) - .getRootNode(); - verifyModification(afterBarPutEvent, TOP_ARGUMENT, ModificationType.SUBTREE_MODIFIED); - final DataObjectModification barPutMod = afterBarPutEvent - .getModifiedChildListItem(TopLevelList.class, TOP_BAR_KEY); - assertNotNull(barPutMod); - verifyModification(barPutMod, BAR_ARGUMENT, ModificationType.WRITE); - - deleteTx(BAR_PATH).submit().checkedGet(); - final DataObjectModification afterBarDeleteEvent = Iterables.getOnlyElement(listener.nextEvent()) - .getRootNode(); - verifyModification(afterBarDeleteEvent, TOP_ARGUMENT, ModificationType.SUBTREE_MODIFIED); - final DataObjectModification barDeleteMod = afterBarDeleteEvent - .getModifiedChildListItem(TopLevelList.class, TOP_BAR_KEY); - verifyModification(barDeleteMod, BAR_ARGUMENT, ModificationType.DELETE); - } - - @Test - public void testWildcardedListListener() throws Exception { - final EventCapturingListener listener = new EventCapturingListener<>(); - final DataTreeIdentifier wildcard = new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, - TOP_PATH.child(TopLevelList.class)); - dataBrokerImpl.registerDataTreeChangeListener(wildcard, listener); - - putTx(TOP_PATH, TOP_INITIAL_DATA).submit().checkedGet(); - - final DataTreeModification fooWriteEvent = Iterables.getOnlyElement(listener.nextEvent()); - assertEquals(FOO_PATH, fooWriteEvent.getRootPath().getRootIdentifier()); - verifyModification(fooWriteEvent.getRootNode(), FOO_ARGUMENT, ModificationType.WRITE); - - putTx(BAR_PATH, BAR_DATA).submit().checkedGet(); - final DataTreeModification barWriteEvent = Iterables.getOnlyElement(listener.nextEvent()); - assertEquals(BAR_PATH, barWriteEvent.getRootPath().getRootIdentifier()); - verifyModification(barWriteEvent.getRootNode(), BAR_ARGUMENT, ModificationType.WRITE); - - deleteTx(BAR_PATH).submit().checkedGet(); - final DataTreeModification barDeleteEvent = Iterables.getOnlyElement(listener.nextEvent()); - assertEquals(BAR_PATH, barDeleteEvent.getRootPath().getRootIdentifier()); - verifyModification(barDeleteEvent.getRootNode(), BAR_ARGUMENT, ModificationType.DELETE); - } - - @SuppressWarnings("unchecked") - @Test - public void testWildcardNotificationOfPreexistingData() { - InstanceIdentifier id = InstanceIdentifier.builder(Top.class).build(); - ArrayList list = new ArrayList<>(); - list.add(new TopLevelListBuilder().setName("name").build()); - TopBuilder builder = new TopBuilder().setTopLevelList(list); - - DataBroker dataBroker = getDataBroker(); - - WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction(); - writeTransaction.put(LogicalDatastoreType.OPERATIONAL, id, builder.build()); - assertCommit(writeTransaction.submit()); - - DataTreeChangeListener listener = mock(DataTreeChangeListener.class); - InstanceIdentifier wildcard = InstanceIdentifier.builder(Top.class).child(TopLevelList.class) - .build(); - dataBroker.registerDataTreeChangeListener(new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, wildcard), - listener); - - verify(listener, timeout(1000)).onDataTreeChanged(Matchers.anyObject()); - } - - private void createAndVerifyTop(final EventCapturingListener listener) throws Exception { - putTx(TOP_PATH,TOP_INITIAL_DATA).submit().checkedGet(); - final Collection> events = listener.nextEvent(); - - assertFalse("Non empty collection should be received.",events.isEmpty()); - final DataTreeModification initialWrite = Iterables.getOnlyElement(events); - final DataObjectModification initialNode = initialWrite.getRootNode(); - verifyModification(initialNode,TOP_PATH.getPathArguments().iterator().next(),ModificationType.WRITE); - assertEquals(TOP_INITIAL_DATA, initialNode.getDataAfter()); - } - - private static void verifyModification(final DataObjectModification barWrite, - final PathArgument pathArg, final ModificationType eventType) { - assertEquals(pathArg.getType(), barWrite.getDataType()); - assertEquals(eventType,barWrite.getModificationType()); - assertEquals(pathArg, barWrite.getIdentifier()); - } - - private WriteTransaction putTx(final InstanceIdentifier path,final T data) { - final WriteTransaction tx = dataBrokerImpl.newWriteOnlyTransaction(); - tx.put(LogicalDatastoreType.OPERATIONAL, path, data); - return tx; - } - - private WriteTransaction deleteTx(final InstanceIdentifier path) { - final WriteTransaction tx = dataBrokerImpl.newWriteOnlyTransaction(); - tx.delete(LogicalDatastoreType.OPERATIONAL, path); - return tx; - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/ForwardedNotificationAdapterTest.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/ForwardedNotificationAdapterTest.java deleted file mode 100644 index cd67d5a470..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/ForwardedNotificationAdapterTest.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.impl.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotSame; -import static org.junit.Assert.assertTrue; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableSet; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; -import org.opendaylight.controller.md.sal.binding.test.AbstractNotificationBrokerTest; -import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.OpendaylightMdsalListTestListener; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.TwoLevelListChanged; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.TwoLevelListChangedBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListKey; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.binding.YangModuleInfo; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@Deprecated -public class ForwardedNotificationAdapterTest extends AbstractNotificationBrokerTest { - - private static final Logger LOG = LoggerFactory.getLogger(ForwardedNotificationAdapterTest.class); - - @Override - protected Set getModuleInfos() throws Exception { - return ImmutableSet.of(BindingReflections.getModuleInfo(TwoLevelListChanged.class)); - - } - - private static TwoLevelListChanged createTestData() { - final TwoLevelListChangedBuilder tb = new TwoLevelListChangedBuilder(); - tb.setTopLevelList(ImmutableList.of(new TopLevelListBuilder().withKey(new TopLevelListKey("test")).build())); - return tb.build(); - } - - @Test - public void testNotifSubscription() throws InterruptedException { - final CountDownLatch latch = new CountDownLatch(1); - final TwoLevelListChanged testData = createTestData(); - - final TestNotifListener testNotifListener = new TestNotifListener(latch); - final ListenerRegistration listenerRegistration = getNotificationService() - .registerNotificationListener(testNotifListener); - getNotificationPublishService().putNotification(testData); - - latch.await(); - assertTrue(testNotifListener.getReceivedNotifications().size() == 1); - assertEquals(testData, testNotifListener.getReceivedNotifications().get(0)); - - listenerRegistration.close(); - } - - @Test - public void testNotifSubscription2() throws InterruptedException { - final CountDownLatch latch = new CountDownLatch(1); - final TwoLevelListChanged testData = createTestData(); - - final TestNotifListener testNotifListener = new TestNotifListener(latch); - final ListenerRegistration 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(); - } - - @Test - public void testNotifSubscription3() throws InterruptedException { - final CountDownLatch latch = new CountDownLatch(1); - final TwoLevelListChanged testData = createTestData(); - - final TestNotifListener testNotifListener = new TestNotifListener(latch); - final ListenerRegistration 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(); - } - - private static class TestNotifListener implements OpendaylightMdsalListTestListener { - private final List receivedNotifications = new ArrayList<>(); - private final CountDownLatch latch; - - TestNotifListener(final CountDownLatch latch) { - this.latch = latch; - } - - @Override - public void onTwoLevelListChanged(final TwoLevelListChanged notification) { - receivedNotifications.add(notification); - latch.countDown(); - } - - public List getReceivedNotifications() { - return receivedNotifications; - } - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/ListInsertionDataChangeListenerTest.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/ListInsertionDataChangeListenerTest.java deleted file mode 100644 index e4284f6447..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/ListInsertionDataChangeListenerTest.java +++ /dev/null @@ -1,175 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.impl.test; -import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.CONFIGURATION; -import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.TOP_BAR_KEY; -import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.TOP_FOO_KEY; -import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.top; -import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.topLevelList; - -import com.google.common.collect.ImmutableSet; -import java.util.HashSet; -import java.util.Objects; -import java.util.Set; -import java.util.function.Function; -import java.util.stream.Collectors; -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.controller.md.sal.binding.api.DataObjectModification.ModificationType; -import org.opendaylight.controller.md.sal.binding.api.DataTreeModification; -import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.binding.test.AbstractDataTreeChangeListenerTest; -import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListBuilder; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.binding.YangModuleInfo; - -/** - * This testsuite tests explanation for data change scope and data modifications - * which were described in - * https://lists.opendaylight.org/pipermail/controller-dev/2014-July/005541.html. - */ -@Deprecated -public class ListInsertionDataChangeListenerTest extends AbstractDataTreeChangeListenerTest { - - private static final InstanceIdentifier TOP = InstanceIdentifier.create(Top.class); - private static final InstanceIdentifier WILDCARDED = TOP.child(TopLevelList.class); - private static final InstanceIdentifier TOP_FOO = TOP.child(TopLevelList.class, TOP_FOO_KEY); - private static final InstanceIdentifier TOP_BAR = TOP.child(TopLevelList.class, TOP_BAR_KEY); - - @Override - protected Set getModuleInfos() throws Exception { - return ImmutableSet.of(BindingReflections.getModuleInfo(Top.class)); - } - - @Before - public void setupWithDataBroker() { - WriteTransaction initialTx = getDataBroker().newWriteOnlyTransaction(); - initialTx.put(CONFIGURATION, TOP, top(topLevelList(TOP_FOO_KEY))); - assertCommit(initialTx.submit()); - } - - @Test - public void replaceTopNodeSubtreeListeners() { - final TopLevelList topBar = topLevelList(TOP_BAR_KEY); - final Top top = top(topBar); - final TopLevelList topFoo = topLevelList(TOP_FOO_KEY); - - // Listener for TOP element - final TestListener topListener = createListener(CONFIGURATION, TOP, - added(TOP, top(topLevelList(TOP_FOO_KEY))), replaced(TOP, top(topFoo), top)); - - // Listener for all list items. This one should see Foo item deleted and Bar item added. - final TestListener allListener = createListener(CONFIGURATION, WILDCARDED, - added(TOP_FOO, topFoo), added(TOP_BAR, topBar), deleted(TOP_FOO, topFoo)); - - // Listener for all Foo item. This one should see only Foo item deleted. - final TestListener fooListener = createListener(CONFIGURATION, TOP_FOO, - added(TOP_FOO, topFoo), deleted(TOP_FOO, topFoo)); - - // Listener for bar list items. - final TestListener barListener = createListener(CONFIGURATION, TOP_BAR, - added(TOP_BAR, topBar)); - - ReadWriteTransaction writeTx = getDataBroker().newReadWriteTransaction(); - writeTx.put(CONFIGURATION, TOP, top); - assertCommit(writeTx.submit()); - - topListener.verify(); - allListener.verify(); - fooListener.verify(); - barListener.verify(); - } - - @Test - public void mergeTopNodeSubtreeListeners() { - final TopLevelList topBar = topLevelList(TOP_BAR_KEY); - final TopLevelList topFoo = topLevelList(TOP_FOO_KEY); - - final TestListener topListener = createListener(CONFIGURATION, TOP, - added(TOP, top(topLevelList(TOP_FOO_KEY))), topSubtreeModified(topFoo, topBar)); - final TestListener allListener = createListener(CONFIGURATION, WILDCARDED, - added(TOP_FOO, topFoo), added(TOP_BAR, topBar)); - final TestListener fooListener = createListener(CONFIGURATION, TOP_FOO, - added(TOP_FOO, topFoo)); - final TestListener barListener = createListener(CONFIGURATION, TOP_BAR, - added(TOP_BAR, topBar)); - - ReadWriteTransaction writeTx = getDataBroker().newReadWriteTransaction(); - writeTx.merge(CONFIGURATION, TOP, top(topLevelList(TOP_BAR_KEY))); - assertCommit(writeTx.submit()); - - topListener.verify(); - allListener.verify(); - fooListener.verify(); - barListener.verify(); - } - - @Test - public void putTopBarNodeSubtreeListeners() { - final TopLevelList topBar = topLevelList(TOP_BAR_KEY); - final TopLevelList topFoo = topLevelList(TOP_FOO_KEY); - - final TestListener topListener = createListener(CONFIGURATION, TOP, - added(TOP, top(topLevelList(TOP_FOO_KEY))), topSubtreeModified(topFoo, topBar)); - final TestListener allListener = createListener(CONFIGURATION, WILDCARDED, - added(TOP_FOO, topFoo), added(TOP_BAR, topBar)); - final TestListener fooListener = createListener(CONFIGURATION, TOP_FOO, - added(TOP_FOO, topFoo)); - final TestListener barListener = createListener(CONFIGURATION, TOP_BAR, - added(TOP_BAR, topBar)); - - ReadWriteTransaction writeTx = getDataBroker().newReadWriteTransaction(); - writeTx.put(CONFIGURATION, TOP_BAR, topLevelList(TOP_BAR_KEY)); - assertCommit(writeTx.submit()); - - topListener.verify(); - allListener.verify(); - fooListener.verify(); - barListener.verify(); - } - - @Test - public void mergeTopBarNodeSubtreeListeners() { - final TopLevelList topBar = topLevelList(TOP_BAR_KEY); - final TopLevelList topFoo = topLevelList(TOP_FOO_KEY); - - final TestListener topListener = createListener(CONFIGURATION, TOP, - added(TOP, top(topLevelList(TOP_FOO_KEY))), topSubtreeModified(topFoo, topBar)); - final TestListener allListener = createListener(CONFIGURATION, WILDCARDED, - added(TOP_FOO, topFoo), added(TOP_BAR, topBar)); - final TestListener fooListener = createListener(CONFIGURATION, TOP_FOO, - added(TOP_FOO, topFoo)); - final TestListener barListener = createListener(CONFIGURATION, TOP_BAR, - added(TOP_BAR, topBar)); - - ReadWriteTransaction writeTx = getDataBroker().newReadWriteTransaction(); - writeTx.merge(CONFIGURATION, TOP_BAR, topLevelList(TOP_BAR_KEY)); - assertCommit(writeTx.submit()); - - topListener.verify(); - allListener.verify(); - fooListener.verify(); - barListener.verify(); - } - - private static Function, Boolean> topSubtreeModified(final TopLevelList topFoo, - final TopLevelList topBar) { - return match(ModificationType.SUBTREE_MODIFIED, TOP, - (Function) dataBefore -> Objects.equals(top(topFoo), dataBefore), - dataAfter -> { - Set expList = new HashSet<>(top(topBar, topFoo).getTopLevelList()); - Set actualList = dataAfter.getTopLevelList().stream() - .map(list -> new TopLevelListBuilder(list).build()).collect(Collectors.toSet()); - return expList.equals(actualList); - }); - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/WriteTransactionTest.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/WriteTransactionTest.java deleted file mode 100644 index c899863e9d..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/WriteTransactionTest.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.impl.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import com.google.common.base.Optional; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; -import org.junit.Test; -import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.binding.test.AbstractConcurrentDataBrokerTest; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.TopBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListKey; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -@Deprecated -public class WriteTransactionTest extends AbstractConcurrentDataBrokerTest { - - private static final InstanceIdentifier TOP_PATH = InstanceIdentifier.create(Top.class); - private static final TopLevelListKey TOP_LIST_KEY = new TopLevelListKey("foo"); - private static final InstanceIdentifier NODE_PATH = TOP_PATH.child(TopLevelList.class, TOP_LIST_KEY); - private static final TopLevelList NODE = new TopLevelListBuilder().withKey(TOP_LIST_KEY).build(); - - @Test - @Deprecated - public void testSubmit() throws InterruptedException, ExecutionException, TimeoutException { - WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction(); - writeTx.put(LogicalDatastoreType.OPERATIONAL, TOP_PATH, new TopBuilder().build()); - writeTx.put(LogicalDatastoreType.OPERATIONAL, NODE_PATH, NODE); - writeTx.submit().get(5, TimeUnit.SECONDS); - - ReadOnlyTransaction readTx = getDataBroker().newReadOnlyTransaction(); - Optional listNode = readTx.read(LogicalDatastoreType.OPERATIONAL, NODE_PATH).get(); - assertTrue("List node must exists after commit", listNode.isPresent()); - assertEquals("List node", NODE, listNode.get()); - } - - @Test - public void testCommit() throws InterruptedException, ExecutionException, TimeoutException { - WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction(); - writeTx.put(LogicalDatastoreType.OPERATIONAL, TOP_PATH, new TopBuilder().build()); - writeTx.put(LogicalDatastoreType.OPERATIONAL, NODE_PATH, NODE); - writeTx.commit().get(5, TimeUnit.SECONDS); - - ReadOnlyTransaction readTx = getDataBroker().newReadOnlyTransaction(); - Optional listNode = readTx.read(LogicalDatastoreType.OPERATIONAL, NODE_PATH).get(); - assertTrue("List node must exists after commit", listNode.isPresent()); - assertEquals("List node", NODE, listNode.get()); - } - - @Test - public void testPutCreateParentsSuccess() throws InterruptedException, ExecutionException, TimeoutException { - WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction(); - writeTx.put(LogicalDatastoreType.OPERATIONAL, NODE_PATH, NODE,true); - writeTx.commit().get(5, TimeUnit.SECONDS); - - ReadOnlyTransaction readTx = getDataBroker().newReadOnlyTransaction(); - Optional topNode = readTx.read(LogicalDatastoreType.OPERATIONAL, TOP_PATH).get(); - assertTrue("Top node must exists after commit",topNode.isPresent()); - Optional listNode = readTx.read(LogicalDatastoreType.OPERATIONAL, NODE_PATH).get(); - assertTrue("List node must exists after commit",listNode.isPresent()); - } - - @Test - public void testMergeCreateParentsSuccess() throws InterruptedException, ExecutionException, TimeoutException { - WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction(); - writeTx.merge(LogicalDatastoreType.OPERATIONAL, NODE_PATH, NODE,true); - writeTx.commit().get(5, TimeUnit.SECONDS); - - ReadOnlyTransaction readTx = getDataBroker().newReadOnlyTransaction(); - Optional topNode = readTx.read(LogicalDatastoreType.OPERATIONAL, TOP_PATH).get(); - assertTrue("Top node must exists after commit",topNode.isPresent()); - Optional listNode = readTx.read(LogicalDatastoreType.OPERATIONAL, NODE_PATH).get(); - assertTrue("List node must exists after commit",listNode.isPresent()); - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/AbstractBaseDataBrokerTest.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/AbstractBaseDataBrokerTest.java deleted file mode 100644 index dc1d871ec6..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/AbstractBaseDataBrokerTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2017 Red Hat, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.test; - -import com.google.common.util.concurrent.ListenableFuture; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -@Deprecated -public abstract class AbstractBaseDataBrokerTest extends AbstractSchemaAwareTest { - - private static final int ASSERT_COMMIT_DEFAULT_TIMEOUT = 5000; - - private AbstractDataBrokerTestCustomizer testCustomizer; - private DataBroker dataBroker; - private DOMDataBroker domBroker; - - protected abstract AbstractDataBrokerTestCustomizer createDataBrokerTestCustomizer(); - - public AbstractDataBrokerTestCustomizer getDataBrokerTestCustomizer() { - if (testCustomizer == null) { - throw new IllegalStateException("testCustomizer not yet set by call to createDataBrokerTestCustomizer()"); - } - return testCustomizer; - } - - @Override - protected void setupWithSchema(final SchemaContext context) { - testCustomizer = createDataBrokerTestCustomizer(); - dataBroker = testCustomizer.createDataBroker(); - domBroker = testCustomizer.getDOMDataBroker(); - testCustomizer.updateSchema(context); - } - - public DataBroker getDataBroker() { - return dataBroker; - } - - public DOMDataBroker getDomBroker() { - return domBroker; - } - - protected static final void assertCommit(final ListenableFuture commit) { - assertCommit(commit, ASSERT_COMMIT_DEFAULT_TIMEOUT); - } - - protected static final void assertCommit(final ListenableFuture commit, long timeoutInMS) { - try { - commit.get(timeoutInMS, TimeUnit.MILLISECONDS); - } catch (InterruptedException | ExecutionException | TimeoutException e) { - throw new IllegalStateException(e); - } - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/AbstractConcurrentDataBrokerTest.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/AbstractConcurrentDataBrokerTest.java deleted file mode 100644 index 9fedfbb0e8..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/AbstractConcurrentDataBrokerTest.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2017 Red Hat, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.test; - -/** - * AbstractConcurrentDataBrokerTest. - * - *

Uses single thread executor for the Serialized DOM DataBroker (instead of the - * direct executor used by the {@literal @}Deprecated AbstractDataBrokerTest) in order - * to allow tests to use the DataBroker concurrently from several threads. - * - *

See also bug 7538 for more details. - * - * @author Michael Vorburger - */ -@Deprecated -public abstract class AbstractConcurrentDataBrokerTest extends AbstractBaseDataBrokerTest { - private final boolean useMTDataTreeChangeListenerExecutor; - - protected AbstractConcurrentDataBrokerTest() { - this(false); - } - - protected AbstractConcurrentDataBrokerTest(final boolean useMTDataTreeChangeListenerExecutor) { - this.useMTDataTreeChangeListenerExecutor = useMTDataTreeChangeListenerExecutor; - } - - @Override - protected AbstractDataBrokerTestCustomizer createDataBrokerTestCustomizer() { - return new ConcurrentDataBrokerTestCustomizer(useMTDataTreeChangeListenerExecutor); - } - -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/AbstractDataBrokerTest.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/AbstractDataBrokerTest.java deleted file mode 100644 index 35f0650985..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/AbstractDataBrokerTest.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.test; - -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -/** - * AbstractDataBrokerTest. - * - * @deprecated Please now use the AbstractConcurrentDataBrokerTest instead of - * this. Normally in a well written test this should be a drop-in - * replacement. Instead of {@literal @}Override - * setupWithDataBroker(DataBroker dataBroker), please just use - * JUnit's {@literal @}Before before() { ... getDataBroker() }. Some - * tests which relied on the Test DataBroker being synchronous, - * contrary to its specification as well as the production - * implementation, may require changes to e.g. use get() on - * submit()'ed transaction to make the test wait before asserts. See - * also - * bug - * 7538 for more details. - */ -@Deprecated -public class AbstractDataBrokerTest extends AbstractBaseDataBrokerTest { - - @Override - protected AbstractDataBrokerTestCustomizer createDataBrokerTestCustomizer() { - return new DataBrokerTestCustomizer(); - } - - @Override - protected void setupWithSchema(SchemaContext context) { - super.setupWithSchema(context); - setupWithDataBroker(getDataBroker()); - } - - protected void setupWithDataBroker(final DataBroker dataBroker) { - // Intentionally left No-op, subclasses may customize it - } - -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/AbstractDataBrokerTestCustomizer.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/AbstractDataBrokerTestCustomizer.java deleted file mode 100644 index 44e1375a79..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/AbstractDataBrokerTestCustomizer.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (c) 2017 Red Hat, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.test; - -import com.google.common.collect.ImmutableMap; -import com.google.common.util.concurrent.ListeningExecutorService; -import com.google.common.util.concurrent.MoreExecutors; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; -import org.opendaylight.controller.md.sal.binding.api.NotificationService; -import org.opendaylight.controller.md.sal.binding.impl.BindingDOMDataBrokerAdapter; -import org.opendaylight.controller.md.sal.binding.impl.BindingDOMNotificationPublishServiceAdapter; -import org.opendaylight.controller.md.sal.binding.impl.BindingDOMNotificationServiceAdapter; -import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; -import org.opendaylight.controller.md.sal.dom.broker.impl.DOMNotificationRouter; -import org.opendaylight.controller.md.sal.dom.broker.impl.SerializedDOMDataBroker; -import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore; -import org.opendaylight.controller.sal.binding.test.util.MockSchemaService; -import org.opendaylight.controller.sal.core.spi.data.DOMStore; -import org.opendaylight.mdsal.binding.dom.codec.impl.BindingNormalizedNodeCodecRegistry; -import org.opendaylight.mdsal.binding.generator.impl.GeneratedClassLoadingStrategy; -import org.opendaylight.mdsal.dom.api.DOMSchemaService; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -@Deprecated -public abstract class AbstractDataBrokerTestCustomizer { - - private DOMDataBroker domDataBroker; - private final DOMNotificationRouter domNotificationRouter; - private final MockSchemaService schemaService; - private ImmutableMap datastores; - private final BindingToNormalizedNodeCodec bindingToNormalized; - - public ImmutableMap createDatastores() { - return ImmutableMap.builder() - .put(LogicalDatastoreType.OPERATIONAL, createOperationalDatastore()) - .put(LogicalDatastoreType.CONFIGURATION,createConfigurationDatastore()) - .build(); - } - - public AbstractDataBrokerTestCustomizer() { - this.schemaService = new MockSchemaService(); - final BindingNormalizedNodeCodecRegistry codecRegistry = new BindingNormalizedNodeCodecRegistry(); - final GeneratedClassLoadingStrategy loading = GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy(); - this.bindingToNormalized = new BindingToNormalizedNodeCodec(loading, codecRegistry); - this.schemaService.registerSchemaContextListener(this.bindingToNormalized); - this.domNotificationRouter = DOMNotificationRouter.create(16); - } - - public DOMStore createConfigurationDatastore() { - final InMemoryDOMDataStore store = new InMemoryDOMDataStore("CFG", getDataTreeChangeListenerExecutor()); - this.schemaService.registerSchemaContextListener(store); - return store; - } - - public DOMStore createOperationalDatastore() { - final InMemoryDOMDataStore store = new InMemoryDOMDataStore("OPER", getDataTreeChangeListenerExecutor()); - this.schemaService.registerSchemaContextListener(store); - return store; - } - - public DOMDataBroker createDOMDataBroker() { - return new SerializedDOMDataBroker(getDatastores(), getCommitCoordinatorExecutor()); - } - - public NotificationService createNotificationService() { - return new BindingDOMNotificationServiceAdapter(this.bindingToNormalized.getCodecRegistry(), - this.domNotificationRouter); - } - - public NotificationPublishService createNotificationPublishService() { - return new BindingDOMNotificationPublishServiceAdapter(this.bindingToNormalized, this.domNotificationRouter); - } - - public abstract ListeningExecutorService getCommitCoordinatorExecutor(); - - public ListeningExecutorService getDataTreeChangeListenerExecutor() { - return MoreExecutors.newDirectExecutorService(); - } - - public DataBroker createDataBroker() { - return new BindingDOMDataBrokerAdapter(getDOMDataBroker(), this.bindingToNormalized); - } - - public BindingToNormalizedNodeCodec getBindingToNormalized() { - return this.bindingToNormalized; - } - - public DOMSchemaService getSchemaService() { - return this.schemaService; - } - - public DOMDataBroker getDOMDataBroker() { - if (this.domDataBroker == null) { - this.domDataBroker = createDOMDataBroker(); - } - return this.domDataBroker; - } - - private synchronized ImmutableMap getDatastores() { - if (this.datastores == null) { - this.datastores = createDatastores(); - } - return this.datastores; - } - - public void updateSchema(final SchemaContext ctx) { - this.schemaService.changeSchema(ctx); - } - - public DOMNotificationRouter getDomNotificationRouter() { - return this.domNotificationRouter; - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/AbstractDataTreeChangeListenerTest.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/AbstractDataTreeChangeListenerTest.java deleted file mode 100644 index c96d2c694d..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/AbstractDataTreeChangeListenerTest.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright (c) 2018 Inocybe Technologies and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.test; - -import static org.junit.Assert.fail; - -import com.google.common.util.concurrent.SettableFuture; -import com.google.common.util.concurrent.Uninterruptibles; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; -import java.util.Objects; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; -import java.util.function.Function; -import org.opendaylight.controller.md.sal.binding.api.DataObjectModification.ModificationType; -import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener; -import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier; -import org.opendaylight.controller.md.sal.binding.api.DataTreeModification; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -/** - * Abstract base that provides a DTCL for verification. - * - * @author Thomas Pantelis - */ -@Deprecated -public class AbstractDataTreeChangeListenerTest extends AbstractConcurrentDataBrokerTest { - protected static final class TestListener implements DataTreeChangeListener { - - private final List> accumulatedChanges = new ArrayList<>(); - private final SettableFuture>> future = SettableFuture.create(); - private final Function, Boolean>[] matchers; - private final int expChangeCount; - - private TestListener(Function, Boolean>[] matchers) { - this.expChangeCount = matchers.length; - this.matchers = matchers; - } - - @Override - public void onDataTreeChanged(Collection> changes) { - synchronized (accumulatedChanges) { - accumulatedChanges.addAll(changes); - if (expChangeCount == accumulatedChanges.size()) { - future.set(new ArrayList<>(accumulatedChanges)); - } - } - } - - public Collection> changes() { - try { - final Collection> changes = future.get(5, TimeUnit.SECONDS); - Uninterruptibles.sleepUninterruptibly(500, TimeUnit.MILLISECONDS); - return changes; - } catch (InterruptedException | TimeoutException | ExecutionException e) { - throw new AssertionError(String.format( - "Data tree change notifications not received. Expected: %s. Actual: %s - %s", - expChangeCount, accumulatedChanges.size(), accumulatedChanges), e); - } - } - - public void verify() { - Collection> changes = new ArrayList<>(changes()); - Iterator> iter = changes.iterator(); - while (iter.hasNext()) { - DataTreeModification dataTreeModification = iter.next(); - for (Function, Boolean> matcher: matchers) { - if (matcher.apply(dataTreeModification)) { - iter.remove(); - break; - } - } - } - - if (!changes.isEmpty()) { - DataTreeModification mod = changes.iterator().next(); - fail(String.format("Received unexpected notification: type: %s, path: %s, before: %s, after: %s", - mod.getRootNode().getModificationType(), mod.getRootPath().getRootIdentifier(), - mod.getRootNode().getDataBefore(), mod.getRootNode().getDataAfter())); - } - } - - public boolean hasChanges() { - synchronized (accumulatedChanges) { - return !accumulatedChanges.isEmpty(); - } - } - } - - protected AbstractDataTreeChangeListenerTest() { - super(true); - } - - @SafeVarargs - protected final TestListener createListener(final LogicalDatastoreType store, - final InstanceIdentifier path, Function, Boolean>... matchers) { - TestListener listener = new TestListener<>(matchers); - getDataBroker().registerDataTreeChangeListener(new DataTreeIdentifier<>(store, path), listener); - return listener; - } - - public static Function, Boolean> match( - ModificationType type, InstanceIdentifier path, Function checkDataBefore, - Function checkDataAfter) { - return modification -> type == modification.getRootNode().getModificationType() - && path.equals(modification.getRootPath().getRootIdentifier()) - && checkDataBefore.apply(modification.getRootNode().getDataBefore()) - && checkDataAfter.apply(modification.getRootNode().getDataAfter()); - } - - public static Function, Boolean> match( - ModificationType type, InstanceIdentifier path, T expDataBefore, T expDataAfter) { - return match(type, path, dataBefore -> Objects.equals(expDataBefore, dataBefore), - (Function) dataAfter -> Objects.equals(expDataAfter, dataAfter)); - } - - public static Function, Boolean> added( - InstanceIdentifier path, T data) { - return match(ModificationType.WRITE, path, null, data); - } - - public static Function, Boolean> replaced( - InstanceIdentifier path, T dataBefore, T dataAfter) { - return match(ModificationType.WRITE, path, dataBefore, dataAfter); - } - - public static Function, Boolean> deleted( - InstanceIdentifier path, T dataBefore) { - return match(ModificationType.DELETE, path, dataBefore, null); - } - - public static Function, Boolean> subtreeModified( - InstanceIdentifier path, T dataBefore, T dataAfter) { - return match(ModificationType.SUBTREE_MODIFIED, path, dataBefore, dataAfter); - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/AbstractNotificationBrokerTest.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/AbstractNotificationBrokerTest.java deleted file mode 100644 index cd40130072..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/AbstractNotificationBrokerTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.test; - -import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; -import org.opendaylight.controller.md.sal.binding.api.NotificationService; -import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec; -import org.opendaylight.controller.md.sal.dom.broker.impl.DOMNotificationRouter; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -@Deprecated -public class AbstractNotificationBrokerTest extends AbstractSchemaAwareTest { - - private BindingToNormalizedNodeCodec bindingToNormalizedNodeCodec; - private DOMNotificationRouter domNotificationRouter; - private NotificationService notificationService; - private NotificationPublishService notificationPublishService; - - @Override - protected void setupWithSchema(final SchemaContext context) { - final DataBrokerTestCustomizer testCustomizer = createDataBrokerTestCustomizer(); - domNotificationRouter = testCustomizer.getDomNotificationRouter(); - notificationService = testCustomizer.createNotificationService(); - notificationPublishService = testCustomizer.createNotificationPublishService(); - bindingToNormalizedNodeCodec = testCustomizer.getBindingToNormalized(); - testCustomizer.updateSchema(context); - } - - protected DataBrokerTestCustomizer createDataBrokerTestCustomizer() { - return new DataBrokerTestCustomizer(); - } - - public NotificationService getNotificationService() { - return notificationService; - } - - public NotificationPublishService getNotificationPublishService() { - return notificationPublishService; - } - - public DOMNotificationRouter getDomNotificationRouter() { - return domNotificationRouter; - } - - public BindingToNormalizedNodeCodec getBindingToNormalizedNodeCodec() { - return bindingToNormalizedNodeCodec; - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/AbstractSchemaAwareTest.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/AbstractSchemaAwareTest.java deleted file mode 100644 index 524b903bd0..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/AbstractSchemaAwareTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.test; - -import com.google.common.cache.CacheBuilder; -import com.google.common.cache.CacheLoader; -import com.google.common.cache.LoadingCache; -import com.google.common.collect.ImmutableSet; -import java.util.Set; -import org.junit.Before; -import org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext; -import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections; -import org.opendaylight.yangtools.yang.binding.YangModuleInfo; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -@Deprecated -public abstract class AbstractSchemaAwareTest { - private static final LoadingCache> MODULE_INFO_CACHE = CacheBuilder.newBuilder() - .weakKeys().weakValues().build(new CacheLoader>() { - @Override - public Set load(final ClassLoader key) { - return BindingReflections.loadModuleInfos(key); - } - }); - private static final LoadingCache, SchemaContext> SCHEMA_CONTEXT_CACHE = - CacheBuilder.newBuilder().weakValues().build(new CacheLoader, SchemaContext>() { - @Override - public SchemaContext load(final Set key) { - final ModuleInfoBackedContext moduleContext = ModuleInfoBackedContext.create(); - moduleContext.addModuleInfos(key); - return moduleContext.tryToCreateSchemaContext().get(); - } - }); - - protected Set getModuleInfos() throws Exception { - return MODULE_INFO_CACHE.getUnchecked(Thread.currentThread().getContextClassLoader()); - } - - protected SchemaContext getSchemaContext() throws Exception { - // ImmutableSet guarantees non-null - return SCHEMA_CONTEXT_CACHE.getUnchecked(ImmutableSet.copyOf(getModuleInfos())); - } - - @Before - public final void setup() throws Exception { - setupWithSchema(getSchemaContext()); - } - - /** - * Setups test with Schema context. - * This method is called before {@link #setupWithSchemaService(SchemaService)} - */ - protected abstract void setupWithSchema(SchemaContext context); - -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/AssertCollections.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/AssertCollections.java deleted file mode 100644 index b9e1772aaf..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/AssertCollections.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.md.sal.binding.test; - -import java.util.Collection; -import java.util.Map; -import org.junit.Assert; - -@Deprecated -public final class AssertCollections { - private AssertCollections() { - } - - public static void assertEmpty(final Collection set) { - Assert.assertTrue(set.isEmpty()); - } - - public static void assertEmpty(final Map set) { - Assert.assertTrue(set.isEmpty()); - } - - public static void assertContains(final Collection set, final Object... values) { - for (Object key : values) { - Assert.assertTrue(set.contains(key)); - } - - } - - public static void assertContains(final Map map, final Object... values) { - for (Object key : values) { - Assert.assertTrue(map.containsKey(key)); - } - } - - public static void assertNotContains(final Collection set, final Object... values) { - for (Object key : values) { - Assert.assertFalse(set.contains(key)); - } - } - - public static void assertNotContains(final Map map, final Object... values) { - for (Object key : values) { - Assert.assertFalse(map.containsKey(key)); - } - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/ConcurrentDataBrokerTestCustomizer.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/ConcurrentDataBrokerTestCustomizer.java deleted file mode 100644 index 95b17d7ff0..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/ConcurrentDataBrokerTestCustomizer.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2017 Red Hat, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.test; - -import com.google.common.util.concurrent.ListeningExecutorService; -import com.google.common.util.concurrent.MoreExecutors; -import java.util.concurrent.Executors; - -/** - * ConcurrentDataBrokerTestCustomizer. - * - *

See {@link AbstractConcurrentDataBrokerTest} and - * bug 7538 for more details & background. - * - * @author Michael Vorburger - */ -@Deprecated -public class ConcurrentDataBrokerTestCustomizer extends AbstractDataBrokerTestCustomizer { - - private final ListeningExecutorService dataTreeChangeListenerExecutorSingleton; - - public ConcurrentDataBrokerTestCustomizer(boolean useMTDataTreeChangeListenerExecutor) { - if (useMTDataTreeChangeListenerExecutor) { - dataTreeChangeListenerExecutorSingleton = MoreExecutors.listeningDecorator(Executors.newCachedThreadPool()); - } else { - dataTreeChangeListenerExecutorSingleton = MoreExecutors.newDirectExecutorService(); - } - } - - @Override - public ListeningExecutorService getCommitCoordinatorExecutor() { - return MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor()); - } - - @Override - public ListeningExecutorService getDataTreeChangeListenerExecutor() { - return dataTreeChangeListenerExecutorSingleton; - } - -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/ConstantSchemaAbstractDataBrokerTest.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/ConstantSchemaAbstractDataBrokerTest.java deleted file mode 100644 index 93f15b70e9..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/ConstantSchemaAbstractDataBrokerTest.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2016 Red Hat, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.test; - -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -/** - * AbstractDataBrokerTest which creates the SchemaContext - * only once, and keeps it in a static, instead of re-recreating - * it for each Test, and is thus faster. - * - * @author Michael Vorburger - * @deprecated This class is no longer useful, as {@link AbstractSchemaAwareTest#getSchemaContext()} provides effective - * caching. - */ -@Deprecated -public class ConstantSchemaAbstractDataBrokerTest extends AbstractConcurrentDataBrokerTest { - - public ConstantSchemaAbstractDataBrokerTest() { - } - - public ConstantSchemaAbstractDataBrokerTest(final boolean useMTDataTreeChangeListenerExecutor) { - super(useMTDataTreeChangeListenerExecutor); - } - - @Override - protected SchemaContext getSchemaContext() throws Exception { - return SchemaContextSingleton.getSchemaContext(super::getSchemaContext); - } - -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/DataBrokerTestCustomizer.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/DataBrokerTestCustomizer.java deleted file mode 100644 index e037de452b..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/DataBrokerTestCustomizer.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.test; - -import com.google.common.util.concurrent.ListeningExecutorService; -import com.google.common.util.concurrent.MoreExecutors; - -/** - * DataBrokerTestCustomizer. - * - * @deprecated Please use the ConcurrentDataBrokerTestCustomizer instead of - * this; see AbstractDataBrokerTest for more details. - */ -@Deprecated -public class DataBrokerTestCustomizer extends AbstractDataBrokerTestCustomizer { - - @Override - public ListeningExecutorService getCommitCoordinatorExecutor() { - return MoreExecutors.newDirectExecutorService(); - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/DataBrokerTestModule.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/DataBrokerTestModule.java deleted file mode 100644 index 384f3dfb27..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/DataBrokerTestModule.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2016 Red Hat, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.test; - -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec; -import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; -import org.opendaylight.controller.md.sal.dom.broker.impl.DOMNotificationRouter; -import org.opendaylight.mdsal.dom.api.DOMSchemaService; -import org.opendaylight.yangtools.yang.model.api.SchemaContextProvider; - -@Deprecated -public class DataBrokerTestModule { - - public static DataBroker dataBroker() { - return new DataBrokerTestModule(false).getDataBroker(); - } - - private final boolean useMTDataTreeChangeListenerExecutor; - private ConstantSchemaAbstractDataBrokerTest dataBrokerTest; - - public DataBrokerTestModule(boolean useMTDataTreeChangeListenerExecutor) { - this.useMTDataTreeChangeListenerExecutor = useMTDataTreeChangeListenerExecutor; - } - - // Suppress IllegalCatch because of AbstractDataBrokerTest (change later) - @SuppressWarnings({ "checkstyle:IllegalCatch", "checkstyle:IllegalThrows" }) - public DataBroker getDataBroker() throws RuntimeException { - try { - // This is a little bit "upside down" - in the future, - // we should probably put what is in AbstractDataBrokerTest - // into this DataBrokerTestModule, and make AbstractDataBrokerTest - // use it, instead of the way around it currently is (the opposite); - // this is just for historical reasons... and works for now. - dataBrokerTest = new ConstantSchemaAbstractDataBrokerTest(useMTDataTreeChangeListenerExecutor); - dataBrokerTest.setup(); - return dataBrokerTest.getDataBroker(); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - public DOMDataBroker getDOMDataBroker() { - return dataBrokerTest.getDomBroker(); - } - - public BindingToNormalizedNodeCodec getBindingToNormalizedNodeCodec() { - return dataBrokerTest.getDataBrokerTestCustomizer().getBindingToNormalized(); - } - - public DOMNotificationRouter getDOMNotificationRouter() { - return dataBrokerTest.getDataBrokerTestCustomizer().getDomNotificationRouter(); - } - - public DOMSchemaService getSchemaService() { - return dataBrokerTest.getDataBrokerTestCustomizer().getSchemaService(); - } - - public SchemaContextProvider getSchemaContextProvider() { - return (SchemaContextProvider) dataBrokerTest.getDataBrokerTestCustomizer().getSchemaService(); - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/SchemaContextSingleton.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/SchemaContextSingleton.java deleted file mode 100644 index 06763bc2a1..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/SchemaContextSingleton.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2016 Red Hat, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.test; - -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -/** - * {@link SchemaContext} singleton holder (static). - * - *

This is useful in scenarios such as unit tests, but not OSGi environments, - * where there is a flat classpath and thus really only one single - * SchemaContext. - * - * @author Michael Vorburger - * @deprecated This class should not be used, as it pollutes the classpath. - */ -@Deprecated -public final class SchemaContextSingleton { - - private static SchemaContext staticSchemaContext; - - public static synchronized SchemaContext getSchemaContext(final Supplier supplier) throws Exception { - if (staticSchemaContext == null) { - staticSchemaContext = supplier.get(); - } - return staticSchemaContext; - } - - private SchemaContextSingleton() { - - } - - @FunctionalInterface - public interface Supplier { - T get() throws Exception; - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/tests/AbstractDataBrokerTestTest.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/tests/AbstractDataBrokerTestTest.java deleted file mode 100644 index 937f024ea9..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/tests/AbstractDataBrokerTestTest.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2016 Red Hat, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.test.tests; - -import static com.google.common.truth.Truth.assertThat; -import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.TOP_FOO_KEY; -import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.path; -import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.topLevelList; - -import org.junit.Before; -import org.junit.FixMethodOrder; -import org.junit.Test; -import org.junit.runners.MethodSorters; -import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.binding.test.AbstractConcurrentDataBrokerTest; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; -import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.TreeComplexUsesAugment; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.TreeComplexUsesAugmentBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.complex.from.grouping.ContainerWithUsesBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.TopBuilder; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -/** - * Integration tests the AbstractDataBrokerTest. - * - * @author Michael Vorburger - */ -@Deprecated -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class AbstractDataBrokerTestTest extends AbstractConcurrentDataBrokerTest { - - private static final InstanceIdentifier TOP_PATH = InstanceIdentifier.create(Top.class); - - @Before - public void before() { - assertThat(getDataBroker()).isNotNull(); - } - - @Test - public void aEnsureDataBrokerIsNotNull() { - assertThat(getDataBroker()).isNotNull(); - } - - @Test - public void bPutSomethingIntoDataStore() throws Exception { - writeInitialState(); - assertThat(isTopInDataStore()).isTrue(); - } - - @Test - public void cEnsureDataStoreIsEmptyAgainInNewTest() throws ReadFailedException { - assertThat(isTopInDataStore()).isFalse(); - } - - // copy/pasted from Bug1125RegressionTest.writeInitialState() - private void writeInitialState() throws TransactionCommitFailedException { - WriteTransaction initialTx = getDataBroker().newWriteOnlyTransaction(); - initialTx.put(LogicalDatastoreType.OPERATIONAL, TOP_PATH, new TopBuilder().build()); - TreeComplexUsesAugment fooAugment = new TreeComplexUsesAugmentBuilder() - .setContainerWithUses(new ContainerWithUsesBuilder().setLeafFromGrouping("foo").build()).build(); - initialTx.put(LogicalDatastoreType.OPERATIONAL, path(TOP_FOO_KEY), topLevelList(TOP_FOO_KEY, fooAugment)); - initialTx.submit().checkedGet(); - } - - private boolean isTopInDataStore() throws ReadFailedException { - try (ReadOnlyTransaction readTx = getDataBroker().newReadOnlyTransaction()) { - return readTx.read(LogicalDatastoreType.OPERATIONAL, TOP_PATH).checkedGet().isPresent(); - } - } - -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/tests/DataBrokerTestModuleTest.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/tests/DataBrokerTestModuleTest.java deleted file mode 100644 index 1512d8e481..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/tests/DataBrokerTestModuleTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2016 Red Hat, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.test.tests; - -import static com.google.common.truth.Truth.assertThat; - -import org.junit.Ignore; -import org.junit.Test; -import org.opendaylight.controller.md.sal.binding.test.DataBrokerTestModule; - -/** - * Integration tests the DataBrokerTestModule. - * - * @author Michael Vorburger - */ -@Deprecated -public class DataBrokerTestModuleTest { - - @Test - public void ensureDataBrokerTestModuleWorksWithoutException() { - assertThat(DataBrokerTestModule.dataBroker()).isNotNull(); - } - - @Test - @Ignore // This test is flaky on build server VMs (although fine locally) - public void slowYangLoadingShouldOnlyHappenOnceAndNotDelayEachDataBroker() { - // TODO Write a lil' Timer utility class to make this kind of timing test code more readable - long startAtMs = System.currentTimeMillis(); - DataBrokerTestModule.dataBroker(); - long firstDataBrokerAtMs = System.currentTimeMillis(); - long firstDataBrokerDurationMs = firstDataBrokerAtMs - startAtMs; - DataBrokerTestModule.dataBroker(); - long secondDataBrokerDurationMs = System.currentTimeMillis() - firstDataBrokerAtMs; - assertThat(Math.abs(secondDataBrokerDurationMs - firstDataBrokerDurationMs)) - .isLessThan(firstDataBrokerDurationMs / 4); - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/AbstractDataServiceTest.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/AbstractDataServiceTest.java deleted file mode 100644 index 4dfc92881d..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/AbstractDataServiceTest.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.binding.test; - -import com.google.common.util.concurrent.ListeningExecutorService; -import com.google.common.util.concurrent.MoreExecutors; -import org.junit.Before; -import org.opendaylight.controller.sal.binding.test.util.BindingBrokerTestFactory; -import org.opendaylight.controller.sal.binding.test.util.BindingTestContext; - -@Deprecated -public abstract class AbstractDataServiceTest { - - protected BindingTestContext testContext; - - @Before - public void setUp() { - ListeningExecutorService executor = MoreExecutors.newDirectExecutorService(); - BindingBrokerTestFactory factory = new BindingBrokerTestFactory(); - factory.setExecutor(executor); - factory.setStartWithParsedSchema(getStartWithSchema()); - testContext = factory.getTestContext(); - testContext.start(); - } - - protected boolean getStartWithSchema() { - return true; - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/AugmentationVerifier.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/AugmentationVerifier.java deleted file mode 100644 index 45eed6a069..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/AugmentationVerifier.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.binding.test; - -import static org.junit.Assert.assertNotNull; - -import org.opendaylight.yangtools.yang.binding.Augmentable; -import org.opendaylight.yangtools.yang.binding.Augmentation; - -@Deprecated -public class AugmentationVerifier> { - - private final T object; - - public AugmentationVerifier(final T objectToVerify) { - this.object = objectToVerify; - } - - public AugmentationVerifier assertHasAugmentation(final Class> augmentation) { - assertHasAugmentation(object, augmentation); - return this; - } - - public static > void assertHasAugmentation(final T object, - final Class> augmentation) { - assertNotNull(object); - assertNotNull("Augmentation " + augmentation.getSimpleName() + " is not present.", - object.augmentation(augmentation)); - } - - public static > AugmentationVerifier from(final T obj) { - return new AugmentationVerifier<>(obj); - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/BindingTestUtilities.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/BindingTestUtilities.java deleted file mode 100644 index ad6c189fc4..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/BindingTestUtilities.java +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.binding.test; - -@Deprecated -public class BindingTestUtilities { - -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/BarListener.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/BarListener.java deleted file mode 100644 index 59009442f1..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/BarListener.java +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.binding.test.mock; - -import org.opendaylight.yangtools.yang.binding.NotificationListener; - -@Deprecated -public interface BarListener extends NotificationListener { - - void onBarUpdate(BarUpdate notification); - - void onFlowDelete(FlowDelete notification); - -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/BarUpdate.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/BarUpdate.java deleted file mode 100644 index 473b68fd01..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/BarUpdate.java +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.binding.test.mock; - -import org.opendaylight.yangtools.yang.binding.Notification; - -@Deprecated -public interface BarUpdate extends Grouping,Notification { - - - -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/CompositeListener.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/CompositeListener.java deleted file mode 100644 index 86d30d8614..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/CompositeListener.java +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.binding.test.mock; - -@Deprecated -public interface CompositeListener extends FooListener, BarListener { - -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/FlowDelete.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/FlowDelete.java deleted file mode 100644 index 281e741567..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/FlowDelete.java +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.binding.test.mock; - -import org.opendaylight.yangtools.yang.binding.Notification; - -@Deprecated -public interface FlowDelete extends Notification{ - -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/FooListener.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/FooListener.java deleted file mode 100644 index b9065b6182..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/FooListener.java +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.binding.test.mock; - -import org.opendaylight.yangtools.yang.binding.NotificationListener; - -@Deprecated -public interface FooListener extends NotificationListener { - - void onFooUpdate(FooUpdate notification); - -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/FooService.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/FooService.java deleted file mode 100644 index 5e7aad0fd6..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/FooService.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.binding.test.mock; - -import java.util.concurrent.Future; -import org.opendaylight.yangtools.yang.binding.RpcService; -import org.opendaylight.yangtools.yang.common.RpcResult; - -@Deprecated -public interface FooService extends RpcService { - - Future> foo(); - - Future> simple(SimpleInput obj); - - Future> inheritedContext(InheritedContextInput obj); - -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/FooUpdate.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/FooUpdate.java deleted file mode 100644 index bc57681513..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/FooUpdate.java +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.binding.test.mock; - -import org.opendaylight.yangtools.yang.binding.Notification; - -@Deprecated -public interface FooUpdate extends Notification { - -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/Grouping.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/Grouping.java deleted file mode 100644 index f1162cef14..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/Grouping.java +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.binding.test.mock; - -import org.opendaylight.yangtools.yang.binding.BaseIdentity; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.binding.annotations.RoutingContext; - -@Deprecated -public interface Grouping { - - @RoutingContext(BaseIdentity.class) - InstanceIdentifier getInheritedIdentifier(); -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/InheritedContextInput.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/InheritedContextInput.java deleted file mode 100644 index 256bb74200..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/InheritedContextInput.java +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.binding.test.mock; - -@Deprecated -public interface InheritedContextInput extends Grouping { - -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/ReferencableObject.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/ReferencableObject.java deleted file mode 100644 index 5af6a47be6..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/ReferencableObject.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.binding.test.mock; - -import org.opendaylight.yangtools.yang.binding.ChildOf; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.DataRoot; -import org.opendaylight.yangtools.yang.binding.Identifiable; - -@Deprecated -public interface ReferencableObject extends DataObject, Identifiable, ChildOf { - -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/ReferencableObjectKey.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/ReferencableObjectKey.java deleted file mode 100644 index 76557f8e85..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/ReferencableObjectKey.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.binding.test.mock; - -import org.opendaylight.yangtools.yang.binding.Identifier; - -@Deprecated -public class ReferencableObjectKey implements Identifier { - private static final long serialVersionUID = 1L; - final Integer value; - - public ReferencableObjectKey(Integer value) { - this.value = value; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + (value == null ? 0 : value.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - ReferencableObjectKey other = (ReferencableObjectKey) obj; - if (value == null) { - if (other.value != null) { - return false; - } - } else if (!value.equals(other.value)) { - return false; - } - return true; - } - - @Override - public String toString() { - return "ReferencableObjectKey [value=" + value + "]"; - } - - -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/SimpleInput.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/SimpleInput.java deleted file mode 100644 index eaefe264a5..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/SimpleInput.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.binding.test.mock; - -import org.opendaylight.yangtools.yang.binding.Augmentable; -import org.opendaylight.yangtools.yang.binding.BaseIdentity; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.binding.annotations.RoutingContext; - -@Deprecated -public interface SimpleInput extends DataObject,Augmentable { - - @RoutingContext(BaseIdentity.class) - InstanceIdentifier getIdentifier(); -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/util/BindingBrokerTestFactory.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/util/BindingBrokerTestFactory.java deleted file mode 100644 index cd4e4101d9..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/util/BindingBrokerTestFactory.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.binding.test.util; - -import com.google.common.annotations.Beta; -import com.google.common.base.Preconditions; -import com.google.common.util.concurrent.ListeningExecutorService; -import com.google.common.util.concurrent.MoreExecutors; -import java.util.concurrent.ExecutorService; - -@Beta -@Deprecated -public class BindingBrokerTestFactory { - private boolean startWithParsedSchema = true; - private ExecutorService executor; - - - public boolean isStartWithParsedSchema() { - return startWithParsedSchema; - } - - public void setStartWithParsedSchema(final boolean startWithParsedSchema) { - this.startWithParsedSchema = startWithParsedSchema; - } - - public ExecutorService getExecutor() { - return executor; - } - - public void setExecutor(final ExecutorService executor) { - this.executor = executor; - } - - public BindingTestContext getTestContext() { - Preconditions.checkState(executor != null, "Executor is not set."); - ListeningExecutorService listenableExecutor = MoreExecutors.listeningDecorator(executor); - return new BindingTestContext(listenableExecutor, startWithParsedSchema); - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/util/BindingTestContext.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/util/BindingTestContext.java deleted file mode 100644 index 4ba3d7a081..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/util/BindingTestContext.java +++ /dev/null @@ -1,255 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.binding.test.util; - -import static com.google.common.base.Preconditions.checkState; - -import com.google.common.annotations.Beta; -import com.google.common.collect.ImmutableMap; -import com.google.common.util.concurrent.ListeningExecutorService; -import com.google.common.util.concurrent.MoreExecutors; -import java.util.Set; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.MountPointService; -import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; -import org.opendaylight.controller.md.sal.binding.api.NotificationService; -import org.opendaylight.controller.md.sal.binding.compat.HeliumNotificationProviderServiceAdapter; -import org.opendaylight.controller.md.sal.binding.compat.HeliumRpcProviderRegistry; -import org.opendaylight.controller.md.sal.binding.impl.BindingDOMDataBrokerAdapter; -import org.opendaylight.controller.md.sal.binding.impl.BindingDOMMountPointServiceAdapter; -import org.opendaylight.controller.md.sal.binding.impl.BindingDOMNotificationPublishServiceAdapter; -import org.opendaylight.controller.md.sal.binding.impl.BindingDOMNotificationServiceAdapter; -import org.opendaylight.controller.md.sal.binding.impl.BindingDOMRpcProviderServiceAdapter; -import org.opendaylight.controller.md.sal.binding.impl.BindingDOMRpcServiceAdapter; -import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; -import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService; -import org.opendaylight.controller.md.sal.dom.api.DOMNotificationPublishService; -import org.opendaylight.controller.md.sal.dom.api.DOMNotificationService; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcProviderService; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcService; -import org.opendaylight.controller.md.sal.dom.broker.impl.DOMNotificationRouter; -import org.opendaylight.controller.md.sal.dom.broker.impl.DOMRpcRouter; -import org.opendaylight.controller.md.sal.dom.broker.impl.SerializedDOMDataBroker; -import org.opendaylight.controller.md.sal.dom.broker.impl.mount.DOMMountPointServiceImpl; -import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore; -import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry; -import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; -import org.opendaylight.controller.sal.binding.impl.RootBindingAwareBroker; -import org.opendaylight.controller.sal.core.spi.data.DOMStore; -import org.opendaylight.mdsal.binding.dom.codec.impl.BindingNormalizedNodeCodecRegistry; -import org.opendaylight.mdsal.binding.generator.impl.GeneratedClassLoadingStrategy; -import org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext; -import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections; -import org.opendaylight.yangtools.yang.binding.YangModuleInfo; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -@Beta -@Deprecated -public class BindingTestContext implements AutoCloseable { - private BindingToNormalizedNodeCodec codec; - - private RootBindingAwareBroker baBrokerImpl; - - private HeliumNotificationProviderServiceAdapter baNotifyImpl; - - - private final ListeningExecutorService executor; - - private final boolean startWithSchema; - - private DOMMountPointService biMountImpl; - - private ImmutableMap newDatastores; - - private DOMDataBroker newDOMDataBroker; - - private final MockSchemaService mockSchemaService = new MockSchemaService(); - - private DataBroker dataBroker; - - private RpcConsumerRegistry baConsumerRpc; - - private BindingDOMRpcProviderServiceAdapter baProviderRpc; - private DOMRpcRouter domRouter; - private org.opendaylight.mdsal.dom.broker.DOMRpcRouter delegateDomRouter; - - private NotificationPublishService publishService; - - private NotificationService listenService; - - private DOMNotificationPublishService domPublishService; - - private DOMNotificationService domListenService; - - private Set schemaModuleInfos; - - public DOMDataBroker getDomAsyncDataBroker() { - return this.newDOMDataBroker; - } - - public BindingToNormalizedNodeCodec getCodec() { - return this.codec; - } - - - protected BindingTestContext(final ListeningExecutorService executor, final boolean startWithSchema) { - this.executor = executor; - this.startWithSchema = startWithSchema; - } - - public void startDomDataBroker() { - } - - public void startNewDataBroker() { - checkState(this.executor != null, "Executor needs to be set"); - checkState(this.newDOMDataBroker != null, "DOM Data Broker must be set"); - this.dataBroker = new BindingDOMDataBrokerAdapter(this.newDOMDataBroker, this.codec); - } - - public void startNewDomDataBroker() { - checkState(this.executor != null, "Executor needs to be set"); - final InMemoryDOMDataStore operStore = new InMemoryDOMDataStore("OPER", - MoreExecutors.newDirectExecutorService()); - final InMemoryDOMDataStore configStore = new InMemoryDOMDataStore("CFG", - MoreExecutors.newDirectExecutorService()); - this.newDatastores = ImmutableMap.builder() - .put(LogicalDatastoreType.OPERATIONAL, operStore) - .put(LogicalDatastoreType.CONFIGURATION, configStore) - .build(); - - this.newDOMDataBroker = new SerializedDOMDataBroker(this.newDatastores, this.executor); - - this.mockSchemaService.registerSchemaContextListener(configStore); - this.mockSchemaService.registerSchemaContextListener(operStore); - } - - public void startBindingDataBroker() { - - } - - public void startBindingBroker() { - checkState(this.executor != null, "Executor needs to be set"); - checkState(this.baNotifyImpl != null, "Notification Service must be started"); - - this.baConsumerRpc = new BindingDOMRpcServiceAdapter(getDomRpcInvoker(), this.codec); - this.baProviderRpc = new BindingDOMRpcProviderServiceAdapter(getDomRpcRegistry(), this.codec); - - this.baBrokerImpl = new RootBindingAwareBroker("test"); - - final MountPointService mountService = new BindingDOMMountPointServiceAdapter(this.biMountImpl, this.codec); - this.baBrokerImpl.setMountService(mountService); - this.baBrokerImpl.setRpcBroker(new HeliumRpcProviderRegistry(this.baConsumerRpc, this.baProviderRpc)); - this.baBrokerImpl.setNotificationBroker(this.baNotifyImpl); - this.baBrokerImpl.start(); - } - - public void startForwarding() { - - } - - public void startBindingToDomMappingService() { - final BindingNormalizedNodeCodecRegistry codecRegistry = new BindingNormalizedNodeCodecRegistry(); - final GeneratedClassLoadingStrategy loading = GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy(); - this.codec = new BindingToNormalizedNodeCodec(loading, codecRegistry); - this.mockSchemaService.registerSchemaContextListener(this.codec); - } - - private void updateYangSchema(final Set moduleInfos) { - this.mockSchemaService.changeSchema(getContext(moduleInfos)); - } - - private static SchemaContext getContext(final Set moduleInfos) { - final ModuleInfoBackedContext ctx = ModuleInfoBackedContext.create(); - ctx.addModuleInfos(moduleInfos); - return ctx.tryToCreateSchemaContext().get(); - } - - public void start() { - startNewDomDataBroker(); - - startDomBroker(); - startDomMountPoint(); - startBindingToDomMappingService(); - startNewDataBroker(); - startBindingNotificationBroker(); - startBindingBroker(); - - startForwarding(); - - if (schemaModuleInfos != null) { - updateYangSchema(schemaModuleInfos); - } else if (this.startWithSchema) { - loadYangSchemaFromClasspath(); - } - } - - private void startDomMountPoint() { - this.biMountImpl = new DOMMountPointServiceImpl(); - } - - private void startDomBroker() { - checkState(this.executor != null); - - delegateDomRouter = org.opendaylight.mdsal.dom.broker.DOMRpcRouter.newInstance(mockSchemaService); - this.domRouter = new DOMRpcRouter(delegateDomRouter.getRpcService(), delegateDomRouter.getRpcProviderService()); - } - - public void startBindingNotificationBroker() { - checkState(this.executor != null); - final DOMNotificationRouter router = DOMNotificationRouter.create(16); - this.domPublishService = router; - this.domListenService = router; - this.publishService = new BindingDOMNotificationPublishServiceAdapter(this.codec, this.domPublishService); - this.listenService = new BindingDOMNotificationServiceAdapter(this.codec, this.domListenService); - this.baNotifyImpl = new HeliumNotificationProviderServiceAdapter(this.publishService,this.listenService); - - } - - public void loadYangSchemaFromClasspath() { - updateYangSchema(BindingReflections.loadModuleInfos()); - } - - public RpcProviderRegistry getBindingRpcRegistry() { - return this.baBrokerImpl.getRoot(); - } - - public DOMRpcProviderService getDomRpcRegistry() { - return this.domRouter; - } - - public DOMRpcService getDomRpcInvoker() { - return this.domRouter; - } - - public org.opendaylight.mdsal.dom.broker.DOMRpcRouter getDelegateDomRouter() { - return delegateDomRouter; - } - - @Override - public void close() { - - } - - public MountPointService getBindingMountPointService() { - return this.baBrokerImpl.getMountService(); - } - - public DOMMountPointService getDomMountProviderService() { - return this.biMountImpl; - } - - public DataBroker getDataBroker() { - return this.dataBroker; - } - - public void setSchemaModuleInfos(Set moduleInfos) { - this.schemaModuleInfos = moduleInfos; - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/util/MockSchemaService.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/util/MockSchemaService.java deleted file mode 100644 index 5ec8aa8034..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/util/MockSchemaService.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.binding.test.util; - -import com.google.common.collect.ClassToInstanceMap; -import com.google.common.collect.ImmutableClassToInstanceMap; -import org.opendaylight.mdsal.dom.api.DOMSchemaService; -import org.opendaylight.mdsal.dom.api.DOMSchemaServiceExtension; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.util.ListenerRegistry; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.opendaylight.yangtools.yang.model.api.SchemaContextListener; -import org.opendaylight.yangtools.yang.model.api.SchemaContextProvider; - -@Deprecated -public final class MockSchemaService implements DOMSchemaService, SchemaContextProvider { - - private SchemaContext schemaContext; - - ListenerRegistry listeners = ListenerRegistry.create(); - - @Override - public synchronized SchemaContext getGlobalContext() { - return schemaContext; - } - - @Override - public synchronized SchemaContext getSessionContext() { - return schemaContext; - } - - @Override - public ListenerRegistration registerSchemaContextListener( - final SchemaContextListener listener) { - return listeners.register(listener); - } - - @Override - public synchronized SchemaContext getSchemaContext() { - return schemaContext; - } - - @Override - public ClassToInstanceMap getExtensions() { - return ImmutableClassToInstanceMap.of(); - } - - public synchronized void changeSchema(final SchemaContext newContext) { - schemaContext = newContext; - for (ListenerRegistration listener : listeners.getRegistrations()) { - listener.getInstance().onGlobalContextUpdated(schemaContext); - } - } -} diff --git a/opendaylight/md-sal/sal-binding-dom-it/pom.xml b/opendaylight/md-sal/sal-binding-dom-it/pom.xml deleted file mode 100644 index 656e4afe81..0000000000 --- a/opendaylight/md-sal/sal-binding-dom-it/pom.xml +++ /dev/null @@ -1,122 +0,0 @@ - - - 4.0.0 - - org.opendaylight.odlparent - odlparent - 6.0.4 - - - - org.opendaylight.controller - sal-binding-dom-it - 1.12.0-SNAPSHOT - jar - - - - - org.opendaylight.yangtools - yangtools-artifacts - 4.0.6 - pom - import - - - org.opendaylight.mdsal - mdsal-artifacts - 5.0.9 - pom - import - - - org.opendaylight.controller - mdsal-artifacts - 1.12.0-SNAPSHOT - pom - import - - - - - - - junit - junit - - - org.opendaylight.mdsal - yang-binding - - - org.opendaylight.controller - sal-binding-broker-impl - test - - - org.opendaylight.controller - sal-binding-broker-impl - test-jar - test - - - org.ops4j.pax.exam - pax-exam-container-native - test - - - org.slf4j - slf4j-simple - test - - - org.opendaylight.yangtools - yang-test-util - - - org.opendaylight.controller - sal-test-model - - - org.opendaylight.mdsal.model - opendaylight-l2-types - - - - - - - org.jacoco - jacoco-maven-plugin - - - org.opendaylight.controller.* - - - - - pre-test - - prepare-agent - - - - post-test - - report - - test - - - - - - - - scm:git:http://git.opendaylight.org/gerrit/controller.git - scm:git:ssh://git.opendaylight.org:29418/controller.git - HEAD - https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL - - - diff --git a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/md/sal/binding/data/ConcurrentImplicitCreateTest.java b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/md/sal/binding/data/ConcurrentImplicitCreateTest.java deleted file mode 100644 index 1930e2b4c9..0000000000 --- a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/md/sal/binding/data/ConcurrentImplicitCreateTest.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.data; - -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; -import org.junit.Test; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.sal.binding.test.AbstractDataServiceTest; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListKey; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -// FIXME: THis test should be moved to sal-binding-broker and rewritten to use new DataBroker API -public class ConcurrentImplicitCreateTest extends AbstractDataServiceTest { - - private static final TopLevelListKey FOO_KEY = new TopLevelListKey("foo"); - private static final TopLevelListKey BAR_KEY = new TopLevelListKey("bar"); - private static final InstanceIdentifier TOP_PATH = InstanceIdentifier.builder(Top.class).build(); - private static final InstanceIdentifier FOO_PATH = TOP_PATH.child(TopLevelList.class, FOO_KEY); - private static final InstanceIdentifier BAR_PATH = TOP_PATH.child(TopLevelList.class, BAR_KEY); - - @Test - public void testConcurrentCreate() throws InterruptedException, ExecutionException, TimeoutException { - - DataBroker dataBroker = testContext.getDataBroker(); - WriteTransaction fooTx = dataBroker.newWriteOnlyTransaction(); - WriteTransaction barTx = dataBroker.newWriteOnlyTransaction(); - - fooTx.put(LogicalDatastoreType.OPERATIONAL, FOO_PATH, new TopLevelListBuilder().withKey(FOO_KEY).build()); - barTx.put(LogicalDatastoreType.OPERATIONAL, BAR_PATH, new TopLevelListBuilder().withKey(BAR_KEY).build()); - - fooTx.submit().get(5, TimeUnit.SECONDS); - barTx.submit().get(5, TimeUnit.SECONDS); - } -} diff --git a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/md/sal/binding/data/WildcardedDataChangeListenerTest.java b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/md/sal/binding/data/WildcardedDataChangeListenerTest.java deleted file mode 100644 index 13f36f1721..0000000000 --- a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/md/sal/binding/data/WildcardedDataChangeListenerTest.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.data; - -import static org.junit.Assert.assertFalse; -import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.OPERATIONAL; - -import com.google.common.collect.ImmutableSet; -import com.google.common.util.concurrent.Uninterruptibles; -import java.util.Collections; -import java.util.Set; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; -import org.junit.Test; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.binding.test.AbstractDataTreeChangeListenerTest; -import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.TreeComplexUsesAugment; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.TreeComplexUsesAugmentBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.complex.from.grouping.ContainerWithUses; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.complex.from.grouping.ContainerWithUsesBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.complex.from.grouping.ListViaUses; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.complex.from.grouping.ListViaUsesBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.complex.from.grouping.ListViaUsesKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListKey; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.binding.YangModuleInfo; - -// FIXME: This test should be moved to compat test-suite -public class WildcardedDataChangeListenerTest extends AbstractDataTreeChangeListenerTest { - - private static final TopLevelListKey TOP_LEVEL_LIST_0_KEY = new TopLevelListKey("test:0"); - private static final TopLevelListKey TOP_LEVEL_LIST_1_KEY = new TopLevelListKey("test:1"); - - protected static final InstanceIdentifier DEEP_WILDCARDED_PATH = InstanceIdentifier - .builder(Top.class) - .child(TopLevelList.class) - .augmentation(TreeComplexUsesAugment.class) - .child(ListViaUses.class) - .build(); - - private static final InstanceIdentifier NODE_0_TCU_PATH = InstanceIdentifier - .builder(Top.class) - .child(TopLevelList.class, TOP_LEVEL_LIST_0_KEY) - .augmentation(TreeComplexUsesAugment.class) - .build(); - - private static final InstanceIdentifier NODE_1_TCU_PATH = InstanceIdentifier - .builder(Top.class) - .child(TopLevelList.class, TOP_LEVEL_LIST_1_KEY) - .augmentation(TreeComplexUsesAugment.class) - .build(); - - - private static final ListViaUsesKey LIST_VIA_USES_KEY = new ListViaUsesKey("test"); - - private static final InstanceIdentifier NODE_0_LVU_PATH = NODE_0_TCU_PATH.child(ListViaUses.class, - LIST_VIA_USES_KEY); - - private static final InstanceIdentifier NODE_1_LVU_PATH = NODE_1_TCU_PATH.child(ListViaUses.class, - LIST_VIA_USES_KEY); - - private static final InstanceIdentifier NODE_0_CWU_PATH = - NODE_0_TCU_PATH.child(ContainerWithUses.class); - - private static final ContainerWithUses CWU = new ContainerWithUsesBuilder() - .setLeafFromGrouping("some container value").build(); - - private static final ListViaUses LVU = new ListViaUsesBuilder() - .withKey(LIST_VIA_USES_KEY).setName("john").build(); - - @Override - protected Set getModuleInfos() throws Exception { - return ImmutableSet.of(BindingReflections.getModuleInfo(Top.class), - BindingReflections.getModuleInfo(TreeComplexUsesAugment.class)); - } - - @Test - public void testSeparateWrites() throws InterruptedException, TimeoutException, ExecutionException { - - DataBroker dataBroker = getDataBroker(); - - final TestListener listener = createListener(OPERATIONAL, DEEP_WILDCARDED_PATH, - dataTreeModification -> NODE_0_LVU_PATH.equals(dataTreeModification.getRootPath().getRootIdentifier()), - dataTreeModification -> NODE_1_LVU_PATH.equals(dataTreeModification.getRootPath().getRootIdentifier())); - - final WriteTransaction transaction = dataBroker.newWriteOnlyTransaction(); - transaction.put(OPERATIONAL, NODE_0_CWU_PATH, CWU, true); - transaction.put(OPERATIONAL, NODE_0_LVU_PATH, LVU, true); - transaction.put(OPERATIONAL, NODE_1_LVU_PATH, LVU, true); - transaction.submit().get(5, TimeUnit.SECONDS); - - listener.verify(); - } - - @Test - public void testWriteByReplace() throws InterruptedException, TimeoutException, ExecutionException { - - DataBroker dataBroker = getDataBroker(); - - final TestListener listener = createListener(OPERATIONAL, DEEP_WILDCARDED_PATH, - dataTreeModification -> NODE_0_LVU_PATH.equals(dataTreeModification.getRootPath().getRootIdentifier()), - dataTreeModification -> NODE_1_LVU_PATH.equals(dataTreeModification.getRootPath().getRootIdentifier())); - - final WriteTransaction cwuTx = dataBroker.newWriteOnlyTransaction(); - cwuTx.put(OPERATIONAL, NODE_0_CWU_PATH, CWU, true); - cwuTx.submit().get(5, TimeUnit.SECONDS); - - Uninterruptibles.sleepUninterruptibly(500, TimeUnit.MILLISECONDS); - assertFalse(listener.hasChanges()); - - final WriteTransaction lvuTx = dataBroker.newWriteOnlyTransaction(); - - TreeComplexUsesAugment tcua = new TreeComplexUsesAugmentBuilder() - .setListViaUses(Collections.singletonList(LVU)).build(); - - lvuTx.put(OPERATIONAL, NODE_0_TCU_PATH, tcua, true); - lvuTx.put(OPERATIONAL, NODE_1_LVU_PATH, LVU, true); - lvuTx.submit().get(5, TimeUnit.SECONDS); - - listener.verify(); - } - - @Test - public void testChangeOnReplaceWithSameValue() throws InterruptedException, TimeoutException, ExecutionException { - - DataBroker dataBroker = getDataBroker(); - - // Write initial state NODE_0_FLOW - final WriteTransaction transaction = dataBroker.newWriteOnlyTransaction(); - transaction.put(OPERATIONAL, NODE_0_LVU_PATH, LVU, true); - transaction.submit().get(5, TimeUnit.SECONDS); - - final TestListener listener = createListener(OPERATIONAL, DEEP_WILDCARDED_PATH, - dataTreeModification -> NODE_1_LVU_PATH.equals(dataTreeModification.getRootPath().getRootIdentifier()), - dataTreeModification -> NODE_0_LVU_PATH.equals(dataTreeModification.getRootPath().getRootIdentifier()), - dataTreeModification -> NODE_1_LVU_PATH.equals(dataTreeModification.getRootPath().getRootIdentifier())); - - final WriteTransaction secondTx = dataBroker.newWriteOnlyTransaction(); - secondTx.put(OPERATIONAL, NODE_0_LVU_PATH, LVU, true); - secondTx.put(OPERATIONAL, NODE_1_LVU_PATH, LVU, true); - secondTx.submit().get(5, TimeUnit.SECONDS); - - listener.verify(); - } -} diff --git a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/DeleteNestedAugmentationListenParentTest.java b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/DeleteNestedAugmentationListenParentTest.java deleted file mode 100644 index 81d7e9dc61..0000000000 --- a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/DeleteNestedAugmentationListenParentTest.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.binding.test.bugfix; - -import com.google.common.collect.ImmutableSet; -import java.util.Set; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; -import org.junit.Test; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.binding.test.AbstractDataTreeChangeListenerTest; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.List11SimpleAugment; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.List11SimpleAugmentBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.TllComplexAugment; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.aug.grouping.List1; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.aug.grouping.List1Key; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.aug.grouping.list1.List11; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.aug.grouping.list1.List11Builder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.aug.grouping.list1.List11Key; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListKey; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.binding.YangModuleInfo; - -public class DeleteNestedAugmentationListenParentTest extends AbstractDataTreeChangeListenerTest { - - private static final TopLevelListKey FOO_KEY = new TopLevelListKey("foo"); - - private static final List1Key LIST1_KEY = new List1Key("one"); - - private static final List11Key LIST11_KEY = new List11Key(100); - - private static final InstanceIdentifier TLL_COMPLEX_AUGMENT_PATH = InstanceIdentifier - .builder(Top.class) - .child(TopLevelList.class,FOO_KEY) - .augmentation(TllComplexAugment.class) - .build(); - - private static final InstanceIdentifier LIST11_PATH = TLL_COMPLEX_AUGMENT_PATH.builder() - .child(List1.class,LIST1_KEY) - .child(List11.class,LIST11_KEY) - .build(); - - @Override - protected Set getModuleInfos() throws Exception { - return ImmutableSet.of(BindingReflections.getModuleInfo(Top.class), - BindingReflections.getModuleInfo(List11SimpleAugment.class)); - } - - @Test - public void deleteChildListenParent() throws InterruptedException, ExecutionException, TimeoutException { - DataBroker dataBroker = getDataBroker(); - final WriteTransaction initTx = dataBroker.newWriteOnlyTransaction(); - - List11 list11Before = createList11(); - initTx.put(LogicalDatastoreType.OPERATIONAL, LIST11_PATH, list11Before, true); - initTx.submit().get(5, TimeUnit.SECONDS); - - List11 list11After = new List11Builder().withKey(LIST11_KEY).setAttrStr("good").build(); - - final TestListener listener = createListener(LogicalDatastoreType.OPERATIONAL, LIST11_PATH, - added(LIST11_PATH, list11Before), subtreeModified(LIST11_PATH, list11Before, list11After)); - - final WriteTransaction deleteTx = dataBroker.newWriteOnlyTransaction(); - deleteTx.delete(LogicalDatastoreType.OPERATIONAL, LIST11_PATH.augmentation(List11SimpleAugment.class)); - deleteTx.submit().get(5, TimeUnit.SECONDS); - - listener.verify(); - } - - private static List11 createList11() { - List11Builder builder = new List11Builder() - .withKey(LIST11_KEY) - .addAugmentation(List11SimpleAugment.class,new List11SimpleAugmentBuilder() - .setAttrStr2("bad").build()) - .setAttrStr("good"); - return builder.build(); - } -} diff --git a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/WriteParentListenAugmentTest.java b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/WriteParentListenAugmentTest.java deleted file mode 100644 index 09836147f2..0000000000 --- a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/WriteParentListenAugmentTest.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.binding.test.bugfix; - -import static org.junit.Assert.assertEquals; -import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.OPERATIONAL; - -import com.google.common.collect.ImmutableSet; -import java.util.Set; -import java.util.concurrent.TimeUnit; -import org.junit.Test; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.binding.test.AbstractDataTreeChangeListenerTest; -import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.TreeComplexUsesAugment; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.TreeComplexUsesAugmentBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.complex.from.grouping.ContainerWithUsesBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListKey; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.binding.YangModuleInfo; - -public class WriteParentListenAugmentTest extends AbstractDataTreeChangeListenerTest { - - private static final String TLL_NAME = "foo"; - - private static final TopLevelListKey TLL_KEY = new TopLevelListKey(TLL_NAME); - private static final InstanceIdentifier TLL_INSTANCE_ID_BA = InstanceIdentifier.builder(Top.class) - .child(TopLevelList.class, TLL_KEY).build(); - - private static final InstanceIdentifier AUGMENT_WILDCARDED_PATH = InstanceIdentifier - .builder(Top.class).child(TopLevelList.class).augmentation(TreeComplexUsesAugment.class).build(); - - private static final InstanceIdentifier AUGMENT_TLL_PATH = InstanceIdentifier - .builder(Top.class).child(TopLevelList.class, TLL_KEY).augmentation(TreeComplexUsesAugment.class).build(); - - @Override - protected Set getModuleInfos() throws Exception { - return ImmutableSet.of(BindingReflections.getModuleInfo(Top.class), - BindingReflections.getModuleInfo(TreeComplexUsesAugment.class)); - } - - @Test - public void writeNodeListenAugment() throws Exception { - - DataBroker dataBroker = getDataBroker(); - - final TreeComplexUsesAugment treeComplexUsesAugment = treeComplexUsesAugment("one"); - - final TestListener listener = createListener(OPERATIONAL, AUGMENT_WILDCARDED_PATH, - added(AUGMENT_TLL_PATH, treeComplexUsesAugment)); - - final WriteTransaction transaction = dataBroker.newWriteOnlyTransaction(); - - TopLevelList tll = new TopLevelListBuilder().withKey(TLL_KEY) - .addAugmentation(TreeComplexUsesAugment.class, treeComplexUsesAugment).build(); - transaction.put(OPERATIONAL, TLL_INSTANCE_ID_BA, tll, true); - transaction.submit().get(5, TimeUnit.SECONDS); - - listener.verify(); - - final WriteTransaction transaction2 = dataBroker.newWriteOnlyTransaction(); - transaction2.put(OPERATIONAL, AUGMENT_TLL_PATH, treeComplexUsesAugment("two")); - transaction2.submit().get(5, TimeUnit.SECONDS); - - TreeComplexUsesAugment readedAug = dataBroker.newReadOnlyTransaction().read( - OPERATIONAL, AUGMENT_TLL_PATH).get(5, TimeUnit.SECONDS).get(); - assertEquals("two", readedAug.getContainerWithUses().getLeafFromGrouping()); - } - - private static TreeComplexUsesAugment treeComplexUsesAugment(final String value) { - return new TreeComplexUsesAugmentBuilder() - .setContainerWithUses(new ContainerWithUsesBuilder().setLeafFromGrouping(value).build()) - .build(); - } -} diff --git a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/WriteParentReadChildTest.java b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/WriteParentReadChildTest.java deleted file mode 100644 index ccedb89a2b..0000000000 --- a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/WriteParentReadChildTest.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.sal.binding.test.bugfix; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import com.google.common.base.Optional; -import com.google.common.collect.ImmutableList; -import java.util.concurrent.TimeUnit; -import org.junit.Test; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.sal.binding.test.AbstractDataServiceTest; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.TllComplexAugment; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.aug.grouping.List1; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.aug.grouping.List1Builder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.aug.grouping.List1Key; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.aug.grouping.list1.List11; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.aug.grouping.list1.List11Builder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.aug.grouping.list1.List11Key; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListKey; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -public class WriteParentReadChildTest extends AbstractDataServiceTest { - - private static final int LIST11_ID = 1234; - private static final String LIST1_NAME = "bar"; - private static final String TLL_NAME = "foo"; - - private static final TopLevelListKey TLL_KEY = new TopLevelListKey(TLL_NAME); - private static final List11Key LIST11_KEY = new List11Key(LIST11_ID); - private static final List1Key LIST1_KEY = new List1Key(LIST1_NAME); - - private static final InstanceIdentifier TLL_INSTANCE_ID_BA = InstanceIdentifier.builder(Top.class) - .child(TopLevelList.class, TLL_KEY).build(); - - private static final InstanceIdentifier LIST1_INSTANCE_ID_BA = - TLL_INSTANCE_ID_BA.builder() - .augmentation(TllComplexAugment.class).child(List1.class, LIST1_KEY).build(); - - private static final InstanceIdentifier LIST11_INSTANCE_ID_BA = - LIST1_INSTANCE_ID_BA.child(List11.class, LIST11_KEY); - - /** - * The scenario tests writing parent node, which also contains child items - * and then reading child directly, by specifying path to the child. - * Expected behaviour is child is returned. - */ - @Test - public void writeParentReadChild() throws Exception { - - DataBroker dataBroker = testContext.getDataBroker(); - final WriteTransaction transaction = dataBroker.newWriteOnlyTransaction(); - - List11 list11 = new List11Builder().withKey(LIST11_KEY).setAttrStr("primary").build(); - List1 list1 = new List1Builder().withKey(LIST1_KEY).setList11(ImmutableList.of(list11)).build(); - - transaction.put(LogicalDatastoreType.OPERATIONAL, LIST1_INSTANCE_ID_BA, list1, true); - transaction.submit().get(5, TimeUnit.SECONDS); - - Optional readList1 = dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.OPERATIONAL, - LIST1_INSTANCE_ID_BA).get(1000, TimeUnit.MILLISECONDS); - assertTrue(readList1.isPresent()); - - Optional readList11 = dataBroker.newReadOnlyTransaction().read( - LogicalDatastoreType.OPERATIONAL, LIST11_INSTANCE_ID_BA).get(5, TimeUnit.SECONDS); - assertNotNull("Readed flow should not be null.",readList11); - assertTrue(readList11.isPresent()); - assertEquals(list11, readList11.get()); - } -} diff --git a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/package-info.java b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/package-info.java deleted file mode 100644 index f328661477..0000000000 --- a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/package-info.java +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -/** - * This testsuite test Hydrogen-level API and regression for most of it. - */ -// FIXME: this testsuite needs to be refactored to use new DataBroker API, moved to sal-binding-broker-impl -// and uses models only from sal-test-model. -package org.opendaylight.controller.sal.binding.test.bugfix; \ No newline at end of file diff --git a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/BrokerIntegrationTest.java b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/BrokerIntegrationTest.java deleted file mode 100644 index 306cfcf779..0000000000 --- a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/BrokerIntegrationTest.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.binding.test.connect.dom; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import com.google.common.base.Optional; -import java.util.concurrent.TimeUnit; -import org.junit.Test; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.sal.binding.test.AbstractDataServiceTest; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListKey; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -public class BrokerIntegrationTest extends AbstractDataServiceTest { - - private static final TopLevelListKey TLL_FOO_KEY = new TopLevelListKey("foo"); - private static final TopLevelListKey TLL_BAR_KEY = new TopLevelListKey("bar"); - private static final TopLevelListKey TLL_BAZ_KEY = new TopLevelListKey("baz"); - private static final InstanceIdentifier TOP_PATH = InstanceIdentifier.builder(Top.class).build(); - private static final InstanceIdentifier FOO_PATH = TOP_PATH.child(TopLevelList.class, TLL_FOO_KEY); - private static final InstanceIdentifier BAR_PATH = TOP_PATH.child(TopLevelList.class, TLL_BAR_KEY); - private static final InstanceIdentifier BAZ_PATH = TOP_PATH.child(TopLevelList.class, TLL_BAZ_KEY); - - @Test - public void simpleModifyOperation() throws Exception { - - DataBroker dataBroker = testContext.getDataBroker(); - Optional tllFoo = dataBroker.newReadOnlyTransaction().read( - LogicalDatastoreType.CONFIGURATION, FOO_PATH).get(5, TimeUnit.SECONDS); - assertFalse(tllFoo.isPresent()); - - TopLevelList tllFooData = createTll(TLL_FOO_KEY); - - final WriteTransaction transaction = dataBroker.newWriteOnlyTransaction(); - transaction.put(LogicalDatastoreType.CONFIGURATION, FOO_PATH, tllFooData); - transaction.submit().get(5, TimeUnit.SECONDS); - - Optional readedData = dataBroker.newReadOnlyTransaction().read( - LogicalDatastoreType.CONFIGURATION, FOO_PATH).get(5, TimeUnit.SECONDS); - assertTrue(readedData.isPresent()); - assertEquals(tllFooData.key(), readedData.get().key()); - - TopLevelList nodeBarData = createTll(TLL_BAR_KEY); - TopLevelList nodeBazData = createTll(TLL_BAZ_KEY); - - final WriteTransaction insertMoreTr = dataBroker.newWriteOnlyTransaction(); - insertMoreTr.put(LogicalDatastoreType.CONFIGURATION, BAR_PATH, nodeBarData); - insertMoreTr.put(LogicalDatastoreType.CONFIGURATION, BAZ_PATH, nodeBazData); - insertMoreTr.submit().get(5, TimeUnit.SECONDS); - - Optional top = dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, TOP_PATH) - .get(5, TimeUnit.SECONDS); - assertTrue(top.isPresent()); - assertEquals(3, top.get().getTopLevelList().size()); - - // We create transaction no 2 - final WriteTransaction removalTransaction = dataBroker.newWriteOnlyTransaction(); - - // We remove node 1 - removalTransaction.delete(LogicalDatastoreType.CONFIGURATION, BAR_PATH); - - // We commit transaction - removalTransaction.submit().get(5, TimeUnit.SECONDS); - - Optional readedData2 = dataBroker.newReadOnlyTransaction().read( - LogicalDatastoreType.CONFIGURATION, BAR_PATH).get(5, TimeUnit.SECONDS); - assertFalse(readedData2.isPresent()); - } - - private static TopLevelList createTll(final TopLevelListKey key) { - return new TopLevelListBuilder().withKey(key).build(); - } -} diff --git a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/CrossBrokerMountPointTest.java b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/CrossBrokerMountPointTest.java deleted file mode 100644 index 7ad1b547f0..0000000000 --- a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/CrossBrokerMountPointTest.java +++ /dev/null @@ -1,227 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.binding.test.connect.dom; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import com.google.common.base.Optional; -import com.google.common.util.concurrent.CheckedFuture; -import com.google.common.util.concurrent.FluentFuture; -import com.google.common.util.concurrent.Futures; -import com.google.common.util.concurrent.MoreExecutors; -import java.util.Collections; -import java.util.Map; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; -import org.gaul.modernizer_maven_annotations.SuppressModernizer; -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.MountPoint; -import org.opendaylight.controller.md.sal.binding.api.MountPointService; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; -import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener; -import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; -import org.opendaylight.controller.md.sal.dom.api.DOMDataBrokerExtension; -import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction; -import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction; -import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction; -import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService; -import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain; -import org.opendaylight.controller.sal.binding.test.util.BindingBrokerTestFactory; -import org.opendaylight.controller.sal.binding.test.util.BindingTestContext; -import org.opendaylight.mdsal.common.api.CommitInfo; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.List11SimpleAugment; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.TllComplexAugment; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.aug.grouping.List1; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.aug.grouping.List1Key; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.aug.grouping.list1.List11; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.aug.grouping.list1.List11Key; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.top.top.level.list.list1.list1._1.Cont; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListKey; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.data.impl.schema.Builders; -import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; - -public class CrossBrokerMountPointTest { - - private static final QName TLL_NAME_QNAME = QName.create(TopLevelList.QNAME, "name"); - private static final String TLL_NAME = "foo:1"; - - private static final TopLevelListKey TLL_KEY = new TopLevelListKey(TLL_NAME); - - private static final Map TLL_KEY_BI = Collections.singletonMap(TLL_NAME_QNAME, - TLL_NAME); - - private static final InstanceIdentifier TLL_INSTANCE_ID_BA = InstanceIdentifier.builder(Top.class) // - .child(TopLevelList.class, TLL_KEY).build(); - - private static final List1Key LIST1_KEY = new List1Key("foo"); - private static final List11Key LIST11_KEY = new List11Key(1); - - private static final InstanceIdentifier AUG_CONT_ID_BA = TLL_INSTANCE_ID_BA - .builder().augmentation(TllComplexAugment.class) // - .child(List1.class, LIST1_KEY) // - .child(List11.class, LIST11_KEY) // - .augmentation(List11SimpleAugment.class) // - .child(Cont.class) // - .build(); - - private static final QName AUG_CONT = QName.create(List11.QNAME, - Cont.QNAME.getLocalName()); - - private static final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier TLL_INSTANCE_ID_BI = // - YangInstanceIdentifier.builder() // - .node(Top.QNAME) // - .node(TopLevelList.QNAME) // - .nodeWithKey(TopLevelList.QNAME, TLL_KEY_BI) // - .build(); - - private static final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier GROUP_STATISTICS_ID_BI = - YangInstanceIdentifier - .builder(TLL_INSTANCE_ID_BI) - .nodeWithKey(QName.create(TllComplexAugment.QNAME, "list1"), - QName.create(TllComplexAugment.QNAME, "attr-str"), LIST1_KEY.getAttrStr()) - .nodeWithKey(QName.create(TllComplexAugment.QNAME, "list1-1"), - QName.create(TllComplexAugment.QNAME, "attr-int"), LIST11_KEY.getAttrInt()) - .node(AUG_CONT).build(); - - private BindingTestContext testContext; - private MountPointService bindingMountPointService; - private DOMMountPointService domMountPointService; - - @Before - public void setup() { - final BindingBrokerTestFactory testFactory = new BindingBrokerTestFactory(); - testFactory.setExecutor(MoreExecutors.newDirectExecutorService()); - testFactory.setStartWithParsedSchema(true); - testContext = testFactory.getTestContext(); - - testContext.start(); - bindingMountPointService = testContext.getBindingMountPointService(); - domMountPointService = testContext.getDomMountProviderService(); - - // biRpcInvoker = testContext.getDomRpcInvoker(); - assertNotNull(bindingMountPointService); - assertNotNull(domMountPointService); - - // flowService = MessageCapturingFlowService.create(baRpcRegistry); - } - - @Test - public void testMountPoint() throws ReadFailedException, TimeoutException { - final Integer attrIntValue = 500; - domMountPointService.createMountPoint(TLL_INSTANCE_ID_BI) - .addService(DOMDataBroker.class, new DOMDataBroker() { - - @Override - public DOMDataWriteTransaction newWriteOnlyTransaction() { - throw new UnsupportedOperationException(); - } - - @Override - public DOMDataReadWriteTransaction newReadWriteTransaction() { - return new DOMDataReadWriteTransaction() { - - @Override - @SuppressModernizer - public CheckedFuture>, ReadFailedException> read( - final LogicalDatastoreType store, final YangInstanceIdentifier path) { - if (store == LogicalDatastoreType.OPERATIONAL && path.getLastPathArgument() - .equals(GROUP_STATISTICS_ID_BI.getLastPathArgument())) { - - final ContainerNode data = Builders.containerBuilder() - .withNodeIdentifier(new NodeIdentifier(AUG_CONT)) - .withChild(ImmutableNodes.leafNode(QName.create(AUG_CONT, "attr-int"), - attrIntValue)) - .build(); - - return Futures.immediateCheckedFuture(Optional.>of(data)); - } - return Futures.immediateFailedCheckedFuture(new ReadFailedException(TLL_NAME, - new Exception())); - } - - @Override - public CheckedFuture exists(final LogicalDatastoreType store, - final YangInstanceIdentifier path) { - throw new UnsupportedOperationException(); - } - - @Override - public Object getIdentifier() { - return this; - } - - @Override - public boolean cancel() { - return false; - } - - @Override - public void delete(final LogicalDatastoreType store, final YangInstanceIdentifier path) { - throw new UnsupportedOperationException(); - } - - @Override - public void merge(final LogicalDatastoreType store, final YangInstanceIdentifier path, - final NormalizedNode data) { - throw new UnsupportedOperationException(); - } - - @Override - public void put(final LogicalDatastoreType store, final YangInstanceIdentifier path, - final NormalizedNode data) { - throw new UnsupportedOperationException(); - } - - @Override - public FluentFuture commit() { - throw new UnsupportedOperationException(); - } - }; - } - - @Override - public DOMDataReadOnlyTransaction newReadOnlyTransaction() { - throw new UnsupportedOperationException(); - } - - @Override - public DOMTransactionChain createTransactionChain(final TransactionChainListener listener) { - throw new UnsupportedOperationException(); - } - - @Override - public Map, DOMDataBrokerExtension> getSupportedExtensions() { - return Collections.emptyMap(); - } - }).register(); - - final Optional bindingMountPoint = bindingMountPointService.getMountPoint(TLL_INSTANCE_ID_BA); - assertTrue(bindingMountPoint.isPresent()); - - final Optional dataBroker = bindingMountPoint.get().getService(DataBroker.class); - assertTrue(dataBroker.isPresent()); - - final Optional data = dataBroker.get().newReadWriteTransaction().read(LogicalDatastoreType.OPERATIONAL, - AUG_CONT_ID_BA).checkedGet(5, TimeUnit.SECONDS); - assertTrue(data.isPresent()); - assertEquals(attrIntValue ,data.get().getAttrInt()); - } -} diff --git a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/CrossBrokerRpcTest.java b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/CrossBrokerRpcTest.java deleted file mode 100644 index eb5cf21260..0000000000 --- a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/CrossBrokerRpcTest.java +++ /dev/null @@ -1,223 +0,0 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.binding.test.connect.dom; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNotSame; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; - -import com.google.common.collect.HashMultimap; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Multimap; -import com.google.common.util.concurrent.Futures; -import com.google.common.util.concurrent.ListenableFuture; -import com.google.common.util.concurrent.MoreExecutors; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.Future; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcProviderService; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcService; -import org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult; -import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; -import org.opendaylight.controller.sal.binding.test.util.BindingBrokerTestFactory; -import org.opendaylight.controller.sal.binding.test.util.BindingTestContext; -import org.opendaylight.mdsal.binding.dom.adapter.BindingDOMRpcProviderServiceAdapter; -import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.KnockKnockInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.KnockKnockInputBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.KnockKnockOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.KnockKnockOutputBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.OpendaylightOfMigrationTestModelService; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.rpc.routing.rev140701.TestContext; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.common.RpcResult; -import org.opendaylight.yangtools.yang.common.RpcResultBuilder; -import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; - -public class CrossBrokerRpcTest { - - protected RpcProviderRegistry providerRegistry; - protected DOMRpcProviderService provisionRegistry; - private BindingTestContext testContext; - private DOMRpcService biRpcInvoker; - private MessageCapturingFlowService knockService; - - public static final TopLevelListKey NODE_A = new TopLevelListKey("a"); - public static final TopLevelListKey NODE_B = new TopLevelListKey("b"); - public static final TopLevelListKey NODE_C = new TopLevelListKey("c"); - - private static final QName NODE_ID_QNAME = QName.create(TopLevelList.QNAME, "name"); - private static final QName KNOCK_KNOCK_QNAME = QName.create(KnockKnockOutput.QNAME, "knock-knock"); - private static final SchemaPath KNOCK_KNOCK_PATH = SchemaPath.create(true, KNOCK_KNOCK_QNAME); - - public static final InstanceIdentifier NODES_PATH = InstanceIdentifier.builder(Top.class).build(); - public static final InstanceIdentifier BA_NODE_A_ID = NODES_PATH.child(TopLevelList.class, NODE_A); - public static final InstanceIdentifier BA_NODE_B_ID = NODES_PATH.child(TopLevelList.class, NODE_B); - public static final InstanceIdentifier BA_NODE_C_ID = NODES_PATH.child(TopLevelList.class, NODE_C); - - public static final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier BI_NODE_C_ID = - createBINodeIdentifier(NODE_C); - - - @Before - public void setup() throws Exception { - BindingBrokerTestFactory testFactory = new BindingBrokerTestFactory(); - testFactory.setExecutor(MoreExecutors.newDirectExecutorService()); - testContext = testFactory.getTestContext(); - - testContext.setSchemaModuleInfos(ImmutableSet.of( - BindingReflections.getModuleInfo(OpendaylightOfMigrationTestModelService.class))); - testContext.start(); - providerRegistry = testContext.getBindingRpcRegistry(); - provisionRegistry = testContext.getDomRpcRegistry(); - biRpcInvoker = testContext.getDomRpcInvoker(); - assertNotNull(providerRegistry); - assertNotNull(provisionRegistry); - - knockService = MessageCapturingFlowService.create(providerRegistry); - - } - - @After - public void teardown() { - testContext.close(); - } - - @Test - public void testBindingRpcShortcutRegisteredViaLegacyAPI() - throws InterruptedException, ExecutionException, TimeoutException { - final ListenableFuture> knockResult = knockResult(true, "open"); - knockService.registerPath(TestContext.class, BA_NODE_A_ID).setKnockKnockResult(knockResult); - - OpendaylightOfMigrationTestModelService baKnockInvoker = - providerRegistry.getRpcService(OpendaylightOfMigrationTestModelService.class); - - final KnockKnockInput knockInput = knockKnock(BA_NODE_A_ID).setQuestion("Who's there?").build(); - ListenableFuture> future = baKnockInvoker.knockKnock(knockInput); - - final RpcResult rpcResult = future.get(5, TimeUnit.SECONDS); - - assertEquals(knockResult.get().getResult().getClass(), rpcResult.getResult().getClass()); - assertSame(knockResult.get().getResult(), rpcResult.getResult()); - assertSame(knockInput, knockService.getReceivedKnocks().get(BA_NODE_A_ID).iterator().next()); - } - - @Test - public void testBindingRpcShortcutRegisteredViaMdsalAPI() - throws InterruptedException, ExecutionException, TimeoutException { - final ListenableFuture> knockResult = knockResult(true, "open"); - - BindingDOMRpcProviderServiceAdapter mdsalServiceRegistry = new BindingDOMRpcProviderServiceAdapter( - testContext.getDelegateDomRouter().getRpcProviderService(), testContext.getCodec()); - - final Multimap, KnockKnockInput> receivedKnocks = HashMultimap.create(); - mdsalServiceRegistry.registerRpcImplementation(OpendaylightOfMigrationTestModelService.class, - (OpendaylightOfMigrationTestModelService) input -> { - receivedKnocks.put(input.getKnockerId(), input); - return knockResult; - }, ImmutableSet.of(BA_NODE_A_ID)); - - OpendaylightOfMigrationTestModelService baKnockInvoker = - providerRegistry.getRpcService(OpendaylightOfMigrationTestModelService.class); - - final KnockKnockInput knockInput = knockKnock(BA_NODE_A_ID).setQuestion("Who's there?").build(); - Future> future = baKnockInvoker.knockKnock(knockInput); - - final RpcResult rpcResult = future.get(5, TimeUnit.SECONDS); - - assertEquals(knockResult.get().getResult().getClass(), rpcResult.getResult().getClass()); - assertSame(knockResult.get().getResult(), rpcResult.getResult()); - assertSame(knockInput, receivedKnocks.get(BA_NODE_A_ID).iterator().next()); - } - - @Test - public void bindingRoutedRpcProvider_DomInvokerTest() throws Exception { - - knockService// - .registerPath(TestContext.class, BA_NODE_A_ID) // - .registerPath(TestContext.class, BA_NODE_B_ID) // - .setKnockKnockResult(knockResult(true, "open")); - - OpendaylightOfMigrationTestModelService baKnockInvoker = - providerRegistry.getRpcService(OpendaylightOfMigrationTestModelService.class); - assertNotSame(knockService, baKnockInvoker); - - KnockKnockInput knockKnockA = knockKnock(BA_NODE_A_ID) // - .setQuestion("who's there?").build(); - - ContainerNode knockKnockDom = toDomRpc(KNOCK_KNOCK_QNAME, knockKnockA); - assertNotNull(knockKnockDom); - DOMRpcResult domResult = biRpcInvoker.invokeRpc(KNOCK_KNOCK_PATH, knockKnockDom).get(); - assertNotNull(domResult); - assertNotNull("DOM result is successful.", domResult.getResult()); - assertTrue("Bidning Add Flow RPC was captured.", knockService.getReceivedKnocks().containsKey(BA_NODE_A_ID)); - assertEquals(knockKnockA, knockService.getReceivedKnocks().get(BA_NODE_A_ID).iterator().next()); - } - - @Test - public void bindingRpcInvoker_DomRoutedProviderTest() throws Exception { - KnockKnockOutputBuilder builder = new KnockKnockOutputBuilder(); - builder.setAnswer("open"); - final KnockKnockOutput output = builder.build(); - - provisionRegistry.registerRpcImplementation((rpc, input) -> { - ContainerNode result = testContext.getCodec().getCodecFactory().toNormalizedNodeRpcData(output); - return Futures.immediateCheckedFuture(new DefaultDOMRpcResult(result)); - }, DOMRpcIdentifier.create(KNOCK_KNOCK_PATH, BI_NODE_C_ID)); - - OpendaylightOfMigrationTestModelService baKnockInvoker = - providerRegistry.getRpcService(OpendaylightOfMigrationTestModelService.class); - Future> baResult = baKnockInvoker.knockKnock(knockKnock(BA_NODE_C_ID) - .setQuestion("Who's there?").build()); - assertNotNull(baResult); - assertEquals(output, baResult.get().getResult()); - } - - private ContainerNode toDomRpcInput(final DataObject addFlowA) { - return testContext.getCodec().getCodecFactory().toNormalizedNodeRpcData(addFlowA); - } - - private static org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier createBINodeIdentifier( - final TopLevelListKey listKey) { - return org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.builder().node(Top.QNAME) - .node(TopLevelList.QNAME) - .nodeWithKey(TopLevelList.QNAME, NODE_ID_QNAME, listKey.getName()).build(); - } - - private static ListenableFuture> knockResult(final boolean success, - final String answer) { - KnockKnockOutput output = new KnockKnockOutputBuilder().setAnswer(answer).build(); - RpcResult result = RpcResultBuilder.status(success).withResult(output) - .build(); - return Futures.immediateFuture(result); - } - - private static KnockKnockInputBuilder knockKnock(final InstanceIdentifier listId) { - KnockKnockInputBuilder builder = new KnockKnockInputBuilder(); - builder.setKnockerId(listId); - return builder; - } - - private ContainerNode toDomRpc(final QName rpcName, final KnockKnockInput knockInput) { - return toDomRpcInput(knockInput); - } -} diff --git a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/DOMRpcServiceTestBugfix560.java b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/DOMRpcServiceTestBugfix560.java deleted file mode 100644 index cce41da2d7..0000000000 --- a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/DOMRpcServiceTestBugfix560.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.binding.test.connect.dom; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import com.google.common.base.Optional; -import com.google.common.util.concurrent.CheckedFuture; -import com.google.common.util.concurrent.Futures; -import com.google.common.util.concurrent.ListenableFuture; -import com.google.common.util.concurrent.MoreExecutors; -import java.util.concurrent.ExecutionException; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.controller.md.sal.binding.api.MountPoint; -import org.opendaylight.controller.md.sal.binding.api.MountPointService; -import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcAvailabilityListener; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcException; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcService; -import org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult; -import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry; -import org.opendaylight.controller.sal.binding.test.util.BindingBrokerTestFactory; -import org.opendaylight.controller.sal.binding.test.util.BindingTestContext; -import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.bi.ba.rpcservice.rev140701.OpendaylightTestRpcServiceService; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.bi.ba.rpcservice.rev140701.RockTheHouseInputBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.bi.ba.rpcservice.rev140701.RockTheHouseOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListKey; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.binding.YangModuleInfo; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.common.RpcResult; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; -import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier; -import org.opendaylight.yangtools.yang.model.repo.api.StatementParserMode; -import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource; -import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; - -/** - * Test case for reported bug 560. - * - * @author Lukas Sedlak - * @see https://bugs.opendaylight.org/show_bug.cgi?id=560 - */ -public class DOMRpcServiceTestBugfix560 { - - private static final String RPC_SERVICE_NAMESPACE = - "urn:opendaylight:params:xml:ns:yang:controller:md:sal:test:bi:ba:rpcservice"; - private static final String REVISION_DATE = "2014-07-01"; - private static final QName RPC_NAME = QName.create(RPC_SERVICE_NAMESPACE, REVISION_DATE, "rock-the-house"); - - private static final String TLL_NAME = "id"; - private static final QName TLL_NAME_QNAME = QName.create(TopLevelList.QNAME, "name"); - - private static final InstanceIdentifier BA_MOUNT_ID = createBATllIdentifier(TLL_NAME); - private static final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier BI_MOUNT_ID = - createBITllIdentifier(TLL_NAME); - - private BindingTestContext testContext; - private DOMMountPointService domMountPointService; - private MountPointService bindingMountPointService; - private SchemaContext schemaContext; - - @Before - public void setUp() throws Exception { - final BindingBrokerTestFactory testFactory = new BindingBrokerTestFactory(); - testFactory.setExecutor(MoreExecutors.newDirectExecutorService()); - testFactory.setStartWithParsedSchema(true); - testContext = testFactory.getTestContext(); - - testContext.start(); - domMountPointService = testContext.getDomMountProviderService(); - bindingMountPointService = testContext.getBindingMountPointService(); - assertNotNull(domMountPointService); - - final YangModuleInfo moduleInfo = BindingReflections.getModuleInfo(OpendaylightTestRpcServiceService.class); - assertNotNull(moduleInfo); - - schemaContext = YangParserTestUtils.parseYangSources(StatementParserMode.DEFAULT_MODE, null, - YangTextSchemaSource.delegateForByteSource(RevisionSourceIdentifier.create( - moduleInfo.getName().getLocalName(), moduleInfo.getName().getRevision()), - moduleInfo.getYangTextByteSource())); - } - - private static org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier createBITllIdentifier( - final String mount) { - return org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier - .builder().node(Top.QNAME) - .node(TopLevelList.QNAME) - .nodeWithKey(TopLevelList.QNAME, TLL_NAME_QNAME, mount) - .build(); - } - - private static InstanceIdentifier createBATllIdentifier( - final String mount) { - return InstanceIdentifier.builder(Top.class) - .child(TopLevelList.class, new TopLevelListKey(mount)).build(); - } - - @Test - public void test() throws ExecutionException, InterruptedException { - // FIXME: This is made to only make sure instance identifier codec for path is instantiated. - domMountPointService.createMountPoint(BI_MOUNT_ID).addService(DOMRpcService.class, new DOMRpcService() { - @Override - public ListenerRegistration registerRpcListener(final T arg0) { - // TODO Auto-generated method stub - return null; - } - - @Override - public CheckedFuture invokeRpc(final SchemaPath arg0, - final NormalizedNode arg1) { - return Futures.immediateCheckedFuture(new DefaultDOMRpcResult((NormalizedNode) null)); - } - }).register(); - - final Optional mountInstance = bindingMountPointService.getMountPoint(BA_MOUNT_ID); - assertTrue(mountInstance.isPresent()); - - final Optional rpcRegistry = mountInstance.get().getService(RpcConsumerRegistry.class); - assertTrue(rpcRegistry.isPresent()); - final OpendaylightTestRpcServiceService rpcService = rpcRegistry.get() - .getRpcService(OpendaylightTestRpcServiceService.class); - assertNotNull(rpcService); - - try { - final ListenableFuture> result = rpcService - .rockTheHouse(new RockTheHouseInputBuilder().build()); - assertTrue(result.get().isSuccessful()); - } catch (final IllegalStateException ex) { - fail("OpendaylightTestRpcServiceService class doesn't contain rockTheHouse method!"); - } - } - - @After - public void teardown() { - testContext.close(); - } -} diff --git a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/MessageCapturingFlowService.java b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/MessageCapturingFlowService.java deleted file mode 100644 index bc521d1254..0000000000 --- a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/MessageCapturingFlowService.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.binding.test.connect.dom; - -import static org.junit.Assert.assertNotNull; - -import com.google.common.collect.HashMultimap; -import com.google.common.collect.Multimap; -import com.google.common.util.concurrent.ListenableFuture; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration; -import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.KnockKnockInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.KnockKnockOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.OpendaylightOfMigrationTestModelService; -import org.opendaylight.yangtools.yang.binding.BaseIdentity; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.common.RpcResult; - -public class MessageCapturingFlowService implements OpendaylightOfMigrationTestModelService, AutoCloseable { - - private ListenableFuture> knockKnockResult; - - private final Multimap, KnockKnockInput> receivedKnocks = HashMultimap.create(); - private RoutedRpcRegistration registration; - - public ListenableFuture> getKnockKnockResult() { - return knockKnockResult; - } - - public MessageCapturingFlowService setKnockKnockResult( - final ListenableFuture> kkOutput) { - this.knockKnockResult = kkOutput; - return this; - } - - public Multimap, KnockKnockInput> getReceivedKnocks() { - return receivedKnocks; - } - - public MessageCapturingFlowService registerTo(final RpcProviderRegistry registry) { - registration = registry.addRoutedRpcImplementation(OpendaylightOfMigrationTestModelService.class, this); - assertNotNull(registration); - return this; - } - - @Override - public void close() { - registration.close(); - } - - public MessageCapturingFlowService registerPath(final Class context, - final InstanceIdentifier path) { - registration.registerPath(context, path); - return this; - } - - public MessageCapturingFlowService unregisterPath(final Class context, - final InstanceIdentifier path) { - registration.unregisterPath(context, path); - return this; - } - - public static MessageCapturingFlowService create() { - return new MessageCapturingFlowService(); - } - - public static MessageCapturingFlowService create(final RpcProviderRegistry registry) { - MessageCapturingFlowService ret = new MessageCapturingFlowService(); - ret.registerTo(registry); - return ret; - } - - @Override - public ListenableFuture> knockKnock(final KnockKnockInput input) { - receivedKnocks.put(input.getKnockerId(), input); - return knockKnockResult; - } -} diff --git a/opendaylight/md-sal/sal-binding-it/src/test/java/org/opendaylight/controller/test/sal/binding/it/AbstractTestProvider.java b/opendaylight/md-sal/sal-binding-it/src/test/java/org/opendaylight/controller/test/sal/binding/it/AbstractTestProvider.java deleted file mode 100644 index 6871a0af61..0000000000 --- a/opendaylight/md-sal/sal-binding-it/src/test/java/org/opendaylight/controller/test/sal/binding/it/AbstractTestProvider.java +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.test.sal.binding.it; - -import org.opendaylight.controller.sal.binding.api.BindingAwareProvider; - -public abstract class AbstractTestProvider implements BindingAwareProvider { - - -} diff --git a/opendaylight/md-sal/sal-binding-it/src/test/java/org/opendaylight/controller/test/sal/binding/it/DataServiceIT.java b/opendaylight/md-sal/sal-binding-it/src/test/java/org/opendaylight/controller/test/sal/binding/it/DataServiceIT.java index 53d88aee68..833c710e32 100644 --- a/opendaylight/md-sal/sal-binding-it/src/test/java/org/opendaylight/controller/test/sal/binding/it/DataServiceIT.java +++ b/opendaylight/md-sal/sal-binding-it/src/test/java/org/opendaylight/controller/test/sal/binding/it/DataServiceIT.java @@ -12,13 +12,13 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -import com.google.common.base.Optional; +import java.util.Optional; import java.util.concurrent.TimeUnit; import javax.inject.Inject; import org.junit.Test; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.WriteTransaction; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.Lists; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.lists.UnorderedContainer; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.lists.unordered.container.UnorderedList; @@ -51,7 +51,7 @@ public class DataServiceIT extends AbstractIT { UnorderedList nodeData1 = createNode("0"); transaction.put(LogicalDatastoreType.OPERATIONAL, node1, nodeData1); - transaction.submit().get(5, TimeUnit.SECONDS); + transaction.commit().get(5, TimeUnit.SECONDS); Optional readedData = dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.OPERATIONAL, node1).get(5, TimeUnit.SECONDS); @@ -63,7 +63,7 @@ public class DataServiceIT extends AbstractIT { transaction2.delete(LogicalDatastoreType.OPERATIONAL, node1); - transaction2.submit().get(5, TimeUnit.SECONDS); + transaction2.commit().get(5, TimeUnit.SECONDS); Optional readedData2 = dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.OPERATIONAL, node1).get(5, TimeUnit.SECONDS); diff --git a/opendaylight/md-sal/sal-binding-it/src/test/java/org/opendaylight/controller/test/sal/binding/it/NotificationIT.java b/opendaylight/md-sal/sal-binding-it/src/test/java/org/opendaylight/controller/test/sal/binding/it/NotificationIT.java index 703897f814..c1d94e65be 100644 --- a/opendaylight/md-sal/sal-binding-it/src/test/java/org/opendaylight/controller/test/sal/binding/it/NotificationIT.java +++ b/opendaylight/md-sal/sal-binding-it/src/test/java/org/opendaylight/controller/test/sal/binding/it/NotificationIT.java @@ -13,7 +13,8 @@ import java.util.ArrayList; import java.util.List; import javax.inject.Inject; import org.junit.Test; -import org.opendaylight.controller.sal.binding.api.NotificationProviderService; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; +import org.opendaylight.mdsal.binding.api.NotificationService; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.bi.ba.notification.rev150205.OpendaylightTestNotificationListener; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.bi.ba.notification.rev150205.OutOfPixieDustNotification; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.bi.ba.notification.rev150205.OutOfPixieDustNotificationBuilder; @@ -32,7 +33,11 @@ public class NotificationIT extends AbstractIT { @Inject @Filter(timeout = 120 * 1000) - NotificationProviderService notificationService; + NotificationService notificationService; + + @Inject + @Filter(timeout = 120 * 1000) + NotificationPublishService notificationPublishService; /** * Test of delivering of notification. @@ -46,7 +51,7 @@ public class NotificationIT extends AbstractIT { LOG.info("The notification of type FlowAdded with cookie ID 0 is created. The " + "delay 100ms to make sure that the notification was delivered to " + "listener."); - notificationService.publish(noDustNotification("rainy day", 42)); + notificationPublishService.putNotification(noDustNotification("rainy day", 42)); Thread.sleep(100); /** @@ -64,9 +69,9 @@ public class NotificationIT extends AbstractIT { notificationService.registerNotificationListener(listener2); LOG.info("3 notifications are published"); - notificationService.publish(noDustNotification("rainy day", 5)); - notificationService.publish(noDustNotification("rainy day", 10)); - notificationService.publish(noDustNotification("tax collector", 2)); + notificationPublishService.putNotification(noDustNotification("rainy day", 5)); + notificationPublishService.putNotification(noDustNotification("rainy day", 10)); + notificationPublishService.putNotification(noDustNotification("tax collector", 2)); /** * The delay 100ms to make sure that the notifications were delivered to @@ -88,7 +93,7 @@ public class NotificationIT extends AbstractIT { listener2Reg.close(); LOG.info("The notification 5 is published"); - notificationService.publish(noDustNotification("entomologist hunt", 10)); + notificationPublishService.putNotification(noDustNotification("entomologist hunt", 10)); /** * The delay 100ms to make sure that the notification was delivered to @@ -118,9 +123,8 @@ public class NotificationIT extends AbstractIT { } /** - * Implements - * {@link OpendaylightTestNotificationListener} and contains attributes which keep lists of objects of - * the type {@link OutOfFairyDustNotification}. + * Implements {@link OpendaylightTestNotificationListener} and contains attributes which keep lists of objects of + * the type {@link OutOfPixieDustNotification}. */ public static class NotificationTestListener implements OpendaylightTestNotificationListener { List notificationBag = new ArrayList<>(); diff --git a/opendaylight/md-sal/sal-binding-it/src/test/java/org/opendaylight/controller/test/sal/binding/it/RoutedServiceIT.java b/opendaylight/md-sal/sal-binding-it/src/test/java/org/opendaylight/controller/test/sal/binding/it/RoutedServiceIT.java index 91e53d0cc8..523071415d 100644 --- a/opendaylight/md-sal/sal-binding-it/src/test/java/org/opendaylight/controller/test/sal/binding/it/RoutedServiceIT.java +++ b/opendaylight/md-sal/sal-binding-it/src/test/java/org/opendaylight/controller/test/sal/binding/it/RoutedServiceIT.java @@ -15,21 +15,22 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import com.google.common.util.concurrent.Futures; +import java.util.Set; import javax.inject.Inject; import org.junit.Before; import org.junit.Test; import org.mockito.Mockito; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration; -import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; +import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry; +import org.opendaylight.mdsal.binding.api.RpcProviderService; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.rpc.routing.rev140701.OpendaylightTestRoutedRpcService; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.rpc.routing.rev140701.RoutedSimpleRouteInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.rpc.routing.rev140701.RoutedSimpleRouteInputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.rpc.routing.rev140701.RoutedSimpleRouteOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.rpc.routing.rev140701.TestContext; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.Lists; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.lists.UnorderedContainer; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.lists.unordered.container.UnorderedList; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.lists.unordered.container.UnorderedListKey; +import org.opendaylight.yangtools.concepts.ObjectRegistration; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcResult; import org.ops4j.pax.exam.util.Filter; @@ -49,7 +50,11 @@ public class RoutedServiceIT extends AbstractIT { @Inject @Filter(timeout = 120 * 1000) - RpcProviderRegistry rpcProviderRegistry; + RpcProviderService rpcProviderService; + + @Inject + @Filter(timeout = 120 * 1000) + RpcConsumerRegistry rpcConsumerRegistry; /** * Prepare mocks. @@ -66,32 +71,29 @@ public class RoutedServiceIT extends AbstractIT { @Test public void testServiceRegistration() { - LOG.info("Register provider 1 with first implementation of routeSimpleService - service1"); + LOG.info("Register provider 1 with first implementation of routeSimpleService - service1 of node 1"); + final InstanceIdentifier nodeOnePath = createNodeRef("foo:node:1"); + final InstanceIdentifier nodeTwo = createNodeRef("foo:node:2"); - RoutedRpcRegistration firstReg = rpcProviderRegistry - .addRoutedRpcImplementation(OpendaylightTestRoutedRpcService.class, odlRoutedService1); + ObjectRegistration firstReg = rpcProviderService.registerRpcImplementation( + OpendaylightTestRoutedRpcService.class, odlRoutedService1, Set.of(nodeOnePath)); assertNotNull("Registration should not be null", firstReg); assertSame(odlRoutedService1, firstReg.getInstance()); - LOG.info("Register provider 2 with second implementation of routeSimpleService - service2"); + LOG.info("Register provider 2 with second implementation of routeSimpleService - service2 of node 2"); - RoutedRpcRegistration secondReg = rpcProviderRegistry - .addRoutedRpcImplementation(OpendaylightTestRoutedRpcService.class, odlRoutedService2); + ObjectRegistration secondReg = rpcProviderService.registerRpcImplementation( + OpendaylightTestRoutedRpcService.class, odlRoutedService2, Set.of(nodeTwo)); assertNotNull("Registration should not be null", firstReg); assertSame(odlRoutedService2, secondReg.getInstance()); assertNotSame(secondReg, firstReg); OpendaylightTestRoutedRpcService consumerService = - rpcProviderRegistry.getRpcService(OpendaylightTestRoutedRpcService.class); + rpcConsumerRegistry.getRpcService(OpendaylightTestRoutedRpcService.class); assertNotNull("MD-SAL instance of test Service should be returned", consumerService); assertNotSame("Provider instance and consumer instance should not be same.", odlRoutedService1, consumerService); - final InstanceIdentifier nodeOnePath = createNodeRef("foo:node:1"); - - LOG.info("Provider 1 registers path of node 1"); - firstReg.registerPath(TestContext.class, nodeOnePath); - /** * Consumer creates addFlow message for node one and sends it to the MD-SAL. */ @@ -107,10 +109,6 @@ public class RoutedServiceIT extends AbstractIT { */ verify(odlRoutedService2, times(0)).routedSimpleRoute(simpleRouteFirstFoo); - LOG.info("Provider 2 registers path of node 2"); - final InstanceIdentifier nodeTwo = createNodeRef("foo:node:2"); - secondReg.registerPath(TestContext.class, nodeTwo); - /** * Consumer sends message to nodeTwo for three times. Should be processed by second instance. */ @@ -126,10 +124,12 @@ public class RoutedServiceIT extends AbstractIT { verify(odlRoutedService1, times(0)).routedSimpleRoute(simpleRouteSecondFoo); LOG.info("Unregistration of the path for the node one in the first provider"); - firstReg.unregisterPath(TestContext.class, nodeOnePath); + firstReg.close(); LOG.info("Provider 2 registers path of node 1"); - secondReg.registerPath(TestContext.class, nodeOnePath); + secondReg.close(); + secondReg = rpcProviderService.registerRpcImplementation( + OpendaylightTestRoutedRpcService.class, odlRoutedService2, Set.of(nodeOnePath)); /** * A consumer sends third message to node 1. @@ -165,8 +165,6 @@ public class RoutedServiceIT extends AbstractIT { * @return simpleRouteInput instance */ static RoutedSimpleRouteInput createSimpleRouteInput(final InstanceIdentifier node) { - final RoutedSimpleRouteInputBuilder ret = new RoutedSimpleRouteInputBuilder(); - ret.setRoute(node); - return ret.build(); + return new RoutedSimpleRouteInputBuilder().setRoute(node).build(); } } diff --git a/opendaylight/md-sal/sal-binding-util/pom.xml b/opendaylight/md-sal/sal-binding-util/pom.xml deleted file mode 100644 index a87b693ab3..0000000000 --- a/opendaylight/md-sal/sal-binding-util/pom.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - 4.0.0 - - org.opendaylight.controller - mdsal-parent - 1.12.0-SNAPSHOT - ../parent - - - org.opendaylight.controller - sal-binding-util - 1.12.0-SNAPSHOT - bundle - - - - org.opendaylight.controller - sal-binding-api - - - - - scm:git:http://git.opendaylight.org/gerrit/controller.git - scm:git:ssh://git.opendaylight.org:29418/controller.git - HEAD - https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL - - - diff --git a/opendaylight/md-sal/sal-binding-util/src/main/java/org/opendaylight/controller/md/sal/binding/util/AbstractBindingSalConsumerInstance.java b/opendaylight/md-sal/sal-binding-util/src/main/java/org/opendaylight/controller/md/sal/binding/util/AbstractBindingSalConsumerInstance.java deleted file mode 100644 index cc16cf3148..0000000000 --- a/opendaylight/md-sal/sal-binding-util/src/main/java/org/opendaylight/controller/md/sal/binding/util/AbstractBindingSalConsumerInstance.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.util; - -import com.google.common.base.Preconditions; -import org.opendaylight.controller.sal.binding.api.NotificationListener; -import org.opendaylight.controller.sal.binding.api.NotificationService; -import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.binding.Notification; -import org.opendaylight.yangtools.yang.binding.RpcService; - -@Deprecated(forRemoval = true) -public abstract class AbstractBindingSalConsumerInstance - implements RpcConsumerRegistry, NotificationService { - - private final R rpcRegistry; - private final N notificationBroker; - - protected final R getRpcRegistry() { - return rpcRegistry; - } - - protected final N getNotificationBroker() { - return notificationBroker; - } - - protected final R getRpcRegistryChecked() { - Preconditions.checkState(rpcRegistry != null,"Rpc Registry is not available."); - return rpcRegistry; - } - - protected final N getNotificationBrokerChecked() { - Preconditions.checkState(notificationBroker != null,"Notification Broker is not available."); - return notificationBroker; - } - - protected AbstractBindingSalConsumerInstance(R rpcRegistry, N notificationBroker) { - this.rpcRegistry = rpcRegistry; - this.notificationBroker = notificationBroker; - } - - @Override - public T getRpcService(Class module) { - return getRpcRegistryChecked().getRpcService(module); - } - - @Override - public ListenerRegistration> registerNotificationListener( - Class notificationType, NotificationListener listener) { - return getNotificationBrokerChecked().registerNotificationListener(notificationType, listener); - } - - @Override - public ListenerRegistration - registerNotificationListener(org.opendaylight.yangtools.yang.binding.NotificationListener listener) { - return getNotificationBrokerChecked().registerNotificationListener(listener); - } -} diff --git a/opendaylight/md-sal/sal-binding-util/src/main/java/org/opendaylight/controller/md/sal/binding/util/AbstractBindingSalProviderInstance.java b/opendaylight/md-sal/sal-binding-util/src/main/java/org/opendaylight/controller/md/sal/binding/util/AbstractBindingSalProviderInstance.java deleted file mode 100644 index c19d99b34c..0000000000 --- a/opendaylight/md-sal/sal-binding-util/src/main/java/org/opendaylight/controller/md/sal/binding/util/AbstractBindingSalProviderInstance.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.util; - -import java.util.concurrent.ExecutorService; -import org.opendaylight.controller.md.sal.common.api.routing.RouteChangeListener; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration; -import org.opendaylight.controller.sal.binding.api.NotificationProviderService; -import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; -import org.opendaylight.controller.sal.binding.api.rpc.RpcContextIdentifier; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.binding.Notification; -import org.opendaylight.yangtools.yang.binding.RpcService; - -@Deprecated(forRemoval = true) -public abstract class AbstractBindingSalProviderInstance - extends AbstractBindingSalConsumerInstance - implements RpcProviderRegistry, NotificationProviderService { - - public AbstractBindingSalProviderInstance(final R rpcRegistry, final N notificationBroker) { - super(rpcRegistry, notificationBroker); - } - - @Override - public RpcRegistration addRpcImplementation(final Class type, final T implementation) - throws IllegalStateException { - return getRpcRegistryChecked().addRpcImplementation(type, implementation); - } - - @Override - public RoutedRpcRegistration addRoutedRpcImplementation(final Class type, - final T implementation) throws IllegalStateException { - return getRpcRegistryChecked().addRoutedRpcImplementation(type, implementation); - } - - @Override - public void publish(final Notification notification) { - getNotificationBrokerChecked().publish(notification); - } - - @Override - public void publish(final Notification notification, final ExecutorService service) { - getNotificationBrokerChecked().publish(notification, service); - } - - @Override - public >> ListenerRegistration - registerRouteChangeListener(final L listener) { - return getRpcRegistryChecked().registerRouteChangeListener(listener); - } - - @Override - public ListenerRegistration registerInterestListener( - final NotificationInterestListener interestListener) { - return getNotificationBrokerChecked().registerInterestListener(interestListener); - } -} diff --git a/opendaylight/md-sal/sal-binding-util/src/main/java/org/opendaylight/controller/md/sal/binding/util/BindingContextUtils.java b/opendaylight/md-sal/sal-binding-util/src/main/java/org/opendaylight/controller/md/sal/binding/util/BindingContextUtils.java deleted file mode 100644 index 914f6d5516..0000000000 --- a/opendaylight/md-sal/sal-binding-util/src/main/java/org/opendaylight/controller/md/sal/binding/util/BindingContextUtils.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.util; - -import static java.util.Objects.requireNonNull; - -import com.google.common.collect.ClassToInstanceMap; -import com.google.common.collect.MutableClassToInstanceMap; -import org.opendaylight.controller.md.sal.common.api.routing.RouteChangeListener; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration; -import org.opendaylight.controller.sal.binding.api.BindingAwareConsumer; -import org.opendaylight.controller.sal.binding.api.BindingAwareProvider; -import org.opendaylight.controller.sal.binding.api.BindingAwareService; -import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry; -import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; -import org.opendaylight.controller.sal.binding.api.rpc.RpcContextIdentifier; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.binding.RpcService; - -@Deprecated(forRemoval = true) -public final class BindingContextUtils { - private BindingContextUtils() { - } - - public static ConsumerContext createConsumerContext(final BindingAwareConsumer consumer, - final ClassToInstanceMap serviceProvider) { - requireNonNull(consumer, "Consumer should not be null"); - return new SingleConsumerContextImpl(requireNonNull(serviceProvider, "Service map should not be null")); - } - - public static ProviderContext createProviderContext(final BindingAwareProvider provider, - final ClassToInstanceMap serviceProvider) { - requireNonNull(provider, "Provider should not be null"); - return new SingleProviderContextImpl(requireNonNull(serviceProvider, "Service map should not be null")); - } - - public static ConsumerContext createConsumerContextAndInitialize(final BindingAwareConsumer consumer, - final ClassToInstanceMap serviceProvider) { - ConsumerContext context = createConsumerContext(consumer, serviceProvider); - consumer.onSessionInitialized(context); - return context; - } - - public static ProviderContext createProviderContextAndInitialize(final BindingAwareProvider provider, - final ClassToInstanceMap serviceProvider) { - ProviderContext context = createProviderContext(provider, serviceProvider); - provider.onSessionInitiated(context); - return context; - } - - public static T createContextProxyOrReturnService(final Class service, - final T instance) { - // FIXME: Create Proxy - return instance; - } - - private static class SingleConsumerContextImpl implements ConsumerContext, AutoCloseable { - - private ClassToInstanceMap alreadyRetrievedServices; - private ClassToInstanceMap serviceProvider; - - SingleConsumerContextImpl(final ClassToInstanceMap serviceProvider) { - this.alreadyRetrievedServices = MutableClassToInstanceMap.create(); - this.serviceProvider = serviceProvider; - } - - @Override - public final T getRpcService(final Class module) { - return getSALService(RpcConsumerRegistry.class).getRpcService(module); - } - - @Override - public final T getSALService(final Class service) { - T potential = alreadyRetrievedServices.getInstance(requireNonNull(service, - "Service class should not be null.")); - if (potential != null) { - return potential; - } - return tryToRetrieveSalService(service); - } - - private synchronized T tryToRetrieveSalService(final Class service) { - final T potential = alreadyRetrievedServices.getInstance(service); - if (potential != null) { - return potential; - } - final T requested = serviceProvider.getInstance(service); - if (requested == null) { - throw new IllegalArgumentException("Requested service " + service.getName() + " is not available."); - } - final T retrieved = BindingContextUtils.createContextProxyOrReturnService(service,requested); - alreadyRetrievedServices.put(service, retrieved); - return retrieved; - } - - @Override - public final void close() { - alreadyRetrievedServices = null; - serviceProvider = null; - } - } - - private static class SingleProviderContextImpl extends SingleConsumerContextImpl implements ProviderContext { - SingleProviderContextImpl(final ClassToInstanceMap serviceProvider) { - super(serviceProvider); - } - - @Override - public >> ListenerRegistration - registerRouteChangeListener(final L listener) { - return getSALService(RpcProviderRegistry.class).registerRouteChangeListener(listener); - } - - @Override - public RoutedRpcRegistration addRoutedRpcImplementation(final Class type, - final T implementation) { - return getSALService(RpcProviderRegistry.class).addRoutedRpcImplementation(type, implementation); - } - - @Override - public RpcRegistration addRpcImplementation(final Class type, - final T implementation) { - return getSALService(RpcProviderRegistry.class).addRpcImplementation(type, implementation); - } - } -} diff --git a/opendaylight/md-sal/sal-binding-util/src/main/java/org/opendaylight/controller/md/sal/binding/util/TypeSafeDataReader.java b/opendaylight/md-sal/sal-binding-util/src/main/java/org/opendaylight/controller/md/sal/binding/util/TypeSafeDataReader.java deleted file mode 100644 index d263102a26..0000000000 --- a/opendaylight/md-sal/sal-binding-util/src/main/java/org/opendaylight/controller/md/sal/binding/util/TypeSafeDataReader.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.binding.util; - -import org.opendaylight.controller.md.sal.common.api.data.DataReader; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -/** - * Deprecated. - * - * @deprecated Use {@link org.opendaylight.controller.md.sal.binding.api.ReadTransaction#read( - * org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType, InstanceIdentifier)} instead. - */ -@Deprecated(forRemoval = true) -public final class TypeSafeDataReader { - - private final DataReader, DataObject> delegate; - - public DataReader, DataObject> getDelegate() { - return delegate; - } - - public TypeSafeDataReader( - final DataReader, DataObject> delegate) { - this.delegate = delegate; - } - - @SuppressWarnings("unchecked") - public D readConfigurationData( - final InstanceIdentifier path) { - return (D) delegate.readConfigurationData(path); - } - - @SuppressWarnings("unchecked") - public D readOperationalData( - final InstanceIdentifier path) { - return (D) delegate.readOperationalData(path); - } - - public static TypeSafeDataReader forReader( - final DataReader, DataObject> delegate) { - return new TypeSafeDataReader(delegate); - } -} diff --git a/opendaylight/md-sal/sal-cluster-admin-impl/pom.xml b/opendaylight/md-sal/sal-cluster-admin-impl/pom.xml index 22ec903cde..9a860bbd42 100644 --- a/opendaylight/md-sal/sal-cluster-admin-impl/pom.xml +++ b/opendaylight/md-sal/sal-cluster-admin-impl/pom.xml @@ -77,8 +77,8 @@ - org.opendaylight.controller - sal-binding-api + org.opendaylight.mdsal + mdsal-binding-api org.opendaylight.controller diff --git a/opendaylight/md-sal/sal-common-api/pom.xml b/opendaylight/md-sal/sal-common-api/pom.xml deleted file mode 100644 index 8e3f0f8dea..0000000000 --- a/opendaylight/md-sal/sal-common-api/pom.xml +++ /dev/null @@ -1,55 +0,0 @@ - - - 4.0.0 - - org.opendaylight.controller - mdsal-parent - 1.12.0-SNAPSHOT - ../parent - - - org.opendaylight.controller - 1.12.0-SNAPSHOT - sal-common-api - bundle - - - - org.opendaylight.yangtools - concepts - - - org.opendaylight.yangtools - util - - - org.opendaylight.yangtools - yang-common - - - org.opendaylight.yangtools - yang-data-api - - - org.opendaylight.mdsal - mdsal-common-api - - - org.apache.commons - commons-lang3 - test - - - junit - junit - test - - - - - scm:git:http://git.opendaylight.org/gerrit/controller.git - scm:git:ssh://git.opendaylight.org:29418/controller.git - HEAD - https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL - - diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/MappingCheckedFuture.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/MappingCheckedFuture.java deleted file mode 100644 index d3e1cd8d70..0000000000 --- a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/MappingCheckedFuture.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2014 Brocade Communications Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.common.api; - -import static java.util.Objects.requireNonNull; - -import com.google.common.util.concurrent.AbstractCheckedFuture; -import com.google.common.util.concurrent.ListenableFuture; -import java.util.concurrent.CancellationException; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; -import java.util.function.Function; - -/** - * An implementation of CheckedFuture that provides similar behavior for the get methods - * that the checkedGet methods provide. - * - *

For {@link CancellationException} and {@link InterruptedException}, the specified exception mapper - * is invoked to translate them to the checked exception type. - * - *

For {@link ExecutionException}, the mapper is invoked to translate the cause to the checked exception - * and a new ExecutionException is thrown with the translated cause. - * - * @author Thomas Pantelis - * - * @param The result type returned by this Future's get method - * @param The checked exception type - */ -@Deprecated(forRemoval = true) -public final class MappingCheckedFuture extends AbstractCheckedFuture { - private final Function mapper; - - private MappingCheckedFuture(final ListenableFuture delegate, final Function mapper) { - super(delegate); - this.mapper = requireNonNull(mapper); - } - - /** - * Creates a new MappingCheckedFuture that wraps the given {@link ListenableFuture} - * delegate. - * - * @param delegate the {@link ListenableFuture} to wrap - * @param mapper the mapping {@link Function} used to translate exceptions from the delegate - * @return a new MappingCheckedFuture - */ - public static MappingCheckedFuture create( - final ListenableFuture delegate, final Function mapper) { - return new MappingCheckedFuture<>(delegate, mapper); - } - - @Override - @SuppressWarnings("checkstyle:parameterName") - protected X mapException(final Exception e) { - return mapper.apply(e); - } - - private ExecutionException wrapInExecutionException(final String message, final Exception ex) { - return new ExecutionException(message, mapException(ex)); - } - - @Override - public V get() throws InterruptedException, ExecutionException { - try { - return super.get(); - } catch (final InterruptedException e) { - Thread.currentThread().interrupt(); - throw wrapInExecutionException("Operation was interrupted", e); - } catch (final CancellationException e) { - throw wrapInExecutionException("Operation was cancelled", e); - } catch (final ExecutionException e) { - throw wrapInExecutionException(e.getMessage(), e); - } - } - - @Override - public V get(final long timeout, final TimeUnit unit) - throws InterruptedException, ExecutionException, TimeoutException { - try { - return super.get(timeout, unit); - } catch (final InterruptedException e) { - Thread.currentThread().interrupt(); - throw wrapInExecutionException("Operation was interrupted", e); - } catch (final CancellationException e) { - throw wrapInExecutionException("Operation was cancelled", e); - } catch (final ExecutionException e) { - throw wrapInExecutionException(e.getMessage(), e); - } - } -} diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/RegistrationListener.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/RegistrationListener.java deleted file mode 100644 index 716add81a1..0000000000 --- a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/RegistrationListener.java +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.common.api; - -import java.util.EventListener; -import org.opendaylight.yangtools.concepts.Registration; - -@Deprecated(forRemoval = true) -public interface RegistrationListener extends EventListener { - - void onRegister(T registration); - - void onUnregister(T registration); -} diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncConfigurationCommitCohort.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncConfigurationCommitCohort.java deleted file mode 100644 index 9e4290eba2..0000000000 --- a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncConfigurationCommitCohort.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.common.api.data; - -import com.google.common.util.concurrent.ListenableFuture; -import org.opendaylight.yangtools.concepts.Path; - -/** - * Three phase Commit Cohort for subtree, which is uniquely associated with user submitted transaction. - * - * @param

- * Type of path (subtree identifier), which represents location in - * tree - * @param - * Type of data (payload), which represents data payload - */ -@Deprecated(forRemoval = true) -public interface AsyncConfigurationCommitCohort

, D> { - - /** - * Initiates a pre-commit of associated request - * - *

- * Implementation MUST NOT do any blocking calls during this callback, all - * pre-commit preparation SHOULD happen asynchronously and MUST result in - * completing returned future object. - * - * @param rebasedTransaction - * Read-only view of transaction as if happened on top of actual - * data store - * @return Future which is completed once pre-commit phase for this request - * is finished. - */ - ListenableFuture preCommit(AsyncReadTransaction rebasedTransaction); - - /** - * Initiates a commit phase of associated request - * - *

- * Implementation MUST NOT do any blocking calls during this callback, all - * commit finalization SHOULD happen asynchronously and MUST result in - * completing returned future object. - * - * @return Future which is completed once commit phase for associated - * request is finished. - */ - ListenableFuture commit(); - - /** - * Initiates abort phase of associated request - * - *

- * Implementation MUST NOT do any blocking calls during this callback, all - * commit finalization SHOULD happen asynchronously and MUST result in - * completing returned future object. - * - * @return Future which is completed once commit phase for associated - * request is finished. - */ - ListenableFuture abort(); - -} diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncConfigurationCommitCoordinator.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncConfigurationCommitCoordinator.java deleted file mode 100644 index 8cfde44347..0000000000 --- a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncConfigurationCommitCoordinator.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.common.api.data; - -import org.opendaylight.yangtools.concepts.ObjectRegistration; -import org.opendaylight.yangtools.concepts.Path; - -/** - * Three Phase Commit Coordinator with support of user-supplied commit cohorts - * which participates in three-phase commit protocols. - * - * @param

- * Type of path (subtree identifier), which represents location in - * tree - * @param - * Type of data (payload), which represents data payload - */ -@Deprecated(forRemoval = true) -public interface AsyncConfigurationCommitCoordinator

, D> { - /** - * Register configuration commit handler for particular subtree. Configuration commit handler is invoked for all - * write transactions which modifies subtree - * - * @param subtree Subtree which configuration commit handler is interested it - * @param commitHandler Instance of user-provided commit handler - * @return Registration object representing this registration. Invoking {@link ObjectRegistration#close()} - * will unregister configuration commit handler. - */ - > ObjectRegistration registerConfigurationCommitHandler( - P subtree, C commitHandler); -} diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncConfigurationCommitHandler.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncConfigurationCommitHandler.java deleted file mode 100644 index 868c87df6a..0000000000 --- a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncConfigurationCommitHandler.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.common.api.data; - -import com.google.common.util.concurrent.CheckedFuture; -import org.opendaylight.yangtools.concepts.Path; - -/** - * User-supplied participant in three-phase commit of transaction for configuration data tree. - * - *

- * Client-supplied implementation of commit handler for subtree, which - * is responsible for processing CAN-COMMIT phase of three-phase commit protocol - * and return CommitCohort, which provides access to additional transitions - * such as PRE-COMMIT, COMMIT and ABORT. - * - * @param

- * Type of path (subtree identifier), which represents location in - * tree - * @param - * Type of data (payload), which represents data payload - */ -@Deprecated(forRemoval = true) -public interface AsyncConfigurationCommitHandler

, D> { - - /** - * Requests a can commit phase - * - *

- * Implementations SHOULD NOT do any blocking operation during - * processing this callback. - * - * Implementation Notes - *

    - *
  • Implementation are REQUIRED to use request object for any data related access
  • - *
  • Implementations SHOULD NOT use any other state stored outside configuration subtree for validation
  • - *
  • Validation should happen asynchronously, outside callback call by updating returned {@link CheckedFuture} - * object.
  • - *
  • If validation (CAN_COMMIT) phase: - *
      - *
    • is successful - invocation of {@link CheckedFuture#checkedGet()} on returned future MUST - * return {@link AsyncConfigurationCommitCohort} associated with request.
    • - *
    • is unsuccessful - invocation of {@link CheckedFuture#checkedGet()} must throw instance - * of {@link DataValidationFailedException} - * with human readable explanaition of error condition. - *
    • - *
    - *
  • - *
- * @param request - * Commit Request submitted by client, which contains - * information about modifications and read-only view as - * if transaction happened. - * @return CheckedFuture which contains client-supplied implementation of {@link AsyncConfigurationCommitCohort} - * associated with submitted request, if can commit phase is - * successful, if can commit was unsuccessful, future must fail with - * {@link TransactionCommitFailedException} exception. - */ - CheckedFuture, DataValidationFailedException> canCommit( - ConfigurationCommitRequest request); - - /** - * Commit Request as was submitted by client code - * - *

- * Commit Request contains list view of created / updated / removed - * path and read-only view of proposed client transaction, - * which may be used to retrieve modified or referenced data. - * - * - * @param

- * Type of path (subtree identifier), which represents location - * in tree - * @param - * Type of data (payload), which represents data payload - */ - interface ConfigurationCommitRequest

, D> { - - /** - * Read-only transaction which provides access only to configuration - * data tree as if submitted transaction successfully happened and - * no other concurrent modifications happened between allocation - * of client transactions and write of client transactions. - * - *

- * Implementations of Commit Handlers are REQUIRED to use this - * read-only view to access any data from configuration data tree, - * in order to capture them as preconditions for this transaction. - * - * @return Read-only transaction which provides access only to configuration - * data tree as if submitted transaction successfully happened - */ - AsyncReadTransaction getReadOnlyView(); - - /** - * Returns iteration of paths, to data which was introduced by this transaction. - * - * @return Iteration of paths, which was introduced by this transaction. - */ - Iterable

getCreatedPaths(); - - /** - * Returns iteration of paths, to data which was updated by this transaction. - * - * @return Iteration of paths, which was updated by this transaction. - */ - Iterable

getUpdatedPaths(); - - /** - * Returns iteration of paths, to data which was removed by this transaction. - * - * @return Iteration of paths, which was removed by this transaction. - */ - Iterable

getRemovedPaths(); - } - -} diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncDataBroker.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncDataBroker.java deleted file mode 100644 index 74f05fc11b..0000000000 --- a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncDataBroker.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.common.api.data; - -import org.opendaylight.yangtools.concepts.Path; - -/** - * Base interface that provides access to a conceptual data tree store and also provides the ability to - * subscribe for changes to data under a given branch of the tree. - * - *

- * All operations on the data tree are performed via one of the transactions: - *

    - *
  • Read-Only - allocated using {@link #newReadOnlyTransaction()} - *
  • Write-Only - allocated using {@link #newWriteOnlyTransaction()} - *
  • Read-Write - allocated using {@link #newReadWriteTransaction()} - *
- * - *

- * These transactions provide a stable isolated view of data tree, which is - * guaranteed to be not affected by other concurrent transactions, until - * transaction is committed. - * - *

- * For a detailed explanation of how transaction are isolated and how transaction-local - * changes are committed to global data tree, see - * {@link AsyncReadTransaction}, {@link AsyncWriteTransaction}, - * {@link AsyncReadWriteTransaction} and {@link AsyncWriteTransaction#submit()}. - * - * - *

- * It is strongly recommended to use the type of transaction, which - * provides only the minimal capabilities you need. This allows for - * optimizations at the data broker / data store level. For example, - * implementations may optimize the transaction for reading if they know ahead - * of time that you only need to read data - such as not keeping additional meta-data, - * which may be required for write transactions. - * - *

- * Implementation Note: This interface is not intended to be implemented - * by users of MD-SAL, but only to be consumed by them. - * - * @param

- * Type of path (subtree identifier), which represents location in - * tree - * @param - * Type of data (payload), which represents data payload - */ -@Deprecated(forRemoval = true) -public interface AsyncDataBroker

, D> extends AsyncDataTransactionFactory { - - @Override - AsyncReadOnlyTransaction newReadOnlyTransaction(); - - @Override - AsyncReadWriteTransaction newReadWriteTransaction(); - - @Override - AsyncWriteTransaction newWriteOnlyTransaction(); -} diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncDataTransactionFactory.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncDataTransactionFactory.java deleted file mode 100644 index 50c91388fa..0000000000 --- a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncDataTransactionFactory.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.common.api.data; - -import org.opendaylight.yangtools.concepts.Path; - -/** - * A factory which allocates new transactions to operate on the data - * tree. - * - *

- * Note: This interface is not intended to be used directly, but rather - * via subinterfaces which introduces additional semantics to allocated - * transactions. - *

    - *
  • {@link AsyncDataBroker} - *
  • {@link TransactionChain} - *
- * - *

- * All operations on the data tree are performed via one of the transactions: - *

    - *
  • Read-Only - allocated using {@link #newReadOnlyTransaction()} - *
  • Write-Only - allocated using {@link #newWriteOnlyTransaction()} - *
  • Read-Write - allocated using {@link #newReadWriteTransaction()} - *
- * - *

- * These transactions provides a stable isolated view of the data tree, which is - * guaranteed to be not affected by other concurrent transactions, until - * transaction is committed. - * - *

- * For a detailed explanation of how transaction are isolated and how transaction-local - * changes are committed to global data tree, see - * {@link AsyncReadTransaction}, {@link AsyncWriteTransaction}, - * {@link AsyncReadWriteTransaction} and {@link AsyncWriteTransaction#submit()}. - * - *

- * It is strongly recommended to use the type of transaction, which - * provides only the minimal capabilities you need. This allows for - * optimizations at the data broker / data store level. For example, - * implementations may optimize the transaction for reading if they know ahead - * of time that you only need to read data - such as not keeping additional meta-data, - * which may be required for write transactions. - * - *

- * Implementation Note: This interface is not intended to be implemented - * by users of MD-SAL, but only to be consumed by them. - * - * @see AsyncDataBroker - * @see TransactionChain - * - * @param

- * Type of path (subtree identifier), which represents location in - * tree - * @param - * Type of data (payload), which represents data payload - */ -@Deprecated(forRemoval = true) -public interface AsyncDataTransactionFactory

, D> { - - /** - * Allocates a new read-only transaction which provides an immutable snapshot of the data tree. - * - *

- * The view of data tree is an immutable snapshot of current data tree state when - * transaction was allocated. - * - * @return new read-only transaction - */ - AsyncReadOnlyTransaction newReadOnlyTransaction(); - - /** - * Allocates new read-write transaction which provides a mutable view of the data - * tree. - * - *

- * Preconditions for mutation of data tree are captured from the snapshot of - * data tree state, when the transaction is allocated. If data was - * changed during transaction in an incompatible way then the commit of this transaction - * will fail. See {@link AsyncWriteTransaction#submit()} for more - * details about conflicting and not-conflicting changes and - * failure scenarios. - * - * @return new read-write transaction - */ - AsyncReadWriteTransaction newReadWriteTransaction(); - - /** - * Allocates new write-only transaction based on latest state of data - * tree. - * - *

- * Preconditions for mutation of data tree are captured from the snapshot of - * data tree state, when the transaction is allocated. If data was - * changed during transaction in an incompatible way then the commit of this transaction - * will fail. See {@link AsyncWriteTransaction#submit()} for more - * details about conflicting and not-conflicting changes and - * failure scenarios. - * - *

- * Since this transaction does not provide a view of the data it SHOULD BE - * used only by callers which are exclusive writers (exporters of data) - * to the subtree they modify. This prevents optimistic - * lock failures as described in {@link AsyncWriteTransaction#submit()}. - * - *

- * Exclusivity of writers to particular subtree SHOULD BE enforced by - * external locking mechanism. - * - * @return new write-only transaction - */ - AsyncWriteTransaction newWriteOnlyTransaction(); - -} diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncReadOnlyTransaction.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncReadOnlyTransaction.java deleted file mode 100644 index e2cd7bd4f6..0000000000 --- a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncReadOnlyTransaction.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.common.api.data; - -import org.opendaylight.yangtools.concepts.Path; - -/** - * Marker interface for a read-only view of the data tree. - * - * @see AsyncReadTransaction - * - * @param

- * Type of path (subtree identifier), which represents location in - * tree - * @param - * Type of data (payload), which represents data payload - */ -@Deprecated(forRemoval = true) -public interface AsyncReadOnlyTransaction

, D> extends AsyncReadTransaction, AutoCloseable { - - /** - * Closes this transaction and releases all resources associated with it. - * - */ - @Override - void close(); -} diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncReadTransaction.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncReadTransaction.java deleted file mode 100644 index 48808a159e..0000000000 --- a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncReadTransaction.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.common.api.data; - -import org.opendaylight.yangtools.concepts.Path; - -/** - * Marker interface for stateful read view of the data tree. - * - *

- * View of the data tree is a stable point-in-time snapshot of the current data tree state when - * the transaction was created. It's state and underlying data tree - * is not affected by other concurrently running transactions. - * - *

- * Implementation Note: This interface is not intended to be implemented - * by users of MD-SAL, but only to be consumed by them. - * - *

Transaction isolation example

- * Lets assume initial state of data tree for PATH is A. - * - *
- * txRead = broker.newReadOnlyTransaction();   // read Transaction is snapshot of data
- * txWrite = broker.newReadWriteTransactoin(); // concurrent write transaction
- *
- * txRead.read(OPERATIONAL,PATH).get();        // will return Optional containing A
- * txWrite = broker.put(OPERATIONAL,PATH,B);   // writes B to PATH
- *
- * txRead.read(OPERATIONAL,PATH).get();        // still returns Optional containing A
- *
- * txWrite.commit().get();                     // data tree is updated, PATH contains B
- * txRead.read(OPERATIONAL,PATH).get();        // still returns Optional containing A
- *
- * txAfterCommit = broker.newReadOnlyTransaction(); // read Transaction is snapshot of new state
- * txAfterCommit.read(OPERATIONAL,PATH).get(); // returns Optional containing B;
- * 
- * - *

- * Note: example contains blocking calls on future only to illustrate - * that action happened after other asynchronous action. Use of blocking call - * {@link com.google.common.util.concurrent.ListenableFuture#get()} is discouraged for most - * uses and you should use - * {@link com.google.common.util.concurrent.Futures#addCallback(com.google.common.util.concurrent.ListenableFuture, - * com.google.common.util.concurrent.FutureCallback, java.util.concurrent.Executor)} - * or other functions from {@link com.google.common.util.concurrent.Futures} to - * register more specific listeners. - * - * @param

- * Type of path (subtree identifier), which represents location in - * tree - * @param - * Type of data (payload), which represents data payload - */ -@Deprecated(forRemoval = true) -public interface AsyncReadTransaction

, D> extends AsyncTransaction { - -} diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncReadWriteTransaction.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncReadWriteTransaction.java deleted file mode 100644 index 5babd8c78f..0000000000 --- a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncReadWriteTransaction.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.common.api.data; - -import org.opendaylight.yangtools.concepts.Path; - -/** - * Transaction enabling a client to have a combined read/write capabilities. - * - *

- * The initial state of the write transaction is stable snapshot of current data tree - * state captured when transaction was created and it's state and underlying - * data tree are not affected by other concurrently running transactions. - * - *

- * Write transactions are isolated from other concurrent write transactions. All - * writes are local to the transaction and represents only a proposal of state - * change for data tree and it is not visible to any other concurrently running - * transactions. - * - *

- * Applications publish the changes proposed in the transaction by calling {@link #submit} - * on the transaction. This seals the transaction - * (preventing any further writes using this transaction) and submits it to be - * processed and applied to global conceptual data tree. - * - *

- * The transaction commit may fail due to a concurrent transaction modifying and committing data in - * an incompatible way. See {@link #submit()} for more concrete commit failure examples. - * - * Implementation Note: This interface is not intended to be implemented - * by users of MD-SAL, but only to be consumed by them. - * - *

Examples

- * - *

Transaction local state

- * - *

- * Let assume initial state of data tree for PATH is A - * . - * - *

- * txWrite = broker.newReadWriteTransaction(); // concurrent write transaction
- *
- * txWrite.read(OPERATIONAL,PATH).get()        // will return Optional containing A
- * txWrite.put(OPERATIONAL,PATH,B);            // writes B to PATH
- * txWrite.read(OPERATIONAL,PATH).get()        // will return Optional Containing B
- *
- * txWrite.commit().get();                     // data tree is updated, PATH contains B
- *
- * tx1afterCommit = broker.newReadOnlyTransaction(); // read Transaction is snapshot of new state
- * tx1afterCommit.read(OPERATIONAL,PATH).get(); // returns Optional containing B
- * 
- * - *

- * As you could see read-write transaction provides capabilities as - * {@link AsyncWriteTransaction} but also allows for reading proposed changes as - * if they already happened. - * - *

Transaction isolation (read transaction, read-write transaction)

Let - * assume initial state of data tree for PATH is A. - * - *
- * txRead = broker.newReadOnlyTransaction();   // read Transaction is snapshot of data
- * txWrite = broker.newReadWriteTransaction(); // concurrent write transaction
- *
- * txRead.read(OPERATIONAL,PATH).get();        // will return Optional containing A
- * txWrite.read(OPERATIONAL,PATH).get()        // will return Optional containing A
- *
- * txWrite.put(OPERATIONAL,PATH,B);            // writes B to PATH
- * txWrite.read(OPERATIONAL,PATH).get()        // will return Optional Containing B
- *
- * txRead.read(OPERATIONAL,PATH).get();        // concurrent read transaction still returns
- *                                             // Optional containing A
- *
- * txWrite.commit().get();                     // data tree is updated, PATH contains B
- * txRead.read(OPERATIONAL,PATH).get();        // still returns Optional containing A
- *
- * tx1afterCommit = broker.newReadOnlyTransaction(); // read Transaction is snapshot of new state
- * tx1afterCommit.read(OPERATIONAL,PATH).get(); // returns Optional containing B
- * 
- * - *

Transaction isolation (2 concurrent read-write transactions)

Let - * assume initial state of data tree for PATH is A. - * - *
- * tx1 = broker.newReadWriteTransaction(); // read Transaction is snapshot of data
- * tx2 = broker.newReadWriteTransaction(); // concurrent write transaction
- *
- * tx1.read(OPERATIONAL,PATH).get();       // will return Optional containing A
- * tx2.read(OPERATIONAL,PATH).get()        // will return Optional containing A
- *
- * tx2.put(OPERATIONAL,PATH,B);            // writes B to PATH
- * tx2.read(OPERATIONAL,PATH).get()        // will return Optional Containing B
- *
- * tx1.read(OPERATIONAL,PATH).get();       // tx1 read-write transaction still sees Optional
- *                                         // containing A since is isolated from tx2
- * tx1.put(OPERATIONAL,PATH,C);            // writes C to PATH
- * tx1.read(OPERATIONAL,PATH).get()        // will return Optional Containing C
- *
- * tx2.read(OPERATIONAL,PATH).get()        // tx2 read-write transaction still sees Optional
- *                                         // containing B since is isolated from tx1
- *
- * tx2.commit().get();                     // data tree is updated, PATH contains B
- * tx1.read(OPERATIONAL,PATH).get();       // still returns Optional containing C since is isolated from tx2
- *
- * tx1afterCommit = broker.newReadOnlyTransaction(); // read Transaction is snapshot of new state
- * tx1afterCommit.read(OPERATIONAL,PATH).get(); // returns Optional containing B
- *
- * tx1.commit()                            // Will fail with OptimisticLockFailedException
- *                                         // which means concurrent transaction changed the same PATH
- *
- * 
- * - *

- * Note: examples contains blocking calls on future only to illustrate - * that action happened after other asynchronous action. Use of blocking call - * {@link com.google.common.util.concurrent.ListenableFuture#get()} is discouraged for most uses and you should - * use {@link com.google.common.util.concurrent.Futures#addCallback(com.google.common.util.concurrent.ListenableFuture, - * com.google.common.util.concurrent.FutureCallback, java.util.concurrent.Executor)} - * or other functions from {@link com.google.common.util.concurrent.Futures} to - * register more specific listeners. - * - * @see AsyncReadTransaction - * @see AsyncWriteTransaction - * - * @param

- * Type of path (subtree identifier), which represents location in - * tree - * @param - * Type of data (payload), which represents data payload - */ -@Deprecated(forRemoval = true) -public interface AsyncReadWriteTransaction

, D> extends AsyncReadTransaction, - AsyncWriteTransaction { - -} diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncTransaction.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncTransaction.java deleted file mode 100644 index 50b0798f8d..0000000000 --- a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncTransaction.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.common.api.data; - -import org.opendaylight.yangtools.concepts.Identifiable; -import org.opendaylight.yangtools.concepts.Path; - - -/** - * A common parent for all transactions which operate on a conceptual data tree. - * - *

- * See derived transaction types for more concrete behavior: - *

    - *
  • {@link AsyncReadTransaction} - Read capabilities, user is able to read data from data tree
  • - *
  • {@link AsyncWriteTransaction} - Write capabilities, user is able to propose changes to data tree
  • - *
  • {@link AsyncReadWriteTransaction} - Read and Write capabilities, user is able to read state and to propose - * changes of state.
  • - *
- * - * Implementation Note: This interface is not intended to be implemented - * by users of MD-SAL. - * - * @param

Type of path (subtree identifier), which represents location in tree - * @param Type of data (payload), which represents data payload - */ -@Deprecated(forRemoval = true) -public interface AsyncTransaction

,D> extends // - Identifiable { - - @Override - Object getIdentifier(); -} diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncWriteTransaction.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncWriteTransaction.java deleted file mode 100644 index 725e364525..0000000000 --- a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncWriteTransaction.java +++ /dev/null @@ -1,391 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.common.api.data; - -import com.google.common.util.concurrent.CheckedFuture; -import com.google.common.util.concurrent.FluentFuture; -import com.google.common.util.concurrent.ListenableFuture; -import com.google.common.util.concurrent.MoreExecutors; -import org.eclipse.jdt.annotation.NonNull; -import org.opendaylight.controller.md.sal.common.api.MappingCheckedFuture; -import org.opendaylight.mdsal.common.api.CommitInfo; -import org.opendaylight.yangtools.concepts.Path; -import org.opendaylight.yangtools.util.concurrent.ExceptionMapper; - -/** - * Write transaction provides mutation capabilities for a data tree. - * - *

- * Initial state of write transaction is a stable snapshot of the current data tree. - * The state is captured when the transaction is created and its state and underlying - * data tree are not affected by other concurrently running transactions. - * - *

- * Write transactions are isolated from other concurrent write transactions. All - * writes are local to the transaction and represent only a proposal of state - * change for the data tree and it is not visible to any other concurrently running - * transaction. - * - *

- * Applications make changes to the local data tree in the transaction by via the - * put, merge, and delete operations. - * - *

Put operation

- * Stores a piece of data at a specified path. This acts as an add / replace - * operation, which is to say that whole subtree will be replaced by the - * specified data. - * - *

- * Performing the following put operations: - * - *

- * 1) container { list [ a ] }
- * 2) container { list [ b ] }
- * 
- * - *

- * will result in the following data being present: - * - *

- * container { list [ b ] }
- * 
- *

Merge operation

- * Merges a piece of data with the existing data at a specified path. Any pre-existing data - * which is not explicitly overwritten will be preserved. This means that if you store a container, - * its child lists will be merged. - * - *

- * Performing the following merge operations: - * - *

- * 1) container { list [ a ] }
- * 2) container { list [ b ] }
- * 
- * - *

- * will result in the following data being present: - * - *

- * container { list [ a, b ] }
- * 
- * - *

- * This also means that storing the container will preserve any - * augmentations which have been attached to it. - * - *

Delete operation

- * Removes a piece of data from a specified path. - * - *

- * After applying changes to the local data tree, applications publish the changes proposed in the - * transaction by calling {@link #submit} on the transaction. This seals the transaction - * (preventing any further writes using this transaction) and submits it to be - * processed and applied to global conceptual data tree. - * - *

- * The transaction commit may fail due to a concurrent transaction modifying and committing data in - * an incompatible way. See {@link #submit} for more concrete commit failure examples. - * - *

- * Implementation Note: This interface is not intended to be implemented - * by users of MD-SAL, but only to be consumed by them. - * - * @param

- * Type of path (subtree identifier), which represents location in - * tree - * @param - * Type of data (payload), which represents data payload - */ -@Deprecated(forRemoval = true) -public interface AsyncWriteTransaction

, D> extends AsyncTransaction { - /** - * Cancels the transaction. - * - *

- * Transactions can only be cancelled if it's state is new or submitted. - * - *

- * Invoking cancel() on a failed or cancelled transaction will have no effect, and transaction - * is considered cancelled. - * - *

- * Invoking cancel() on a finished transaction (future returned by {@link #submit()} already completed will always - * fail (return false). - * - * @return {@code false} if the task could not be cancelled, typically because it has already completed normally - * {@code true} otherwise - * - */ - boolean cancel(); - - /** - * Removes a piece of data from specified path. This operation does not fail - * if the specified path does not exist. - * - * @param store - * Logical data store which should be modified - * @param path - * Data object path - * @throws IllegalStateException - * if the transaction as already been submitted or cancelled - */ - void delete(LogicalDatastoreType store, P path); - - /** - * Submits this transaction to be asynchronously applied to update the logical data tree. - * The returned CheckedFuture conveys the result of applying the data changes. - * - *

- * Note: It is strongly recommended to process the CheckedFuture result in an asynchronous - * manner rather than using the blocking get() method. See example usage below. - * - *

- * This call logically seals the transaction, which prevents the client from - * further changing data tree using this transaction. Any subsequent calls to - * {@link #delete(LogicalDatastoreType, Path)} will fail with - * {@link IllegalStateException}. - * - *

- * The transaction is marked as submitted and enqueued into the data store back-end for processing. - * - *

- * Whether or not the commit is successful is determined by versioning - * of the data tree and validation of registered commit participants - * ({@link AsyncConfigurationCommitHandler}) if the transaction changes the data tree. - * - *

- * The effects of a successful commit of data depends on data tree change listeners and commit participants - * ({@link AsyncConfigurationCommitHandler}) that are registered with the data broker. - * - *

Example usage:

- *
-     *  private void doWrite( final int tries ) {
-     *      WriteTransaction writeTx = dataBroker.newWriteOnlyTransaction();
-     *
-     *      MyDataObject data = ...;
-     *      InstanceIdentifier<MyDataObject> path = ...;
-     *      writeTx.put( LogicalDatastoreType.OPERATIONAL, path, data );
-     *
-     *      Futures.addCallback( writeTx.submit(), new FutureCallback<Void>() {
-     *          public void onSuccess( Void result ) {
-     *              // succeeded
-     *          }
-     *
-     *          public void onFailure( Throwable t ) {
-     *              if( t instanceof OptimisticLockFailedException ) {
-     *                  if( ( tries - 1 ) > 0 ) {
-     *                      // do retry
-     *                      doWrite( tries - 1 );
-     *                  } else {
-     *                      // out of retries
-     *                  }
-     *              } else {
-     *                  // failed due to another type of TransactionCommitFailedException.
-     *              }
-     *          } );
-     * }
-     * ...
-     * doWrite( 2 );
-     * 
- *

Failure scenarios

- * - *

- * Transaction may fail because of multiple reasons, such as - *

    - *
  • Another transaction finished earlier and modified the same node in a - * non-compatible way (see below). In this case the returned future will fail with an - * {@link OptimisticLockFailedException}. It is the responsibility of the - * caller to create a new transaction and submit the same modification again in - * order to update data tree. Warning: In most cases, retrying after an - * OptimisticLockFailedException will result in a high probability of success. - * However, there are scenarios, albeit unusual, where any number of retries will - * not succeed. Therefore it is strongly recommended to limit the number of retries (2 or 3) - * to avoid an endless loop. - *
  • - *
  • Data change introduced by this transaction did not pass validation by - * commit handlers or data was incorrectly structured. Returned future will - * fail with a {@link DataValidationFailedException}. User should not retry to - * create new transaction with same data, since it probably will fail again. - *
  • - *
- * - *

Change compatibility

- * - *

- * There are several sets of changes which could be considered incompatible - * between two transactions which are derived from same initial state. - * Rules for conflict detection applies recursively for each subtree - * level. - * - *

Change compatibility of leafs, leaf-list items

- * - *

- * Following table shows state changes and failures between two concurrent transactions, - * which are based on same initial state, Tx 1 completes successfully - * before Tx 2 is submitted. - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
Data store state changes
Initial stateTx 1Tx 2Result
Emptyput(A,1)put(A,2)Tx 2 will fail, state is A=1
Emptyput(A,1)merge(A,2)A=2
Emptymerge(A,1)put(A,2)Tx 2 will fail, state is A=1
Emptymerge(A,1)merge(A,2)A=2
A=0put(A,1)put(A,2)Tx 2 will fail, A=1
A=0put(A,1)merge(A,2)A=2
A=0merge(A,1)put(A,2)Tx 2 will fail, A=1
A=0merge(A,1)merge(A,2)A=2
A=0delete(A)put(A,2)Tx 2 will fail, A does not exists
A=0delete(A)merge(A,2)A=2
- * - *

Change compatibility of subtrees

- * - *

- * Following table shows state changes and failures between two concurrent transactions, - * which are based on same initial state, Tx 1 completes successfully - * before Tx 2 is submitted. - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
Data store state changes
Initial stateTx 1Tx 2Result
Emptyput(TOP,[])put(TOP,[])Tx 2 will fail, state is TOP=[]
Emptyput(TOP,[])merge(TOP,[])TOP=[]
Emptyput(TOP,[FOO=1])put(TOP,[BAR=1])Tx 2 will fail, state is TOP=[FOO=1] - *
Emptyput(TOP,[FOO=1])merge(TOP,[BAR=1])TOP=[FOO=1,BAR=1]
Emptymerge(TOP,[FOO=1])put(TOP,[BAR=1])Tx 2 will fail, state is TOP=[FOO=1] - *
Emptymerge(TOP,[FOO=1])merge(TOP,[BAR=1])TOP=[FOO=1,BAR=1]
TOP=[]put(TOP,[FOO=1])put(TOP,[BAR=1])Tx 2 will fail, state is TOP=[FOO=1] - *
TOP=[]put(TOP,[FOO=1])merge(TOP,[BAR=1])state is TOP=[FOO=1,BAR=1]
TOP=[]merge(TOP,[FOO=1])put(TOP,[BAR=1])Tx 2 will fail, state is TOP=[FOO=1] - *
TOP=[]merge(TOP,[FOO=1])merge(TOP,[BAR=1])state is TOP=[FOO=1,BAR=1]
TOP=[]delete(TOP)put(TOP,[BAR=1])Tx 2 will fail, state is empty store - *
TOP=[]delete(TOP)merge(TOP,[BAR=1])state is TOP=[BAR=1]
TOP=[]put(TOP/FOO,1)put(TOP/BAR,1])state is TOP=[FOO=1,BAR=1]
TOP=[]put(TOP/FOO,1)merge(TOP/BAR,1)state is TOP=[FOO=1,BAR=1]
TOP=[]merge(TOP/FOO,1)put(TOP/BAR,1)state is TOP=[FOO=1,BAR=1]
TOP=[]merge(TOP/FOO,1)merge(TOP/BAR,1)state is TOP=[FOO=1,BAR=1]
TOP=[]delete(TOP)put(TOP/BAR,1)Tx 2 will fail, state is empty store
TOP=[]delete(TOP)merge(TOP/BAR,1]Tx 2 will fail, state is empty store - *
TOP=[FOO=1]put(TOP/FOO,2)put(TOP/BAR,1)state is TOP=[FOO=2,BAR=1]
TOP=[FOO=1]put(TOP/FOO,2)merge(TOP/BAR,1)state is TOP=[FOO=2,BAR=1]
TOP=[FOO=1]merge(TOP/FOO,2)put(TOP/BAR,1)state is TOP=[FOO=2,BAR=1]
TOP=[FOO=1]merge(TOP/FOO,2)merge(TOP/BAR,1)state is TOP=[FOO=2,BAR=1] - *
TOP=[FOO=1]delete(TOP/FOO)put(TOP/BAR,1)state is TOP=[BAR=1]
TOP=[FOO=1]delete(TOP/FOO)merge(TOP/BAR,1]state is TOP=[BAR=1]
- * - * - *

Examples of failure scenarios

- * - *

Conflict of two transactions

- * - *

- * This example illustrates two concurrent transactions, which derived from - * same initial state of data tree and proposes conflicting modifications. - * - *

-     * txA = broker.newWriteTransaction(); // allocates new transaction, data tree is empty
-     * txB = broker.newWriteTransaction(); // allocates new transaction, data tree is empty
-     *
-     * txA.put(CONFIGURATION, PATH, A);    // writes to PATH value A
-     * txB.put(CONFIGURATION, PATH, B)     // writes to PATH value B
-     *
-     * ListenableFuture futureA = txA.submit(); // transaction A is sealed and submitted
-     * ListenebleFuture futureB = txB.submit(); // transaction B is sealed and submitted
-     * 
- * - *

- * Commit of transaction A will be processed asynchronously and data tree - * will be updated to contain value A for PATH. - * Returned {@link ListenableFuture} will successfully complete once - * state is applied to data tree. - * - *

- * Commit of Transaction B will fail, because previous transaction also - * modified path in a concurrent way. The state introduced by transaction B - * will not be applied. Returned {@link ListenableFuture} object will fail - * with {@link OptimisticLockFailedException} exception, which indicates to - * client that concurrent transaction prevented the submitted transaction from being - * applied. - *
- * @return a CheckFuture containing the result of the commit. The Future blocks until the - * commit operation is complete. A successful commit returns nothing. On failure, - * the Future will fail with a {@link TransactionCommitFailedException} or an exception - * derived from TransactionCommitFailedException. - * - * @throws IllegalStateException - * if the transaction is not new - * @deprecated Use {@link #commit()} instead. - */ - @Deprecated - default CheckedFuture submit() { - return MappingCheckedFuture.create(commit().transform(ignored -> null, MoreExecutors.directExecutor()), - SUBMIT_EXCEPTION_MAPPER); - } - - /** - * Submits this transaction to be asynchronously applied to update the logical data tree. The returned - * {@link FluentFuture} conveys the result of applying the data changes. - * - *

- * This call logically seals the transaction, which prevents the client from further changing the data tree using - * this transaction. Any subsequent calls to put(LogicalDatastoreType, Path, Object), - * merge(LogicalDatastoreType, Path, Object), delete(LogicalDatastoreType, Path) will fail - * with {@link IllegalStateException}. The transaction is marked as submitted and enqueued into the data store - * back-end for processing. - * - *

- * Whether or not the commit is successful is determined by versioning of the data tree and validation of registered - * commit participants if the transaction changes the data tree. - * - *

- * The effects of a successful commit of data depends on listeners and commit participants that are registered with - * the data broker. - * - *

- * A successful commit produces implementation-specific {@link CommitInfo} structure, which is used to communicate - * post-condition information to the caller. Such information can contain commit-id, timing information or any - * other information the implementation wishes to share. - * - * @return a FluentFuture containing the result of the commit information. The Future blocks until the commit - * operation is complete. A successful commit returns nothing. On failure, the Future will fail with a - * {@link TransactionCommitFailedException} or an exception derived from TransactionCommitFailedException. - * @throws IllegalStateException if the transaction is already committed or was canceled. - */ - @NonNull FluentFuture commit(); - - /** - * This only exists for reuse by the deprecated {@link #submit} method and is not intended for general use. - */ - @Deprecated - ExceptionMapper SUBMIT_EXCEPTION_MAPPER = - new ExceptionMapper("submit", TransactionCommitFailedException.class) { - @Override - protected TransactionCommitFailedException newWithCause(final String message, final Throwable cause) { - return new TransactionCommitFailedException(message, cause); - } - }; -} diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/DataReader.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/DataReader.java deleted file mode 100644 index 9ede6381b5..0000000000 --- a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/DataReader.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.common.api.data; - -import org.opendaylight.yangtools.concepts.Path; - -/** - * Reader for reading YANG subtrees based on their path. - * - *

- * Reader is requested to return object at specified path and all it's subnodes - * known to the reader or null if node is not found in this reader. - * - * @param

Path Type - * @param Data Type - * @deprecated Replaced by org.opendaylight.controller.sal.core.spi.data.DOMStore contract. - */ -@Deprecated(forRemoval = true) -public interface DataReader

, D> { - - /** - * Reads data from Operational data store located at provided path. - * - * @param path Path to data - * @return the data - */ - D readOperationalData(P path); - - D readConfigurationData(P path); -} diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/DataStoreUnavailableException.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/DataStoreUnavailableException.java deleted file mode 100644 index 0641155736..0000000000 --- a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/DataStoreUnavailableException.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.common.api.data; - -/** - * This exception occurs if the datastore is temporarily unavailable. - * A retry of the transaction may succeed after a period of time - * - * @deprecated Use {@link org.opendaylight.mdsal.common.api.DataStoreUnavailableException} instead. - */ -@Deprecated(forRemoval = true) -public class DataStoreUnavailableException extends Exception { - private static final long serialVersionUID = 1L; - - public DataStoreUnavailableException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/DataValidationFailedException.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/DataValidationFailedException.java deleted file mode 100644 index 16c956caf4..0000000000 --- a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/DataValidationFailedException.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.common.api.data; - -import static java.util.Objects.requireNonNull; - -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; -import org.opendaylight.yangtools.concepts.Path; -import org.opendaylight.yangtools.yang.common.RpcError.ErrorType; -import org.opendaylight.yangtools.yang.common.RpcResultBuilder; - -/** - * Failure of asynchronous transaction commit caused by invalid data. - * - *

- * This exception is raised and returned when transaction commit - * failed, because other data submitted via transactions. - * - *

- * Clients usually are not able recover from this error condition by - * retrieving same transaction, since data introduced by this transaction - * are invalid. - * - * @deprecated Use {@link org.opendaylight.mdsal.common.api.DataValidationFailedException} instead. - */ -@Deprecated(forRemoval = true) -public class DataValidationFailedException extends TransactionCommitFailedException { - - private static final long serialVersionUID = 1L; - - @SuppressFBWarnings("SE_BAD_FIELD") - private final Path path; - - private final Class> pathType; - - public

> DataValidationFailedException(final Class

pathType,final P path, - final String message, final Throwable cause) { - super(message, cause, RpcResultBuilder.newError(ErrorType.APPLICATION, "invalid-value", message, null, - path != null ? path.toString() : null, cause)); - this.pathType = requireNonNull(pathType, "path type must not be null"); - this.path = requireNonNull(path,"path must not be null."); - } - - public

> DataValidationFailedException(final Class

pathType,final P path, - final String message) { - this(pathType, path, message, null); - } - - public final Path getPath() { - return path; - } - - public final Class> getPathType() { - return pathType; - } -} diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/LogicalDatastoreType.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/LogicalDatastoreType.java deleted file mode 100644 index c72be1c5d7..0000000000 --- a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/LogicalDatastoreType.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.common.api.data; - -import org.eclipse.jdt.annotation.NonNullByDefault; - -@Deprecated(forRemoval = true) -@NonNullByDefault -public enum LogicalDatastoreType { - /** - * Logical atastore representing operational state of the system - * and it's components - * - *

- * This datastore is used to describe operational state of - * the system and it's operation related data. - * - */ - OPERATIONAL { - @Override - public org.opendaylight.mdsal.common.api.LogicalDatastoreType toMdsal() { - return org.opendaylight.mdsal.common.api.LogicalDatastoreType.OPERATIONAL; - } - }, - /** - * Logical Datastore representing configuration state of the system - * and it's components. - * - *

- * This datastore is used to describe intended state of - * the system and intended operation mode. - * - */ - CONFIGURATION { - @Override - public org.opendaylight.mdsal.common.api.LogicalDatastoreType toMdsal() { - return org.opendaylight.mdsal.common.api.LogicalDatastoreType.CONFIGURATION; - } - }; - - /** - * Convert this logical datastore type to its MD-SAL counterpart. - * - * @return MD-SAL counterpart of this type. - */ - public abstract org.opendaylight.mdsal.common.api.LogicalDatastoreType toMdsal(); - - /** - * Convert MD-SAL logical datastore type to this counterpart. - * - * @param type MD-SAL counterpart of this type. - * @return Corresponding value in this type. - */ - public static LogicalDatastoreType fromMdsal(final org.opendaylight.mdsal.common.api.LogicalDatastoreType type) { - switch (type) { - case CONFIGURATION: - return CONFIGURATION; - case OPERATIONAL: - return OPERATIONAL; - default: - throw new IllegalArgumentException("Unhandled type " + type); - } - } -} diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/OptimisticLockFailedException.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/OptimisticLockFailedException.java deleted file mode 100644 index afc6677434..0000000000 --- a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/OptimisticLockFailedException.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.md.sal.common.api.data; - -import org.opendaylight.yangtools.yang.common.RpcError.ErrorType; -import org.opendaylight.yangtools.yang.common.RpcResultBuilder; - -/** -* Failure of asynchronous transaction commit caused by failure -* of optimistic locking. -* -*

-* This exception is raised and returned when transaction commit -* failed, because other transaction finished successfully -* and modified same data as failed transaction. -* -*

-* Clients may recover from this error condition by -* retrieving current state and submitting new updated -* transaction. -* - * @deprecated Use {@link org.opendaylight.mdsal.common.api.OptimisticLockFailedException} instead. -*/ -@Deprecated(forRemoval = true) -public class OptimisticLockFailedException extends TransactionCommitFailedException { - - private static final long serialVersionUID = 1L; - - public OptimisticLockFailedException(final String message, final Throwable cause) { - super(message, cause, RpcResultBuilder.newError(ErrorType.APPLICATION, "resource-denied", - message, null, null, cause)); - } - - public OptimisticLockFailedException(final String message) { - this(message, null); - } -} diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/ReadFailedException.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/ReadFailedException.java deleted file mode 100644 index 98ad8ed132..0000000000 --- a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/ReadFailedException.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2014 Brocade Communications Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.md.sal.common.api.data; - -import org.opendaylight.yangtools.util.concurrent.ExceptionMapper; -import org.opendaylight.yangtools.yang.common.OperationFailedException; -import org.opendaylight.yangtools.yang.common.RpcError; - -/** - * An exception for a failed read. - * - * @deprecated Use {@link org.opendaylight.mdsal.common.api.ReadFailedException} instead. - */ -@Deprecated(forRemoval = true) -public class ReadFailedException extends OperationFailedException { - - private static final long serialVersionUID = 1L; - - public static final ExceptionMapper MAPPER = - new ExceptionMapper("read", ReadFailedException.class) { - @Override - protected ReadFailedException newWithCause(String message, Throwable cause) { - return new ReadFailedException(message, cause); - } - }; - - public ReadFailedException(String message, RpcError... errors) { - super(message, errors); - } - - public ReadFailedException(String message, Throwable cause, RpcError... errors) { - super(message, cause, errors); - } -} diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/TransactionChain.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/TransactionChain.java deleted file mode 100644 index 68e8dbf4d9..0000000000 --- a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/TransactionChain.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.common.api.data; - -import org.opendaylight.yangtools.concepts.Path; - -/** - * A chain of transactions. Transactions in a chain need to be committed in - * sequence and each transaction should see the effects of previous committed transactions - * as they occurred. A chain makes no guarantees of atomicity across the chained transactions - - * the transactions are committed as soon as possible in the order that they were submitted. - * - *

- * This behaviour is different from the default AsyncDataBroker, where a - * transaction is always created from the current global state, not taking into - * account any transactions previously committed by the calling thread. Due to - * the asynchronous nature of transaction submission this can lead to surprising - * results. If a thread executes the following sequence sufficiently quickly: - * - *

- * AsyncWriteTransaction t1 = broker.newWriteOnlyTransaction(); - * t1.put(id, data); - * t1.submit(); - * - *

- * AsyncReadTransaction t2 = broker.newReadOnlyTransaction(); - * Optional<?> maybeData = t2.read(id).get(); - * - *

- * it may happen, that it sees maybeData.isPresent() == false, simply because - * t1 has not completed the processes of being applied and t2 is actually - * allocated from the previous state. This is obviously bad for users who create - * incremental state in the datastore and actually read what they write in - * subsequent transactions. - * - *

- * Using a TransactionChain instead of a broker solves this particular problem, - * and leads to expected behavior: t2 will always see the data written in t1 - * present. - */ -@Deprecated(forRemoval = true) -public interface TransactionChain

, D> extends AutoCloseable, AsyncDataTransactionFactory { - - /** - * Create a new read only transaction which will continue the chain. - * - *

- * The previous write transaction has to be either SUBMITTED - * ({@link AsyncWriteTransaction#submit submit} was invoked) or CANCELLED - * ({@link #close close} was invoked). - * - *

- * The returned read-only transaction presents an isolated view of the data if the previous - * write transaction was successful - in other words, this read-only transaction will see the - * state changes made by the previous write transaction in the chain. However, state which - * was introduced by other transactions outside this transaction chain after creation of - * the previous transaction is not visible. - * - * @return New transaction in the chain. - * @throws IllegalStateException - * if the previous transaction was not SUBMITTED or CANCELLED. - * @throws TransactionChainClosedException - * if the chain has been closed. - */ - @Override - AsyncReadOnlyTransaction newReadOnlyTransaction(); - - /** - * Create a new read-write transaction which will continue the chain. - * - *

- * The previous write transaction has to be either SUBMITTED - * ({@link AsyncWriteTransaction#submit submit} was invoked) or CANCELLED - * ({@link #close close} was invoked). - * - *

- * The returned read-write transaction presents an isolated view of the data if the previous - * write transaction was successful - in other words, this read-write transaction will see the - * state changes made by the previous write transaction in the chain. However, state which - * was introduced by other transactions outside this transaction chain after creation of - * the previous transaction is not visible. - * - *

- * Committing this read-write transaction using {@link AsyncWriteTransaction#submit submit} - * will submit the state changes in this transaction to be visible to any subsequent - * transaction in this chain and also to any transaction outside this chain. - * - * @return New transaction in the chain. - * @throws IllegalStateException - * if the previous transaction was not SUBMITTED or CANCELLED. - * @throws TransactionChainClosedException - * if the chain has been closed. - */ - @Override - AsyncReadWriteTransaction newReadWriteTransaction(); - - /** - * Create a new write-only transaction which will continue the chain. - * - *

- * The previous write transaction has to be either SUBMITTED - * ({@link AsyncWriteTransaction#submit submit} was invoked) or CANCELLED - * ({@link #close close} was invoked). - * - *

- * The returned write-only transaction presents an isolated view of the data if the previous - * write transaction was successful - in other words, this write-only transaction will see the - * state changes made by the previous write transaction in the chain. However, state which - * was introduced by other transactions outside this transaction chain after creation of - * the previous transaction is not visible. - * - *

- * Committing this write-only transaction using {@link AsyncWriteTransaction#submit submit} - * will submit the state changes in this transaction to be visible to any subsequent - * transaction in this chain and also to any transaction outside this chain. - * - * @return New transaction in the chain. - * @throws IllegalStateException - * if the previous transaction was not SUBMITTED or CANCELLED. - * @throws TransactionChainClosedException - * if the chain has been closed. - */ - @Override - AsyncWriteTransaction newWriteOnlyTransaction(); - - @Override - void close(); -} diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/TransactionChainClosedException.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/TransactionChainClosedException.java deleted file mode 100644 index e2d8fa0011..0000000000 --- a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/TransactionChainClosedException.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.common.api.data; - -/** - * Exception thrown when an attempt is made to open a new transaction in a closed chain. - */ -@Deprecated(forRemoval = true) -public final class TransactionChainClosedException extends IllegalStateException { - private static final long serialVersionUID = 1L; - - public TransactionChainClosedException(final String message) { - super(message); - } - - public TransactionChainClosedException(final String message, final Throwable cause) { - super(message, cause); - } -} diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/TransactionChainFactory.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/TransactionChainFactory.java deleted file mode 100644 index 1e312184ed..0000000000 --- a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/TransactionChainFactory.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.common.api.data; - -import org.opendaylight.yangtools.concepts.Path; - -/** - * Interface for creating transaction chains. - */ -@Deprecated(forRemoval = true) -public interface TransactionChainFactory

, D> { - - /** - * Create a new transaction chain. The chain will be initialized to read - * from its backing datastore, with no outstanding transaction. Listener - * will be registered to handle chain-level events. - * - * @param listener Transaction chain event listener - * @return A new transaction chain. - */ - TransactionChain createTransactionChain(TransactionChainListener listener); -} - diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/TransactionChainListener.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/TransactionChainListener.java deleted file mode 100644 index c27ef75c70..0000000000 --- a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/TransactionChainListener.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.common.api.data; - -import java.util.EventListener; - -/** - * Listener for transaction chain events. - */ -@Deprecated(forRemoval = true) -public interface TransactionChainListener extends EventListener { - /** - * Invoked if when a transaction in the chain fails. All other transactions are automatically cancelled by the time - * this notification is invoked. Implementations should invoke chain.close() to close the chain. - * - * @param chain Transaction chain which failed - * @param transaction Transaction which caused the chain to fail - * @param cause The cause of transaction failure - */ - void onTransactionChainFailed(TransactionChain chain, AsyncTransaction transaction, Throwable cause); - - /** - * Invoked when a transaction chain is completed. A transaction chain is considered completed when it has been - * closed and all its instructions have completed successfully. - * - * @param chain Transaction chain which completed - */ - void onTransactionChainSuccessful(TransactionChain chain); -} - diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/TransactionCommitDeadlockException.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/TransactionCommitDeadlockException.java deleted file mode 100644 index f7b6102651..0000000000 --- a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/TransactionCommitDeadlockException.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2014 Brocade Communications Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.md.sal.common.api.data; - -import com.google.common.base.Supplier; -import org.opendaylight.yangtools.yang.common.RpcError; -import org.opendaylight.yangtools.yang.common.RpcError.ErrorType; -import org.opendaylight.yangtools.yang.common.RpcResultBuilder; - -/** - * A type of TransactionCommitFailedException that indicates a situation that would result in a - * threading deadlock. This can occur if a caller that submits a write transaction tries to perform - * a blocking call via one of the get methods on the returned ListenableFuture. Callers - * should process the commit result asynchronously (via Futures#addCallback) to ensure deadlock - * won't occur. - * - * @author Thomas Pantelis - * - * @deprecated Use {@link org.opendaylight.mdsal.common.api.TransactionCommitDeadlockException} instead. - */ -@Deprecated(forRemoval = true) -public class TransactionCommitDeadlockException extends TransactionCommitFailedException { - private static final long serialVersionUID = 1L; - private static final String DEADLOCK_MESSAGE = - "An attempt to block on a ListenableFuture via a get method from a write " - + "transaction submit was detected that would result in deadlock. The commit " - + "result must be obtained asynchronously, e.g. via Futures#addCallback, to avoid deadlock."; - private static final RpcError DEADLOCK_RPCERROR = RpcResultBuilder.newError(ErrorType.APPLICATION, - "lock-denied", DEADLOCK_MESSAGE); - - public static final Supplier DEADLOCK_EXCEPTION_SUPPLIER = - () -> new TransactionCommitDeadlockException(DEADLOCK_MESSAGE, DEADLOCK_RPCERROR); - - public TransactionCommitDeadlockException(final String message, final RpcError... errors) { - super(message, errors); - } -} diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/TransactionCommitFailedException.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/TransactionCommitFailedException.java deleted file mode 100644 index be92b9274d..0000000000 --- a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/TransactionCommitFailedException.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.common.api.data; - -import org.opendaylight.yangtools.yang.common.OperationFailedException; -import org.opendaylight.yangtools.yang.common.RpcError; - -/** - * Failed commit of asynchronous transaction. This exception is raised and returned when transaction commit failed. - * - * @deprecated Use {@link org.opendaylight.mdsal.common.api.TransactionCommitFailedException} instead. - */ -@Deprecated(forRemoval = true) -public class TransactionCommitFailedException extends OperationFailedException { - - private static final long serialVersionUID = 1L; - - public TransactionCommitFailedException(final String message, final RpcError... errors) { - this(message, null, errors); - } - - public TransactionCommitFailedException(final String message, final Throwable cause, - final RpcError... errors) { - super(message, cause, errors); - } -} diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/notify/NotificationPublishService.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/notify/NotificationPublishService.java deleted file mode 100644 index 40d17f6aba..0000000000 --- a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/notify/NotificationPublishService.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.common.api.notify; - -import java.util.concurrent.ExecutorService; - -/** - * Interface for publishing YANG-modeled notifications. - * - *

- * Users of this interface can publish any YANG-modeled notification which will - * be delivered to all subscribed listeners. - * - *

- * Preferred way of publishing of notifications is done by invoking {@link #publish(Object)}. - * - *

You may consider using {@link #publish(Object, ExecutorService)} if and only if - * your use-case requires customized execution policy or run-to-completion - * inside process. - * - *

- * The metadata required to deliver a notification to the correct listeners is - * extracted from the published notification. - * - *

- * FIXME: Consider clarification of execution/delivery policy, how it will be - * affected by Actor model and cluster-wide notifications. - * - * @param the type of notifications - */ -@Deprecated(forRemoval = true) -public interface NotificationPublishService { - - /** - * Publishes a notification and notifies subscribed listeners. All listener - * notifications are done via a default executor. - * - *

- * Note: This call will block when the default executor is saturated - * and the notification queue for this executor is full. - * - * @param notification - * the notification to publish. - */ - void publish(N notification); - - /** - * Publishes a notification and notifies subscribed listeners. All listener - * notifications are done via the provided executor. - * - *

- * Note: Use only if necessary. Consider using - * {@link #publish(Object)} for most use-cases. - * - *

- * By using this method you could customize execution policy of listeners present - * inside process (e.g. using single-threaded executor or even same-thread executor - * delivery. - * - *

- * This executor is used only for inside-process notification deliveries. - * - * @param notification - * the notification to publish. - * @param executor - * the executor that will be used to deliver notifications to - * subscribed listeners. - */ - void publish(N notification, ExecutorService executor); -} diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/notify/NotificationSubscriptionService.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/notify/NotificationSubscriptionService.java deleted file mode 100644 index 81879ec52e..0000000000 --- a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/notify/NotificationSubscriptionService.java +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.common.api.notify; - -import java.util.EventListener; -import org.opendaylight.yangtools.concepts.ListenerRegistration; - -@Deprecated(forRemoval = true) -public interface NotificationSubscriptionService { - - ListenerRegistration registerNotificationListener(T type, L listener); -} diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/routing/RouteChange.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/routing/RouteChange.java deleted file mode 100644 index 74bc57f575..0000000000 --- a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/routing/RouteChange.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.common.api.routing; - -import java.util.Map; -import java.util.Set; - -/** - * Event representing change in RPC routing table. - * - * - * @param Type, which is used to represent Routing context. - * @param

Type of data tree path, which is used to identify route. - */ -@Deprecated(forRemoval = true) -public interface RouteChange { - - /** - * Returns a map of removed routes in associated routing contexts. - * - *

- * This map represents routes, which were withdrawn from broker local - * routing table and broker may need to forward RPC to other broker - * in order to process RPC request. - * - * @return Map of contexts and removed routes - */ - Map> getRemovals(); - - /** - * Returns a map of announced routes in associated routing contexts. - * - *

- * This map represents routes, which were announced by broker - * and are present in broker's local routing table. This routes - * are processed by implementations which are registered - * to originating broker. - * - * @return Map of contexts and announced routes - */ - Map> getAnnouncements(); -} diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/routing/RouteChangeListener.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/routing/RouteChangeListener.java deleted file mode 100644 index e996a67acb..0000000000 --- a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/routing/RouteChangeListener.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.common.api.routing; - -import java.util.EventListener; - -/** - * Listener which is interested in receiving RouteChangeEvents for its local broker. - * - *

- * Listener is registered via {@link RouteChangePublisher#registerRouteChangeListener(RouteChangeListener)} - * - * @param Type, which is used to represent Routing context. - * @param

Type of data tree path, which is used to identify route. - */ -@Deprecated(forRemoval = true) -public interface RouteChangeListener extends EventListener { - - /** - * Callback which is invoked if there is an rpc routing table change. - * - * @param change Event representing change in local RPC routing table. - */ - void onRouteChange(RouteChange change); -} diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/routing/RouteChangePublisher.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/routing/RouteChangePublisher.java deleted file mode 100644 index a8e1bb1d02..0000000000 --- a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/routing/RouteChangePublisher.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.common.api.routing; - -import org.opendaylight.yangtools.concepts.ListenerRegistration; - -/** - * Publishes changes in local RPC routing table to registered listener. - * - * @param Type, which is used to represent Routing context. - * @param

Type of data tree path, which is used to identify route. - */ -@Deprecated(forRemoval = true) -public interface RouteChangePublisher { - - > ListenerRegistration registerRouteChangeListener(L listener); -} diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/routing/RoutedRegistration.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/routing/RoutedRegistration.java deleted file mode 100644 index e1b6d7b55b..0000000000 --- a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/routing/RoutedRegistration.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.common.api.routing; - -import org.opendaylight.yangtools.concepts.Path; -import org.opendaylight.yangtools.concepts.Registration; - -/** - * Base interface for a routed RPC RPC implementation registration. - * - * @param the context type used for routing - * @param

the path identifier type - * @param the RPC implementation type - */ -@Deprecated(forRemoval = true) -public interface RoutedRegistration, S> extends Registration { - - /** - * Registers the RPC implementation associated with this registration for the given path - * identifier and context. - * - * @param context the context used for routing RPCs to this implementation. - * @param path the path identifier for which to register. - */ - void registerPath(C context, P path); - - /** - * Unregisters the RPC implementation associated with this registration for the given path - * identifier and context. - * - * @param context the context used for routing RPCs to this implementation. - * @param path the path identifier for which to unregister. - */ - void unregisterPath(C context, P path); - - @Override - void close(); -} diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/routing/RoutingTable.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/routing/RoutingTable.java deleted file mode 100644 index 8465303168..0000000000 --- a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/routing/RoutingTable.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.common.api.routing; - -import java.util.Map; -import org.opendaylight.yangtools.concepts.Path; - -@Deprecated(forRemoval = true) -public interface RoutingTable, T> { - - C getIdentifier(); - - T getDefaultRoute(); - - Map getRoutes(); - - T getRoute(P path); -} diff --git a/opendaylight/md-sal/sal-common-api/src/test/java/org/opendaylight/controller/md/sal/common/api/MappingCheckedFutureTest.java b/opendaylight/md-sal/sal-common-api/src/test/java/org/opendaylight/controller/md/sal/common/api/MappingCheckedFutureTest.java deleted file mode 100644 index 99be312c6c..0000000000 --- a/opendaylight/md-sal/sal-common-api/src/test/java/org/opendaylight/controller/md/sal/common/api/MappingCheckedFutureTest.java +++ /dev/null @@ -1,241 +0,0 @@ -/* - * Copyright (c) 2014 Brocade Communications Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.common.api; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import com.google.common.util.concurrent.CheckedFuture; -import com.google.common.util.concurrent.SettableFuture; -import java.util.concurrent.CancellationException; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicReference; -import org.junit.Test; -import org.opendaylight.yangtools.util.concurrent.ExceptionMapper; - -/** - * Unit tests for MappingCheckedFuture. - * - * @author Thomas Pantelis - */ -@Deprecated -public class MappingCheckedFutureTest { - - interface FutureInvoker { - void invokeGet(CheckedFuture future) throws Exception; - - Throwable extractWrappedTestEx(Exception from); - } - - static class TestException extends Exception { - private static final long serialVersionUID = 1L; - - TestException(final String message, final Throwable cause) { - super(message, cause); - } - } - - static final ExceptionMapper MAPPER = new ExceptionMapper( - "Test", TestException.class) { - - @Override - protected TestException newWithCause(final String message, final Throwable cause) { - return new TestException(message, cause); - } - }; - - static final FutureInvoker GET = new FutureInvoker() { - @Override - public void invokeGet(final CheckedFuture future) throws Exception { - future.get(); - } - - @Override - public Throwable extractWrappedTestEx(final Exception from) { - if (from instanceof ExecutionException) { - return from.getCause(); - } - - return from; - } - }; - - static final FutureInvoker TIMED_GET = new FutureInvoker() { - @Override - public void invokeGet(final CheckedFuture future) throws Exception { - future.get(1, TimeUnit.HOURS); - } - - @Override - public Throwable extractWrappedTestEx(final Exception from) { - if (from instanceof ExecutionException) { - return from.getCause(); - } - - return from; - } - }; - - static final FutureInvoker CHECKED_GET = new FutureInvoker() { - @Override - public void invokeGet(final CheckedFuture future) throws Exception { - future.checkedGet(); - } - - @Override - public Throwable extractWrappedTestEx(final Exception from) { - return from; - } - }; - - static final FutureInvoker TIMED_CHECKED_GET = new FutureInvoker() { - @Override - public void invokeGet(final CheckedFuture future) throws Exception { - future.checkedGet(50, TimeUnit.MILLISECONDS); - } - - @Override - public Throwable extractWrappedTestEx(final Exception from) { - return from; - } - }; - - @Test - public void testGet() throws Exception { - SettableFuture delegate = SettableFuture.create(); - MappingCheckedFuture future = MappingCheckedFuture.create(delegate, MAPPER); - delegate.set("test"); - assertEquals("get", "test", future.get()); - } - - @Test - public void testGetWithExceptions() throws Exception { - testExecutionException(GET, new RuntimeException()); - testExecutionException(GET, new TestException("mock", null)); - testCancellationException(GET); - testInterruptedException(GET); - } - - @Test - public void testTimedGet() throws Exception { - SettableFuture delegate = SettableFuture.create(); - MappingCheckedFuture future = MappingCheckedFuture.create(delegate, MAPPER); - delegate.set("test"); - assertEquals("get", "test", future.get(50, TimeUnit.MILLISECONDS)); - } - - @Test - public void testTimedGetWithExceptions() throws Exception { - testExecutionException(TIMED_GET, new RuntimeException()); - testCancellationException(TIMED_GET); - testInterruptedException(TIMED_GET); - } - - @Test - public void testCheckedGetWithExceptions() throws Exception { - testExecutionException(CHECKED_GET, new RuntimeException()); - testCancellationException(CHECKED_GET); - testInterruptedException(CHECKED_GET); - } - - @Test - public void testTimedCheckedWithExceptions() throws Exception { - testExecutionException(TIMED_CHECKED_GET, new RuntimeException()); - testCancellationException(TIMED_CHECKED_GET); - testInterruptedException(TIMED_CHECKED_GET); - } - - @SuppressWarnings("checkstyle:illegalCatch") - private static void testExecutionException(final FutureInvoker invoker, final Throwable cause) { - SettableFuture delegate = SettableFuture.create(); - MappingCheckedFuture mappingFuture = MappingCheckedFuture.create(delegate, MAPPER); - - delegate.setException(cause); - - try { - invoker.invokeGet(mappingFuture); - fail("Expected exception thrown"); - } catch (Exception e) { - Throwable expectedTestEx = invoker.extractWrappedTestEx(e); - assertNotNull("Expected returned exception is null", expectedTestEx); - assertEquals("Exception type", TestException.class, expectedTestEx.getClass()); - - if (cause instanceof TestException) { - assertNull("Expected null cause", expectedTestEx.getCause()); - } else { - assertSame("TestException cause", cause, expectedTestEx.getCause()); - } - } - } - - @SuppressWarnings("checkstyle:illegalCatch") - private static void testCancellationException(final FutureInvoker invoker) { - SettableFuture delegate = SettableFuture.create(); - MappingCheckedFuture mappingFuture = MappingCheckedFuture.create(delegate, MAPPER); - - mappingFuture.cancel(false); - - try { - invoker.invokeGet(mappingFuture); - fail("Expected exception thrown"); - } catch (Exception e) { - Throwable expectedTestEx = invoker.extractWrappedTestEx(e); - assertNotNull("Expected returned exception is null", expectedTestEx); - assertEquals("Exception type", TestException.class, expectedTestEx.getClass()); - assertEquals("TestException cause type", CancellationException.class, expectedTestEx.getCause().getClass()); - } - } - - @SuppressWarnings("checkstyle:illegalCatch") - private static void testInterruptedException(final FutureInvoker invoker) throws Exception { - SettableFuture delegate = SettableFuture.create(); - final MappingCheckedFuture mappingFuture = MappingCheckedFuture.create(delegate, MAPPER); - - final AtomicReference assertError = new AtomicReference<>(); - final CountDownLatch doneLatch = new CountDownLatch(1); - Thread thread = new Thread() { - @Override - public void run() { - try { - doInvoke(); - } catch (AssertionError e) { - assertError.set(e); - } finally { - doneLatch.countDown(); - } - } - - void doInvoke() { - try { - invoker.invokeGet(mappingFuture); - fail("Expected exception thrown"); - } catch (Exception e) { - Throwable expectedTestEx = invoker.extractWrappedTestEx(e); - assertNotNull("Expected returned exception is null", expectedTestEx); - assertEquals("Exception type", TestException.class, expectedTestEx.getClass()); - assertEquals("TestException cause type", InterruptedException.class, - expectedTestEx.getCause().getClass()); - } - } - }; - thread.start(); - - thread.interrupt(); - assertTrue("get call completed", doneLatch.await(5, TimeUnit.SECONDS)); - - if (assertError.get() != null) { - throw assertError.get(); - } - } -} diff --git a/opendaylight/md-sal/sal-common-impl/pom.xml b/opendaylight/md-sal/sal-common-impl/pom.xml deleted file mode 100644 index a6f1be8599..0000000000 --- a/opendaylight/md-sal/sal-common-impl/pom.xml +++ /dev/null @@ -1,67 +0,0 @@ - - - 4.0.0 - - org.opendaylight.controller - mdsal-parent - 1.12.0-SNAPSHOT - ../parent - - - org.opendaylight.controller - sal-common-impl - 1.12.0-SNAPSHOT - bundle - - - - org.opendaylight.controller - sal-common-api - - - org.opendaylight.controller - sal-common-util - - - org.opendaylight.yangtools - yang-data-impl - - - org.opendaylight.yangtools - yang-model-api - - - org.mockito - mockito-core - test - - - org.opendaylight.yangtools - yang-parser-impl - test - - - - - - - org.apache.felix - maven-bundle-plugin - - - org.opendaylight.controller.md.sal.common.impl, - org.opendaylight.controller.md.sal.common.impl.* - - - - - - - - scm:git:http://git.opendaylight.org/gerrit/controller.git - scm:git:ssh://git.opendaylight.org:29418/controller.git - HEAD - https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL - - - diff --git a/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/util/compat/DataNormalizationException.java b/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/util/compat/DataNormalizationException.java deleted file mode 100644 index 2780e584fd..0000000000 --- a/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/util/compat/DataNormalizationException.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.common.impl.util.compat; - -@Deprecated(forRemoval = true) -public class DataNormalizationException extends Exception { - private static final long serialVersionUID = 1L; - - public DataNormalizationException(String message) { - super(message); - } - - public DataNormalizationException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/util/compat/DataNormalizationOperation.java b/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/util/compat/DataNormalizationOperation.java deleted file mode 100644 index c9713837a2..0000000000 --- a/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/util/compat/DataNormalizationOperation.java +++ /dev/null @@ -1,607 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.common.impl.util.compat; - -import com.google.common.base.Optional; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import org.eclipse.jdt.annotation.Nullable; -import org.gaul.modernizer_maven_annotations.SuppressModernizer; -import org.opendaylight.yangtools.concepts.Identifiable; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; -import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.data.impl.schema.Builders; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder; -import org.opendaylight.yangtools.yang.model.api.AnyxmlSchemaNode; -import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode; -import org.opendaylight.yangtools.yang.model.api.AugmentationTarget; -import org.opendaylight.yangtools.yang.model.api.CaseSchemaNode; -import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode; -import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; -import org.opendaylight.yangtools.yang.model.api.DataNodeContainer; -import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; -import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode; -import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode; -import org.opendaylight.yangtools.yang.model.api.ListSchemaNode; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.opendaylight.yangtools.yang.model.api.SchemaNode; -import org.opendaylight.yangtools.yang.model.util.EffectiveAugmentationSchema; - -@Deprecated(forRemoval = true) -public abstract class DataNormalizationOperation implements Identifiable { - - private final T identifier; - private final DataSchemaNode dataSchemaNode; - - @Override - public T getIdentifier() { - return identifier; - } - - protected DataNormalizationOperation(final T identifier, final SchemaNode schema) { - this.identifier = identifier; - dataSchemaNode = schema instanceof DataSchemaNode ? (DataSchemaNode)schema : null; - } - - public boolean isMixin() { - return false; - } - - - public boolean isKeyedEntry() { - return false; - } - - protected Set getQNameIdentifiers() { - return Collections.singleton(identifier.getNodeType()); - } - - public abstract DataNormalizationOperation getChild(PathArgument child) throws DataNormalizationException; - - public abstract DataNormalizationOperation getChild(QName child) throws DataNormalizationException; - - public abstract boolean isLeaf(); - - @SuppressModernizer - public Optional getDataSchemaNode() { - return Optional.fromNullable(dataSchemaNode); - } - - private abstract static class SimpleTypeNormalization - extends DataNormalizationOperation { - SimpleTypeNormalization(final T identifier, final DataSchemaNode potential) { - super(identifier,potential); - } - - @Override - public DataNormalizationOperation getChild(final PathArgument child) { - return null; - } - - @Override - public DataNormalizationOperation getChild(final QName child) { - return null; - } - - @Override - public NormalizedNode createDefault(final PathArgument currentArg) { - return null; - } - - @Override - public boolean isLeaf() { - return true; - } - } - - private static final class LeafNormalization extends SimpleTypeNormalization { - LeafNormalization(final LeafSchemaNode potential) { - super(new NodeIdentifier(potential.getQName()),potential); - } - } - - private static final class LeafListEntryNormalization extends SimpleTypeNormalization { - LeafListEntryNormalization(final LeafListSchemaNode potential) { - super(new NodeWithValue(potential.getQName(), null),potential); - } - - @Override - public boolean isKeyedEntry() { - return true; - } - } - - private abstract static class CompositeNodeNormalizationOperation - extends DataNormalizationOperation { - CompositeNodeNormalizationOperation(final T identifier, final DataSchemaNode schema) { - super(identifier,schema); - } - - @Override - public boolean isLeaf() { - return false; - } - } - - private abstract static class DataContainerNormalizationOperation - extends CompositeNodeNormalizationOperation { - private final DataNodeContainer schema; - private final Map> byQName; - private final Map> byArg; - - DataContainerNormalizationOperation(final T identifier, final DataNodeContainer schema, - final DataSchemaNode node) { - super(identifier,node); - this.schema = schema; - this.byArg = new ConcurrentHashMap<>(); - this.byQName = new ConcurrentHashMap<>(); - } - - @Override - public DataNormalizationOperation getChild(final PathArgument child) throws DataNormalizationException { - DataNormalizationOperation potential = byArg.get(child); - if (potential != null) { - return potential; - } - potential = fromLocalSchema(child); - return register(potential); - } - - @Override - public DataNormalizationOperation getChild(final QName child) throws DataNormalizationException { - DataNormalizationOperation potential = byQName.get(child); - if (potential != null) { - return potential; - } - potential = fromLocalSchemaAndQName(schema, child); - return register(potential); - } - - private DataNormalizationOperation fromLocalSchema(final PathArgument child) - throws DataNormalizationException { - if (child instanceof AugmentationIdentifier) { - return fromSchemaAndQNameChecked(schema, ((AugmentationIdentifier) child).getPossibleChildNames() - .iterator().next()); - } - return fromSchemaAndQNameChecked(schema, child.getNodeType()); - } - - protected DataNormalizationOperation fromLocalSchemaAndQName(final DataNodeContainer schema2, - final QName child) throws DataNormalizationException { - return fromSchemaAndQNameChecked(schema2, child); - } - - private DataNormalizationOperation register(final DataNormalizationOperation potential) { - if (potential != null) { - byArg.put(potential.getIdentifier(), potential); - for (final QName qname : potential.getQNameIdentifiers()) { - byQName.put(qname, potential); - } - } - return potential; - } - - private static DataNormalizationOperation fromSchemaAndQNameChecked(final DataNodeContainer schema, - final QName child) throws DataNormalizationException { - - final DataSchemaNode result = findChildSchemaNode(schema, child); - if (result == null) { - throw new DataNormalizationException(String.format( - "Supplied QName %s is not valid according to schema %s, potential children nodes: %s", child, - schema,schema.getChildNodes())); - } - - // We try to look up if this node was added by augmentation - if (schema instanceof DataSchemaNode && result.isAugmenting()) { - return fromAugmentation(schema, (AugmentationTarget) schema, result); - } - return fromDataSchemaNode(result); - } - } - - private static final class ListItemNormalization extends - DataContainerNormalizationOperation { - ListItemNormalization(final NodeIdentifierWithPredicates identifier, final ListSchemaNode schema) { - super(identifier, schema, schema); - } - - @Override - @SuppressFBWarnings("BC_UNCONFIRMED_CAST") - public NormalizedNode createDefault(final PathArgument currentArg) { - final DataContainerNodeBuilder builder = Builders - .mapEntryBuilder().withNodeIdentifier((NodeIdentifierWithPredicates) currentArg); - for (final Entry keyValue : ((NodeIdentifierWithPredicates) currentArg).entrySet()) { - builder.addChild(Builders.leafBuilder() - // - .withNodeIdentifier(new NodeIdentifier(keyValue.getKey())).withValue(keyValue.getValue()) - .build()); - } - return builder.build(); - } - - @Override - public boolean isKeyedEntry() { - return true; - } - } - - private static final class UnkeyedListItemNormalization - extends DataContainerNormalizationOperation { - UnkeyedListItemNormalization(final ListSchemaNode schema) { - super(new NodeIdentifier(schema.getQName()), schema,schema); - } - - @Override - @SuppressFBWarnings("BC_UNCONFIRMED_CAST") - public NormalizedNode createDefault(final PathArgument currentArg) { - return Builders.unkeyedListEntryBuilder().withNodeIdentifier((NodeIdentifier) currentArg).build(); - } - } - - private static final class ContainerNormalization extends DataContainerNormalizationOperation { - ContainerNormalization(final ContainerSchemaNode schema) { - super(new NodeIdentifier(schema.getQName()),schema, schema); - } - - @Override - @SuppressFBWarnings("BC_UNCONFIRMED_CAST") - public NormalizedNode createDefault(final PathArgument currentArg) { - return Builders.containerBuilder().withNodeIdentifier((NodeIdentifier) currentArg).build(); - } - } - - private abstract static class MixinNormalizationOp - extends CompositeNodeNormalizationOperation { - - MixinNormalizationOp(final T identifier, final DataSchemaNode schema) { - super(identifier,schema); - } - - @Override - public final boolean isMixin() { - return true; - } - } - - private static final class OrderedLeafListMixinNormalization extends UnorderedLeafListMixinNormalization { - OrderedLeafListMixinNormalization(final LeafListSchemaNode potential) { - super(potential); - } - - @Override - public NormalizedNode createDefault(final PathArgument currentArg) { - return Builders.orderedLeafSetBuilder().withNodeIdentifier(getIdentifier()).build(); - } - } - - private static class UnorderedLeafListMixinNormalization extends MixinNormalizationOp { - - private final DataNormalizationOperation innerOp; - - UnorderedLeafListMixinNormalization(final LeafListSchemaNode potential) { - super(new NodeIdentifier(potential.getQName()),potential); - innerOp = new LeafListEntryNormalization(potential); - } - - @Override - public NormalizedNode createDefault(final PathArgument currentArg) { - return Builders.leafSetBuilder().withNodeIdentifier(getIdentifier()).build(); - } - - @Override - public DataNormalizationOperation getChild(final PathArgument child) { - if (child instanceof NodeWithValue) { - return innerOp; - } - return null; - } - - @Override - public DataNormalizationOperation getChild(final QName child) { - if (getIdentifier().getNodeType().equals(child)) { - return innerOp; - } - return null; - } - } - - private static final class AugmentationNormalization - extends DataContainerNormalizationOperation { - - AugmentationNormalization(final AugmentationSchemaNode augmentation, final DataNodeContainer schema) { - super(augmentationIdentifierFrom(augmentation), augmentationProxy(augmentation,schema),null); - } - - private static DataNodeContainer augmentationProxy(final AugmentationSchemaNode augmentation, - final DataNodeContainer schema) { - final Set children = new HashSet<>(); - for (final DataSchemaNode augNode : augmentation.getChildNodes()) { - children.add(schema.getDataChildByName(augNode.getQName())); - } - return new EffectiveAugmentationSchema(augmentation, children); - } - - @Override - public boolean isMixin() { - return true; - } - - @Override - protected DataNormalizationOperation fromLocalSchemaAndQName(final DataNodeContainer schema, - final QName child) { - final DataSchemaNode result = findChildSchemaNode(schema, child); - if (result == null) { - return null; - } - - // We try to look up if this node was added by augmentation - if (schema instanceof DataSchemaNode && result.isAugmenting()) { - return fromAugmentation(schema, (AugmentationTarget) schema, result); - } - return fromDataSchemaNode(result); - } - - @Override - protected Set getQNameIdentifiers() { - return getIdentifier().getPossibleChildNames(); - } - - @Override - public NormalizedNode createDefault(final PathArgument currentArg) { - return Builders.augmentationBuilder().withNodeIdentifier(getIdentifier()).build(); - } - } - - private static class UnorderedMapMixinNormalization extends MixinNormalizationOp { - private final ListItemNormalization innerNode; - - UnorderedMapMixinNormalization(final ListSchemaNode list) { - super(new NodeIdentifier(list.getQName()),list); - this.innerNode = new ListItemNormalization(NodeIdentifierWithPredicates.of(list.getQName(), - Collections.emptyMap()), list); - } - - @Override - public NormalizedNode createDefault(final PathArgument currentArg) { - return Builders.mapBuilder().withNodeIdentifier(getIdentifier()).build(); - } - - @Override - public DataNormalizationOperation getChild(final PathArgument child) { - if (child.getNodeType().equals(getIdentifier().getNodeType())) { - return innerNode; - } - return null; - } - - @Override - public DataNormalizationOperation getChild(final QName child) { - if (getIdentifier().getNodeType().equals(child)) { - return innerNode; - } - return null; - } - } - - private static class UnkeyedListMixinNormalization extends MixinNormalizationOp { - private final UnkeyedListItemNormalization innerNode; - - UnkeyedListMixinNormalization(final ListSchemaNode list) { - super(new NodeIdentifier(list.getQName()),list); - this.innerNode = new UnkeyedListItemNormalization(list); - } - - @Override - public NormalizedNode createDefault(final PathArgument currentArg) { - return Builders.unkeyedListBuilder().withNodeIdentifier(getIdentifier()).build(); - } - - @Override - public DataNormalizationOperation getChild(final PathArgument child) { - if (child.getNodeType().equals(getIdentifier().getNodeType())) { - return innerNode; - } - return null; - } - - @Override - public DataNormalizationOperation getChild(final QName child) { - if (getIdentifier().getNodeType().equals(child)) { - return innerNode; - } - return null; - } - } - - private static final class OrderedMapMixinNormalization extends UnorderedMapMixinNormalization { - OrderedMapMixinNormalization(final ListSchemaNode list) { - super(list); - } - - @Override - public NormalizedNode createDefault(final PathArgument currentArg) { - return Builders.orderedMapBuilder().withNodeIdentifier(getIdentifier()).build(); - } - } - - private static class ChoiceNodeNormalization extends MixinNormalizationOp { - private final ImmutableMap> byQName; - private final ImmutableMap> byArg; - - ChoiceNodeNormalization(final ChoiceSchemaNode schema) { - super(new NodeIdentifier(schema.getQName()),schema); - final ImmutableMap.Builder> byQNameBuilder = ImmutableMap.builder(); - final ImmutableMap.Builder> byArgBuilder = - ImmutableMap.builder(); - - for (final CaseSchemaNode caze : schema.getCases().values()) { - for (final DataSchemaNode cazeChild : caze.getChildNodes()) { - final DataNormalizationOperation childOp = fromDataSchemaNode(cazeChild); - byArgBuilder.put(childOp.getIdentifier(), childOp); - for (final QName qname : childOp.getQNameIdentifiers()) { - byQNameBuilder.put(qname, childOp); - } - } - } - byQName = byQNameBuilder.build(); - byArg = byArgBuilder.build(); - } - - @Override - public DataNormalizationOperation getChild(final PathArgument child) { - return byArg.get(child); - } - - @Override - public DataNormalizationOperation getChild(final QName child) { - return byQName.get(child); - } - - @Override - public NormalizedNode createDefault(final PathArgument currentArg) { - return Builders.choiceBuilder().withNodeIdentifier(getIdentifier()).build(); - } - } - - private static class AnyxmlNormalization extends DataNormalizationOperation { - AnyxmlNormalization(final AnyxmlSchemaNode schema) { - super(new NodeIdentifier(schema.getQName()), schema); - } - - @Override - public DataNormalizationOperation getChild(final PathArgument child) { - return null; - } - - @Override - public DataNormalizationOperation getChild(final QName child) { - return null; - } - - @Override - public boolean isLeaf() { - return false; - } - - @Override - public NormalizedNode createDefault(final PathArgument currentArg) { - return null; - } - } - - private static @Nullable DataSchemaNode findChildSchemaNode(final DataNodeContainer parent, final QName child) { - final DataSchemaNode potential = parent.getDataChildByName(child); - return potential != null ? potential : findChoice(parent, child); - } - - private static @Nullable ChoiceSchemaNode findChoice(final DataNodeContainer parent, final QName child) { - for (final ChoiceSchemaNode choice : Iterables.filter(parent.getChildNodes(), ChoiceSchemaNode.class)) { - for (final CaseSchemaNode caze : choice.getCases().values()) { - if (findChildSchemaNode(caze, child) != null) { - return choice; - } - } - } - return null; - } - - public static AugmentationIdentifier augmentationIdentifierFrom(final AugmentationSchemaNode augmentation) { - final ImmutableSet.Builder potentialChildren = ImmutableSet.builder(); - for (final DataSchemaNode child : augmentation.getChildNodes()) { - potentialChildren.add(child.getQName()); - } - return new AugmentationIdentifier(potentialChildren.build()); - } - - /** - * Returns a DataNormalizationOperation for provided child node. - * - *

- * If supplied child is added by Augmentation this operation returns - * a DataNormalizationOperation for augmentation, - * otherwise returns a DataNormalizationOperation for child as - * call for {@link #fromDataSchemaNode(DataSchemaNode)}. - */ - @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", - justification = "https://github.com/spotbugs/spotbugs/issues/811") - private static DataNormalizationOperation fromAugmentation(final DataNodeContainer parent, - final AugmentationTarget parentAug, final DataSchemaNode child) { - AugmentationSchemaNode augmentation = null; - for (final AugmentationSchemaNode aug : parentAug.getAvailableAugmentations()) { - final DataSchemaNode potential = aug.getDataChildByName(child.getQName()); - if (potential != null) { - augmentation = aug; - break; - } - - } - if (augmentation != null) { - return new AugmentationNormalization(augmentation, parent); - } else { - return fromDataSchemaNode(child); - } - } - - public static DataNormalizationOperation fromDataSchemaNode(final DataSchemaNode potential) { - if (potential instanceof ContainerSchemaNode) { - return new ContainerNormalization((ContainerSchemaNode) potential); - } else if (potential instanceof ListSchemaNode) { - - return fromListSchemaNode((ListSchemaNode) potential); - } else if (potential instanceof LeafSchemaNode) { - return new LeafNormalization((LeafSchemaNode) potential); - } else if (potential instanceof ChoiceSchemaNode) { - return new ChoiceNodeNormalization((ChoiceSchemaNode) potential); - } else if (potential instanceof LeafListSchemaNode) { - return fromLeafListSchemaNode((LeafListSchemaNode) potential); - } else if (potential instanceof AnyxmlSchemaNode) { - return new AnyxmlNormalization((AnyxmlSchemaNode) potential); - } - return null; - } - - private static DataNormalizationOperation fromListSchemaNode(final ListSchemaNode potential) { - final List keyDefinition = potential.getKeyDefinition(); - if (keyDefinition == null || keyDefinition.isEmpty()) { - return new UnkeyedListMixinNormalization(potential); - } - if (potential.isUserOrdered()) { - return new OrderedMapMixinNormalization(potential); - } - return new UnorderedMapMixinNormalization(potential); - } - - private static DataNormalizationOperation fromLeafListSchemaNode(final LeafListSchemaNode potential) { - if (potential.isUserOrdered()) { - return new OrderedLeafListMixinNormalization(potential); - } - return new UnorderedLeafListMixinNormalization(potential); - } - - - public static DataNormalizationOperation from(final SchemaContext ctx) { - return new ContainerNormalization(ctx); - } - - public abstract NormalizedNode createDefault(PathArgument currentArg); -} diff --git a/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/util/compat/DataNormalizer.java b/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/util/compat/DataNormalizer.java deleted file mode 100644 index 21ddd2fbba..0000000000 --- a/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/util/compat/DataNormalizer.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.common.impl.util.compat; - -import static com.google.common.base.Preconditions.checkArgument; - -import com.google.common.collect.ImmutableList; -import java.util.Iterator; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -/** - * Deprecated. - * - * @deprecated This class provides compatibility between XML semantics - * and {@link org.opendaylight.yangtools.yang.data.util.DataSchemaContextTree} - */ -@Deprecated(forRemoval = true) -public class DataNormalizer { - - private final DataNormalizationOperation operation; - - public DataNormalizer(final SchemaContext ctx) { - operation = DataNormalizationOperation.from(ctx); - } - - public YangInstanceIdentifier toNormalized(final YangInstanceIdentifier legacy) { - ImmutableList.Builder normalizedArgs = ImmutableList.builder(); - - DataNormalizationOperation currentOp = operation; - Iterator arguments = legacy.getPathArguments().iterator(); - - try { - while (arguments.hasNext()) { - PathArgument legacyArg = arguments.next(); - currentOp = currentOp.getChild(legacyArg); - checkArgument(currentOp != null, - "Legacy Instance Identifier %s is not correct. Normalized Instance Identifier so far %s", - legacy, normalizedArgs.build()); - while (currentOp.isMixin()) { - normalizedArgs.add(currentOp.getIdentifier()); - currentOp = currentOp.getChild(legacyArg.getNodeType()); - } - normalizedArgs.add(legacyArg); - } - } catch (DataNormalizationException e) { - throw new IllegalArgumentException(String.format("Failed to normalize path %s", legacy), e); - } - - return YangInstanceIdentifier.create(normalizedArgs.build()); - } - - public DataNormalizationOperation getOperation(final YangInstanceIdentifier legacy) - throws DataNormalizationException { - DataNormalizationOperation currentOp = operation; - - for (PathArgument pathArgument : legacy.getPathArguments()) { - currentOp = currentOp.getChild(pathArgument); - } - return currentOp; - } - - public YangInstanceIdentifier toLegacy(final YangInstanceIdentifier normalized) throws DataNormalizationException { - ImmutableList.Builder legacyArgs = ImmutableList.builder(); - DataNormalizationOperation currentOp = operation; - for (PathArgument normalizedArg : normalized.getPathArguments()) { - currentOp = currentOp.getChild(normalizedArg); - if (!currentOp.isMixin()) { - legacyArgs.add(normalizedArg); - } - } - return YangInstanceIdentifier.create(legacyArgs.build()); - } - - public DataNormalizationOperation getRootOperation() { - return operation; - } -} diff --git a/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/util/compat/DataSchemaContainerProxy.java b/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/util/compat/DataSchemaContainerProxy.java deleted file mode 100644 index cf97561321..0000000000 --- a/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/util/compat/DataSchemaContainerProxy.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.common.impl.util.compat; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.Optional; -import java.util.Set; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.model.api.DataNodeContainer; -import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; -import org.opendaylight.yangtools.yang.model.api.GroupingDefinition; -import org.opendaylight.yangtools.yang.model.api.TypeDefinition; -import org.opendaylight.yangtools.yang.model.api.UsesNode; - -@Deprecated(forRemoval = true) -class DataSchemaContainerProxy implements DataNodeContainer { - - private final Set realChildSchemas; - private final Map mappedChildSchemas; - - DataSchemaContainerProxy(final Set realChildSchema) { - realChildSchemas = realChildSchema; - mappedChildSchemas = new HashMap<>(); - for (DataSchemaNode schema : realChildSchemas) { - mappedChildSchemas.put(schema.getQName(), schema); - } - } - - @Override - public Optional findDataChildByName(final QName name) { - return Optional.ofNullable(mappedChildSchemas.get(name)); - } - - @Override - public Set getChildNodes() { - return realChildSchemas; - } - - @Override - public Set getGroupings() { - return Collections.emptySet(); - } - - @Override - public Set> getTypeDefinitions() { - return Collections.emptySet(); - } - - @Override - public Set getUses() { - return Collections.emptySet(); - } -} diff --git a/opendaylight/md-sal/sal-common-impl/src/test/resources/normalization-test.yang b/opendaylight/md-sal/sal-common-impl/src/test/resources/normalization-test.yang deleted file mode 100644 index 6df5306850..0000000000 --- a/opendaylight/md-sal/sal-common-impl/src/test/resources/normalization-test.yang +++ /dev/null @@ -1,74 +0,0 @@ -module normalization-test { - yang-version 1; - namespace "urn:opendaylight:params:xml:ns:yang:controller:md:sal:normalization:test"; - prefix "norm-test"; - - revision "2014-03-13" { - description "Initial revision."; - } - - grouping outer-grouping { - } - - container test { - list outer-list { - key id; - leaf id { - type uint16; - } - choice outer-choice { - case one { - leaf one { - type string; - } - } - case two-three { - leaf two { - type string; - } - leaf three { - type string; - } - } - } - list inner-list { - key name; - ordered-by user; - - leaf name { - type string; - } - leaf value { - type string; - } - } - } - - list unkeyed-list { - leaf name { - type string; - } - } - - leaf-list unordered-leaf-list { - type string; - } - - leaf-list ordered-leaf-list { - ordered-by user; - type string; - } - - container outer-container { - } - - anyxml any-xml-data; - } - - augment /norm-test:test/norm-test:outer-container { - - leaf augmented-leaf { - type string; - } - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-common-util/pom.xml b/opendaylight/md-sal/sal-common-util/pom.xml index 9cb9927d00..c904e1e112 100644 --- a/opendaylight/md-sal/sal-common-util/pom.xml +++ b/opendaylight/md-sal/sal-common-util/pom.xml @@ -14,10 +14,6 @@ bundle - - org.opendaylight.controller - sal-common-api - org.opendaylight.yangtools concepts diff --git a/opendaylight/md-sal/sal-distributed-datastore/pom.xml b/opendaylight/md-sal/sal-distributed-datastore/pom.xml index d71573b419..4e3baf905f 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/pom.xml +++ b/opendaylight/md-sal/sal-distributed-datastore/pom.xml @@ -111,26 +111,14 @@ test-jar test - - org.opendaylight.controller - sal-binding-api - org.opendaylight.controller sal-clustering-commons - - org.opendaylight.controller - sal-common-api - org.opendaylight.controller sal-common-util - - org.opendaylight.controller - sal-core-compat - org.opendaylight.controller sal-akka-segmented-journal @@ -139,24 +127,12 @@ org.opendaylight.mdsal - mdsal-dom-api - - - org.opendaylight.mdsal - mdsal-dom-spi + mdsal-binding-dom-codec org.opendaylight.mdsal mdsal-dom-broker - - org.opendaylight.mdsal - mdsal-binding-dom-codec - - - org.opendaylight.controller - sal-core-spi - org.opendaylight.yangtools diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/compat/LegacyDOMStoreAdapter.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/compat/LegacyDOMStoreAdapter.java deleted file mode 100644 index 03df0a189d..0000000000 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/compat/LegacyDOMStoreAdapter.java +++ /dev/null @@ -1,186 +0,0 @@ -/* - * Copyright (c) 2016 Brocade Communications Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.cluster.datastore.compat; - -import static java.util.Objects.requireNonNull; - -import com.google.common.base.Optional; -import com.google.common.collect.ForwardingObject; -import com.google.common.util.concurrent.CheckedFuture; -import com.google.common.util.concurrent.ListenableFuture; -import com.google.common.util.concurrent.MoreExecutors; -import org.eclipse.jdt.annotation.NonNull; -import org.opendaylight.controller.cluster.datastore.DistributedDataStoreInterface; -import org.opendaylight.controller.md.sal.common.api.MappingCheckedFuture; -import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; -import org.opendaylight.controller.sal.core.compat.ReadFailedExceptionAdapter; -import org.opendaylight.controller.sal.core.spi.data.DOMStore; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; - -/** - * Adapter between the legacy controller API-based DOMStore and the mdsal API-based DOMStore. - * - * @author Thomas Pantelis - */ -@Deprecated(forRemoval = true) -public class LegacyDOMStoreAdapter extends ForwardingObject implements DOMStore, AutoCloseable { - private final DistributedDataStoreInterface delegate; - - public LegacyDOMStoreAdapter(DistributedDataStoreInterface delegate) { - this.delegate = delegate; - } - - @Override - public DOMStoreReadTransaction newReadOnlyTransaction() { - return new DOMStoreTransactionAdapter(delegate().newReadOnlyTransaction()); - } - - @Override - public DOMStoreWriteTransaction newWriteOnlyTransaction() { - return new DOMStoreTransactionAdapter(delegate().newWriteOnlyTransaction()); - } - - @Override - public DOMStoreReadWriteTransaction newReadWriteTransaction() { - return new DOMStoreTransactionAdapter(delegate().newReadWriteTransaction()); - } - - @Override - public DOMStoreTransactionChain createTransactionChain() { - final org.opendaylight.mdsal.dom.spi.store.DOMStoreTransactionChain delegateChain = - delegate().createTransactionChain(); - return new DOMStoreTransactionChain() { - @Override - public DOMStoreReadTransaction newReadOnlyTransaction() { - return new DOMStoreTransactionAdapter(delegateChain.newReadOnlyTransaction()); - } - - @Override - public DOMStoreWriteTransaction newWriteOnlyTransaction() { - return new DOMStoreTransactionAdapter(delegateChain.newWriteOnlyTransaction()); - } - - @Override - public DOMStoreReadWriteTransaction newReadWriteTransaction() { - return new DOMStoreTransactionAdapter(delegateChain.newReadWriteTransaction()); - } - - @Override - public void close() { - delegateChain.close(); - } - }; - } - - @Override - public void close() { - } - - @Override - protected DistributedDataStoreInterface delegate() { - return delegate; - } - - private static class DOMStoreTransactionAdapter implements DOMStoreReadWriteTransaction { - private final org.opendaylight.mdsal.dom.spi.store.DOMStoreReadTransaction readDelegate; - private final org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction writeDelegate; - private final Object identifier; - - DOMStoreTransactionAdapter(org.opendaylight.mdsal.dom.spi.store.@NonNull DOMStoreReadTransaction readDelegate) { - this.readDelegate = requireNonNull(readDelegate); - this.identifier = readDelegate.getIdentifier(); - this.writeDelegate = null; - } - - DOMStoreTransactionAdapter( - org.opendaylight.mdsal.dom.spi.store.@NonNull DOMStoreWriteTransaction writeDelegate) { - this.writeDelegate = requireNonNull(writeDelegate); - this.identifier = writeDelegate.getIdentifier(); - this.readDelegate = null; - } - - DOMStoreTransactionAdapter( - org.opendaylight.mdsal.dom.spi.store.@NonNull DOMStoreReadWriteTransaction rwDelegate) { - this.readDelegate = requireNonNull(rwDelegate); - this.writeDelegate = rwDelegate; - this.identifier = readDelegate.getIdentifier(); - } - - @Override - public Object getIdentifier() { - return identifier; - } - - @Override - public void close() { - if (writeDelegate != null) { - writeDelegate.close(); - } else { - readDelegate.close(); - } - } - - @Override - public void write(YangInstanceIdentifier path, NormalizedNode data) { - writeDelegate.write(path, data); - } - - @Override - public void merge(YangInstanceIdentifier path, NormalizedNode data) { - writeDelegate.merge(path, data); - } - - @Override - public void delete(YangInstanceIdentifier path) { - writeDelegate.delete(path); - } - - @Override - public DOMStoreThreePhaseCommitCohort ready() { - final org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort cohort = writeDelegate.ready(); - return new DOMStoreThreePhaseCommitCohort() { - @Override - public ListenableFuture canCommit() { - return cohort.canCommit(); - } - - @Override - public ListenableFuture preCommit() { - return cohort.preCommit(); - } - - @Override - public ListenableFuture commit() { - return cohort.commit(); - } - - @Override - public ListenableFuture abort() { - return cohort.abort(); - } - }; - } - - @Override - public CheckedFuture>, ReadFailedException> read(YangInstanceIdentifier path) { - return MappingCheckedFuture.create(readDelegate.read(path).transform( - Optional::fromJavaUtil, MoreExecutors.directExecutor()), ReadFailedExceptionAdapter.INSTANCE); - } - - @Override - public CheckedFuture exists(YangInstanceIdentifier path) { - return MappingCheckedFuture.create(readDelegate.exists(path), ReadFailedExceptionAdapter.INSTANCE); - } - } -} diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/RegisterDataTreeChangeListener.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/RegisterDataTreeChangeListener.java index cbe9dbf5d0..0e9fae4243 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/RegisterDataTreeChangeListener.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/RegisterDataTreeChangeListener.java @@ -19,8 +19,7 @@ import org.opendaylight.controller.cluster.datastore.node.utils.stream.Serializa import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; /** - * Request a {@link org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener} registration be made on the - * shard leader. + * Request a {@link org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener} registration be made on the shard leader. */ public final class RegisterDataTreeChangeListener implements Externalizable { private static final long serialVersionUID = 1L; diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/resources/OSGI-INF/blueprint/clustered-datastore.xml b/opendaylight/md-sal/sal-distributed-datastore/src/main/resources/OSGI-INF/blueprint/clustered-datastore.xml index ac3d982729..7962d9b9b9 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/resources/OSGI-INF/blueprint/clustered-datastore.xml +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/resources/OSGI-INF/blueprint/clustered-datastore.xml @@ -153,13 +153,6 @@ - - - - - - - - 4.0.0 - - org.opendaylight.controller - mdsal-parent - 1.12.0-SNAPSHOT - ../parent - - - org.opendaylight.controller - sal-core-api - 1.12.0-SNAPSHOT - bundle - - - - org.opendaylight.controller - sal-common-api - - - org.opendaylight.yangtools - yang-data-api - - - org.opendaylight.yangtools - yang-model-api - - - org.osgi - org.osgi.core - - - org.opendaylight.controller - sal-test-model - - - org.opendaylight.mdsal - mdsal-dom-api - - - org.opendaylight.yangtools - yang-data-impl - test - - - - - scm:git:http://git.opendaylight.org/gerrit/controller.git - scm:git:ssh://git.opendaylight.org:29418/controller.git - HEAD - https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL - - - diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/ClusteredDOMDataTreeChangeListener.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/ClusteredDOMDataTreeChangeListener.java deleted file mode 100644 index c5170b6546..0000000000 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/ClusteredDOMDataTreeChangeListener.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2015 Brocade Communications Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.api; - -/** - * ClusteredDOMDataTreeChangeListener is a marker interface to enable data tree change notifications on all - * instances in a cluster where this listener is registered. - * - *

- * Applications should implement ClusteredDOMDataTreeChangeListener instead of {@link DOMDataTreeChangeListener}, - * if they want to listen for data tree change notifications on any node of a clustered data store. - * {@link DOMDataTreeChangeListener} enables notifications only at the leader of the data store. - * - * @author Thomas Pantelis - * @deprecated Use {@link org.opendaylight.mdsal.dom.api.ClusteredDOMDataTreeChangeListener} instead. - */ -@Deprecated(forRemoval = true) -public interface ClusteredDOMDataTreeChangeListener extends DOMDataTreeChangeListener { - -} diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMActionProviderService.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMActionProviderService.java deleted file mode 100644 index 7322046160..0000000000 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMActionProviderService.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.api; - -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; - -/** - * Bridge to action registration. - * - * @deprecated Use {@link org.opendaylight.mdsal.dom.api.DOMActionProviderService} instead - */ -@Deprecated(forRemoval = true) -@SuppressFBWarnings(value = "NM_SAME_SIMPLE_NAME_AS_INTERFACE", justification = "Migration") -public interface DOMActionProviderService extends DOMService, org.opendaylight.mdsal.dom.api.DOMActionProviderService { - -} diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMActionService.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMActionService.java deleted file mode 100644 index 34cc7e6634..0000000000 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMActionService.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.api; - -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; - -/** - * Bridge to action invocation. - * - * @deprecated Use {@link org.opendaylight.mdsal.dom.api.DOMActionService} instead - */ -@Deprecated(forRemoval = true) -@SuppressFBWarnings(value = "NM_SAME_SIMPLE_NAME_AS_INTERFACE", justification = "Migration") -public interface DOMActionService extends DOMService, org.opendaylight.mdsal.dom.api.DOMActionService { - -} diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataBroker.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataBroker.java deleted file mode 100644 index c2f929c6af..0000000000 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataBroker.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.api; - -import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker; -import org.opendaylight.controller.md.sal.common.api.data.TransactionChainFactory; -import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; - -/** - * Data Broker which provides data transaction and data change listener functionality - * using {@link NormalizedNode} data format. - * - *

- * This interface is type capture of generic interfaces and returns type captures - * of results for client-code convenience. - * - * @deprecated Use {@link org.opendaylight.mdsal.dom.api.DOMDataBroker} instead - */ -@Deprecated(forRemoval = true) -public interface DOMDataBroker extends - AsyncDataBroker>, - TransactionChainFactory>, - DOMExtensibleService { - - @Override - DOMDataReadOnlyTransaction newReadOnlyTransaction(); - - @Override - DOMDataReadWriteTransaction newReadWriteTransaction(); - - @Override - DOMDataWriteTransaction newWriteOnlyTransaction(); - - @Override - DOMTransactionChain createTransactionChain(TransactionChainListener listener); -} diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataBrokerExtension.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataBrokerExtension.java deleted file mode 100644 index 4b5d9ddbcb..0000000000 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataBrokerExtension.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.api; - -/** - * Type capture of a {@link DOMServiceExtension} applicable to {@link DOMDataBroker} implementations. - * - * @deprecated Use {@link org.opendaylight.mdsal.dom.api.DOMDataBrokerExtension} instead. - */ -@Deprecated(forRemoval = true) -public interface DOMDataBrokerExtension extends DOMServiceExtension { - -} diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataReadOnlyTransaction.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataReadOnlyTransaction.java deleted file mode 100644 index ba59903b10..0000000000 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataReadOnlyTransaction.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.md.sal.dom.api; - -import org.opendaylight.controller.md.sal.common.api.data.AsyncReadOnlyTransaction; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; - -@Deprecated(forRemoval = true) -public interface DOMDataReadOnlyTransaction extends DOMDataReadTransaction, - AsyncReadOnlyTransaction> { -} diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataReadTransaction.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataReadTransaction.java deleted file mode 100644 index d90f68f817..0000000000 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataReadTransaction.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.api; - -import com.google.common.base.Optional; -import com.google.common.util.concurrent.CheckedFuture; -import org.opendaylight.controller.md.sal.common.api.data.AsyncReadTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; - -/** - * A transaction that provides read access to a logical data store. - * - *

- * For more information on usage and examples, please see the documentation in {@link AsyncReadTransaction}. - * - * @deprecated Use {@link org.opendaylight.mdsal.dom.api.DOMDataTreeReadTransaction} instead. - */ -@Deprecated(forRemoval = true) -public interface DOMDataReadTransaction extends AsyncReadTransaction> { - /** - * Reads data from provided logical data store located at the provided path. - * - *

- * If the target is a subtree, then the whole subtree is read (and will be - * accessible from the returned data object). - * - * @param store - * Logical data store from which read should occur. - * @param path - * Path which uniquely identifies subtree which client want to - * read - * @return a CheckFuture containing the result of the read. The Future blocks until the - * commit operation is complete. Once complete: - *

    - *
  • If the data at the supplied path exists, the Future returns an Optional object - * containing the data.
  • - *
  • If the data at the supplied path does not exist, the Future returns - * Optional#absent().
  • - *
  • If the read of the data fails, the Future will fail with a - * {@link ReadFailedException} or an exception derived from ReadFailedException.
  • - *
- */ - CheckedFuture>, ReadFailedException> read( - LogicalDatastoreType store, YangInstanceIdentifier path); - - /** - * Checks if data is available in the logical data store located at provided path. - * - *

- * Note: a successful result from this method makes no guarantee that a subsequent call to {@link #read} - * will succeed. It is possible that the data resides in a data store on a remote node and, if that - * node goes down or a network failure occurs, a subsequent read would fail. Another scenario is if - * the data is deleted in between the calls to exists and read - * - * @param store - * Logical data store from which read should occur. - * @param path - * Path which uniquely identifies subtree which client want to - * check existence of - * @return a CheckFuture containing the result of the check. - *

    - *
  • If the data at the supplied path exists, the Future returns a Boolean - * whose value is true, false otherwise
  • - *
  • If checking for the data fails, the Future will fail with a - * {@link ReadFailedException} or an exception derived from ReadFailedException.
  • - *
- */ - CheckedFuture exists(LogicalDatastoreType store, YangInstanceIdentifier path); -} diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataReadWriteTransaction.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataReadWriteTransaction.java deleted file mode 100644 index 551a50f74c..0000000000 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataReadWriteTransaction.java +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.api; - -import org.opendaylight.controller.md.sal.common.api.data.AsyncReadWriteTransaction; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; - -@Deprecated(forRemoval = true) -public interface DOMDataReadWriteTransaction extends DOMDataReadTransaction, DOMDataWriteTransaction, - AsyncReadWriteTransaction> { -} diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataTreeChangeListener.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataTreeChangeListener.java deleted file mode 100644 index 28aaeb45b3..0000000000 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataTreeChangeListener.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.api; - -import java.util.Collection; -import java.util.EventListener; -import org.eclipse.jdt.annotation.NonNull; -import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate; - -/** - * Interface implemented by classes interested in receiving notifications about - * data tree changes. This interface provides a cursor-based view of the change, which has potentially - * lower overhead. - * - *

- * Note: this interface enables notifications only at the leader of the data store, if clustered. If you want - * notifications on all instances in a cluster, use the {@link ClusteredDOMDataTreeChangeListener}. - * - * @deprecated Use {@link org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener} instead. - */ -@Deprecated(forRemoval = true) -public interface DOMDataTreeChangeListener extends EventListener { - /** - * Invoked when there was data change for the supplied path, which was used - * to register this listener. - * - *

- * This method may be also invoked during registration of the listener if - * there is any pre-existing data in the conceptual data tree for supplied - * path. This initial event will contain all pre-existing data as created. - * - *

- * A data change event may be triggered spuriously, e.g. such that data before - * and after compare as equal. Implementations of this interface are expected - * to recover from such events. Event producers are expected to exert reasonable - * effort to suppress such events. - * - *

- * In other words, it is completely acceptable to observe - * a {@link org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode}, - * which reports a {@link org.opendaylight.yangtools.yang.data.api.schema.tree.ModificationType} - * other than UNMODIFIED, while the before- and after- data items compare as - * equal. - * - * @param changes Collection of change events, may not be null or empty. - */ - void onDataTreeChanged(@NonNull Collection changes); -} diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataTreeChangeService.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataTreeChangeService.java deleted file mode 100644 index 82dee04afd..0000000000 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataTreeChangeService.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.api; - -import org.eclipse.jdt.annotation.NonNull; -import org.opendaylight.yangtools.concepts.ListenerRegistration; - -/** - * A {@link DOMServiceExtension} which allows users to register for changes to a subtree. - * - * @deprecated Use {@link org.opendaylight.mdsal.dom.api.DOMDataTreeChangeService} instead. - */ -@Deprecated(forRemoval = true) -public interface DOMDataTreeChangeService extends DOMDataBrokerExtension { - /** - * Registers a {@link DOMDataTreeChangeListener} to receive - * notifications when data changes under a given path in the conceptual data - * tree. - * - *

- * You are able to register for notifications for any node or subtree - * which can be represented using {@link DOMDataTreeIdentifier}. - * - *

- * You are able to register for data change notifications for a subtree or leaf - * even if it does not exist. You will receive notification once that node is - * created. - * - *

- * If there is any pre-existing data in the data tree for the path for which you are - * registering, you will receive an initial data change event, which will - * contain all pre-existing data, marked as created. - * - *

- * This method returns a {@link ListenerRegistration} object. To - * "unregister" your listener for changes call the {@link ListenerRegistration#close()} - * method on the returned object. - * - *

- * You MUST explicitly unregister your listener when you no longer want to receive - * notifications. This is especially true in OSGi environments, where failure to - * do so during bundle shutdown can lead to stale listeners being still registered. - * - * @param treeId - * Data tree identifier of the subtree which should be watched for - * changes. - * @param listener - * Listener instance which is being registered - * @return Listener registration object, which may be used to unregister - * your listener using {@link ListenerRegistration#close()} to stop - * delivery of change events. - */ - @NonNull ListenerRegistration registerDataTreeChangeListener( - @NonNull DOMDataTreeIdentifier treeId, @NonNull L listener); -} diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataTreeCommitCohortRegistry.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataTreeCommitCohortRegistry.java deleted file mode 100644 index 6cf1e4d60d..0000000000 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataTreeCommitCohortRegistry.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (c) 2017 2015 Brocade Communications Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.api; - -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; - -/** - * Interface for a DOM commit cohort registry. - * - * @author Thomas Pantelis - * @deprecated Use {@link org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohortRegistry} instead. - */ -@Deprecated(forRemoval = true) -@SuppressFBWarnings("NM_SAME_SIMPLE_NAME_AS_INTERFACE") -public interface DOMDataTreeCommitCohortRegistry extends DOMDataBrokerExtension, - org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohortRegistry { -} diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataTreeIdentifier.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataTreeIdentifier.java deleted file mode 100644 index 4c46ec509d..0000000000 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataTreeIdentifier.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.api; - -import static java.util.Objects.requireNonNull; - -import com.google.common.base.MoreObjects; -import java.io.Serializable; -import java.util.Iterator; -import org.eclipse.jdt.annotation.NonNull; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.yangtools.concepts.Immutable; -import org.opendaylight.yangtools.concepts.Path; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; - -/** - * A unique identifier for a particular subtree. It is composed of the logical - * data store type and the instance identifier of the root node. - * - * @deprecated Use {@link org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier} instead. - */ -@Deprecated(forRemoval = true) -public final class DOMDataTreeIdentifier implements Immutable, - Path, Serializable, Comparable { - private static final long serialVersionUID = 1L; - private final @NonNull YangInstanceIdentifier rootIdentifier; - private final @NonNull LogicalDatastoreType datastoreType; - - public DOMDataTreeIdentifier(final LogicalDatastoreType datastoreType, - final YangInstanceIdentifier rootIdentifier) { - this.datastoreType = requireNonNull(datastoreType); - this.rootIdentifier = requireNonNull(rootIdentifier); - } - - /** - * Return a counterpart to an MD-SAL data tree identifier. - * - * @return Controller data tree identifier. - */ - public static DOMDataTreeIdentifier fromMdsal(final org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier mdsal) { - return new DOMDataTreeIdentifier(LogicalDatastoreType.fromMdsal(mdsal.getDatastoreType()), - mdsal.getRootIdentifier()); - } - - /** - * Return MD-SAL counterpart of this object. - * - * @return MD-SAL data tree identifier. - */ - public org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier toMdsal() { - return new org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier(datastoreType.toMdsal(), rootIdentifier); - } - - /** - * Return the logical data store type. - * - * @return Logical data store type. Guaranteed to be non-null. - */ - public @NonNull LogicalDatastoreType getDatastoreType() { - return datastoreType; - } - - /** - * Return the {@link YangInstanceIdentifier} of the root node. - * - * @return Instance identifier corresponding to the root node. - */ - public @NonNull YangInstanceIdentifier getRootIdentifier() { - return rootIdentifier; - } - - @Override - public boolean contains(final DOMDataTreeIdentifier other) { - return datastoreType == other.datastoreType && rootIdentifier.contains(other.rootIdentifier); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + datastoreType.hashCode(); - result = prime * result + rootIdentifier.hashCode(); - return result; - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) { - return true; - } - if (!(obj instanceof DOMDataTreeIdentifier)) { - return false; - } - DOMDataTreeIdentifier other = (DOMDataTreeIdentifier) obj; - if (datastoreType != other.datastoreType) { - return false; - } - return rootIdentifier.equals(other.rootIdentifier); - } - - @Override - public int compareTo(final DOMDataTreeIdentifier obj) { - int cmp = datastoreType.compareTo(obj.datastoreType); - if (cmp != 0) { - return cmp; - } - - final Iterator mi = rootIdentifier.getPathArguments().iterator(); - final Iterator oi = obj.rootIdentifier.getPathArguments().iterator(); - - while (mi.hasNext()) { - if (!oi.hasNext()) { - return 1; - } - - final PathArgument ma = mi.next(); - final PathArgument oa = oi.next(); - cmp = ma.compareTo(oa); - if (cmp != 0) { - return cmp; - } - } - - return oi.hasNext() ? -1 : 0; - } - - @Override - public String toString() { - return MoreObjects.toStringHelper(this).add("datastore", datastoreType).add("root", rootIdentifier).toString(); - } -} diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataWriteTransaction.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataWriteTransaction.java deleted file mode 100644 index ad677d493e..0000000000 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataWriteTransaction.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.api; - -import org.opendaylight.controller.md.sal.common.api.data.AsyncWriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; - -/** - * A transaction that provides mutation capabilities on a data tree. - * - *

- * For more information on usage and examples, please see the documentation in {@link AsyncWriteTransaction}. - * - * @deprecated Use {@link org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction} instead. - */ -@Deprecated(forRemoval = true) -public interface DOMDataWriteTransaction extends AsyncWriteTransaction> { - - @Override - void delete(LogicalDatastoreType store, YangInstanceIdentifier path); - - /** - * Stores a piece of data at the specified path. This acts as an add / replace - * operation, which is to say that whole subtree will be replaced by the specified data. - * - *

- * For more information on usage and examples, please see the documentation in {@link AsyncWriteTransaction}. - * - *

- * If you need to make sure that a parent object exists but you do not want modify - * its pre-existing state by using put, consider using {@link #merge} instead. - * - * @param store - * the logical data store which should be modified - * @param path - * the data object path - * @param data - * the data object to be written to the specified path - * @throws IllegalStateException - * if the transaction has already been submitted - */ - void put(LogicalDatastoreType store, YangInstanceIdentifier path, NormalizedNode data); - - /** - * Merges a piece of data with the existing data at a specified path. Any pre-existing data - * which is not explicitly overwritten will be preserved. This means that if you store a container, - * its child lists will be merged. - * - *

- * For more information on usage and examples, please see the documentation in {@link AsyncWriteTransaction}. - * - *

- * If you require an explicit replace operation, use {@link #put} instead. - * - * @param store - * the logical data store which should be modified - * @param path - * the data object path - * @param data - * the data object to be merged to the specified path - * @throws IllegalStateException - * if the transaction has already been submitted - */ - void merge(LogicalDatastoreType store, YangInstanceIdentifier path, NormalizedNode data); -} diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMEvent.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMEvent.java deleted file mode 100644 index 6210744157..0000000000 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMEvent.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.md.sal.dom.api; - -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; -import java.time.Instant; -import java.util.Date; - -/** - * Generic event interface. - * @deprecated Use {@link org.opendaylight.mdsal.dom.api.DOMEvent} instead. - */ -@Deprecated(forRemoval = true) -@SuppressFBWarnings(value = "NM_SAME_SIMPLE_NAME_AS_INTERFACE", justification = "Migration") -public interface DOMEvent extends org.opendaylight.mdsal.dom.api.DOMEvent { - - @Override - default Instant getEventInstant() { - final Date eventTime = getEventTime(); - return eventTime != null ? eventTime.toInstant() : null; - } - - /** - * Get the time of the event occurrence. - * - * @return the event time - */ - Date getEventTime(); -} diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMExtensibleService.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMExtensibleService.java deleted file mode 100644 index cdc9560d6e..0000000000 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMExtensibleService.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.api; - -import com.google.common.annotations.Beta; -import java.util.Map; -import org.eclipse.jdt.annotation.NonNull; - -/** - * Marker interface for services which can support {@link DOMServiceExtension}. - * Aside for marking these, they also provide runtime query to detect whether - * a particular trait is in fact available. - * - * @param Base {@link DOMService} - * @param Extension type - * @deprecated Use {@link org.opendaylight.mdsal.dom.api.DOMExtensibleService} instead. - */ -@Deprecated(forRemoval = true) -@Beta -public interface DOMExtensibleService, - E extends DOMServiceExtension> extends DOMService { - /** - * Return a map of currently-supported extensions, along with accessor services - * which provide access to the specific functionality bound to this service. - * - * @return A map of supported functionality. - */ - @NonNull Map, E> getSupportedExtensions(); -} diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMMountPoint.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMMountPoint.java deleted file mode 100644 index 772cf7de3b..0000000000 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMMountPoint.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.api; - -import com.google.common.base.Optional; -import org.opendaylight.yangtools.concepts.Identifiable; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -@Deprecated(forRemoval = true) -public interface DOMMountPoint extends Identifiable { - - Optional getService(Class cls); - - SchemaContext getSchemaContext(); -} diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMMountPointService.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMMountPointService.java deleted file mode 100644 index 71f23bb534..0000000000 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMMountPointService.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.api; - -import com.google.common.base.Optional; -import org.opendaylight.mdsal.dom.api.DOMMountPointListener; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.concepts.ObjectRegistration; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -/** - * Deprecated. - * - * @deprecated Use {@link org.opendaylight.mdsal.dom.api.DOMMountPointService} instead - */ -@Deprecated(forRemoval = true) -public interface DOMMountPointService extends DOMService { - - Optional getMountPoint(YangInstanceIdentifier path); - - DOMMountPointBuilder createMountPoint(YangInstanceIdentifier path); - - ListenerRegistration registerProvisionListener(DOMMountPointListener listener); - - interface DOMMountPointBuilder { - - DOMMountPointBuilder addService(Class type,T impl); - - DOMMountPointBuilder addInitialSchemaContext(SchemaContext ctx); - - ObjectRegistration register(); - } -} diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMNotification.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMNotification.java deleted file mode 100644 index 737f2a56cc..0000000000 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMNotification.java +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.api; - -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; - -/** - * A single YANG notification. - * @deprecated Use {@link org.opendaylight.mdsal.dom.api.DOMNotification} instead. - */ -@Deprecated(forRemoval = true) -@SuppressFBWarnings(value = "NM_SAME_SIMPLE_NAME_AS_INTERFACE", justification = "Migration") -public interface DOMNotification extends org.opendaylight.mdsal.dom.api.DOMNotification { -} diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMNotificationListener.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMNotificationListener.java deleted file mode 100644 index 00a3ccb0d4..0000000000 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMNotificationListener.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.api; - -import java.util.EventListener; -import org.eclipse.jdt.annotation.NonNull; - -/** - * Interface implemented by listeners interested in {@link DOMNotification}s. - * @deprecated Use {@link org.opendaylight.mdsal.dom.api.DOMNotificationListener} instead. - */ -@Deprecated(forRemoval = true) -public interface DOMNotificationListener extends EventListener { - /** - * Invoked whenever a {@link DOMNotification} matching the subscription - * criteria is received. - * - * @param notification Received notification - */ - void onNotification(@NonNull DOMNotification notification); -} diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMNotificationPublishService.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMNotificationPublishService.java deleted file mode 100644 index 90aa87849e..0000000000 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMNotificationPublishService.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.api; - -import com.google.common.util.concurrent.Futures; -import com.google.common.util.concurrent.ListenableFuture; -import java.util.concurrent.TimeUnit; -import org.eclipse.jdt.annotation.NonNull; - -/** - * A {@link DOMService} which allows its user to send {@link DOMNotification}s. It - * provides two styles of initiating the notification delivery, similar to - * {@link java.util.concurrent.BlockingQueue}: - * - a put-style method which waits until the implementation can accept the notification - * for delivery, and - * - an offer-style method, which attempts to enqueue the notification, but allows - * the caller to specify that it should never wait, or put an upper bound on how - * long it is going to wait. - * - * @deprecated Use {@link org.opendaylight.mdsal.dom.api.DOMNotificationPublishService} instead - */ -@Deprecated(forRemoval = true) -public interface DOMNotificationPublishService extends DOMService { - /** - * Well-known value indicating that the implementation is currently not - * able to accept a notification. - */ - ListenableFuture REJECTED = Futures.immediateFailedFuture( - new DOMNotificationRejectedException("Unacceptable blocking conditions encountered")); - - /** - * Publish a notification. The result of this method is a {@link ListenableFuture} - * which will complete once the notification has been delivered to all immediate - * registrants. The type of the object resulting from the future is not defined - * and implementations may use it to convey additional information related to the - * publishing process. - * - *

- * Abstract subclasses can refine the return type as returning a promise of a - * more specific type, e.g.: - * - * {@code - * public interface DeliveryStatus { int getListenerCount(); } - * ListenableFuture putNotification(DOMNotification notification); - * } - * - *

- * Once the Future succeeds, the resulting object can be queried for traits using - * instanceof, e.g: - * - * {@code - * // Can block when (for example) the implemention's ThreadPool queue is full - * Object o = service.putNotification(notif).get(); - * if (o instanceof DeliveryStatus) { - * DeliveryStatus ds = (DeliveryStatus)o; - * LOG.debug("Notification was received by {} listeners", ds.getListenerCount();); - * } - * } - * - *

- * In case an implementation is running out of resources, it can block the calling - * thread until enough resources become available to accept the notification for - * processing, or it is interrupted. - * - *

- * Caution: completion here means that the implementation has completed processing - * of the notification. This does not mean that all existing registrants - * have seen the notification. Most importantly, the delivery process at - * other cluster nodes may have not begun yet. - * - * @param notification Notification to be published. - * @return A listenable future which will report completion when the service - * has finished propagating the notification to its immediate registrants. - * @throws InterruptedException if interrupted while waiting - * @throws NullPointerException if notification is null. - */ - @NonNull ListenableFuture putNotification(@NonNull DOMNotification notification) throws InterruptedException; - - /** - * Attempt to publish a notification. The result of this method is a {@link ListenableFuture} - * which will complete once the notification has been delivered to all immediate - * registrants. The type of the object resulting from the future is not defined - * and implementations may use it to convey additional information related to the - * publishing process. Unlike {@link #putNotification(DOMNotification)}, this method - * is guaranteed not to block if the underlying implementation encounters contention. - * - * @param notification Notification to be published. - * @return A listenable future which will report completion when the service - * has finished propagating the notification to its immediate registrants, - * or {@link #REJECTED} if resource constraints prevent - * the implementation from accepting the notification for delivery. - * @throws NullPointerException if notification is null. - */ - @NonNull ListenableFuture offerNotification(@NonNull DOMNotification notification); - - /** - * Attempt to publish a notification. The result of this method is a {@link ListenableFuture} - * which will complete once the notification has been delivered to all immediate - * registrants. The type of the object resulting from the future is not defined - * and implementations may use it to convey additional information related to the - * publishing process. Unlike {@link #putNotification(DOMNotification)}, this method - * is guaranteed to block more than the specified timeout. - * - * @param notification Notification to be published. - * @param timeout how long to wait before giving up, in units of unit, must not be negative - * @param unit a TimeUnit determining how to interpret the timeout parameter - * @return A listenable future which will report completion when the service - * has finished propagating the notification to its immediate registrants, - * or {@link #REJECTED} if resource constraints prevent - * the implementation from accepting the notification for delivery. - * @throws InterruptedException if interrupted while waiting - * @throws NullPointerException if notification or unit is null. - * @throws IllegalArgumentException if timeout is negative. - */ - @NonNull ListenableFuture offerNotification(@NonNull DOMNotification notification, - long timeout, @NonNull TimeUnit unit) throws InterruptedException; -} diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMNotificationRejectedException.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMNotificationRejectedException.java deleted file mode 100644 index e4faaec99c..0000000000 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMNotificationRejectedException.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.api; - -/** - * This exception indicates that given notification can not be processed by corresponding mechanism. - * More info can be provided in message. - * - *

- * Expected use: {@link DOMNotificationPublishService} - * @deprecated Use {@link org.opendaylight.mdsal.dom.api.DOMNotificationRejectedException} instead. - */ -@Deprecated(forRemoval = true) -public class DOMNotificationRejectedException extends Exception { - private static final long serialVersionUID = 1L; - - public DOMNotificationRejectedException(final String message) { - super(message); - } - - public DOMNotificationRejectedException(final String message, final Throwable cause) { - super(message, cause); - } -} diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMNotificationService.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMNotificationService.java deleted file mode 100644 index a17e4f1cc7..0000000000 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMNotificationService.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.api; - -import java.util.Collection; -import org.eclipse.jdt.annotation.NonNull; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; - -/** - * A {@link DOMService} which allows its users to subscribe to receive - * {@link DOMNotification}s. - * - * @deprecated Use {@link org.opendaylight.mdsal.dom.api.DOMNotificationService} instead - */ -@Deprecated(forRemoval = true) -public interface DOMNotificationService extends DOMService { - /** - * Register a {@link DOMNotificationListener} to receive a set of notifications. As with - * other ListenerRegistration-based interfaces, registering an instance multiple times - * results in notifications being delivered for each registration. - * - * @param listener Notification instance to register - * @param types Notification types which should be delivered to the listener. Duplicate - * entries are processed only once, null entries are ignored. - * @return Registration handle. Invoking {@link ListenerRegistration#close()} - * will stop the delivery of notifications to the listener - * @throws IllegalArgumentException if types is empty or contains an invalid element, such as - * null or a SchemaPath which does not represent a valid {@link DOMNotification} type. - * @throws NullPointerException if either of the arguments is null - */ - ListenerRegistration registerNotificationListener( - @NonNull T listener, @NonNull Collection types); - - /** - * Register a {@link DOMNotificationListener} to receive a set of notifications. As with - * other ListenerRegistration-based interfaces, registering an instance multiple times - * results in notifications being delivered for each registration. - * - * @param listener Notification instance to register - * @param types Notification types which should be delivered to the listener. Duplicate - * entries are processed only once, null entries are ignored. - * @return Registration handle. Invoking {@link ListenerRegistration#close()} - * will stop the delivery of notifications to the listener - * @throws IllegalArgumentException if types is empty or contains an invalid element, such as - * null or a SchemaPath which does not represent a valid {@link DOMNotification} type. - * @throws NullPointerException if listener is null - */ - // FIXME: Java 8: provide a default implementation of this method. - ListenerRegistration registerNotificationListener( - @NonNull T listener, SchemaPath... types); -} diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMRpcAvailabilityListener.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMRpcAvailabilityListener.java deleted file mode 100644 index 93db2a0962..0000000000 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMRpcAvailabilityListener.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.api; - -import java.util.Collection; -import java.util.EventListener; -import org.eclipse.jdt.annotation.NonNull; - -/** - * An {@link EventListener} used to track RPC implementations becoming (un)available a {@link DOMRpcService}. Note that - * the reported {@link DOMRpcIdentifier}s form an identifier space shared between RFC7950 actions and RFC6020 RPCs, - * the former being also known as 'Routed RPCs'. - * - *

- * Interpretation of DOMRpcIdentifiers has to be evaluated in the context of one of these types, which need to be - * determined by matching {@link DOMRpcIdentifier#getType()} against a - * {@link org.opendaylight.yangtools.yang.model.api.SchemaContext}, which determines actual semantics of - * {@link DOMRpcIdentifier#getContextReference()}. Corresponding SchemaNode is required to be a known sub-interface - * of {@link org.opendaylight.yangtools.yang.model.api.OperationDefinition}. - * - *

- * For RFC6020 RPCs, reported context reference is always non-null and empty. It indicates an RPC implementation has - * been registered and invocations can be reasonably (with obvious distributed system caveats coming from asynchronous - * events) expected to succeed. - * - *

- * For RFC7950 actions with a non-empty context-reference, the indication is the same as for RFC6020 RPCs. - * - *

- * For RFC7950 actions with an empty context-reference, the indication is that the corresponding actions are - * potentially available, but are subject to dynamic lifecycle of their context references. This includes two primary - * use cases: - *

    - *
  • dynamic action instantiation (when a device connects)
  • - *
  • dynamic action translation, such as transforming one action into another
  • - *
- * First use case will provide further availability events with non-empty context references as they become available, - * which can be safely ignored if the listener is interested in pure invocation-type integration. - * - *

- * Second use case will not be providing further events, but rather will attempt to map any incoming invocation onto - * some other RPC or action, or similar, which can separately fail. If a sub-request fails, such implementations are - * required do report {@link DOMRpcImplementationNotAvailableException} as the invocation result, with the underlying - * failure being linked as a cause. - * - * @deprecated Use {@link org.opendaylight.mdsal.dom.api.DOMRpcAvailabilityListener} instead. - */ -@Deprecated(forRemoval = true) -public interface DOMRpcAvailabilityListener extends EventListener { - /** - * Method invoked whenever an RPC type becomes available. - * - * @param rpcs RPC types newly available - */ - void onRpcAvailable(@NonNull Collection rpcs); - - /** - * Method invoked whenever an RPC type becomes unavailable. - * - * @param rpcs RPC types which became unavailable - */ - void onRpcUnavailable(@NonNull Collection rpcs); - - /** - * Implementation filtering method. This method is useful for forwarding RPC implementations, - * which need to ensure they do not re-announce their own implementations. Without this method - * a forwarder which registers an implementation would be notified of its own implementation, - * potentially re-exporting it as local -- hence creating a forwarding loop. - * - * @param impl RPC implementation being registered - * @return False if the implementation should not be reported, defaults to true. - */ - default boolean acceptsImplementation(final DOMRpcImplementation impl) { - return true; - } -} diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMRpcException.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMRpcException.java deleted file mode 100644 index b2f170c18b..0000000000 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMRpcException.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.api; - -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; - -/** - * Base class for failures that can occur during RPC invocation. This covers - * transport and protocol-level failures. - * - * @deprecated Use {@link org.opendaylight.mdsal.dom.api.DOMRpcException} instead. - */ -@Deprecated(forRemoval = true) -@SuppressFBWarnings(value = "NM_SAME_SIMPLE_NAME_AS_SUPERCLASS", justification = "Migration") -public abstract class DOMRpcException extends org.opendaylight.mdsal.dom.api.DOMRpcException { - private static final long serialVersionUID = 1L; - - /** - * Construct an new instance with a message and an empty cause. - * - * @param message Exception message - */ - protected DOMRpcException(final String message) { - super(message); - } - - /** - * Construct an new instance with a message and a cause. - * - * @param message Exception message - * @param cause Chained cause - */ - protected DOMRpcException(final String message, final Throwable cause) { - super(message, cause); - } -} diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMRpcIdentifier.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMRpcIdentifier.java deleted file mode 100644 index 9fb3a233a9..0000000000 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMRpcIdentifier.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.api; - -import static java.util.Objects.requireNonNull; - -import com.google.common.base.MoreObjects; -import java.util.Objects; -import org.eclipse.jdt.annotation.NonNull; -import org.eclipse.jdt.annotation.Nullable; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; - -/** - * Identifier of a RPC context. This is an extension of the YANG RPC, which - * always has global context. It allows an RPC to have a instance identifier - * attached, so that there can be multiple implementations bound to different - * contexts concurrently. - * - * @deprecated Use {@link org.opendaylight.mdsal.dom.api.DOMRpcIdentifier} instead. - */ -@Deprecated(forRemoval = true) -public abstract class DOMRpcIdentifier { - - private static final class Global extends DOMRpcIdentifier { - private Global(final @NonNull SchemaPath type) { - super(type); - } - - @Override - public YangInstanceIdentifier getContextReference() { - return YangInstanceIdentifier.empty(); - } - } - - private static final class Local extends DOMRpcIdentifier { - private final YangInstanceIdentifier contextReference; - - private Local(final @NonNull SchemaPath type, final @NonNull YangInstanceIdentifier contextReference) { - super(type); - this.contextReference = requireNonNull(contextReference); - } - - @Override - public YangInstanceIdentifier getContextReference() { - return contextReference; - } - } - - private final SchemaPath type; - - private DOMRpcIdentifier(final SchemaPath type) { - this.type = requireNonNull(type); - } - - /** - * Create a global RPC identifier. - * - * @param type RPC type, SchemaPath of its definition, may not be null - * @return A global RPC identifier, guaranteed to be non-null. - */ - public static @NonNull DOMRpcIdentifier create(final @NonNull SchemaPath type) { - return new Global(type); - } - - /** - * Create an RPC identifier with a particular context reference. - * - * @param type RPC type, SchemaPath of its definition, may not be null - * @param contextReference Context reference, null means a global RPC identifier. - * @return A global RPC identifier, guaranteed to be non-null. - */ - public static @NonNull DOMRpcIdentifier create(final @NonNull SchemaPath type, - final @Nullable YangInstanceIdentifier contextReference) { - if (contextReference == null || contextReference.isEmpty()) { - return new Global(type); - } - return new Local(type, contextReference); - } - - public static DOMRpcIdentifier fromMdsal(final org.opendaylight.mdsal.dom.api.DOMRpcIdentifier mdsal) { - return create(mdsal.getType(), mdsal.getContextReference()); - } - - public org.opendaylight.mdsal.dom.api.DOMRpcIdentifier toMdsal() { - return org.opendaylight.mdsal.dom.api.DOMRpcIdentifier.create(type, getContextReference()); - } - - /** - * Return the RPC type. - * - * @return RPC type. - */ - public final @NonNull SchemaPath getType() { - return type; - } - - /** - * Return the RPC context reference. Null value indicates global context. - * - * @return RPC context reference. - */ - public abstract @NonNull YangInstanceIdentifier getContextReference(); - - @Override - public final int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + type.hashCode(); - result = prime * result + getContextReference().hashCode(); - return result; - } - - @Override - public final boolean equals(final Object obj) { - if (this == obj) { - return true; - } - if (!(obj instanceof DOMRpcIdentifier)) { - return false; - } - DOMRpcIdentifier other = (DOMRpcIdentifier) obj; - if (!type.equals(other.type)) { - return false; - } - return Objects.equals(getContextReference(), other.getContextReference()); - } - - @Override - public final String toString() { - return MoreObjects.toStringHelper(this).omitNullValues().add("type", type).add("contextReference", - getContextReference()).toString(); - } -} diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMRpcImplementation.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMRpcImplementation.java deleted file mode 100644 index 5741c02d79..0000000000 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMRpcImplementation.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.api; - -import com.google.common.util.concurrent.CheckedFuture; -import org.eclipse.jdt.annotation.NonNull; -import org.eclipse.jdt.annotation.Nullable; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; - -/** - * Interface implemented by an individual RPC implementation. This API allows for dispatch - * implementations, e.g. an individual object handling a multitude of RPCs. - * - * @deprecated Use {@link org.opendaylight.mdsal.dom.api.DOMRpcImplementation} instead. - */ -@Deprecated(forRemoval = true) -public interface DOMRpcImplementation { - /** - * Initiate invocation of the RPC. Implementations of this method are - * expected to not block on external resources. - * - * @param rpc RPC identifier which was invoked - * @param input Input arguments, null if the RPC does not take any. - * @return A {@link CheckedFuture} which will return either a result structure, - * or report a subclass of {@link DOMRpcException} reporting a transport - * error. - */ - @NonNull CheckedFuture invokeRpc(@NonNull DOMRpcIdentifier rpc, - @Nullable NormalizedNode input); - - /** - * Return the relative invocation cost of this implementation. Default implementation return 0. - * - * @return Non-negative cost of invoking this implementation. - */ - default long invocationCost() { - return 0; - } -} diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMRpcImplementationNotAvailableException.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMRpcImplementationNotAvailableException.java deleted file mode 100644 index 1a93922647..0000000000 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMRpcImplementationNotAvailableException.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.api; - -import static java.util.Objects.requireNonNull; - -import org.eclipse.jdt.annotation.NonNull; - -/** - * Exception indicating that no implementation of the requested RPC service is available. - * - * @deprecated Use {@link org.opendaylight.mdsal.dom.api.DOMRpcImplementationNotAvailableException} instead. - */ -@Deprecated(forRemoval = true) -public class DOMRpcImplementationNotAvailableException extends DOMRpcException { - private static final long serialVersionUID = 1L; - - public DOMRpcImplementationNotAvailableException(final @NonNull String format, final Object... args) { - super(String.format(format, args)); - } - - public DOMRpcImplementationNotAvailableException(final @NonNull Throwable cause, final @NonNull String format, - final Object... args) { - super(String.format(format, args), requireNonNull(cause)); - } - - public DOMRpcImplementationNotAvailableException(final String message, final Throwable cause) { - super(message, cause); - } -} diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMRpcImplementationRegistration.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMRpcImplementationRegistration.java deleted file mode 100644 index c9b255e4a0..0000000000 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMRpcImplementationRegistration.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.api; - -import org.opendaylight.yangtools.concepts.ObjectRegistration; - -/** - * A registration of a {@link DOMRpcImplementation}. Used to track and revoke a registration - * with a {@link DOMRpcProviderService}. - * - * @param RPC implementation type - * @deprecated Use {@link org.opendaylight.mdsal.dom.api.DOMRpcImplementationRegistration} instead. - */ -@Deprecated(forRemoval = true) -public interface DOMRpcImplementationRegistration extends ObjectRegistration { - @Override - void close(); -} diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMRpcProviderService.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMRpcProviderService.java deleted file mode 100644 index 4c5280799a..0000000000 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMRpcProviderService.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.api; - -import java.util.Set; -import org.eclipse.jdt.annotation.NonNull; - -/** - * A {@link DOMService} which allows registration of RPC implementations with a conceptual router. The client - * counterpart of this service is {@link DOMRpcService}. - * - *

- * This interface supports both RFC6020 RPCs and RFC7950 actions (formerly known as 'Routed RPCs'. Invocation for - * RFC6020 RPCs is always based on an empty context reference. Invocation of actions requires a non-empty context - * reference and is matched against registered implementations as follows: - *

    - *
  • First, attempt to look up the implementation based on exact match. If a match is found the invocation is - * on that implementation, returning its result.
  • - *
  • Second, attempt to look up the implementation which registered for empty context reference. If a such an - * implementation exists, invoke that implementation, returning its result
  • - *
  • Throw {@link DOMRpcImplementationNotAvailableException} - *
- * - *

- * All implementations are required to perform these steps as specified above. - * - * @deprecated Use {@link org.opendaylight.mdsal.dom.api.DOMRpcProviderService} instead - */ -@Deprecated(forRemoval = true) -public interface DOMRpcProviderService extends DOMService { - /** - * Register an {@link DOMRpcImplementation} object with this service. - * - * @param implementation RPC implementation, must not be null - * @param rpcs Array of supported RPC identifiers. Must not be null, empty, or contain a null element. - * Each identifier is added exactly once, no matter how many times it occurs. - * @return A {@link DOMRpcImplementationRegistration} object, guaranteed to be non-null. - * @throws NullPointerException if implementation or types is null - * @throws IllegalArgumentException if types is empty or contains a null element. - */ - @NonNull DOMRpcImplementationRegistration registerRpcImplementation( - @NonNull T implementation, @NonNull DOMRpcIdentifier... rpcs); - - /** - * Register an {@link DOMRpcImplementation} object with this service. - * - * @param implementation RPC implementation, must not be null - * @param rpcs Set of supported RPC identifiers. Must not be null, empty, or contain a null element. - * @return A {@link DOMRpcImplementationRegistration} object, guaranteed to be non-null. - * @throws NullPointerException if implementation or types is null - * @throws IllegalArgumentException if types is empty or contains a null element. - */ - @NonNull DOMRpcImplementationRegistration registerRpcImplementation( - @NonNull T implementation, @NonNull Set rpcs); -} diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMRpcResult.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMRpcResult.java deleted file mode 100644 index b55f355f62..0000000000 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMRpcResult.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.api; - -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; - -/** - * Interface defining a result of an RPC call. - * - * @deprecated Use {@link org.opendaylight.mdsal.dom.api.DOMRpcResult} instead. - */ -@Deprecated(forRemoval = true) -@SuppressFBWarnings(value = "NM_SAME_SIMPLE_NAME_AS_INTERFACE", justification = "Migration") -public interface DOMRpcResult extends org.opendaylight.mdsal.dom.api.DOMRpcResult { -} diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMRpcService.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMRpcService.java deleted file mode 100644 index 88dd3f472d..0000000000 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMRpcService.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.api; - -import com.google.common.util.concurrent.CheckedFuture; -import org.eclipse.jdt.annotation.NonNull; -import org.eclipse.jdt.annotation.Nullable; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; - -/** - * A {@link DOMService} which allows clients to invoke RPCs. The conceptual model of this - * service is that of a dynamic router, where the set of available RPC services can change - * dynamically. The service allows users to add a listener to track the process of - * RPCs becoming available. - * - * @deprecated Use {@link org.opendaylight.mdsal.dom.api.DOMRpcService} instead - */ -@Deprecated(forRemoval = true) -public interface DOMRpcService extends DOMService { - /** - * Initiate invocation of an RPC. This method is guaranteed to not block on any external - * resources. - * - * @param type SchemaPath of the RPC to be invoked - * @param input Input arguments, null if the RPC does not take any. - * @return A {@link CheckedFuture} which will return either a result structure, - * or report a subclass of {@link DOMRpcException} reporting a transport - * error. - */ - @NonNull CheckedFuture invokeRpc(@NonNull SchemaPath type, - @Nullable NormalizedNode input); - - /** - * Register a {@link DOMRpcAvailabilityListener} with this service to receive notifications - * about RPC implementations becoming (un)available. The listener will be invoked with the - * current implementations reported and will be kept uptodate as implementations come and go. - * - *

- * Users should note that using a listener does not necessarily mean that - * {@link #invokeRpc(SchemaPath, NormalizedNode)} will not report a failure due to - * {@link DOMRpcImplementationNotAvailableException} and need to be ready to handle it. - * - *

- * Implementations of this interface are encouraged to take reasonable precautions to prevent this scenario from - * occurring. - * - * @param listener {@link DOMRpcAvailabilityListener} instance to register - * @return A {@link ListenerRegistration} representing this registration. Performing - * a {@link ListenerRegistration#close()} will cancel it. Returned object - * is guaranteed to be non-null. - */ - @NonNull ListenerRegistration registerRpcListener(@NonNull T listener); -} diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMService.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMService.java deleted file mode 100644 index 882330faf1..0000000000 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMService.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.api; - -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; - -/** - * Marker interface for services which can be obtained from a {@link DOMMountPoint} instance. No further semantics are - * implied. - * - * @deprecated Use {@link org.opendaylight.mdsal.dom.api.DOMService} instead. - */ -@Deprecated(forRemoval = true) -@SuppressFBWarnings(value = "NM_SAME_SIMPLE_NAME_AS_INTERFACE", justification = "Migration") -public interface DOMService extends org.opendaylight.mdsal.dom.api.DOMService { - -} diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMServiceExtension.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMServiceExtension.java deleted file mode 100644 index d8cb956ca9..0000000000 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMServiceExtension.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.api; - -import com.google.common.annotations.Beta; - -/** - * Marker interface for services which expose additional functionality on top of some base {@link DOMService}. - * - * @deprecated Use {@link org.opendaylight.mdsal.dom.api.DOMServiceExtension} instead. - */ -@Beta -@Deprecated(forRemoval = true) -public interface DOMServiceExtension, E extends DOMServiceExtension> { - -} diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMTransactionChain.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMTransactionChain.java deleted file mode 100644 index fdeeccd114..0000000000 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMTransactionChain.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.api; - -import org.opendaylight.controller.md.sal.common.api.data.TransactionChain; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; - -/** - * A chain of DOM Data transactions. - * - *

- * Transactions in a chain need to be committed in sequence and each - * transaction should see the effects of previous transactions as if they happened. A chain - * makes no guarantees of atomicity, in fact transactions are committed as soon as possible. - * - *

- * This interface is type capture of {@link TransactionChain} for DOM Data Contracts. - * - * @deprecated Use {@link org.opendaylight.mdsal.dom.api.DOMTransactionChain} instead. - */ -@Deprecated(forRemoval = true) -public interface DOMTransactionChain extends TransactionChain> { - - @Override - DOMDataReadOnlyTransaction newReadOnlyTransaction(); - - @Override - DOMDataReadWriteTransaction newReadWriteTransaction(); - - @Override - DOMDataWriteTransaction newWriteOnlyTransaction(); -} diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DefaultDOMRpcException.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DefaultDOMRpcException.java deleted file mode 100644 index 04da7b8450..0000000000 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DefaultDOMRpcException.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (c) 2018 Inocybe Technologies and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.api; - -/** - * Default implementation of DOMRpcException. - * - * @author Thomas Pantelis - * @deprecated Use {@link org.opendaylight.mdsal.dom.api.DefaultDOMRpcException} instead. - */ -@Deprecated(forRemoval = true) -public class DefaultDOMRpcException extends DOMRpcException { - private static final long serialVersionUID = 1L; - - public DefaultDOMRpcException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/pom.xml b/opendaylight/md-sal/sal-dom-broker/pom.xml deleted file mode 100644 index f69a5ed6ea..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/pom.xml +++ /dev/null @@ -1,121 +0,0 @@ - - - 4.0.0 - - org.opendaylight.controller - mdsal-parent - 1.12.0-SNAPSHOT - ../parent - - - org.opendaylight.controller - sal-broker-impl - 1.12.0-SNAPSHOT - bundle - - - - com.lmax - disruptor - - - org.opendaylight.mdsal - mdsal-eos-dom-api - - - org.opendaylight.mdsal - mdsal-dom-api - - - org.opendaylight.mdsal - mdsal-dom-broker - - - org.opendaylight.controller - sal-common-impl - - - org.opendaylight.controller - sal-common-util - - - org.opendaylight.controller - sal-core-api - - - org.opendaylight.controller - sal-core-spi - - - org.opendaylight.controller - sal-core-compat - - - org.opendaylight.yangtools - util - - - org.opendaylight.yangtools - yang-data-impl - - - - org.slf4j - slf4j-api - - - - org.opendaylight.yangtools - mockito-configuration - test - - - org.slf4j - slf4j-simple - test - - - org.opendaylight.yangtools - yang-test-util - - - org.opendaylight.controller - sal-inmemory-datastore - test - - - - - - - org.apache.felix - maven-bundle-plugin - true - - - ${project.groupId}.${project.artifactId} - - - org.opendaylight.controller.sal.dom.broker, - org.opendaylight.controller.sal.dom.broker.impl, - org.opendaylight.controller.sal.dom.broker.util, - org.opendaylight.controller.sal.dom.broker.spi, - - - org.opendaylight.controller.md.sal.dom.broker.impl, - org.opendaylight.controller.md.sal.dom.broker.impl.*, - org.opendaylight.controller.md.sal.dom.clustering.impl, - - - - - - - - scm:git:http://git.opendaylight.org/gerrit/controller.git - scm:git:ssh://git.opendaylight.org:29418/controller.git - HEAD - https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL - - - diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/AbstractDOMDataBroker.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/AbstractDOMDataBroker.java deleted file mode 100755 index 6cd1a49f07..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/AbstractDOMDataBroker.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.broker.impl; - -import static com.google.common.base.Preconditions.checkState; - -import com.google.common.collect.ImmutableMap; -import java.util.Collections; -import java.util.EnumMap; -import java.util.Map; -import java.util.Map.Entry; -import java.util.concurrent.atomic.AtomicLong; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener; -import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; -import org.opendaylight.controller.md.sal.dom.api.DOMDataBrokerExtension; -import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener; -import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeService; -import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeIdentifier; -import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain; -import org.opendaylight.controller.sal.core.spi.data.DOMStore; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreTreeChangePublisher; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@Deprecated(forRemoval = true) -public abstract class AbstractDOMDataBroker extends AbstractDOMForwardedTransactionFactory - implements DOMDataBroker { - private static final Logger LOG = LoggerFactory.getLogger(AbstractDOMDataBroker.class); - - private final AtomicLong txNum = new AtomicLong(); - private final AtomicLong chainNum = new AtomicLong(); - private final Map, DOMDataBrokerExtension> extensions; - private volatile AutoCloseable closeable; - - protected AbstractDOMDataBroker(final Map datastores) { - super(datastores); - - boolean treeChange = true; - for (DOMStore ds : datastores.values()) { - if (!(ds instanceof DOMStoreTreeChangePublisher)) { - treeChange = false; - break; - } - } - - if (treeChange) { - extensions = ImmutableMap., DOMDataBrokerExtension>of( - DOMDataTreeChangeService.class, new DOMDataTreeChangeService() { - @Override - public ListenerRegistration - registerDataTreeChangeListener(final DOMDataTreeIdentifier treeId, 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(); - } - } - - public void setCloseable(final AutoCloseable closeable) { - this.closeable = closeable; - } - - @Override - @SuppressWarnings("checkstyle:IllegalCatch") - public void close() { - super.close(); - - if (closeable != null) { - try { - closeable.close(); - } catch (Exception e) { - LOG.debug("Error closing instance", e); - } - } - } - - @Override - protected Object newTransactionIdentifier() { - return "DOM-" + txNum.getAndIncrement(); - } - - @Override - public Map, DOMDataBrokerExtension> getSupportedExtensions() { - return extensions; - } - - @Override - public DOMTransactionChain createTransactionChain(final TransactionChainListener listener) { - checkNotClosed(); - - final Map backingChains = new EnumMap<>( - LogicalDatastoreType.class); - for (Entry entry : getTxFactories().entrySet()) { - backingChains.put(entry.getKey(), entry.getValue().createTransactionChain()); - } - - final long chainId = chainNum.getAndIncrement(); - LOG.debug("Transactoin chain {} created with listener {}, backing store chains {}", chainId, listener, - backingChains); - return new DOMDataBrokerTransactionChainImpl(chainId, backingChains, this, listener); - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/AbstractDOMForwardedCompositeTransaction.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/AbstractDOMForwardedCompositeTransaction.java deleted file mode 100644 index 763614d098..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/AbstractDOMForwardedCompositeTransaction.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.broker.impl; - -import static com.google.common.base.Preconditions.checkArgument; -import static java.util.Objects.requireNonNull; - -import java.util.Collection; -import java.util.Map; -import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransaction; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; - -/** - * Composite DOM Transaction backed by {@link DOMStoreTransaction}. - * - *

- * Abstract base for composite transaction, which provides access only to common - * functionality as retrieval of subtransaction, close method and retrieval of - * identifier. - * - * @param - * Subtransaction distinguisher - * @param - * Subtransaction type - */ -@Deprecated(forRemoval = true) -abstract class AbstractDOMForwardedCompositeTransaction implements - AsyncTransaction> { - - private final Map backingTxs; - private final Object identifier; - - /** - * Creates new composite Transactions. - * - * @param identifier - * Identifier of transaction. - * @param backingTxs - * Key,value map of backing transactions. - */ - protected AbstractDOMForwardedCompositeTransaction(final Object identifier, final Map backingTxs) { - this.identifier = requireNonNull(identifier, "Identifier should not be null"); - this.backingTxs = requireNonNull(backingTxs, "Backing transactions should not be null"); - } - - /** - * Returns subtransaction associated with supplied key. - * - * @param key key - * @return subtransaction - * @throws NullPointerException - * if key is null - * @throws IllegalArgumentException - * if no subtransaction is associated with key. - */ - protected final T getSubtransaction(final K key) { - final T ret = backingTxs.get(requireNonNull(key, "key must not be null.")); - checkArgument(ret != null, "No subtransaction associated with %s", key); - return ret; - } - - /** - * Returns immutable Iterable of all subtransactions. - * - */ - protected Collection getSubtransactions() { - return backingTxs.values(); - } - - @Override - public Object getIdentifier() { - return identifier; - } - - @SuppressWarnings("checkstyle:IllegalCatch") - protected void closeSubtransactions() { - /* - * We share one exception for all failures, which are added - * as supressedExceptions to it. - */ - IllegalStateException failure = null; - for (T subtransaction : backingTxs.values()) { - try { - subtransaction.close(); - } catch (Exception e) { - // If we did not allocated failure we allocate it - if (failure == null) { - failure = new IllegalStateException("Uncaught exception occured during closing transaction", e); - } else { - // We update it with additional exceptions, which occurred during error. - failure.addSuppressed(e); - } - } - } - // If we have failure, we throw it at after all attempts to close. - if (failure != null) { - throw failure; - } - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/AbstractDOMForwardedTransactionFactory.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/AbstractDOMForwardedTransactionFactory.java deleted file mode 100644 index 399dcd1df4..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/AbstractDOMForwardedTransactionFactory.java +++ /dev/null @@ -1,263 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.broker.impl; - -import com.google.common.base.Preconditions; -import com.google.common.base.Supplier; -import com.google.common.util.concurrent.ListenableFuture; -import java.util.Collection; -import java.util.EnumMap; -import java.util.Map; -import java.util.Map.Entry; -import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; -import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction; -import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction; -import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionFactory; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction; -import org.opendaylight.yangtools.concepts.Path; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; - -/** - * Abstract composite transaction factory. - * - *

- * Provides an convenience common implementation for composite DOM Transactions, - * where subtransaction is identified by {@link LogicalDatastoreType} type and - * implementation of subtransaction is provided by - * {@link DOMStoreTransactionFactory}. - * - * Note:This class does not have thread-safe implementation of {@link #close()}, - * implementation may allow accessing and allocating new transactions during closing - * this instance. - * - * @param - * Type of {@link DOMStoreTransactionFactory} factory. - */ -@Deprecated(forRemoval = true) -abstract class AbstractDOMForwardedTransactionFactory implements AutoCloseable { - @SuppressWarnings("rawtypes") - private static final AtomicIntegerFieldUpdater UPDATER = - AtomicIntegerFieldUpdater.newUpdater(AbstractDOMForwardedTransactionFactory.class, "closed"); - private final Map storeTxFactories; - private volatile int closed = 0; - - protected AbstractDOMForwardedTransactionFactory(final Map txFactories) { - this.storeTxFactories = new EnumMap<>(txFactories); - } - - /** - * Implementations must return unique identifier for each and every call of - * this method. - * - * @return new Unique transaction identifier. - */ - protected abstract Object newTransactionIdentifier(); - - /** - * User-supplied implementation of {@link DOMDataWriteTransaction#commit()} - * for transaction. - * - *

- * Callback invoked when {@link DOMDataWriteTransaction#commit()} is invoked - * on transaction created by this factory. - * - * @param transaction - * Transaction on which {@link DOMDataWriteTransaction#commit()} - * was invoked. - * @param cohorts - * Iteratable of cohorts for subtransactions associated with - * the transaction being committed. - * @return a ListenableFuture. if commit coordination on cohorts finished successfully, - * a CommitInfo is returned from the Future, On failure, - * the Future fails with a {@link TransactionCommitFailedException}. - */ - protected abstract ListenableFuture commit(DOMDataWriteTransaction transaction, - Collection cohorts, Supplier futureValueSupplier); - - /** - * Creates a new composite read-only transaction - * - *

- * Creates a new composite read-only transaction backed by one transaction - * per factory in {@link #getTxFactories()}. - * - *

- * Subtransaction for reading is selected by supplied - * {@link LogicalDatastoreType} as parameter for - * {@link DOMDataReadOnlyTransaction#read(LogicalDatastoreType, - * org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)}. - * - *

- * Id of returned transaction is retrieved via - * {@link #newTransactionIdentifier()}. - * - * @return New composite read-only transaction. - */ - public final DOMDataReadOnlyTransaction newReadOnlyTransaction() { - checkNotClosed(); - - final Map txns = new EnumMap<>(LogicalDatastoreType.class); - for (Entry store : storeTxFactories.entrySet()) { - txns.put(store.getKey(), store.getValue().newReadOnlyTransaction()); - } - return new DOMForwardedReadOnlyTransaction(newTransactionIdentifier(), txns); - } - - /** - * Creates a new composite write-only transaction - * - *

- * Creates a new composite write-only transaction backed by one write-only - * transaction per factory in {@link #getTxFactories()}. - * - *

- * Implementation of composite Write-only transaction is following: - * - *

- *

  • - * {@link DOMDataWriteTransaction#put(LogicalDatastoreType, YangInstanceIdentifier, NormalizedNode)} - * - backing subtransaction is selected by {@link LogicalDatastoreType}, - * {@link DOMStoreWriteTransaction#write(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier, - * org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)} - * is invoked on selected subtransaction. - *
  • - * {@link DOMDataWriteTransaction#merge(LogicalDatastoreType, YangInstanceIdentifier, NormalizedNode)} - * - backing subtransaction is selected by {@link LogicalDatastoreType}, - * {@link DOMStoreWriteTransaction#merge(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier, - * org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)} - * is invoked on selected subtransaction. - *
  • - * {@link DOMDataWriteTransaction#delete(LogicalDatastoreType, Path)} - * {@link DOMStoreWriteTransaction#delete(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)} is - * invoked on - * selected subtransaction. - *
  • {@link DOMDataWriteTransaction#commit()} - results in invoking - * {@link DOMStoreWriteTransaction#ready()}, gathering all resulting cohorts - * and then invoking finalized implementation callback - * {@link #commit} with transaction which was commited and gathered results. - *
  • - *
- * - *

- * Id of returned transaction is generated via - * {@link #newTransactionIdentifier()}. - * - * @return New composite write-only transaction associated with this factory. - */ - public final DOMDataWriteTransaction newWriteOnlyTransaction() { - checkNotClosed(); - - final Map txns = new EnumMap<>(LogicalDatastoreType.class); - for (Entry store : storeTxFactories.entrySet()) { - txns.put(store.getKey(), store.getValue().newWriteOnlyTransaction()); - } - return new DOMForwardedWriteTransaction<>(newTransactionIdentifier(), txns, this); - } - - /** - * Creates a new composite write-only transaction - * - *

- * Creates a new composite write-only transaction backed by one write-only transaction per factory in - * {@link #getTxFactories()}. - * - *

- * Implementation of composite Write-only transaction is following: - * - *

- *

    - *
  • - * {@link org.opendaylight.controller.md.sal.dom.api.DOMDataReadTransaction#read(LogicalDatastoreType, - * YangInstanceIdentifier)} - * - backing subtransaction is selected by {@link LogicalDatastoreType}, - * {@link DOMStoreReadTransaction#read(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)} is invoked - * on selected subtransaction. - *
  • - * {@link DOMDataWriteTransaction#put(LogicalDatastoreType, - * org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier, - * org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)} - * - backing subtransaction is selected by {@link LogicalDatastoreType}, - * {@link DOMStoreWriteTransaction#write(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier, - * org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)} - * is invoked on selected subtransaction. - *
  • - * {@link DOMDataWriteTransaction#merge(LogicalDatastoreType, - * org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier, - * org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)} - * - backing subtransaction is selected by {@link LogicalDatastoreType}, - * {@link DOMStoreWriteTransaction#merge(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier, - * org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)} - * is invoked on selected subtransaction. - *
  • - * {@link DOMDataWriteTransaction#delete(LogicalDatastoreType, - * org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)} - * - backing subtransaction is selected by {@link LogicalDatastoreType}, - * {@link DOMStoreWriteTransaction#delete(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)} is - * invoked on - * selected subtransaction. - *
  • {@link DOMDataWriteTransaction#commit()} - results in invoking - * {@link DOMStoreWriteTransaction#ready()}, gathering all resulting cohorts - * and then invoking finalized implementation callback - * {@link #commit} with transaction which was committed and gathered results. - *
  • - *
- * - *

- * Id of returned transaction is generated via - * {@link #newTransactionIdentifier()}. - * - * @return New composite read-write transaction associated with this factory. - */ - public final DOMDataReadWriteTransaction newReadWriteTransaction() { - checkNotClosed(); - - final Map txns = new EnumMap<>(LogicalDatastoreType.class); - for (Entry store : storeTxFactories.entrySet()) { - txns.put(store.getKey(), store.getValue().newReadWriteTransaction()); - } - return new DOMForwardedReadWriteTransaction(newTransactionIdentifier(), txns, this); - } - - /** - * Convenience accessor of backing factories intended to be used only by - * finalization of this class. - * - * Note: - * Finalization of this class may want to access other functionality of - * supplied Transaction factories. - * - * @return Map of backing transaction factories. - */ - protected final Map getTxFactories() { - return storeTxFactories; - } - - /** - * Checks if instance is not closed. - * - * @throws IllegalStateException If instance of this class was closed. - * - */ - protected final void checkNotClosed() { - Preconditions.checkState(closed == 0, "Transaction factory was closed. No further operations allowed."); - } - - @Override - public void close() { - final boolean success = UPDATER.compareAndSet(this, 0, 1); - Preconditions.checkState(success, "Transaction factory was already closed"); - } -} - diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/AbstractDOMRpcRoutingTableEntry.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/AbstractDOMRpcRoutingTableEntry.java deleted file mode 100644 index 54f343ff15..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/AbstractDOMRpcRoutingTableEntry.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.broker.impl; - -import static java.util.Objects.requireNonNull; - -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableMap.Builder; -import com.google.common.collect.Maps; -import com.google.common.util.concurrent.CheckedFuture; -import java.util.ArrayList; -import java.util.Comparator; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcAvailabilityListener; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcException; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementation; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; - -@Deprecated(forRemoval = true) -abstract class AbstractDOMRpcRoutingTableEntry { - private final Map> implementations; - private final SchemaPath schemaPath; - - AbstractDOMRpcRoutingTableEntry(final SchemaPath schemaPath, - final Map> implementations) { - this.schemaPath = requireNonNull(schemaPath); - this.implementations = requireNonNull(implementations); - } - - final SchemaPath getSchemaPath() { - return schemaPath; - } - - final List getImplementations(final YangInstanceIdentifier context) { - return implementations.get(context); - } - - final Map> getImplementations() { - return implementations; - } - - final boolean containsContext(final YangInstanceIdentifier contextReference) { - return implementations.containsKey(contextReference); - } - - final Set registeredIdentifiers(final DOMRpcAvailabilityListener listener) { - return Maps.filterValues(implementations, list -> list.stream().anyMatch(listener::acceptsImplementation)) - .keySet(); - } - - /** - * Adds an entry to the DOM RPC routing table. - * - * @param implementation RPC implementation - * @param newRpcs List of new RPCs, must be mutable - */ - final AbstractDOMRpcRoutingTableEntry add(final DOMRpcImplementation implementation, - final List newRpcs) { - final Builder> vb = ImmutableMap.builder(); - for (final Entry> ve : implementations.entrySet()) { - if (newRpcs.remove(ve.getKey())) { - final List i = new ArrayList<>(ve.getValue().size() + 1); - i.addAll(ve.getValue()); - i.add(implementation); - - // New implementation is at the end, this will move it to be the last among implementations - // with equal cost -- relying on sort() being stable. - i.sort(Comparator.comparingLong(DOMRpcImplementation::invocationCost)); - vb.put(ve.getKey(), i); - } else { - vb.put(ve); - } - } - for (final YangInstanceIdentifier ii : newRpcs) { - final List impl = new ArrayList<>(1); - impl.add(implementation); - vb.put(ii, impl); - } - - return newInstance(vb.build()); - } - - final AbstractDOMRpcRoutingTableEntry remove(final DOMRpcImplementation implementation, - final List removed) { - final Builder> vb = ImmutableMap.builder(); - for (final Entry> ve : implementations.entrySet()) { - if (removed.remove(ve.getKey())) { - final List i = new ArrayList<>(ve.getValue()); - i.remove(implementation); - // We could trimToSize(), but that may perform another copy just to get rid - // of a single element. That is probably not worth the trouble. - if (!i.isEmpty()) { - vb.put(ve.getKey(), i); - } - } else { - vb.put(ve); - } - } - - final Map> v = vb.build(); - return v.isEmpty() ? null : newInstance(v); - } - - protected abstract CheckedFuture invokeRpc(NormalizedNode input); - - protected abstract AbstractDOMRpcRoutingTableEntry newInstance( - Map> impls); -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/CommitCoordinationTask.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/CommitCoordinationTask.java deleted file mode 100644 index bd16b5dbc9..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/CommitCoordinationTask.java +++ /dev/null @@ -1,280 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.broker.impl; - -import static java.util.Objects.requireNonNull; - -import com.google.common.base.Supplier; -import com.google.common.base.Throwables; -import com.google.common.util.concurrent.Futures; -import com.google.common.util.concurrent.ListenableFuture; -import java.util.Collection; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutionException; -import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; -import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort; -import org.opendaylight.yangtools.util.DurationStatisticsTracker; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Implementation of blocking three-phase commit-coordination tasks without - * support of cancellation. - */ -@Deprecated(forRemoval = true) -final class CommitCoordinationTask implements Callable { - private enum Phase { - canCommit, - preCommit, - doCommit, - } - - private static final Logger LOG = LoggerFactory.getLogger(CommitCoordinationTask.class); - private final Collection cohorts; - private final DurationStatisticsTracker commitStatTracker; - private final DOMDataWriteTransaction tx; - private final Supplier futureValueSupplier; - - CommitCoordinationTask(final DOMDataWriteTransaction transaction, - final Collection cohorts, - final DurationStatisticsTracker commitStatTracker, - final Supplier futureValueSupplier) { - this.tx = requireNonNull(transaction, "transaction must not be null"); - this.cohorts = requireNonNull(cohorts, "cohorts must not be null"); - this.commitStatTracker = commitStatTracker; - this.futureValueSupplier = futureValueSupplier; - } - - @Override - public T call() throws TransactionCommitFailedException { - final long startTime = commitStatTracker != null ? System.nanoTime() : 0; - - Phase phase = Phase.canCommit; - - try { - LOG.debug("Transaction {}: canCommit Started", tx.getIdentifier()); - canCommitBlocking(); - - phase = Phase.preCommit; - LOG.debug("Transaction {}: preCommit Started", tx.getIdentifier()); - preCommitBlocking(); - - phase = Phase.doCommit; - LOG.debug("Transaction {}: doCommit Started", tx.getIdentifier()); - commitBlocking(); - - LOG.debug("Transaction {}: doCommit completed", tx.getIdentifier()); - return futureValueSupplier.get(); - } catch (final TransactionCommitFailedException e) { - LOG.warn("Tx: {} Error during phase {}, starting Abort", tx.getIdentifier(), phase, e); - abortBlocking(e); - throw e; - } finally { - if (commitStatTracker != null) { - commitStatTracker.addDuration(System.nanoTime() - startTime); - } - } - } - - /** - * Invokes canCommit on underlying cohorts and blocks till - * all results are returned. - * - *

- * Valid state transition is from SUBMITTED to CAN_COMMIT, - * if currentPhase is not SUBMITTED throws IllegalStateException. - * - * @throws TransactionCommitFailedException - * If one of cohorts failed can Commit - * - */ - private void canCommitBlocking() throws TransactionCommitFailedException { - for (final ListenableFuture canCommit : canCommitAll()) { - try { - final Boolean result = (Boolean)canCommit.get(); - if (result == null || !result) { - throw new TransactionCommitFailedException("Can Commit failed, no detailed cause available."); - } - } catch (InterruptedException | ExecutionException e) { - throw TransactionCommitFailedExceptionMapper.CAN_COMMIT_ERROR_MAPPER.apply(e); - } - } - } - - /** - * Invokes canCommit on underlying cohorts and returns composite future - * which will contains {@link Boolean#TRUE} only and only if - * all cohorts returned true. - * - *

- * Valid state transition is from SUBMITTED to CAN_COMMIT, - * if currentPhase is not SUBMITTED throws IllegalStateException. - * - * @return List of all cohorts futures from can commit phase. - * - */ - private ListenableFuture[] canCommitAll() { - final ListenableFuture[] ops = new ListenableFuture[cohorts.size()]; - int index = 0; - for (final DOMStoreThreePhaseCommitCohort cohort : cohorts) { - ops[index++] = cohort.canCommit(); - } - return ops; - } - - /** - * Invokes preCommit on underlying cohorts and blocks till - * all results are returned. - * - *

- * Valid state transition is from CAN_COMMIT to PRE_COMMIT, if current - * state is not CAN_COMMIT - * throws IllegalStateException. - * - * @throws TransactionCommitFailedException - * If one of cohorts failed preCommit - * - */ - private void preCommitBlocking() throws TransactionCommitFailedException { - final ListenableFuture[] preCommitFutures = preCommitAll(); - try { - for (final ListenableFuture future : preCommitFutures) { - future.get(); - } - } catch (InterruptedException | ExecutionException e) { - throw TransactionCommitFailedExceptionMapper.PRE_COMMIT_MAPPER.apply(e); - } - } - - /** - * Invokes preCommit on underlying cohorts and returns future - * which will complete once all preCommit on cohorts completed or - * failed. - * - *

- * Valid state transition is from CAN_COMMIT to PRE_COMMIT, if current - * state is not CAN_COMMIT - * throws IllegalStateException. - * - * @return List of all cohorts futures from can commit phase. - * - */ - private ListenableFuture[] preCommitAll() { - final ListenableFuture[] ops = new ListenableFuture[cohorts.size()]; - int index = 0; - for (final DOMStoreThreePhaseCommitCohort cohort : cohorts) { - ops[index++] = cohort.preCommit(); - } - return ops; - } - - /** - * Invokes commit on underlying cohorts and blocks till - * all results are returned. - * - *

- * Valid state transition is from PRE_COMMIT to COMMIT, if not throws - * IllegalStateException. - * - * @throws TransactionCommitFailedException - * If one of cohorts failed preCommit - * - */ - private void commitBlocking() throws TransactionCommitFailedException { - final ListenableFuture[] commitFutures = commitAll(); - try { - for (final ListenableFuture future : commitFutures) { - future.get(); - } - } catch (InterruptedException | ExecutionException e) { - throw TransactionCommitFailedExceptionMapper.COMMIT_ERROR_MAPPER.apply(e); - } - } - - /** - * Invokes commit on underlying cohorts and returns future which - * completes - * once all commits on cohorts are completed. - * - *

- * Valid state transition is from PRE_COMMIT to COMMIT, if not throws - * IllegalStateException - * - * @return List of all cohorts futures from can commit phase. - */ - private ListenableFuture[] commitAll() { - final ListenableFuture[] ops = new ListenableFuture[cohorts.size()]; - int index = 0; - for (final DOMStoreThreePhaseCommitCohort cohort : cohorts) { - ops[index++] = cohort.commit(); - } - return ops; - } - - /** - * Aborts transaction. - * - *

- * Invokes {@link DOMStoreThreePhaseCommitCohort#abort()} on all - * cohorts, blocks - * for all results. If any of the abort failed throws - * IllegalStateException, - * which will contains originalCause as suppressed Exception. - * - *

- * If aborts we're successful throws supplied exception - * - * @param originalCause - * Exception which should be used to fail transaction for - * consumers of transaction - * future and listeners of transaction failure. - * @param phase phase in which the problem ensued - * @throws TransactionCommitFailedException - * on invocation of this method. - * originalCa - * @throws IllegalStateException - * if abort failed. - */ - private void abortBlocking( - final TransactionCommitFailedException originalCause) throws TransactionCommitFailedException { - Exception cause = originalCause; - try { - abortAsyncAll().get(); - } catch (InterruptedException | ExecutionException e) { - LOG.error("Tx: {} Error during Abort.", tx.getIdentifier(), e); - cause = new IllegalStateException("Abort failed.", e); - cause.addSuppressed(e); - } - Throwables.propagateIfPossible(cause, TransactionCommitFailedException.class); - } - - /** - * Invokes abort on underlying cohorts and returns future which - * completes once all abort on cohorts are completed. - * - * @return Future which will complete once all cohorts completed - * abort. - */ - @SuppressWarnings({"unchecked", "rawtypes"}) - private ListenableFuture abortAsyncAll() { - - final ListenableFuture[] ops = new ListenableFuture[cohorts.size()]; - int index = 0; - for (final DOMStoreThreePhaseCommitCohort cohort : cohorts) { - ops[index++] = cohort.abort(); - } - - /* - * We are returning all futures as list, not only succeeded ones in - * order to fail composite future if any of them failed. - * See Futures.allAsList for this description. - */ - return (ListenableFuture) Futures.allAsList(ops); - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMDataBrokerTransactionChainImpl.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMDataBrokerTransactionChainImpl.java deleted file mode 100755 index 2848b2de72..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMDataBrokerTransactionChainImpl.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.broker.impl; - -import static com.google.common.base.Preconditions.checkState; -import static java.util.Objects.requireNonNull; - -import com.google.common.base.Supplier; -import com.google.common.util.concurrent.FutureCallback; -import com.google.common.util.concurrent.Futures; -import com.google.common.util.concurrent.ListenableFuture; -import com.google.common.util.concurrent.MoreExecutors; -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; -import java.util.Collection; -import java.util.Map; -import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; -import java.util.concurrent.atomic.AtomicLong; -import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener; -import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction; -import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * NormalizedNode implementation of {@link org.opendaylight.controller.md.sal.common.api.data.TransactionChain} which - * is backed - * by several {@link DOMStoreTransactionChain} differentiated by provided - * {@link org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType} type. - */ -@Deprecated(forRemoval = true) -final class DOMDataBrokerTransactionChainImpl extends - AbstractDOMForwardedTransactionFactory implements DOMTransactionChain { - private enum State { - RUNNING, CLOSING, CLOSED, FAILED, - } - - private static final AtomicIntegerFieldUpdater COUNTER_UPDATER - = AtomicIntegerFieldUpdater.newUpdater(DOMDataBrokerTransactionChainImpl.class, "counter"); - private static final AtomicReferenceFieldUpdater STATE_UPDATER - = AtomicReferenceFieldUpdater.newUpdater(DOMDataBrokerTransactionChainImpl.class, State.class, "state"); - private static final Logger LOG = LoggerFactory.getLogger(DOMDataBrokerTransactionChainImpl.class); - private final AtomicLong txNum = new AtomicLong(); - private final AbstractDOMDataBroker broker; - private final TransactionChainListener listener; - private final long chainId; - - private volatile State state = State.RUNNING; - private volatile int counter = 0; - - /** - * DOMDataBrokerTransactionChainImpl constructor. - * - * @param chainId ID of transaction chain - * @param chains Backing {@link DOMStoreTransactionChain}s. - * @param broker Commit Coordinator which should be used to coordinate commits - * of transaction - * produced by this chain. - * @param listener Listener, which listens on transaction chain events. - * @throws NullPointerException If any of arguments is null. - */ - DOMDataBrokerTransactionChainImpl(final long chainId, - final Map chains, - final AbstractDOMDataBroker broker, - final TransactionChainListener listener) { - super(chains); - this.chainId = chainId; - this.broker = requireNonNull(broker); - this.listener = requireNonNull(listener); - } - - private void checkNotFailed() { - checkState(state != State.FAILED, "Transaction chain has failed"); - } - - @Override - protected Object newTransactionIdentifier() { - return "DOM-CHAIN-" + chainId + "-" + txNum.getAndIncrement(); - } - - @Override - public ListenableFuture commit(final DOMDataWriteTransaction transaction, - final Collection cohorts, final Supplier futureValueSupplier) { - checkNotFailed(); - checkNotClosed(); - - final ListenableFuture ret = broker.commit(transaction, cohorts, futureValueSupplier); - - COUNTER_UPDATER.incrementAndGet(this); - Futures.addCallback(ret, new FutureCallback() { - @Override - public void onSuccess(final T result) { - transactionCompleted(); - } - - @Override - public void onFailure(final Throwable throwable) { - transactionFailed(transaction, throwable); - } - }, MoreExecutors.directExecutor()); - - return ret; - } - - @Override - public void close() { - final boolean success = STATE_UPDATER.compareAndSet(this, State.RUNNING, State.CLOSING); - if (!success) { - LOG.debug("Chain {} is no longer running", this); - return; - } - - super.close(); - for (DOMStoreTransactionChain subChain : getTxFactories().values()) { - subChain.close(); - } - - if (counter == 0) { - finishClose(); - } - } - - private void finishClose() { - state = State.CLOSED; - listener.onTransactionChainSuccessful(this); - } - - @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", - justification = "https://github.com/spotbugs/spotbugs/issues/811") - private void transactionCompleted() { - if (COUNTER_UPDATER.decrementAndGet(this) == 0 && state == State.CLOSING) { - finishClose(); - } - } - - @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", - justification = "https://github.com/spotbugs/spotbugs/issues/811") - private void transactionFailed(final DOMDataWriteTransaction tx, final Throwable cause) { - state = State.FAILED; - LOG.debug("Transaction chain {} failed.", this, cause); - listener.onTransactionChainFailed(this, tx, cause); - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMForwardedReadOnlyTransaction.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMForwardedReadOnlyTransaction.java deleted file mode 100644 index 4b685eacb7..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMForwardedReadOnlyTransaction.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.broker.impl; - -import com.google.common.base.Optional; -import com.google.common.util.concurrent.CheckedFuture; -import java.util.Map; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; -import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; - -/** - * Read Only Transaction, which is composed of several - * {@link DOMStoreReadTransaction} transactions. Subtransaction is selected by - * {@link LogicalDatastoreType} type parameter in - * {@link #read(LogicalDatastoreType, YangInstanceIdentifier)}. - */ -@Deprecated(forRemoval = true) -class DOMForwardedReadOnlyTransaction extends - AbstractDOMForwardedCompositeTransaction implements - DOMDataReadOnlyTransaction { - - protected DOMForwardedReadOnlyTransaction(final Object identifier, - final Map backingTxs) { - super(identifier, backingTxs); - } - - @Override - public CheckedFuture>, ReadFailedException> read( - final LogicalDatastoreType store, final YangInstanceIdentifier path) { - return getSubtransaction(store).read(path); - } - - @Override - public CheckedFuture exists( - final LogicalDatastoreType store, - final YangInstanceIdentifier path) { - return getSubtransaction(store).exists(path); - } - - @Override - public void close() { - closeSubtransactions(); - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMForwardedReadWriteTransaction.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMForwardedReadWriteTransaction.java deleted file mode 100644 index 22dc81fedb..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMForwardedReadWriteTransaction.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.md.sal.dom.broker.impl; - -import com.google.common.base.Optional; -import com.google.common.util.concurrent.CheckedFuture; -import java.util.Map; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; -import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; - -/** - * Read-Write Transaction, which is composed of several - * {@link DOMStoreReadWriteTransaction} transactions. Subtransaction is selected by - * {@link LogicalDatastoreType} type parameter in: - * - *

    - *
  • {@link #read(LogicalDatastoreType, YangInstanceIdentifier)} - *
  • {@link #put(LogicalDatastoreType, YangInstanceIdentifier, NormalizedNode)} - *
  • {@link #delete(LogicalDatastoreType, YangInstanceIdentifier)} - *
  • {@link #merge(LogicalDatastoreType, YangInstanceIdentifier, NormalizedNode)} - *
- * {@link #commit()} will result in invocation of - * {@link DOMDataCommitImplementation#submit(org.opendaylight.controller.md.sal.dom - * .api.DOMDataWriteTransaction, Iterable)} - * invocation with all {@link org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort} - * for underlying transactions. - * - */ -@Deprecated(forRemoval = true) -final class DOMForwardedReadWriteTransaction extends DOMForwardedWriteTransaction - implements DOMDataReadWriteTransaction { - protected DOMForwardedReadWriteTransaction(final Object identifier, - final Map backingTxs, - final AbstractDOMForwardedTransactionFactory commitImpl) { - super(identifier, backingTxs, commitImpl); - } - - @Override - public CheckedFuture>, ReadFailedException> read( - final LogicalDatastoreType store, final YangInstanceIdentifier path) { - return getSubtransaction(store).read(path); - } - - @Override - public CheckedFuture exists( - final LogicalDatastoreType store, - final YangInstanceIdentifier path) { - return getSubtransaction(store).exists(path); - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMForwardedWriteTransaction.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMForwardedWriteTransaction.java deleted file mode 100644 index 58c91001c4..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMForwardedWriteTransaction.java +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.broker.impl; - -import static com.google.common.base.Preconditions.checkState; -import static java.util.Objects.requireNonNull; - -import com.google.common.base.Supplier; -import com.google.common.util.concurrent.FluentFuture; -import com.google.common.util.concurrent.Futures; -import com.google.common.util.concurrent.ListenableFuture; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Map; -import java.util.concurrent.Future; -import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction; -import org.opendaylight.mdsal.common.api.CommitInfo; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Read-Write Transaction, which is composed of several - * {@link DOMStoreWriteTransaction} transactions. A sub-transaction is selected by - * {@link LogicalDatastoreType} type parameter in: - * - *

- *

    - *
  • {@link #put(LogicalDatastoreType, YangInstanceIdentifier, NormalizedNode)} - *
  • {@link #delete(LogicalDatastoreType, YangInstanceIdentifier)} - *
  • {@link #merge(LogicalDatastoreType, YangInstanceIdentifier, NormalizedNode)} - *
- * - *

- * {@link #commit()} will result in invocation of - * {@link DOMDataCommitImplementation#submit(org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction, - * Iterable)} invocation with all {@link org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort} - * for underlying transactions. - * - * @param Subtype of {@link DOMStoreWriteTransaction} which is used as - * subtransaction. - */ -@Deprecated(forRemoval = true) -class DOMForwardedWriteTransaction extends - AbstractDOMForwardedCompositeTransaction implements DOMDataWriteTransaction { - @SuppressWarnings("rawtypes") - private static final AtomicReferenceFieldUpdater - IMPL_UPDATER = AtomicReferenceFieldUpdater - .newUpdater(DOMForwardedWriteTransaction.class, AbstractDOMForwardedTransactionFactory.class, "commitImpl"); - @SuppressWarnings("rawtypes") - private static final AtomicReferenceFieldUpdater FUTURE_UPDATER - = AtomicReferenceFieldUpdater.newUpdater(DOMForwardedWriteTransaction.class, Future.class, "commitFuture"); - private static final Logger LOG = LoggerFactory.getLogger(DOMForwardedWriteTransaction.class); - private static final Future CANCELLED_FUTURE = Futures.immediateCancelledFuture(); - - /** - * Implementation of real commit. It also acts as an indication that - * the transaction is running -- which we flip atomically using - * {@link #IMPL_UPDATER}. - */ - private volatile AbstractDOMForwardedTransactionFactory commitImpl; - - /** - * Future task of transaction commit. It starts off as null, but is - * set appropriately on {@link #commit()} and {@link #cancel()} via - * {@link AtomicReferenceFieldUpdater#lazySet(Object, Object)}. - * - *

- * Lazy set is safe for use because it is only referenced to in the - * {@link #cancel()} slow path, where we will busy-wait for it. The - * fast path gets the benefit of a store-store barrier instead of the - * usual store-load barrier. - */ - private volatile Future commitFuture; - - protected DOMForwardedWriteTransaction(final Object identifier, final Map backingTxs, - final AbstractDOMForwardedTransactionFactory commitImpl) { - super(identifier, backingTxs); - this.commitImpl = requireNonNull(commitImpl, "commitImpl must not be null."); - } - - @Override - public void put(final LogicalDatastoreType store, final YangInstanceIdentifier path, - final NormalizedNode data) { - checkRunning(commitImpl); - getSubtransaction(store).write(path, data); - } - - @Override - public void delete(final LogicalDatastoreType store, final YangInstanceIdentifier path) { - checkRunning(commitImpl); - getSubtransaction(store).delete(path); - } - - @Override - public void merge(final LogicalDatastoreType store, final YangInstanceIdentifier path, - final NormalizedNode data) { - checkRunning(commitImpl); - getSubtransaction(store).merge(path, data); - } - - @Override - public boolean cancel() { - final AbstractDOMForwardedTransactionFactory impl = IMPL_UPDATER.getAndSet(this, null); - if (impl != null) { - LOG.trace("Transaction {} cancelled before submit", getIdentifier()); - FUTURE_UPDATER.lazySet(this, CANCELLED_FUTURE); - closeSubtransactions(); - return true; - } - - // The transaction is in process of being submitted or cancelled. Busy-wait - // for the corresponding future. - Future future; - do { - future = commitFuture; - } while (future == null); - - return future.cancel(false); - } - - @Override - public FluentFuture commit() { - return FluentFuture.from(doCommit(CommitInfo::empty)); - } - - @SuppressWarnings("checkstyle:IllegalCatch") - private ListenableFuture doCommit(final Supplier futureValueSupplier) { - final AbstractDOMForwardedTransactionFactory impl = IMPL_UPDATER.getAndSet(this, null); - checkRunning(impl); - - final Collection txns = getSubtransactions(); - final Collection cohorts = new ArrayList<>(txns.size()); - - ListenableFuture ret; - try { - for (DOMStoreWriteTransaction txn : txns) { - cohorts.add(txn.ready()); - } - - ret = impl.commit(this, cohorts, futureValueSupplier); - } catch (RuntimeException e) { - ret = FluentFuture.from(Futures.immediateFailedFuture( - TransactionCommitFailedExceptionMapper.COMMIT_ERROR_MAPPER.apply(e))); - } - FUTURE_UPDATER.lazySet(this, ret); - return ret; - } - - private void checkRunning(final AbstractDOMForwardedTransactionFactory impl) { - checkState(impl != null, "Transaction %s is no longer running", getIdentifier()); - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMNotificationRouter.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMNotificationRouter.java deleted file mode 100644 index e8e6452f09..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMNotificationRouter.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.broker.impl; - -import com.google.common.util.concurrent.ListenableFuture; -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; -import java.util.Collection; -import java.util.concurrent.TimeUnit; -import org.opendaylight.controller.md.sal.dom.api.DOMNotification; -import org.opendaylight.controller.md.sal.dom.api.DOMNotificationListener; -import org.opendaylight.controller.md.sal.dom.api.DOMNotificationPublishService; -import org.opendaylight.controller.md.sal.dom.api.DOMNotificationService; -import org.opendaylight.controller.md.sal.dom.spi.DOMNotificationSubscriptionListener; -import org.opendaylight.controller.md.sal.dom.spi.DOMNotificationSubscriptionListenerRegistry; -import org.opendaylight.controller.sal.core.compat.LegacyDOMNotificationServiceAdapter; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; - -/** - * Joint implementation of {@link DOMNotificationPublishService} and {@link DOMNotificationService}. Provides - * routing of notifications from publishers to subscribers. - * - *

- * Internal implementation works by allocating a two-handler Disruptor. The first handler delivers notifications - * to subscribed listeners and the second one notifies whoever may be listening on the returned future. Registration - * state tracking is performed by a simple immutable multimap -- when a registration or unregistration occurs we - * re-generate the entire map from scratch and set it atomically. While registrations/unregistrations synchronize - * on this instance, notifications do not take any locks here. - * - *

- * The fully-blocking {@link #offerNotification(DOMNotification)} - * is realized using the Disruptor's native operations. The bounded-blocking - * {@link #offerNotification(DOMNotification, long, TimeUnit)} - * is realized by arming a background wakeup interrupt. - */ -@Deprecated(forRemoval = true) -@SuppressFBWarnings(value = "NP_NONNULL_PARAM_VIOLATION", justification = "Void is the only allowed value") -public final class DOMNotificationRouter extends LegacyDOMNotificationServiceAdapter implements AutoCloseable, - DOMNotificationPublishService, DOMNotificationSubscriptionListenerRegistry { - - private final org.opendaylight.mdsal.dom.api.DOMNotificationPublishService delegateNotificationPublishService; - private final org.opendaylight.mdsal.dom.spi.DOMNotificationSubscriptionListenerRegistry delegateListenerRegistry; - - private DOMNotificationRouter( - final org.opendaylight.mdsal.dom.api.DOMNotificationService delegateNotificationService, - final org.opendaylight.mdsal.dom.api.DOMNotificationPublishService delegateNotificationPublishService, - final org.opendaylight.mdsal.dom.spi.DOMNotificationSubscriptionListenerRegistry delegateListenerRegistry) { - super(delegateNotificationService); - this.delegateNotificationPublishService = delegateNotificationPublishService; - this.delegateListenerRegistry = delegateListenerRegistry; - } - - public static DOMNotificationRouter create(final int queueDepth) { - final org.opendaylight.mdsal.dom.broker.DOMNotificationRouter delegate = - org.opendaylight.mdsal.dom.broker.DOMNotificationRouter.create(queueDepth); - return create(delegate, delegate, delegate); - } - - public static DOMNotificationRouter create(final int queueDepth, final long spinTime, final long parkTime, - final TimeUnit unit) { - final org.opendaylight.mdsal.dom.broker.DOMNotificationRouter delegate = - org.opendaylight.mdsal.dom.broker.DOMNotificationRouter.create(queueDepth, spinTime, parkTime, unit); - return create(delegate, delegate, delegate); - } - - public static DOMNotificationRouter create( - final org.opendaylight.mdsal.dom.api.DOMNotificationService delegateNotificationService, - final org.opendaylight.mdsal.dom.api.DOMNotificationPublishService delegateNotificationPublishService, - final org.opendaylight.mdsal.dom.spi.DOMNotificationSubscriptionListenerRegistry delegateListenerRegistry) { - return new DOMNotificationRouter(delegateNotificationService, delegateNotificationPublishService, - delegateListenerRegistry); - } - - @Override - public synchronized ListenerRegistration registerNotificationListener( - final T listener, final Collection types) { - return super.registerNotificationListener(listener, types); - } - - @Override - public ListenerRegistration registerSubscriptionListener( - final L listener) { - return delegateListenerRegistry.registerSubscriptionListener(listener); - } - - @Override - public ListenableFuture putNotification(final DOMNotification notification) throws InterruptedException { - return delegateNotificationPublishService.putNotification(notification); - } - - @Override - public ListenableFuture offerNotification(final DOMNotification notification) { - return delegateNotificationPublishService.offerNotification(notification); - } - - @Override - public ListenableFuture offerNotification(final DOMNotification notification, final long timeout, - final TimeUnit unit) throws InterruptedException { - return delegateNotificationPublishService.offerNotification(notification, timeout, unit); - } - - @Override - public void close() { - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMNotificationRouterEvent.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMNotificationRouterEvent.java deleted file mode 100644 index f733a2fc8b..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMNotificationRouterEvent.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.broker.impl; - -import static java.util.Objects.requireNonNull; - -import com.google.common.util.concurrent.ListenableFuture; -import com.google.common.util.concurrent.SettableFuture; -import com.lmax.disruptor.EventFactory; -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; -import java.util.Collection; -import org.opendaylight.controller.md.sal.dom.api.DOMNotification; -import org.opendaylight.controller.md.sal.dom.api.DOMNotificationListener; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * A single notification event in the disruptor ringbuffer. These objects are reused, - * so they do have mutable state. - */ -@Deprecated(forRemoval = true) -final class DOMNotificationRouterEvent { - private static final Logger LOG = LoggerFactory.getLogger(DOMNotificationRouterEvent.class); - public static final EventFactory FACTORY = DOMNotificationRouterEvent::new; - - private Collection> subscribers; - private DOMNotification notification; - private SettableFuture future; - - private DOMNotificationRouterEvent() { - // Hidden on purpose, initialized in initialize() - } - - @SuppressWarnings("checkstyle:hiddenField") - ListenableFuture initialize(final DOMNotification notification, - final Collection> - subscribers) { - this.notification = requireNonNull(notification); - this.subscribers = requireNonNull(subscribers); - this.future = SettableFuture.create(); - return this.future; - } - - void deliverNotification() { - LOG.trace("Start delivery of notification {}", notification); - for (ListenerRegistration r : subscribers) { - final DOMNotificationListener listener = r.getInstance(); - LOG.trace("Notifying listener {}", listener); - listener.onNotification(notification); - LOG.trace("Listener notification completed"); - } - LOG.trace("Delivery completed"); - } - - @SuppressFBWarnings(value = "NP_NONNULL_PARAM_VIOLATION", justification = "Void is the only allowed value") - void setFuture() { - future.set(null); - notification = null; - subscribers = null; - future = null; - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMRpcRouter.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMRpcRouter.java deleted file mode 100644 index 92c596bdf4..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMRpcRouter.java +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.broker.impl; - -import com.google.common.annotations.VisibleForTesting; -import com.google.common.collect.ImmutableSet; -import com.google.common.util.concurrent.CheckedFuture; -import com.google.common.util.concurrent.ListenableFuture; -import java.util.Collections; -import java.util.Map; -import java.util.Set; -import java.util.WeakHashMap; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcAvailabilityListener; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcException; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementation; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementationRegistration; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcProviderService; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcService; -import org.opendaylight.controller.md.sal.dom.spi.AbstractDOMRpcImplementationRegistration; -import org.opendaylight.controller.sal.core.compat.DOMRpcServiceAdapter; -import org.opendaylight.controller.sal.core.compat.LegacyDOMRpcResultFutureAdapter; -import org.opendaylight.controller.sal.core.compat.MdsalDOMRpcResultFutureAdapter; -import org.opendaylight.controller.sal.core.compat.RpcAvailabilityListenerAdapter; -import org.opendaylight.yangtools.concepts.AbstractListenerRegistration; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.opendaylight.yangtools.yang.model.api.SchemaContextListener; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; - -@Deprecated(forRemoval = true) -public final class DOMRpcRouter implements AutoCloseable, DOMRpcService, DOMRpcProviderService, SchemaContextListener { - // This mapping is used to translate mdsal DOMRpcImplementations to their corresponding legacy - // DOMRpcImplementations registered thru this interface when invoking a DOMRpcAvailabilityListener. - private final Map implMapping = - Collections.synchronizedMap(new WeakHashMap<>()); - - private final org.opendaylight.mdsal.dom.api.DOMRpcService delegateRpcService; - private final org.opendaylight.mdsal.dom.api.DOMRpcProviderService delegateRpcProviderService; - - // Note - this is only used for backward compatibility for UTs that use the empty constructor which creates - // a local mdsal DOMRpcRouter that needs to be updated with the SchemaContext. In production, the mdsal API - // services are passed via the constructor and are set up externally with the SchemaContext. - private final SchemaContextListener delegateSchemaContextListener; - - @VisibleForTesting - public DOMRpcRouter() { - org.opendaylight.mdsal.dom.broker.DOMRpcRouter delegate = new org.opendaylight.mdsal.dom.broker.DOMRpcRouter(); - this.delegateRpcService = delegate.getRpcService(); - this.delegateRpcProviderService = delegate.getRpcProviderService(); - this.delegateSchemaContextListener = delegate; - } - - public DOMRpcRouter(final org.opendaylight.mdsal.dom.api.DOMRpcService delegateRpcService, - final org.opendaylight.mdsal.dom.api.DOMRpcProviderService delegateRpcProviderService) { - this.delegateRpcService = delegateRpcService; - this.delegateRpcProviderService = delegateRpcProviderService; - this.delegateSchemaContextListener = null; - } - - @Override - public DOMRpcImplementationRegistration registerRpcImplementation( - final T implementation, final DOMRpcIdentifier... rpcs) { - return registerRpcImplementation(implementation, ImmutableSet.copyOf(rpcs)); - } - - @Override - public synchronized DOMRpcImplementationRegistration registerRpcImplementation( - final T implementation, final Set rpcs) { - org.opendaylight.mdsal.dom.api.DOMRpcImplementation delegateImpl = - new org.opendaylight.mdsal.dom.api.DOMRpcImplementation() { - @Override - public ListenableFuture invokeRpc( - final org.opendaylight.mdsal.dom.api.DOMRpcIdentifier rpc, final NormalizedNode input) { - return new MdsalDOMRpcResultFutureAdapter(implementation.invokeRpc(DOMRpcIdentifier.fromMdsal(rpc), - input)); - } - - - @Override - public long invocationCost() { - return implementation.invocationCost(); - } - }; - - implMapping.put(delegateImpl, implementation); - - final org.opendaylight.mdsal.dom.api.DOMRpcImplementationRegistration - reg = delegateRpcProviderService - .registerRpcImplementation(delegateImpl, DOMRpcServiceAdapter.convert(rpcs)); - - return new AbstractDOMRpcImplementationRegistration(implementation) { - @Override - protected void removeRegistration() { - reg.close(); - implMapping.remove(delegateImpl); - } - }; - } - - @Override - public CheckedFuture invokeRpc(final SchemaPath type, - final NormalizedNode input) { - final ListenableFuture future = - delegateRpcService.invokeRpc(type, input); - return future instanceof MdsalDOMRpcResultFutureAdapter ? ((MdsalDOMRpcResultFutureAdapter)future).delegate() - : new LegacyDOMRpcResultFutureAdapter(future); - } - - @Override - public synchronized ListenerRegistration registerRpcListener( - final T listener) { - final ListenerRegistration reg = - delegateRpcService.registerRpcListener(new RpcAvailabilityListenerAdapter(listener) { - @Override - public boolean acceptsImplementation(final org.opendaylight.mdsal.dom.api.DOMRpcImplementation impl) { - // If the DOMRpcImplementation wasn't registered thru this interface then the mapping won't be - // present - in this we can't call the listener so just assume acceptance which is the default - // behavior. This should be fine since a legacy listener would not be aware of implementation types - // registered via the new mdsal API. - final DOMRpcImplementation legacyImpl = implMapping.get(impl); - return legacyImpl != null ? delegate().acceptsImplementation(legacyImpl) : true; - } - }); - - return new AbstractListenerRegistration(listener) { - @Override - protected void removeRegistration() { - reg.close(); - } - }; - } - - @Override - public void close() { - } - - @Override - @VisibleForTesting - public void onGlobalContextUpdated(final SchemaContext context) { - if (delegateSchemaContextListener != null) { - delegateSchemaContextListener.onGlobalContextUpdated(context); - } - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMRpcRoutingTable.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMRpcRoutingTable.java deleted file mode 100644 index c133f8bc59..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMRpcRoutingTable.java +++ /dev/null @@ -1,192 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.broker.impl; - -import static java.util.Objects.requireNonNull; - -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableMap.Builder; -import com.google.common.collect.LinkedListMultimap; -import com.google.common.collect.ListMultimap; -import com.google.common.util.concurrent.CheckedFuture; -import com.google.common.util.concurrent.Futures; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcAvailabilityListener; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcException; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementation; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementationNotAvailableException; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult; -import org.opendaylight.controller.md.sal.dom.broker.spi.rpc.RpcRoutingStrategy; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.model.api.Module; -import org.opendaylight.yangtools.yang.model.api.RpcDefinition; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; - -@Deprecated(forRemoval = true) -final class DOMRpcRoutingTable { - - static final DOMRpcRoutingTable EMPTY = new DOMRpcRoutingTable(ImmutableMap.of(), null); - - private final Map rpcs; - private final SchemaContext schemaContext; - - private DOMRpcRoutingTable(final Map rpcs, - final SchemaContext schemaContext) { - this.rpcs = requireNonNull(rpcs); - this.schemaContext = schemaContext; - } - - static ListMultimap decomposeIdentifiers(final Set rpcs) { - final ListMultimap ret = LinkedListMultimap.create(); - for (DOMRpcIdentifier i : rpcs) { - ret.put(i.getType(), i.getContextReference()); - } - return ret; - } - - DOMRpcRoutingTable add(final DOMRpcImplementation implementation, final Set rpcsToAdd) { - if (rpcsToAdd.isEmpty()) { - return this; - } - - // First decompose the identifiers to a multimap - final ListMultimap toAdd = decomposeIdentifiers(rpcsToAdd); - - // Now iterate over existing entries, modifying them as appropriate... - final Builder mb = ImmutableMap.builder(); - for (Entry re : this.rpcs.entrySet()) { - List newRpcs = new ArrayList<>(toAdd.removeAll(re.getKey())); - if (!newRpcs.isEmpty()) { - final AbstractDOMRpcRoutingTableEntry ne = re.getValue().add(implementation, newRpcs); - mb.put(re.getKey(), ne); - } else { - mb.put(re); - } - } - - // Finally add whatever is left in the decomposed multimap - for (Entry> e : toAdd.asMap().entrySet()) { - final Builder> vb = ImmutableMap.builder(); - final List v = Collections.singletonList(implementation); - for (YangInstanceIdentifier i : e.getValue()) { - vb.put(i, v); - } - - mb.put(e.getKey(), createRpcEntry(schemaContext, e.getKey(), vb.build())); - } - - return new DOMRpcRoutingTable(mb.build(), schemaContext); - } - - DOMRpcRoutingTable remove(final DOMRpcImplementation implementation, final Set rpcIds) { - if (rpcIds.isEmpty()) { - return this; - } - - // First decompose the identifiers to a multimap - final ListMultimap toRemove = decomposeIdentifiers(rpcIds); - - // Now iterate over existing entries, modifying them as appropriate... - final Builder b = ImmutableMap.builder(); - for (Entry e : this.rpcs.entrySet()) { - final List removed = new ArrayList<>(toRemove.removeAll(e.getKey())); - if (!removed.isEmpty()) { - final AbstractDOMRpcRoutingTableEntry ne = e.getValue().remove(implementation, removed); - if (ne != null) { - b.put(e.getKey(), ne); - } - } else { - b.put(e); - } - } - - // All done, whatever is in toRemove, was not there in the first place - return new DOMRpcRoutingTable(b.build(), schemaContext); - } - - boolean contains(final DOMRpcIdentifier input) { - final AbstractDOMRpcRoutingTableEntry contexts = rpcs.get(input.getType()); - return contexts != null && contexts.containsContext(input.getContextReference()); - } - - Map> getRpcs(final DOMRpcAvailabilityListener listener) { - final Map> ret = new HashMap<>(rpcs.size()); - for (Entry e : rpcs.entrySet()) { - final Set ids = e.getValue().registeredIdentifiers(listener); - if (!ids.isEmpty()) { - ret.put(e.getKey(), ids); - } - } - - return ret; - } - - private static RpcDefinition findRpcDefinition(final SchemaContext context, final SchemaPath schemaPath) { - if (context != null) { - final QName qname = schemaPath.getPathFromRoot().iterator().next(); - final Module module = context.findModule(qname.getModule()).orElse(null); - if (module != null && module.getRpcs() != null) { - for (RpcDefinition rpc : module.getRpcs()) { - if (qname.equals(rpc.getQName())) { - return rpc; - } - } - } - } - - return null; - } - - private static AbstractDOMRpcRoutingTableEntry createRpcEntry(final SchemaContext context, final SchemaPath key, - final Map> implementations) { - final RpcDefinition rpcDef = findRpcDefinition(context, key); - if (rpcDef == null) { - return new UnknownDOMRpcRoutingTableEntry(key, implementations); - } - - final RpcRoutingStrategy strategy = RpcRoutingStrategy.from(rpcDef); - if (strategy.isContextBasedRouted()) { - return new RoutedDOMRpcRoutingTableEntry(rpcDef, YangInstanceIdentifier.of(strategy.getLeaf()), - implementations); - - } - - return new GlobalDOMRpcRoutingTableEntry(rpcDef, implementations); - } - - CheckedFuture invokeRpc(final SchemaPath type, final NormalizedNode input) { - final AbstractDOMRpcRoutingTableEntry entry = rpcs.get(type); - if (entry == null) { - return Futures.immediateFailedCheckedFuture( - new DOMRpcImplementationNotAvailableException("No implementation of RPC %s available", type)); - } - - return entry.invokeRpc(input); - } - - DOMRpcRoutingTable setSchemaContext(final SchemaContext context) { - final Builder b = ImmutableMap.builder(); - - for (Entry e : rpcs.entrySet()) { - b.put(e.getKey(), createRpcEntry(context, e.getKey(), e.getValue().getImplementations())); - } - - return new DOMRpcRoutingTable(b.build(), context); - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/GlobalDOMRpcRoutingTableEntry.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/GlobalDOMRpcRoutingTableEntry.java deleted file mode 100644 index a0d83b963c..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/GlobalDOMRpcRoutingTableEntry.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.broker.impl; - -import static java.util.Objects.requireNonNull; - -import com.google.common.util.concurrent.CheckedFuture; -import java.util.List; -import java.util.Map; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcException; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementation; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.model.api.RpcDefinition; - -@Deprecated(forRemoval = true) -final class GlobalDOMRpcRoutingTableEntry extends AbstractDOMRpcRoutingTableEntry { - private final DOMRpcIdentifier rpcId; - - private GlobalDOMRpcRoutingTableEntry(final DOMRpcIdentifier rpcId, - final Map> impls) { - super(rpcId.getType(), impls); - this.rpcId = requireNonNull(rpcId); - } - - // We do not need the RpcDefinition, but this makes sure we do not - // forward something we don't know to be an RPC. - GlobalDOMRpcRoutingTableEntry(final RpcDefinition def, - final Map> impls) { - super(def.getPath(), impls); - this.rpcId = DOMRpcIdentifier.create(def.getPath()); - } - - @Override - protected CheckedFuture invokeRpc(final NormalizedNode input) { - return getImplementations(YangInstanceIdentifier.empty()).get(0).invokeRpc(rpcId, input); - } - - @Override - protected GlobalDOMRpcRoutingTableEntry newInstance( - final Map> impls) { - return new GlobalDOMRpcRoutingTableEntry(rpcId, impls); - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/PingPongDataBroker.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/PingPongDataBroker.java deleted file mode 100644 index 994522fed3..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/PingPongDataBroker.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.broker.impl; - -import static java.util.Objects.requireNonNull; - -import org.eclipse.jdt.annotation.NonNull; -import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener; -import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; -import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener; -import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeService; -import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeIdentifier; -import org.opendaylight.controller.md.sal.dom.spi.ForwardingDOMDataBroker; -import org.opendaylight.yangtools.concepts.ListenerRegistration; - -/** - * An implementation of a {@link DOMDataBroker}, which forwards most requests to a delegate. - * - *

- * Its interpretation of the API contract is somewhat looser, specifically it does not - * guarantee transaction ordering between transactions allocated directly from the broker - * and its transaction chains. - */ -@Deprecated(forRemoval = true) -public final class PingPongDataBroker extends ForwardingDOMDataBroker implements AutoCloseable, - DOMDataTreeChangeService { - private final DOMDataBroker delegate; - - /** - * Instantiate a new broker, backed by the the specified delegate - * {@link DOMDataBroker}. - * - * @param delegate Backend broker, may not be null. - */ - public PingPongDataBroker(final @NonNull DOMDataBroker delegate) { - this.delegate = requireNonNull(delegate); - } - - @Override - protected DOMDataBroker delegate() { - return delegate; - } - - @Override - public PingPongTransactionChain createTransactionChain(final TransactionChainListener listener) { - return new PingPongTransactionChain(delegate, listener); - } - - @Override - public void close() { - // intentionally NOOP - } - - @Override - public ListenerRegistration registerDataTreeChangeListener( - final DOMDataTreeIdentifier treeId, final L listener) { - final DOMDataTreeChangeService treeService = (DOMDataTreeChangeService) delegate.getSupportedExtensions() - .get(DOMDataTreeChangeService.class); - if (treeService != null) { - return treeService.registerDataTreeChangeListener(treeId, listener); - } - - throw new UnsupportedOperationException("Delegate " + delegate + " does not support required functionality"); - } - - @Override - public String toString() { - return "PingPongDataBroker backed by " + delegate; - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/PingPongTransaction.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/PingPongTransaction.java deleted file mode 100644 index 58cf5e725b..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/PingPongTransaction.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.broker.impl; - -import static java.util.Objects.requireNonNull; - -import com.google.common.base.MoreObjects; -import com.google.common.base.MoreObjects.ToStringHelper; -import com.google.common.util.concurrent.FutureCallback; -import com.google.common.util.concurrent.ListenableFuture; -import com.google.common.util.concurrent.SettableFuture; -import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction; -import org.opendaylight.mdsal.common.api.CommitInfo; - -/** - * Transaction context. Tracks the relationship with the backend transaction. - * We never leak this class to the user and have it implement the {@link FutureCallback} - * interface so we have a simple way of propagating the result. - */ -@Deprecated(forRemoval = true) -final class PingPongTransaction implements FutureCallback { - private final DOMDataReadWriteTransaction delegate; - private final SettableFuture future; - private DOMDataReadWriteTransaction frontendTransaction; - - PingPongTransaction(final DOMDataReadWriteTransaction delegate) { - this.delegate = requireNonNull(delegate); - future = SettableFuture.create(); - } - - DOMDataReadWriteTransaction getTransaction() { - return delegate; - } - - DOMDataReadWriteTransaction getFrontendTransaction() { - return frontendTransaction; - } - - ListenableFuture getCommitFuture() { - return future; - } - - @Override - public void onSuccess(final CommitInfo result) { - future.set(result); - } - - @Override - public void onFailure(final Throwable throwable) { - future.setException(throwable); - } - - void recordFrontendTransaction(final DOMDataReadWriteTransaction tx) { - if (frontendTransaction != null) { - frontendTransaction = tx; - } - } - - @Override - public String toString() { - return addToStringAttributes(MoreObjects.toStringHelper(this)).toString(); - } - - protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) { - return toStringHelper.add("delegate", delegate); - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/PingPongTransactionChain.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/PingPongTransactionChain.java deleted file mode 100644 index e72315520f..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/PingPongTransactionChain.java +++ /dev/null @@ -1,482 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.broker.impl; - -import static com.google.common.base.Preconditions.checkState; -import static com.google.common.base.Verify.verify; -import static java.util.Objects.requireNonNull; - -import com.google.common.base.Optional; -import com.google.common.util.concurrent.CheckedFuture; -import com.google.common.util.concurrent.FluentFuture; -import com.google.common.util.concurrent.FutureCallback; -import com.google.common.util.concurrent.MoreExecutors; -import java.util.AbstractMap.SimpleImmutableEntry; -import java.util.Map.Entry; -import java.util.concurrent.CancellationException; -import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; -import org.checkerframework.checker.lock.qual.GuardedBy; -import org.checkerframework.checker.lock.qual.Holding; -import org.eclipse.jdt.annotation.NonNull; -import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; -import org.opendaylight.controller.md.sal.common.api.data.TransactionChain; -import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener; -import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; -import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction; -import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction; -import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction; -import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain; -import org.opendaylight.controller.md.sal.dom.spi.ForwardingDOMDataReadWriteTransaction; -import org.opendaylight.mdsal.common.api.CommitInfo; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * An implementation of {@link DOMTransactionChain}, which has a very specific - * behavior, which some users may find surprising. If keeps the general - * intent of the contract, but it makes sure there are never more than two - * transactions allocated at any given time: one of them is being committed, - * and while that is happening, the other one acts as the scratch pad. Once - * the committing transaction completes successfully, the scratch transaction - * is enqueued as soon as it is ready. - * - *

- * This mode of operation means that there is no inherent isolation between - * the front-end transactions and transactions cannot be reasonably cancelled. - * - *

- * It furthermore means that the transactions returned by {@link #newReadOnlyTransaction()} - * counts as an outstanding transaction and the user may not allocate multiple - * read-only transactions at the same time. - */ -@Deprecated(forRemoval = true) -public final class PingPongTransactionChain implements DOMTransactionChain { - private static final Logger LOG = LoggerFactory.getLogger(PingPongTransactionChain.class); - private final TransactionChainListener listener; - private final DOMTransactionChain delegate; - - @GuardedBy("this") - private boolean failed; - @GuardedBy("this") - private PingPongTransaction shutdownTx; - @GuardedBy("this") - private Entry deadTx; - - /** - * This updater is used to manipulate the "ready" transaction. We perform only atomic - * get-and-set on it. - */ - private static final AtomicReferenceFieldUpdater READY_UPDATER - = AtomicReferenceFieldUpdater - .newUpdater(PingPongTransactionChain.class, PingPongTransaction.class, "readyTx"); - private volatile PingPongTransaction readyTx; - - /** - * This updater is used to manipulate the "locked" transaction. A locked transaction - * means we know that the user still holds a transaction and should at some point call - * us. We perform on compare-and-swap to ensure we properly detect when a user is - * attempting to allocated multiple transactions concurrently. - */ - private static final AtomicReferenceFieldUpdater LOCKED_UPDATER - = AtomicReferenceFieldUpdater - .newUpdater(PingPongTransactionChain.class, PingPongTransaction.class, "lockedTx"); - private volatile PingPongTransaction lockedTx; - - /** - * This updater is used to manipulate the "inflight" transaction. There can be at most - * one of these at any given time. We perform only compare-and-swap on these. - */ - private static final AtomicReferenceFieldUpdater INFLIGHT_UPDATER - = AtomicReferenceFieldUpdater - .newUpdater(PingPongTransactionChain.class, PingPongTransaction.class, "inflightTx"); - private volatile PingPongTransaction inflightTx; - - PingPongTransactionChain(final DOMDataBroker broker, final TransactionChainListener listener) { - this.listener = requireNonNull(listener); - this.delegate = broker.createTransactionChain(new TransactionChainListener() { - @Override - public void onTransactionChainFailed(final TransactionChain chain, - final AsyncTransaction transaction, final Throwable cause) { - LOG.debug("Transaction chain {} reported failure in {}", chain, transaction, cause); - delegateFailed(chain, cause); - } - - @Override - public void onTransactionChainSuccessful(final TransactionChain chain) { - delegateSuccessful(chain); - } - }); - } - - void delegateSuccessful(final TransactionChain chain) { - final Entry canceled; - synchronized (this) { - // This looks weird, but we need not hold the lock while invoking callbacks - canceled = deadTx; - } - - if (canceled == null) { - listener.onTransactionChainSuccessful(this); - return; - } - - // Backend shutdown successful, but we have a batch of transactions we have to report as dead due to the - // user calling cancel(). - final PingPongTransaction tx = canceled.getKey(); - final Throwable cause = canceled.getValue(); - LOG.debug("Transaction chain {} successful, failing cancelled transaction {}", chain, tx, cause); - - listener.onTransactionChainFailed(this, tx.getFrontendTransaction(), cause); - tx.onFailure(cause); - } - - void delegateFailed(final TransactionChain chain, final Throwable cause) { - - final DOMDataReadWriteTransaction frontend; - final PingPongTransaction tx = inflightTx; - if (tx == null) { - LOG.warn("Transaction chain {} failed with no pending transactions", chain); - frontend = null; - } else { - frontend = tx.getFrontendTransaction(); - } - - listener.onTransactionChainFailed(this, frontend, cause); - - synchronized (this) { - failed = true; - - /* - * If we do not have a locked transaction, we need to ensure that - * the backend transaction is cancelled. Otherwise we can defer - * until the user calls us. - */ - if (lockedTx == null) { - processIfReady(); - } - } - } - - private synchronized PingPongTransaction slowAllocateTransaction() { - checkState(shutdownTx == null, "Transaction chain %s has been shut down", this); - - if (deadTx != null) { - throw new IllegalStateException( - String.format("Transaction chain %s has failed due to transaction %s being canceled", this, - deadTx.getKey()), deadTx.getValue()); - } - - final DOMDataReadWriteTransaction delegateTx = delegate.newReadWriteTransaction(); - final PingPongTransaction newTx = new PingPongTransaction(delegateTx); - - if (!LOCKED_UPDATER.compareAndSet(this, null, newTx)) { - delegateTx.cancel(); - throw new IllegalStateException( - String.format("New transaction %s raced with transaction %s", newTx, lockedTx)); - } - - return newTx; - } - - private PingPongTransaction allocateTransaction() { - // Step 1: acquire current state - final PingPongTransaction oldTx = READY_UPDATER.getAndSet(this, null); - - // Slow path: allocate a delegate transaction - if (oldTx == null) { - return slowAllocateTransaction(); - } - - // Fast path: reuse current transaction. We will check failures and similar on commit(). - if (!LOCKED_UPDATER.compareAndSet(this, null, oldTx)) { - // Ouch. Delegate chain has not detected a duplicate transaction allocation. This is the best we can do. - oldTx.getTransaction().cancel(); - throw new IllegalStateException( - String.format("Reusable transaction %s raced with transaction %s", oldTx, lockedTx)); - } - - return oldTx; - } - - /* - * This forces allocateTransaction() on a slow path, which has to happen after - * this method has completed executing. Also inflightTx may be updated outside - * the lock, hence we need to re-check. - */ - @Holding("this") - private void processIfReady() { - if (inflightTx == null) { - final PingPongTransaction tx = READY_UPDATER.getAndSet(this, null); - if (tx != null) { - processTransaction(tx); - } - } - } - - /** - * Process a ready transaction. The caller needs to ensure that - * each transaction is seen only once by this method. - * - * @param tx Transaction which needs processing. - */ - @Holding("this") - private void processTransaction(final @NonNull PingPongTransaction tx) { - if (failed) { - LOG.debug("Cancelling transaction {}", tx); - tx.getTransaction().cancel(); - return; - } - - LOG.debug("Submitting transaction {}", tx); - if (!INFLIGHT_UPDATER.compareAndSet(this, null, tx)) { - LOG.warn("Submitting transaction {} while {} is still running", tx, inflightTx); - } - - tx.getTransaction().commit().addCallback(new FutureCallback() { - @Override - public void onSuccess(final CommitInfo result) { - transactionSuccessful(tx, result); - } - - @Override - public void onFailure(final Throwable throwable) { - transactionFailed(tx, throwable); - } - }, MoreExecutors.directExecutor()); - } - - /* - * We got invoked from the data store thread. We need to do two things: - * 1) release the in-flight transaction - * 2) process the potential next transaction - * - * We have to perform 2) under lock. We could perform 1) without locking, but that means the CAS result may - * not be accurate, as a user thread may submit the ready transaction before we acquire the lock -- and checking - * for next transaction is not enough, as that may have also be allocated (as a result of a quick - * submit/allocate/submit between 1) and 2)). Hence we'd end up doing the following: - * 1) CAS of inflightTx - * 2) take lock - * 3) volatile read of inflightTx - * - * Rather than doing that, we keep this method synchronized, hence performing only: - * 1) take lock - * 2) CAS of inflightTx - * - * Since the user thread is barred from submitting the transaction (in processIfReady), we can then proceed with - * the knowledge that inflightTx is null -- processTransaction() will still do a CAS, but that is only for - * correctness. - */ - private synchronized void processNextTransaction(final PingPongTransaction tx) { - final boolean success = INFLIGHT_UPDATER.compareAndSet(this, tx, null); - checkState(success, "Completed transaction %s while %s was submitted", tx, inflightTx); - - final PingPongTransaction nextTx = READY_UPDATER.getAndSet(this, null); - if (nextTx != null) { - processTransaction(nextTx); - } else if (shutdownTx != null) { - processTransaction(shutdownTx); - delegate.close(); - shutdownTx = null; - } - } - - void transactionSuccessful(final PingPongTransaction tx, final CommitInfo result) { - LOG.debug("Transaction {} completed successfully", tx); - - tx.onSuccess(result); - processNextTransaction(tx); - } - - void transactionFailed(final PingPongTransaction tx, final Throwable throwable) { - LOG.debug("Transaction {} failed", tx, throwable); - - tx.onFailure(throwable); - processNextTransaction(tx); - } - - void readyTransaction(final @NonNull PingPongTransaction tx) { - // First mark the transaction as not locked. - final boolean lockedMatch = LOCKED_UPDATER.compareAndSet(this, tx, null); - checkState(lockedMatch, "Attempted to submit transaction %s while we have %s", tx, lockedTx); - LOG.debug("Transaction {} unlocked", tx); - - /* - * The transaction is ready. It will then be picked up by either next allocation, - * or a background transaction completion callback. - */ - final boolean success = READY_UPDATER.compareAndSet(this, null, tx); - checkState(success, "Transaction %s collided on ready state", tx, readyTx); - LOG.debug("Transaction {} readied", tx); - - /* - * We do not see a transaction being in-flight, so we need to take care of dispatching - * the transaction to the backend. We are in the ready case, we cannot short-cut - * the checking of readyTx, as an in-flight transaction may have completed between us - * setting the field above and us checking. - */ - if (inflightTx == null) { - synchronized (this) { - processIfReady(); - } - } - } - - /** - * Transaction cancellation is a heavyweight operation. We only support cancelation of a locked transaction - * and return false for everything else. Cancelling such a transaction will result in all transactions in the - * batch to be cancelled. - * - * @param tx Backend shared transaction - * @param frontendTx transaction - * @param isOpen indicator whether the transaction was already closed - */ - synchronized void cancelTransaction(final PingPongTransaction tx, final DOMDataReadWriteTransaction frontendTx) { - // Attempt to unlock the operation. - final boolean lockedMatch = LOCKED_UPDATER.compareAndSet(this, tx, null); - verify(lockedMatch, "Cancelling transaction %s collided with locked transaction %s", tx, lockedTx); - - // Cancel the backend transaction, so we do not end up leaking it. - final boolean backendCancelled = tx.getTransaction().cancel(); - - if (failed) { - // The transaction has failed, this is probably the user just clearing up the transaction they had. We have - // already cancelled the transaction anyway, - return; - } else if (!backendCancelled) { - LOG.warn("Backend transaction cannot be cancelled during cancellation of {}, attempting to continue", tx); - } - - // We have dealt with canceling the backend transaction and have unlocked the transaction. Since we are still - // inside the synchronized block, any allocations are blocking on the slow path. Now we have to decide the fate - // of this transaction chain. - // - // If there are no other frontend transactions in this batch we are aligned with backend state and we can - // continue processing. - if (frontendTx.equals(tx.getFrontendTransaction())) { - LOG.debug("Cancelled transaction {} was head of the batch, resuming processing", tx); - return; - } - - // There are multiple frontend transactions in this batch. We have to report them as failed, which dooms this - // transaction chain, too. Since we just came off of a locked transaction, we do not have a ready transaction - // at the moment, but there may be some transaction in-flight. So we proceed to shutdown the backend chain - // and mark the fact that we should be turning its completion into a failure. - deadTx = new SimpleImmutableEntry<>(tx, new CancellationException("Transaction " + frontendTx + " canceled") - .fillInStackTrace()); - delegate.close(); - } - - @Override - public synchronized void close() { - final PingPongTransaction notLocked = lockedTx; - checkState(notLocked == null, "Attempted to close chain with outstanding transaction %s", notLocked); - - // This is not reliable, but if we observe it to be null and the process has already completed, - // the backend transaction chain will throw the appropriate error. - checkState(shutdownTx == null, "Attempted to close an already-closed chain"); - - // This may be a reaction to our failure callback, in that case the backend is already shutdown - if (deadTx != null) { - LOG.debug("Delegate {} is already closed due to failure {}", delegate, deadTx); - return; - } - - // Force allocations on slow path, picking up a potentially-outstanding transaction - final PingPongTransaction tx = READY_UPDATER.getAndSet(this, null); - - if (tx != null) { - // We have one more transaction, which needs to be processed somewhere. If we do not - // a transaction in-flight, we need to push it down ourselves. - // If there is an in-flight transaction we will schedule this last one into a dedicated - // slot. Allocation slow path will check its presence and fail, the in-flight path will - // pick it up, submit and immediately close the chain. - if (inflightTx == null) { - processTransaction(tx); - delegate.close(); - } else { - shutdownTx = tx; - } - } else { - // Nothing outstanding, we can safely shutdown - delegate.close(); - } - } - - @Override - public DOMDataReadOnlyTransaction newReadOnlyTransaction() { - final PingPongTransaction tx = allocateTransaction(); - - return new DOMDataReadOnlyTransaction() { - @Override - public CheckedFuture>, ReadFailedException> read( - final LogicalDatastoreType store, final YangInstanceIdentifier path) { - return tx.getTransaction().read(store, path); - } - - @Override - public CheckedFuture exists(final LogicalDatastoreType store, - final YangInstanceIdentifier path) { - return tx.getTransaction().exists(store, path); - } - - @Override - public Object getIdentifier() { - return tx.getTransaction().getIdentifier(); - } - - @Override - public void close() { - readyTransaction(tx); - } - }; - } - - @Override - public DOMDataReadWriteTransaction newReadWriteTransaction() { - final PingPongTransaction tx = allocateTransaction(); - final DOMDataReadWriteTransaction ret = new ForwardingDOMDataReadWriteTransaction() { - private boolean isOpen = true; - - @Override - protected DOMDataReadWriteTransaction delegate() { - return tx.getTransaction(); - } - - @Override - public FluentFuture commit() { - readyTransaction(tx); - isOpen = false; - return FluentFuture.from(tx.getCommitFuture()).transformAsync( - ignored -> CommitInfo.emptyFluentFuture(), MoreExecutors.directExecutor()); - } - - @Override - public boolean cancel() { - if (isOpen) { - cancelTransaction(tx, this); - isOpen = false; - return true; - } else { - return false; - } - } - }; - - tx.recordFrontendTransaction(ret); - return ret; - } - - @Override - public DOMDataWriteTransaction newWriteOnlyTransaction() { - return newReadWriteTransaction(); - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/RoutedDOMRpcRoutingTableEntry.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/RoutedDOMRpcRoutingTableEntry.java deleted file mode 100644 index 14fccc05bc..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/RoutedDOMRpcRoutingTableEntry.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.broker.impl; - -import static java.util.Objects.requireNonNull; - -import com.google.common.util.concurrent.CheckedFuture; -import com.google.common.util.concurrent.Futures; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcException; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementation; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementationNotAvailableException; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodes; -import org.opendaylight.yangtools.yang.model.api.RpcDefinition; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@Deprecated(forRemoval = true) -final class RoutedDOMRpcRoutingTableEntry extends AbstractDOMRpcRoutingTableEntry { - private static final Logger LOG = LoggerFactory.getLogger(RoutedDOMRpcRoutingTableEntry.class); - private final DOMRpcIdentifier globalRpcId; - private final YangInstanceIdentifier keyId; - - private RoutedDOMRpcRoutingTableEntry(final DOMRpcIdentifier globalRpcId, final YangInstanceIdentifier keyId, - final Map> impls) { - super(globalRpcId.getType(), impls); - this.keyId = requireNonNull(keyId); - this.globalRpcId = requireNonNull(globalRpcId); - } - - RoutedDOMRpcRoutingTableEntry(final RpcDefinition def, final YangInstanceIdentifier keyId, - final Map> impls) { - super(def.getPath(), impls); - this.keyId = requireNonNull(keyId); - this.globalRpcId = DOMRpcIdentifier.create(def.getPath()); - } - - @Override - protected CheckedFuture invokeRpc(final NormalizedNode input) { - final Optional> maybeKey = NormalizedNodes.findNode(input, keyId); - - // Routing key is present, attempt to deliver as a routed RPC - if (maybeKey.isPresent()) { - final NormalizedNode key = maybeKey.get(); - final Object value = key.getValue(); - if (value instanceof YangInstanceIdentifier) { - final YangInstanceIdentifier iid = (YangInstanceIdentifier) value; - - // Find a DOMRpcImplementation for a specific iid - final List specificImpls = getImplementations(iid); - if (specificImpls != null) { - return specificImpls.get(0).invokeRpc(DOMRpcIdentifier.create(getSchemaPath(), iid), input); - } - - LOG.debug("No implementation for context {} found will now look for wildcard id", iid); - - // Find a DOMRpcImplementation for a wild card. Usually remote-rpc-connector would register an - // implementation this way - final List mayBeRemoteImpls = getImplementations(YangInstanceIdentifier.empty()); - - if (mayBeRemoteImpls != null) { - return mayBeRemoteImpls.get(0).invokeRpc(DOMRpcIdentifier.create(getSchemaPath(), iid), input); - } - - } else { - LOG.warn("Ignoring wrong context value {}", value); - } - } - - final List impls = getImplementations(null); - if (impls != null) { - return impls.get(0).invokeRpc(globalRpcId, input); - } else { - return Futures.immediateFailedCheckedFuture( - new DOMRpcImplementationNotAvailableException("No implementation of RPC %s available", - getSchemaPath())); - } - } - - @Override - protected RoutedDOMRpcRoutingTableEntry newInstance( - final Map> impls) { - return new RoutedDOMRpcRoutingTableEntry(globalRpcId, keyId, impls); - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/SerializedDOMDataBroker.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/SerializedDOMDataBroker.java deleted file mode 100644 index 887d11260b..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/SerializedDOMDataBroker.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.broker.impl; - -import static com.google.common.base.Preconditions.checkArgument; -import static java.util.Objects.requireNonNull; - -import com.google.common.base.Supplier; -import com.google.common.util.concurrent.Futures; -import com.google.common.util.concurrent.ListenableFuture; -import com.google.common.util.concurrent.ListeningExecutorService; -import java.util.Collection; -import java.util.Map; -import java.util.concurrent.RejectedExecutionException; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; -import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction; -import org.opendaylight.controller.sal.core.spi.data.DOMStore; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort; -import org.opendaylight.yangtools.util.DurationStatisticsTracker; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Implementation of blocking three phase commit coordinator, which which - * supports coordination on multiple {@link DOMStoreThreePhaseCommitCohort}. - * - *

- * This implementation does not support cancellation of commit, - * - *

- * In order to advance to next phase of three phase commit all subtasks of - * previous step must be finish. - * - *

- * This executor does not have an upper bound on subtask timeout. - */ -@Deprecated(forRemoval = true) -public class SerializedDOMDataBroker extends AbstractDOMDataBroker { - private static final Logger LOG = LoggerFactory.getLogger(SerializedDOMDataBroker.class); - private final DurationStatisticsTracker commitStatsTracker = DurationStatisticsTracker.createConcurrent(); - private final ListeningExecutorService executor; - - /** - * Construct DOMDataCommitCoordinator which uses supplied executor to - * process commit coordinations. - * - * @param datastores data stores - * @param executor executor service - */ - public SerializedDOMDataBroker(final Map datastores, - final ListeningExecutorService executor) { - super(datastores); - this.executor = requireNonNull(executor, "executor must not be null."); - } - - public DurationStatisticsTracker getCommitStatsTracker() { - return commitStatsTracker; - } - - @Override - protected ListenableFuture commit(final DOMDataWriteTransaction transaction, - final Collection cohorts, final Supplier futureValueSupplier) { - checkArgument(transaction != null, "Transaction must not be null."); - checkArgument(cohorts != null, "Cohorts must not be null."); - LOG.debug("Tx: {} is submitted for execution.", transaction.getIdentifier()); - - ListenableFuture commitFuture; - try { - commitFuture = executor.submit(new CommitCoordinationTask<>(transaction, cohorts, commitStatsTracker, - futureValueSupplier)); - } catch (RejectedExecutionException e) { - LOG.error("The commit executor {} queue is full - submit task was rejected. \n", executor, e); - commitFuture = Futures.immediateFailedFuture(new TransactionCommitFailedException( - "Could not submit the commit task - the commit queue capacity has been exceeded.", e)); - } - - return commitFuture; - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/TransactionCommitFailedExceptionMapper.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/TransactionCommitFailedExceptionMapper.java deleted file mode 100644 index 1b3c5a680d..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/TransactionCommitFailedExceptionMapper.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.broker.impl; - -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; -import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; -import org.opendaylight.yangtools.util.concurrent.ExceptionMapper; - -/** - * Utility exception mapper which translates Exception to {@link TransactionCommitFailedException}. - * - * @see ExceptionMapper - */ -@Deprecated(forRemoval = true) -public final class TransactionCommitFailedExceptionMapper extends ExceptionMapper { - - public static final TransactionCommitFailedExceptionMapper PRE_COMMIT_MAPPER = create("preCommit"); - - public static final TransactionCommitFailedExceptionMapper CAN_COMMIT_ERROR_MAPPER = create("canCommit"); - - public static final TransactionCommitFailedExceptionMapper COMMIT_ERROR_MAPPER = create("commit"); - - private TransactionCommitFailedExceptionMapper(final String opName) { - super(opName, TransactionCommitFailedException.class); - } - - public static TransactionCommitFailedExceptionMapper create(final String opName) { - return new TransactionCommitFailedExceptionMapper(opName); - } - - @Override - protected TransactionCommitFailedException newWithCause(final String message, final Throwable cause) { - return new TransactionCommitFailedException(message, cause); - } - - @Override - @SuppressFBWarnings("BC_UNCONFIRMED_CAST_OF_RETURN_VALUE") - public TransactionCommitFailedException apply(Exception input) { - return super.apply(input); - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/UnknownDOMRpcRoutingTableEntry.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/UnknownDOMRpcRoutingTableEntry.java deleted file mode 100644 index fa1f2be49c..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/UnknownDOMRpcRoutingTableEntry.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.broker.impl; - -import com.google.common.util.concurrent.CheckedFuture; -import com.google.common.util.concurrent.Futures; -import java.util.List; -import java.util.Map; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcException; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementation; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementationNotAvailableException; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; - -@Deprecated(forRemoval = true) -final class UnknownDOMRpcRoutingTableEntry extends AbstractDOMRpcRoutingTableEntry { - private final CheckedFuture unknownRpc; - - UnknownDOMRpcRoutingTableEntry(final SchemaPath schemaPath, - final Map> impls) { - super(schemaPath, impls); - unknownRpc = Futures.immediateFailedCheckedFuture( - new DOMRpcImplementationNotAvailableException("SchemaPath %s is not resolved to an RPC", schemaPath)); - } - - @Override - protected CheckedFuture invokeRpc(final NormalizedNode input) { - return unknownRpc; - } - - @Override - protected UnknownDOMRpcRoutingTableEntry newInstance( - final Map> impls) { - return new UnknownDOMRpcRoutingTableEntry(getSchemaPath(), impls); - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/legacy/sharded/adapter/LegacyShardedDOMDataBrokerAdapter.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/legacy/sharded/adapter/LegacyShardedDOMDataBrokerAdapter.java deleted file mode 100644 index f3d60fd4f6..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/legacy/sharded/adapter/LegacyShardedDOMDataBrokerAdapter.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.broker.impl.legacy.sharded.adapter; - -import static java.util.Objects.requireNonNull; - -import java.util.Collections; -import java.util.Map; -import java.util.concurrent.atomic.AtomicLong; -import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener; -import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; -import org.opendaylight.controller.md.sal.dom.api.DOMDataBrokerExtension; -import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction; -import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction; -import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction; -import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain; -import org.opendaylight.mdsal.dom.api.DOMSchemaService; -import org.opendaylight.mdsal.dom.broker.ShardedDOMDataBrokerAdapter; - -/** - * DOMDataBroker implementation that forwards calls to - * {@link org.opendaylight.mdsal.dom.broker.ShardedDOMDataBrokerAdapter}, - * which in turn translates calls to shard aware implementation of - * {@link org.opendaylight.mdsal.dom.api.DOMDataTreeService} - * - *

- * The incompatibility between first and latter APIs, puts restriction on {@link DOMDataReadWriteTransaction} - * and {@link DOMDataReadOnlyTransaction} provided by this data broker. See - * {@link ShardedDOMDataBrokerDelegatingReadWriteTransaction} - * and {@link ShardedDOMDataBrokerDelegatingReadTransaction} respectively. - */ -// FIXME try to refactor some of the implementation to abstract class for better reusability -@Deprecated(forRemoval = true) -public class LegacyShardedDOMDataBrokerAdapter implements DOMDataBroker { - - private final org.opendaylight.mdsal.dom.api.DOMDataBroker delegateDataBroker; - private final DOMSchemaService schemaService; - private final AtomicLong txNum = new AtomicLong(); - private final AtomicLong chainNum = new AtomicLong(); - - public LegacyShardedDOMDataBrokerAdapter(final ShardedDOMDataBrokerAdapter delegateDataBroker, - final DOMSchemaService schemaService) { - this.delegateDataBroker = requireNonNull(delegateDataBroker); - this.schemaService = requireNonNull(schemaService); - } - - @Override - public DOMDataReadOnlyTransaction newReadOnlyTransaction() { - return new ShardedDOMDataBrokerDelegatingReadTransaction(newTransactionIdentifier(), - delegateDataBroker.newReadOnlyTransaction()); - } - - @Override - public DOMDataReadWriteTransaction newReadWriteTransaction() { - return new ShardedDOMDataBrokerDelegatingReadWriteTransaction(newTransactionIdentifier(), - schemaService.getGlobalContext(), - newReadOnlyTransaction(), - newWriteOnlyTransaction()); - } - - @Override - public DOMDataWriteTransaction newWriteOnlyTransaction() { - return new ShardedDOMDataBrokerDelegatingWriteTransaction(newTransactionIdentifier(), - delegateDataBroker.newWriteOnlyTransaction()); - } - - @Override - public DOMTransactionChain createTransactionChain(final TransactionChainListener listener) { - return new ShardedDOMDataBrokerDelegatingTransactionChain(chainNum.getAndIncrement(), - schemaService.getGlobalContext(), delegateDataBroker, - listener); - } - - @Override - public Map, DOMDataBrokerExtension> getSupportedExtensions() { - return Collections.emptyMap(); - } - - private Object newTransactionIdentifier() { - return "DOM-" + txNum.getAndIncrement(); - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/legacy/sharded/adapter/ShardedDOMDataBrokerDelegatingReadTransaction.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/legacy/sharded/adapter/ShardedDOMDataBrokerDelegatingReadTransaction.java deleted file mode 100644 index dcc2176aad..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/legacy/sharded/adapter/ShardedDOMDataBrokerDelegatingReadTransaction.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.broker.impl.legacy.sharded.adapter; - -import static java.util.Objects.requireNonNull; - -import com.google.common.base.Optional; -import com.google.common.util.concurrent.CheckedFuture; -import com.google.common.util.concurrent.Futures; -import com.google.common.util.concurrent.MoreExecutors; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; -import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction; -import org.opendaylight.mdsal.dom.api.DOMDataTreeReadTransaction; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; - -/** - * Read transaction that delegates calls to {@link org.opendaylight.mdsal.dom.broker.ShardedDOMReadTransactionAdapter}, - * which in turn translates calls to shard aware implementation of - * {@link org.opendaylight.mdsal.dom.api.DOMDataTreeService}. - * - *

- * Since reading data distributed on different subshards is not guaranteed to - * return all relevant data, we cannot guarantee it neither. Best effort is to - * return all data we get from first initial data change event received. - */ -@Deprecated(forRemoval = true) -class ShardedDOMDataBrokerDelegatingReadTransaction implements DOMDataReadOnlyTransaction { - private final DOMDataTreeReadTransaction delegateTx; - private final Object txIdentifier; - - ShardedDOMDataBrokerDelegatingReadTransaction(final Object txIdentifier, - final DOMDataTreeReadTransaction delegateTx) { - this.delegateTx = requireNonNull(delegateTx); - this.txIdentifier = requireNonNull(txIdentifier); - } - - @Override - public CheckedFuture>, ReadFailedException> read(final LogicalDatastoreType store, - final YangInstanceIdentifier path) { - return Futures.makeChecked(delegateTx.read(store.toMdsal(), path).transform( - Optional::fromJavaUtil, MoreExecutors.directExecutor()), ReadFailedException.MAPPER); - } - - @Override - public CheckedFuture exists(final LogicalDatastoreType store, - final YangInstanceIdentifier path) { - return Futures.makeChecked(delegateTx.exists(store.toMdsal(), path), ReadFailedException.MAPPER); - } - - @Override - public Object getIdentifier() { - return txIdentifier; - } - - @Override - public void close() { - delegateTx.close(); - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/legacy/sharded/adapter/ShardedDOMDataBrokerDelegatingReadWriteTransaction.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/legacy/sharded/adapter/ShardedDOMDataBrokerDelegatingReadWriteTransaction.java deleted file mode 100644 index f9baaab478..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/legacy/sharded/adapter/ShardedDOMDataBrokerDelegatingReadWriteTransaction.java +++ /dev/null @@ -1,240 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.broker.impl.legacy.sharded.adapter; - -import static com.google.common.base.Preconditions.checkState; -import static java.util.Objects.requireNonNull; - -import com.google.common.base.Optional; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Lists; -import com.google.common.util.concurrent.CheckedFuture; -import com.google.common.util.concurrent.FluentFuture; -import com.google.common.util.concurrent.FutureCallback; -import com.google.common.util.concurrent.Futures; -import com.google.common.util.concurrent.ListenableFuture; -import com.google.common.util.concurrent.MoreExecutors; -import com.google.common.util.concurrent.SettableFuture; -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; -import java.util.EnumMap; -import java.util.LinkedList; -import java.util.Map; -import java.util.Queue; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; -import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction; -import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction; -import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction; -import org.opendaylight.mdsal.common.api.CommitInfo; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree; -import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeConfiguration; -import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification; -import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot; -import org.opendaylight.yangtools.yang.data.impl.schema.tree.InMemoryDataTreeFactory; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -/** - * Read/write transaction that delegates write and initial read to - * {@link org.opendaylight.mdsal.dom.broker.ShardedDOMWriteTransactionAdapter} - * and {@link org.opendaylight.mdsal.dom.broker.ShardedDOMReadTransactionAdapter} - * respectively. These two in turn rely on shard aware implementation of - * {@link org.opendaylight.mdsal.dom.api.DOMDataTreeService}. - * - *

- * Since reading data distributed on different subshards is not guaranteed to - * return all relevant data, best effort is to try to operate only on single - * subtree in conceptual data tree. We define this subtree by first write - * operation performed on transaction. All next read and write operations - * should be performed just in this initial subtree. - * - */ -// FIXME explicitly enforce just one subtree requirement -@Deprecated(forRemoval = true) -class ShardedDOMDataBrokerDelegatingReadWriteTransaction implements DOMDataReadWriteTransaction { - private final DOMDataReadOnlyTransaction readTxDelegate; - private final DOMDataWriteTransaction writeTxDelegate; - private final Object txIdentifier; - private final ImmutableMap> modificationHistoryMap; - private final ImmutableMap snapshotMap; - private final Map>>> initialReadMap; - private YangInstanceIdentifier root = null; - - ShardedDOMDataBrokerDelegatingReadWriteTransaction(final Object readWriteTxId, final SchemaContext ctx, - final DOMDataReadOnlyTransaction readTxDelegate, - final DOMDataWriteTransaction writeTxDelegate) { - this.readTxDelegate = requireNonNull(readTxDelegate); - this.writeTxDelegate = requireNonNull(writeTxDelegate); - this.txIdentifier = requireNonNull(readWriteTxId); - this.initialReadMap = new EnumMap<>(LogicalDatastoreType.class); - - final InMemoryDataTreeFactory treeFactory = new InMemoryDataTreeFactory(); - final ImmutableMap.Builder snapshotMapBuilder = ImmutableMap.builder(); - final ImmutableMap.Builder> modificationHistoryMapBuilder - = ImmutableMap.builder(); - for (final LogicalDatastoreType store : LogicalDatastoreType.values()) { - final DataTree tree = treeFactory.create(treeConfigForStore(store)); - tree.setSchemaContext(ctx); - snapshotMapBuilder.put(store, tree.takeSnapshot()); - - modificationHistoryMapBuilder.put(store, new LinkedList<>()); - } - - modificationHistoryMap = modificationHistoryMapBuilder.build(); - snapshotMap = snapshotMapBuilder.build(); - } - - @Override - public boolean cancel() { - readTxDelegate.close(); - return writeTxDelegate.cancel(); - } - - @Override - public void delete(final LogicalDatastoreType store, final YangInstanceIdentifier path) { - if (root == null) { - initialRead(path); - } - - modificationHistoryMap.get(store).add(new Modification(Modification.Operation.DELETE, path, null)); - writeTxDelegate.delete(store, path); - } - - @Override - public FluentFuture commit() { - return writeTxDelegate.commit(); - } - - @Override - public CheckedFuture>, ReadFailedException> read(final LogicalDatastoreType store, - final YangInstanceIdentifier path) { - checkState(root != null, - "A modify operation (put, merge or delete) must be performed prior to a read operation"); - final SettableFuture>> readResult = SettableFuture.create(); - final Queue currentHistory = Lists.newLinkedList(modificationHistoryMap.get(store)); - Futures.addCallback(initialReadMap.get(store), new FutureCallback>>() { - @Override - public void onSuccess(final Optional> result) { - final DataTreeModification mod = snapshotMap.get(store).newModification(); - if (result.isPresent()) { - mod.write(path, result.get()); - } - applyModificationHistoryToSnapshot(mod, currentHistory); - readResult.set(Optional.fromJavaUtil(mod.readNode(path))); - } - - @Override - public void onFailure(final Throwable throwable) { - readResult.setException(throwable); - } - }, MoreExecutors.directExecutor()); - - return Futures.makeChecked(readResult, ReadFailedException.MAPPER); - } - - @Override - public CheckedFuture exists(final LogicalDatastoreType store, - final YangInstanceIdentifier path) { - checkState(root != null, - "A modify operation (put, merge or delete) must be performed prior to an exists operation"); - return Futures.makeChecked(Futures.transform(read(store, path), Optional::isPresent, - MoreExecutors.directExecutor()), ReadFailedException.MAPPER); - } - - @Override - public void put(final LogicalDatastoreType store, final YangInstanceIdentifier path, - final NormalizedNode data) { - if (root == null) { - initialRead(path); - } - - modificationHistoryMap.get(store).add(new Modification(Modification.Operation.WRITE, path, data)); - writeTxDelegate.put(store, path, data); - } - - @Override - public void merge(final LogicalDatastoreType store, final YangInstanceIdentifier path, - final NormalizedNode data) { - if (root == null) { - initialRead(path); - } - - modificationHistoryMap.get(store).add(new Modification(Modification.Operation.MERGE, path, data)); - writeTxDelegate.merge(store, path, data); - } - - @Override - public Object getIdentifier() { - return txIdentifier; - } - - private void initialRead(final YangInstanceIdentifier path) { - root = path; - - for (final LogicalDatastoreType store : LogicalDatastoreType.values()) { - initialReadMap.put(store, readTxDelegate.read(store, path)); - } - } - - private static DataTreeConfiguration treeConfigForStore(final LogicalDatastoreType store) { - return store == LogicalDatastoreType.CONFIGURATION ? DataTreeConfiguration.DEFAULT_CONFIGURATION - : DataTreeConfiguration.DEFAULT_OPERATIONAL; - } - - @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", - justification = "https://github.com/spotbugs/spotbugs/issues/811") - private static void applyModificationHistoryToSnapshot(final DataTreeModification dataTreeModification, - final Queue modificationHistory) { - while (!modificationHistory.isEmpty()) { - final Modification modification = modificationHistory.poll(); - switch (modification.getOperation()) { - case WRITE: - dataTreeModification.write(modification.getPath(), modification.getData()); - break; - case MERGE: - dataTreeModification.merge(modification.getPath(), modification.getData()); - break; - case DELETE: - dataTreeModification.delete(modification.getPath()); - break; - default: - // NOOP - } - } - } - - static class Modification { - - enum Operation { - WRITE, MERGE, DELETE - } - - private final NormalizedNode data; - private final YangInstanceIdentifier path; - private final Operation operation; - - Modification(final Operation operation, final YangInstanceIdentifier path, final NormalizedNode data) { - this.data = data; - this.path = requireNonNull(path); - this.operation = requireNonNull(operation); - } - - Operation getOperation() { - return operation; - } - - YangInstanceIdentifier getPath() { - return path; - } - - NormalizedNode getData() { - return data; - } - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/legacy/sharded/adapter/ShardedDOMDataBrokerDelegatingTransactionChain.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/legacy/sharded/adapter/ShardedDOMDataBrokerDelegatingTransactionChain.java deleted file mode 100644 index d4ff17d23e..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/legacy/sharded/adapter/ShardedDOMDataBrokerDelegatingTransactionChain.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.broker.impl.legacy.sharded.adapter; - -import static java.util.Objects.requireNonNull; - -import com.google.common.base.Preconditions; -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.atomic.AtomicLong; -import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction; -import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener; -import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction; -import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction; -import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction; -import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain; -import org.opendaylight.mdsal.dom.api.DOMDataTreeReadTransaction; -import org.opendaylight.mdsal.dom.api.DOMDataTreeTransaction; -import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction; -import org.opendaylight.mdsal.dom.api.DOMTransactionChainListener; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -@Deprecated(forRemoval = true) -class ShardedDOMDataBrokerDelegatingTransactionChain implements DOMTransactionChain, DOMTransactionChainListener { - private final Map> transactionMap = new HashMap<>(); - private final org.opendaylight.mdsal.dom.api.DOMTransactionChain txChainDelegate; - private final SchemaContext schemaContext; - private final TransactionChainListener txChainListener; - private final Object txChainIdentifier; - private final AtomicLong txNum = new AtomicLong(); - - ShardedDOMDataBrokerDelegatingTransactionChain(final Object txChainIdentifier, - final SchemaContext schemaContext, - final org.opendaylight.mdsal.dom.api.DOMDataBroker - brokerDelegate, - final TransactionChainListener txChainListener) { - requireNonNull(brokerDelegate); - this.schemaContext = requireNonNull(schemaContext); - this.txChainIdentifier = requireNonNull(txChainIdentifier); - this.txChainListener = requireNonNull(txChainListener); - this.txChainDelegate = brokerDelegate.createTransactionChain(this); - } - - @Override - public DOMDataReadOnlyTransaction newReadOnlyTransaction() { - final DOMDataTreeReadTransaction readTxDelegate = txChainDelegate.newReadOnlyTransaction(); - final DOMDataReadOnlyTransaction readTx = new ShardedDOMDataBrokerDelegatingReadTransaction( - newTransactionIdentifier(), readTxDelegate); - transactionMap.put(readTxDelegate.getIdentifier(), readTx); - - return readTx; - } - - @Override - public DOMDataReadWriteTransaction newReadWriteTransaction() { - final Object readWriteTxId = newTransactionIdentifier(); - final DOMDataTreeReadTransaction readTxDelegate = txChainDelegate.newReadOnlyTransaction(); - final DOMDataReadOnlyTransaction readTx = new ShardedDOMDataBrokerDelegatingReadTransaction(readWriteTxId, - readTxDelegate); - - final DOMDataTreeWriteTransaction writeTxDelegate = txChainDelegate.newWriteOnlyTransaction(); - final DOMDataWriteTransaction writeTx = new ShardedDOMDataBrokerDelegatingWriteTransaction(readWriteTxId, - writeTxDelegate); - - final DOMDataReadWriteTransaction readWriteTx = new ShardedDOMDataBrokerDelegatingReadWriteTransaction( - readWriteTxId, schemaContext, readTx, writeTx); - transactionMap.put(readTxDelegate.getIdentifier(), readWriteTx); - transactionMap.put(writeTxDelegate.getIdentifier(), readWriteTx); - - return readWriteTx; - } - - @Override - public DOMDataWriteTransaction newWriteOnlyTransaction() { - final DOMDataTreeWriteTransaction writeTxDelegate = txChainDelegate.newWriteOnlyTransaction(); - final DOMDataWriteTransaction writeTx = new ShardedDOMDataBrokerDelegatingWriteTransaction( - newTransactionIdentifier(), writeTxDelegate); - transactionMap.put(writeTxDelegate.getIdentifier(), writeTx); - - return writeTx; - } - - @Override - public void close() { - txChainDelegate.close(); - } - - @Override - public void onTransactionChainFailed(final org.opendaylight.mdsal.dom.api.DOMTransactionChain chain, - final DOMDataTreeTransaction transaction, final Throwable cause) { - txChainListener.onTransactionChainFailed(this, transactionFromDelegate(transaction.getIdentifier()), cause); - } - - @Override - public void onTransactionChainSuccessful(final org.opendaylight.mdsal.dom.api.DOMTransactionChain chain) { - txChainListener.onTransactionChainSuccessful(this); - } - - private AsyncTransaction transactionFromDelegate(final Object delegateId) { - Preconditions.checkState(transactionMap.containsKey(delegateId), - "Delegate transaction {} is not present in transaction chain history", delegateId); - return transactionMap.get(delegateId); - } - - private Object newTransactionIdentifier() { - return "DOM-CHAIN-" + txChainIdentifier + "-" + txNum.getAndIncrement(); - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/legacy/sharded/adapter/ShardedDOMDataBrokerDelegatingWriteTransaction.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/legacy/sharded/adapter/ShardedDOMDataBrokerDelegatingWriteTransaction.java deleted file mode 100644 index 692f296864..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/legacy/sharded/adapter/ShardedDOMDataBrokerDelegatingWriteTransaction.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.broker.impl.legacy.sharded.adapter; - -import static java.util.Objects.requireNonNull; - -import com.google.common.util.concurrent.FluentFuture; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction; -import org.opendaylight.mdsal.common.api.CommitInfo; -import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; - -@Deprecated(forRemoval = true) -class ShardedDOMDataBrokerDelegatingWriteTransaction implements DOMDataWriteTransaction { - private final DOMDataTreeWriteTransaction delegateTx; - private final Object txIdentifier; - - ShardedDOMDataBrokerDelegatingWriteTransaction(final Object txIdentifier, - final DOMDataTreeWriteTransaction delegateTx) { - this.delegateTx = requireNonNull(delegateTx); - this.txIdentifier = requireNonNull(txIdentifier); - } - - @Override - public void put(final LogicalDatastoreType store, final YangInstanceIdentifier path, - final NormalizedNode data) { - delegateTx.put(store.toMdsal(), path, data); - } - - @Override - public void merge(final LogicalDatastoreType store, final YangInstanceIdentifier path, - final NormalizedNode data) { - delegateTx.merge(store.toMdsal(), path, data); - } - - @Override - public boolean cancel() { - return delegateTx.cancel(); - } - - @Override - public void delete(final LogicalDatastoreType store, final YangInstanceIdentifier path) { - delegateTx.delete(store.toMdsal(), path); - } - - @Override - public FluentFuture commit() { - return delegateTx.commit(); - } - - @Override - public Object getIdentifier() { - return txIdentifier; - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/mount/DOMMountPointServiceImpl.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/mount/DOMMountPointServiceImpl.java deleted file mode 100644 index fdcb5d8753..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/mount/DOMMountPointServiceImpl.java +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.broker.impl.mount; - -import static java.util.Objects.requireNonNull; - -import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Optional; -import com.google.common.base.Preconditions; -import com.google.common.collect.ClassToInstanceMap; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.MutableClassToInstanceMap; -import java.util.Map; -import java.util.Map.Entry; -import org.opendaylight.controller.md.sal.dom.api.DOMActionService; -import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; -import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint; -import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService; -import org.opendaylight.controller.md.sal.dom.api.DOMNotificationService; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcService; -import org.opendaylight.controller.md.sal.dom.api.DOMService; -import org.opendaylight.controller.md.sal.dom.broker.spi.mount.SimpleDOMMountPoint; -import org.opendaylight.controller.sal.core.compat.DOMDataBrokerAdapter; -import org.opendaylight.controller.sal.core.compat.DOMMountPointAdapter; -import org.opendaylight.controller.sal.core.compat.DOMNotificationServiceAdapter; -import org.opendaylight.controller.sal.core.compat.DOMRpcServiceAdapter; -import org.opendaylight.mdsal.dom.api.DOMMountPointListener; -import org.opendaylight.yangtools.concepts.AbstractObjectRegistration; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.concepts.ObjectRegistration; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -@Deprecated(forRemoval = true) -public class DOMMountPointServiceImpl implements DOMMountPointService { - @Deprecated - private abstract static class CompatFactory { - private final Class controllerClass; - private final Class mdsalClass; - - CompatFactory(final Class controllerClass, final Class mdsalClass) { - this.controllerClass = requireNonNull(controllerClass); - this.mdsalClass = requireNonNull(mdsalClass); - } - - final void addService(final org.opendaylight.mdsal.dom.api.DOMMountPointService.DOMMountPointBuilder builder, - final ClassToInstanceMap services) { - if (!services.containsKey(mdsalClass)) { - final C controllerService = services.getInstance(controllerClass); - if (controllerService != null) { - final M mdsalService = createService(controllerService); - if (mdsalService != null) { - builder.addService(mdsalClass, mdsalService); - } - } - } - } - - abstract M createService(C delegate); - } - - private static final Map, CompatFactory> KNOWN_SERVICES = ImmutableMap.of( - DOMActionService.class, new CompatFactory( - DOMActionService.class, org.opendaylight.mdsal.dom.api.DOMActionService.class) { - @Override - org.opendaylight.mdsal.dom.api.DOMActionService createService(final DOMActionService delegate) { - return delegate; - } - }, - DOMDataBroker.class, new CompatFactory( - DOMDataBroker.class, org.opendaylight.mdsal.dom.api.DOMDataBroker.class) { - @Override - org.opendaylight.mdsal.dom.api.DOMDataBroker createService(final DOMDataBroker delegate) { - return new DOMDataBrokerAdapter(delegate); - } - }, - DOMNotificationService.class, new CompatFactory(DOMNotificationService.class, - org.opendaylight.mdsal.dom.api.DOMNotificationService.class) { - @Override - org.opendaylight.mdsal.dom.api.DOMNotificationService createService(final DOMNotificationService delegate) { - return new DOMNotificationServiceAdapter(delegate); - } - }, - DOMRpcService.class, new CompatFactory( - DOMRpcService.class, org.opendaylight.mdsal.dom.api.DOMRpcService.class) { - @Override - org.opendaylight.mdsal.dom.api.DOMRpcService createService(final DOMRpcService delegate) { - return new DOMRpcServiceAdapter(delegate); - } - }); - - private final org.opendaylight.mdsal.dom.api.DOMMountPointService delegate; - - @VisibleForTesting - public DOMMountPointServiceImpl() { - this(new org.opendaylight.mdsal.dom.broker.DOMMountPointServiceImpl()); - } - - public DOMMountPointServiceImpl(final org.opendaylight.mdsal.dom.api.DOMMountPointService delegate) { - this.delegate = delegate; - } - - @Override - public Optional getMountPoint(final YangInstanceIdentifier path) { - return Optional.fromJavaUtil(delegate.getMountPoint(path).map(DOMMountPointAdapter::new)); - } - - @Override - public DOMMountPointBuilder createMountPoint(final YangInstanceIdentifier path) { - return new DOMMountPointBuilderImpl(path); - } - - @Override - public ListenerRegistration registerProvisionListener(final DOMMountPointListener listener) { - return delegate.registerProvisionListener(listener); - } - - @SuppressWarnings("unchecked") - ObjectRegistration registerMountPoint(final SimpleDOMMountPoint mountPoint) { - final org.opendaylight.mdsal.dom.api.DOMMountPointService.DOMMountPointBuilder delegateBuilder = - delegate.createMountPoint(mountPoint.getIdentifier()); - - if (mountPoint.getSchemaContext() != null) { - delegateBuilder.addInitialSchemaContext(mountPoint.getSchemaContext()); - } - - final ClassToInstanceMap myServices = mountPoint.getServices(); - for (Entry, DOMService> entry : myServices.entrySet()) { - delegateBuilder.addService((Class)entry.getKey(), entry.getValue()); - - final CompatFactory compat = KNOWN_SERVICES.get(entry.getKey()); - if (compat != null) { - compat.addService(delegateBuilder, myServices); - } - } - - final ObjectRegistration delegateReg = delegateBuilder.register(); - return new AbstractObjectRegistration(mountPoint) { - @Override - protected void removeRegistration() { - delegateReg.close(); - } - }; - } - - public class DOMMountPointBuilderImpl implements DOMMountPointBuilder { - private final ClassToInstanceMap services = MutableClassToInstanceMap.create(); - private final YangInstanceIdentifier path; - private SimpleDOMMountPoint mountPoint; - private SchemaContext schemaContext; - - public DOMMountPointBuilderImpl(final YangInstanceIdentifier path) { - this.path = path; - } - - @Override - public DOMMountPointBuilder addService(final Class type, final T impl) { - services.putInstance(type, impl); - return this; - } - - @Override - public DOMMountPointBuilder addInitialSchemaContext(final SchemaContext ctx) { - schemaContext = ctx; - return this; - } - - @Override - public ObjectRegistration register() { - Preconditions.checkState(mountPoint == null, "Mount point is already built."); - mountPoint = SimpleDOMMountPoint.create(path, services, schemaContext); - return registerMountPoint(mountPoint); - } - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/SchemaContextProviders.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/SchemaContextProviders.java deleted file mode 100644 index e1c5a875ed..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/SchemaContextProviders.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.dom.broker.impl; - -import org.opendaylight.mdsal.dom.api.DOMSchemaService; -import org.opendaylight.yangtools.concepts.Delegator; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.opendaylight.yangtools.yang.model.api.SchemaContextProvider; - -@Deprecated(forRemoval = true) -public final class SchemaContextProviders { - - private SchemaContextProviders() { - throw new UnsupportedOperationException("Utility class."); - } - - public static SchemaContextProvider fromSchemaService(final DOMSchemaService schemaService) { - if (schemaService instanceof SchemaContextProvider) { - return (SchemaContextProvider) schemaService; - } - return new SchemaServiceAdapter(schemaService); - } - - private static final class SchemaServiceAdapter implements SchemaContextProvider, Delegator { - - private final DOMSchemaService service; - - SchemaServiceAdapter(final DOMSchemaService service) { - this.service = service; - } - - @Override - public SchemaContext getSchemaContext() { - return service.getGlobalContext(); - } - - @Override - public DOMSchemaService getDelegate() { - return service; - } - - @Override - public String toString() { - return "SchemaServiceAdapter [service=" + service + "]"; - } - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/util/ProxySchemaContext.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/util/ProxySchemaContext.java deleted file mode 100644 index b96977ed74..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/util/ProxySchemaContext.java +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.sal.dom.broker.util; - -import com.google.common.base.Preconditions; -import java.util.Collection; -import java.util.List; -import java.util.Optional; -import java.util.Set; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.common.QNameModule; -import org.opendaylight.yangtools.yang.common.Revision; -import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode; -import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; -import org.opendaylight.yangtools.yang.model.api.ExtensionDefinition; -import org.opendaylight.yangtools.yang.model.api.GroupingDefinition; -import org.opendaylight.yangtools.yang.model.api.Module; -import org.opendaylight.yangtools.yang.model.api.NotificationDefinition; -import org.opendaylight.yangtools.yang.model.api.RpcDefinition; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.opendaylight.yangtools.yang.model.api.SchemaContextProvider; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; -import org.opendaylight.yangtools.yang.model.api.Status; -import org.opendaylight.yangtools.yang.model.api.TypeDefinition; -import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode; -import org.opendaylight.yangtools.yang.model.api.UsesNode; - -/** - * ProxySchema Context for SchemaContextProviders. - */ -@Deprecated(forRemoval = true) -public class ProxySchemaContext implements SchemaContext { - - private final SchemaContextProvider schemaProvider; - - public ProxySchemaContext(final SchemaContextProvider schemaProvider) { - this.schemaProvider = schemaProvider; - } - - private SchemaContext getCurrentSchema() { - Preconditions.checkState(schemaProvider.getSchemaContext() != null, "Schema context unavailable from %s", - schemaProvider); - return schemaProvider.getSchemaContext(); - } - - @Override - public Set getDataDefinitions() { - return getCurrentSchema().getDataDefinitions(); - } - - @Override - public Set getModules() { - return getCurrentSchema().getModules(); - } - - @Override - public Set getNotifications() { - return getCurrentSchema().getNotifications(); - } - - @Override - public Set getOperations() { - return getCurrentSchema().getOperations(); - } - - @Override - public Set getExtensions() { - return getCurrentSchema().getExtensions(); - } - - @Override - public boolean isPresenceContainer() { - return getCurrentSchema().isPresenceContainer(); - } - - @Override - public Set> getTypeDefinitions() { - return getCurrentSchema().getTypeDefinitions(); - } - - @Override - public Collection getChildNodes() { - return getCurrentSchema().getChildNodes(); - } - - @Override - public Set getGroupings() { - return getCurrentSchema().getGroupings(); - } - - @Override - public Optional findDataChildByName(final QName name) { - return getCurrentSchema().findDataChildByName(name); - } - - @Override - public Set getUses() { - return getCurrentSchema().getUses(); - } - - @Override - public Set getAvailableAugmentations() { - return getCurrentSchema().getAvailableAugmentations(); - } - - @Override - public boolean isAugmenting() { - return getCurrentSchema().isAugmenting(); - } - - @Override - public boolean isAddedByUses() { - return getCurrentSchema().isAddedByUses(); - } - - @Override - public boolean isConfiguration() { - return getCurrentSchema().isConfiguration(); - } - - @Override - public QName getQName() { - return getCurrentSchema().getQName(); - } - - @Override - public SchemaPath getPath() { - return getCurrentSchema().getPath(); - } - - @Override - public List getUnknownSchemaNodes() { - return getCurrentSchema().getUnknownSchemaNodes(); - } - - @Override - public Optional getDescription() { - return getCurrentSchema().getDescription(); - } - - @Override - public Optional getReference() { - return getCurrentSchema().getReference(); - } - - @Override - public Status getStatus() { - return getCurrentSchema().getStatus(); - } - - @Override - public Optional findModule(final String name, final Optional revision) { - return getCurrentSchema().findModule(name, revision); - } - - @Override - public Optional findModule(final QNameModule qnameModule) { - return getCurrentSchema().findModule(qnameModule); - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/resources/OSGI-INF/blueprint/dom-broker.xml b/opendaylight/md-sal/sal-dom-broker/src/main/resources/OSGI-INF/blueprint/dom-broker.xml deleted file mode 100644 index 67ebcf5e42..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/resources/OSGI-INF/blueprint/dom-broker.xml +++ /dev/null @@ -1,86 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - org.opendaylight.controller.md.sal.dom.api.DOMNotificationService - org.opendaylight.controller.md.sal.dom.api.DOMNotificationPublishService - org.opendaylight.controller.md.sal.dom.spi.DOMNotificationSubscriptionListenerRegistry - - - - - - - - - - - - - - - - org.opendaylight.controller.md.sal.dom.api.DOMRpcService - org.opendaylight.controller.md.sal.dom.api.DOMRpcProviderService - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/BlockingTransactionChainListener.java b/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/BlockingTransactionChainListener.java deleted file mode 100644 index c7e3a201d8..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/BlockingTransactionChainListener.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.broker.impl; - -import com.google.common.util.concurrent.SettableFuture; -import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction; -import org.opendaylight.controller.md.sal.common.api.data.TransactionChain; -import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener; - -/** - * Simple implementation of {@link TransactionChainListener} for testing. - * - *

- * This transaction chain listener does not contain any logic, only update - * futures ({@link #getFailFuture()} and {@link #getSuccessFuture()} when - * transaction chain event is retrieved. - */ -@Deprecated -class BlockingTransactionChainListener implements TransactionChainListener { - - private final SettableFuture failFuture = SettableFuture.create(); - private final SettableFuture successFuture = SettableFuture.create(); - - @Override - public void onTransactionChainFailed(final TransactionChain chain, final AsyncTransaction transaction, - final Throwable cause) { - failFuture.set(cause); - } - - @Override - public void onTransactionChainSuccessful(final TransactionChain chain) { - successFuture.set(null); - } - - public SettableFuture getFailFuture() { - return failFuture; - } - - public SettableFuture getSuccessFuture() { - return successFuture; - } - -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMBrokerPerformanceTest.java b/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMBrokerPerformanceTest.java deleted file mode 100644 index 31d3fdf733..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMBrokerPerformanceTest.java +++ /dev/null @@ -1,221 +0,0 @@ -/* - * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.md.sal.dom.broker.impl; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.CONFIGURATION; -import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.OPERATIONAL; - -import com.google.common.base.Optional; -import com.google.common.collect.ImmutableMap; -import com.google.common.util.concurrent.Futures; -import com.google.common.util.concurrent.ListenableFuture; -import com.google.common.util.concurrent.ListeningExecutorService; -import com.google.common.util.concurrent.MoreExecutors; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.Callable; -import java.util.concurrent.Executors; -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.dom.api.DOMDataReadTransaction; -import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction; -import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore; -import org.opendaylight.controller.md.sal.dom.store.impl.TestModel; -import org.opendaylight.controller.sal.core.spi.data.DOMStore; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@Deprecated -public class DOMBrokerPerformanceTest { - - private static final Logger LOG = LoggerFactory.getLogger(DOMBrokerPerformanceTest.class); - - private static NormalizedNode outerList(final int index) { - return ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, index); - } - - private static YangInstanceIdentifier outerListPath(final int index) { - return YangInstanceIdentifier.builder(TestModel.OUTER_LIST_PATH)// - .nodeWithKey(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, index) // - .build(); - } - - private SchemaContext schemaContext; - private AbstractDOMDataBroker domBroker; - - private static V measure(final String name, final Callable callable) throws Exception { - // TODO Auto-generated method stub - LOG.debug("Measurement:{} Start", name); - long startNano = System.nanoTime(); - try { - return callable.call(); - } finally { - long endNano = System.nanoTime(); - LOG.info("Measurement:\"{}\" Time:{} ms", name, (endNano - startNano) / 1000000.0d); - } - } - - @Before - public void setupStore() { - InMemoryDOMDataStore operStore = new InMemoryDOMDataStore("OPER", MoreExecutors.newDirectExecutorService()); - InMemoryDOMDataStore configStore = new InMemoryDOMDataStore("CFG", MoreExecutors.newDirectExecutorService()); - schemaContext = TestModel.createTestContext(); - - operStore.onGlobalContextUpdated(schemaContext); - configStore.onGlobalContextUpdated(schemaContext); - - ImmutableMap stores = ImmutableMap.builder() // - .put(CONFIGURATION, configStore) // - .put(OPERATIONAL, operStore) // - .build(); - ListeningExecutorService executor = MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor()); - domBroker = new SerializedDOMDataBroker(stores, executor); - } - - @Test - public void testPerformance() throws Exception { - measure("Test Suite (all tests)", (Callable) () -> { - smallTestSuite(10, 1000); - //smallTestSuite(10, 100); - smallTestSuite(100, 100); - //smallTestSuite(100, 100); - //smallTestSuite(1000, 10); - smallTestSuite(1000, 10); - //smallTestSuite(1000, 1000); - return null; - }); - } - - private void smallTestSuite(final int txNum, final int innerListWriteNum) throws Exception { - measure("TestSuite (Txs:" + txNum + " innerWrites:" + innerListWriteNum + ")", (Callable) () -> { - measureOneTransactionTopContainer(); - measureSeparateWritesOneLevel(txNum, innerListWriteNum); - return null; - }); - } - - private void measureSeparateWritesOneLevel(final int txNum, final int innerNum) throws Exception { - final List transactions = measure("Txs:" + txNum + " Allocate", () -> { - List builder = new ArrayList<>(txNum); - for (int i = 0; i < txNum; i++) { - DOMDataReadWriteTransaction writeTx = domBroker.newReadWriteTransaction(); - builder.add(writeTx); - } - return builder; - }); - assertEquals(txNum, transactions.size()); - measure("Txs:" + txNum + " Writes:1", (Callable) () -> { - int index = 0; - for (DOMDataReadWriteTransaction writeTx : transactions) { - // Writes /test/outer-list/i in writeTx - writeTx.put(OPERATIONAL, outerListPath(index), outerList(index)); - index++; - } - return null; - }); - - measure("Txs:" + txNum + " Writes:" + innerNum, (Callable) () -> { - int index = 0; - for (DOMDataReadWriteTransaction writeTx : transactions) { - // Writes /test/outer-list/i in writeTx - YangInstanceIdentifier path = YangInstanceIdentifier.builder(outerListPath(index)) - .node(TestModel.INNER_LIST_QNAME).build(); - writeTx.put(OPERATIONAL, path, ImmutableNodes.mapNodeBuilder(TestModel.INNER_LIST_QNAME).build()); - for (int j = 0; j < innerNum; j++) { - YangInstanceIdentifier innerPath = YangInstanceIdentifier.builder(path) - .nodeWithKey(TestModel.INNER_LIST_QNAME, TestModel.NAME_QNAME, String.valueOf(j)).build(); - writeTx.put(OPERATIONAL, innerPath, ImmutableNodes - .mapEntry(TestModel.INNER_LIST_QNAME, TestModel.NAME_QNAME, String.valueOf(j))); - } - index++; - } - return null; - }); - - measure("Txs:" + txNum + " Submit, Finish", (Callable) () -> { - List> allFutures = measure(txNum + " Submits", () -> { - List> builder = new ArrayList<>(txNum); - for (DOMDataReadWriteTransaction tx : transactions) { - builder.add(tx.commit()); - } - return builder; - }); - Futures.allAsList(allFutures).get(); - return null; - }); - - final DOMDataReadTransaction readTx = measure("Txs:1 (ro), Allocate", - (Callable) () -> domBroker - .newReadOnlyTransaction()); - - - measure("Txs:1 (ro) Reads:" + txNum + " (1-level)", (Callable) () -> { - for (int i = 0; i < txNum; i++) { - ListenableFuture>> potential = readTx.read(OPERATIONAL, outerListPath(i)); - assertTrue("outerList/" + i, potential.get().isPresent()); - } - return null; - }); - - measure("Txs:1 (ro) Reads:" + txNum * innerNum + " (2-level)", (Callable) () -> { - for (int i = 0; i < txNum; i++) { - for (int j = 0; j < innerNum; j++) { - YangInstanceIdentifier path = YangInstanceIdentifier.builder(outerListPath(i)) - // - .node(TestModel.INNER_LIST_QNAME) - .nodeWithKey(TestModel.INNER_LIST_QNAME, TestModel.NAME_QNAME, String.valueOf(j)).build(); - ListenableFuture>> potential = readTx.read(OPERATIONAL, path); - assertTrue("outer-list/" + i + "/inner-list/" + j, potential.get().isPresent()); - } - } - return null; - }); - } - - private void measureOneTransactionTopContainer() throws Exception { - - final DOMDataReadWriteTransaction writeTx = - measure("Txs:1 Allocate", () -> domBroker.newReadWriteTransaction()); - - measure("Txs:1 Write", (Callable) () -> { - writeTx.put(OPERATIONAL, TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME)); - writeTx.put(OPERATIONAL, TestModel.OUTER_LIST_PATH, - ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME).build()); - return null; - }); - - measure("Txs:1 Reads:1", (Callable) () -> { - // Reads /test in writeTx - ListenableFuture>> writeTxContainer = writeTx - .read(OPERATIONAL, TestModel.TEST_PATH); - assertTrue(writeTxContainer.get().isPresent()); - return null; - }); - - measure("Txs:1 Reads:1", (Callable) () -> { - // Reads /test in writeTx - ListenableFuture>> writeTxContainer = writeTx - .read(OPERATIONAL, TestModel.TEST_PATH); - assertTrue(writeTxContainer.get().isPresent()); - return null; - }); - - measure("Txs:1 Submit, Finish", (Callable) () -> { - measure("Txs:1 Submit", (Callable>) writeTx::commit).get(); - return null; - }); - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMBrokerTest.java b/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMBrokerTest.java deleted file mode 100644 index 065035ffc3..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMBrokerTest.java +++ /dev/null @@ -1,235 +0,0 @@ -/* - * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.md.sal.dom.broker.impl; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.CONFIGURATION; -import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.OPERATIONAL; - -import com.google.common.base.Optional; -import com.google.common.collect.ImmutableMap; -import com.google.common.util.concurrent.ForwardingExecutorService; -import com.google.common.util.concurrent.ListenableFuture; -import com.google.common.util.concurrent.ListeningExecutorService; -import com.google.common.util.concurrent.MoreExecutors; -import java.util.Collections; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.RejectedExecutionException; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; -import java.util.concurrent.atomic.AtomicReference; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mockito; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitDeadlockException; -import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; -import org.opendaylight.controller.md.sal.dom.api.DOMDataReadTransaction; -import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction; -import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction; -import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore; -import org.opendaylight.controller.md.sal.dom.store.impl.TestModel; -import org.opendaylight.controller.sal.core.spi.data.DOMStore; -import org.opendaylight.yangtools.util.concurrent.DeadlockDetectingListeningExecutorService; -import org.opendaylight.yangtools.util.concurrent.SpecialExecutors; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -@Deprecated -public class DOMBrokerTest { - - private SchemaContext schemaContext; - private AbstractDOMDataBroker domBroker; - private ListeningExecutorService executor; - private ExecutorService futureExecutor; - private CommitExecutorService commitExecutor; - - @Before - public void setupStore() { - - InMemoryDOMDataStore operStore = new InMemoryDOMDataStore("OPER", MoreExecutors.newDirectExecutorService()); - InMemoryDOMDataStore configStore = new InMemoryDOMDataStore("CFG", MoreExecutors.newDirectExecutorService()); - schemaContext = TestModel.createTestContext(); - - operStore.onGlobalContextUpdated(schemaContext); - configStore.onGlobalContextUpdated(schemaContext); - - final ImmutableMap stores = - ImmutableMap.builder() // - .put(CONFIGURATION, configStore) // - .put(OPERATIONAL, operStore) // - .build(); - - commitExecutor = new CommitExecutorService(Executors.newSingleThreadExecutor()); - futureExecutor = SpecialExecutors.newBlockingBoundedCachedThreadPool(1, 5, "FCB", DOMBrokerTest.class); - executor = new DeadlockDetectingListeningExecutorService(commitExecutor, - TransactionCommitDeadlockException - .DEADLOCK_EXCEPTION_SUPPLIER, - futureExecutor); - domBroker = new SerializedDOMDataBroker(stores, executor); - } - - @After - public void tearDown() { - if (executor != null) { - executor.shutdownNow(); - } - - if (futureExecutor != null) { - futureExecutor.shutdownNow(); - } - } - - @Test(timeout = 10000) - public void testTransactionIsolation() throws InterruptedException, ExecutionException { - - assertNotNull(domBroker); - - DOMDataReadTransaction readTx = domBroker.newReadOnlyTransaction(); - assertNotNull(readTx); - - DOMDataReadWriteTransaction writeTx = domBroker.newReadWriteTransaction(); - assertNotNull(writeTx); - /** - * - * Writes /test in writeTx - * - */ - writeTx.put(OPERATIONAL, TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME)); - - /** - * Reads /test from writeTx Read should return container. - * - */ - ListenableFuture>> writeTxContainer = writeTx - .read(OPERATIONAL, TestModel.TEST_PATH); - assertTrue(writeTxContainer.get().isPresent()); - - /** - * Reads /test from readTx Read should return Absent. - * - */ - ListenableFuture>> readTxContainer = readTx - .read(OPERATIONAL, TestModel.TEST_PATH); - assertFalse(readTxContainer.get().isPresent()); - } - - @Test(timeout = 10000) - public void testTransactionCommit() throws InterruptedException, ExecutionException, TimeoutException { - - DOMDataReadWriteTransaction writeTx = domBroker.newReadWriteTransaction(); - assertNotNull(writeTx); - /** - * - * Writes /test in writeTx - * - */ - writeTx.put(OPERATIONAL, TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME)); - - /** - * Reads /test from writeTx Read should return container. - * - */ - ListenableFuture>> writeTxContainer = writeTx - .read(OPERATIONAL, TestModel.TEST_PATH); - assertTrue(writeTxContainer.get().isPresent()); - - writeTx.commit().get(5, TimeUnit.SECONDS); - - Optional> afterCommitRead = domBroker.newReadOnlyTransaction() - .read(OPERATIONAL, TestModel.TEST_PATH).get(); - assertTrue(afterCommitRead.isPresent()); - } - - @Test(timeout = 10000) - @Deprecated - public void testTransactionSubmit() throws InterruptedException, ExecutionException, TimeoutException { - - DOMDataReadWriteTransaction writeTx = domBroker.newReadWriteTransaction(); - assertNotNull(writeTx); - /** - * - * Writes /test in writeTx - * - */ - writeTx.put(OPERATIONAL, TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME)); - - /** - * Reads /test from writeTx Read should return container. - * - */ - ListenableFuture>> writeTxContainer = writeTx - .read(OPERATIONAL, TestModel.TEST_PATH); - assertTrue(writeTxContainer.get().isPresent()); - - writeTx.submit().get(5, TimeUnit.SECONDS); - - Optional> afterCommitRead = domBroker.newReadOnlyTransaction() - .read(OPERATIONAL, TestModel.TEST_PATH).get(); - assertTrue(afterCommitRead.isPresent()); - } - - @Test(expected = TransactionCommitFailedException.class) - @SuppressWarnings({"checkstyle:IllegalThrows", "checkstyle:AvoidHidingCauseException"}) - public void testRejectedCommit() throws Throwable { - - commitExecutor.delegate = Mockito.mock(ExecutorService.class); - Mockito.doThrow(new RejectedExecutionException("mock")).when(commitExecutor.delegate) - .execute(Mockito.any(Runnable.class)); - Mockito.doNothing().when(commitExecutor.delegate).shutdown(); - Mockito.doReturn(Collections.emptyList()).when(commitExecutor.delegate).shutdownNow(); - Mockito.doReturn("").when(commitExecutor.delegate).toString(); - Mockito.doReturn(true).when(commitExecutor.delegate) - .awaitTermination(Mockito.anyLong(), Mockito.any(TimeUnit.class)); - - DOMDataReadWriteTransaction writeTx = domBroker.newReadWriteTransaction(); - writeTx.put(OPERATIONAL, TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME)); - - try { - writeTx.commit().get(5, TimeUnit.SECONDS); - } catch (ExecutionException e) { - throw e.getCause(); - } - } - - @SuppressWarnings("checkstyle:IllegalCatch") - AtomicReference submitTxAsync(final DOMDataWriteTransaction writeTx) { - final AtomicReference caughtEx = new AtomicReference<>(); - new Thread(() -> { - try { - writeTx.commit(); - } catch (Throwable e) { - caughtEx.set(e); - } - }).start(); - - return caughtEx; - } - - - static class CommitExecutorService extends ForwardingExecutorService { - - ExecutorService delegate; - - CommitExecutorService(final ExecutorService delegate) { - this.delegate = delegate; - } - - @Override - protected ExecutorService delegate() { - return delegate; - } - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMDataTreeListenerTest.java b/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMDataTreeListenerTest.java deleted file mode 100644 index b026e209a3..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMDataTreeListenerTest.java +++ /dev/null @@ -1,445 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.broker.impl; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.CONFIGURATION; -import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.OPERATIONAL; - -import com.google.common.collect.ImmutableMap; -import com.google.common.util.concurrent.ForwardingExecutorService; -import com.google.common.util.concurrent.ListeningExecutorService; -import com.google.common.util.concurrent.MoreExecutors; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitDeadlockException; -import org.opendaylight.controller.md.sal.dom.api.DOMDataBrokerExtension; -import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener; -import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeService; -import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeIdentifier; -import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction; -import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore; -import org.opendaylight.controller.md.sal.dom.store.impl.TestModel; -import org.opendaylight.controller.sal.core.spi.data.DOMStore; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.util.concurrent.DeadlockDetectingListeningExecutorService; -import org.opendaylight.yangtools.util.concurrent.SpecialExecutors; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild; -import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; -import org.opendaylight.yangtools.yang.data.api.schema.MapNode; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate; -import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode; -import org.opendaylight.yangtools.yang.data.api.schema.tree.ModificationType; -import org.opendaylight.yangtools.yang.data.impl.schema.Builders; -import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -@Deprecated -public class DOMDataTreeListenerTest { - - private SchemaContext schemaContext; - private AbstractDOMDataBroker domBroker; - private ListeningExecutorService executor; - private ExecutorService futureExecutor; - private CommitExecutorService commitExecutor; - - private static final DataContainerChild OUTER_LIST = ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME) - .withChild(ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1)).build(); - - private static final DataContainerChild OUTER_LIST_2 = ImmutableNodes - .mapNodeBuilder(TestModel.OUTER_LIST_QNAME) - .withChild(ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 2)).build(); - - private static final NormalizedNode TEST_CONTAINER = Builders.containerBuilder() - .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME)).withChild(OUTER_LIST) - .build(); - - private static final NormalizedNode TEST_CONTAINER_2 = Builders.containerBuilder() - .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME)).withChild(OUTER_LIST_2) - .build(); - - private static DOMDataTreeIdentifier ROOT_DATA_TREE_ID = new DOMDataTreeIdentifier( - LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH); - - private static DOMDataTreeIdentifier OUTER_LIST_DATA_TREE_ID = new DOMDataTreeIdentifier( - LogicalDatastoreType.CONFIGURATION, TestModel.OUTER_LIST_PATH); - - @Before - public void setupStore() { - InMemoryDOMDataStore operStore = new InMemoryDOMDataStore("OPER", MoreExecutors.newDirectExecutorService()); - InMemoryDOMDataStore configStore = new InMemoryDOMDataStore("CFG", MoreExecutors.newDirectExecutorService()); - schemaContext = TestModel.createTestContext(); - - operStore.onGlobalContextUpdated(schemaContext); - configStore.onGlobalContextUpdated(schemaContext); - - final ImmutableMap stores = ImmutableMap.builder() // - .put(CONFIGURATION, configStore) // - .put(OPERATIONAL, operStore) // - .build(); - - commitExecutor = new CommitExecutorService(Executors.newSingleThreadExecutor()); - futureExecutor = SpecialExecutors.newBlockingBoundedCachedThreadPool(1, 5, "FCB", - DOMDataTreeListenerTest.class); - executor = new DeadlockDetectingListeningExecutorService(commitExecutor, - TransactionCommitDeadlockException - .DEADLOCK_EXCEPTION_SUPPLIER, - futureExecutor); - domBroker = new SerializedDOMDataBroker(stores, executor); - } - - @After - public void tearDown() { - if (executor != null) { - executor.shutdownNow(); - } - - if (futureExecutor != null) { - futureExecutor.shutdownNow(); - } - } - - @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 listenerReg = dataTreeChangeService - .registerDataTreeChangeListener(ROOT_DATA_TREE_ID, listener); - - final DOMDataWriteTransaction writeTx = domBroker.newWriteOnlyTransaction(); - writeTx.put(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH, TEST_CONTAINER); - writeTx.commit(); - - latch.await(5, TimeUnit.SECONDS); - - assertEquals(1, listener.getReceivedChanges().size()); - final Collection 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(); - } - - @Test - public void replaceContainerContainerInTreeTest() throws InterruptedException, ExecutionException { - final 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.commit().get(); - - final TestDataTreeListener listener = new TestDataTreeListener(latch); - final ListenerRegistration listenerReg = dataTreeChangeService - .registerDataTreeChangeListener(ROOT_DATA_TREE_ID, listener); - writeTx = domBroker.newWriteOnlyTransaction(); - writeTx.put(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH, TEST_CONTAINER_2); - writeTx.commit(); - - latch.await(5, TimeUnit.SECONDS); - - assertEquals(2, listener.getReceivedChanges().size()); - Collection 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(); - } - - @Test - public void deleteContainerContainerInTreeTest() throws InterruptedException, ExecutionException { - final 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.commit().get(); - - final TestDataTreeListener listener = new TestDataTreeListener(latch); - final ListenerRegistration listenerReg = dataTreeChangeService - .registerDataTreeChangeListener(ROOT_DATA_TREE_ID, listener); - - writeTx = domBroker.newWriteOnlyTransaction(); - writeTx.delete(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH); - writeTx.commit(); - - latch.await(5, TimeUnit.SECONDS); - - assertEquals(2, listener.getReceivedChanges().size()); - Collection 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(); - } - - @Test - public void replaceChildListContainerInTreeTest() throws InterruptedException, ExecutionException { - final 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.commit().get(); - - final TestDataTreeListener listener = new TestDataTreeListener(latch); - final ListenerRegistration listenerReg = dataTreeChangeService - .registerDataTreeChangeListener(ROOT_DATA_TREE_ID, listener); - - writeTx = domBroker.newWriteOnlyTransaction(); - writeTx.put(LogicalDatastoreType.CONFIGURATION, TestModel.OUTER_LIST_PATH, OUTER_LIST_2); - writeTx.commit(); - - latch.await(5, TimeUnit.SECONDS); - - assertEquals(2, listener.getReceivedChanges().size()); - Collection 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.SUBTREE_MODIFIED, candidateRoot); - final DataTreeCandidateNode modifiedChild = candidateRoot - .getModifiedChild(new YangInstanceIdentifier.NodeIdentifier(TestModel.OUTER_LIST_QNAME)).get(); - checkChange(OUTER_LIST, OUTER_LIST_2, ModificationType.WRITE, modifiedChild); - listenerReg.close(); - } - - @Test - public void rootModificationChildListenerTest() throws InterruptedException, ExecutionException { - final 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.commit().get(); - - final TestDataTreeListener listener = new TestDataTreeListener(latch); - final ListenerRegistration listenerReg = dataTreeChangeService - .registerDataTreeChangeListener(OUTER_LIST_DATA_TREE_ID, listener); - - writeTx = domBroker.newWriteOnlyTransaction(); - writeTx.put(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH, TEST_CONTAINER_2); - writeTx.commit().get(); - - latch.await(1, TimeUnit.SECONDS); - - assertEquals(2, listener.getReceivedChanges().size()); - Collection 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(); - } - - @Test - public void listEntryChangeNonRootRegistrationTest() throws InterruptedException, ExecutionException { - final 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.commit().get(); - - final TestDataTreeListener listener = new TestDataTreeListener(latch); - final ListenerRegistration listenerReg = dataTreeChangeService - .registerDataTreeChangeListener(OUTER_LIST_DATA_TREE_ID, listener); - - final YangInstanceIdentifier.NodeIdentifierWithPredicates outerListEntryId1 - = YangInstanceIdentifier.NodeIdentifierWithPredicates.of(TestModel.OUTER_LIST_QNAME, - TestModel.ID_QNAME, 1); - final YangInstanceIdentifier.NodeIdentifierWithPredicates outerListEntryId2 - = YangInstanceIdentifier.NodeIdentifierWithPredicates.of(TestModel.OUTER_LIST_QNAME, - TestModel.ID_QNAME, 2); - final YangInstanceIdentifier.NodeIdentifierWithPredicates outerListEntryId3 - = YangInstanceIdentifier.NodeIdentifierWithPredicates.of(TestModel.OUTER_LIST_QNAME, - TestModel.ID_QNAME, 3); - - final MapEntryNode outerListEntry1 = ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1); - final MapEntryNode outerListEntry2 = ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 2); - final MapEntryNode outerListEntry3 = ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 3); - - final MapNode listAfter = ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME).withChild(outerListEntry2) - .withChild(outerListEntry3).build(); - - writeTx = domBroker.newWriteOnlyTransaction(); - writeTx.delete(LogicalDatastoreType.CONFIGURATION, TestModel.OUTER_LIST_PATH.node(outerListEntryId1)); - writeTx.put(LogicalDatastoreType.CONFIGURATION, TestModel.OUTER_LIST_PATH.node(outerListEntryId2), - outerListEntry2); - writeTx.put(LogicalDatastoreType.CONFIGURATION, TestModel.OUTER_LIST_PATH.node(outerListEntryId3), - outerListEntry3); - writeTx.commit(); - - latch.await(5, TimeUnit.SECONDS); - - assertEquals(2, listener.getReceivedChanges().size()); - Collection 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, listAfter, ModificationType.SUBTREE_MODIFIED, candidateRoot); - final DataTreeCandidateNode entry1Canditate = candidateRoot.getModifiedChild(outerListEntryId1).get(); - checkChange(outerListEntry1, null, ModificationType.DELETE, entry1Canditate); - final DataTreeCandidateNode entry2Canditate = candidateRoot.getModifiedChild(outerListEntryId2).get(); - checkChange(null, outerListEntry2, ModificationType.WRITE, entry2Canditate); - final DataTreeCandidateNode entry3Canditate = candidateRoot.getModifiedChild(outerListEntryId3).get(); - checkChange(null, outerListEntry3, ModificationType.WRITE, entry3Canditate); - listenerReg.close(); - } - - private static void checkChange(final NormalizedNode expectedBefore, final NormalizedNode expectedAfter, - final ModificationType expectedMod, final DataTreeCandidateNode candidateNode) { - if (expectedBefore != null) { - assertTrue(candidateNode.getDataBefore().isPresent()); - assertEquals(expectedBefore, candidateNode.getDataBefore().get()); - } else { - assertFalse(candidateNode.getDataBefore().isPresent()); - } - - if (expectedAfter != null) { - assertTrue(candidateNode.getDataAfter().isPresent()); - assertEquals(expectedAfter, candidateNode.getDataAfter().get()); - } else { - assertFalse(candidateNode.getDataAfter().isPresent()); - } - - assertEquals(expectedMod, candidateNode.getModificationType()); - } - - private DOMDataTreeChangeService getDOMDataTreeChangeService() { - final DOMDataBrokerExtension extension = domBroker.getSupportedExtensions().get(DOMDataTreeChangeService.class); - if (extension == null) { - return null; - } - DOMDataTreeChangeService dataTreeChangeService = null; - if (extension instanceof DOMDataTreeChangeService) { - dataTreeChangeService = (DOMDataTreeChangeService) extension; - } - return dataTreeChangeService; - } - - - static class CommitExecutorService extends ForwardingExecutorService { - - ExecutorService delegate; - - CommitExecutorService(final ExecutorService delegate) { - this.delegate = delegate; - } - - @Override - protected ExecutorService delegate() { - return delegate; - } - } - - static class TestDataTreeListener implements DOMDataTreeChangeListener { - - private final List> receivedChanges = new ArrayList<>(); - private final CountDownLatch latch; - - TestDataTreeListener(final CountDownLatch latch) { - this.latch = latch; - } - - @Override - public void onDataTreeChanged(final Collection changes) { - receivedChanges.add(changes); - latch.countDown(); - } - - public List> getReceivedChanges() { - return receivedChanges; - } - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMForwardedWriteTransactionTest.java b/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMForwardedWriteTransactionTest.java deleted file mode 100644 index 9aa6de14b2..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMForwardedWriteTransactionTest.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.broker.impl; - -import static org.junit.Assert.assertTrue; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.doThrow; - -import com.google.common.util.concurrent.CheckedFuture; -import java.util.Collections; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction; - -@Deprecated -public class DOMForwardedWriteTransactionTest { - - @Mock - private AbstractDOMForwardedTransactionFactory abstractDOMForwardedTransactionFactory; - - @Mock - private DOMStoreWriteTransaction domStoreWriteTransaction; - - @Before - public void setup() { - MockitoAnnotations.initMocks(this); - } - - @Test - public void readyRuntimeExceptionAndCancel() { - RuntimeException thrown = new RuntimeException(); - doThrow(thrown).when(domStoreWriteTransaction).ready(); - DOMForwardedWriteTransaction domForwardedWriteTransaction = - new DOMForwardedWriteTransaction<>( - new Object(), - Collections.singletonMap(LogicalDatastoreType.OPERATIONAL, domStoreWriteTransaction), - abstractDOMForwardedTransactionFactory); - CheckedFuture submitFuture = domForwardedWriteTransaction.submit(); - try { - submitFuture.checkedGet(); - Assert.fail("TransactionCommitFailedException expected"); - } catch (TransactionCommitFailedException e) { - assertTrue(e.getCause() == thrown); - domForwardedWriteTransaction.cancel(); - } - } - - @Test - public void submitRuntimeExceptionAndCancel() { - RuntimeException thrown = new RuntimeException(); - doReturn(null).when(domStoreWriteTransaction).ready(); - doThrow(thrown).when(abstractDOMForwardedTransactionFactory).commit(any(), any(), any()); - DOMForwardedWriteTransaction domForwardedWriteTransaction = - new DOMForwardedWriteTransaction<>( - new Object(), - Collections.singletonMap(LogicalDatastoreType.OPERATIONAL, domStoreWriteTransaction), - abstractDOMForwardedTransactionFactory); - CheckedFuture submitFuture = domForwardedWriteTransaction.submit(); - try { - submitFuture.checkedGet(); - Assert.fail("TransactionCommitFailedException expected"); - } catch (TransactionCommitFailedException e) { - assertTrue(e.getCause() == thrown); - domForwardedWriteTransaction.cancel(); - } - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMNotificationRouterTest.java b/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMNotificationRouterTest.java deleted file mode 100644 index 5de0709d75..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMNotificationRouterTest.java +++ /dev/null @@ -1,272 +0,0 @@ -/* - * Copyright (c) 2018 Inocybe Technologies and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.broker.impl; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import com.google.common.collect.ImmutableSet; -import com.google.common.util.concurrent.SettableFuture; -import com.google.common.util.concurrent.Uninterruptibles; -import java.time.Instant; -import java.time.temporal.ChronoUnit; -import java.util.Date; -import java.util.Set; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; -import org.eclipse.jdt.annotation.Nullable; -import org.junit.BeforeClass; -import org.junit.Test; -import org.opendaylight.controller.md.sal.dom.api.DOMEvent; -import org.opendaylight.controller.md.sal.dom.api.DOMNotification; -import org.opendaylight.controller.md.sal.dom.api.DOMNotificationListener; -import org.opendaylight.controller.md.sal.dom.spi.DOMNotificationSubscriptionListener; -import org.opendaylight.controller.md.sal.dom.store.impl.TestModel; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; -import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder; -import org.opendaylight.yangtools.yang.model.api.Module; -import org.opendaylight.yangtools.yang.model.api.NotificationDefinition; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; - -/** - * Unit tests for DOMNotificationRouter. - * - * @author Thomas Pantelis - */ -@Deprecated -public class DOMNotificationRouterTest { - private static final ContainerNode BODY = ImmutableContainerNodeBuilder.create().withNodeIdentifier( - new NodeIdentifier(QName.create(TestModel.TEST_QNAME.getModule(), "test-notification"))) - .withChild(ImmutableNodes.leafNode(QName.create(TestModel.TEST_QNAME.getModule(), "value-leaf"), "foo")) - .build(); - // Truncate to milliseconds, as Java 9+ we get microsecond precision, which cannot be expressed in terms of Date - private static final Instant INSTANT = Instant.now().truncatedTo(ChronoUnit.MILLIS); - - private static SchemaPath notificationSchemaPath; - - private final org.opendaylight.mdsal.dom.broker.DOMNotificationRouter mdsalRouter = - org.opendaylight.mdsal.dom.broker.DOMNotificationRouter.create(16); - private final DOMNotificationRouter legacyRouter = - DOMNotificationRouter.create(mdsalRouter, mdsalRouter, mdsalRouter); - private final TestLegacyDOMNotificationListener testLegacyListener = new TestLegacyDOMNotificationListener(); - private final TestMdsalDOMNotificationListener testMdsalListener = new TestMdsalDOMNotificationListener(); - - @BeforeClass - public static void staticSetup() { - final SchemaContext schemaContext = TestModel.createTestContext(); - - Module testModule = schemaContext.findModule("odl-datastore-test", TestModel.TEST_QNAME.getRevision()).get(); - NotificationDefinition notificationDefinition = null; - for (NotificationDefinition def: testModule.getNotifications()) { - if (def.getQName().getLocalName().equals("test-notification")) { - notificationDefinition = def; - break; - } - } - - assertNotNull("test-notification not found in " + testModule.getNotifications(), notificationDefinition); - notificationSchemaPath = notificationDefinition.getPath(); - } - - @Test - public void testLegacyListenerAndPublish() throws InterruptedException, ExecutionException, TimeoutException { - final ListenerRegistration reg = - legacyRouter.registerNotificationListener(testLegacyListener, notificationSchemaPath); - - legacyRouter.putNotification(new TestLegacyDOMNotification()).get(5, TimeUnit.SECONDS); - testLegacyListener.verifyReceived(notificationSchemaPath, BODY, null); - - legacyRouter.offerNotification(new TestLegacyDOMNotification()).get(5, TimeUnit.SECONDS); - testLegacyListener.verifyReceived(notificationSchemaPath, BODY, null); - - legacyRouter.offerNotification(new TestLegacyDOMNotification(), 100, TimeUnit.MILLISECONDS) - .get(5, TimeUnit.SECONDS); - testLegacyListener.verifyReceived(notificationSchemaPath, BODY, null); - - legacyRouter.offerNotification(new TestLegacyDOMEvent()).get(5, TimeUnit.SECONDS); - testLegacyListener.verifyReceived(notificationSchemaPath, BODY, Date.from(INSTANT)); - - reg.close(); - - legacyRouter.offerNotification(new TestLegacyDOMNotification()).get(5, TimeUnit.SECONDS); - testLegacyListener.verifyNotReceived(); - } - - @Test - public void testLegacyListenerAndMdsalPublish() - throws InterruptedException, ExecutionException, TimeoutException { - legacyRouter.registerNotificationListener(testLegacyListener, notificationSchemaPath); - - mdsalRouter.offerNotification(new TestMdsalDOMNotification()).get(5, TimeUnit.SECONDS); - testLegacyListener.verifyReceived(notificationSchemaPath, BODY, null); - - mdsalRouter.offerNotification(new TestMdsalDOMEvent()).get(5, TimeUnit.SECONDS); - testLegacyListener.verifyReceived(notificationSchemaPath, BODY, Date.from(INSTANT)); - } - - @Test - public void testMdsalListenerAndLegacyPublish() - throws InterruptedException, ExecutionException, TimeoutException { - mdsalRouter.registerNotificationListener(testMdsalListener, notificationSchemaPath); - - legacyRouter.offerNotification(new TestLegacyDOMNotification()).get(5, TimeUnit.SECONDS); - testMdsalListener.verifyReceived(notificationSchemaPath, BODY, null); - - legacyRouter.offerNotification(new TestLegacyDOMEvent()).get(5, TimeUnit.SECONDS); - testMdsalListener.verifyReceived(notificationSchemaPath, BODY, INSTANT); - } - - @Test - public void testRegisterSubscriptionListener() throws InterruptedException, ExecutionException, TimeoutException { - TestLegacyDOMNotificationSubscriptionListener listener = new TestLegacyDOMNotificationSubscriptionListener(); - final ListenerRegistration subscriptionReg = - legacyRouter.registerSubscriptionListener(listener); - - listener.verifyReceived(); - - final ListenerRegistration listenerReg = - legacyRouter.registerNotificationListener(testLegacyListener, notificationSchemaPath); - - listener.verifyReceived(notificationSchemaPath); - - listenerReg.close(); - - listener.verifyReceived(); - - subscriptionReg.close(); - - legacyRouter.registerNotificationListener(testLegacyListener, notificationSchemaPath); - - listener.verifyNotReceived(); - } - - private static class TestLegacyDOMNotificationListener implements DOMNotificationListener { - SettableFuture receivedNotification = SettableFuture.create(); - - @Override - public void onNotification(final DOMNotification notification) { - receivedNotification.set(notification); - } - - void verifyReceived(final SchemaPath path, final ContainerNode body, final @Nullable Date eventTime) - throws InterruptedException, ExecutionException, TimeoutException { - final DOMNotification actual = receivedNotification.get(5, TimeUnit.SECONDS); - assertEquals(path, actual.getType()); - assertEquals(body, actual.getBody()); - - if (eventTime != null) { - assertTrue("Expected DOMEvent", actual instanceof DOMEvent); - assertEquals(eventTime, ((DOMEvent)actual).getEventTime()); - } else { - assertFalse("Unexpected DOMEvent", actual instanceof DOMEvent); - } - - receivedNotification = SettableFuture.create(); - } - - void verifyNotReceived() { - Uninterruptibles.sleepUninterruptibly(200, TimeUnit.MILLISECONDS); - assertFalse("Unexpected notification", receivedNotification.isDone()); - } - } - - private static class TestMdsalDOMNotificationListener - implements org.opendaylight.mdsal.dom.api.DOMNotificationListener { - SettableFuture receivedNotification = SettableFuture.create(); - - @Override - public void onNotification(final org.opendaylight.mdsal.dom.api.DOMNotification notification) { - receivedNotification.set(notification); - } - - void verifyReceived(final SchemaPath path, final ContainerNode body, final @Nullable Instant eventTime) - throws InterruptedException, ExecutionException, TimeoutException { - final org.opendaylight.mdsal.dom.api.DOMNotification actual = - receivedNotification.get(5, TimeUnit.SECONDS); - assertEquals(path, actual.getType()); - assertEquals(body, actual.getBody()); - - if (eventTime != null) { - assertTrue("Expected DOMEvent", actual instanceof org.opendaylight.mdsal.dom.api.DOMEvent); - assertEquals(eventTime, ((org.opendaylight.mdsal.dom.api.DOMEvent)actual).getEventInstant()); - } else { - assertFalse("Unexpected DOMEvent", actual instanceof org.opendaylight.mdsal.dom.api.DOMEvent); - } - - receivedNotification = SettableFuture.create(); - } - } - - private static class TestLegacyDOMNotificationSubscriptionListener implements DOMNotificationSubscriptionListener { - SettableFuture> receivedNotification = SettableFuture.create(); - - @Override - public void onSubscriptionChanged(final Set currentTypes) { - receivedNotification.set(currentTypes); - } - - void verifyReceived(final SchemaPath... paths) - throws InterruptedException, ExecutionException, TimeoutException { - final Set actual = receivedNotification.get(5, TimeUnit.SECONDS); - assertEquals(ImmutableSet.copyOf(paths), actual); - receivedNotification = SettableFuture.create(); - } - - void verifyNotReceived() { - Uninterruptibles.sleepUninterruptibly(200, TimeUnit.MILLISECONDS); - assertFalse("Unexpected notification", receivedNotification.isDone()); - } - } - - private static class TestLegacyDOMNotification implements DOMNotification { - @Override - public SchemaPath getType() { - return notificationSchemaPath; - } - - @Override - public ContainerNode getBody() { - return BODY; - } - } - - private static class TestLegacyDOMEvent extends TestLegacyDOMNotification implements DOMEvent { - @Override - public Date getEventTime() { - return Date.from(INSTANT); - } - } - - private static class TestMdsalDOMNotification implements org.opendaylight.mdsal.dom.api.DOMNotification { - @Override - public SchemaPath getType() { - return notificationSchemaPath; - } - - @Override - public ContainerNode getBody() { - return BODY; - } - } - - private static class TestMdsalDOMEvent extends TestMdsalDOMNotification - implements org.opendaylight.mdsal.dom.api.DOMEvent { - @Override - public Instant getEventInstant() { - return INSTANT; - } - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMRpcRouterTest.java b/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMRpcRouterTest.java deleted file mode 100644 index dc6f3acfb6..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMRpcRouterTest.java +++ /dev/null @@ -1,362 +0,0 @@ -/* - * Copyright (c) 2018 Inocybe Technologies and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.broker.impl; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.after; -import static org.mockito.Mockito.doNothing; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.reset; -import static org.mockito.Mockito.timeout; -import static org.mockito.Mockito.verify; - -import com.google.common.collect.ImmutableList; -import com.google.common.util.concurrent.CheckedFuture; -import com.google.common.util.concurrent.FluentFuture; -import com.google.common.util.concurrent.Futures; -import com.google.common.util.concurrent.ListenableFuture; -import java.util.AbstractMap.SimpleEntry; -import java.util.Collections; -import java.util.Map.Entry; -import java.util.concurrent.ExecutionException; -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcAvailabilityListener; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcException; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementation; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementationNotAvailableException; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementationRegistration; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult; -import org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult; -import org.opendaylight.controller.md.sal.dom.store.impl.TestModel; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.util.concurrent.FluentFutures; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.common.RpcError.ErrorType; -import org.opendaylight.yangtools.yang.common.RpcResultBuilder; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; -import org.opendaylight.yangtools.yang.model.api.Module; -import org.opendaylight.yangtools.yang.model.api.RpcDefinition; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; - -/** - * Unit tests for DOMRpcRouter. - * - * @author Thomas Pantelis - */ -@Deprecated -public class DOMRpcRouterTest { - - private static final NormalizedNode RPC_INPUT = ImmutableNodes.leafNode( - QName.create(TestModel.TEST_QNAME.getModule(), "input-leaf"), "foo"); - private static final NormalizedNode RPC_OUTPUT = ImmutableNodes.leafNode( - QName.create(TestModel.TEST_QNAME.getModule(), "output-leaf"), "bar"); - private final TestLegacyDOMRpcImplementation testLegacyRpcImpl = new TestLegacyDOMRpcImplementation(); - private final TestMdsalDOMRpcImplementation testMdsalRpcImpl = new TestMdsalDOMRpcImplementation(); - private org.opendaylight.mdsal.dom.broker.DOMRpcRouter mdsalRpcRouter; - private DOMRpcRouter legacyRpcRouter; - private DOMRpcIdentifier legacyTestRpcIdentifier; - private DOMRpcIdentifier legacyTestRpcNoInputIdentifier; - private org.opendaylight.mdsal.dom.api.DOMRpcIdentifier mdsalTestRpcIdentifier; - private org.opendaylight.mdsal.dom.api.DOMRpcIdentifier mdsalTestRpcNoInputIdentifier; - - @Before - public void setup() { - mdsalRpcRouter = new org.opendaylight.mdsal.dom.broker.DOMRpcRouter(); - final SchemaContext schemaContext = TestModel.createTestContext(); - mdsalRpcRouter.onGlobalContextUpdated(schemaContext); - legacyRpcRouter = new DOMRpcRouter(mdsalRpcRouter.getRpcService(), mdsalRpcRouter.getRpcProviderService()); - - legacyTestRpcIdentifier = DOMRpcIdentifier.create(findRpc(schemaContext, "test-rpc")); - legacyTestRpcNoInputIdentifier = DOMRpcIdentifier.create(findRpc(schemaContext, "test-rpc-no-input")); - mdsalTestRpcIdentifier = org.opendaylight.mdsal.dom.api.DOMRpcIdentifier.create( - findRpc(schemaContext, "test-rpc")); - mdsalTestRpcNoInputIdentifier = org.opendaylight.mdsal.dom.api.DOMRpcIdentifier.create( - findRpc(schemaContext, "test-rpc-no-input")); - } - - @Test - public void testLegacyRegistrationAndInvocation() throws InterruptedException, ExecutionException { - final DOMRpcImplementationRegistration reg = - legacyRpcRouter.registerRpcImplementation(testLegacyRpcImpl, legacyTestRpcIdentifier, - legacyTestRpcNoInputIdentifier); - - // Test success - - DefaultDOMRpcResult result = new DefaultDOMRpcResult(RPC_OUTPUT); - testLegacyRpcImpl.init(Futures.immediateCheckedFuture(result)); - - ListenableFuture future = legacyRpcRouter.invokeRpc(legacyTestRpcIdentifier.getType(), RPC_INPUT); - - assertSame(result, future.get()); - testLegacyRpcImpl.verifyInput(legacyTestRpcIdentifier, RPC_INPUT); - - // Test exception returned - - TestLegacyDOMRpcException rpcEx = new TestLegacyDOMRpcException(); - testLegacyRpcImpl.init(Futures.immediateFailedCheckedFuture(rpcEx)); - - try { - legacyRpcRouter.invokeRpc(legacyTestRpcIdentifier.getType(), RPC_INPUT).get(); - fail("Expected exception"); - } catch (ExecutionException e) { - assertEquals(rpcEx, e.getCause()); - } - - // Test no input or output - - testLegacyRpcImpl.init(Futures.immediateCheckedFuture(null)); - - future = legacyRpcRouter.invokeRpc(legacyTestRpcNoInputIdentifier.getType(), null); - - assertNull(future.get()); - testLegacyRpcImpl.verifyInput(legacyTestRpcNoInputIdentifier, null); - - // Test close - - reg.close(); - - try { - legacyRpcRouter.invokeRpc(legacyTestRpcIdentifier.getType(), RPC_INPUT).get(); - fail("Expected exception"); - } catch (ExecutionException e) { - assertTrue(e.getCause() instanceof DOMRpcImplementationNotAvailableException); - } - } - - @Test - public void testLegacyRegistrationAndMdsalInvocation() throws InterruptedException, ExecutionException { - legacyRpcRouter.registerRpcImplementation(testLegacyRpcImpl, legacyTestRpcIdentifier, - legacyTestRpcNoInputIdentifier); - - // Test success - - DefaultDOMRpcResult result = new DefaultDOMRpcResult(RPC_OUTPUT, - Collections.singleton(RpcResultBuilder.newError(ErrorType.RPC, "tag", "message"))); - testLegacyRpcImpl.init(Futures.immediateCheckedFuture(result)); - - ListenableFuture future = - mdsalRpcRouter.getRpcService().invokeRpc(mdsalTestRpcIdentifier.getType(), RPC_INPUT); - - assertEquals(RPC_OUTPUT, future.get().getResult()); - assertEquals(1, future.get().getErrors().size()); - assertEquals(ErrorType.RPC, future.get().getErrors().iterator().next().getErrorType()); - assertEquals("tag", future.get().getErrors().iterator().next().getTag()); - assertEquals("message", future.get().getErrors().iterator().next().getMessage()); - testLegacyRpcImpl.verifyInput(legacyTestRpcIdentifier, RPC_INPUT); - - // Test exception returned - - TestLegacyDOMRpcException rpcEx = new TestLegacyDOMRpcException(); - testLegacyRpcImpl.init(Futures.immediateFailedCheckedFuture(rpcEx)); - - try { - mdsalRpcRouter.getRpcService().invokeRpc(mdsalTestRpcIdentifier.getType(), RPC_INPUT).get(); - fail("Expected exception"); - } catch (ExecutionException e) { - assertEquals(rpcEx, e.getCause()); - } - - // Test no input or output - - testLegacyRpcImpl.init(Futures.immediateCheckedFuture(null)); - - future = mdsalRpcRouter.getRpcService().invokeRpc(mdsalTestRpcNoInputIdentifier.getType(), null); - - assertNull(future.get()); - testLegacyRpcImpl.verifyInput(legacyTestRpcNoInputIdentifier, null); - } - - @Test - public void testMdsalRegistrationAndLegacyInvocation() throws InterruptedException, ExecutionException { - mdsalRpcRouter.getRpcProviderService().registerRpcImplementation(testMdsalRpcImpl, mdsalTestRpcIdentifier, - mdsalTestRpcNoInputIdentifier); - - // Test success - - org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult result = - new org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult(RPC_OUTPUT, - Collections.singleton(RpcResultBuilder.newError(ErrorType.RPC, "tag", "message"))); - testMdsalRpcImpl.init(FluentFutures.immediateFluentFuture(result)); - - ListenableFuture future = legacyRpcRouter.invokeRpc(legacyTestRpcIdentifier.getType(), RPC_INPUT); - - assertEquals(RPC_OUTPUT, future.get().getResult()); - assertEquals(1, future.get().getErrors().size()); - assertEquals(ErrorType.RPC, future.get().getErrors().iterator().next().getErrorType()); - assertEquals("tag", future.get().getErrors().iterator().next().getTag()); - assertEquals("message", future.get().getErrors().iterator().next().getMessage()); - testMdsalRpcImpl.verifyInput(mdsalTestRpcIdentifier, RPC_INPUT); - - // Test exception returned - - TestMdsalDOMRpcException rpcEx = new TestMdsalDOMRpcException(); - testMdsalRpcImpl.init(FluentFutures.immediateFailedFluentFuture(rpcEx)); - - try { - legacyRpcRouter.invokeRpc(legacyTestRpcIdentifier.getType(), RPC_INPUT).get(); - fail("Expected exception"); - } catch (ExecutionException e) { - assertTrue("Unexpected exception " + e.getCause(), e.getCause() instanceof DOMRpcException); - assertEquals(rpcEx, e.getCause().getCause()); - } - - // Test no input or output - - testMdsalRpcImpl.init(FluentFutures.immediateNullFluentFuture()); - - future = legacyRpcRouter.invokeRpc(legacyTestRpcNoInputIdentifier.getType(), null); - - assertNull(future.get()); - testMdsalRpcImpl.verifyInput(mdsalTestRpcNoInputIdentifier, null); - } - - @Test - public void testRegisterRpcListener() { - final TestLegacyDOMRpcImplementation2 testRpcImpl2 = new TestLegacyDOMRpcImplementation2(); - - DOMRpcAvailabilityListener listener = mock(DOMRpcAvailabilityListener.class); - doNothing().when(listener).onRpcAvailable(any()); - doNothing().when(listener).onRpcUnavailable(any()); - doReturn(true).when(listener).acceptsImplementation(any()); - final ListenerRegistration listenerReg = legacyRpcRouter.registerRpcListener(listener); - - DOMRpcAvailabilityListener filteredListener = mock(DOMRpcAvailabilityListener.class); - doNothing().when(filteredListener).onRpcAvailable(any()); - doNothing().when(filteredListener).onRpcUnavailable(any()); - doReturn(true).when(filteredListener).acceptsImplementation(testLegacyRpcImpl); - doReturn(false).when(filteredListener).acceptsImplementation(testRpcImpl2); - final ListenerRegistration filteredListenerReg = legacyRpcRouter.registerRpcListener(filteredListener); - - final DOMRpcImplementationRegistration testRpcReg = - legacyRpcRouter.registerRpcImplementation(testLegacyRpcImpl, legacyTestRpcIdentifier); - - verify(listener, timeout(5000)).onRpcAvailable(ImmutableList.of(legacyTestRpcIdentifier)); - verify(filteredListener, timeout(5000)).onRpcAvailable(ImmutableList.of(legacyTestRpcIdentifier)); - - final DOMRpcImplementationRegistration testRpcNoInputReg = - legacyRpcRouter.registerRpcImplementation(testRpcImpl2, legacyTestRpcNoInputIdentifier); - - verify(listener, timeout(5000)).onRpcAvailable(ImmutableList.of(legacyTestRpcNoInputIdentifier)); - verify(filteredListener, after(200).never()).onRpcAvailable(ImmutableList.of(legacyTestRpcNoInputIdentifier)); - - testRpcReg.close(); - - verify(listener, timeout(5000)).onRpcUnavailable(ImmutableList.of(legacyTestRpcIdentifier)); - verify(filteredListener, timeout(5000)).onRpcUnavailable(ImmutableList.of(legacyTestRpcIdentifier)); - - testRpcNoInputReg.close(); - - verify(listener, timeout(5000)).onRpcUnavailable(ImmutableList.of(legacyTestRpcNoInputIdentifier)); - verify(filteredListener, after(200).never()).onRpcUnavailable(ImmutableList.of(legacyTestRpcNoInputIdentifier)); - - reset(listener, filteredListener); - - listenerReg.close(); - filteredListenerReg.close(); - - legacyRpcRouter.registerRpcImplementation(testLegacyRpcImpl, legacyTestRpcIdentifier); - - verify(listener, after(200).never()).onRpcAvailable(ImmutableList.of(legacyTestRpcIdentifier)); - verify(filteredListener, never()).onRpcAvailable(ImmutableList.of(legacyTestRpcIdentifier)); - } - - private static SchemaPath findRpc(SchemaContext schemaContext, String name) { - Module testModule = schemaContext.findModule("odl-datastore-test", TestModel.TEST_QNAME.getRevision()).get(); - RpcDefinition rpcDefinition = null; - for (RpcDefinition def: testModule.getRpcs()) { - if (def.getQName().getLocalName().equals(name)) { - rpcDefinition = def; - break; - } - } - - assertNotNull(name + " rpc not found in " + testModule.getRpcs(), rpcDefinition); - return rpcDefinition.getPath(); - } - - private abstract static class AbstractDOMRpcImplementation { - Entry> rpcInput; - - void verifyInput(T expRpc, NormalizedNode expInput) { - assertNotNull(rpcInput); - assertEquals(expRpc, rpcInput.getKey()); - assertEquals(expInput, rpcInput.getValue()); - } - } - - private static class TestLegacyDOMRpcImplementation extends AbstractDOMRpcImplementation - implements DOMRpcImplementation { - CheckedFuture returnFuture; - - @Override - public CheckedFuture invokeRpc( - final DOMRpcIdentifier rpc, final NormalizedNode input) { - rpcInput = new SimpleEntry<>(rpc, input); - return returnFuture; - } - - void init(CheckedFuture retFuture) { - this.returnFuture = retFuture; - rpcInput = null; - } - } - - private static class TestMdsalDOMRpcImplementation - extends AbstractDOMRpcImplementation - implements org.opendaylight.mdsal.dom.api.DOMRpcImplementation { - FluentFuture returnFuture; - - @Override - public FluentFuture invokeRpc( - final org.opendaylight.mdsal.dom.api.DOMRpcIdentifier rpc, final NormalizedNode input) { - rpcInput = new SimpleEntry<>(rpc, input); - return returnFuture; - } - - void init(FluentFuture retFuture) { - this.returnFuture = retFuture; - rpcInput = null; - } - } - - private static class TestLegacyDOMRpcImplementation2 implements DOMRpcImplementation { - @Override - public CheckedFuture invokeRpc( - final DOMRpcIdentifier rpc, final NormalizedNode input) { - return null; - } - } - - private static class TestLegacyDOMRpcException extends DOMRpcException { - private static final long serialVersionUID = 1L; - - TestLegacyDOMRpcException() { - super("test"); - } - } - - private static class TestMdsalDOMRpcException extends org.opendaylight.mdsal.dom.api.DOMRpcException { - private static final long serialVersionUID = 1L; - - TestMdsalDOMRpcException() { - super("test"); - } - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMTransactionChainTest.java b/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMTransactionChainTest.java deleted file mode 100644 index 6f313e1588..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMTransactionChainTest.java +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.broker.impl; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; -import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.CONFIGURATION; -import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.OPERATIONAL; - -import com.google.common.base.Optional; -import com.google.common.collect.ImmutableMap; -import com.google.common.util.concurrent.ListenableFuture; -import com.google.common.util.concurrent.ListeningExecutorService; -import com.google.common.util.concurrent.MoreExecutors; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.dom.api.DOMDataReadTransaction; -import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction; -import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain; -import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore; -import org.opendaylight.controller.md.sal.dom.store.impl.TestModel; -import org.opendaylight.controller.sal.core.spi.data.DOMStore; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -@Deprecated -public class DOMTransactionChainTest { - - private SchemaContext schemaContext; - private AbstractDOMDataBroker domBroker; - - @Before - public void setupStore() { - InMemoryDOMDataStore operStore = new InMemoryDOMDataStore("OPER", MoreExecutors.newDirectExecutorService()); - InMemoryDOMDataStore configStore = new InMemoryDOMDataStore("CFG", MoreExecutors.newDirectExecutorService()); - schemaContext = TestModel.createTestContext(); - - operStore.onGlobalContextUpdated(schemaContext); - configStore.onGlobalContextUpdated(schemaContext); - - ImmutableMap stores = ImmutableMap.builder() // - .put(CONFIGURATION, configStore) // - .put(OPERATIONAL, operStore) // - .build(); - - ListeningExecutorService executor = MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor()); - domBroker = new SerializedDOMDataBroker(stores, executor); - } - - @Test - public void testTransactionChainNoConflict() throws InterruptedException, ExecutionException, TimeoutException { - BlockingTransactionChainListener listener = new BlockingTransactionChainListener(); - DOMTransactionChain txChain = domBroker.createTransactionChain(listener); - assertNotNull(txChain); - - /** - * We alocate new read-write transaction and write /test. - */ - DOMDataReadWriteTransaction firstTx = allocateAndWrite(txChain); - - /** - * First transaction is marked as ready, we are able to allocate chained - * transactions. - */ - ListenableFuture firstWriteTxFuture = firstTx.commit(); - - /** - * We alocate chained transaction - read transaction. - */ - DOMDataReadTransaction secondReadTx = txChain.newReadOnlyTransaction(); - - /** - * - * We test if we are able to read data from tx, read should not fail - * since we are using chained transaction. - */ - assertTestContainerExists(secondReadTx); - - /** - * We alocate next transaction, which is still based on first one, but - * is read-write. - * - */ - DOMDataReadWriteTransaction thirdDeleteTx = allocateAndDelete(txChain); - - /** - * We commit first transaction. - * - */ - assertCommitSuccessful(firstWriteTxFuture); - - /** - * Allocates transaction from data store. - */ - DOMDataReadTransaction storeReadTx = domBroker.newReadOnlyTransaction(); - - /** - * We verify transaction is commited to store, container should exists - * in datastore. - */ - assertTestContainerExists(storeReadTx); - - /** - * third transaction is sealed and commited. - */ - ListenableFuture thirdDeleteTxFuture = thirdDeleteTx.commit(); - assertCommitSuccessful(thirdDeleteTxFuture); - - /** - * We close transaction chain. - */ - txChain.close(); - - listener.getSuccessFuture().get(1000, TimeUnit.MILLISECONDS); - } - - @Test - @SuppressWarnings("checkstyle:IllegalCatch") - public void testTransactionChainNotSealed() throws InterruptedException, ExecutionException { - BlockingTransactionChainListener listener = new BlockingTransactionChainListener(); - DOMTransactionChain txChain = domBroker.createTransactionChain(listener); - assertNotNull(txChain); - - /** - * We alocate new read-write transaction and write /test - */ - allocateAndWrite(txChain); - - /** - * We alocate chained transaction - read transaction, note first one is - * still not commited to datastore, so this allocation should fail with - * IllegalStateException. - */ - try { - txChain.newReadOnlyTransaction(); - fail("Allocation of secondReadTx should fail with IllegalStateException"); - } catch (Exception e) { - assertTrue(e instanceof IllegalStateException); - } - } - - private static DOMDataReadWriteTransaction allocateAndDelete( - final DOMTransactionChain txChain) throws InterruptedException, ExecutionException { - DOMDataReadWriteTransaction tx = txChain.newReadWriteTransaction(); - - /** - * We test existence of /test in third transaction container should - * still be visible from first one (which is still uncommmited). - * - */ - assertTestContainerExists(tx); - - /** - * We delete node in third transaction - */ - tx.delete(LogicalDatastoreType.OPERATIONAL, TestModel.TEST_PATH); - return tx; - } - - private static DOMDataReadWriteTransaction allocateAndWrite(final DOMTransactionChain txChain) - throws InterruptedException, ExecutionException { - DOMDataReadWriteTransaction tx = txChain.newReadWriteTransaction(); - assertTestContainerWrite(tx); - return tx; - } - - private static void assertCommitSuccessful(final ListenableFuture future) - throws InterruptedException, ExecutionException { - future.get(); - } - - private static void assertTestContainerExists(final DOMDataReadTransaction readTx) - throws InterruptedException, ExecutionException { - ListenableFuture>> readFuture = readTx.read(OPERATIONAL, TestModel.TEST_PATH); - Optional> readedData = readFuture.get(); - assertTrue(readedData.isPresent()); - } - - private static void assertTestContainerWrite(final DOMDataReadWriteTransaction tx) - throws InterruptedException, ExecutionException { - tx.put(OPERATIONAL, TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME)); - assertTestContainerExists(tx); - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/MountPointServiceTest.java b/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/MountPointServiceTest.java deleted file mode 100644 index f837788510..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/MountPointServiceTest.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.md.sal.dom.broker.impl; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import com.google.common.base.Optional; -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint; -import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService; -import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService.DOMMountPointBuilder; -import org.opendaylight.controller.md.sal.dom.broker.impl.mount.DOMMountPointServiceImpl; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; - -@Deprecated -public class MountPointServiceTest { - - private DOMMountPointService mountService; - private static final YangInstanceIdentifier PATH = YangInstanceIdentifier - .of(QName.create("namespace", "2012-12-12", "top")); - - @Before - public void setup() { - mountService = new DOMMountPointServiceImpl(); - } - - @Test - public void createSimpleMountPoint() { - Optional mountNotPresent = mountService.getMountPoint(PATH); - assertFalse(mountNotPresent.isPresent()); - DOMMountPointBuilder mountBuilder = mountService.createMountPoint(PATH); - mountBuilder.register(); - - Optional mountPresent = mountService.getMountPoint(PATH); - assertTrue(mountPresent.isPresent()); - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/legacy/sharded/adapter/ShardedDOMDataBrokerDelegatingReadWriteTransactionTest.java b/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/legacy/sharded/adapter/ShardedDOMDataBrokerDelegatingReadWriteTransactionTest.java deleted file mode 100644 index 8286909920..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/legacy/sharded/adapter/ShardedDOMDataBrokerDelegatingReadWriteTransactionTest.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.md.sal.dom.broker.impl.legacy.sharded.adapter; - -import static org.junit.Assert.assertEquals; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.doNothing; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.verify; - -import com.google.common.base.Optional; -import com.google.common.util.concurrent.Futures; -import org.gaul.modernizer_maven_annotations.SuppressModernizer; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Matchers; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction; -import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction; -import org.opendaylight.controller.md.sal.dom.store.impl.TestModel; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild; -import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; -import org.opendaylight.yangtools.yang.data.api.schema.MapNode; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.CollectionNodeBuilder; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder; - -@Deprecated -public class ShardedDOMDataBrokerDelegatingReadWriteTransactionTest { - - @Mock - private DOMDataWriteTransaction writeTx; - - @Mock - private DOMDataReadOnlyTransaction readTx; - - private ShardedDOMDataBrokerDelegatingReadWriteTransaction rwTx; - - @Before - public void setUp() { - MockitoAnnotations.initMocks(this); - doNothing().when(writeTx).put(any(), any(), any()); - doNothing().when(writeTx).merge(any(), any(), any()); - doNothing().when(writeTx).delete(any(), any()); - rwTx = new ShardedDOMDataBrokerDelegatingReadWriteTransaction("TEST-TX", TestModel.createTestContext(), readTx, - writeTx); - } - - @Test(expected = IllegalStateException.class) - public void testFirstReadShouldFail() { - rwTx.read(LogicalDatastoreType.OPERATIONAL, TestModel.TEST_PATH); - } - - @Test - public void testGetIdentifier() { - assertEquals("TEST-TX", rwTx.getIdentifier()); - } - - @Test - @SuppressModernizer - public void testReadWriteOperations() throws Exception { - doReturn(Futures.immediateCheckedFuture(Optional.absent())).when(readTx).read(any(), any()); - rwTx.put(LogicalDatastoreType.OPERATIONAL, TestModel.TEST_PATH, testNodeWithOuter(1, 2, 3)); - - verify(writeTx).put(eq(LogicalDatastoreType.OPERATIONAL), Matchers.eq(TestModel.TEST_PATH), - Matchers.eq(testNodeWithOuter(1, 2, 3))); - verify(readTx).read(eq(LogicalDatastoreType.OPERATIONAL), Matchers.eq(TestModel.TEST_PATH)); - - assertEquals(testNodeWithOuter(1, 2, 3), - rwTx.read(LogicalDatastoreType.OPERATIONAL, TestModel.TEST_PATH).checkedGet().get()); - - rwTx.merge(LogicalDatastoreType.OPERATIONAL, TestModel.TEST_PATH, testNodeWithOuter(4, 5, 6)); - assertEquals(testNodeWithOuter(1, 2, 3, 4, 5, 6), - rwTx.read(LogicalDatastoreType.OPERATIONAL, TestModel.TEST_PATH).checkedGet().get()); - - rwTx.delete(LogicalDatastoreType.OPERATIONAL, TestModel.TEST_PATH); - - verify(writeTx).delete(eq(LogicalDatastoreType.OPERATIONAL), Matchers.eq(TestModel.TEST_PATH)); - assertEquals(Optional.absent(), rwTx.read(LogicalDatastoreType.OPERATIONAL, TestModel.TEST_PATH).checkedGet()); - } - - private static DataContainerChild outerNode(final int... ids) { - CollectionNodeBuilder outer = ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME); - for (int id : ids) { - outer.addChild(ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, id)); - } - - return outer.build(); - } - - private static NormalizedNode testNodeWithOuter(final int... ids) { - return testNodeWithOuter(outerNode(ids)); - } - - private static NormalizedNode testNodeWithOuter(final DataContainerChild outer) { - return ImmutableContainerNodeBuilder.create() - .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME)).withChild(outer) - .build(); - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/legacy/sharded/adapter/ShardedDOMDataBrokerDelegatingTransactionChainTest.java b/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/legacy/sharded/adapter/ShardedDOMDataBrokerDelegatingTransactionChainTest.java deleted file mode 100644 index efbe7e2d26..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/legacy/sharded/adapter/ShardedDOMDataBrokerDelegatingTransactionChainTest.java +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.md.sal.dom.broker.impl.legacy.sharded.adapter; - -import static org.junit.Assert.assertEquals; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.doNothing; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.ArgumentCaptor; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction; -import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener; -import org.opendaylight.controller.md.sal.dom.store.impl.TestModel; -import org.opendaylight.mdsal.dom.api.DOMDataBroker; -import org.opendaylight.mdsal.dom.api.DOMDataTreeReadTransaction; -import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction; -import org.opendaylight.mdsal.dom.api.DOMTransactionChain; - -@Deprecated -public class ShardedDOMDataBrokerDelegatingTransactionChainTest { - - @Mock - private DOMDataBroker dataBroker; - - @Mock - private DOMTransactionChain delegateTxChain; - - @Mock - private TransactionChainListener txChainlistener; - - private ShardedDOMDataBrokerDelegatingTransactionChain txChain; - - @Before - public void setUp() { - MockitoAnnotations.initMocks(this); - - doReturn(delegateTxChain).when(dataBroker).createTransactionChain(any()); - txChain = new ShardedDOMDataBrokerDelegatingTransactionChain("1", TestModel.createTestContext(), dataBroker, - txChainlistener); - } - - @Test - public void testClose() { - doNothing().when(delegateTxChain).close(); - txChain.close(); - verify(delegateTxChain).close(); - } - - @Test - public void testNewWriteTransaction() { - DOMDataTreeWriteTransaction delegateWriteTx = mock(DOMDataTreeWriteTransaction.class); - doReturn(delegateWriteTx).when(delegateTxChain).newWriteOnlyTransaction(); - doReturn("TEST-WRITE-TX-DELEGATE").when(delegateWriteTx).getIdentifier(); - txChain.newWriteOnlyTransaction(); - verify(delegateTxChain).newWriteOnlyTransaction(); - } - - @Test - public void testNewReadOnlyTransaction() { - DOMDataTreeReadTransaction delegateReadTx = mock(DOMDataTreeReadTransaction.class); - doReturn("TEST-READ-TX-DELEGATE").when(delegateReadTx).getIdentifier(); - doReturn(delegateReadTx).when(delegateTxChain).newReadOnlyTransaction(); - txChain.newReadOnlyTransaction(); - verify(delegateTxChain).newReadOnlyTransaction(); - } - - - @Test - public void testNewReadWriteTransaction() { - DOMDataTreeReadTransaction delegateReadTx = mock(DOMDataTreeReadTransaction.class); - doReturn("TEST-READ-TX-DELEGATE").when(delegateReadTx).getIdentifier(); - doReturn(delegateReadTx).when(delegateTxChain).newReadOnlyTransaction(); - - DOMDataTreeWriteTransaction delegateWriteTx = mock(DOMDataTreeWriteTransaction.class); - doReturn(delegateWriteTx).when(delegateTxChain).newWriteOnlyTransaction(); - doReturn("TEST-WRITE-TX-DELEGATE").when(delegateWriteTx).getIdentifier(); - - txChain.newReadWriteTransaction(); - verify(delegateTxChain).newReadOnlyTransaction(); - verify(delegateTxChain).newWriteOnlyTransaction(); - } - - @Test - public void testTransactionChainFailed() { - final DOMDataTreeWriteTransaction writeTxDelegate = mock(DOMDataTreeWriteTransaction.class); - doReturn("DELEGATE-WRITE-TX-1").when(writeTxDelegate).getIdentifier(); - doReturn(writeTxDelegate).when(delegateTxChain).newWriteOnlyTransaction(); - doNothing().when(txChainlistener).onTransactionChainFailed(any(), any(), any()); - - // verify writetx fail - txChain.newWriteOnlyTransaction(); - txChain.onTransactionChainFailed(delegateTxChain, writeTxDelegate, new Throwable("Fail")); - - final ArgumentCaptor txCaptor = ArgumentCaptor.forClass(AsyncTransaction.class); - final ArgumentCaptor throwableCaptor = ArgumentCaptor.forClass(Throwable.class); - verify(txChainlistener).onTransactionChainFailed(eq(txChain), txCaptor.capture(), throwableCaptor.capture()); - assertEquals("DOM-CHAIN-1-0", txCaptor.getValue().getIdentifier()); - assertEquals("Fail", throwableCaptor.getValue().getMessage()); - - // verify readtx fail - final DOMDataTreeReadTransaction readTxDelegate = mock(DOMDataTreeReadTransaction.class); - doReturn("DELEGATE-READ-TX-1").when(readTxDelegate).getIdentifier(); - doReturn(readTxDelegate).when(delegateTxChain).newReadOnlyTransaction(); - doNothing().when(txChainlistener).onTransactionChainFailed(any(), any(), any()); - txChain.newReadOnlyTransaction(); - txChain.onTransactionChainFailed(delegateTxChain, readTxDelegate, new Throwable("Fail")); - verify(txChainlistener, times(2)) - .onTransactionChainFailed(eq(txChain), txCaptor.capture(), throwableCaptor.capture()); - assertEquals("DOM-CHAIN-1-1", txCaptor.getValue().getIdentifier()); - assertEquals("Fail", throwableCaptor.getValue().getMessage()); - - - // verify readwritetx fail, we must check both read and write failure - // translates to returned readwritetx - - // we can reuse write and read tx delegates, just return different - // identifiers to avoid conflicts in keys in tx dictionary - doReturn("DELEGATE-WRITE-RWTX-1").when(writeTxDelegate).getIdentifier(); - doReturn("DELEGATE-READ-RWTX-1").when(readTxDelegate).getIdentifier(); - txChain.newReadWriteTransaction(); - txChain.onTransactionChainFailed(delegateTxChain, writeTxDelegate, new Throwable("Fail")); - verify(txChainlistener, times(3)) - .onTransactionChainFailed(eq(txChain), txCaptor.capture(), throwableCaptor.capture()); - assertEquals("DOM-CHAIN-1-2", txCaptor.getValue().getIdentifier()); - assertEquals("Fail", throwableCaptor.getValue().getMessage()); - - txChain.onTransactionChainFailed(delegateTxChain, readTxDelegate, new Throwable("Fail")); - verify(txChainlistener, times(4)) - .onTransactionChainFailed(eq(txChain), txCaptor.capture(), throwableCaptor.capture()); - assertEquals("DOM-CHAIN-1-2", txCaptor.getValue().getIdentifier()); - assertEquals("Fail", throwableCaptor.getValue().getMessage()); - } - - @Test - public void testTransactionChainSuccessful() { - doNothing().when(txChainlistener).onTransactionChainSuccessful(any()); - txChain.onTransactionChainSuccessful(delegateTxChain); - verify(txChainlistener).onTransactionChainSuccessful(eq(txChain)); - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/TestModel.java b/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/TestModel.java deleted file mode 100644 index 70260eb496..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/TestModel.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.store.impl; - -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; - -@Deprecated -public final class TestModel { - - private TestModel() { - } - - public static final QName TEST_QNAME = - QName.create("urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test", "2014-03-13", "test"); - public static final QName TEST2_QNAME = - QName.create("urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test", "2014-03-13", "test2"); - public static final QName OUTER_LIST_QNAME = QName.create(TEST_QNAME, "outer-list"); - public static final QName INNER_LIST_QNAME = QName.create(TEST_QNAME, "inner-list"); - public static final QName OUTER_CHOICE_QNAME = QName.create(TEST_QNAME, "outer-choice"); - public static final QName ID_QNAME = QName.create(TEST_QNAME, "id"); - public static final QName NAME_QNAME = QName.create(TEST_QNAME, "name"); - public static final QName VALUE_QNAME = QName.create(TEST_QNAME, "value"); - public static final QName TWO_QNAME = QName.create(TEST_QNAME,"two"); - public static final QName THREE_QNAME = QName.create(TEST_QNAME,"three"); - public static final YangInstanceIdentifier TEST_PATH = YangInstanceIdentifier.of(TEST_QNAME); - public static final YangInstanceIdentifier TEST2_PATH = YangInstanceIdentifier.of(TEST2_QNAME); - public static final YangInstanceIdentifier OUTER_LIST_PATH = - YangInstanceIdentifier.builder(TEST_PATH).node(OUTER_LIST_QNAME).build(); - private static final String DATASTORE_TEST_YANG = "/odl-datastore-test.yang"; - - public static SchemaContext createTestContext() { - return YangParserTestUtils.parseYangResource(DATASTORE_TEST_YANG); - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/test/resources/odl-datastore-test.yang b/opendaylight/md-sal/sal-dom-broker/src/test/resources/odl-datastore-test.yang deleted file mode 100644 index f7b960e9f9..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/test/resources/odl-datastore-test.yang +++ /dev/null @@ -1,70 +0,0 @@ -module odl-datastore-test { - yang-version 1; - namespace "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test"; - prefix "store-test"; - - revision "2014-03-13" { - description "Initial revision."; - } - - container test { - presence "needs to be present when empty"; - - list outer-list { - key id; - leaf id { - type uint16; - } - choice outer-choice { - case one { - leaf one { - type string; - } - } - case two-three { - leaf two { - type string; - } - leaf three { - type string; - } - } - } - list inner-list { - key name; - leaf name { - type string; - } - leaf value { - type string; - } - } - } - } - - container test2 { - } - - rpc test-rpc { - input { - leaf input-leaf { - type string; - } - } - - output { - leaf output-leaf { - type string; - } - } - } - - rpc test-rpc-no-input { - } - - notification test-notification { - leaf value-leaf { - type string; - } - } -} diff --git a/opendaylight/md-sal/sal-dom-compat/pom.xml b/opendaylight/md-sal/sal-dom-compat/pom.xml deleted file mode 100644 index 12d3f16190..0000000000 --- a/opendaylight/md-sal/sal-dom-compat/pom.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - 4.0.0 - - org.opendaylight.controller - mdsal-parent - 1.12.0-SNAPSHOT - ../parent - - - org.opendaylight.controller - sal-core-compat - 1.12.0-SNAPSHOT - bundle - - - - org.opendaylight.controller - sal-core-spi - - - org.opendaylight.mdsal - mdsal-dom-spi - - - org.mockito - mockito-core - test - - - org.opendaylight.mdsal - mdsal-dom-broker - test - - - - - scm:git:http://git.opendaylight.org/gerrit/controller.git - scm:git:ssh://git.opendaylight.org:29418/controller.git - HEAD - https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL - - - diff --git a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/AbstractDOMRpcResultFutureAdapter.java b/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/AbstractDOMRpcResultFutureAdapter.java deleted file mode 100644 index ca138d9a21..0000000000 --- a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/AbstractDOMRpcResultFutureAdapter.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (c) 2018 Inocybe Technologies and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.core.compat; - -import com.google.common.util.concurrent.AbstractFuture; -import com.google.common.util.concurrent.ListenableFuture; -import java.util.Optional; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.Executor; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; -import org.opendaylight.mdsal.dom.api.DOMRpcException; -import org.opendaylight.mdsal.dom.api.DOMRpcResult; -import org.opendaylight.yangtools.util.concurrent.ExceptionMapper; - -/** - * Base for a DOMRpcResult future adapter. - * - * @author Thomas Pantelis - */ -@Deprecated(forRemoval = true) -@SuppressWarnings("checkstyle:ClassTypeParameterName") -public abstract class AbstractDOMRpcResultFutureAdapter, E extends DOMRpcException> extends AbstractFuture { - private final D delegate; - private final ExceptionMapper exMapper; - private volatile Optional result; - - AbstractDOMRpcResultFutureAdapter(D delegate, ExceptionMapper exMapper) { - this.delegate = delegate; - this.exMapper = exMapper; - } - - protected abstract T transform(F fromResult); - - public D delegate() { - return delegate; - } - - @Override - public void addListener(Runnable listener, Executor executor) { - delegate.addListener(listener, executor); - } - - @Override - public boolean cancel(boolean mayInterruptIfRunning) { - return delegate.cancel(mayInterruptIfRunning); - } - - @Override - public boolean isCancelled() { - return delegate.isCancelled(); - } - - @Override - public boolean isDone() { - return delegate.isDone(); - } - - @Override - public T get() throws InterruptedException, ExecutionException { - if (result != null) { - return result.orElse(null); - } - - try { - return transformIfNecessary(delegate.get()); - } catch (ExecutionException e) { - throw new ExecutionException(e.getMessage(), exMapper.apply(e)); - } - } - - @Override - public T get(final long timeout, final TimeUnit unit) throws InterruptedException, ExecutionException, - TimeoutException { - if (result != null) { - return result.orElse(null); - } - - try { - return transformIfNecessary(delegate.get(timeout, unit)); - } catch (ExecutionException e) { - throw new ExecutionException(e.getMessage(), exMapper.apply(e)); - } - } - - private synchronized T transformIfNecessary(F delegateResult) { - if (result == null) { - if (delegateResult == null) { - result = Optional.empty(); - } else { - result = Optional.of(transform(delegateResult)); - } - } - - return result.orElse(null); - } -} diff --git a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/AbstractLegacyDOMDataBrokerAdapter.java b/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/AbstractLegacyDOMDataBrokerAdapter.java deleted file mode 100644 index 7a2dd6406b..0000000000 --- a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/AbstractLegacyDOMDataBrokerAdapter.java +++ /dev/null @@ -1,376 +0,0 @@ -/* - * Copyright (c) 2017 Inocybe Technologies and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.core.compat; - -import static java.util.Objects.requireNonNull; - -import com.google.common.base.Optional; -import com.google.common.collect.ClassToInstanceMap; -import com.google.common.collect.ForwardingObject; -import com.google.common.collect.ImmutableClassToInstanceMap; -import com.google.common.collect.ImmutableClassToInstanceMap.Builder; -import com.google.common.util.concurrent.CheckedFuture; -import com.google.common.util.concurrent.FluentFuture; -import com.google.common.util.concurrent.FutureCallback; -import com.google.common.util.concurrent.MoreExecutors; -import com.google.common.util.concurrent.SettableFuture; -import java.util.Collection; -import java.util.Map; -import java.util.concurrent.atomic.AtomicReference; -import java.util.function.Supplier; -import org.eclipse.jdt.annotation.NonNull; -import org.opendaylight.controller.md.sal.common.api.MappingCheckedFuture; -import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction; -import org.opendaylight.controller.md.sal.common.api.data.DataStoreUnavailableException; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.OptimisticLockFailedException; -import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; -import org.opendaylight.controller.md.sal.common.api.data.TransactionChainClosedException; -import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener; -import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; -import org.opendaylight.controller.md.sal.dom.api.ClusteredDOMDataTreeChangeListener; -import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; -import org.opendaylight.controller.md.sal.dom.api.DOMDataBrokerExtension; -import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction; -import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction; -import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener; -import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeService; -import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeCommitCohortRegistry; -import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeIdentifier; -import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction; -import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain; -import org.opendaylight.mdsal.common.api.CommitInfo; -import org.opendaylight.mdsal.dom.api.DOMDataTreeReadOperations; -import org.opendaylight.mdsal.dom.api.DOMDataTreeReadTransaction; -import org.opendaylight.mdsal.dom.api.DOMDataTreeReadWriteTransaction; -import org.opendaylight.mdsal.dom.api.DOMDataTreeTransaction; -import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction; -import org.opendaylight.mdsal.dom.api.DOMTransactionChainClosedException; -import org.opendaylight.mdsal.dom.api.DOMTransactionChainListener; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.util.concurrent.ExceptionMapper; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate; - -/** - * Adapter between the legacy controller API-based DOMDataBroker and the mdsal API-based DOMDataBroker. - * - * @author Thomas Pantelis - */ -@Deprecated(forRemoval = true) -public abstract class AbstractLegacyDOMDataBrokerAdapter extends ForwardingObject implements DOMDataBroker { - private static final ExceptionMapper COMMIT_EX_MAPPER = - new ExceptionMapper("commit", TransactionCommitFailedException.class) { - @Override - protected TransactionCommitFailedException newWithCause(final String message, final Throwable cause) { - if (cause instanceof org.opendaylight.mdsal.common.api.OptimisticLockFailedException) { - return new OptimisticLockFailedException(cause.getMessage(), cause.getCause()); - } else if (cause instanceof org.opendaylight.mdsal.common.api.TransactionCommitFailedException) { - Throwable rootCause = cause.getCause(); - if (rootCause instanceof org.opendaylight.mdsal.common.api.DataStoreUnavailableException) { - rootCause = new DataStoreUnavailableException(rootCause.getMessage(), rootCause.getCause()); - } - - return new TransactionCommitFailedException(cause.getMessage(), rootCause); - } - - return new TransactionCommitFailedException(message, cause); - } - }; - - private final org.opendaylight.mdsal.dom.api.DOMDataBroker delegate; - private final ClassToInstanceMap extensions; - - public AbstractLegacyDOMDataBrokerAdapter(final org.opendaylight.mdsal.dom.api.DOMDataBroker delegate) { - this.delegate = delegate; - - ClassToInstanceMap delegateExtensions = - delegate.getExtensions(); - - Builder extBuilder = ImmutableClassToInstanceMap.builder(); - final org.opendaylight.mdsal.dom.api.DOMDataTreeChangeService delegateTreeChangeService = - (org.opendaylight.mdsal.dom.api.DOMDataTreeChangeService) delegateExtensions.get( - org.opendaylight.mdsal.dom.api.DOMDataTreeChangeService.class); - if (delegateTreeChangeService != null) { - extBuilder.put(DOMDataTreeChangeService.class, new DOMDataTreeChangeService() { - @Override - public ListenerRegistration registerDataTreeChangeListener( - final DOMDataTreeIdentifier treeId, final L listener) { - final org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener delegateListener; - if (listener instanceof ClusteredDOMDataTreeChangeListener) { - delegateListener = new ClusteredProxyListener(listener); - } else { - delegateListener = new ProxyListener(listener); - } - - final ListenerRegistration reg = - delegateTreeChangeService.registerDataTreeChangeListener(treeId.toMdsal(), delegateListener); - - return new ListenerRegistration() { - @Override - public L getInstance() { - return listener; - } - - @Override - public void close() { - reg.close(); - } - }; - } - }); - } - - final org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohortRegistry delegateCohortRegistry = - (org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohortRegistry) delegateExtensions.get( - org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohortRegistry.class); - if (delegateCohortRegistry != null) { - extBuilder.put(DOMDataTreeCommitCohortRegistry.class, delegateCohortRegistry::registerCommitCohort); - } - - extensions = extBuilder.build(); - } - - @Override - protected org.opendaylight.mdsal.dom.api.DOMDataBroker delegate() { - return delegate; - } - - @Override - public Map, DOMDataBrokerExtension> getSupportedExtensions() { - return extensions; - } - - @Override - public DOMDataReadOnlyTransaction newReadOnlyTransaction() { - return new DOMDataReadOnlyTransactionAdapter(delegate().newReadOnlyTransaction()); - } - - @Override - public DOMDataReadWriteTransaction newReadWriteTransaction() { - return new DOMDataTransactionAdapter(delegate().newReadWriteTransaction()); - } - - @Override - public DOMDataWriteTransaction newWriteOnlyTransaction() { - return new DOMDataTransactionAdapter(delegate().newWriteOnlyTransaction()); - } - - @Override - public DOMTransactionChain createTransactionChain(final TransactionChainListener listener) { - AtomicReference legacyChain = new AtomicReference<>(); - DOMTransactionChainListener delegateListener = - new DOMTransactionChainListener() { - @Override - @SuppressWarnings("rawtypes") - public void onTransactionChainFailed(final org.opendaylight.mdsal.dom.api.DOMTransactionChain chain, - final DOMDataTreeTransaction transaction, final Throwable cause) { - listener.onTransactionChainFailed(legacyChain.get(), - (AsyncTransaction) () -> transaction.getIdentifier(), - cause instanceof Exception ? COMMIT_EX_MAPPER.apply((Exception)cause) : cause); - } - - @Override - public void onTransactionChainSuccessful(final org.opendaylight.mdsal.dom.api.DOMTransactionChain chain) { - listener.onTransactionChainSuccessful(legacyChain.get()); - } - }; - - final org.opendaylight.mdsal.dom.api.DOMTransactionChain delegateChain = - delegate().createTransactionChain(delegateListener); - legacyChain.set(new DOMTransactionChain() { - @Override - public DOMDataReadOnlyTransaction newReadOnlyTransaction() { - return new DOMDataReadOnlyTransactionAdapter(wrapException(delegateChain::newReadOnlyTransaction)); - } - - @Override - public DOMDataReadWriteTransaction newReadWriteTransaction() { - return new DOMDataTransactionAdapter(wrapException(delegateChain::newReadWriteTransaction)); - } - - @Override - public DOMDataWriteTransaction newWriteOnlyTransaction() { - return new DOMDataTransactionAdapter(wrapException(delegateChain::newWriteOnlyTransaction)); - } - - @Override - public void close() { - delegateChain.close(); - } - }); - - return legacyChain.get(); - } - - abstract org.opendaylight.mdsal.dom.api.DOMTransactionChain createDelegateChain( - DOMTransactionChainListener listener); - - static T wrapException(final Supplier supplier) { - try { - return supplier.get(); - } catch (DOMTransactionChainClosedException e) { - throw new TransactionChainClosedException("Transaction chain already closed", e); - } - } - - private static class DOMDataTransactionAdapter implements DOMDataReadWriteTransaction { - private final DOMDataTreeReadOperations readDelegate; - private final DOMDataTreeWriteTransaction writeDelegate; - private final Object identifier; - - DOMDataTransactionAdapter(final @NonNull DOMDataTreeReadOperations readDelegate, final Object identifier) { - this.readDelegate = requireNonNull(readDelegate); - this.identifier = requireNonNull(identifier); - this.writeDelegate = null; - } - - DOMDataTransactionAdapter(final @NonNull DOMDataTreeWriteTransaction writeDelegate) { - this.writeDelegate = requireNonNull(writeDelegate); - this.identifier = writeDelegate.getIdentifier(); - this.readDelegate = null; - } - - DOMDataTransactionAdapter(final @NonNull DOMDataTreeReadWriteTransaction rwDelegate) { - this.readDelegate = requireNonNull(rwDelegate); - this.writeDelegate = rwDelegate; - this.identifier = rwDelegate.getIdentifier(); - } - - DOMDataTreeReadOperations readDelegate() { - return readDelegate; - } - - DOMDataTreeWriteTransaction writeDelegate() { - return writeDelegate; - } - - @Override - public Object getIdentifier() { - return identifier; - } - - @Override - public CheckedFuture>, ReadFailedException> read(final LogicalDatastoreType store, - final YangInstanceIdentifier path) { - return MappingCheckedFuture.create(readDelegate().read(store.toMdsal(), path).transform( - Optional::fromJavaUtil, MoreExecutors.directExecutor()), ReadFailedExceptionAdapter.INSTANCE); - } - - @Override - public CheckedFuture exists(final LogicalDatastoreType store, - final YangInstanceIdentifier path) { - return MappingCheckedFuture.create(readDelegate().exists(store.toMdsal(), path), - ReadFailedExceptionAdapter.INSTANCE); - } - - @Override - public void delete(final LogicalDatastoreType store, final YangInstanceIdentifier path) { - writeDelegate().delete(store.toMdsal(), path); - } - - @Override - public void put(final LogicalDatastoreType store, final YangInstanceIdentifier path, - final NormalizedNode data) { - writeDelegate().put(store.toMdsal(), path, data); - } - - @Override - public void merge(final LogicalDatastoreType store, final YangInstanceIdentifier path, - final NormalizedNode data) { - writeDelegate().merge(store.toMdsal(), path, data); - } - - @Override - public boolean cancel() { - return writeDelegate().cancel(); - } - - @Override - public FluentFuture commit() { - final SettableFuture resultFuture = SettableFuture.create(); - writeDelegate().commit().addCallback(new FutureCallback() { - @Override - public void onSuccess(final CommitInfo result) { - resultFuture.set(result); - } - - @Override - public void onFailure(final Throwable ex) { - if (ex instanceof Exception) { - resultFuture.setException(COMMIT_EX_MAPPER.apply((Exception)ex)); - } else { - resultFuture.setException(ex); - } - } - }, MoreExecutors.directExecutor()); - - return FluentFuture.from(resultFuture); - } - } - - private static class DOMDataReadOnlyTransactionAdapter implements DOMDataReadOnlyTransaction { - private final DOMDataTreeReadTransaction transaction; - private final DOMDataTransactionAdapter adapter; - - DOMDataReadOnlyTransactionAdapter(final DOMDataTreeReadTransaction delegateTx) { - this.transaction = requireNonNull(delegateTx); - adapter = new DOMDataTransactionAdapter(delegateTx, transaction.getIdentifier()); - } - - @Override - public CheckedFuture>, ReadFailedException> read(final LogicalDatastoreType store, - final YangInstanceIdentifier path) { - return adapter.read(store, path); - } - - @Override - public CheckedFuture exists(final LogicalDatastoreType store, - final YangInstanceIdentifier path) { - return adapter.exists(store, path); - } - - @Override - public Object getIdentifier() { - return adapter.getIdentifier(); - } - - @Override - public void close() { - transaction.close(); - } - } - - private static class ProxyListener extends ForwardingObject - implements org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener { - private final DOMDataTreeChangeListener delegate; - - ProxyListener(final DOMDataTreeChangeListener delegate) { - this.delegate = requireNonNull(delegate); - } - - @Override - public void onDataTreeChanged(Collection changes) { - delegate.onDataTreeChanged(changes); - } - - @Override - protected DOMDataTreeChangeListener delegate() { - return delegate; - } - } - - private static final class ClusteredProxyListener extends ProxyListener - implements org.opendaylight.mdsal.dom.api.ClusteredDOMDataTreeChangeListener { - - ClusteredProxyListener(DOMDataTreeChangeListener delegate) { - super(delegate); - } - } -} diff --git a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMDataBrokerAdapter.java b/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMDataBrokerAdapter.java deleted file mode 100644 index fd833077e9..0000000000 --- a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMDataBrokerAdapter.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.core.compat; - -import static java.util.Objects.requireNonNull; - -import com.google.common.collect.ClassToInstanceMap; -import com.google.common.collect.ForwardingObject; -import com.google.common.collect.ImmutableClassToInstanceMap; -import com.google.common.collect.ImmutableClassToInstanceMap.Builder; -import java.util.Map; -import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; -import org.opendaylight.controller.md.sal.dom.api.DOMDataBrokerExtension; -import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeService; -import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeCommitCohortRegistry; -import org.opendaylight.mdsal.dom.api.DOMDataTreeReadTransaction; -import org.opendaylight.mdsal.dom.api.DOMDataTreeReadWriteTransaction; -import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction; -import org.opendaylight.mdsal.dom.api.DOMTransactionChain; -import org.opendaylight.mdsal.dom.api.DOMTransactionChainListener; -import org.opendaylight.mdsal.dom.spi.PingPongMergingDOMDataBroker; - -@Deprecated(forRemoval = true) -public class DOMDataBrokerAdapter extends ForwardingObject implements PingPongMergingDOMDataBroker { - private final ClassToInstanceMap extensions; - private final DOMDataBroker delegate; - - public DOMDataBrokerAdapter(final DOMDataBroker delegate) { - this.delegate = requireNonNull(delegate); - - Map, DOMDataBrokerExtension> delegateExtensions = - delegate.getSupportedExtensions(); - Builder extBuilder = - ImmutableClassToInstanceMap.builder(); - - final DOMDataTreeChangeService delegateTreeChangeService = (DOMDataTreeChangeService) delegateExtensions.get( - DOMDataTreeChangeService.class); - if (delegateTreeChangeService != null) { - extBuilder.put(org.opendaylight.mdsal.dom.api.DOMDataTreeChangeService.class, - new DOMDataTreeChangeServiceAdapter(delegateTreeChangeService)); - } - - final DOMDataTreeCommitCohortRegistry delegateCohortRegistry = - (DOMDataTreeCommitCohortRegistry) delegateExtensions.get(DOMDataTreeCommitCohortRegistry.class); - if (delegateCohortRegistry != null) { - extBuilder.put(DOMDataTreeCommitCohortRegistry.class, delegateCohortRegistry::registerCommitCohort); - } - - extensions = extBuilder.build(); - } - - @Override - public DOMDataTreeReadTransaction newReadOnlyTransaction() { - return new DOMDataTreeReadTransactionAdapter(delegate.newReadOnlyTransaction()); - } - - @Override - public DOMDataTreeWriteTransaction newWriteOnlyTransaction() { - return new DOMDataTreeWriteTransactionAdapter(delegate.newWriteOnlyTransaction()); - } - - @Override - public DOMDataTreeReadWriteTransaction newReadWriteTransaction() { - return new DOMDataTreeReadWriteTransactionAdapter(delegate.newReadWriteTransaction()); - } - - @Override - public ClassToInstanceMap getExtensions() { - return extensions; - } - - @Override - public DOMTransactionChain createTransactionChain(final DOMTransactionChainListener listener) { - return new DOMTransactionChainAdapter(listener, delegate::createTransactionChain); - } - - @Override - protected DOMDataBroker delegate() { - return delegate; - } -} diff --git a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMDataTreeChangeServiceAdapter.java b/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMDataTreeChangeServiceAdapter.java deleted file mode 100644 index 05effbf8df..0000000000 --- a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMDataTreeChangeServiceAdapter.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.core.compat; - -import static java.util.Objects.requireNonNull; - -import com.google.common.collect.ForwardingObject; -import org.opendaylight.controller.md.sal.dom.api.ClusteredDOMDataTreeChangeListener; -import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener; -import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeService; -import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeIdentifier; -import org.opendaylight.yangtools.concepts.AbstractListenerRegistration; -import org.opendaylight.yangtools.concepts.ListenerRegistration; - -@Deprecated(forRemoval = true) -public class DOMDataTreeChangeServiceAdapter extends ForwardingObject - implements org.opendaylight.mdsal.dom.api.DOMDataTreeChangeService { - - private final DOMDataTreeChangeService delegate; - - DOMDataTreeChangeServiceAdapter(final DOMDataTreeChangeService delegate) { - this.delegate = requireNonNull(delegate); - } - - @Override - public ListenerRegistration - registerDataTreeChangeListener(final org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier treeId, - final L listener) { - final DOMDataTreeChangeListener delegateListener; - if (listener instanceof org.opendaylight.mdsal.dom.api.ClusteredDOMDataTreeChangeListener) { - delegateListener = (ClusteredDOMDataTreeChangeListener) listener::onDataTreeChanged; - } else { - delegateListener = listener::onDataTreeChanged; - } - final ListenerRegistration reg = delegate().registerDataTreeChangeListener( - DOMDataTreeIdentifier.fromMdsal(treeId), delegateListener); - - return new AbstractListenerRegistration(listener) { - @Override - protected void removeRegistration() { - reg.close(); - } - }; - } - - @Override - protected DOMDataTreeChangeService delegate() { - return delegate; - } -} diff --git a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMDataTreeReadTransactionAdapter.java b/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMDataTreeReadTransactionAdapter.java deleted file mode 100644 index 069e626dd4..0000000000 --- a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMDataTreeReadTransactionAdapter.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.core.compat; - -import static java.util.Objects.requireNonNull; - -import com.google.common.collect.ForwardingObject; -import com.google.common.util.concurrent.FluentFuture; -import java.util.Optional; -import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction; -import org.opendaylight.mdsal.common.api.LogicalDatastoreType; -import org.opendaylight.mdsal.dom.api.DOMDataTreeReadTransaction; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; - -@Deprecated(forRemoval = true) -public class DOMDataTreeReadTransactionAdapter extends ForwardingObject implements DOMDataTreeReadTransaction { - private final DOMDataReadOnlyTransaction delegate; - - public DOMDataTreeReadTransactionAdapter(final DOMDataReadOnlyTransaction delegate) { - this.delegate = requireNonNull(delegate); - } - - @Override - public Object getIdentifier() { - return delegate().getIdentifier(); - } - - @Override - public FluentFuture>> read(final LogicalDatastoreType store, - final YangInstanceIdentifier path) { - return TransactionUtils.read(delegate(), store, path); - } - - @Override - public FluentFuture exists(final LogicalDatastoreType store, final YangInstanceIdentifier path) { - return TransactionUtils.exists(delegate(), store, path); - } - - @Override - public void close() { - delegate().close(); - } - - @Override - protected DOMDataReadOnlyTransaction delegate() { - return delegate; - } -} diff --git a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMDataTreeReadWriteTransactionAdapter.java b/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMDataTreeReadWriteTransactionAdapter.java deleted file mode 100644 index 77225372ca..0000000000 --- a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMDataTreeReadWriteTransactionAdapter.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.core.compat; - -import static java.util.Objects.requireNonNull; - -import com.google.common.collect.ForwardingObject; -import com.google.common.util.concurrent.FluentFuture; -import java.util.Optional; -import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction; -import org.opendaylight.mdsal.common.api.CommitInfo; -import org.opendaylight.mdsal.common.api.LogicalDatastoreType; -import org.opendaylight.mdsal.dom.api.DOMDataTreeReadWriteTransaction; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; - -@Deprecated(forRemoval = true) -public class DOMDataTreeReadWriteTransactionAdapter extends ForwardingObject - implements DOMDataTreeReadWriteTransaction { - private final DOMDataReadWriteTransaction delegate; - - public DOMDataTreeReadWriteTransactionAdapter(final DOMDataReadWriteTransaction delegate) { - this.delegate = requireNonNull(delegate); - } - - @Override - public Object getIdentifier() { - return delegate().getIdentifier(); - } - - @Override - public FluentFuture>> read(final LogicalDatastoreType store, - final YangInstanceIdentifier path) { - return TransactionUtils.read(delegate(), store, path); - } - - @Override - public FluentFuture exists(final LogicalDatastoreType store, final YangInstanceIdentifier path) { - return TransactionUtils.exists(delegate(), store, path); - } - - @Override - public void put(final LogicalDatastoreType store, final YangInstanceIdentifier path, - final NormalizedNode data) { - TransactionUtils.put(delegate(), store, path, data); - } - - @Override - public void merge(final LogicalDatastoreType store, final YangInstanceIdentifier path, - final NormalizedNode data) { - TransactionUtils.merge(delegate(), store, path, data); - } - - @Override - public void delete(final LogicalDatastoreType store, final YangInstanceIdentifier path) { - TransactionUtils.delete(delegate(), store, path); - } - - @Override - public FluentFuture commit() { - return delegate().commit(); - } - - @Override - public boolean cancel() { - return delegate().cancel(); - } - - @Override - protected DOMDataReadWriteTransaction delegate() { - return delegate; - } -} diff --git a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMDataTreeWriteTransactionAdapter.java b/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMDataTreeWriteTransactionAdapter.java deleted file mode 100644 index 1f6b7cd613..0000000000 --- a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMDataTreeWriteTransactionAdapter.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.core.compat; - -import static java.util.Objects.requireNonNull; - -import com.google.common.collect.ForwardingObject; -import com.google.common.util.concurrent.FluentFuture; -import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction; -import org.opendaylight.mdsal.common.api.CommitInfo; -import org.opendaylight.mdsal.common.api.LogicalDatastoreType; -import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; - -@Deprecated(forRemoval = true) -public class DOMDataTreeWriteTransactionAdapter extends ForwardingObject - implements DOMDataTreeWriteTransaction { - private final DOMDataWriteTransaction delegate; - - public DOMDataTreeWriteTransactionAdapter(final DOMDataWriteTransaction delegate) { - this.delegate = requireNonNull(delegate); - } - - @Override - public Object getIdentifier() { - return delegate().getIdentifier(); - } - - @Override - public void put(final LogicalDatastoreType store, final YangInstanceIdentifier path, - final NormalizedNode data) { - TransactionUtils.put(delegate(), store, path, data); - } - - @Override - public void merge(final LogicalDatastoreType store, final YangInstanceIdentifier path, - final NormalizedNode data) { - TransactionUtils.merge(delegate(), store, path, data); - } - - @Override - public void delete(final LogicalDatastoreType store, final YangInstanceIdentifier path) { - TransactionUtils.delete(delegate(), store, path); - } - - @Override - public FluentFuture commit() { - return delegate().commit(); - } - - @Override - public boolean cancel() { - return delegate().cancel(); - } - - @Override - protected DOMDataWriteTransaction delegate() { - return delegate; - } -} diff --git a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMMountPointAdapter.java b/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMMountPointAdapter.java deleted file mode 100644 index decf604c0a..0000000000 --- a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMMountPointAdapter.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.core.compat; - -import static java.util.Objects.requireNonNull; - -import com.google.common.base.Optional; -import com.google.common.collect.ForwardingObject; -import com.google.common.collect.ImmutableMap; -import java.util.Map; -import org.eclipse.jdt.annotation.Nullable; -import org.gaul.modernizer_maven_annotations.SuppressModernizer; -import org.opendaylight.controller.md.sal.dom.api.DOMActionService; -import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; -import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint; -import org.opendaylight.controller.md.sal.dom.api.DOMNotificationService; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcService; -import org.opendaylight.controller.md.sal.dom.api.DOMService; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -/** - * Adapter providing Controller DOMMountPoint implementation based on an MD-SAL DOMMountPoint delegate. Services are - * looked up in the delegate first. If a lookup is unsuccessful, this class attempts to transparently proxy well-known - * Controller DOMServices on top of their MD-SAL counterparts available from delegate. - */ -@Deprecated(forRemoval = true) -public class DOMMountPointAdapter extends ForwardingObject implements DOMMountPoint { - private abstract static class CompatFactory { - private final Class mdsalClass; - - CompatFactory(final Class mdsalClass) { - this.mdsalClass = requireNonNull(mdsalClass); - } - - final @Nullable C createService(final org.opendaylight.mdsal.dom.api.DOMMountPoint mountPoint) { - return mountPoint.getService(mdsalClass).map(this::createService).orElse(null); - } - - abstract C createService(M delegate); - } - - private static final Map, CompatFactory> KNOWN_SERVICES = ImmutableMap.of( - DOMActionService.class, new CompatFactory( - org.opendaylight.mdsal.dom.api.DOMActionService.class) { - @Override - DOMActionService createService(final org.opendaylight.mdsal.dom.api.DOMActionService delegate) { - return new LegacyDOMActionServiceAdapter(delegate); - } - }, - DOMDataBroker.class, new CompatFactory( - org.opendaylight.mdsal.dom.api.DOMDataBroker.class) { - @Override - DOMDataBroker createService(final org.opendaylight.mdsal.dom.api.DOMDataBroker delegate) { - return new LegacyDOMDataBrokerAdapter(delegate); - } - }, - DOMNotificationService.class, new CompatFactory(org.opendaylight.mdsal.dom.api.DOMNotificationService.class) { - @Override - DOMNotificationService createService(final org.opendaylight.mdsal.dom.api.DOMNotificationService delegate) { - return new LegacyDOMNotificationServiceAdapter(delegate); - } - }, - DOMRpcService.class, new CompatFactory( - org.opendaylight.mdsal.dom.api.DOMRpcService.class) { - @Override - DOMRpcService createService(final org.opendaylight.mdsal.dom.api.DOMRpcService delegate) { - return new LegacyDOMRpcServiceAdapter(delegate); - } - }); - - private final org.opendaylight.mdsal.dom.api.DOMMountPoint delegate; - - public DOMMountPointAdapter(final org.opendaylight.mdsal.dom.api.DOMMountPoint delegate) { - this.delegate = requireNonNull(delegate); - } - - @Override - public YangInstanceIdentifier getIdentifier() { - return delegate().getIdentifier(); - } - - @Override - @SuppressModernizer - public Optional getService(final Class cls) { - final java.util.Optional found = delegate.getService(cls); - if (found.isPresent()) { - return Optional.of(found.get()); - } - - final CompatFactory compat = KNOWN_SERVICES.get(cls); - return Optional.fromNullable(cls.cast(compat == null ? null : compat.createService(delegate))); - } - - @Override - public SchemaContext getSchemaContext() { - return delegate().getSchemaContext(); - } - - @Override - public int hashCode() { - return getIdentifier().hashCode(); - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) { - return true; - } - - if (!(obj instanceof DOMMountPoint)) { - return false; - } - - DOMMountPoint other = (DOMMountPoint) obj; - return getIdentifier().equals(other.getIdentifier()); - } - - @Override - protected org.opendaylight.mdsal.dom.api.DOMMountPoint delegate() { - return delegate; - } -} diff --git a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMNotificationServiceAdapter.java b/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMNotificationServiceAdapter.java deleted file mode 100644 index 8b9ae39203..0000000000 --- a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMNotificationServiceAdapter.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.core.compat; - -import static java.util.Objects.requireNonNull; - -import com.google.common.collect.ForwardingObject; -import java.util.Arrays; -import java.util.Collection; -import org.opendaylight.controller.md.sal.dom.api.DOMNotificationService; -import org.opendaylight.mdsal.dom.api.DOMNotificationListener; -import org.opendaylight.yangtools.concepts.AbstractListenerRegistration; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; - -@Deprecated(forRemoval = true) -public class DOMNotificationServiceAdapter extends ForwardingObject - implements org.opendaylight.mdsal.dom.api.DOMNotificationService { - - private final DOMNotificationService delegate; - - public DOMNotificationServiceAdapter(final DOMNotificationService delegate) { - this.delegate = requireNonNull(delegate); - } - - @Override - public ListenerRegistration registerNotificationListener(final T listener, - final Collection types) { - // Controller events are sub-interfaces of MD-SAL events, hence direct routing is okay - final ListenerRegistration reg = delegate().registerNotificationListener(listener::onNotification, types); - - return new AbstractListenerRegistration(listener) { - @Override - protected void removeRegistration() { - reg.close(); - - } - }; - } - - @Override - public ListenerRegistration registerNotificationListener(final T listener, - final SchemaPath... types) { - return registerNotificationListener(listener, Arrays.asList(types)); - } - - @Override - protected DOMNotificationService delegate() { - return delegate; - } -} diff --git a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMRpcServiceAdapter.java b/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMRpcServiceAdapter.java deleted file mode 100644 index 745a2e0254..0000000000 --- a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMRpcServiceAdapter.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.core.compat; - -import static java.util.Objects.requireNonNull; - -import com.google.common.collect.ForwardingObject; -import com.google.common.util.concurrent.ListenableFuture; -import java.util.Collection; -import java.util.Set; -import java.util.stream.Collectors; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcAvailabilityListener; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcService; -import org.opendaylight.mdsal.dom.api.DOMRpcResult; -import org.opendaylight.yangtools.concepts.AbstractListenerRegistration; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; - -@Deprecated(forRemoval = true) -public class DOMRpcServiceAdapter extends ForwardingObject implements org.opendaylight.mdsal.dom.api.DOMRpcService { - private final DOMRpcService delegate; - - public DOMRpcServiceAdapter(final DOMRpcService delegate) { - this.delegate = requireNonNull(delegate); - } - - @Override - public ListenableFuture invokeRpc(final SchemaPath type, final NormalizedNode input) { - return new MdsalDOMRpcResultFutureAdapter(delegate().invokeRpc(type, input)); - } - - @Override - public ListenerRegistration - registerRpcListener(final T listener) { - final ListenerRegistration reg = delegate().registerRpcListener(new DOMRpcAvailabilityListener() { - @Override - public void onRpcAvailable(final Collection rpcs) { - listener.onRpcAvailable(convert(rpcs)); - } - - @Override - public void onRpcUnavailable(final Collection rpcs) { - listener.onRpcUnavailable(convert(rpcs)); - } - }); - - return new AbstractListenerRegistration(listener) { - @Override - protected void removeRegistration() { - reg.close(); - } - }; - } - - @Override - protected DOMRpcService delegate() { - return delegate; - } - - public static Set convert( - final Collection rpcs) { - return rpcs.stream().map(DOMRpcIdentifier::toMdsal).collect(Collectors.toSet()); - } -} diff --git a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMStoreAdapter.java b/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMStoreAdapter.java deleted file mode 100644 index 49154777a1..0000000000 --- a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMStoreAdapter.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.core.compat; - -import com.google.common.collect.ForwardingObject; -import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener; -import org.opendaylight.controller.sal.core.spi.data.DOMStore; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreTreeChangePublisher; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction; -import org.opendaylight.yangtools.concepts.AbstractListenerRegistration; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; - -@Deprecated(forRemoval = true) -public abstract class DOMStoreAdapter extends ForwardingObject - implements DOMStore, DOMStoreTreeChangePublisher { - @Override - protected abstract T delegate(); - - @Override - public DOMStoreReadTransaction newReadOnlyTransaction() { - return new DOMStoreReadTransactionAdapter<>(delegate().newReadOnlyTransaction()); - } - - @Override - public DOMStoreReadWriteTransaction newReadWriteTransaction() { - return new DOMStoreReadWriteTransactionAdapter(delegate().newReadWriteTransaction()); - } - - @Override - public DOMStoreWriteTransaction newWriteOnlyTransaction() { - return new DOMStoreWriteTransactionAdapter(delegate().newWriteOnlyTransaction()); - } - - @Override - public DOMStoreTransactionChain createTransactionChain() { - return new DOMStoreTransactionChainAdapter(delegate().createTransactionChain()); - } - - @Override - public ListenerRegistration registerTreeChangeListener( - final YangInstanceIdentifier treeId, final L listener) { - final ListenerRegistration reg = delegate().registerTreeChangeListener(treeId, listener::onDataTreeChanged); - return new AbstractListenerRegistration(listener) { - @Override - protected void removeRegistration() { - reg.close(); - } - }; - } -} diff --git a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMStoreReadTransactionAdapter.java b/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMStoreReadTransactionAdapter.java deleted file mode 100644 index c05d722022..0000000000 --- a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMStoreReadTransactionAdapter.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.core.compat; - -import static java.util.Objects.requireNonNull; - -import com.google.common.base.Optional; -import com.google.common.collect.ForwardingObject; -import com.google.common.util.concurrent.CheckedFuture; -import com.google.common.util.concurrent.MoreExecutors; -import org.opendaylight.controller.md.sal.common.api.MappingCheckedFuture; -import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; - -@Deprecated(forRemoval = true) -public class DOMStoreReadTransactionAdapter - extends ForwardingObject implements DOMStoreReadTransaction { - private final T delegate; - - public DOMStoreReadTransactionAdapter(final T delegate) { - this.delegate = requireNonNull(delegate); - } - - @Override - protected T delegate() { - return delegate; - } - - @Override - public Object getIdentifier() { - return delegate.getIdentifier(); - } - - @Override - public void close() { - delegate.close(); - } - - @Override - public CheckedFuture>, ReadFailedException> read( - final YangInstanceIdentifier path) { - return MappingCheckedFuture.create(delegate.read(path).transform( - Optional::fromJavaUtil, MoreExecutors.directExecutor()), ReadFailedExceptionAdapter.INSTANCE); - } - - @Override - public CheckedFuture exists(final YangInstanceIdentifier path) { - return MappingCheckedFuture.create(delegate.exists(path), ReadFailedExceptionAdapter.INSTANCE); - } -} diff --git a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMStoreReadWriteTransactionAdapter.java b/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMStoreReadWriteTransactionAdapter.java deleted file mode 100644 index c32ed1238a..0000000000 --- a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMStoreReadWriteTransactionAdapter.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.core.compat; - -import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; - -@Deprecated(forRemoval = true) -public class DOMStoreReadWriteTransactionAdapter - extends DOMStoreReadTransactionAdapter - implements DOMStoreReadWriteTransaction { - public DOMStoreReadWriteTransactionAdapter( - final org.opendaylight.mdsal.dom.spi.store.DOMStoreReadWriteTransaction delegate) { - super(delegate); - } - - @Override - public void write(final YangInstanceIdentifier path, final NormalizedNode data) { - delegate().write(path, data); - } - - @Override - public DOMStoreThreePhaseCommitCohort ready() { - return new DOMStoreThreePhaseCommitCohortAdapter(delegate().ready()); - } - - @Override - public void merge(final YangInstanceIdentifier path, final NormalizedNode data) { - delegate().merge(path, data); - } - - @Override - public void delete(final YangInstanceIdentifier path) { - delegate().delete(path); - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMStoreThreePhaseCommitCohortAdapter.java b/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMStoreThreePhaseCommitCohortAdapter.java deleted file mode 100644 index 2e1af065f7..0000000000 --- a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMStoreThreePhaseCommitCohortAdapter.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.core.compat; - -import static java.util.Objects.requireNonNull; - -import com.google.common.collect.ForwardingObject; -import com.google.common.util.concurrent.ListenableFuture; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort; - -@Deprecated(forRemoval = true) -public class DOMStoreThreePhaseCommitCohortAdapter extends ForwardingObject implements DOMStoreThreePhaseCommitCohort { - private final org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort delegate; - - public DOMStoreThreePhaseCommitCohortAdapter( - final org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort delegate) { - this.delegate = requireNonNull(delegate); - } - - @Override - protected org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort delegate() { - return delegate; - } - - @Override - public ListenableFuture preCommit() { - return delegate.preCommit(); - } - - @Override - public ListenableFuture commit() { - return delegate.commit(); - } - - @Override - public ListenableFuture canCommit() { - return delegate.canCommit(); - } - - @Override - public ListenableFuture abort() { - return delegate.abort(); - } -} diff --git a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMStoreTransactionChainAdapter.java b/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMStoreTransactionChainAdapter.java deleted file mode 100644 index 874b7cfbee..0000000000 --- a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMStoreTransactionChainAdapter.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.core.compat; - -import static java.util.Objects.requireNonNull; - -import com.google.common.collect.ForwardingObject; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction; - -@Deprecated(forRemoval = true) -public class DOMStoreTransactionChainAdapter extends ForwardingObject implements DOMStoreTransactionChain { - private final org.opendaylight.mdsal.dom.spi.store.DOMStoreTransactionChain delegate; - - public DOMStoreTransactionChainAdapter( - final org.opendaylight.mdsal.dom.spi.store.DOMStoreTransactionChain delegate) { - this.delegate = requireNonNull(delegate); - } - - @Override - protected org.opendaylight.mdsal.dom.spi.store.DOMStoreTransactionChain delegate() { - return delegate; - } - - @Override - public DOMStoreWriteTransaction newWriteOnlyTransaction() { - return new DOMStoreWriteTransactionAdapter(delegate.newWriteOnlyTransaction()); - } - - @Override - public DOMStoreReadWriteTransaction newReadWriteTransaction() { - return new DOMStoreReadWriteTransactionAdapter(delegate.newReadWriteTransaction()); - } - - @Override - public DOMStoreReadTransaction newReadOnlyTransaction() { - return new DOMStoreReadTransactionAdapter<>(delegate.newReadOnlyTransaction()); - } - - @Override - public void close() { - delegate.close(); - } -} diff --git a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMStoreWriteTransactionAdapter.java b/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMStoreWriteTransactionAdapter.java deleted file mode 100644 index beee79cda5..0000000000 --- a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMStoreWriteTransactionAdapter.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.core.compat; - -import static java.util.Objects.requireNonNull; - -import com.google.common.collect.ForwardingObject; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; - -@Deprecated(forRemoval = true) -public class DOMStoreWriteTransactionAdapter extends ForwardingObject implements DOMStoreWriteTransaction { - private final org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction delegate; - - public DOMStoreWriteTransactionAdapter( - final org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction delegate) { - this.delegate = requireNonNull(delegate); - } - - @Override - protected org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction delegate() { - return delegate; - } - - @Override - public Object getIdentifier() { - return delegate.getIdentifier(); - } - - @Override - public void close() { - delegate.close(); - } - - @Override - public void write(final YangInstanceIdentifier path, final NormalizedNode data) { - delegate.write(path, data); - } - - @Override - public DOMStoreThreePhaseCommitCohort ready() { - return new DOMStoreThreePhaseCommitCohortAdapter(delegate.ready()); - } - - @Override - public void merge(final YangInstanceIdentifier path, final NormalizedNode data) { - delegate.merge(path, data); - } - - @Override - public void delete(final YangInstanceIdentifier path) { - delegate.delete(path); - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMTransactionChainAdapter.java b/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMTransactionChainAdapter.java deleted file mode 100644 index d6b5e5c8ce..0000000000 --- a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMTransactionChainAdapter.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.core.compat; - -import static java.util.Objects.requireNonNull; - -import com.google.common.cache.Cache; -import com.google.common.cache.CacheBuilder; -import com.google.common.collect.ForwardingObject; -import java.util.function.Function; -import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction; -import org.opendaylight.controller.md.sal.common.api.data.TransactionChain; -import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener; -import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction; -import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction; -import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction; -import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain; -import org.opendaylight.mdsal.dom.api.DOMDataTreeReadTransaction; -import org.opendaylight.mdsal.dom.api.DOMDataTreeReadWriteTransaction; -import org.opendaylight.mdsal.dom.api.DOMDataTreeTransaction; -import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction; -import org.opendaylight.mdsal.dom.api.DOMTransactionChainListener; - -@Deprecated(forRemoval = true) -public class DOMTransactionChainAdapter extends ForwardingObject - implements org.opendaylight.mdsal.dom.api.DOMTransactionChain, TransactionChainListener { - private final Cache, DOMDataTreeTransaction> transactions = CacheBuilder.newBuilder() - .weakKeys().weakValues().build(); - - private final DOMTransactionChainListener listener; - private final DOMTransactionChain delegate; - - public DOMTransactionChainAdapter(final DOMTransactionChainListener listener, - final Function function) { - this.listener = requireNonNull(listener); - this.delegate = function.apply(this); - } - - @Override - public void close() { - delegate().close(); - transactions.invalidateAll(); - } - - @Override - public DOMDataTreeReadTransaction newReadOnlyTransaction() { - final DOMDataReadOnlyTransaction tx = delegate.newReadOnlyTransaction(); - return track(tx, new DOMDataTreeReadTransactionAdapter(tx) { - @Override - public void close() { - untrack(delegate()); - super.close(); - } - }); - } - - @Override - public DOMDataTreeWriteTransaction newWriteOnlyTransaction() { - final DOMDataWriteTransaction tx = delegate.newWriteOnlyTransaction(); - return track(tx, new DOMDataTreeWriteTransactionAdapter(tx) { - @Override - public boolean cancel() { - untrack(delegate()); - return super.cancel(); - } - }); - } - - @Override - public DOMDataTreeReadWriteTransaction newReadWriteTransaction() { - final DOMDataReadWriteTransaction tx = delegate.newReadWriteTransaction(); - return track(tx, new DOMDataTreeReadWriteTransactionAdapter(tx) { - @Override - public boolean cancel() { - untrack(delegate()); - return super.cancel(); - } - }); - } - - @Override - public void onTransactionChainFailed(final TransactionChain chain, final AsyncTransaction transaction, - final Throwable cause) { - listener.onTransactionChainFailed(this, null, cause); - } - - @Override - public void onTransactionChainSuccessful(final TransactionChain chain) { - listener.onTransactionChainSuccessful(this); - } - - @Override - protected DOMTransactionChain delegate() { - return delegate; - } - - private T track(final AsyncTransaction controllerTx, final T mdsalTx) { - transactions.put(controllerTx, mdsalTx); - return mdsalTx; - } - - void untrack(final AsyncTransaction controllerTx) { - transactions.invalidate(controllerTx); - } -} diff --git a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/LegacyDOMActionServiceAdapter.java b/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/LegacyDOMActionServiceAdapter.java deleted file mode 100644 index 10f65be36b..0000000000 --- a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/LegacyDOMActionServiceAdapter.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.core.compat; - -import static java.util.Objects.requireNonNull; - -import com.google.common.collect.ClassToInstanceMap; -import com.google.common.collect.ForwardingObject; -import com.google.common.util.concurrent.ListenableFuture; -import org.opendaylight.controller.md.sal.dom.api.DOMActionService; -import org.opendaylight.mdsal.dom.api.DOMActionResult; -import org.opendaylight.mdsal.dom.api.DOMActionServiceExtension; -import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; - -@Deprecated(forRemoval = true) -public class LegacyDOMActionServiceAdapter extends ForwardingObject implements DOMActionService { - private final org.opendaylight.mdsal.dom.api.DOMActionService delegate; - - public LegacyDOMActionServiceAdapter(final org.opendaylight.mdsal.dom.api.DOMActionService delegate) { - this.delegate = requireNonNull(delegate); - } - - @Override - protected org.opendaylight.mdsal.dom.api.DOMActionService delegate() { - return delegate; - } - - @Override - public ListenableFuture invokeAction(final SchemaPath type, - final DOMDataTreeIdentifier path, final ContainerNode input) { - return delegate.invokeAction(type, path, input); - } - - @Override - public ClassToInstanceMap getExtensions() { - return delegate.getExtensions(); - } -} diff --git a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/LegacyDOMDataBrokerAdapter.java b/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/LegacyDOMDataBrokerAdapter.java deleted file mode 100644 index f807b740ec..0000000000 --- a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/LegacyDOMDataBrokerAdapter.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2017 Inocybe Technologies and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.core.compat; - -import org.opendaylight.mdsal.dom.api.DOMTransactionChain; -import org.opendaylight.mdsal.dom.api.DOMTransactionChainListener; - -/** - * Adapter between the legacy controller API-based DOMDataBroker and the mdsal API-based DOMDataBroker. - * - * @author Thomas Pantelis - */ -@Deprecated(forRemoval = true) -public class LegacyDOMDataBrokerAdapter extends AbstractLegacyDOMDataBrokerAdapter { - public LegacyDOMDataBrokerAdapter(final org.opendaylight.mdsal.dom.api.DOMDataBroker delegate) { - super(delegate); - } - - @Override - DOMTransactionChain createDelegateChain(DOMTransactionChainListener listener) { - return delegate().createTransactionChain(listener); - } -} diff --git a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/LegacyDOMNotificationServiceAdapter.java b/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/LegacyDOMNotificationServiceAdapter.java deleted file mode 100644 index a3f3053b74..0000000000 --- a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/LegacyDOMNotificationServiceAdapter.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.core.compat; - -import static java.util.Objects.requireNonNull; - -import com.google.common.collect.ForwardingObject; -import java.time.Instant; -import java.util.Arrays; -import java.util.Collection; -import java.util.Date; -import org.opendaylight.controller.md.sal.dom.api.DOMEvent; -import org.opendaylight.controller.md.sal.dom.api.DOMNotification; -import org.opendaylight.controller.md.sal.dom.api.DOMNotificationListener; -import org.opendaylight.controller.md.sal.dom.api.DOMNotificationService; -import org.opendaylight.yangtools.concepts.AbstractListenerRegistration; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; - -@Deprecated(forRemoval = true) -public class LegacyDOMNotificationServiceAdapter extends ForwardingObject implements DOMNotificationService { - private final org.opendaylight.mdsal.dom.api.DOMNotificationService delegate; - - public LegacyDOMNotificationServiceAdapter(final org.opendaylight.mdsal.dom.api.DOMNotificationService delegate) { - this.delegate = requireNonNull(delegate); - } - - @Override - public ListenerRegistration registerNotificationListener(final T listener, - final Collection types) { - final ListenerRegistration reg = - delegate().registerNotificationListener(notification -> { - if (notification instanceof DOMNotification) { - listener.onNotification((DOMNotification)notification); - return; - } - - if (notification instanceof org.opendaylight.mdsal.dom.api.DOMEvent) { - listener.onNotification(new DefaultDOMEvent(notification, - (org.opendaylight.mdsal.dom.api.DOMEvent)notification)); - return; - } - - listener.onNotification(new DefaultDOMNotification(notification)); - }, types); - - return new AbstractListenerRegistration(listener) { - @Override - protected void removeRegistration() { - reg.close(); - } - }; - } - - @Override - public ListenerRegistration registerNotificationListener(final T listener, - final SchemaPath... types) { - return registerNotificationListener(listener, Arrays.asList(types)); - } - - @Override - protected org.opendaylight.mdsal.dom.api.DOMNotificationService delegate() { - return delegate; - } - - private static class DefaultDOMNotification implements DOMNotification { - private final org.opendaylight.mdsal.dom.api.DOMNotification delegate; - - DefaultDOMNotification(final org.opendaylight.mdsal.dom.api.DOMNotification delegate) { - this.delegate = requireNonNull(delegate); - } - - @Override - public SchemaPath getType() { - return delegate.getType(); - } - - @Override - public ContainerNode getBody() { - return delegate.getBody(); - } - } - - private static class DefaultDOMEvent extends DefaultDOMNotification implements DOMEvent { - private final Date eventTime; - - DefaultDOMEvent(final org.opendaylight.mdsal.dom.api.DOMNotification fromNotification, - final org.opendaylight.mdsal.dom.api.DOMEvent fromEvent) { - super(fromNotification); - final Instant eventInstant = fromEvent.getEventInstant(); - this.eventTime = eventInstant != null ? Date.from(eventInstant) : null; - } - - @Override - public Date getEventTime() { - return eventTime; - } - } -} diff --git a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/LegacyDOMRpcResultFutureAdapter.java b/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/LegacyDOMRpcResultFutureAdapter.java deleted file mode 100644 index 238c0a03a9..0000000000 --- a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/LegacyDOMRpcResultFutureAdapter.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2018 Inocybe Technologies and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.core.compat; - -import com.google.common.util.concurrent.CheckedFuture; -import com.google.common.util.concurrent.ListenableFuture; -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcException; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementationNotAvailableException; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult; -import org.opendaylight.controller.md.sal.dom.api.DefaultDOMRpcException; -import org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult; -import org.opendaylight.yangtools.util.concurrent.ExceptionMapper; - -/** - * Adapts a {@link org.opendaylight.mdsal.dom.api.DOMRpcResult} CheckedFuture to a {@link DOMRpcResult} CheckedFuture. - * - * @author Thomas Pantelis - */ -@Deprecated(forRemoval = true) -public class LegacyDOMRpcResultFutureAdapter extends AbstractDOMRpcResultFutureAdapter, - DOMRpcException> implements CheckedFuture { - - private static final ExceptionMapper LEGACY_DOM_RPC_EX_MAPPER = - new ExceptionMapper("rpc", DOMRpcException.class) { - @Override - protected DOMRpcException newWithCause(String message, Throwable cause) { - return cause instanceof DOMRpcException ? (DOMRpcException)cause - : cause instanceof org.opendaylight.mdsal.dom.api.DOMRpcImplementationNotAvailableException - ? new DOMRpcImplementationNotAvailableException(cause.getMessage(), cause.getCause()) - : new DefaultDOMRpcException("RPC failed", cause); - } - }; - - public LegacyDOMRpcResultFutureAdapter(ListenableFuture delegate) { - super(delegate, LEGACY_DOM_RPC_EX_MAPPER); - } - - @Override - @SuppressFBWarnings("BC_UNCONFIRMED_CAST_OF_RETURN_VALUE") - public DOMRpcResult checkedGet() throws DOMRpcException { - try { - return get(); - } catch (InterruptedException | ExecutionException e) { - throw LEGACY_DOM_RPC_EX_MAPPER.apply(e); - } - } - - @Override - @SuppressFBWarnings("BC_UNCONFIRMED_CAST_OF_RETURN_VALUE") - public DOMRpcResult checkedGet(final long timeout, final TimeUnit unit) throws TimeoutException, DOMRpcException { - try { - return get(timeout, unit); - } catch (InterruptedException | ExecutionException e) { - throw LEGACY_DOM_RPC_EX_MAPPER.apply(e); - } - } - - @Override - protected DOMRpcResult transform(org.opendaylight.mdsal.dom.api.DOMRpcResult fromResult) { - return new DefaultDOMRpcResult(fromResult.getResult(), fromResult.getErrors()); - } -} diff --git a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/LegacyDOMRpcServiceAdapter.java b/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/LegacyDOMRpcServiceAdapter.java deleted file mode 100644 index eed8e1b2e4..0000000000 --- a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/LegacyDOMRpcServiceAdapter.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.core.compat; - -import static java.util.Objects.requireNonNull; - -import com.google.common.collect.ForwardingObject; -import com.google.common.util.concurrent.CheckedFuture; -import com.google.common.util.concurrent.ListenableFuture; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcAvailabilityListener; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcException; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcService; -import org.opendaylight.yangtools.concepts.AbstractListenerRegistration; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; - -@Deprecated(forRemoval = true) -public class LegacyDOMRpcServiceAdapter extends ForwardingObject implements DOMRpcService { - private final org.opendaylight.mdsal.dom.api.DOMRpcService delegate; - - public LegacyDOMRpcServiceAdapter(final org.opendaylight.mdsal.dom.api.DOMRpcService delegate) { - this.delegate = requireNonNull(delegate); - } - - @Override - public CheckedFuture invokeRpc(final SchemaPath type, - final NormalizedNode input) { - final ListenableFuture future = delegate().invokeRpc(type, input); - return future instanceof MdsalDOMRpcResultFutureAdapter ? ((MdsalDOMRpcResultFutureAdapter)future).delegate() - : new LegacyDOMRpcResultFutureAdapter(future); - } - - @Override - public ListenerRegistration registerRpcListener(final T listener) { - final ListenerRegistration reg = - delegate().registerRpcListener(new RpcAvailabilityListenerAdapter<>(listener)); - - return new AbstractListenerRegistration(listener) { - @Override - protected void removeRegistration() { - reg.close(); - } - }; - } - - @Override - protected org.opendaylight.mdsal.dom.api.DOMRpcService delegate() { - return delegate; - } -} diff --git a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/LegacyPingPongDOMDataBrokerAdapter.java b/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/LegacyPingPongDOMDataBrokerAdapter.java deleted file mode 100644 index 36e46fcae3..0000000000 --- a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/LegacyPingPongDOMDataBrokerAdapter.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2019 PANTHEON.tech and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.core.compat; - -import org.opendaylight.mdsal.dom.api.DOMTransactionChain; -import org.opendaylight.mdsal.dom.api.DOMTransactionChainListener; - -/** - * Adapter between the legacy controller API-based DOMDataBroker and the mdsal API-based DOMDataBroker, equivalent - * to PingPongDOMDataBroker. - */ -@Deprecated(forRemoval = true) -public class LegacyPingPongDOMDataBrokerAdapter extends AbstractLegacyDOMDataBrokerAdapter { - public LegacyPingPongDOMDataBrokerAdapter(final org.opendaylight.mdsal.dom.api.DOMDataBroker delegate) { - super(delegate); - } - - @Override - DOMTransactionChain createDelegateChain(DOMTransactionChainListener listener) { - return delegate().createMergingTransactionChain(listener); - } -} diff --git a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/MdsalDOMRpcResultFutureAdapter.java b/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/MdsalDOMRpcResultFutureAdapter.java deleted file mode 100644 index 7b5020c591..0000000000 --- a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/MdsalDOMRpcResultFutureAdapter.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2018 Inocybe Technologies and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.core.compat; - -import com.google.common.util.concurrent.CheckedFuture; -import org.opendaylight.mdsal.dom.api.DOMRpcException; -import org.opendaylight.mdsal.dom.api.DOMRpcResult; -import org.opendaylight.mdsal.dom.api.DefaultDOMRpcException; -import org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult; -import org.opendaylight.yangtools.util.concurrent.ExceptionMapper; - -/** - * Adapts a {@link org.opendaylight.controller.md.sal.dom.api.DOMRpcResult} CheckedFuture to a - * {@link DOMRpcResult} CheckedFuture. - * - * @author Thomas Pantelis - */ -@Deprecated(forRemoval = true) -public class MdsalDOMRpcResultFutureAdapter extends AbstractDOMRpcResultFutureAdapter< - DOMRpcResult, org.opendaylight.controller.md.sal.dom.api.DOMRpcResult, - CheckedFuture, DOMRpcException> { - private static final ExceptionMapper MDSAL_DOM_RPC_EX_MAPPER = - new ExceptionMapper("rpc", DOMRpcException.class) { - @Override - protected DOMRpcException newWithCause(String message, Throwable cause) { - return cause instanceof DOMRpcException ? (DOMRpcException) cause - : new DefaultDOMRpcException("RPC failed", cause); - } - }; - - public MdsalDOMRpcResultFutureAdapter(CheckedFuture delegate) { - super(delegate, MDSAL_DOM_RPC_EX_MAPPER); - } - - @Override - protected DOMRpcResult transform(org.opendaylight.controller.md.sal.dom.api.DOMRpcResult fromResult) { - return new DefaultDOMRpcResult(fromResult.getResult(), fromResult.getErrors()); - } -} diff --git a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/ReadFailedExceptionAdapter.java b/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/ReadFailedExceptionAdapter.java deleted file mode 100644 index 942de1cbdb..0000000000 --- a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/ReadFailedExceptionAdapter.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2018 Inocybe Technologies and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.core.compat; - -import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; -import org.opendaylight.yangtools.util.concurrent.ExceptionMapper; - -/** - * Adapter that maps the controller API-based ReadFailedException to the mdsal API-based ReadFailedException. - * - * @author Thomas Pantelis - */ -@Deprecated(forRemoval = true) -public final class ReadFailedExceptionAdapter extends ExceptionMapper { - public static final ReadFailedExceptionAdapter INSTANCE = new ReadFailedExceptionAdapter(); - - private ReadFailedExceptionAdapter() { - super("read", ReadFailedException.class); - } - - @Override - protected ReadFailedException newWithCause(String message, Throwable cause) { - if (cause instanceof org.opendaylight.mdsal.common.api.ReadFailedException) { - return new ReadFailedException(cause.getMessage(), cause.getCause()); - } - - return new ReadFailedException(message, cause); - } -} diff --git a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/RpcAvailabilityListenerAdapter.java b/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/RpcAvailabilityListenerAdapter.java deleted file mode 100644 index adcd27e7cf..0000000000 --- a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/RpcAvailabilityListenerAdapter.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.core.compat; - -import static java.util.Objects.requireNonNull; - -import com.google.common.collect.ForwardingObject; -import java.util.Collection; -import java.util.stream.Collectors; -import org.eclipse.jdt.annotation.NonNull; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcAvailabilityListener; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier; - -@Deprecated(forRemoval = true) -public class RpcAvailabilityListenerAdapter extends ForwardingObject - implements org.opendaylight.mdsal.dom.api.DOMRpcAvailabilityListener { - private final @NonNull T delegate; - - public RpcAvailabilityListenerAdapter(final T delegate) { - this.delegate = requireNonNull(delegate); - } - - @Override - public void onRpcAvailable(final Collection rpcs) { - delegate.onRpcAvailable(convert(rpcs)); - } - - @Override - public void onRpcUnavailable(final Collection rpcs) { - delegate.onRpcUnavailable(convert(rpcs)); - } - - @Override - protected T delegate() { - return delegate; - } - - private static @NonNull Collection convert( - final Collection from) { - return from.stream().map(DOMRpcIdentifier::fromMdsal).collect(Collectors.toList()); - } -} diff --git a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/TransactionUtils.java b/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/TransactionUtils.java deleted file mode 100644 index fa3fc57f74..0000000000 --- a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/TransactionUtils.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.core.compat; - -import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.fromMdsal; - -import com.google.common.util.concurrent.FluentFuture; -import com.google.common.util.concurrent.MoreExecutors; -import java.util.Optional; -import org.opendaylight.controller.md.sal.dom.api.DOMDataReadTransaction; -import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction; -import org.opendaylight.mdsal.common.api.LogicalDatastoreType; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; - -@Deprecated(forRemoval = true) -final class TransactionUtils { - private TransactionUtils() { - - } - - static FluentFuture exists(final DOMDataReadTransaction tx, - final LogicalDatastoreType store, final YangInstanceIdentifier path) { - return FluentFuture.from(tx.exists(fromMdsal(store), path)); - } - - static FluentFuture>> read(final DOMDataReadTransaction tx, - final LogicalDatastoreType store, final YangInstanceIdentifier path) { - return FluentFuture.from(tx.read(fromMdsal(store), path)).transform(opt -> opt.toJavaUtil(), - MoreExecutors.directExecutor()); - } - - static void delete(final DOMDataWriteTransaction tx, final LogicalDatastoreType store, - final YangInstanceIdentifier path) { - tx.delete(fromMdsal(store), path); - } - - static void merge(final DOMDataWriteTransaction tx, final LogicalDatastoreType store, - final YangInstanceIdentifier path, final NormalizedNode data) { - tx.merge(fromMdsal(store), path, data); - } - - static void put(final DOMDataWriteTransaction tx, final LogicalDatastoreType store, - final YangInstanceIdentifier path, final NormalizedNode data) { - tx.put(fromMdsal(store), path, data); - } -} diff --git a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/package-info.java b/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/package-info.java deleted file mode 100644 index 536c9c5534..0000000000 --- a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/package-info.java +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -/** - * Controller/MDSAL compatibility library. Contains classes useful for bridging Controller's sal-core-{api,spi} - * to MD-SAL's mdsal-dom-{api,spi}. - */ -@Deprecated(forRemoval = true) -package org.opendaylight.controller.sal.core.compat; \ No newline at end of file diff --git a/opendaylight/md-sal/sal-dom-compat/src/test/java/org/opendaylight/controller/sal/core/compat/DOMMountPointAdapterTest.java b/opendaylight/md-sal/sal-dom-compat/src/test/java/org/opendaylight/controller/sal/core/compat/DOMMountPointAdapterTest.java deleted file mode 100644 index 4c57f1c84e..0000000000 --- a/opendaylight/md-sal/sal-dom-compat/src/test/java/org/opendaylight/controller/sal/core/compat/DOMMountPointAdapterTest.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.core.compat; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.mock; - -import com.google.common.collect.ImmutableClassToInstanceMap; -import java.util.Optional; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; -import org.opendaylight.controller.md.sal.dom.api.DOMActionService; -import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; -import org.opendaylight.controller.md.sal.dom.api.DOMNotificationService; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcService; -import org.opendaylight.mdsal.dom.api.DOMMountPoint; - -@Deprecated -@RunWith(MockitoJUnitRunner.StrictStubs.class) -public class DOMMountPointAdapterTest { - @Mock - private DOMMountPoint delegate; - - private DOMMountPointAdapter adapter; - - @Before - public void before() { - doReturn(Optional.empty()).when(delegate).getService(any()); - adapter = new DOMMountPointAdapter(delegate); - } - - @Test - public void testDOMActionService() { - assertFalse(adapter.getService(DOMActionService.class).isPresent()); - - org.opendaylight.mdsal.dom.api.DOMActionService mdsal = - mock(org.opendaylight.mdsal.dom.api.DOMActionService.class); - - doReturn(Optional.of(mdsal)).when(delegate).getService(org.opendaylight.mdsal.dom.api.DOMActionService.class); - assertTrue(adapter.getService(DOMActionService.class).isPresent()); - } - - @Test - public void testDOMDataBroker() { - assertFalse(adapter.getService(DOMDataBroker.class).isPresent()); - - org.opendaylight.mdsal.dom.api.DOMDataBroker mdsal = mock(org.opendaylight.mdsal.dom.api.DOMDataBroker.class); - doReturn(ImmutableClassToInstanceMap.of()).when(mdsal).getExtensions(); - - doReturn(Optional.of(mdsal)).when(delegate).getService(org.opendaylight.mdsal.dom.api.DOMDataBroker.class); - assertTrue(adapter.getService(DOMDataBroker.class).isPresent()); - } - - @Test - public void testDOMNotificationService() { - assertFalse(adapter.getService(DOMNotificationService.class).isPresent()); - - org.opendaylight.mdsal.dom.api.DOMNotificationService mdsal = - mock(org.opendaylight.mdsal.dom.api.DOMNotificationService.class); - - doReturn(Optional.of(mdsal)).when(delegate).getService( - org.opendaylight.mdsal.dom.api.DOMNotificationService.class); - assertTrue(adapter.getService(DOMNotificationService.class).isPresent()); - } - - @Test - public void testDOMRpcService() { - assertFalse(adapter.getService(DOMRpcService.class).isPresent()); - - org.opendaylight.mdsal.dom.api.DOMRpcService mdsal = mock(org.opendaylight.mdsal.dom.api.DOMRpcService.class); - - doReturn(Optional.of(mdsal)).when(delegate).getService(org.opendaylight.mdsal.dom.api.DOMRpcService.class); - assertTrue(adapter.getService(DOMRpcService.class).isPresent()); - } -} diff --git a/opendaylight/md-sal/sal-dom-compat/src/test/java/org/opendaylight/controller/sal/core/compat/LegacyDOMDataBrokerAdapterTest.java b/opendaylight/md-sal/sal-dom-compat/src/test/java/org/opendaylight/controller/sal/core/compat/LegacyDOMDataBrokerAdapterTest.java deleted file mode 100644 index e0bfc9c419..0000000000 --- a/opendaylight/md-sal/sal-dom-compat/src/test/java/org/opendaylight/controller/sal/core/compat/LegacyDOMDataBrokerAdapterTest.java +++ /dev/null @@ -1,530 +0,0 @@ -/* - * Copyright (c) 2017 Inocybe Technologies and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.core.compat; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyObject; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.doAnswer; -import static org.mockito.Mockito.doNothing; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.inOrder; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; - -import com.google.common.collect.ClassToInstanceMap; -import com.google.common.collect.ImmutableClassToInstanceMap; -import com.google.common.collect.ImmutableMap; -import com.google.common.util.concurrent.CheckedFuture; -import com.google.common.util.concurrent.Futures; -import com.google.common.util.concurrent.MoreExecutors; -import java.util.Arrays; -import java.util.Collection; -import java.util.Optional; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; -import org.junit.Before; -import org.junit.Test; -import org.mockito.ArgumentCaptor; -import org.mockito.InOrder; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction; -import org.opendaylight.controller.md.sal.common.api.data.DataStoreUnavailableException; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.OptimisticLockFailedException; -import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; -import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener; -import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; -import org.opendaylight.controller.md.sal.dom.api.ClusteredDOMDataTreeChangeListener; -import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction; -import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction; -import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener; -import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeService; -import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeIdentifier; -import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction; -import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain; -import org.opendaylight.mdsal.dom.api.DOMDataBrokerExtension; -import org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohort; -import org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohortRegistration; -import org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohortRegistry; -import org.opendaylight.mdsal.dom.broker.SerializedDOMDataBroker; -import org.opendaylight.mdsal.dom.spi.store.DOMStore; -import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadTransaction; -import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadWriteTransaction; -import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort; -import org.opendaylight.mdsal.dom.spi.store.DOMStoreTransactionChain; -import org.opendaylight.mdsal.dom.spi.store.DOMStoreTreeChangePublisher; -import org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.util.concurrent.FluentFutures; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.data.api.schema.tree.ConflictingModificationAppliedException; -import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate; -import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException; -import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; - -/** - * Unit tests for LegacyDOMDataBrokerAdapter. - * - * @author Thomas Pantelis - */ -@Deprecated -public class LegacyDOMDataBrokerAdapterTest { - public static final QName TEST_QNAME = QName.create("test", "2018-07-11", "test"); - private static final YangInstanceIdentifier TEST_PATH = YangInstanceIdentifier.of(TEST_QNAME); - - @Mock - private TestDOMStore mockOperStore; - - @Mock - private TestDOMStore mockConfigStore; - - @Mock - private DOMStoreReadTransaction mockConfigReadTx; - - @Mock - private DOMStoreWriteTransaction mockConfigWriteTx; - - @Mock - private DOMStoreReadWriteTransaction mockConfigReadWriteTx; - - @Mock - private DOMStoreThreePhaseCommitCohort mockConfigCommitCohort; - - @Mock - private DOMStoreReadTransaction mockOperReadTx; - - @Mock - private DOMStoreWriteTransaction mockOperWriteTx; - - @Mock - private DOMStoreReadWriteTransaction mockOperReadWriteTx; - - @Mock - private DOMStoreThreePhaseCommitCohort mockOperCommitCohort; - - @Mock - private DOMDataTreeCommitCohortRegistry mockCommitCohortRegistry; - - private LegacyDOMDataBrokerAdapter adapter; - private NormalizedNode dataNode; - - @Before - public void setup() { - MockitoAnnotations.initMocks(this); - - SerializedDOMDataBroker backendBroker = new SerializedDOMDataBroker(ImmutableMap.of( - org.opendaylight.mdsal.common.api.LogicalDatastoreType.OPERATIONAL, mockOperStore, - org.opendaylight.mdsal.common.api.LogicalDatastoreType.CONFIGURATION, mockConfigStore), - MoreExecutors.newDirectExecutorService()) { - @Override - public ClassToInstanceMap getExtensions() { - return ImmutableClassToInstanceMap.builder().putAll(super.getExtensions()) - .put(DOMDataTreeCommitCohortRegistry.class, mockCommitCohortRegistry).build(); - } - }; - - adapter = new LegacyDOMDataBrokerAdapter(backendBroker); - - doReturn(Futures.immediateFuture(Boolean.TRUE)).when(mockConfigCommitCohort).canCommit(); - doReturn(Futures.immediateFuture(null)).when(mockConfigCommitCohort).preCommit(); - doReturn(Futures.immediateFuture(null)).when(mockConfigCommitCohort).commit(); - doReturn(Futures.immediateFuture(null)).when(mockConfigCommitCohort).abort(); - - dataNode = ImmutableNodes.containerNode(TEST_QNAME); - - doReturn(mockConfigWriteTx).when(mockConfigStore).newWriteOnlyTransaction(); - doNothing().when(mockConfigWriteTx).write(TEST_PATH, dataNode); - doNothing().when(mockConfigWriteTx).merge(TEST_PATH, dataNode); - doNothing().when(mockConfigWriteTx).delete(TEST_PATH); - doNothing().when(mockConfigWriteTx).close(); - doReturn(mockConfigCommitCohort).when(mockConfigWriteTx).ready(); - - doReturn(mockConfigReadTx).when(mockConfigStore).newReadOnlyTransaction(); - doReturn(FluentFutures.immediateFluentFuture(Optional.of(dataNode))).when(mockConfigReadTx).read(TEST_PATH); - doReturn(FluentFutures.immediateFluentFuture(Boolean.TRUE)).when(mockConfigReadTx).exists(TEST_PATH); - - doReturn(mockConfigReadWriteTx).when(mockConfigStore).newReadWriteTransaction(); - doNothing().when(mockConfigReadWriteTx).write(TEST_PATH, dataNode); - doReturn(mockConfigCommitCohort).when(mockConfigReadWriteTx).ready(); - doReturn(FluentFutures.immediateFluentFuture(Optional.of(dataNode))) - .when(mockConfigReadWriteTx).read(TEST_PATH); - - DOMStoreTransactionChain mockTxChain = mock(DOMStoreTransactionChain.class); - doReturn(mockConfigReadTx).when(mockTxChain).newReadOnlyTransaction(); - doReturn(mockConfigWriteTx).when(mockTxChain).newWriteOnlyTransaction(); - doReturn(mockConfigReadWriteTx).when(mockTxChain).newReadWriteTransaction(); - doReturn(mockTxChain).when(mockConfigStore).createTransactionChain(); - - doReturn(mock(DOMStoreTransactionChain.class)).when(mockOperStore).createTransactionChain(); - - doReturn(Futures.immediateFuture(Boolean.TRUE)).when(mockOperCommitCohort).canCommit(); - doReturn(Futures.immediateFuture(null)).when(mockOperCommitCohort).preCommit(); - doReturn(Futures.immediateFuture(null)).when(mockOperCommitCohort).commit(); - doReturn(Futures.immediateFuture(null)).when(mockOperCommitCohort).abort(); - - doReturn(mockOperReadTx).when(mockOperStore).newReadOnlyTransaction(); - - doReturn(mockOperWriteTx).when(mockOperStore).newWriteOnlyTransaction(); - doReturn(mockOperCommitCohort).when(mockOperWriteTx).ready(); - - doReturn(mockOperReadWriteTx).when(mockOperStore).newReadWriteTransaction(); - doReturn(mockOperCommitCohort).when(mockOperReadWriteTx).ready(); - - DOMStoreTransactionChain mockOperTxChain = mock(DOMStoreTransactionChain.class); - doReturn(mockOperReadTx).when(mockOperTxChain).newReadOnlyTransaction(); - doReturn(mockOperWriteTx).when(mockOperTxChain).newWriteOnlyTransaction(); - doReturn(mockOperReadWriteTx).when(mockOperTxChain).newReadWriteTransaction(); - doReturn(mockOperTxChain).when(mockOperStore).createTransactionChain(); - } - - @Test - public void testReadOnlyTransaction() throws Exception { - DOMDataReadOnlyTransaction tx = adapter.newReadOnlyTransaction(); - - // Test successful read - - CheckedFuture>, ReadFailedException> readFuture = - tx.read(LogicalDatastoreType.CONFIGURATION, TEST_PATH); - com.google.common.base.Optional> readOptional = readFuture.get(); - assertEquals("isPresent", true, readOptional.isPresent()); - assertEquals("NormalizedNode", dataNode, readOptional.get()); - - // Test successful exists - - CheckedFuture existsFuture = - tx.exists(LogicalDatastoreType.CONFIGURATION, TEST_PATH); - assertEquals("exists", Boolean.TRUE, existsFuture.get()); - - // Test failed read - - String errorMsg = "mock read error"; - Throwable cause = new RuntimeException(); - doReturn(FluentFutures.immediateFailedFluentFuture(new org.opendaylight.mdsal.common.api.ReadFailedException( - errorMsg, cause))).when(mockConfigReadTx).read(TEST_PATH); - - try { - tx.read(LogicalDatastoreType.CONFIGURATION, TEST_PATH).checkedGet(); - fail("Expected ReadFailedException"); - } catch (ReadFailedException e) { - assertEquals("getMessage", errorMsg, e.getMessage()); - assertEquals("getCause", cause, e.getCause()); - } - - // Test close - tx.close(); - verify(mockConfigReadTx).close(); - } - - @Test - public void testWriteOnlyTransaction() throws Exception { - // Test successful write operations and submit - - DOMDataWriteTransaction tx = adapter.newWriteOnlyTransaction(); - - tx.put(LogicalDatastoreType.CONFIGURATION, TEST_PATH, dataNode); - verify(mockConfigWriteTx).write(TEST_PATH, dataNode); - - tx.merge(LogicalDatastoreType.CONFIGURATION, TEST_PATH, dataNode); - verify(mockConfigWriteTx).merge(TEST_PATH, dataNode); - - tx.delete(LogicalDatastoreType.CONFIGURATION, TEST_PATH); - verify(mockConfigWriteTx).delete(TEST_PATH); - - tx.commit().get(5, TimeUnit.SECONDS); - - InOrder inOrder = inOrder(mockConfigCommitCohort); - inOrder.verify(mockConfigCommitCohort).canCommit(); - inOrder.verify(mockConfigCommitCohort).preCommit(); - inOrder.verify(mockConfigCommitCohort).commit(); - - // Test cancel - - tx = adapter.newWriteOnlyTransaction(); - tx.put(LogicalDatastoreType.CONFIGURATION, TEST_PATH, dataNode); - tx.cancel(); - verify(mockConfigWriteTx).close(); - - // Test submit with OptimisticLockFailedException - - String errorMsg = "mock OptimisticLockFailedException"; - Throwable cause = new ConflictingModificationAppliedException(TEST_PATH, "mock"); - doReturn(Futures.immediateFailedFuture(new org.opendaylight.mdsal.common.api.OptimisticLockFailedException( - errorMsg, cause))).when(mockConfigCommitCohort).canCommit(); - - try { - tx = adapter.newWriteOnlyTransaction(); - tx.put(LogicalDatastoreType.CONFIGURATION, TEST_PATH, dataNode); - commit(tx); - fail("Expected OptimisticLockFailedException"); - } catch (OptimisticLockFailedException e) { - assertEquals("getMessage", errorMsg, e.getMessage()); - assertEquals("getCause", cause, e.getCause()); - } - - // Test submit with TransactionCommitFailedException - - errorMsg = "mock TransactionCommitFailedException"; - cause = new DataValidationFailedException(TEST_PATH, "mock"); - doReturn(Futures.immediateFailedFuture(new org.opendaylight.mdsal.common.api.TransactionCommitFailedException( - errorMsg, cause))).when(mockConfigCommitCohort).canCommit(); - - try { - tx = adapter.newWriteOnlyTransaction(); - tx.put(LogicalDatastoreType.CONFIGURATION, TEST_PATH, dataNode); - commit(tx); - fail("Expected TransactionCommitFailedException"); - } catch (TransactionCommitFailedException e) { - assertEquals("getMessage", errorMsg, e.getMessage()); - assertEquals("getCause", cause, e.getCause()); - } - - // Test submit with DataStoreUnavailableException - - errorMsg = "mock NoShardLeaderException"; - cause = new DataStoreUnavailableException("mock", new RuntimeException()); - doReturn(Futures.immediateFailedFuture(cause)).when(mockConfigCommitCohort).canCommit(); - - try { - tx = adapter.newWriteOnlyTransaction(); - tx.put(LogicalDatastoreType.CONFIGURATION, TEST_PATH, dataNode); - commit(tx); - fail("Expected TransactionCommitFailedException"); - } catch (TransactionCommitFailedException e) { - assertEquals("getCause type", DataStoreUnavailableException.class, e.getCause().getClass()); - } - - // Test submit with RuntimeException - - errorMsg = "mock RuntimeException"; - cause = new RuntimeException(errorMsg); - doReturn(Futures.immediateFailedFuture(cause)).when(mockConfigCommitCohort).canCommit(); - - try { - tx = adapter.newWriteOnlyTransaction(); - tx.put(LogicalDatastoreType.CONFIGURATION, TEST_PATH, dataNode); - commit(tx); - fail("Expected TransactionCommitFailedException"); - } catch (TransactionCommitFailedException e) { - assertEquals("getCause", cause, e.getCause()); - } - } - - @Test - public void testReadWriteTransaction() throws Exception { - DOMDataReadWriteTransaction tx = adapter.newReadWriteTransaction(); - - CheckedFuture>, ReadFailedException> readFuture = - tx.read(LogicalDatastoreType.CONFIGURATION, TEST_PATH); - com.google.common.base.Optional> readOptional = readFuture.get(); - assertEquals("isPresent", true, readOptional.isPresent()); - assertEquals("NormalizedNode", dataNode, readOptional.get()); - - tx.put(LogicalDatastoreType.CONFIGURATION, TEST_PATH, dataNode); - verify(mockConfigReadWriteTx).write(TEST_PATH, dataNode); - - tx.commit().get(5, TimeUnit.SECONDS); - - InOrder inOrder = inOrder(mockConfigCommitCohort); - inOrder.verify(mockConfigCommitCohort).canCommit(); - inOrder.verify(mockConfigCommitCohort).preCommit(); - inOrder.verify(mockConfigCommitCohort).commit(); - } - - @SuppressWarnings("rawtypes") - @Test - public void testTransactionChain() throws Exception { - TransactionChainListener mockListener = mock(TransactionChainListener.class); - doNothing().when(mockListener).onTransactionChainSuccessful(anyObject()); - doNothing().when(mockListener).onTransactionChainFailed(anyObject(), anyObject(), anyObject()); - - DOMTransactionChain chain = adapter.createTransactionChain(mockListener); - - // Test read-only tx - - DOMDataReadOnlyTransaction readTx = chain.newReadOnlyTransaction(); - - CheckedFuture>, ReadFailedException> readFuture = - readTx.read(LogicalDatastoreType.CONFIGURATION, TEST_PATH); - com.google.common.base.Optional> readOptional = readFuture.get(); - assertEquals("isPresent", true, readOptional.isPresent()); - assertEquals("NormalizedNode", dataNode, readOptional.get()); - - // Test write-only tx - - DOMDataWriteTransaction writeTx = chain.newWriteOnlyTransaction(); - - writeTx.put(LogicalDatastoreType.CONFIGURATION, TEST_PATH, dataNode); - verify(mockConfigWriteTx).write(TEST_PATH, dataNode); - writeTx.commit().get(5, TimeUnit.SECONDS); - - InOrder inOrder = inOrder(mockConfigCommitCohort); - inOrder.verify(mockConfigCommitCohort).canCommit(); - inOrder.verify(mockConfigCommitCohort).preCommit(); - inOrder.verify(mockConfigCommitCohort).commit(); - - // Test read-write tx - - DOMDataReadWriteTransaction readWriteTx = chain.newReadWriteTransaction(); - - readFuture = readWriteTx.read(LogicalDatastoreType.CONFIGURATION, TEST_PATH); - readOptional = readFuture.get(); - assertEquals("isPresent", true, readOptional.isPresent()); - assertEquals("NormalizedNode", dataNode, readOptional.get()); - - chain.close(); - verify(mockListener).onTransactionChainSuccessful(chain); - - // Test failed chain - - doReturn(Futures.immediateFailedFuture(new org.opendaylight.mdsal.common.api.TransactionCommitFailedException( - "mock", (Throwable)null))).when(mockConfigCommitCohort).canCommit(); - - chain = adapter.createTransactionChain(mockListener); - - writeTx = chain.newWriteOnlyTransaction(); - - try { - writeTx.put(LogicalDatastoreType.CONFIGURATION, TEST_PATH, dataNode); - commit(writeTx); - fail("Expected TransactionCommitFailedException"); - } catch (TransactionCommitFailedException e) { - // expected - } - - ArgumentCaptor failedTx = ArgumentCaptor.forClass(AsyncTransaction.class); - verify(mockListener).onTransactionChainFailed(eq(chain), failedTx.capture(), - any(TransactionCommitFailedException.class)); - } - - @SuppressWarnings("unchecked") - @Test - public void testDataTreeChangeListener() { - DOMDataTreeChangeService domDTCLService = - (DOMDataTreeChangeService) adapter.getSupportedExtensions().get(DOMDataTreeChangeService.class); - assertNotNull("DOMDataTreeChangeService not found", domDTCLService); - - ArgumentCaptor storeDTCL = - ArgumentCaptor.forClass(org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener.class); - ListenerRegistration mockReg = - mock(ListenerRegistration.class); - doNothing().when(mockReg).close(); - doAnswer(invocation -> storeDTCL.getValue()).when(mockReg).getInstance(); - doReturn(mockReg).when(mockConfigStore).registerTreeChangeListener(eq(TEST_PATH), - storeDTCL.capture()); - - DOMDataTreeChangeListener brokerDTCL = mock(DOMDataTreeChangeListener.class); - ListenerRegistration reg = domDTCLService.registerDataTreeChangeListener( - new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, TEST_PATH), brokerDTCL); - assertEquals("getInstance", brokerDTCL, reg.getInstance()); - - Collection changes = Arrays.asList(mock(DataTreeCandidate.class)); - storeDTCL.getValue().onDataTreeChanged(changes); - verify(brokerDTCL).onDataTreeChanged(changes); - - reg.close(); - verify(mockReg).close(); - - // Test ClusteredDOMDataTreeChangeListener - - ArgumentCaptor storeClusteredDTCL = - ArgumentCaptor.forClass(org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener.class); - mockReg = mock(ListenerRegistration.class); - doReturn(mockReg).when(mockConfigStore).registerTreeChangeListener(eq(TEST_PATH), - storeClusteredDTCL.capture()); - - final ClusteredDOMDataTreeChangeListener brokerClusteredDTCL = mock(ClusteredDOMDataTreeChangeListener.class); - domDTCLService.registerDataTreeChangeListener(new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, - TEST_PATH), brokerClusteredDTCL); - - assertTrue("Expected ClusteredDOMDataTreeChangeListener: " + storeClusteredDTCL.getValue(), - storeClusteredDTCL.getValue() - instanceof org.opendaylight.mdsal.dom.api.ClusteredDOMDataTreeChangeListener); - storeClusteredDTCL.getValue().onDataTreeChanged(changes); - verify(brokerClusteredDTCL).onDataTreeChanged(changes); - } - - @SuppressWarnings("unchecked") - @Test - public void testDataTreeCommitCohortRegistry() { - org.opendaylight.controller.md.sal.dom.api.DOMDataTreeCommitCohortRegistry domCohortRegistry = - (org.opendaylight.controller.md.sal.dom.api.DOMDataTreeCommitCohortRegistry) - adapter.getSupportedExtensions().get( - org.opendaylight.controller.md.sal.dom.api.DOMDataTreeCommitCohortRegistry.class); - assertNotNull("DOMDataTreeCommitCohortRegistry not found", domCohortRegistry); - - DOMDataTreeCommitCohort mockCohort = mock(DOMDataTreeCommitCohort.class); - org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier treeId = - new org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier( - org.opendaylight.mdsal.common.api.LogicalDatastoreType.CONFIGURATION, TEST_PATH); - DOMDataTreeCommitCohortRegistration mockReg = - mock(DOMDataTreeCommitCohortRegistration.class); - doReturn(mockReg).when(mockCommitCohortRegistry).registerCommitCohort(treeId, mockCohort); - - DOMDataTreeCommitCohortRegistration reg = domCohortRegistry.registerCommitCohort( - treeId, mockCohort); - assertEquals("DOMDataTreeCommitCohortRegistration", mockReg, reg); - - verify(mockCommitCohortRegistry).registerCommitCohort(treeId, mockCohort); - } - - @Test - @Deprecated - public void testSubmit() throws Exception { - DOMDataWriteTransaction tx = adapter.newWriteOnlyTransaction(); - - tx.put(LogicalDatastoreType.CONFIGURATION, TEST_PATH, dataNode); - verify(mockConfigWriteTx).write(TEST_PATH, dataNode); - - tx.submit().get(5, TimeUnit.SECONDS); - - InOrder inOrder = inOrder(mockConfigCommitCohort); - inOrder.verify(mockConfigCommitCohort).canCommit(); - inOrder.verify(mockConfigCommitCohort).preCommit(); - inOrder.verify(mockConfigCommitCohort).commit(); - - String errorMsg = "mock OptimisticLockFailedException"; - Throwable cause = new ConflictingModificationAppliedException(TEST_PATH, "mock"); - doReturn(Futures.immediateFailedFuture(new org.opendaylight.mdsal.common.api.TransactionCommitFailedException( - errorMsg, cause))).when(mockConfigCommitCohort).canCommit(); - - try { - tx = adapter.newWriteOnlyTransaction(); - tx.put(LogicalDatastoreType.CONFIGURATION, TEST_PATH, dataNode); - commit(tx); - fail("Expected TransactionCommitFailedException"); - } catch (TransactionCommitFailedException e) { - assertEquals("getMessage", errorMsg, e.getMessage()); - assertEquals("getCause", cause, e.getCause()); - } - } - - @SuppressWarnings("checkstyle:AvoidHidingCauseException") - private static void commit(final DOMDataWriteTransaction tx) - throws TransactionCommitFailedException, InterruptedException, TimeoutException { - try { - tx.commit().get(5, TimeUnit.SECONDS); - } catch (ExecutionException e) { - assertTrue("Expected TransactionCommitFailedException. Actual: " + e.getCause(), - e.getCause() instanceof TransactionCommitFailedException); - throw (TransactionCommitFailedException)e.getCause(); - } - } - - private interface TestDOMStore extends DOMStore, DOMStoreTreeChangePublisher, - org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohortRegistry { - } -} diff --git a/opendaylight/md-sal/sal-dom-spi/pom.xml b/opendaylight/md-sal/sal-dom-spi/pom.xml deleted file mode 100644 index c2ff80a656..0000000000 --- a/opendaylight/md-sal/sal-dom-spi/pom.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - 4.0.0 - - org.opendaylight.controller - mdsal-parent - 1.12.0-SNAPSHOT - ../parent - - - org.opendaylight.controller - sal-core-spi - 1.12.0-SNAPSHOT - bundle - - - - org.opendaylight.controller - sal-core-api - - - org.opendaylight.mdsal - mdsal-dom-spi - - - - - scm:git:http://git.opendaylight.org/gerrit/controller.git - scm:git:ssh://git.opendaylight.org:29418/controller.git - HEAD - https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL - - - diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/broker/spi/mount/SimpleDOMMountPoint.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/broker/spi/mount/SimpleDOMMountPoint.java deleted file mode 100644 index 9ecb09346e..0000000000 --- a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/broker/spi/mount/SimpleDOMMountPoint.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.broker.spi.mount; - -import com.google.common.base.Optional; -import com.google.common.collect.ClassToInstanceMap; -import com.google.common.collect.ImmutableClassToInstanceMap; -import java.util.Map.Entry; -import java.util.Set; -import org.gaul.modernizer_maven_annotations.SuppressModernizer; -import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint; -import org.opendaylight.controller.md.sal.dom.api.DOMService; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -@Deprecated(forRemoval = true) -public final class SimpleDOMMountPoint implements DOMMountPoint { - - private final YangInstanceIdentifier identifier; - private final ClassToInstanceMap services; - private final SchemaContext schemaContext; - - public static SimpleDOMMountPoint create(final YangInstanceIdentifier identifier, - final ClassToInstanceMap services, final SchemaContext ctx) { - return new SimpleDOMMountPoint(identifier, services, ctx); - } - - private SimpleDOMMountPoint(final YangInstanceIdentifier identifier, - final ClassToInstanceMap services, final SchemaContext ctx) { - this.identifier = identifier; - this.services = ImmutableClassToInstanceMap.copyOf(services); - this.schemaContext = ctx; - } - - @Override - public YangInstanceIdentifier getIdentifier() { - return identifier; - } - - @Override - public SchemaContext getSchemaContext() { - return schemaContext; - } - - @Override - @SuppressModernizer - public Optional getService(final Class cls) { - return Optional.fromNullable(services.getInstance(cls)); - } - - public Set, DOMService>> getAllServices() { - return services.entrySet(); - } - - public ClassToInstanceMap getServices() { - return services; - } - - @Override - public int hashCode() { - return identifier.hashCode(); - } - - @Override - public boolean equals(final Object obj) { - return this == obj || obj instanceof DOMMountPoint && identifier.equals(((DOMMountPoint) obj).getIdentifier()); - } -} diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/broker/spi/rpc/RpcRoutingStrategy.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/broker/spi/rpc/RpcRoutingStrategy.java deleted file mode 100644 index d716ae61cc..0000000000 --- a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/broker/spi/rpc/RpcRoutingStrategy.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.broker.spi.rpc; - -import static java.util.Objects.requireNonNull; - -import com.google.common.base.Optional; -import org.gaul.modernizer_maven_annotations.SuppressModernizer; -import org.opendaylight.yangtools.concepts.Identifiable; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; -import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; -import org.opendaylight.yangtools.yang.model.api.RpcDefinition; -import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode; - -@Deprecated(forRemoval = true) -public abstract class RpcRoutingStrategy implements Identifiable { - private static final QName CONTEXT_REFERENCE = QName.create("urn:opendaylight:yang:extension:yang-ext", - "2013-07-09", "context-reference").intern(); - - private final QName identifier; - - private RpcRoutingStrategy(final QName identifier) { - this.identifier = requireNonNull(identifier); - } - - /** - * Returns leaf QName in which RPC Route is stored. - * - * @return leaf QName in which RPC Route is stored - * @throws UnsupportedOperationException If RPC is not content routed. - * ({@link #isContextBasedRouted()} returned false) - */ - public abstract QName getLeaf(); - - /** - * Returns identity QName which represents RPC Routing context. - * - * @return identity QName which represents RPC Routing context - * @throws UnsupportedOperationException If RPC is not content routed. - * ({@link #isContextBasedRouted()} returned false) - */ - public abstract QName getContext(); - - @Override - public final QName getIdentifier() { - return identifier; - } - - /** - * Returns true if RPC is routed by context. - * - * @return true if RPC is routed by content. - */ - public abstract boolean isContextBasedRouted(); - - public static RpcRoutingStrategy from(final RpcDefinition rpc) { - ContainerSchemaNode input = rpc.getInput(); - if (input != null) { - for (DataSchemaNode schemaNode : input.getChildNodes()) { - Optional context = getRoutingContext(schemaNode); - if (context.isPresent()) { - return new RoutedRpcStrategy(rpc.getQName(), context.get(), schemaNode.getQName()); - } - } - } - return new GlobalRpcStrategy(rpc.getQName()); - } - - @SuppressModernizer - public static Optional getRoutingContext(final DataSchemaNode schemaNode) { - for (UnknownSchemaNode extension : schemaNode.getUnknownSchemaNodes()) { - if (CONTEXT_REFERENCE.equals(extension.getNodeType())) { - return Optional.fromNullable(extension.getQName()); - } - } - return Optional.absent(); - } - - private static final class RoutedRpcStrategy extends RpcRoutingStrategy { - private final QName context; - private final QName leaf; - - private RoutedRpcStrategy(final QName identifier, final QName ctx, final QName leaf) { - super(identifier); - this.context = requireNonNull(ctx); - this.leaf = requireNonNull(leaf); - } - - @Override - public QName getContext() { - return context; - } - - @Override - public QName getLeaf() { - return leaf; - } - - @Override - public boolean isContextBasedRouted() { - return true; - } - } - - private static final class GlobalRpcStrategy extends RpcRoutingStrategy { - GlobalRpcStrategy(final QName identifier) { - super(identifier); - } - - @Override - public boolean isContextBasedRouted() { - return false; - } - - @Override - public QName getContext() { - throw new UnsupportedOperationException("Non-routed strategy does not have a context"); - } - - @Override - public QName getLeaf() { - throw new UnsupportedOperationException("Non-routed strategy does not have a context"); - } - } -} diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/AbstractDOMDataTreeChangeListenerRegistration.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/AbstractDOMDataTreeChangeListenerRegistration.java deleted file mode 100644 index 3e865750ba..0000000000 --- a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/AbstractDOMDataTreeChangeListenerRegistration.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.spi; - -import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener; -import org.opendaylight.yangtools.concepts.AbstractListenerRegistration; - -/** - * Abstract implementation of a ListenerRegistration constrained to subclasses - * of {@link DOMDataTreeChangeListener}. - * - * @param type of listener - * @deprecated Use {@link org.opendaylight.mdsal.dom.spi.AbstractDOMDataTreeChangeListenerRegistration} instead. - */ -@Deprecated(forRemoval = true) -public abstract class AbstractDOMDataTreeChangeListenerRegistration - extends AbstractListenerRegistration { - protected AbstractDOMDataTreeChangeListenerRegistration(final T listener) { - super(listener); - } -} diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/AbstractDOMRpcImplementationRegistration.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/AbstractDOMRpcImplementationRegistration.java deleted file mode 100644 index 6b71b02716..0000000000 --- a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/AbstractDOMRpcImplementationRegistration.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.spi; - -import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementation; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementationRegistration; -import org.opendaylight.yangtools.concepts.AbstractObjectRegistration; - -/** - * Abstract base class for {@link DOMRpcImplementationRegistration} implementations. - * @deprecated Use {@link org.opendaylight.mdsal.dom.spi.AbstractDOMRpcImplementationRegistration} instead. - */ -@Deprecated(forRemoval = true) -public abstract class AbstractDOMRpcImplementationRegistration - extends AbstractObjectRegistration implements DOMRpcImplementationRegistration { - protected AbstractDOMRpcImplementationRegistration(final T instance) { - super(instance); - } -} diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/AbstractDOMRpcProviderService.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/AbstractDOMRpcProviderService.java deleted file mode 100644 index 9c1d0dab44..0000000000 --- a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/AbstractDOMRpcProviderService.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.spi; - -import com.google.common.collect.ImmutableSet; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementation; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementationRegistration; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcProviderService; - -/** - * Convenience abstract base class for {@link DOMRpcProviderService} implementations. - * @deprecated Use {@link org.opendaylight.mdsal.dom.spi.AbstractDOMRpcProviderService} instead. - */ -@Deprecated(forRemoval = true) -public abstract class AbstractDOMRpcProviderService implements DOMRpcProviderService { - @Override - public final DOMRpcImplementationRegistration registerRpcImplementation( - final T implementation, final DOMRpcIdentifier... types) { - return registerRpcImplementation(implementation, ImmutableSet.copyOf(types)); - } -} diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/DOMNotificationSubscriptionListener.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/DOMNotificationSubscriptionListener.java deleted file mode 100644 index c556bee94f..0000000000 --- a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/DOMNotificationSubscriptionListener.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.spi; - -import com.google.common.annotations.Beta; -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; - -/** - * Listener which is notified when subscriptions changes and - * provides set of notification types for which currently - * subscriptions are in place. - * - * @deprecated Use {@link org.opendaylight.mdsal.dom.spi.DOMNotificationSubscriptionListener} instead. - */ -@Beta -@Deprecated(forRemoval = true) -@SuppressFBWarnings(value = "NM_SAME_SIMPLE_NAME_AS_INTERFACE", justification = "Migration") -public interface DOMNotificationSubscriptionListener - extends org.opendaylight.mdsal.dom.spi.DOMNotificationSubscriptionListener { -} diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/DOMNotificationSubscriptionListenerRegistry.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/DOMNotificationSubscriptionListenerRegistry.java deleted file mode 100644 index 57c90a8428..0000000000 --- a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/DOMNotificationSubscriptionListenerRegistry.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.spi; - -import com.google.common.annotations.Beta; -import org.opendaylight.yangtools.concepts.ListenerRegistration; - -/** - * Registry of {@link DOMNotificationSubscriptionListener} - * which listens for changes in notification types. - * - * @deprecated Use {@link org.opendaylight.mdsal.dom.spi.DOMNotificationSubscriptionListenerRegistry} instead. - */ -@Deprecated(forRemoval = true) -@Beta -public interface DOMNotificationSubscriptionListenerRegistry { - - ListenerRegistration registerSubscriptionListener(L listener); - -} diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/DefaultDOMRpcResult.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/DefaultDOMRpcResult.java deleted file mode 100644 index a295561686..0000000000 --- a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/DefaultDOMRpcResult.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.spi; - -import static java.util.Objects.requireNonNull; - -import com.google.common.annotations.Beta; -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; -import java.io.Serializable; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.Objects; -import org.eclipse.jdt.annotation.NonNull; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult; -import org.opendaylight.yangtools.concepts.Immutable; -import org.opendaylight.yangtools.yang.common.RpcError; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; - -/** - * Utility class implementing {@link DefaultDOMRpcResult}. - * @deprecated Use {@link org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult} instead. - */ -@Deprecated(forRemoval = true) -@Beta -public final class DefaultDOMRpcResult implements DOMRpcResult, Immutable, Serializable { - private static final long serialVersionUID = 1L; - - // Flagged as "Non-transient non-serializable instance field" - the Collection is Serializable but the RpcError - // interface isn't. In lieu of changing the interface, we assume the implementation is Serializable which is - // reasonable since the only implementation that is actually used is from the RpcResultBuilder. - @SuppressFBWarnings("SE_BAD_FIELD") - private final Collection errors; - - // Unfortunately the NormalizedNode interface isn't Serializable but we assume the implementations are. - @SuppressFBWarnings("SE_BAD_FIELD") - private final NormalizedNode result; - - private static Collection asCollection(final RpcError... errors) { - if (errors.length == 0) { - return Collections.emptyList(); - } else { - return Arrays.asList(errors); - } - } - - public DefaultDOMRpcResult(final NormalizedNode result, final RpcError... errors) { - this(result, asCollection(errors)); - } - - public DefaultDOMRpcResult(final RpcError... errors) { - this(null, asCollection(errors)); - } - - public DefaultDOMRpcResult(final NormalizedNode result) { - this(result, Collections.emptyList()); - } - - public DefaultDOMRpcResult(final NormalizedNode result, - final @NonNull Collection errors) { - this.result = result; - this.errors = requireNonNull(errors); - } - - public DefaultDOMRpcResult(final @NonNull Collection errors) { - this(null, errors); - } - - @Override - public Collection getErrors() { - return errors; - } - - @Override - public NormalizedNode getResult() { - return result; - } - - @Override - public int hashCode() { - int ret = errors.hashCode(); - if (result != null) { - ret = 31 * ret + result.hashCode(); - } - return ret; - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) { - return true; - } - if (!(obj instanceof DefaultDOMRpcResult)) { - return false; - } - - final DefaultDOMRpcResult other = (DefaultDOMRpcResult) obj; - if (!errors.equals(other.errors)) { - return false; - } - return Objects.equals(result, other.result); - } -} diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMDataBroker.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMDataBroker.java deleted file mode 100644 index 1925e5e5b2..0000000000 --- a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMDataBroker.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.spi; - -import com.google.common.collect.ForwardingObject; -import java.util.Map; -import org.eclipse.jdt.annotation.NonNull; -import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener; -import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; -import org.opendaylight.controller.md.sal.dom.api.DOMDataBrokerExtension; -import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction; -import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction; -import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction; -import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain; - -/** - * Utility {@link DOMDataBroker} implementation which forwards all interface - * method invocation to a delegate instance. - * - * @deprecated Use {@link org.opendaylight.mdsal.dom.spi.ForwardingDOMDataBroker} instead. - */ -@Deprecated(forRemoval = true) -public abstract class ForwardingDOMDataBroker extends ForwardingObject implements DOMDataBroker { - @Override - protected abstract @NonNull DOMDataBroker delegate(); - - @Override - public DOMDataReadOnlyTransaction newReadOnlyTransaction() { - return delegate().newReadOnlyTransaction(); - } - - @Override - public DOMDataReadWriteTransaction newReadWriteTransaction() { - return delegate().newReadWriteTransaction(); - } - - @Override - public DOMDataWriteTransaction newWriteOnlyTransaction() { - return delegate().newWriteOnlyTransaction(); - } - - @Override - public DOMTransactionChain createTransactionChain(final TransactionChainListener listener) { - return delegate().createTransactionChain(listener); - } - - @Override - public Map, DOMDataBrokerExtension> getSupportedExtensions() { - return delegate().getSupportedExtensions(); - } -} diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMDataReadOnlyTransaction.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMDataReadOnlyTransaction.java deleted file mode 100644 index d36e6ae35c..0000000000 --- a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMDataReadOnlyTransaction.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.spi; - -import com.google.common.base.Optional; -import com.google.common.collect.ForwardingObject; -import com.google.common.util.concurrent.CheckedFuture; -import org.eclipse.jdt.annotation.NonNull; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; -import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; - -/** - * Utility {@link DOMDataReadOnlyTransaction} implementation which forwards all interface - * method invocation to a delegate instance. - * - * @deprecated Use {@link org.opendaylight.mdsal.dom.spi.ForwardingDOMDataReadOnlyTransaction} instead. - */ -@Deprecated(forRemoval = true) -public abstract class ForwardingDOMDataReadOnlyTransaction extends ForwardingObject - implements DOMDataReadOnlyTransaction { - @Override - protected abstract @NonNull DOMDataReadOnlyTransaction delegate(); - - @Override - public CheckedFuture>, ReadFailedException> read(final LogicalDatastoreType store, - final YangInstanceIdentifier path) { - return delegate().read(store, path); - } - - @Override - public CheckedFuture exists(final LogicalDatastoreType store, - final YangInstanceIdentifier path) { - return delegate().exists(store, path); - } - - @Override - public Object getIdentifier() { - return delegate().getIdentifier(); - } - - @Override - public void close() { - delegate().close(); - } -} diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMDataReadWriteTransaction.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMDataReadWriteTransaction.java deleted file mode 100644 index 7864205dfe..0000000000 --- a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMDataReadWriteTransaction.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.spi; - -import com.google.common.base.Optional; -import com.google.common.collect.ForwardingObject; -import com.google.common.util.concurrent.CheckedFuture; -import com.google.common.util.concurrent.FluentFuture; -import org.eclipse.jdt.annotation.NonNull; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; -import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction; -import org.opendaylight.mdsal.common.api.CommitInfo; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; - -/** - * Utility {@link DOMDataReadWriteTransaction} implementation which forwards all interface - * method invocation to a delegate instance. - * - * @deprecated Use {@link org.opendaylight.mdsal.dom.spi.ForwardingDOMDataReadWriteTransaction} instead. - */ -@Deprecated(forRemoval = true) -public abstract class ForwardingDOMDataReadWriteTransaction extends ForwardingObject - implements DOMDataReadWriteTransaction { - @Override - protected abstract @NonNull DOMDataReadWriteTransaction delegate(); - - @Override - public CheckedFuture>, ReadFailedException> read(final LogicalDatastoreType store, - final YangInstanceIdentifier path) { - return delegate().read(store, path); - } - - @Override - public CheckedFuture exists(final LogicalDatastoreType store, - final YangInstanceIdentifier path) { - return delegate().exists(store, path); - } - - @Override - public Object getIdentifier() { - return delegate().getIdentifier(); - } - - @Override - public void put(final LogicalDatastoreType store, final YangInstanceIdentifier path, - final NormalizedNode data) { - delegate().put(store, path, data); - } - - @Override - public void merge(final LogicalDatastoreType store, final YangInstanceIdentifier path, - final NormalizedNode data) { - delegate().merge(store, path, data); - } - - @Override - public boolean cancel() { - return delegate().cancel(); - } - - @Override - public void delete(final LogicalDatastoreType store, final YangInstanceIdentifier path) { - delegate().delete(store, path); - } - - @Override - public FluentFuture commit() { - return delegate().commit(); - } -} diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMDataWriteTransaction.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMDataWriteTransaction.java deleted file mode 100644 index afefd01bfa..0000000000 --- a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMDataWriteTransaction.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.spi; - -import com.google.common.collect.ForwardingObject; -import com.google.common.util.concurrent.FluentFuture; -import org.eclipse.jdt.annotation.NonNull; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction; -import org.opendaylight.mdsal.common.api.CommitInfo; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; - -/** - * Utility {@link DOMDataWriteTransaction} implementation which forwards all interface - * method invocation to a delegate instance. - * - * @deprecated Use {@link org.opendaylight.mdsal.dom.spi.ForwardingDOMDataWriteTransaction} instead. - */ -@Deprecated(forRemoval = true) -public abstract class ForwardingDOMDataWriteTransaction extends ForwardingObject implements DOMDataWriteTransaction { - @Override - protected abstract @NonNull DOMDataWriteTransaction delegate(); - - @Override - public Object getIdentifier() { - return delegate().getIdentifier(); - } - - @Override - public void put(final LogicalDatastoreType store, final YangInstanceIdentifier path, - final NormalizedNode data) { - delegate().put(store, path, data); - } - - @Override - public void merge(final LogicalDatastoreType store, final YangInstanceIdentifier path, - final NormalizedNode data) { - delegate().merge(store, path, data); - } - - @Override - public boolean cancel() { - return delegate().cancel(); - } - - @Override - public void delete(final LogicalDatastoreType store, final YangInstanceIdentifier path) { - delegate().delete(store, path); - } - - @Override - public FluentFuture commit() { - return delegate().commit(); - } -} diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMNotificationPublishService.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMNotificationPublishService.java deleted file mode 100644 index e3021b115b..0000000000 --- a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMNotificationPublishService.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.spi; - -import com.google.common.collect.ForwardingObject; -import com.google.common.util.concurrent.ListenableFuture; -import java.util.concurrent.TimeUnit; -import org.opendaylight.controller.md.sal.dom.api.DOMNotification; -import org.opendaylight.controller.md.sal.dom.api.DOMNotificationPublishService; - -/** - * Utility implementations of {@link DOMNotificationPublishService} which forwards - * all requests to a delegate instance. - * - * @deprecated Use {@link org.opendaylight.mdsal.dom.spi.ForwardingDOMNotificationPublishService} instead. - */ -@Deprecated(forRemoval = true) -public abstract class ForwardingDOMNotificationPublishService extends ForwardingObject - implements DOMNotificationPublishService { - @Override - protected abstract DOMNotificationPublishService delegate(); - - @Override - public ListenableFuture putNotification(final DOMNotification notification) throws InterruptedException { - return delegate().putNotification(notification); - } - - @Override - public ListenableFuture offerNotification(final DOMNotification notification) { - return delegate().offerNotification(notification); - } - - @Override - public ListenableFuture offerNotification(final DOMNotification notification, final long timeout, - final TimeUnit unit) throws InterruptedException { - return delegate().offerNotification(notification, timeout, unit); - } -} diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMNotificationService.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMNotificationService.java deleted file mode 100644 index 44a10fb21c..0000000000 --- a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMNotificationService.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.spi; - -import com.google.common.collect.ForwardingObject; -import java.util.Collection; -import org.opendaylight.controller.md.sal.dom.api.DOMNotificationListener; -import org.opendaylight.controller.md.sal.dom.api.DOMNotificationService; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; - -/** - * Utility implementation of a {@link DOMNotificationService} which forwards all requests - * to a delegate instance. - * - * @deprecated Use {@link org.opendaylight.mdsal.dom.spi.ForwardingDOMNotificationService} instead. - */ -@Deprecated(forRemoval = true) -public abstract class ForwardingDOMNotificationService extends ForwardingObject implements DOMNotificationService { - @Override - protected abstract DOMNotificationService delegate(); - - @Override - public ListenerRegistration registerNotificationListener(final T listener, - final Collection types) { - return delegate().registerNotificationListener(listener, types); - } - - @Override - public ListenerRegistration registerNotificationListener(final T listener, - final SchemaPath... types) { - return delegate().registerNotificationListener(listener, types); - } -} diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMRpcImplementation.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMRpcImplementation.java deleted file mode 100644 index d6a286a72b..0000000000 --- a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMRpcImplementation.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.spi; - -import com.google.common.collect.ForwardingObject; -import com.google.common.util.concurrent.CheckedFuture; -import org.eclipse.jdt.annotation.NonNull; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcException; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementation; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; - -/** - * Utility implementation which implements {@link DOMRpcImplementation} by forwarding it to - * a backing delegate. - * - * @deprecated Use {@link org.opendaylight.mdsal.dom.spi.ForwardingDOMRpcImplementation} instead. - */ -@Deprecated(forRemoval = true) -public abstract class ForwardingDOMRpcImplementation extends ForwardingObject implements DOMRpcImplementation { - @Override - protected abstract @NonNull DOMRpcImplementation delegate(); - - @Override - public CheckedFuture invokeRpc(final DOMRpcIdentifier type, - final NormalizedNode input) { - return delegate().invokeRpc(type, input); - } -} diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMRpcProviderService.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMRpcProviderService.java deleted file mode 100644 index b71f685e1d..0000000000 --- a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMRpcProviderService.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.spi; - -import com.google.common.collect.ForwardingObject; -import java.util.Set; -import org.eclipse.jdt.annotation.NonNull; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementation; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementationRegistration; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcProviderService; - -/** - * Utility class which implements {@link DOMRpcProviderService} by forwarding - * requests to a backing instance. - * - * @deprecated Use {@link org.opendaylight.mdsal.dom.spi.ForwardingDOMRpcProviderService} instead. - */ -@Deprecated(forRemoval = true) -public abstract class ForwardingDOMRpcProviderService extends ForwardingObject implements DOMRpcProviderService { - @Override - protected abstract @NonNull DOMRpcProviderService delegate(); - - @Override - public DOMRpcImplementationRegistration registerRpcImplementation( - final T implementation, final DOMRpcIdentifier... types) { - return delegate().registerRpcImplementation(implementation, types); - } - - @Override - public DOMRpcImplementationRegistration registerRpcImplementation( - final T implementation, final Set types) { - return delegate().registerRpcImplementation(implementation, types); - } -} diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMRpcResult.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMRpcResult.java deleted file mode 100644 index 86979f00f0..0000000000 --- a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMRpcResult.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.spi; - -import com.google.common.collect.ForwardingObject; -import java.util.Collection; -import org.eclipse.jdt.annotation.NonNull; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult; -import org.opendaylight.yangtools.yang.common.RpcError; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; - -/** - * Utility class which implements {@link DOMRpcResult} by forwarding all methods - * to a backing instance. - * - * @deprecated Use {@link org.opendaylight.mdsal.dom.spi.ForwardingDOMRpcResult} instead. - */ -@Deprecated(forRemoval = true) -public abstract class ForwardingDOMRpcResult extends ForwardingObject implements DOMRpcResult { - @Override - protected abstract @NonNull DOMRpcResult delegate(); - - @Override - public Collection getErrors() { - return delegate().getErrors(); - } - - @Override - public NormalizedNode getResult() { - return delegate().getResult(); - } -} diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMRpcService.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMRpcService.java deleted file mode 100644 index 54cc8bc475..0000000000 --- a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMRpcService.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.spi; - -import com.google.common.collect.ForwardingObject; -import com.google.common.util.concurrent.CheckedFuture; -import org.eclipse.jdt.annotation.NonNull; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcAvailabilityListener; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcException; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcService; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; - -/** - * Utility {@link DOMRpcService} which forwards all requests to a backing delegate instance. - * - * @deprecated Use {@link org.opendaylight.mdsal.dom.spi.ForwardingDOMRpcService} instead. - */ -@Deprecated(forRemoval = true) -public abstract class ForwardingDOMRpcService extends ForwardingObject implements DOMRpcService { - @Override - protected abstract @NonNull DOMRpcService delegate(); - - @Override - public CheckedFuture invokeRpc(final SchemaPath type, - final NormalizedNode input) { - return delegate().invokeRpc(type, input); - } - - @Override - public ListenerRegistration registerRpcListener(final T listener) { - return delegate().registerRpcListener(listener); - } -} diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMTransactionChain.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMTransactionChain.java deleted file mode 100644 index ed4921c1c8..0000000000 --- a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMTransactionChain.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.spi; - -import com.google.common.collect.ForwardingObject; -import org.eclipse.jdt.annotation.NonNull; -import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction; -import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction; -import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction; -import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain; - -/** - * Utility {@link DOMTransactionChain} implementation which forwards all interface - * method invocation to a delegate instance. - * - * @deprecated Use {@link org.opendaylight.mdsal.dom.spi.ForwardingDOMTransactionChain} instead. - */ -@Deprecated(forRemoval = true) -public abstract class ForwardingDOMTransactionChain extends ForwardingObject implements DOMTransactionChain { - @Override - protected abstract @NonNull DOMTransactionChain delegate(); - - @Override - public void close() { - delegate().close(); - } - - @Override - public DOMDataReadOnlyTransaction newReadOnlyTransaction() { - return delegate().newReadOnlyTransaction(); - } - - @Override - public DOMDataReadWriteTransaction newReadWriteTransaction() { - return delegate().newReadWriteTransaction(); - } - - @Override - public DOMDataWriteTransaction newWriteOnlyTransaction() { - return delegate().newWriteOnlyTransaction(); - } -} diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/AbstractDOMStoreTransaction.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/AbstractDOMStoreTransaction.java deleted file mode 100644 index d9eea712c7..0000000000 --- a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/AbstractDOMStoreTransaction.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.core.spi.data; - -import static java.util.Objects.requireNonNull; - -import com.google.common.annotations.Beta; -import com.google.common.base.MoreObjects; -import com.google.common.base.MoreObjects.ToStringHelper; -import org.eclipse.jdt.annotation.NonNull; -import org.eclipse.jdt.annotation.Nullable; - -/** - * Abstract DOM Store Transaction. - * - *

- * Convenience super implementation of DOM Store transaction which provides - * common implementation of {@link #toString()} and {@link #getIdentifier()}. - * - *

- * It can optionally capture the context where it was allocated. - * - * @param identifier type - * @deprecated Use {@link org.opendaylight.mdsal.dom.spi.store.AbstractDOMStoreTransaction} instead. - */ -@Deprecated(forRemoval = true) -@Beta -public abstract class AbstractDOMStoreTransaction implements DOMStoreTransaction { - private final Throwable debugContext; - private final @NonNull T identifier; - - protected AbstractDOMStoreTransaction(final @NonNull T identifier) { - this(identifier, false); - } - - protected AbstractDOMStoreTransaction(final @NonNull T identifier, final boolean debug) { - this.identifier = requireNonNull(identifier, "Identifier must not be null."); - this.debugContext = debug ? new Throwable().fillInStackTrace() : null; - } - - @Override - public final T getIdentifier() { - return identifier; - } - - /** - * Return the context in which this transaction was allocated. - * - * @return The context in which this transaction was allocated, or null if the context was not recorded. - */ - public final @Nullable Throwable getDebugContext() { - return debugContext; - } - - @Override - public final String toString() { - return addToStringAttributes(MoreObjects.toStringHelper(this)).toString(); - } - - /** - * Add class-specific toString attributes. - * - * @param toStringHelper - * ToStringHelper instance - * @return ToStringHelper instance which was passed in - */ - protected ToStringHelper addToStringAttributes(final @NonNull ToStringHelper toStringHelper) { - return toStringHelper.add("id", identifier); - } -} diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/AbstractDOMStoreTreeChangePublisher.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/AbstractDOMStoreTreeChangePublisher.java deleted file mode 100644 index 886331d144..0000000000 --- a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/AbstractDOMStoreTreeChangePublisher.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.core.spi.data; - -import java.util.Collection; -import java.util.List; -import org.eclipse.jdt.annotation.NonNull; -import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener; -import org.opendaylight.controller.md.sal.dom.spi.AbstractDOMDataTreeChangeListenerRegistration; -import org.opendaylight.mdsal.dom.spi.AbstractRegistrationTree; -import org.opendaylight.mdsal.dom.spi.RegistrationTreeNode; -import org.opendaylight.mdsal.dom.spi.RegistrationTreeSnapshot; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; -import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate; -import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode; -import org.opendaylight.yangtools.yang.data.api.schema.tree.ModificationType; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Abstract base class for {@link DOMStoreTreeChangePublisher} implementations. - * - * @deprecated Use {@link org.opendaylight.mdsal.dom.spi.store.AbstractDOMStoreTreeChangePublisher} instead. - */ -@Deprecated(forRemoval = true) -public abstract class AbstractDOMStoreTreeChangePublisher - extends AbstractRegistrationTree> - implements DOMStoreTreeChangePublisher { - private static final Logger LOG = LoggerFactory.getLogger(AbstractDOMStoreTreeChangePublisher.class); - - /** - * Callback for subclass to notify specified registrations of a candidate at a specified path. This method is - * guaranteed to be only called from within {@link #processCandidateTree(DataTreeCandidate)}. - * - * @param registrations Registrations which are affected by the candidate node - * @param path Path of changed candidate node. Guaranteed to match the path specified by the registration - * @param node Candidate node - */ - protected abstract void notifyListeners(@NonNull Collection> - registrations, @NonNull YangInstanceIdentifier path, @NonNull DataTreeCandidateNode node); - - /** - * Callback notifying the subclass that the specified registration is being closed and it's user no longer - * wishes to receive notifications. This notification is invoked while the - * {@link org.opendaylight.yangtools.concepts.ListenerRegistration#close()} - * method is executing. Subclasses can use this callback to properly remove any delayed notifications pending - * towards the registration. - * - * @param registration Registration which is being closed - */ - protected abstract void registrationRemoved(@NonNull AbstractDOMDataTreeChangeListenerRegistration registration); - - /** - * Process a candidate tree with respect to registered listeners. - * - * @param candidate candidate three which needs to be processed - */ - protected final void processCandidateTree(final @NonNull DataTreeCandidate candidate) { - final DataTreeCandidateNode node = candidate.getRootNode(); - if (node.getModificationType() == ModificationType.UNMODIFIED) { - LOG.debug("Skipping unmodified candidate {}", candidate); - return; - } - - try (RegistrationTreeSnapshot> snapshot = takeSnapshot()) { - lookupAndNotify(candidate.getRootPath().getPathArguments(), 0, snapshot.getRootNode(), candidate); - } - } - - @Override - public final AbstractDOMDataTreeChangeListenerRegistration - registerTreeChangeListener(final YangInstanceIdentifier treeId, final L listener) { - // Take the write lock - takeLock(); - try { - final RegistrationTreeNode> node = - findNodeFor(treeId.getPathArguments()); - final AbstractDOMDataTreeChangeListenerRegistration reg = - new AbstractDOMDataTreeChangeListenerRegistration(listener) { - @Override - protected void removeRegistration() { - AbstractDOMStoreTreeChangePublisher.this.removeRegistration(node, this); - registrationRemoved(this); - } - }; - - addRegistration(node, reg); - return reg; - } finally { - // Always release the lock - releaseLock(); - } - } - - private void lookupAndNotify(final List args, final int offset, - final RegistrationTreeNode> node, - final DataTreeCandidate candidate) { - if (args.size() != offset) { - final PathArgument arg = args.get(offset); - - final RegistrationTreeNode> exactChild = - node.getExactChild(arg); - if (exactChild != null) { - lookupAndNotify(args, offset + 1, exactChild, candidate); - } - - for (RegistrationTreeNode> c : - node.getInexactChildren(arg)) { - lookupAndNotify(args, offset + 1, c, candidate); - } - } else { - notifyNode(candidate.getRootPath(), node, candidate.getRootNode()); - } - } - - private void notifyNode(final YangInstanceIdentifier path, - final RegistrationTreeNode> regNode, - final DataTreeCandidateNode candNode) { - if (candNode.getModificationType() == ModificationType.UNMODIFIED) { - LOG.debug("Skipping unmodified candidate {}", path); - return; - } - - final Collection> regs = regNode.getRegistrations(); - if (!regs.isEmpty()) { - notifyListeners(regs, path, candNode); - } - - for (DataTreeCandidateNode candChild : candNode.getChildNodes()) { - if (candChild.getModificationType() != ModificationType.UNMODIFIED) { - final RegistrationTreeNode> regChild = - regNode.getExactChild(candChild.getIdentifier()); - if (regChild != null) { - notifyNode(path.node(candChild.getIdentifier()), regChild, candChild); - } - - for (RegistrationTreeNode> rc : - regNode.getInexactChildren(candChild.getIdentifier())) { - notifyNode(path.node(candChild.getIdentifier()), rc, candChild); - } - } - } - } -} diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/AbstractSnapshotBackedTransactionChain.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/AbstractSnapshotBackedTransactionChain.java deleted file mode 100644 index a06b1b1558..0000000000 --- a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/AbstractSnapshotBackedTransactionChain.java +++ /dev/null @@ -1,305 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.core.spi.data; - -import static com.google.common.base.Preconditions.checkState; -import static java.util.Objects.requireNonNull; - -import com.google.common.annotations.Beta; -import java.util.AbstractMap.SimpleEntry; -import java.util.Map.Entry; -import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; -import org.opendaylight.controller.sal.core.spi.data.SnapshotBackedReadTransaction.TransactionClosePrototype; -import org.opendaylight.controller.sal.core.spi.data.SnapshotBackedWriteTransaction.TransactionReadyPrototype; -import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification; -import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Abstract implementation of the {@link DOMStoreTransactionChain} interface relying on {@link DataTreeSnapshot} - * supplier and backend commit coordinator. - * - * @param transaction identifier type - * @deprecated Use {@link org.opendaylight.mdsal.dom.spi.store.AbstractSnapshotBackedTransactionChain} instead. - */ -@Deprecated(forRemoval = true) -@Beta -public abstract class AbstractSnapshotBackedTransactionChain extends TransactionReadyPrototype - implements DOMStoreTransactionChain, TransactionClosePrototype { - private abstract static class State { - /** - * Allocate a new snapshot. - * - * @return A new snapshot - */ - protected abstract DataTreeSnapshot getSnapshot(Object transactionId); - } - - private static final class Idle extends State { - private final AbstractSnapshotBackedTransactionChain chain; - - Idle(final AbstractSnapshotBackedTransactionChain chain) { - this.chain = requireNonNull(chain); - } - - @Override - protected DataTreeSnapshot getSnapshot(final Object transactionId) { - return chain.takeSnapshot(); - } - } - - /** - * We have a transaction out there. - */ - private static final class Allocated extends State { - private static final AtomicReferenceFieldUpdater SNAPSHOT_UPDATER = - AtomicReferenceFieldUpdater.newUpdater(Allocated.class, DataTreeSnapshot.class, "snapshot"); - private final DOMStoreWriteTransaction transaction; - private volatile DataTreeSnapshot snapshot; - - Allocated(final DOMStoreWriteTransaction transaction) { - this.transaction = requireNonNull(transaction); - } - - public DOMStoreWriteTransaction getTransaction() { - return transaction; - } - - @Override - protected DataTreeSnapshot getSnapshot(final Object transactionId) { - final DataTreeSnapshot ret = snapshot; - checkState(ret != null, - "Could not get snapshot for transaction %s - previous transaction %s is not ready yet", - transactionId, transaction.getIdentifier()); - return ret; - } - - void setSnapshot(final DataTreeSnapshot snapshot) { - final boolean success = SNAPSHOT_UPDATER.compareAndSet(this, null, snapshot); - checkState(success, "Transaction %s has already been marked as ready", transaction.getIdentifier()); - } - } - - /** - * Chain is logically shut down, no further allocation allowed. - */ - private static final class Shutdown extends State { - private final String message; - - Shutdown(final String message) { - this.message = requireNonNull(message); - } - - @Override - protected DataTreeSnapshot getSnapshot(final Object transactionId) { - throw new IllegalStateException(message); - } - } - - @SuppressWarnings("rawtypes") - private static final AtomicReferenceFieldUpdater STATE_UPDATER = - AtomicReferenceFieldUpdater.newUpdater(AbstractSnapshotBackedTransactionChain.class, State.class, "state"); - private static final Logger LOG = LoggerFactory.getLogger(AbstractSnapshotBackedTransactionChain.class); - private static final Shutdown CLOSED = new Shutdown("Transaction chain is closed"); - private static final Shutdown FAILED = new Shutdown("Transaction chain has failed"); - private final Idle idleState; - private volatile State state; - - protected AbstractSnapshotBackedTransactionChain() { - idleState = new Idle(this); - state = idleState; - } - - private Entry getSnapshot(final T transactionId) { - final State localState = state; - return new SimpleEntry<>(localState, localState.getSnapshot(transactionId)); - } - - private boolean recordTransaction(final State expected, final DOMStoreWriteTransaction transaction) { - final State localState = new Allocated(transaction); - return STATE_UPDATER.compareAndSet(this, expected, localState); - } - - @Override - public final DOMStoreReadTransaction newReadOnlyTransaction() { - return newReadOnlyTransaction(nextTransactionIdentifier()); - } - - protected DOMStoreReadTransaction newReadOnlyTransaction(final T transactionId) { - final Entry entry = getSnapshot(transactionId); - return SnapshotBackedTransactions.newReadTransaction(transactionId, getDebugTransactions(), entry.getValue(), - this); - } - - @Override - public void transactionClosed(final SnapshotBackedReadTransaction tx) { - // Defaults to no-op - } - - @Override - public final DOMStoreReadWriteTransaction newReadWriteTransaction() { - return newReadWriteTransaction(nextTransactionIdentifier()); - } - - protected DOMStoreReadWriteTransaction newReadWriteTransaction(final T transactionId) { - Entry entry; - DOMStoreReadWriteTransaction ret; - - do { - entry = getSnapshot(transactionId); - ret = new SnapshotBackedReadWriteTransaction<>(transactionId, getDebugTransactions(), entry.getValue(), - this); - } while (!recordTransaction(entry.getKey(), ret)); - - return ret; - } - - @Override - public final DOMStoreWriteTransaction newWriteOnlyTransaction() { - return newWriteOnlyTransaction(nextTransactionIdentifier()); - } - - protected DOMStoreWriteTransaction newWriteOnlyTransaction(final T transactionId) { - Entry entry; - DOMStoreWriteTransaction ret; - - do { - entry = getSnapshot(transactionId); - ret = new SnapshotBackedWriteTransaction<>(transactionId, getDebugTransactions(), entry.getValue(), this); - } while (!recordTransaction(entry.getKey(), ret)); - - return ret; - } - - @Override - protected final void transactionAborted(final SnapshotBackedWriteTransaction tx) { - final State localState = state; - if (localState instanceof Allocated) { - final Allocated allocated = (Allocated)localState; - if (allocated.getTransaction().equals(tx)) { - final boolean success = STATE_UPDATER.compareAndSet(this, localState, idleState); - if (!success) { - LOG.warn( - "Transaction {} aborted, but chain {} state already transitioned from {} to {}, very strange", - tx, this, localState, state); - } - } - } - } - - @Override - protected final DOMStoreThreePhaseCommitCohort transactionReady( - final SnapshotBackedWriteTransaction tx, - final DataTreeModification tree, - final Exception readyError) { - - final State localState = state; - - if (localState instanceof Allocated) { - final Allocated allocated = (Allocated)localState; - final DOMStoreWriteTransaction transaction = allocated.getTransaction(); - checkState(tx.equals(transaction), "Mis-ordered ready transaction %s last allocated was %s", tx, - transaction); - allocated.setSnapshot(tree); - } else { - LOG.debug("Ignoring transaction {} readiness due to state {}", tx, localState); - } - - return createCohort(tx, tree, readyError); - } - - @Override - public final void close() { - final State localState = state; - - do { - checkState(!CLOSED.equals(localState), "Transaction chain %s has been closed", this); - if (FAILED.equals(localState)) { - LOG.debug("Ignoring user close in failed state"); - return; - } - } while (!STATE_UPDATER.compareAndSet(this, localState, CLOSED)); - } - - /** - * Notify the base logic that a previously-submitted transaction has been committed successfully. - * - * @param transaction Transaction which completed successfully. - */ - protected final void onTransactionCommited(final SnapshotBackedWriteTransaction transaction) { - // If the committed transaction was the one we allocated last, - // we clear it and the ready snapshot, so the next transaction - // allocated refers to the data tree directly. - final State localState = state; - - if (!(localState instanceof Allocated)) { - // This can legally happen if the chain is shut down before the transaction was committed - // by the backend. - LOG.debug("Ignoring successful transaction {} in state {}", transaction, localState); - return; - } - - final Allocated allocated = (Allocated)localState; - final DOMStoreWriteTransaction tx = allocated.getTransaction(); - if (!tx.equals(transaction)) { - LOG.debug("Ignoring non-latest successful transaction {} in state {}", transaction, allocated); - return; - } - - if (!STATE_UPDATER.compareAndSet(this, localState, idleState)) { - LOG.debug("Transaction chain {} has already transitioned from {} to {}, not making it idle", - this, localState, state); - } - } - - /** - * Notify the base logic that a previously-submitted transaction has failed. - * - * @param transaction Transaction which failed. - * @param cause Failure cause - */ - protected final void onTransactionFailed(final SnapshotBackedWriteTransaction transaction, - final Throwable cause) { - LOG.debug("Transaction chain {} failed on transaction {}", this, transaction, cause); - state = FAILED; - } - - /** - * Return the next transaction identifier. - * - * @return transaction identifier. - */ - protected abstract T nextTransactionIdentifier(); - - /** - * Inquire as to whether transactions should record their allocation context. - * - * @return True if allocation context should be recorded. - */ - protected abstract boolean getDebugTransactions(); - - /** - * Take a fresh {@link DataTreeSnapshot} from the backend. - * - * @return A new snapshot. - */ - protected abstract DataTreeSnapshot takeSnapshot(); - - /** - * Create a cohort for driving the transaction through the commit process. - * - * @param transaction Transaction handle - * @param modification {@link DataTreeModification} which needs to be applied to the backend - * @param operationError Any previous error that could be reported through three phase commit - * @return A {@link DOMStoreThreePhaseCommitCohort} cohort. - */ - protected abstract DOMStoreThreePhaseCommitCohort createCohort(SnapshotBackedWriteTransaction transaction, - DataTreeModification modification, - Exception operationError); -} diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/DOMStore.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/DOMStore.java deleted file mode 100644 index e94a73b25c..0000000000 --- a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/DOMStore.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.core.spi.data; - -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; - -/** - * DOM Data Store - * - *

- * DOM Data Store provides transactional tree-like storage for YANG-modeled - * entities described by YANG schema and represented by {@link NormalizedNode}. - * - *

- * Read and write access to stored data is provided only via transactions - * created using {@link #newReadOnlyTransaction()}, - * {@link #newWriteOnlyTransaction()} and {@link #newReadWriteTransaction()}, or - * by creating {@link org.opendaylight.controller.md.sal.common.api.data.TransactionChain}. - * - * @deprecated Use {@link org.opendaylight.mdsal.dom.spi.store.DOMStore} instead. - */ -@Deprecated(forRemoval = true) -public interface DOMStore extends DOMStoreTransactionFactory { - /** - * Creates new transaction chain. - * - *

- * Transactions in a chain need to be committed in sequence and each - * transaction should see the effects of previous transactions as if they - * happened. - * - * @see DOMStoreTransactionChain for more information. - * @return Newly created transaction chain. - */ - DOMStoreTransactionChain createTransactionChain(); -} diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/DOMStoreReadTransaction.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/DOMStoreReadTransaction.java deleted file mode 100644 index 38a4344dab..0000000000 --- a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/DOMStoreReadTransaction.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.core.spi.data; - -import com.google.common.base.Optional; -import com.google.common.util.concurrent.CheckedFuture; -import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; - -@Deprecated(forRemoval = true) -public interface DOMStoreReadTransaction extends DOMStoreTransaction { - - /** - * Reads data from provided logical data store located at provided path. - * - * @param path - * Path which uniquely identifies subtree which client want to - * read - * @return a CheckFuture containing the result of the read. The Future blocks until the - * commit operation is complete. Once complete: - *

    - *
  • If the data at the supplied path exists, the Future returns an Optional object - * containing the data.
  • - *
  • If the data at the supplied path does not exist, the Future returns - * Optional#absent().
  • - *
  • If the read of the data fails, the Future will fail with a - * {@link ReadFailedException} or an exception derived from ReadFailedException.
  • - *
- */ - CheckedFuture>, ReadFailedException> read(YangInstanceIdentifier path); - - /** - * Checks if data is available in the logical data store located at provided path. - * - *

- * Note: a successful result from this method makes no guarantee that a subsequent call to {@link #read} - * will succeed. It is possible that the data resides in a data store on a remote node and, if that - * node goes down or a network failure occurs, a subsequent read would fail. Another scenario is if - * the data is deleted in between the calls to exists and read - * - * @param path - * Path which uniquely identifies subtree which client want to - * check existence of - * @return a CheckFuture containing the result of the check. - *

    - *
  • If the data at the supplied path exists, the Future returns a Boolean - * whose value is true, false otherwise
  • - *
  • If checking for the data fails, the Future will fail with a - * {@link ReadFailedException} or an exception derived from ReadFailedException.
  • - *
- */ - CheckedFuture exists(YangInstanceIdentifier path); -} diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/DOMStoreReadWriteTransaction.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/DOMStoreReadWriteTransaction.java deleted file mode 100644 index 6d798f6654..0000000000 --- a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/DOMStoreReadWriteTransaction.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.core.spi.data; - -/** - * Combination of a {@link DOMStoreReadTransaction} and {@link DOMStoreWriteTransaction}. - * - * @deprecated Use {@link org.opendaylight.mdsal.dom.spi.store.DOMStoreReadWriteTransaction} instead. - */ -@Deprecated(forRemoval = true) -public interface DOMStoreReadWriteTransaction extends DOMStoreReadTransaction, DOMStoreWriteTransaction { - -} diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/DOMStoreThreePhaseCommitCohort.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/DOMStoreThreePhaseCommitCohort.java deleted file mode 100644 index 9a5f1a30c5..0000000000 --- a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/DOMStoreThreePhaseCommitCohort.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.core.spi.data; - -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Interface implemented by the {@link DOMStore} and exposed for each {@link DOMStoreWriteTransaction} - * upon its transition to Ready state. The frontend (DOMStore user) uses this interface to drive the - * commit procedure across potentially multiple DOMStores using the Three-Phase-Commit (3PC) Protocol, - * as described in Three-Phase-Commit Protocol. - * - * @deprecated Use {@link org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort} instead. - */ -@Deprecated(forRemoval = true) -public interface DOMStoreThreePhaseCommitCohort { - - /** - * Sends transaction associated with this three phase commit instance to the - * participant, participant votes on the transaction, if the transaction - * should be committed or aborted. - * - * @return ListenableFuture with vote of the participant. Vote - * {@link ListenableFuture#get()} is following: - *
    - *
  • - * true if transaction is approved by data store. - *
  • false if the transaction is not approved by data store and - * should be aborted. - *
- */ - ListenableFuture canCommit(); - - /** - * Initiates a pre-commit phase of associated transaction on datastore. - * - *

- * This message is valid only and only if and only if the participant responded - * on {@link #canCommit()} call with positive response. - * - * @return ListenableFuture representing acknowledgment for participant - * that pre-commit message was received and processed. - */ - ListenableFuture preCommit(); - - /** - * Initiates a abort phase of associated transaction on data store. - * - * @return ListenableFuture representing acknowledgment for participant - * that abort message was received. - */ - ListenableFuture abort(); - - /** - * Initiates a commit phase on of associated transaction on data store. - * - * @return ListenableFuture representing acknowledgment for participant - * that commit message was received and commit of transaction was - * processed. - */ - ListenableFuture commit(); -} diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/DOMStoreTransaction.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/DOMStoreTransaction.java deleted file mode 100644 index 819fffac47..0000000000 --- a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/DOMStoreTransaction.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.core.spi.data; - -import org.opendaylight.yangtools.concepts.Identifiable; - -/** - * DOM Data Store transaction. - * - * @see DOMStoreReadTransaction - * @see DOMStoreWriteTransaction - * @see DOMStoreReadWriteTransaction - * @deprecated Use {@link org.opendaylight.mdsal.dom.spi.store.DOMStoreTransaction} instead. - */ -@Deprecated(forRemoval = true) -public interface DOMStoreTransaction extends AutoCloseable, Identifiable { - /** - * Unique identifier of the transaction. - */ - @Override - Object getIdentifier(); - - @Override - void close(); -} diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/DOMStoreTransactionChain.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/DOMStoreTransactionChain.java deleted file mode 100644 index 1bb700a390..0000000000 --- a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/DOMStoreTransactionChain.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.core.spi.data; - -/** - * A chain of transactions. Transactions in a chain need to be committed in - * sequence and each transaction must see the effects of previous transactions - * as if they happened. A chain makes no guarantees of atomicity, in fact - * transactions are committed as soon as possible. - * - * @deprecated Use {@link org.opendaylight.mdsal.dom.spi.store.DOMStoreTransactionChain} instead. - */ -@Deprecated(forRemoval = true) -public interface DOMStoreTransactionChain extends DOMStoreTransactionFactory, AutoCloseable { - - /** - * Create a new read only transaction which will continue the chain. The - * previous write transaction has to be either READY or CANCELLED. - * - *

- * If previous write transaction was already commited to data store, new - * read-only transaction is same as obtained via {@link DOMStore#newReadOnlyTransaction()} - * and contains merged result of previous one and current state of data store. - * - *

- * Otherwise read-only transaction presents isolated view as if previous read-write - * transaction was successful. State which was introduced by other transactions - * outside this transaction chain after creation of previous transaction is not visible. - * - * @return New transaction in the chain. - * @throws IllegalStateException - * if the previous transaction was not READY or CANCELLED, or - * if the chain has been closed. - */ - @Override - DOMStoreReadTransaction newReadOnlyTransaction(); - - /** - * Create a new read write transaction which will continue the chain. The - * previous read-write transaction has to be either COMMITED or CANCELLED. - * - *

- * If previous write transaction was already commited to data store, new - * read-write transaction is same as obtained via {@link DOMStore#newReadWriteTransaction()} - * and contains merged result of previous one and current state of data store. - * - *

- * Otherwise read-write transaction presents isolated view as if previous read-write - * transaction was successful. State which was introduced by other transactions - * outside this transaction chain after creation of previous transaction is not visible. - * - * @return New transaction in the chain. - * @throws IllegalStateException - * if the previous transaction was not READY or CANCELLED, or - * if the chain has been closed. - */ - @Override - DOMStoreReadWriteTransaction newReadWriteTransaction(); - - /** - * Create a new write-only transaction which will continue the chain. The - * previous read-write transaction has to be either READY or CANCELLED. - * - * - * @return New transaction in the chain. - * @throws IllegalStateException - * if the previous transaction was not READY or CANCELLED, or - * if the chain has been closed. - */ - @Override - DOMStoreWriteTransaction newWriteOnlyTransaction(); - - /** - * Closes Transaction Chain. - * - *

- * Close method of transaction chain does not guarantee that - * last alocated transaction is ready or was submitted. - * - * @throws IllegalStateException If any of the outstanding created transactions was not canceled or ready. - */ - @Override - void close(); -} diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/DOMStoreTransactionFactory.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/DOMStoreTransactionFactory.java deleted file mode 100644 index 3ccc5e2e6b..0000000000 --- a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/DOMStoreTransactionFactory.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.core.spi.data; - -/** - * Factory for DOM Store Transactions - * - *

- * Factory provides method to construct read-only, read-write and write-only - * transactions, which may be used to retrieve and modify stored information in - * Underlying {@link DOMStore} or {@link DOMStoreTransactionChain}. - * - *

- * See DOMStore, DOMStoreTransactionChain for concrete variations of this factory. - * - *

- * Note: This interface is used only to define common functionality - * between {@link DOMStore} and {@link DOMStoreTransactionChain}, which - * further specify behaviour of returned transactions. - * - * @deprecated Use {@link org.opendaylight.mdsal.dom.spi.store.DOMStoreTransactionFactory} instead. - */ -@Deprecated(forRemoval = true) -public interface DOMStoreTransactionFactory { - - /** - * Creates a read only transaction. - * - *

- * Creates a new read-only transaction, which provides read access to - * snapshot of current state. - * - * @see DOMStoreReadTransaction for more information. - * @return new {@link DOMStoreReadTransaction} - * @throws IllegalStateException - * If state of factory prevents allocating new transaction. - * - */ - DOMStoreReadTransaction newReadOnlyTransaction(); - - /** - * Creates write only transaction. - * - * @see DOMStoreWriteTransaction for more information. - * @return new {@link DOMStoreWriteTransaction} - * @throws IllegalStateException If state of factory prevents allocating new transaction. - */ - DOMStoreWriteTransaction newWriteOnlyTransaction(); - - /** - * Creates Read-Write transaction. - * - * @see DOMStoreReadWriteTransaction for more information. - * @return new {@link DOMStoreWriteTransaction} - * @throws IllegalStateException If state of factory prevents allocating new transaction. - */ - DOMStoreReadWriteTransaction newReadWriteTransaction(); - -} diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/DOMStoreTreeChangePublisher.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/DOMStoreTreeChangePublisher.java deleted file mode 100644 index a353dab2ed..0000000000 --- a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/DOMStoreTreeChangePublisher.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.core.spi.data; - -import org.eclipse.jdt.annotation.NonNull; -import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; - -/** - * Interface implemented by DOMStore implementations which allow registration - * of {@link DOMDataTreeChangeListener} instances. - * - * @deprecated Use {@link org.opendaylight.mdsal.dom.spi.store.DOMStoreTreeChangePublisher} instead. - */ -@Deprecated(forRemoval = true) -public interface DOMStoreTreeChangePublisher { - /** - * Registers a {@link DOMDataTreeChangeListener} to receive - * notifications when data changes under a given path in the conceptual data - * tree. - * - *

- * You are able to register for notifications for any node or subtree - * which can be represented using {@link YangInstanceIdentifier}. - * - *

- * You are able to register for data change notifications for a subtree or leaf - * even if it does not exist. You will receive notification once that node is - * created. - * - *

- * If there is any pre-existing data in data tree on path for which you are - * registering, you will receive initial data change event, which will - * contain all pre-existing data, marked as created. - * - *

- * This method returns a {@link ListenerRegistration} object. To - * "unregister" your listener for changes call the {@link ListenerRegistration#close()} - * method on this returned object. - * - *

- * You MUST explicitly unregister your listener when you no longer want to receive - * notifications. This is especially true in OSGi environments, where failure to - * do so during bundle shutdown can lead to stale listeners being still registered. - * - * @param treeId - * Data tree identifier of the subtree which should be watched for - * changes. - * @param listener - * Listener instance which is being registered - * @return Listener registration object, which may be used to unregister - * your listener using {@link ListenerRegistration#close()} to stop - * delivery of change events. - */ - @NonNull ListenerRegistration registerTreeChangeListener( - @NonNull YangInstanceIdentifier treeId, @NonNull L listener); -} diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/DOMStoreWriteTransaction.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/DOMStoreWriteTransaction.java deleted file mode 100644 index 5d6d99249f..0000000000 --- a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/DOMStoreWriteTransaction.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.core.spi.data; - -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; - -@Deprecated(forRemoval = true) -public interface DOMStoreWriteTransaction extends DOMStoreTransaction { - - /** - * Store a provided data at specified path. This acts as a add / replace - * operation, which is to say that whole subtree will be replaced by - * specified path. - * - *

- * If you need add or merge of current object with specified use - * {@link #merge(YangInstanceIdentifier, NormalizedNode)}. - * - * @param path the path to write - * @param data data object to be written - * @throws IllegalStateException - * if the client code already sealed transaction and invoked - * {@link #ready()} - */ - void write(YangInstanceIdentifier path, NormalizedNode data); - - /** - * Store a provided data at specified path. This acts as a add / replace - * operation, which is to say that whole subtree will be replaced by - * specified path. - * - * @param path the path to write - * @param data data object to be written - * @throws IllegalStateException - * if the client code already sealed transaction and invoked - * {@link #ready()} - */ - void merge(YangInstanceIdentifier path, NormalizedNode data); - - /** - * Deletes data and whole subtree located at provided path. - * - * @param path path to delete - * @throws IllegalStateException - * if the client code already sealed transaction and invoked - * {@link #ready()} - */ - void delete(YangInstanceIdentifier path); - - /** - * Seals transaction, and returns three-phase commit cohort associated - * with this transaction and DOM Store to be coordinated by coordinator. - * - * @return Three Phase Commit Cohort instance for this transaction. - */ - DOMStoreThreePhaseCommitCohort ready(); - -} diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/ForwardingDOMStoreThreePhaseCommitCohort.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/ForwardingDOMStoreThreePhaseCommitCohort.java deleted file mode 100644 index da7c04a326..0000000000 --- a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/ForwardingDOMStoreThreePhaseCommitCohort.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.core.spi.data; - -import com.google.common.annotations.Beta; -import com.google.common.collect.ForwardingObject; -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Abstract base class for {@link DOMStoreThreePhaseCommitCohort} implementations, - * which forward most of their functionality to a backend {@link #delegate()}. - * - * @deprecated Use {@link org.opendaylight.mdsal.dom.spi.store.ForwardingDOMStoreThreePhaseCommitCohort} instead. - */ -@Deprecated(forRemoval = true) -@Beta -public abstract class ForwardingDOMStoreThreePhaseCommitCohort extends ForwardingObject - implements DOMStoreThreePhaseCommitCohort { - @Override - protected abstract DOMStoreThreePhaseCommitCohort delegate(); - - @Override - public ListenableFuture canCommit() { - return delegate().canCommit(); - } - - @Override - public ListenableFuture preCommit() { - return delegate().preCommit(); - } - - @Override - public ListenableFuture abort() { - return delegate().abort(); - } - - @Override - public ListenableFuture commit() { - return delegate().commit(); - } -} diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/SnapshotBackedReadTransaction.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/SnapshotBackedReadTransaction.java deleted file mode 100644 index bb402f8037..0000000000 --- a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/SnapshotBackedReadTransaction.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.core.spi.data; - -import static java.util.Objects.requireNonNull; - -import com.google.common.annotations.Beta; -import com.google.common.base.Optional; -import com.google.common.util.concurrent.CheckedFuture; -import com.google.common.util.concurrent.Futures; -import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; -import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Implementation of read-only transaction backed by {@link DataTreeSnapshot}. - * - *

- * Implementation of read-only transaction backed by {@link DataTreeSnapshot} - * which delegates most of its calls to similar methods provided by underlying snapshot. - * - * @param identifier type - * - * @deprecated Use {@link org.opendaylight.mdsal.dom.spi.store.SnapshotBackedReadTransaction} instead. - */ -@Deprecated(forRemoval = true) -@Beta -public final class SnapshotBackedReadTransaction extends AbstractDOMStoreTransaction - implements DOMStoreReadTransaction { - private static final Logger LOG = LoggerFactory.getLogger(SnapshotBackedReadTransaction.class); - - @SuppressWarnings("rawtypes") - private static final AtomicReferenceFieldUpdater SNAPSHOT_UPDATER = - AtomicReferenceFieldUpdater.newUpdater(SnapshotBackedReadTransaction.class, DataTreeSnapshot.class, - "stableSnapshot"); - - // Guarded by stableSnapshot CAS, hence it does not need to be volatile - private TransactionClosePrototype closeImpl; - private volatile DataTreeSnapshot stableSnapshot; - - /** - * Creates a new read-only transaction. - * - * @param identifier Transaction Identifier - * @param debug Enable transaction debugging - * @param snapshot Snapshot which will be modified. - */ - SnapshotBackedReadTransaction(final T identifier, final boolean debug, final DataTreeSnapshot snapshot, - final TransactionClosePrototype closeImpl) { - super(identifier, debug); - this.stableSnapshot = requireNonNull(snapshot); - this.closeImpl = closeImpl; - LOG.debug("ReadOnly Tx: {} allocated with snapshot {}", identifier, snapshot); - } - - @Override - public void close() { - final DataTreeSnapshot prev = SNAPSHOT_UPDATER.getAndSet(this, null); - if (prev == null) { - LOG.debug("Store transaction: {} : previously closed", getIdentifier()); - return; - } - - LOG.debug("Store transaction: {} : Closed", getIdentifier()); - if (closeImpl != null) { - closeImpl.transactionClosed(this); - closeImpl = null; - } - } - - @Override - @SuppressWarnings("checkstyle:IllegalCatch") - public CheckedFuture>, ReadFailedException> read(final YangInstanceIdentifier path) { - LOG.debug("Tx: {} Read: {}", getIdentifier(), path); - requireNonNull(path, "Path must not be null."); - - final DataTreeSnapshot snapshot = stableSnapshot; - if (snapshot == null) { - return Futures.immediateFailedCheckedFuture(new ReadFailedException("Transaction is closed")); - } - - try { - return Futures.immediateCheckedFuture(Optional.fromJavaUtil(snapshot.readNode(path))); - } catch (RuntimeException e) { - LOG.error("Tx: {} Failed Read of {}", getIdentifier(), path, e); - return Futures.immediateFailedCheckedFuture(new ReadFailedException("Read failed",e)); - } - } - - @Override - public CheckedFuture exists(final YangInstanceIdentifier path) { - LOG.debug("Tx: {} Exists: {}", getIdentifier(), path); - requireNonNull(path, "Path must not be null."); - - try { - return Futures.immediateCheckedFuture(read(path).checkedGet().isPresent()); - } catch (ReadFailedException e) { - return Futures.immediateFailedCheckedFuture(e); - } - } - - /** - * Prototype implementation of {@link SnapshotBackedReadTransaction#close()}. - * - *

- * This class is intended to be implemented by Transaction factories responsible for allocation - * of {@link org.opendaylight.mdsal.dom.spi.store.SnapshotBackedReadTransaction} and - * providing underlying logic for applying implementation. - * - * @param identifier type - */ - public interface TransactionClosePrototype { - /** - * Called when a transaction is closed. This is not invoked at most once for every transaction. - * - * @param tx Transaction which got closed. - */ - void transactionClosed(SnapshotBackedReadTransaction tx); - } -} diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/SnapshotBackedReadWriteTransaction.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/SnapshotBackedReadWriteTransaction.java deleted file mode 100644 index ebfcb57d01..0000000000 --- a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/SnapshotBackedReadWriteTransaction.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.core.spi.data; - -import static java.util.Objects.requireNonNull; - -import com.google.common.annotations.Beta; -import com.google.common.base.Optional; -import com.google.common.util.concurrent.CheckedFuture; -import com.google.common.util.concurrent.Futures; -import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Implementation of Read-Write transaction which is backed by {@link DataTreeSnapshot} - * and executed according to {@link TransactionReadyPrototype}. - * - * @param identifier type - * @deprecated Use {@link org.opendaylight.mdsal.dom.spi.store.SnapshotBackedReadWriteTransaction} instead. - */ -@Deprecated(forRemoval = true) -@Beta -public final class SnapshotBackedReadWriteTransaction extends SnapshotBackedWriteTransaction - implements DOMStoreReadWriteTransaction { - private static final Logger LOG = LoggerFactory.getLogger(SnapshotBackedReadWriteTransaction.class); - - SnapshotBackedReadWriteTransaction(final T identifier, final boolean debug, - final DataTreeSnapshot snapshot, final TransactionReadyPrototype readyImpl) { - super(identifier, debug, snapshot, readyImpl); - } - - @Override - @SuppressWarnings("checkstyle:IllegalCatch") - public CheckedFuture>, ReadFailedException> read(final YangInstanceIdentifier path) { - LOG.debug("Tx: {} Read: {}", getIdentifier(), path); - requireNonNull(path, "Path must not be null."); - - final Optional> result; - try { - result = readSnapshotNode(path); - } catch (RuntimeException e) { - LOG.error("Tx: {} Failed Read of {}", getIdentifier(), path, e); - return Futures.immediateFailedCheckedFuture(new ReadFailedException("Read failed", e)); - } - - if (result == null) { - return Futures.immediateFailedCheckedFuture(new ReadFailedException("Transaction is closed")); - } else { - return Futures.immediateCheckedFuture(result); - } - } - - @Override - public CheckedFuture exists(final YangInstanceIdentifier path) { - try { - return Futures.immediateCheckedFuture( - read(path).checkedGet().isPresent()); - } catch (ReadFailedException e) { - return Futures.immediateFailedCheckedFuture(e); - } - } -} diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/SnapshotBackedTransactions.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/SnapshotBackedTransactions.java deleted file mode 100644 index 86edbfffc8..0000000000 --- a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/SnapshotBackedTransactions.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.core.spi.data; - -import static java.util.Objects.requireNonNull; - -import com.google.common.annotations.Beta; -import org.opendaylight.controller.sal.core.spi.data.SnapshotBackedReadTransaction.TransactionClosePrototype; -import org.opendaylight.controller.sal.core.spi.data.SnapshotBackedWriteTransaction.TransactionReadyPrototype; -import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot; - -/** - * Public utility class for instantiating snapshot-backed transactions. - * - * @deprecated Use {@link org.opendaylight.mdsal.dom.spi.store.SnapshotBackedTransactions} instead. - */ -@Deprecated(forRemoval = true) -@Beta -public final class SnapshotBackedTransactions { - private SnapshotBackedTransactions() { - throw new UnsupportedOperationException("Utility class"); - } - - /** - * Creates a new read-only transaction. - * - * @param identifier Transaction Identifier - * @param debug Enable transaction debugging - * @param snapshot Snapshot which will be modified. - * @return A new read-only transaction - */ - public static SnapshotBackedReadTransaction newReadTransaction(final T identifier, final boolean debug, - final DataTreeSnapshot snapshot) { - return new SnapshotBackedReadTransaction<>(identifier, debug, snapshot, null); - } - - /** - * Creates a new read-only transaction. - * - * @param identifier Transaction Identifier - * @param debug Enable transaction debugging - * @param snapshot Snapshot which will be modified. - * @param closeImpl Implementation of close method - * @return A new read-only transaction - */ - public static SnapshotBackedReadTransaction newReadTransaction(final T identifier, - final boolean debug, final DataTreeSnapshot snapshot, final TransactionClosePrototype closeImpl) { - return new SnapshotBackedReadTransaction<>(identifier, debug, snapshot, requireNonNull(closeImpl)); - } - - /** - * Creates a new read-write transaction. - * - * @param identifier transaction Identifier - * @param debug Enable transaction debugging - * @param snapshot Snapshot which will be modified. - * @param readyImpl Implementation of ready method. - * @return A new read-write transaction - */ - public static SnapshotBackedReadWriteTransaction newReadWriteTransaction(final T identifier, - final boolean debug, final DataTreeSnapshot snapshot, final TransactionReadyPrototype readyImpl) { - return new SnapshotBackedReadWriteTransaction<>(identifier, debug, snapshot, readyImpl); - } - - /** - * Creates a new write-only transaction. - * - * @param identifier transaction Identifier - * @param debug Enable transaction debugging - * @param snapshot Snapshot which will be modified. - * @param readyImpl Implementation of ready method. - * @return A new write transaction - */ - public static SnapshotBackedWriteTransaction newWriteTransaction(final T identifier, final boolean debug, - final DataTreeSnapshot snapshot, final TransactionReadyPrototype readyImpl) { - return new SnapshotBackedWriteTransaction<>(identifier, debug, snapshot, readyImpl); - } -} diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/SnapshotBackedWriteTransaction.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/SnapshotBackedWriteTransaction.java deleted file mode 100644 index b95e3f1cf0..0000000000 --- a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/SnapshotBackedWriteTransaction.java +++ /dev/null @@ -1,213 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.core.spi.data; - -import static com.google.common.base.Preconditions.checkState; -import static java.util.Objects.requireNonNull; - -import com.google.common.annotations.Beta; -import com.google.common.base.MoreObjects.ToStringHelper; -import com.google.common.base.Optional; -import com.google.common.base.Throwables; -import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; -import org.eclipse.jdt.annotation.Nullable; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification; -import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Implementation of Write transaction which is backed by - * {@link DataTreeSnapshot} and executed according to - * {@link org.opendaylight.controller.sal.core.spi.data.SnapshotBackedWriteTransaction.TransactionReadyPrototype}. - * - * @param Identifier type - * @deprecated Use {@link org.opendaylight.mdsal.dom.spi.store.SnapshotBackedWriteTransaction} instead. - */ -@Deprecated(forRemoval = true) -@Beta -public class SnapshotBackedWriteTransaction extends AbstractDOMStoreTransaction - implements DOMStoreWriteTransaction { - private static final Logger LOG = LoggerFactory.getLogger(SnapshotBackedWriteTransaction.class); - @SuppressWarnings("rawtypes") - private static final AtomicReferenceFieldUpdater - READY_UPDATER = AtomicReferenceFieldUpdater.newUpdater(SnapshotBackedWriteTransaction.class, - TransactionReadyPrototype.class, "readyImpl"); - @SuppressWarnings("rawtypes") - private static final AtomicReferenceFieldUpdater - TREE_UPDATER = AtomicReferenceFieldUpdater.newUpdater(SnapshotBackedWriteTransaction.class, - DataTreeModification.class, "mutableTree"); - - // non-null when not ready - private volatile TransactionReadyPrototype readyImpl; - // non-null when not committed/closed - private volatile DataTreeModification mutableTree; - - SnapshotBackedWriteTransaction(final T identifier, final boolean debug, - final DataTreeSnapshot snapshot, final TransactionReadyPrototype readyImpl) { - super(identifier, debug); - this.readyImpl = requireNonNull(readyImpl, "readyImpl must not be null."); - mutableTree = snapshot.newModification(); - LOG.debug("Write Tx: {} allocated with snapshot {}", identifier, snapshot); - } - - @Override - @SuppressWarnings("checkstyle:IllegalCatch") - public void write(final YangInstanceIdentifier path, final NormalizedNode data) { - checkNotReady(); - - final DataTreeModification tree = mutableTree; - LOG.debug("Tx: {} Write: {}:{}", getIdentifier(), path, data); - - try { - tree.write(path, data); - // FIXME: Add checked exception - } catch (RuntimeException e) { - LOG.error("Tx: {}, failed to write {}:{} in {}", getIdentifier(), path, data, tree, e); - // Rethrow original ones if they are subclasses of RuntimeException - // or Error - Throwables.propagateIfPossible(e); - // FIXME: Introduce proper checked exception - throw new IllegalArgumentException("Illegal input data.", e); - } - } - - @Override - @SuppressWarnings("checkstyle:IllegalCatch") - public void merge(final YangInstanceIdentifier path, final NormalizedNode data) { - checkNotReady(); - - final DataTreeModification tree = mutableTree; - LOG.debug("Tx: {} Merge: {}:{}", getIdentifier(), path, data); - - try { - tree.merge(path, data); - // FIXME: Add checked exception - } catch (RuntimeException e) { - LOG.error("Tx: {}, failed to write {}:{} in {}", getIdentifier(), path, data, tree, e); - // Rethrow original ones if they are subclasses of RuntimeException - // or Error - Throwables.propagateIfPossible(e); - // FIXME: Introduce proper checked exception - throw new IllegalArgumentException("Illegal input data.", e); - } - } - - @Override - @SuppressWarnings("checkstyle:IllegalCatch") - public void delete(final YangInstanceIdentifier path) { - checkNotReady(); - - final DataTreeModification tree = mutableTree; - LOG.debug("Tx: {} Delete: {}", getIdentifier(), path); - - try { - tree.delete(path); - // FIXME: Add checked exception - } catch (RuntimeException e) { - LOG.error("Tx: {}, failed to delete {} in {}", getIdentifier(), path, tree, e); - // Rethrow original ones if they are subclasses of RuntimeException - // or Error - Throwables.propagateIfPossible(e); - // FIXME: Introduce proper checked exception - throw new IllegalArgumentException("Illegal path to delete.", e); - } - } - - /** - * Exposed for {@link SnapshotBackedReadWriteTransaction}'s sake only. The contract does - * not allow data access after the transaction has been closed or readied. - * - * @param path Path to read - * @return null if the the transaction has been closed; - */ - final Optional> readSnapshotNode(final YangInstanceIdentifier path) { - return readyImpl == null ? null : Optional.fromJavaUtil(mutableTree.readNode(path)); - } - - private void checkNotReady() { - checkState(readyImpl != null, "Transaction %s is no longer open. No further modifications allowed.", - getIdentifier()); - } - - @Override - @SuppressWarnings("checkstyle:IllegalCatch") - public DOMStoreThreePhaseCommitCohort ready() { - @SuppressWarnings("unchecked") - final TransactionReadyPrototype wasReady = READY_UPDATER.getAndSet(this, null); - checkState(wasReady != null, "Transaction %s is no longer open", getIdentifier()); - - LOG.debug("Store transaction: {} : Ready", getIdentifier()); - - final DataTreeModification tree = mutableTree; - TREE_UPDATER.lazySet(this, null); - try { - tree.ready(); - return wasReady.transactionReady(this, tree, null); - } catch (RuntimeException e) { - LOG.debug("Store transaction: {}: unexpected failure when readying", getIdentifier(), e); - return wasReady.transactionReady(this, tree, e); - } - } - - @Override - public void close() { - @SuppressWarnings("unchecked") - final TransactionReadyPrototype wasReady = READY_UPDATER.getAndSet(this, null); - if (wasReady != null) { - LOG.debug("Store transaction: {} : Closed", getIdentifier()); - TREE_UPDATER.lazySet(this, null); - wasReady.transactionAborted(this); - } else { - LOG.debug("Store transaction: {} : Closed after submit", getIdentifier()); - } - } - - @Override - protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) { - return toStringHelper.add("ready", readyImpl == null); - } - - /** - * This class is intended to be implemented by Transaction factories responsible for allocation of - * {@link org.opendaylight.controller.sal.core.spi.data.SnapshotBackedWriteTransaction} and - * providing underlying logic for applying implementation. - * - * @param identifier type - */ - @Deprecated - public abstract static class TransactionReadyPrototype { - /** - * Called when a transaction is closed without being readied. This is not invoked for - * transactions which are ready. - * - * @param tx Transaction which got aborted. - */ - protected abstract void transactionAborted(SnapshotBackedWriteTransaction tx); - - /** - * Returns a commit coordinator associated with supplied transactions. - * - *

- * This call must not fail. - * - * @param tx - * Transaction on which ready was invoked. - * @param tree - * Modified data tree which has been constructed. - * @param readyError - * Any error that has already happened when readying. - * @return DOMStoreThreePhaseCommitCohort associated with transaction - */ - protected abstract DOMStoreThreePhaseCommitCohort transactionReady(SnapshotBackedWriteTransaction tx, - DataTreeModification tree, - @Nullable Exception readyError); - } -} diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/package-info.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/package-info.java deleted file mode 100644 index 8c8ee3db80..0000000000 --- a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.core.spi.data; \ No newline at end of file diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/statistics/DOMStoreStatsTracker.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/statistics/DOMStoreStatsTracker.java deleted file mode 100644 index 152c37b012..0000000000 --- a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/statistics/DOMStoreStatsTracker.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2014 Brocade Communications Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.sal.core.spi.data.statistics; - -import java.util.concurrent.ExecutorService; -import org.eclipse.jdt.annotation.NonNull; -import org.opendaylight.yangtools.util.concurrent.QueuedNotificationManager; - -/** - * Interface for a class that tracks statistics for a data store. - * - * @author Thomas Pantelis - */ -@Deprecated(forRemoval = true) -public interface DOMStoreStatsTracker { - - /** - * Sets the executor used for DataChangeListener notifications. - * - * @param dclExecutor the executor - */ - void setDataChangeListenerExecutor(@NonNull ExecutorService dclExecutor); - - /** - * Sets the executor used internally by the data store. - * - * @param dsExecutor the executor - */ - void setDataStoreExecutor(@NonNull ExecutorService dsExecutor); - - /** - * Sets the QueuedNotificationManager use for DataChangeListener notifications. - * - * @param manager the manager - */ - void setNotificationManager(@NonNull QueuedNotificationManager manager); -} diff --git a/opendaylight/md-sal/sal-inmemory-datastore/pom.xml b/opendaylight/md-sal/sal-inmemory-datastore/pom.xml deleted file mode 100644 index d3b90d9489..0000000000 --- a/opendaylight/md-sal/sal-inmemory-datastore/pom.xml +++ /dev/null @@ -1,132 +0,0 @@ - - - 4.0.0 - - org.opendaylight.controller - mdsal-parent - 1.12.0-SNAPSHOT - ../parent - - - sal-inmemory-datastore - 1.12.0-SNAPSHOT - bundle - - - - - - org.opendaylight.controller - sal-binding-api - - - - org.opendaylight.controller - sal-common-api - - - - org.opendaylight.controller - sal-common-util - - - - org.opendaylight.controller - sal-core-compat - - - - org.opendaylight.yangtools - concepts - - - - org.opendaylight.yangtools - util - - - - org.opendaylight.mdsal - yang-binding - - - - org.opendaylight.yangtools - yang-data-api - - - org.opendaylight.yangtools - yang-data-impl - - - - org.opendaylight.mdsal - mdsal-dom-inmemory-datastore - - - - org.osgi - org.osgi.core - - - - org.slf4j - slf4j-api - - - - - junit - junit - test - - - org.slf4j - slf4j-simple - test - - - org.opendaylight.mdsal - mdsal-binding-generator-impl - test - - - org.opendaylight.yangtools - mockito-configuration - test - - - org.opendaylight.controller - sal-test-model - test - - - org.opendaylight.yangtools - yang-test-util - - - - - - - org.apache.felix - maven-bundle-plugin - true - - - ${project.groupId}.${project.artifactId} - org.opendaylight.controller.md.sal.dom.store.impl.* - - - - - - - - scm:git:http://git.opendaylight.org/gerrit/controller.git - scm:git:ssh://git.opendaylight.org:29418/controller.git - HEAD - https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL:Architecture:Clustering - - - diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStore.java b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStore.java deleted file mode 100644 index bf3693e5a9..0000000000 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStore.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.store.impl; - -import java.util.concurrent.ExecutorService; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.sal.core.compat.DOMStoreAdapter; -import org.opendaylight.yangtools.concepts.Identifiable; -import org.opendaylight.yangtools.util.concurrent.QueuedNotificationManager; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.opendaylight.yangtools.yang.model.api.SchemaContextListener; - -/** - * In-memory DOM Data Store providing Controller MD-SAL APIs on top of MD-SAL's - * {@link org.opendaylight.mdsal.dom.store.inmemory.InMemoryDOMDataStore}. - * - * @deprecated Please use {@link org.opendaylight.mdsal.dom.store.inmemory.InMemoryDOMDataStore} instead. - */ -@Deprecated(forRemoval = true) -public class InMemoryDOMDataStore - extends DOMStoreAdapter - implements Identifiable, SchemaContextListener, AutoCloseable { - private final org.opendaylight.mdsal.dom.store.inmemory.InMemoryDOMDataStore delegate; - - public InMemoryDOMDataStore(final String name, final ExecutorService dataChangeListenerExecutor) { - this(name, LogicalDatastoreType.OPERATIONAL, dataChangeListenerExecutor, - InMemoryDOMDataStoreConfigProperties.DEFAULT_MAX_DATA_CHANGE_LISTENER_QUEUE_SIZE, false); - } - - public InMemoryDOMDataStore(final String name, final LogicalDatastoreType type, - final ExecutorService dataChangeListenerExecutor, - final int maxDataChangeListenerQueueSize, final boolean debugTransactions) { - delegate = new org.opendaylight.mdsal.dom.store.inmemory.InMemoryDOMDataStore(name, type.toMdsal(), - dataChangeListenerExecutor, maxDataChangeListenerQueueSize, debugTransactions); - } - - @Override - protected org.opendaylight.mdsal.dom.store.inmemory.InMemoryDOMDataStore delegate() { - return delegate; - } - - public void setCloseable(final AutoCloseable closeable) { - delegate.setCloseable(closeable); - } - - public QueuedNotificationManager getDataChangeListenerNotificationManager() { - return delegate.getDataChangeListenerNotificationManager(); - } - - @Override - public final String getIdentifier() { - return delegate.getIdentifier(); - } - - @Override - public void onGlobalContextUpdated(final SchemaContext ctx) { - delegate.onGlobalContextUpdated(ctx); - } - - @Override - public void close() { - delegate.close(); - } - - public final boolean getDebugTransactions() { - return delegate.getDebugTransactions(); - } -} diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStoreConfigProperties.java b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStoreConfigProperties.java deleted file mode 100644 index 0022010169..0000000000 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStoreConfigProperties.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (c) 2014 Brocade Communications Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.store.impl; - -/** - * Holds configuration properties when creating an {@link InMemoryDOMDataStore} instance via the - * {@link InMemoryDOMDataStoreFactory}. - * - * @author Thomas Pantelis - * @see InMemoryDOMDataStoreFactory - * - * @deprecated Use {@link org.opendaylight.mdsal.dom.store.inmemory.InMemoryDOMDataStoreConfigProperties} instead. - */ -@Deprecated(forRemoval = true) -public final class InMemoryDOMDataStoreConfigProperties { - - public static final int DEFAULT_MAX_DATA_CHANGE_EXECUTOR_QUEUE_SIZE = 1000; - public static final int DEFAULT_MAX_DATA_CHANGE_EXECUTOR_POOL_SIZE = 20; - public static final int DEFAULT_MAX_DATA_CHANGE_LISTENER_QUEUE_SIZE = 1000; - public static final int DEFAULT_MAX_DATA_STORE_EXECUTOR_QUEUE_SIZE = 5000; - - private static final InMemoryDOMDataStoreConfigProperties DEFAULT = - create(DEFAULT_MAX_DATA_CHANGE_EXECUTOR_POOL_SIZE, - DEFAULT_MAX_DATA_CHANGE_EXECUTOR_QUEUE_SIZE, - DEFAULT_MAX_DATA_CHANGE_LISTENER_QUEUE_SIZE, - DEFAULT_MAX_DATA_STORE_EXECUTOR_QUEUE_SIZE); - - private final int maxDataChangeExecutorQueueSize; - private final int maxDataChangeExecutorPoolSize; - private final int maxDataChangeListenerQueueSize; - private final int maxDataStoreExecutorQueueSize; - - /** - * Constructs an instance with the given property values. - * - * @param maxDataChangeExecutorPoolSize - * maximum thread pool size for the data change notification executor. - * @param maxDataChangeExecutorQueueSize - * maximum queue size for the data change notification executor. - * @param maxDataChangeListenerQueueSize - * maximum queue size for the data change listeners. - * @param maxDataStoreExecutorQueueSize - * maximum queue size for the data store executor. - */ - public static InMemoryDOMDataStoreConfigProperties create(int maxDataChangeExecutorPoolSize, - int maxDataChangeExecutorQueueSize, int maxDataChangeListenerQueueSize, - int maxDataStoreExecutorQueueSize) { - return new InMemoryDOMDataStoreConfigProperties(maxDataChangeExecutorPoolSize, - maxDataChangeExecutorQueueSize, maxDataChangeListenerQueueSize, - maxDataStoreExecutorQueueSize); - } - - public static InMemoryDOMDataStoreConfigProperties create(int maxDataChangeExecutorPoolSize, - int maxDataChangeExecutorQueueSize, int maxDataChangeListenerQueueSize) { - return new InMemoryDOMDataStoreConfigProperties(maxDataChangeExecutorPoolSize, - maxDataChangeExecutorQueueSize, maxDataChangeListenerQueueSize, - DEFAULT_MAX_DATA_STORE_EXECUTOR_QUEUE_SIZE); - } - - /** - * Returns the InMemoryDOMDataStoreConfigProperties instance with default values. - */ - public static InMemoryDOMDataStoreConfigProperties getDefault() { - return DEFAULT; - } - - private InMemoryDOMDataStoreConfigProperties(int maxDataChangeExecutorPoolSize, - int maxDataChangeExecutorQueueSize, int maxDataChangeListenerQueueSize, - int maxDataStoreExecutorQueueSize) { - this.maxDataChangeExecutorQueueSize = maxDataChangeExecutorQueueSize; - this.maxDataChangeExecutorPoolSize = maxDataChangeExecutorPoolSize; - this.maxDataChangeListenerQueueSize = maxDataChangeListenerQueueSize; - this.maxDataStoreExecutorQueueSize = maxDataStoreExecutorQueueSize; - } - - /** - * Returns the maximum queue size for the data change notification executor. - */ - public int getMaxDataChangeExecutorQueueSize() { - return maxDataChangeExecutorQueueSize; - } - - /** - * Returns the maximum thread pool size for the data change notification executor. - */ - public int getMaxDataChangeExecutorPoolSize() { - return maxDataChangeExecutorPoolSize; - } - - /** - * Returns the maximum queue size for the data change listeners. - */ - public int getMaxDataChangeListenerQueueSize() { - return maxDataChangeListenerQueueSize; - } - - /** - * Returns the maximum queue size for the data store executor. - */ - public int getMaxDataStoreExecutorQueueSize() { - return maxDataStoreExecutorQueueSize; - } -} diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStoreFactory.java b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStoreFactory.java deleted file mode 100644 index 8c4352d72b..0000000000 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStoreFactory.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2014 Brocade Communications Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.store.impl; - -import java.util.concurrent.ExecutorService; -import org.eclipse.jdt.annotation.Nullable; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.mdsal.dom.api.DOMSchemaService; -import org.opendaylight.yangtools.util.concurrent.SpecialExecutors; - -/** - * A factory for creating InMemoryDOMDataStore instances. - * - * @author Thomas Pantelis - * - * @deprecated Use {@link org.opendaylight.mdsal.dom.store.inmemory.InMemoryDOMDataStoreFactory} instead. - */ -@Deprecated(forRemoval = true) -public final class InMemoryDOMDataStoreFactory { - - private InMemoryDOMDataStoreFactory() { - } - - public static InMemoryDOMDataStore create(final String name, final @Nullable DOMSchemaService schemaService) { - return create(name, schemaService, null); - } - - /** - * Creates an InMemoryDOMDataStore instance. - * - * @param name the name of the data store - * @param schemaService the SchemaService to which to register the data store. - * @param properties configuration properties for the InMemoryDOMDataStore instance. If null, - * default property values are used. - * @return an InMemoryDOMDataStore instance - */ - public static InMemoryDOMDataStore create(final String name, final @Nullable DOMSchemaService schemaService, - final @Nullable InMemoryDOMDataStoreConfigProperties properties) { - return create(name, LogicalDatastoreType.OPERATIONAL, schemaService, false, properties); - } - - /** - * Creates an InMemoryDOMDataStore instance. - * - * @param name the name of the data store - * @param type Data store type - * @param schemaService the SchemaService to which to register the data store. - * @param debugTransactions enable transaction debugging - * @param properties configuration properties for the InMemoryDOMDataStore instance. If null, - * default property values are used. - * @return an InMemoryDOMDataStore instance - */ - public static InMemoryDOMDataStore create(final String name, final LogicalDatastoreType type, - final @Nullable DOMSchemaService schemaService, final boolean debugTransactions, - final @Nullable InMemoryDOMDataStoreConfigProperties properties) { - - InMemoryDOMDataStoreConfigProperties actualProperties = properties; - if (actualProperties == null) { - actualProperties = InMemoryDOMDataStoreConfigProperties.getDefault(); - } - - // For DataChangeListener notifications we use an executor that provides the fastest - // task execution time to get higher throughput as DataChangeListeners typically provide - // much of the business logic for a data model. If the executor queue size limit is reached, - // subsequent submitted notifications will block the calling thread. - int dclExecutorMaxQueueSize = actualProperties.getMaxDataChangeExecutorQueueSize(); - int dclExecutorMaxPoolSize = actualProperties.getMaxDataChangeExecutorPoolSize(); - - ExecutorService dataChangeListenerExecutor = SpecialExecutors.newBlockingBoundedFastThreadPool( - dclExecutorMaxPoolSize, dclExecutorMaxQueueSize, name + "-DCL", InMemoryDOMDataStore.class); - - final InMemoryDOMDataStore dataStore = new InMemoryDOMDataStore(name, type, dataChangeListenerExecutor, - actualProperties.getMaxDataChangeListenerQueueSize(), debugTransactions); - - if (schemaService != null) { - schemaService.registerSchemaContextListener(dataStore); - } - - return dataStore; - } -} diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMStoreTreeChangePublisher.java b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMStoreTreeChangePublisher.java deleted file mode 100644 index cac9b0a594..0000000000 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMStoreTreeChangePublisher.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.store.impl; - -import java.util.Collection; -import java.util.Optional; -import java.util.concurrent.ExecutorService; -import org.eclipse.jdt.annotation.NonNull; -import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener; -import org.opendaylight.controller.md.sal.dom.spi.AbstractDOMDataTreeChangeListenerRegistration; -import org.opendaylight.controller.sal.core.spi.data.AbstractDOMStoreTreeChangePublisher; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.util.concurrent.QueuedNotificationManager; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate; -import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode; -import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidates; -import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -final class InMemoryDOMStoreTreeChangePublisher extends AbstractDOMStoreTreeChangePublisher { - private static final Logger LOG = LoggerFactory.getLogger(InMemoryDOMStoreTreeChangePublisher.class); - - private final QueuedNotificationManager, DataTreeCandidate> - notificationManager; - - InMemoryDOMStoreTreeChangePublisher(final ExecutorService listenerExecutor, final int maxQueueSize) { - notificationManager = QueuedNotificationManager.create(listenerExecutor, (listener, notifications) -> { - // FIXME: we are not checking for listener being closed - listener.getInstance().onDataTreeChanged(notifications); - }, maxQueueSize, - "DataTreeChangeListenerQueueMgr"); - } - - private InMemoryDOMStoreTreeChangePublisher(final QueuedNotificationManager< - AbstractDOMDataTreeChangeListenerRegistration, DataTreeCandidate> notificationManager) { - this.notificationManager = notificationManager; - } - - QueuedNotificationManager, DataTreeCandidate> - getNotificationManager() { - return notificationManager; - } - - @Override - protected void notifyListeners(final Collection> registrations, - final YangInstanceIdentifier path, final DataTreeCandidateNode node) { - final DataTreeCandidate candidate = DataTreeCandidates.newDataTreeCandidate(path, node); - - for (AbstractDOMDataTreeChangeListenerRegistration reg : registrations) { - LOG.debug("Enqueueing candidate {} to registration {}", candidate, registrations); - notificationManager.submitNotification(reg, candidate); - } - } - - @Override - protected synchronized void registrationRemoved( - final AbstractDOMDataTreeChangeListenerRegistration registration) { - LOG.debug("Closing registration {}", registration); - - // FIXME: remove the queue for this registration and make sure we clear it - } - - ListenerRegistration registerTreeChangeListener( - final YangInstanceIdentifier treeId, final L listener, final DataTreeSnapshot snapshot) { - final AbstractDOMDataTreeChangeListenerRegistration reg = registerTreeChangeListener(treeId, listener); - - final Optional> 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; - } - - synchronized void publishChange(final @NonNull DataTreeCandidate candidate) { - // Runs synchronized with registrationRemoved() - processCandidateTree(candidate); - } -} diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/jmx/InMemoryDataStoreStats.java b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/jmx/InMemoryDataStoreStats.java deleted file mode 100644 index 7c80fd0282..0000000000 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/jmx/InMemoryDataStoreStats.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2014 Brocade Communications Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.store.impl.jmx; - -import org.opendaylight.controller.md.sal.common.util.jmx.AbstractMXBean; -import org.opendaylight.controller.md.sal.common.util.jmx.QueuedNotificationManagerMXBeanImpl; -import org.opendaylight.controller.md.sal.common.util.jmx.ThreadExecutorStatsMXBeanImpl; -import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore; -import org.opendaylight.yangtools.concepts.AbstractRegistration; -import org.opendaylight.yangtools.util.concurrent.QueuedNotificationManager; - -/** - * Wrapper class for data store MXbeans. - * - * @author Thomas Pantelis - */ -public class InMemoryDataStoreStats extends AbstractRegistration { - - private final AbstractMXBean notificationExecutorStatsBean; - private final QueuedNotificationManagerMXBeanImpl notificationManagerStatsBean; - - public InMemoryDataStoreStats(final String beanType, final QueuedNotificationManager manager) { - - notificationManagerStatsBean = new QueuedNotificationManagerMXBeanImpl(manager, - "notification-manager", beanType, null); - notificationManagerStatsBean.registerMBean(); - - notificationExecutorStatsBean = ThreadExecutorStatsMXBeanImpl.create(manager.getExecutor(), - "notification-executor", beanType, null); - if (notificationExecutorStatsBean != null) { - notificationExecutorStatsBean.registerMBean(); - } - } - - public InMemoryDataStoreStats(final String name, final InMemoryDOMDataStore dataStore) { - this(name, dataStore.getDataChangeListenerNotificationManager()); - } - - @Override - protected void removeRegistration() { - if (notificationExecutorStatsBean != null) { - notificationExecutorStatsBean.unregisterMBean(); - } - - if (notificationManagerStatsBean != null) { - notificationManagerStatsBean.unregisterMBean(); - } - } -} diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/AbstractDataTreeChangeListenerTest.java b/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/AbstractDataTreeChangeListenerTest.java deleted file mode 100644 index 58db9d7dc3..0000000000 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/AbstractDataTreeChangeListenerTest.java +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.store.impl; - -import java.util.Collection; -import java.util.Map; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.opendaylight.controller.md.sal.dom.store.impl.DatastoreTestTask.WriteTransactionCustomizer; -import org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext; -import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.TwoLevelList; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.top.level.list.NestedList; -import org.opendaylight.yangtools.util.concurrent.SpecialExecutors; -import org.opendaylight.yangtools.yang.binding.YangModuleInfo; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates; -import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; -import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; -import org.opendaylight.yangtools.yang.data.api.schema.MapNode; -import org.opendaylight.yangtools.yang.data.api.schema.OrderedMapNode; -import org.opendaylight.yangtools.yang.data.impl.schema.Builders; -import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.CollectionNodeBuilder; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -public abstract class AbstractDataTreeChangeListenerTest { - - protected static final YangInstanceIdentifier TOP_LEVEL = YangInstanceIdentifier - .of(Top.QNAME); - private static final QName NAME_QNAME = QName.create(Top.QNAME, "name"); - protected static final String FOO = "foo"; - protected static final String BAR = "bar"; - protected static final String BAZ = "baz"; - - private InMemoryDOMDataStore datastore; - private SchemaContext schemaContext; - private TestDCLExecutorService dclExecutorService; - - @Before - public final void setup() throws Exception { - final YangModuleInfo moduleInfo = BindingReflections - .getModuleInfo(TwoLevelList.class); - final ModuleInfoBackedContext context = ModuleInfoBackedContext.create(); - context.registerModuleInfo(moduleInfo); - this.schemaContext = context.tryToCreateSchemaContext().get(); - - this.dclExecutorService = new TestDCLExecutorService( - SpecialExecutors.newBlockingBoundedFastThreadPool(1, 10, "DCL", - AbstractDataTreeChangeListenerTest.class)); - - this.datastore = new InMemoryDOMDataStore("TEST", this.dclExecutorService); - this.datastore.onGlobalContextUpdated(this.schemaContext); - } - - @After - public void tearDown() { - if (this.dclExecutorService != null) { - this.dclExecutorService.shutdownNow(); - } - } - - /** - * Create a new test task. The task will operate on the backed database, - * and will use the proper background executor service. - * - * @return Test task initialized to clean up {@value #TOP_LEVEL} and its - * children. - */ - public final DatastoreTestTask newTestTask() { - return new DatastoreTestTask(this.datastore, this.dclExecutorService).cleanup(DatastoreTestTask - .simpleDelete(TOP_LEVEL)); - } - - - public static final YangInstanceIdentifier path(final String topName, - final String nestedName) { - return path(topName).node(NestedList.QNAME).node( - NodeIdentifierWithPredicates.of(NestedList.QNAME, NAME_QNAME, - nestedName)); - } - - public static final YangInstanceIdentifier path(final String topName) { - return TOP_LEVEL.node(TopLevelList.QNAME).node( - NodeIdentifierWithPredicates.of(TopLevelList.QNAME, - NAME_QNAME, topName)); - } - - protected static DataContainerNodeBuilder top() { - return Builders.containerBuilder().withNodeIdentifier( - new NodeIdentifier(Top.QNAME)); - } - - - - protected static void assertEmpty(final Collection set) { - Assert.assertTrue(set.isEmpty()); - } - - protected static void assertEmpty(final Map set) { - Assert.assertTrue(set.isEmpty()); - } - - protected static void assertContains(final Collection set, final K... values) { - for (final K key : values) { - Assert.assertTrue(set.contains(key)); - } - - } - - protected static void assertContains(final Map map, final K... values) { - for (final K key : values) { - Assert.assertTrue(map.containsKey(key)); - } - } - - protected static void assertNotContains(final Collection set, final K... values) { - for (final K key : values) { - Assert.assertFalse(set.contains(key)); - } - } - - protected static void assertNotContains(final Map map, final K... values) { - for (final K key : values) { - Assert.assertFalse(map.containsKey(key)); - } - } - - protected static CollectionNodeBuilder topLevelMap() { - return ImmutableNodes.mapNodeBuilder(TopLevelList.QNAME); - } - - protected static CollectionNodeBuilder nestedMap() { - return Builders.orderedMapBuilder().withNodeIdentifier(new NodeIdentifier(NestedList.QNAME)); - } - - public static DataContainerNodeBuilder topLevelList( - final String key) { - return ImmutableNodes.mapEntryBuilder(TopLevelList.QNAME, NAME_QNAME, - key); - } - - public static DataContainerNodeBuilder nestedList( - final String key) { - return ImmutableNodes - .mapEntryBuilder(NestedList.QNAME, NAME_QNAME, key); - } - - public static final WriteTransactionCustomizer writeOneTopMultipleNested( - final String topName, final String... nestedName) { - final CollectionNodeBuilder nestedMapBuilder = nestedMap(); - for (final String nestedItem : nestedName) { - nestedMapBuilder.addChild(nestedList(nestedItem).build()); - } - - final ContainerNode data = top().addChild( - topLevelMap().addChild( - topLevelList(topName) - .addChild(nestedMapBuilder.build()).build()) - .build()).build(); - - return DatastoreTestTask.simpleWrite(TOP_LEVEL, data); - } - - public static final WriteTransactionCustomizer deleteNested(final String topName, - final String nestedName) { - return DatastoreTestTask.simpleDelete(path(topName, nestedName)); - } -} diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/DatastoreTestTask.java b/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/DatastoreTestTask.java deleted file mode 100644 index 74202a51e4..0000000000 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/DatastoreTestTask.java +++ /dev/null @@ -1,245 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.store.impl; - -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import com.google.common.base.Preconditions; -import com.google.common.util.concurrent.SettableFuture; -import com.google.common.util.concurrent.Uninterruptibles; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; -import java.util.function.Function; -import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener; -import org.opendaylight.controller.sal.core.spi.data.DOMStore; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreTreeChangePublisher; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate; -import org.opendaylight.yangtools.yang.data.api.schema.tree.ModificationType; - -public class DatastoreTestTask { - - private final DOMStore store; - - private WriteTransactionCustomizer setup; - private WriteTransactionCustomizer write; - private ReadTransactionVerifier read; - private WriteTransactionCustomizer cleanup; - private YangInstanceIdentifier changePath; - private DOMStoreTreeChangePublisher storeTreeChangePublisher; - private ChangeEventListener internalListener; - private final TestDCLExecutorService dclExecutorService; - - public DatastoreTestTask(final DOMStore datastore, final TestDCLExecutorService dclExecutorService) { - this.store = datastore; - this.dclExecutorService = dclExecutorService; - } - - @SafeVarargs - public final DatastoreTestTask changeListener(final YangInstanceIdentifier path, - Function... matchers) { - assertTrue(store instanceof DOMStoreTreeChangePublisher); - this.storeTreeChangePublisher = (DOMStoreTreeChangePublisher)store; - this.changePath = path; - this.internalListener = new ChangeEventListener(matchers); - return this; - } - - public static Function added(YangInstanceIdentifier path) { - return candidate -> candidate.getRootNode().getModificationType() == ModificationType.WRITE - && path.equals(candidate.getRootPath()) && !candidate.getRootNode().getDataBefore().isPresent() - && candidate.getRootNode().getDataAfter().isPresent(); - } - - public static Function replaced(YangInstanceIdentifier path) { - return candidate -> candidate.getRootNode().getModificationType() == ModificationType.WRITE - && path.equals(candidate.getRootPath()) && candidate.getRootNode().getDataBefore().isPresent() - && candidate.getRootNode().getDataAfter().isPresent(); - } - - public static Function deleted(YangInstanceIdentifier path) { - return candidate -> candidate.getRootNode().getModificationType() == ModificationType.DELETE - && path.equals(candidate.getRootPath()) && candidate.getRootNode().getDataBefore().isPresent() - && !candidate.getRootNode().getDataAfter().isPresent(); - } - - public static Function subtreeModified(YangInstanceIdentifier path) { - return candidate -> candidate.getRootNode().getModificationType() == ModificationType.SUBTREE_MODIFIED - && path.equals(candidate.getRootPath()) && candidate.getRootNode().getDataBefore().isPresent() - && candidate.getRootNode().getDataAfter().isPresent(); - } - - public DatastoreTestTask setup(final WriteTransactionCustomizer customizer) { - this.setup = customizer; - return this; - } - - public DatastoreTestTask test(final WriteTransactionCustomizer customizer) { - this.write = customizer; - return this; - } - - public DatastoreTestTask read(final ReadTransactionVerifier customizer) { - this.read = customizer; - return this; - } - - public DatastoreTestTask cleanup(final WriteTransactionCustomizer customizer) { - this.cleanup = customizer; - return this; - } - - public void run() throws Exception { - if (setup != null) { - execute(setup); - } - ListenerRegistration registration = null; - if (changePath != null) { - registration = storeTreeChangePublisher.registerTreeChangeListener(changePath, internalListener); - } - - Preconditions.checkState(write != null, "Write Transaction must be set."); - - dclExecutorService.afterTestSetup(); - - execute(write); - if (registration != null) { - // DCL is asynchronous, we need to make sure all tasks are executed before we close the registration, - // otherwise they would get lost - dclExecutorService.shutdown(); - dclExecutorService.awaitTermination(5, TimeUnit.SECONDS); - registration.close(); - } - - if (read != null) { - read.verify(store.newReadOnlyTransaction()); - } - if (cleanup != null) { - execute(cleanup); - } - } - - public void verifyChangeEvents() { - internalListener.verifyChangeEvents(); - } - - public void verifyNoChangeEvent() { - internalListener.verifyNoChangeEvent(); - } - - private void execute(final WriteTransactionCustomizer writeCustomizer) throws InterruptedException, - ExecutionException { - DOMStoreReadWriteTransaction tx = store.newReadWriteTransaction(); - writeCustomizer.customize(tx); - DOMStoreThreePhaseCommitCohort cohort = tx.ready(); - assertTrue(cohort.canCommit().get()); - cohort.preCommit().get(); - cohort.commit().get(); - } - - public interface WriteTransactionCustomizer { - void customize(DOMStoreReadWriteTransaction tx); - } - - public interface ReadTransactionVerifier { - void verify(DOMStoreReadTransaction tx); - } - - private final class ChangeEventListener implements DOMDataTreeChangeListener { - - final SettableFuture> future = SettableFuture.create(); - final Collection accumulatedChanges = new ArrayList<>(); - final Function[] matchers; - final int expChangeCount; - - ChangeEventListener(Function[] matchers) { - this.expChangeCount = matchers.length; - this.matchers = matchers; - } - - Collection changes() { - try { - Collection changes = internalListener.future.get(10, TimeUnit.SECONDS); - Uninterruptibles.sleepUninterruptibly(500, TimeUnit.MILLISECONDS); - return changes; - } catch (TimeoutException e) { - throw new AssertionError(String.format( - "Data tree change notifications not received. Expected: %s. Actual: %s - %s", - expChangeCount, accumulatedChanges.size(), accumulatedChanges), e); - } catch (InterruptedException | ExecutionException e) { - throw new AssertionError("Data tree change notifications failed", e); - } - } - - void verifyChangeEvents() { - Collection changes = new ArrayList<>(changes()); - Iterator iter = changes.iterator(); - while (iter.hasNext()) { - DataTreeCandidate dataTreeModification = iter.next(); - for (Function matcher: matchers) { - if (matcher.apply(dataTreeModification)) { - iter.remove(); - break; - } - } - } - - if (!changes.isEmpty()) { - DataTreeCandidate mod = changes.iterator().next(); - fail(String.format("Received unexpected notification: type: %s, path: %s, before: %s, after: %s", - mod.getRootNode().getModificationType(), mod.getRootPath(), - mod.getRootNode().getDataBefore(), mod.getRootNode().getDataAfter())); - } - } - - void verifyNoChangeEvent() { - try { - Object unexpected = internalListener.future.get(500, TimeUnit.MILLISECONDS); - fail("Got unexpected Data tree change notifications: " + unexpected); - } catch (TimeoutException e) { - // Expected - } catch (InterruptedException | ExecutionException e) { - throw new AssertionError("Data tree change notifications failed", e); - } - } - - @Override - public void onDataTreeChanged(Collection changes) { - synchronized (accumulatedChanges) { - accumulatedChanges.addAll(changes); - if (expChangeCount == accumulatedChanges.size()) { - future.set(new ArrayList<>(accumulatedChanges)); - } - } - } - } - - public static final WriteTransactionCustomizer simpleWrite(final YangInstanceIdentifier path, - final NormalizedNode data) { - return tx -> tx.write(path, data); - } - - public static final WriteTransactionCustomizer simpleMerge(final YangInstanceIdentifier path, - final NormalizedNode data) { - return tx -> tx.merge(path, data); - } - - public static final WriteTransactionCustomizer simpleDelete(final YangInstanceIdentifier path) { - return tx -> tx.delete(path); - } -} diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/DefaultDataTreeChangeListenerTestSuite.java b/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/DefaultDataTreeChangeListenerTestSuite.java deleted file mode 100644 index 2e9204420c..0000000000 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/DefaultDataTreeChangeListenerTestSuite.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.store.impl; - -import org.junit.Test; - -/** - * Base template for a test suite for testing DataTreeChangeListener functionality. - */ -public abstract class DefaultDataTreeChangeListenerTestSuite extends AbstractDataTreeChangeListenerTest { - - protected static final String FOO_SIBLING = "foo-sibling"; - - @Test - public final void putTopLevelOneNested() throws Exception { - - DatastoreTestTask task = newTestTask().test(writeOneTopMultipleNested(FOO, BAR)); - putTopLevelOneNestedSetup(task); - task.run(); - putTopLevelOneNestedVerify(task); - } - - protected abstract void putTopLevelOneNestedSetup(DatastoreTestTask task); - - protected abstract void putTopLevelOneNestedVerify(DatastoreTestTask task); - - @Test - public final void existingTopWriteSibling() throws Exception { - DatastoreTestTask task = newTestTask().setup(writeOneTopMultipleNested(FOO)).test( - tx -> tx.write(path(FOO_SIBLING), topLevelList(FOO_SIBLING).build())); - existingTopWriteSiblingSetup(task); - task.run(); - existingTopWriteSiblingVerify(task); - } - - protected abstract void existingTopWriteSiblingSetup(DatastoreTestTask task); - - protected abstract void existingTopWriteSiblingVerify(DatastoreTestTask task); - - @Test - public final void existingTopWriteTwoNested() throws Exception { - DatastoreTestTask task = newTestTask().setup(writeOneTopMultipleNested(FOO)).test( - tx -> { - tx.write(path(FOO,BAR), nestedList(BAR).build()); - tx.write(path(FOO,BAZ), nestedList(BAZ).build()); - }); - existingTopWriteTwoNestedSetup(task); - task.run(); - existingTopWriteTwoNestedVerify(task); - } - - protected abstract void existingTopWriteTwoNestedSetup(DatastoreTestTask task); - - protected abstract void existingTopWriteTwoNestedVerify(DatastoreTestTask task); - - - @Test - public final void existingOneNestedWriteAdditionalNested() throws Exception { - DatastoreTestTask task = newTestTask().setup(writeOneTopMultipleNested(FOO, BAR)).test( - tx -> tx.write(path(FOO,BAZ), nestedList(BAZ).build())); - existingOneNestedWriteAdditionalNestedSetup(task); - task.run(); - existingOneNestedWriteAdditionalNestedVerify(task); - } - - protected abstract void existingOneNestedWriteAdditionalNestedSetup(DatastoreTestTask task); - - protected abstract void existingOneNestedWriteAdditionalNestedVerify(DatastoreTestTask task); - - @Test - public final void replaceTopLevelNestedChanged() throws Exception { - DatastoreTestTask task = newTestTask().setup(writeOneTopMultipleNested(FOO, BAR)).test( - writeOneTopMultipleNested(FOO, BAZ)); - replaceTopLevelNestedSetup(task); - task.run(); - replaceTopLevelNestedVerify(task); - } - - protected abstract void replaceTopLevelNestedSetup(DatastoreTestTask task); - - protected abstract void replaceTopLevelNestedVerify(DatastoreTestTask task); - - @Test - public final void putTopLevelWithTwoNested() throws Exception { - - DatastoreTestTask task = newTestTask().test(writeOneTopMultipleNested(FOO, BAR, BAZ)); - putTopLevelWithTwoNestedSetup(task); - task.run(); - putTopLevelWithTwoNestedVerify(task); - } - - protected abstract void putTopLevelWithTwoNestedSetup(DatastoreTestTask task); - - protected abstract void putTopLevelWithTwoNestedVerify(DatastoreTestTask task); - - @Test - public final void twoNestedExistsOneIsDeleted() throws Exception { - - DatastoreTestTask task = newTestTask().setup(writeOneTopMultipleNested(FOO, BAR, BAZ)).test( - deleteNested(FOO, BAZ)); - twoNestedExistsOneIsDeletedSetup(task); - task.run(); - twoNestedExistsOneIsDeletedVerify(task); - } - - protected abstract void twoNestedExistsOneIsDeletedSetup(DatastoreTestTask task); - - protected abstract void twoNestedExistsOneIsDeletedVerify(DatastoreTestTask task); - - @Test - public final void nestedListExistsRootDeleted() throws Exception { - - DatastoreTestTask task = newTestTask().cleanup(null).setup(writeOneTopMultipleNested(FOO, BAR, BAZ)) - .test(DatastoreTestTask.simpleDelete(TOP_LEVEL)); - nestedListExistsRootDeletedSetup(task); - task.run(); - nestedListExistsRootDeletedVerify(task); - } - - protected abstract void nestedListExistsRootDeletedSetup(DatastoreTestTask task); - - protected abstract void nestedListExistsRootDeletedVerify(DatastoreTestTask task); -} diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDataStoreTest.java b/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDataStoreTest.java deleted file mode 100644 index 4b80a16385..0000000000 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDataStoreTest.java +++ /dev/null @@ -1,480 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.store.impl; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import com.google.common.base.Optional; -import com.google.common.util.concurrent.CheckedFuture; -import com.google.common.util.concurrent.ListenableFuture; -import com.google.common.util.concurrent.MoreExecutors; -import java.util.concurrent.ExecutionException; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import org.mockito.Mockito; -import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction; -import org.opendaylight.controller.sal.core.spi.data.SnapshotBackedTransactions; -import org.opendaylight.controller.sal.core.spi.data.SnapshotBackedWriteTransaction.TransactionReadyPrototype; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification; -import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot; -import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -public class InMemoryDataStoreTest { - - private SchemaContext schemaContext; - private InMemoryDOMDataStore domStore; - - @Before - public void setupStore() { - domStore = new InMemoryDOMDataStore("TEST", MoreExecutors.newDirectExecutorService()); - schemaContext = TestModel.createTestContext(); - domStore.onGlobalContextUpdated(schemaContext); - } - - @Test - public void testTransactionIsolation() throws InterruptedException, ExecutionException { - - assertNotNull(domStore); - - DOMStoreReadTransaction readTx = domStore.newReadOnlyTransaction(); - assertNotNull(readTx); - - DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction(); - assertNotNull(writeTx); - - /* - * Writes /test in writeTx - */ - NormalizedNode testNode = ImmutableNodes.containerNode(TestModel.TEST_QNAME); - writeTx.write(TestModel.TEST_PATH, testNode); - - /* - * Reads /test from writeTx Read should return container. - */ - ListenableFuture>> writeTxContainer = writeTx.read(TestModel.TEST_PATH); - assertEquals("read: isPresent", true, writeTxContainer.get().isPresent()); - assertEquals("read: data", testNode, writeTxContainer.get().get()); - - /* - * Reads /test from readTx Read should return Absent. - */ - ListenableFuture>> readTxContainer = readTx.read(TestModel.TEST_PATH); - assertEquals("read: isPresent", false, readTxContainer.get().isPresent()); - } - - @Test - public void testTransactionCommit() throws InterruptedException, ExecutionException { - - DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction(); - assertNotNull(writeTx); - - /* - * Writes /test in writeTx - */ - NormalizedNode testNode = ImmutableNodes.containerNode(TestModel.TEST_QNAME); - writeTx.write(TestModel.TEST_PATH, testNode); - - /* - * Reads /test from writeTx Read should return container. - */ - ListenableFuture>> writeTxContainer = writeTx.read(TestModel.TEST_PATH); - assertEquals("read: isPresent", true, writeTxContainer.get().isPresent()); - assertEquals("read: data", testNode, writeTxContainer.get().get()); - - DOMStoreThreePhaseCommitCohort cohort = writeTx.ready(); - - assertThreePhaseCommit(cohort); - - Optional> afterCommitRead = domStore.newReadOnlyTransaction().read(TestModel.TEST_PATH) - .get(); - assertEquals("After commit read: isPresent", true, afterCommitRead.isPresent()); - assertEquals("After commit read: data", testNode, afterCommitRead.get()); - } - - @Test - public void testDelete() throws Exception { - - DOMStoreWriteTransaction writeTx = domStore.newWriteOnlyTransaction(); - assertNotNull(writeTx); - - // Write /test and commit - - writeTx.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME)); - - assertThreePhaseCommit(writeTx.ready()); - - Optional> afterCommitRead = domStore.newReadOnlyTransaction().read(TestModel.TEST_PATH) - .get(); - assertEquals("After commit read: isPresent", true, afterCommitRead.isPresent()); - - // Delete /test and verify - - writeTx = domStore.newWriteOnlyTransaction(); - - writeTx.delete(TestModel.TEST_PATH); - - assertThreePhaseCommit(writeTx.ready()); - - afterCommitRead = domStore.newReadOnlyTransaction().read(TestModel.TEST_PATH).get(); - assertEquals("After commit read: isPresent", false, afterCommitRead.isPresent()); - } - - @Test - public void testMerge() throws Exception { - - DOMStoreWriteTransaction writeTx = domStore.newWriteOnlyTransaction(); - assertNotNull(writeTx); - - ContainerNode containerNode = ImmutableContainerNodeBuilder.create() - .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME)) - .addChild(ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME) - .addChild(ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1)).build()) - .build(); - - writeTx.merge(TestModel.TEST_PATH, containerNode); - - assertThreePhaseCommit(writeTx.ready()); - - Optional> afterCommitRead = domStore.newReadOnlyTransaction().read(TestModel.TEST_PATH) - .get(); - assertEquals("After commit read: isPresent", true, afterCommitRead.isPresent()); - assertEquals("After commit read: data", containerNode, afterCommitRead.get()); - - // Merge a new list entry node - - writeTx = domStore.newWriteOnlyTransaction(); - assertNotNull(writeTx); - - containerNode = ImmutableContainerNodeBuilder.create() - .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME)) - .addChild(ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME) - .addChild(ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1)) - .addChild(ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 2)).build()) - .build(); - - writeTx.merge(TestModel.TEST_PATH, containerNode); - - assertThreePhaseCommit(writeTx.ready()); - - afterCommitRead = domStore.newReadOnlyTransaction().read(TestModel.TEST_PATH).get(); - assertEquals("After commit read: isPresent", true, afterCommitRead.isPresent()); - assertEquals("After commit read: data", containerNode, afterCommitRead.get()); - } - - - @Test - public void testExistsForExistingData() throws Exception { - - DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction(); - assertNotNull(writeTx); - - ContainerNode containerNode = ImmutableContainerNodeBuilder.create() - .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME)) - .addChild(ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME) - .addChild(ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1)).build()) - .build(); - - writeTx.merge(TestModel.TEST_PATH, containerNode); - - CheckedFuture exists = - writeTx.exists(TestModel.TEST_PATH); - - assertEquals(true, exists.checkedGet()); - - DOMStoreThreePhaseCommitCohort ready = writeTx.ready(); - - ready.preCommit().get(); - - ready.commit().get(); - - DOMStoreReadTransaction readTx = domStore.newReadOnlyTransaction(); - assertNotNull(readTx); - - exists = - readTx.exists(TestModel.TEST_PATH); - - assertEquals(true, exists.checkedGet()); - } - - @Test - public void testExistsForNonExistingData() throws Exception { - - DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction(); - assertNotNull(writeTx); - - CheckedFuture exists = - writeTx.exists(TestModel.TEST_PATH); - - assertEquals(false, exists.checkedGet()); - - DOMStoreReadTransaction readTx = domStore.newReadOnlyTransaction(); - assertNotNull(readTx); - - exists = - readTx.exists(TestModel.TEST_PATH); - - assertEquals(false, exists.checkedGet()); - } - - @Test(expected = ReadFailedException.class) - public void testExistsThrowsReadFailedException() throws Exception { - - DOMStoreReadTransaction readTx = domStore.newReadOnlyTransaction(); - assertNotNull(readTx); - - readTx.close(); - - readTx.exists(TestModel.TEST_PATH).checkedGet(); - } - - @Test(expected = ReadFailedException.class) - public void testReadWithReadOnlyTransactionClosed() throws Exception { - - DOMStoreReadTransaction readTx = domStore.newReadOnlyTransaction(); - assertNotNull(readTx); - - readTx.close(); - - doReadAndThrowEx(readTx); - } - - @Test(expected = ReadFailedException.class) - public void testReadWithReadOnlyTransactionFailure() throws Exception { - - DataTreeSnapshot mockSnapshot = Mockito.mock(DataTreeSnapshot.class); - Mockito.doThrow(new RuntimeException("mock ex")).when(mockSnapshot) - .readNode(Mockito.any(YangInstanceIdentifier.class)); - - DOMStoreReadTransaction readTx = SnapshotBackedTransactions.newReadTransaction("1", true, mockSnapshot); - - doReadAndThrowEx(readTx); - } - - @Test(expected = ReadFailedException.class) - public void testReadWithReadWriteTransactionClosed() throws Exception { - - DOMStoreReadTransaction readTx = domStore.newReadWriteTransaction(); - assertNotNull(readTx); - - readTx.close(); - - doReadAndThrowEx(readTx); - } - - @Test(expected = ReadFailedException.class) - public void testReadWithReadWriteTransactionFailure() throws Exception { - - DataTreeSnapshot mockSnapshot = Mockito.mock(DataTreeSnapshot.class); - DataTreeModification mockModification = Mockito.mock(DataTreeModification.class); - Mockito.doThrow(new RuntimeException("mock ex")).when(mockModification) - .readNode(Mockito.any(YangInstanceIdentifier.class)); - Mockito.doReturn(mockModification).when(mockSnapshot).newModification(); - @SuppressWarnings("unchecked") - TransactionReadyPrototype mockReady = Mockito.mock(TransactionReadyPrototype.class); - DOMStoreReadTransaction readTx = SnapshotBackedTransactions.newReadWriteTransaction("1", false, mockSnapshot, - mockReady); - - doReadAndThrowEx(readTx); - } - - private static void doReadAndThrowEx(final DOMStoreReadTransaction readTx) throws ReadFailedException { - readTx.read(TestModel.TEST_PATH).checkedGet(); - } - - @Test(expected = IllegalStateException.class) - public void testWriteWithTransactionReady() { - - DOMStoreWriteTransaction writeTx = domStore.newWriteOnlyTransaction(); - - writeTx.ready(); - - // Should throw ex - writeTx.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME)); - } - - @Test(expected = IllegalStateException.class) - public void testReadyWithTransactionAlreadyReady() { - - DOMStoreWriteTransaction writeTx = domStore.newWriteOnlyTransaction(); - - writeTx.ready(); - - // Should throw ex - writeTx.ready(); - } - - @Test - public void testReadyWithMissingMandatoryData() throws InterruptedException { - DOMStoreWriteTransaction writeTx = domStore.newWriteOnlyTransaction(); - NormalizedNode testNode = ImmutableContainerNodeBuilder.create() - .withNodeIdentifier(new NodeIdentifier(TestModel.MANDATORY_DATA_TEST_QNAME)) - .addChild(ImmutableNodes.leafNode(TestModel.OPTIONAL_QNAME, "data")) - .build(); - writeTx.write(TestModel.MANDATORY_DATA_TEST_PATH, testNode); - DOMStoreThreePhaseCommitCohort ready = writeTx.ready(); - try { - ready.canCommit().get(); - Assert.fail("Expected exception on canCommit"); - } catch (ExecutionException e) { - // nop - } - } - - @Test - public void testTransactionAbort() throws InterruptedException, ExecutionException { - - DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction(); - assertNotNull(writeTx); - - assertTestContainerWrite(writeTx); - - DOMStoreThreePhaseCommitCohort cohort = writeTx.ready(); - - assertTrue(cohort.canCommit().get().booleanValue()); - cohort.preCommit().get(); - cohort.abort().get(); - - Optional> afterCommitRead = domStore.newReadOnlyTransaction().read(TestModel.TEST_PATH) - .get(); - assertFalse(afterCommitRead.isPresent()); - } - - @Test - public void testTransactionChain() throws InterruptedException, ExecutionException { - DOMStoreTransactionChain txChain = domStore.createTransactionChain(); - assertNotNull(txChain); - - /* - * We alocate new read-write transaction and write /test - */ - DOMStoreReadWriteTransaction firstTx = txChain.newReadWriteTransaction(); - assertTestContainerWrite(firstTx); - - /* - * First transaction is marked as ready, we are able to allocate chained - * transactions - */ - final DOMStoreThreePhaseCommitCohort firstWriteTxCohort = firstTx.ready(); - - /* - * We alocate chained transaction - read transaction, note first one is - * still not commited to datastore. - */ - DOMStoreReadTransaction secondReadTx = txChain.newReadOnlyTransaction(); - - /* - * We test if we are able to read data from tx, read should not fail - * since we are using chained transaction. - */ - assertTestContainerExists(secondReadTx); - - /* - * We alocate next transaction, which is still based on first one, but - * is read-write. - */ - DOMStoreReadWriteTransaction thirdDeleteTx = txChain.newReadWriteTransaction(); - - /* - * We test existence of /test in third transaction container should - * still be visible from first one (which is still uncommmited). - */ - assertTestContainerExists(thirdDeleteTx); - - /* - * We delete node in third transaction - */ - thirdDeleteTx.delete(TestModel.TEST_PATH); - - /* - * third transaction is sealed. - */ - DOMStoreThreePhaseCommitCohort thirdDeleteTxCohort = thirdDeleteTx.ready(); - - /* - * We commit first transaction - */ - assertThreePhaseCommit(firstWriteTxCohort); - - // Alocates store transacion - DOMStoreReadTransaction storeReadTx = domStore.newReadOnlyTransaction(); - - /* - * We verify transaction is commited to store, container should exists - * in datastore. - */ - assertTestContainerExists(storeReadTx); - - /* - * We commit third transaction - */ - assertThreePhaseCommit(thirdDeleteTxCohort); - } - - @Test - @Ignore - public void testTransactionConflict() throws InterruptedException, ExecutionException { - DOMStoreReadWriteTransaction txOne = domStore.newReadWriteTransaction(); - DOMStoreReadWriteTransaction txTwo = domStore.newReadWriteTransaction(); - assertTestContainerWrite(txOne); - assertTestContainerWrite(txTwo); - - /* - * Commits transaction - */ - assertThreePhaseCommit(txOne.ready()); - - /* - * Asserts that txTwo could not be commited - */ - assertFalse(txTwo.ready().canCommit().get()); - } - - private static void assertThreePhaseCommit(final DOMStoreThreePhaseCommitCohort cohort) - throws InterruptedException, ExecutionException { - assertTrue(cohort.canCommit().get().booleanValue()); - cohort.preCommit().get(); - cohort.commit().get(); - } - - private static Optional> assertTestContainerWrite(final DOMStoreReadWriteTransaction writeTx) - throws InterruptedException, ExecutionException { - /* - * Writes /test in writeTx - */ - writeTx.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME)); - - return assertTestContainerExists(writeTx); - } - - /** - * Reads /test from readTx Read should return container. - */ - private static Optional> assertTestContainerExists(final DOMStoreReadTransaction readTx) - throws InterruptedException, ExecutionException { - - ListenableFuture>> writeTxContainer = readTx.read(TestModel.TEST_PATH); - assertTrue(writeTxContainer.get().isPresent()); - return writeTxContainer.get(); - } -} diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/RootScopeSubtreeTest.java b/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/RootScopeSubtreeTest.java deleted file mode 100644 index c5af4067fc..0000000000 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/RootScopeSubtreeTest.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.store.impl; - -import static org.opendaylight.controller.md.sal.dom.store.impl.DatastoreTestTask.added; -import static org.opendaylight.controller.md.sal.dom.store.impl.DatastoreTestTask.deleted; -import static org.opendaylight.controller.md.sal.dom.store.impl.DatastoreTestTask.replaced; -import static org.opendaylight.controller.md.sal.dom.store.impl.DatastoreTestTask.subtreeModified; - -public class RootScopeSubtreeTest extends DefaultDataTreeChangeListenerTestSuite { - - @Override - protected void putTopLevelOneNestedSetup(final DatastoreTestTask task) { - task.changeListener(TOP_LEVEL, added(TOP_LEVEL)); - } - - @Override - protected void putTopLevelOneNestedVerify(final DatastoreTestTask task) { - task.verifyChangeEvents(); - } - - @Override - protected void replaceTopLevelNestedSetup(DatastoreTestTask task) { - task.changeListener(TOP_LEVEL, added(TOP_LEVEL), replaced(TOP_LEVEL)); - } - - @Override - protected void replaceTopLevelNestedVerify(final DatastoreTestTask task) { - task.verifyChangeEvents(); - } - - @Override - protected void putTopLevelWithTwoNestedSetup(final DatastoreTestTask task) { - task.changeListener(TOP_LEVEL, added(TOP_LEVEL)); - } - - @Override - protected void putTopLevelWithTwoNestedVerify(final DatastoreTestTask task) { - task.verifyChangeEvents(); - } - - @Override - protected void twoNestedExistsOneIsDeletedSetup(DatastoreTestTask task) { - task.changeListener(TOP_LEVEL, added(TOP_LEVEL), subtreeModified(TOP_LEVEL)); - } - - @Override - protected void twoNestedExistsOneIsDeletedVerify(final DatastoreTestTask task) { - task.verifyChangeEvents(); - } - - @Override - protected void nestedListExistsRootDeletedSetup(DatastoreTestTask task) { - task.changeListener(TOP_LEVEL, added(TOP_LEVEL), deleted(TOP_LEVEL)); - } - - @Override - protected void nestedListExistsRootDeletedVerify(final DatastoreTestTask task) { - task.verifyChangeEvents(); - } - - @Override - protected void existingOneNestedWriteAdditionalNestedSetup(DatastoreTestTask task) { - task.changeListener(TOP_LEVEL, added(TOP_LEVEL), subtreeModified(TOP_LEVEL)); - } - - @Override - protected void existingOneNestedWriteAdditionalNestedVerify(final DatastoreTestTask task) { - task.verifyChangeEvents(); - } - - @Override - protected void existingTopWriteTwoNestedSetup(DatastoreTestTask task) { - task.changeListener(TOP_LEVEL, added(TOP_LEVEL), subtreeModified(TOP_LEVEL)); - } - - @Override - protected void existingTopWriteTwoNestedVerify(final DatastoreTestTask task) { - task.verifyChangeEvents(); - } - - @Override - protected void existingTopWriteSiblingSetup(DatastoreTestTask task) { - task.changeListener(TOP_LEVEL, added(TOP_LEVEL), subtreeModified(TOP_LEVEL)); - } - - @Override - protected void existingTopWriteSiblingVerify(final DatastoreTestTask task) { - task.verifyChangeEvents(); - } -} diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/SchemaUpdateForTransactionTest.java b/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/SchemaUpdateForTransactionTest.java deleted file mode 100644 index 3054e93b92..0000000000 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/SchemaUpdateForTransactionTest.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.store.impl; - -import static org.junit.Assert.assertNotNull; - -import com.google.common.util.concurrent.MoreExecutors; -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction; -import org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext; -import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.bi.ba.rpcservice.rev140701.RockTheHouseInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top; -import org.opendaylight.yangtools.yang.binding.YangModuleInfo; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -public class SchemaUpdateForTransactionTest { - - private static final YangInstanceIdentifier TOP_PATH = YangInstanceIdentifier.of(Top.QNAME); - private SchemaContext schemaContext; - private InMemoryDOMDataStore domStore; - - @Before - public void setupStore() throws Exception { - this.domStore = new InMemoryDOMDataStore("TEST", MoreExecutors.newDirectExecutorService()); - loadSchemas(RockTheHouseInput.class); - } - - public void loadSchemas(final Class... classes) throws Exception { - final ModuleInfoBackedContext context = ModuleInfoBackedContext.create(); - for (final Class clz : classes) { - YangModuleInfo moduleInfo = BindingReflections.getModuleInfo(clz); - - context.registerModuleInfo(moduleInfo); - } - this.schemaContext = context.tryToCreateSchemaContext().get(); - this.domStore.onGlobalContextUpdated(this.schemaContext); - } - - /** - * Test suite tests allocating transaction when schema context - * does not contain module necessary for client write, - * then triggering update of global schema context - * and then performing write (according to new module). - * - *

- * If transaction between allocation and schema context was - * unmodified, it is safe to change its schema context - * to new one (e.g. it will be same as if allocated after - * schema context update.) - */ - @Test - public void testTransactionSchemaUpdate() throws Exception { - - assertNotNull(this.domStore); - - // We allocate transaction, initial schema context does not - // contain Lists model - final DOMStoreReadWriteTransaction writeTx = this.domStore.newReadWriteTransaction(); - assertNotNull(writeTx); - - // we trigger schema context update to contain Lists model - loadSchemas(RockTheHouseInput.class, Top.class); - - /* - * Writes /test in writeTx, this write should not fail - * with IllegalArgumentException since /test is in - * schema context. - */ - writeTx.write(TOP_PATH, ImmutableNodes.containerNode(Top.QNAME)); - } -} diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/TestDCLExecutorService.java b/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/TestDCLExecutorService.java deleted file mode 100644 index cbeff79d12..0000000000 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/TestDCLExecutorService.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2014 Brocade Communications Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.md.sal.dom.store.impl; - -import com.google.common.util.concurrent.ForwardingExecutorService; -import com.google.common.util.concurrent.MoreExecutors; -import java.util.concurrent.ExecutorService; - -/** - * A forwarding Executor used by unit tests for DataChangeListener notifications. - * - * @author Thomas Pantelis - */ -public class TestDCLExecutorService extends ForwardingExecutorService { - - // Start with a same thread executor to avoid timing issues during test setup. - private volatile ExecutorService currentExecutor = MoreExecutors.newDirectExecutorService(); - - // The real executor to use when test setup is complete. - private final ExecutorService postSetupExecutor; - - - public TestDCLExecutorService(final ExecutorService postSetupExecutor) { - this.postSetupExecutor = postSetupExecutor; - } - - @Override - protected ExecutorService delegate() { - return currentExecutor; - } - - public void afterTestSetup() { - // Test setup complete - switch to the real executor. - currentExecutor = postSetupExecutor; - } -} diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/TestModel.java b/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/TestModel.java deleted file mode 100644 index 8e36a8c377..0000000000 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/TestModel.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.store.impl; - -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; - -public final class TestModel { - - public static final QName TEST_QNAME = - QName.create("urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test", "2014-03-13", "test"); - public static final QName OUTER_LIST_QNAME = QName.create(TEST_QNAME, "outer-list"); - public static final QName INNER_LIST_QNAME = QName.create(TEST_QNAME, "inner-list"); - public static final QName OUTER_CHOICE_QNAME = QName.create(TEST_QNAME, "outer-choice"); - public static final QName ID_QNAME = QName.create(TEST_QNAME, "id"); - public static final QName NAME_QNAME = QName.create(TEST_QNAME, "name"); - public static final QName VALUE_QNAME = QName.create(TEST_QNAME, "value"); - public static final QName TWO_QNAME = QName.create(TEST_QNAME, "two"); - public static final QName THREE_QNAME = QName.create(TEST_QNAME, "three"); - public static final YangInstanceIdentifier TEST_PATH = YangInstanceIdentifier.of(TEST_QNAME); - public static final YangInstanceIdentifier OUTER_LIST_PATH = - YangInstanceIdentifier.builder(TEST_PATH).node(OUTER_LIST_QNAME).build(); - - public static final QName MANDATORY_DATA_TEST_QNAME = - QName.create("urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test", - "2014-03-13", - "mandatory-data-test"); - public static final QName OPTIONAL_QNAME = QName.create(MANDATORY_DATA_TEST_QNAME, "optional-data"); - public static final QName MANDATORY_QNAME = QName.create(MANDATORY_DATA_TEST_QNAME, "mandatory-data"); - public static final YangInstanceIdentifier MANDATORY_DATA_TEST_PATH = - YangInstanceIdentifier.of(MANDATORY_DATA_TEST_QNAME); - - private static final String DATASTORE_TEST_YANG = "/odl-datastore-test.yang"; - - private TestModel() { - } - - public static SchemaContext createTestContext() { - return YangParserTestUtils.parseYangResource(DATASTORE_TEST_YANG); - } -} diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/WildcardedScopeBaseTest.java b/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/WildcardedScopeBaseTest.java deleted file mode 100644 index 23c35f3ed3..0000000000 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/WildcardedScopeBaseTest.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.store.impl; - -import static org.opendaylight.controller.md.sal.dom.store.impl.DatastoreTestTask.added; -import static org.opendaylight.controller.md.sal.dom.store.impl.DatastoreTestTask.deleted; -import static org.opendaylight.controller.md.sal.dom.store.impl.DatastoreTestTask.replaced; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; - -public class WildcardedScopeBaseTest extends DefaultDataTreeChangeListenerTestSuite { - - private static final YangInstanceIdentifier TOP_LEVEL_LIST_ALL = TOP_LEVEL.node(TopLevelList.QNAME).node( - TopLevelList.QNAME); - - @Override - protected void putTopLevelOneNestedSetup(final DatastoreTestTask task) { - task.changeListener(TOP_LEVEL_LIST_ALL, added(path(FOO))); - } - - @Override - protected void putTopLevelOneNestedVerify(final DatastoreTestTask task) { - task.verifyChangeEvents(); - } - - @Override - protected void replaceTopLevelNestedSetup(DatastoreTestTask task) { - task.changeListener(TOP_LEVEL_LIST_ALL, added(path(FOO)), replaced(path(FOO))); - } - - @Override - protected void replaceTopLevelNestedVerify(final DatastoreTestTask task) { - task.verifyChangeEvents(); - } - - @Override - protected void putTopLevelWithTwoNestedSetup(final DatastoreTestTask task) { - task.changeListener(TOP_LEVEL_LIST_ALL, added(path(FOO))); - } - - @Override - protected void putTopLevelWithTwoNestedVerify(final DatastoreTestTask task) { - task.verifyChangeEvents(); - } - - @Override - protected void twoNestedExistsOneIsDeletedSetup(DatastoreTestTask task) { - task.changeListener(TOP_LEVEL_LIST_ALL, added(path(FOO))); - } - - @Override - protected void twoNestedExistsOneIsDeletedVerify(final DatastoreTestTask task) { - task.verifyChangeEvents(); - } - - @Override - protected void nestedListExistsRootDeletedSetup(DatastoreTestTask task) { - task.changeListener(TOP_LEVEL_LIST_ALL, added(path(FOO)), deleted(path(FOO))); - } - - @Override - protected void nestedListExistsRootDeletedVerify(final DatastoreTestTask task) { - task.verifyChangeEvents(); - } - - @Override - protected void existingOneNestedWriteAdditionalNestedSetup(DatastoreTestTask task) { - task.changeListener(TOP_LEVEL_LIST_ALL, added(path(FOO))); - } - - @Override - protected void existingOneNestedWriteAdditionalNestedVerify(final DatastoreTestTask task) { - task.verifyChangeEvents(); - } - - @Override - protected void existingTopWriteTwoNestedSetup(DatastoreTestTask task) { - task.changeListener(TOP_LEVEL_LIST_ALL, added(path(FOO))); - } - - @Override - protected void existingTopWriteTwoNestedVerify(final DatastoreTestTask task) { - task.verifyChangeEvents(); - } - - @Override - protected void existingTopWriteSiblingSetup(DatastoreTestTask task) { - task.changeListener(TOP_LEVEL_LIST_ALL, added(path(FOO)), added(path(FOO_SIBLING))); - } - - @Override - protected void existingTopWriteSiblingVerify(final DatastoreTestTask task) { - task.verifyChangeEvents(); - } -} diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/test/resources/odl-datastore-test.yang b/opendaylight/md-sal/sal-inmemory-datastore/src/test/resources/odl-datastore-test.yang deleted file mode 100644 index ffc8fe07c8..0000000000 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/test/resources/odl-datastore-test.yang +++ /dev/null @@ -1,56 +0,0 @@ -module odl-datastore-test { - yang-version 1; - namespace "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test"; - prefix "store-test"; - - revision "2014-03-13" { - description "Initial revision."; - } - - container test { - presence "needs to be present when empty"; - - list outer-list { - key id; - leaf id { - type uint16; - } - choice outer-choice { - case one { - leaf one { - type string; - } - } - case two-three { - leaf two { - type string; - } - leaf three { - type string; - } - } - } - list inner-list { - key name; - leaf name { - type string; - } - leaf value { - type string; - } - } - } - } - - container mandatory-data-test { - presence "needs to be present when empty"; - - leaf optional-data { - type string; - } - leaf mandatory-data { - type string; - mandatory true; - } - } -} diff --git a/opendaylight/md-sal/sal-remoterpc-connector/pom.xml b/opendaylight/md-sal/sal-remoterpc-connector/pom.xml index c868a2e185..65129df37d 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/pom.xml +++ b/opendaylight/md-sal/sal-remoterpc-connector/pom.xml @@ -56,10 +56,6 @@ org.opendaylight.mdsal mdsal-dom-spi - - org.opendaylight.controller - sal-common-impl - org.opendaylight.controller sal-clustering-commons diff --git a/opendaylight/md-sal/samples/clustering-test-app/provider/pom.xml b/opendaylight/md-sal/samples/clustering-test-app/provider/pom.xml index 11f81e7e21..4bf4ccda74 100644 --- a/opendaylight/md-sal/samples/clustering-test-app/provider/pom.xml +++ b/opendaylight/md-sal/samples/clustering-test-app/provider/pom.xml @@ -27,12 +27,12 @@ clustering-it-model - org.opendaylight.controller - sal-binding-api + org.opendaylight.mdsal + mdsal-binding-api - org.opendaylight.controller - sal-common-api + org.opendaylight.mdsal + mdsal-common-api org.opendaylight.controller diff --git a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/listener/PeopleCarListener.java b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/listener/PeopleCarListener.java index 60bfc5644f..cc8540f77e 100644 --- a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/listener/PeopleCarListener.java +++ b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/listener/PeopleCarListener.java @@ -8,11 +8,11 @@ package org.opendaylight.controller.clustering.it.listener; import com.google.common.util.concurrent.FutureCallback; -import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.MoreExecutors; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.WriteTransaction; +import org.opendaylight.mdsal.common.api.CommitInfo; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.people.rev140818.CarPeople; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.people.rev140818.car.people.CarPerson; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.people.rev140818.car.people.CarPersonBuilder; @@ -24,7 +24,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class PeopleCarListener implements CarPurchaseListener { - private static final Logger LOG = LoggerFactory.getLogger(PeopleCarListener.class); private DataBroker dataProvider; @@ -52,9 +51,9 @@ public class PeopleCarListener implements CarPurchaseListener { WriteTransaction tx = dataProvider.newWriteOnlyTransaction(); tx.put(LogicalDatastoreType.CONFIGURATION, carPersonIId, carPerson, true); - Futures.addCallback(tx.submit(), new FutureCallback() { + tx.commit().addCallback(new FutureCallback() { @Override - public void onSuccess(final Void result) { + public void onSuccess(final CommitInfo result) { LOG.info("Successfully added car-person entry: [{}]", carPerson); } diff --git a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/BasicRpcTestProvider.java b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/BasicRpcTestProvider.java index a5e66fdad8..7934ac90de 100644 --- a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/BasicRpcTestProvider.java +++ b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/BasicRpcTestProvider.java @@ -5,13 +5,11 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.controller.clustering.it.provider; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; -import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; +import org.opendaylight.mdsal.binding.api.RpcProviderService; import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService; import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider; import org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier; @@ -19,6 +17,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.controller.basic.rpc.test.r import org.opendaylight.yang.gen.v1.urn.opendaylight.controller.basic.rpc.test.rev160120.BasicGlobalOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.controller.basic.rpc.test.rev160120.BasicGlobalOutputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.controller.basic.rpc.test.rev160120.BasicRpcTestService; +import org.opendaylight.yangtools.concepts.ObjectRegistration; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.slf4j.Logger; @@ -29,11 +28,12 @@ public class BasicRpcTestProvider implements ClusterSingletonService, BasicRpcTe private static final Logger LOG = LoggerFactory.getLogger(BasicRpcTestProvider.class); private static final ServiceGroupIdentifier IDENTIFIER = ServiceGroupIdentifier.create("Basic-rpc-test"); - private final RpcProviderRegistry rpcProviderRegistry; + private final RpcProviderService rpcProviderRegistry; private final ClusterSingletonServiceProvider singletonService; - private BindingAwareBroker.RpcRegistration rpcRegistration; - public BasicRpcTestProvider(final RpcProviderRegistry rpcProviderRegistry, + private ObjectRegistration rpcRegistration; + + public BasicRpcTestProvider(final RpcProviderService rpcProviderRegistry, final ClusterSingletonServiceProvider singletonService) { this.rpcProviderRegistry = rpcProviderRegistry; this.singletonService = singletonService; @@ -44,7 +44,7 @@ public class BasicRpcTestProvider implements ClusterSingletonService, BasicRpcTe @Override public void instantiateServiceInstance() { LOG.info("Basic testing rpc registered as global"); - rpcRegistration = rpcProviderRegistry.addRpcImplementation(BasicRpcTestService.class, this); + rpcRegistration = rpcProviderRegistry.registerRpcImplementation(BasicRpcTestService.class, this); } @Override diff --git a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/CarDataTreeChangeListener.java b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/CarDataTreeChangeListener.java index 8d9eb77ddc..6acf6744a0 100644 --- a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/CarDataTreeChangeListener.java +++ b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/CarDataTreeChangeListener.java @@ -7,10 +7,10 @@ */ package org.opendaylight.controller.clustering.it.provider; -import org.opendaylight.controller.md.sal.binding.api.DataObjectModification; -import org.opendaylight.controller.md.sal.binding.api.DataObjectModification.ModificationType; -import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener; -import org.opendaylight.controller.md.sal.binding.api.DataTreeModification; +import org.opendaylight.mdsal.binding.api.DataObjectModification; +import org.opendaylight.mdsal.binding.api.DataObjectModification.ModificationType; +import org.opendaylight.mdsal.binding.api.DataTreeChangeListener; +import org.opendaylight.mdsal.binding.api.DataTreeModification; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.rev140818.Cars; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.slf4j.Logger; @@ -29,22 +29,20 @@ public class CarDataTreeChangeListener implements DataTreeChangeListener { public void onDataTreeChanged(final java.util.Collection> changes) { if (LOG.isTraceEnabled()) { for (DataTreeModification change : changes) { - ouputChanges(change); + outputChanges(change); } } } - private static void ouputChanges(final DataTreeModification change) { + private static void outputChanges(final DataTreeModification change) { final DataObjectModification rootNode = change.getRootNode(); final ModificationType modificationType = rootNode.getModificationType(); final InstanceIdentifier rootIdentifier = change.getRootPath().getRootIdentifier(); switch (modificationType) { case WRITE: case SUBTREE_MODIFIED: { - final Cars dataBefore = rootNode.getDataBefore(); - final Cars dataAfter = rootNode.getDataAfter(); LOG.trace("onDataTreeChanged - Cars config with path {} was added or changed from {} to {}", - rootIdentifier, dataBefore, dataAfter); + rootIdentifier, rootNode.getDataBefore(), rootNode.getDataAfter()); break; } case DELETE: { diff --git a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/CarProvider.java b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/CarProvider.java index e53523ba55..00a71ee9f5 100644 --- a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/CarProvider.java +++ b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/CarProvider.java @@ -15,19 +15,20 @@ import com.google.common.util.concurrent.MoreExecutors; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicReference; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; -import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; -import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeCommitCohortRegistry; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.DataTreeIdentifier; +import org.opendaylight.mdsal.binding.api.WriteTransaction; +import org.opendaylight.mdsal.common.api.CommitInfo; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; +import org.opendaylight.mdsal.dom.api.DOMDataBroker; import org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohortRegistration; +import org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohortRegistry; import org.opendaylight.mdsal.eos.binding.api.Entity; import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipChange; import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipListener; @@ -86,7 +87,7 @@ public class CarProvider implements CarService { private static final String ENTITY_TYPE = "cars"; private static final InstanceIdentifier CARS_IID = InstanceIdentifier.builder(Cars.class).build(); - private static final DataTreeIdentifier CARS_DTID = new DataTreeIdentifier<>( + private static final DataTreeIdentifier CARS_DTID = DataTreeIdentifier.create( LogicalDatastoreType.CONFIGURATION, CARS_IID); private final DataBroker dataProvider; @@ -163,8 +164,8 @@ public class CarProvider implements CarService { InstanceIdentifier carsId = InstanceIdentifier.create(Cars.class); tx.merge(LogicalDatastoreType.CONFIGURATION, carsId, new CarsBuilder().build()); try { - tx.submit().checkedGet(5, TimeUnit.SECONDS); - } catch (TransactionCommitFailedException | TimeoutException e) { + tx.commit().get(5, TimeUnit.SECONDS); + } catch (TimeoutException | InterruptedException | ExecutionException e) { LOG_PURCHASE_CAR.error("Put Cars failed",e); return Futures.immediateFuture(RpcResultBuilder.success(new StressTestOutputBuilder().build()).build()); } @@ -181,10 +182,10 @@ public class CarProvider implements CarService { CarEntry car = new CarEntryBuilder().setId(new CarId("car" + id)).build(); tx1.put(LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.builder(Cars.class).child(CarEntry.class, car.key()).build(), car); - Futures.addCallback(tx1.submit(), new FutureCallback() { + tx1.commit().addCallback(new FutureCallback() { @Override - public void onSuccess(final Void result) { + public void onSuccess(final CommitInfo result) { // Transaction succeeded succcessCounter.getAndIncrement(); } @@ -318,8 +319,8 @@ public class CarProvider implements CarService { return RpcResultBuilder.success(new RegisterCommitCohortOutputBuilder().build()).buildFuture(); } - final DOMDataTreeCommitCohortRegistry commitCohortRegistry = (DOMDataTreeCommitCohortRegistry) - domDataBroker.getSupportedExtensions().get(DOMDataTreeCommitCohortRegistry.class); + final DOMDataTreeCommitCohortRegistry commitCohortRegistry = domDataBroker.getExtensions().getInstance( + DOMDataTreeCommitCohortRegistry.class); if (commitCohortRegistry == null) { // Shouldn't happen diff --git a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/MdsalLowLevelTestProvider.java b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/MdsalLowLevelTestProvider.java index f4fb21b6dd..e7880ac1bf 100644 --- a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/MdsalLowLevelTestProvider.java +++ b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/MdsalLowLevelTestProvider.java @@ -15,7 +15,6 @@ import akka.actor.PoisonPill; import akka.actor.Props; import akka.dispatch.OnComplete; import akka.pattern.Patterns; -import com.google.common.base.Optional; import com.google.common.base.Strings; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; @@ -23,6 +22,7 @@ import com.google.common.util.concurrent.SettableFuture; import java.util.Collections; import java.util.HashMap; import java.util.Map; +import java.util.Optional; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; @@ -48,21 +48,20 @@ import org.opendaylight.controller.clustering.it.provider.impl.RoutedGetConstant import org.opendaylight.controller.clustering.it.provider.impl.SingletonGetConstantService; import org.opendaylight.controller.clustering.it.provider.impl.WriteTransactionsHandler; import org.opendaylight.controller.clustering.it.provider.impl.YnlListener; -import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; -import org.opendaylight.controller.md.sal.binding.api.NotificationService; -import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; -import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction; -import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener; -import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeService; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementationRegistration; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcProviderService; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; -import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; +import org.opendaylight.mdsal.binding.api.NotificationService; +import org.opendaylight.mdsal.binding.api.RpcProviderService; import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer; import org.opendaylight.mdsal.common.api.LogicalDatastoreType; +import org.opendaylight.mdsal.dom.api.DOMDataBroker; +import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener; +import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeService; import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier; import org.opendaylight.mdsal.dom.api.DOMDataTreeLoopException; +import org.opendaylight.mdsal.dom.api.DOMDataTreeReadTransaction; import org.opendaylight.mdsal.dom.api.DOMDataTreeService; +import org.opendaylight.mdsal.dom.api.DOMRpcImplementationRegistration; +import org.opendaylight.mdsal.dom.api.DOMRpcProviderService; import org.opendaylight.mdsal.dom.api.DOMSchemaService; import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider; import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration; @@ -143,6 +142,7 @@ import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.l import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.WriteTransactionsInput; import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.WriteTransactionsOutput; import org.opendaylight.yangtools.concepts.ListenerRegistration; +import org.opendaylight.yangtools.concepts.ObjectRegistration; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcError.ErrorType; import org.opendaylight.yangtools.yang.common.RpcResult; @@ -154,13 +154,10 @@ import org.slf4j.LoggerFactory; import scala.concurrent.duration.FiniteDuration; public class MdsalLowLevelTestProvider implements OdlMdsalLowlevelControlService { - private static final Logger LOG = LoggerFactory.getLogger(MdsalLowLevelTestProvider.class); - private static final org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType CONTROLLER_CONFIG = - org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.CONFIGURATION; - private final RpcProviderRegistry rpcRegistry; - private final BindingAwareBroker.RpcRegistration registration; + private final RpcProviderService rpcRegistry; + private final ObjectRegistration registration; private final DistributedShardFactory distributedShardFactory; private final DistributedDataStoreInterface configDataStore; private final DOMDataTreeService domDataTreeService; @@ -192,7 +189,7 @@ public class MdsalLowLevelTestProvider implements OdlMdsalLowlevelControlService - public MdsalLowLevelTestProvider(final RpcProviderRegistry rpcRegistry, + public MdsalLowLevelTestProvider(final RpcProviderService rpcRegistry, final DOMRpcProviderService domRpcService, final ClusterSingletonServiceProvider singletonService, final DOMSchemaService schemaService, @@ -218,11 +215,9 @@ public class MdsalLowLevelTestProvider implements OdlMdsalLowlevelControlService this.actorSystem = actorSystemProvider.getActorSystem(); this.prefixLeaderHandler = new PrefixLeaderHandler(domDataTreeService, bindingNormalizedNodeSerializer); + domDataTreeChangeService = domDataBroker.getExtensions().getInstance(DOMDataTreeChangeService.class); - domDataTreeChangeService = - (DOMDataTreeChangeService) domDataBroker.getSupportedExtensions().get(DOMDataTreeChangeService.class); - - registration = rpcRegistry.addRpcImplementation(OdlMdsalLowlevelControlService.class, this); + registration = rpcRegistry.registerRpcImplementation(OdlMdsalLowlevelControlService.class, this); prefixShardHandler = new PrefixShardHandler(distributedShardFactory, domDataTreeService, bindingNormalizedNodeSerializer); @@ -278,11 +273,9 @@ public class MdsalLowLevelTestProvider implements OdlMdsalLowlevelControlService idIntsListener = new IdIntsListener(); - dtclReg = domDataTreeChangeService - .registerDataTreeChangeListener( - new org.opendaylight.controller.md.sal.dom.api.DOMDataTreeIdentifier( - CONTROLLER_CONFIG, WriteTransactionsHandler.ID_INT_YID), - idIntsListener); + dtclReg = domDataTreeChangeService.registerDataTreeChangeListener( + new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, WriteTransactionsHandler.ID_INT_YID), + idIntsListener); return RpcResultBuilder.success(new SubscribeDtclOutputBuilder().build()).buildFuture(); } @@ -504,10 +497,9 @@ public class MdsalLowLevelTestProvider implements OdlMdsalLowlevelControlService "id-ints listener has not received any notifications.").buildFuture(); } - final DOMDataReadOnlyTransaction rTx = domDataBroker.newReadOnlyTransaction(); - try { - final Optional> readResult = - rTx.read(CONTROLLER_CONFIG, WriteTransactionsHandler.ID_INT_YID).get(); + try (DOMDataTreeReadTransaction rTx = domDataBroker.newReadOnlyTransaction()) { + final Optional> readResult = rTx.read(LogicalDatastoreType.CONFIGURATION, + WriteTransactionsHandler.ID_INT_YID).get(); if (!readResult.isPresent()) { return RpcResultBuilder.failed().withError(ErrorType.APPLICATION, "data-missing", diff --git a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/PeopleProvider.java b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/PeopleProvider.java index 5e6e531436..3ab9736811 100644 --- a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/PeopleProvider.java +++ b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/PeopleProvider.java @@ -7,24 +7,27 @@ */ package org.opendaylight.controller.clustering.it.provider; +import com.google.common.collect.ImmutableSet; import com.google.common.util.concurrent.FutureCallback; -import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.MoreExecutors; import com.google.common.util.concurrent.SettableFuture; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; +import java.util.HashSet; +import java.util.Set; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.RpcProviderService; +import org.opendaylight.mdsal.binding.api.WriteTransaction; +import org.opendaylight.mdsal.common.api.CommitInfo; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.purchase.rev140818.CarPurchaseService; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.people.rev140818.AddPersonInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.people.rev140818.AddPersonOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.people.rev140818.AddPersonOutputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.people.rev140818.People; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.people.rev140818.PeopleService; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.people.rev140818.PersonContext; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.people.rev140818.people.Person; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.people.rev140818.people.PersonBuilder; +import org.opendaylight.yangtools.concepts.ObjectRegistration; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcError; import org.opendaylight.yangtools.yang.common.RpcResult; @@ -36,17 +39,17 @@ public class PeopleProvider implements PeopleService, AutoCloseable { private static final Logger LOG = LoggerFactory.getLogger(PeopleProvider.class); + private final Set> regs = new HashSet<>(); private DataBroker dataProvider; - - private BindingAwareBroker.RoutedRpcRegistration rpcRegistration; + private RpcProviderService rpcProviderService; + private CarPurchaseService rpcImplementation; public void setDataProvider(final DataBroker salDataProvider) { this.dataProvider = salDataProvider; } - - public void setRpcRegistration(final BindingAwareBroker.RoutedRpcRegistration rpcRegistration) { - this.rpcRegistration = rpcRegistration; + public void setRpcImplementation(final CarPurchaseService rpcImplementation) { + this.rpcImplementation = rpcImplementation; } @Override @@ -64,11 +67,12 @@ public class PeopleProvider implements PeopleService, AutoCloseable { WriteTransaction tx = dataProvider.newWriteOnlyTransaction(); tx.put(LogicalDatastoreType.CONFIGURATION, personId, person, true); - Futures.addCallback(tx.submit(), new FutureCallback() { + tx.commit().addCallback(new FutureCallback() { @Override - public void onSuccess(final Void result) { + public void onSuccess(final CommitInfo result) { LOG.info("RPC addPerson : person added successfully [{}]", person); - rpcRegistration.registerPath(PersonContext.class, personId); + regs.add(rpcProviderService.registerRpcImplementation(CarPurchaseService.class, rpcImplementation, + ImmutableSet.of(personId))); LOG.info("RPC addPerson : routed rpc registered for instance ID [{}]", personId); futureResult.set(RpcResultBuilder.success(new AddPersonOutputBuilder().build()).build()); } @@ -85,5 +89,7 @@ public class PeopleProvider implements PeopleService, AutoCloseable { @Override public void close() { + regs.forEach(ObjectRegistration::close); + regs.clear(); } } diff --git a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/PurchaseCarProvider.java b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/PurchaseCarProvider.java index 457d8193b7..dc6b47da90 100644 --- a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/PurchaseCarProvider.java +++ b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/PurchaseCarProvider.java @@ -5,12 +5,12 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.controller.clustering.it.provider; +import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; -import com.google.common.util.concurrent.SettableFuture; -import org.opendaylight.controller.sal.binding.api.NotificationProviderService; +import com.google.common.util.concurrent.MoreExecutors; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.purchase.rev140818.BuyCarInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.purchase.rev140818.BuyCarOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.purchase.rev140818.BuyCarOutputBuilder; @@ -25,10 +25,10 @@ public class PurchaseCarProvider implements CarPurchaseService, AutoCloseable { private static final Logger LOG = LoggerFactory.getLogger(PurchaseCarProvider.class); - private NotificationProviderService notificationProvider; + private NotificationPublishService notificationProvider; - public void setNotificationProvider(final NotificationProviderService salService) { + public void setNotificationProvider(final NotificationPublishService salService) { this.notificationProvider = salService; } @@ -36,13 +36,13 @@ public class PurchaseCarProvider implements CarPurchaseService, AutoCloseable { @Override public ListenableFuture> buyCar(final BuyCarInput input) { LOG.info("Routed RPC buyCar : generating notification for buying car [{}]", input); - final SettableFuture> futureResult = SettableFuture.create(); - CarBoughtBuilder carBoughtBuilder = new CarBoughtBuilder(); - carBoughtBuilder.setCarId(input.getCarId()); - carBoughtBuilder.setPersonId(input.getPersonId()); - notificationProvider.publish(carBoughtBuilder.build()); - futureResult.set(RpcResultBuilder.success(new BuyCarOutputBuilder().build()).build()); - return futureResult; + + return Futures.transform(notificationProvider.offerNotification(new CarBoughtBuilder() + .setCarId(input.getCarId()) + .setPersonId(input.getPersonId()) + .build()), + result -> RpcResultBuilder.success(new BuyCarOutputBuilder().build()).build(), + MoreExecutors.directExecutor()); } @Override diff --git a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/AbstractTransactionHandler.java b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/AbstractTransactionHandler.java index de4f3efa03..6b0657ee6f 100644 --- a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/AbstractTransactionHandler.java +++ b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/AbstractTransactionHandler.java @@ -8,8 +8,8 @@ package org.opendaylight.controller.clustering.it.provider.impl; import com.google.common.base.Stopwatch; +import com.google.common.util.concurrent.FluentFuture; import com.google.common.util.concurrent.FutureCallback; -import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import java.util.Collection; import java.util.Collections; @@ -20,6 +20,7 @@ import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import java.util.concurrent.atomic.AtomicLong; +import org.opendaylight.mdsal.common.api.CommitInfo; import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.TransactionsParams; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; @@ -119,14 +120,14 @@ abstract class AbstractTransactionHandler { // Not completed yet: create a transaction and hook it up final long txId = txCounter.incrementAndGet(); - final ListenableFuture execFuture = execWrite(txId); + final FluentFuture execFuture = execWrite(txId); LOG.debug("New future #{} allocated", txId); // Ordering is important: we need to add the future before hooking the callback futures.add(execFuture); - Futures.addCallback(execFuture, new FutureCallback() { + execFuture.addCallback(new FutureCallback() { @Override - public void onSuccess(final Object result) { + public void onSuccess(final CommitInfo result) { txSuccess(execFuture, txId); } @@ -225,7 +226,7 @@ abstract class AbstractTransactionHandler { runTimedOut("Transactions did not finish in " + DEAD_TIMEOUT_SECONDS + " seconds"); } - abstract ListenableFuture execWrite(long txId); + abstract FluentFuture execWrite(long txId); abstract void runFailed(Throwable cause, long txId); diff --git a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/GetConstantService.java b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/GetConstantService.java index 458e2ed818..a800dc921d 100644 --- a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/GetConstantService.java +++ b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/GetConstantService.java @@ -7,19 +7,20 @@ */ package org.opendaylight.controller.clustering.it.provider.impl; -import com.google.common.util.concurrent.CheckedFuture; import com.google.common.util.concurrent.Futures; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcException; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementation; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementationRegistration; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcProviderService; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult; -import org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult; +import com.google.common.util.concurrent.ListenableFuture; +import java.net.URI; +import org.opendaylight.mdsal.dom.api.DOMRpcIdentifier; +import org.opendaylight.mdsal.dom.api.DOMRpcImplementation; +import org.opendaylight.mdsal.dom.api.DOMRpcImplementationRegistration; +import org.opendaylight.mdsal.dom.api.DOMRpcProviderService; +import org.opendaylight.mdsal.dom.api.DOMRpcResult; +import org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult; import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.common.QNameModule; +import org.opendaylight.yangtools.yang.common.Revision; +import org.opendaylight.yangtools.yang.common.YangConstants; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; -import org.opendaylight.yangtools.yang.data.api.schema.LeafNode; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder; import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafNodeBuilder; @@ -28,15 +29,14 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public final class GetConstantService implements DOMRpcImplementation { - private static final Logger LOG = LoggerFactory.getLogger(GetConstantService.class); - private static final QName OUTPUT = - QName.create("tag:opendaylight.org,2017:controller:yang:lowlevel:target","2017-02-15", "output"); - private static final QName CONSTANT = - QName.create("tag:opendaylight.org,2017:controller:yang:lowlevel:target","2017-02-15", "constant"); - private static final QName GET_CONSTANT = - QName.create("tag:opendaylight.org,2017:controller:yang:lowlevel:target","2017-02-15", "get-constant"); + private static final QNameModule MODULE = QNameModule.create( + URI.create("tag:opendaylight.org,2017:controller:yang:lowlevel:target"), Revision.of("2017-02-15")).intern(); + + private static final QName OUTPUT = YangConstants.operationOutputQName(MODULE).intern(); + private static final QName CONSTANT = QName.create(MODULE, "constant").intern(); + private static final QName GET_CONSTANT = QName.create(MODULE, "get-constant").intern(); private final String constant; @@ -46,28 +46,21 @@ public final class GetConstantService implements DOMRpcImplementation { public static DOMRpcImplementationRegistration registerNew( final DOMRpcProviderService rpcProviderService, final String constant) { - LOG.debug("Registering get-constant service, constant value: {}", constant); - final DOMRpcIdentifier id = DOMRpcIdentifier.create(SchemaPath.create(true, GET_CONSTANT)); - - return rpcProviderService.registerRpcImplementation(new GetConstantService(constant), id); + return rpcProviderService.registerRpcImplementation(new GetConstantService(constant), + DOMRpcIdentifier.create(SchemaPath.create(true, GET_CONSTANT))); } @Override - public CheckedFuture invokeRpc(final DOMRpcIdentifier rpc, - final NormalizedNode input) { + public ListenableFuture invokeRpc(final DOMRpcIdentifier rpc, final NormalizedNode input) { LOG.debug("get-constant invoked, current value: {}", constant); - final LeafNode value = ImmutableLeafNodeBuilder.create() + return Futures.immediateFuture(new DefaultDOMRpcResult(ImmutableContainerNodeBuilder.create() + .withNodeIdentifier(new NodeIdentifier(OUTPUT)) + .withChild(ImmutableLeafNodeBuilder.create() .withNodeIdentifier(new NodeIdentifier(CONSTANT)) .withValue(constant) - .build(); - - final ContainerNode result = ImmutableContainerNodeBuilder.create() - .withNodeIdentifier(new NodeIdentifier(OUTPUT)) - .withChild(value) - .build(); - - return Futures.immediateCheckedFuture(new DefaultDOMRpcResult(result)); + .build()) + .build())); } } diff --git a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/IdIntsListener.java b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/IdIntsListener.java index 2727f529b2..14e728d286 100644 --- a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/IdIntsListener.java +++ b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/IdIntsListener.java @@ -7,9 +7,9 @@ */ package org.opendaylight.controller.clustering.it.provider.impl; +import static com.google.common.base.Preconditions.checkState; import static org.opendaylight.controller.clustering.it.provider.impl.AbstractTransactionHandler.ITEM; -import com.google.common.base.Preconditions; import com.google.common.util.concurrent.SettableFuture; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.util.Collection; @@ -21,7 +21,7 @@ import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong; -import org.opendaylight.controller.md.sal.dom.api.ClusteredDOMDataTreeChangeListener; +import org.opendaylight.mdsal.dom.api.ClusteredDOMDataTreeChangeListener; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates; import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; @@ -45,7 +45,7 @@ public class IdIntsListener implements ClusteredDOMDataTreeChangeListener { public void onDataTreeChanged(final Collection changes) { // There should only be one candidate reported - Preconditions.checkState(changes.size() == 1); + checkState(changes.size() == 1); lastNotifTimestamp.set(System.nanoTime()); diff --git a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/PublishNotificationsTask.java b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/PublishNotificationsTask.java index 4f4b7f8e10..79250b6dd0 100644 --- a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/PublishNotificationsTask.java +++ b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/PublishNotificationsTask.java @@ -14,7 +14,7 @@ import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; -import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.target.rev170215.IdSequence; import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.target.rev170215.IdSequenceBuilder; import org.slf4j.Logger; diff --git a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/RoutedGetConstantService.java b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/RoutedGetConstantService.java index 6f90c8c947..64470b022e 100644 --- a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/RoutedGetConstantService.java +++ b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/RoutedGetConstantService.java @@ -7,21 +7,23 @@ */ package org.opendaylight.controller.clustering.it.provider.impl; -import com.google.common.util.concurrent.CheckedFuture; import com.google.common.util.concurrent.Futures; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcException; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementation; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementationRegistration; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcProviderService; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult; -import org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult; +import com.google.common.util.concurrent.ListenableFuture; +import java.net.URI; import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer; +import org.opendaylight.mdsal.dom.api.DOMRpcIdentifier; +import org.opendaylight.mdsal.dom.api.DOMRpcImplementation; +import org.opendaylight.mdsal.dom.api.DOMRpcImplementationRegistration; +import org.opendaylight.mdsal.dom.api.DOMRpcProviderService; +import org.opendaylight.mdsal.dom.api.DOMRpcResult; +import org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.common.QNameModule; +import org.opendaylight.yangtools.yang.common.Revision; +import org.opendaylight.yangtools.yang.common.YangConstants; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; -import org.opendaylight.yangtools.yang.data.api.schema.LeafNode; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder; import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafNodeBuilder; @@ -30,18 +32,13 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public final class RoutedGetConstantService implements DOMRpcImplementation { - private static final Logger LOG = LoggerFactory.getLogger(RoutedGetConstantService.class); - private static final QName OUTPUT = - QName.create("tag:opendaylight.org,2017:controller:yang:lowlevel:target","2017-02-15", "output"); - private static final QName CONSTANT = - QName.create("tag:opendaylight.org,2017:controller:yang:lowlevel:target","2017-02-15", "constant"); - private static final QName CONTEXT = - QName.create("tag:opendaylight.org,2017:controller:yang:lowlevel:target","2017-02-15", "context"); - private static final QName GET_CONTEXTED_CONSTANT = - QName.create("tag:opendaylight.org,2017:controller:yang:lowlevel:target","2017-02-15", - "get-contexted-constant"); + private static final QNameModule MODULE = QNameModule.create( + URI.create("tag:opendaylight.org,2017:controller:yang:lowlevel:target"), Revision.of("2017-02-15")).intern(); + private static final QName OUTPUT = YangConstants.operationOutputQName(MODULE).intern(); + private static final QName CONSTANT = QName.create(MODULE, "constant").intern(); + private static final QName GET_CONTEXTED_CONSTANT = QName.create(MODULE, "get-contexted-constant").intern(); private final String constant; @@ -62,20 +59,15 @@ public final class RoutedGetConstantService implements DOMRpcImplementation { } @Override - public CheckedFuture invokeRpc(final DOMRpcIdentifier rpc, - final NormalizedNode input) { + public ListenableFuture invokeRpc(final DOMRpcIdentifier rpc, final NormalizedNode input) { LOG.debug("get-contexted-constant invoked, current value: {}", constant); - final LeafNode value = ImmutableLeafNodeBuilder.create() - .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(CONSTANT)) + return Futures.immediateFuture(new DefaultDOMRpcResult(ImmutableContainerNodeBuilder.create() + .withNodeIdentifier(new NodeIdentifier(OUTPUT)) + .withChild(ImmutableLeafNodeBuilder.create() + .withNodeIdentifier(new NodeIdentifier(CONSTANT)) .withValue(constant) - .build(); - - final ContainerNode result = ImmutableContainerNodeBuilder.create() - .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(OUTPUT)) - .withChild(value) - .build(); - - return Futures.immediateCheckedFuture(new DefaultDOMRpcResult(result)); + .build()) + .build())); } } diff --git a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/SingletonGetConstantService.java b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/SingletonGetConstantService.java index 50060d36c4..ffa3b80f9f 100644 --- a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/SingletonGetConstantService.java +++ b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/SingletonGetConstantService.java @@ -7,24 +7,24 @@ */ package org.opendaylight.controller.clustering.it.provider.impl; -import com.google.common.util.concurrent.CheckedFuture; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcException; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementation; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementationRegistration; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcProviderService; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult; -import org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult; +import java.net.URI; +import org.opendaylight.mdsal.dom.api.DOMRpcIdentifier; +import org.opendaylight.mdsal.dom.api.DOMRpcImplementation; +import org.opendaylight.mdsal.dom.api.DOMRpcImplementationRegistration; +import org.opendaylight.mdsal.dom.api.DOMRpcProviderService; +import org.opendaylight.mdsal.dom.api.DOMRpcResult; +import org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult; import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService; import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider; import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration; import org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier; import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.common.QNameModule; +import org.opendaylight.yangtools.yang.common.Revision; +import org.opendaylight.yangtools.yang.common.YangConstants; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; -import org.opendaylight.yangtools.yang.data.api.schema.LeafNode; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder; import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafNodeBuilder; @@ -36,15 +36,12 @@ public final class SingletonGetConstantService implements DOMRpcImplementation, private static final Logger LOG = LoggerFactory.getLogger(SingletonGetConstantService.class); - private static final QName OUTPUT = - QName.create("tag:opendaylight.org,2017:controller:yang:lowlevel:target","2017-02-15", "output"); - private static final QName CONSTANT = - QName.create("tag:opendaylight.org,2017:controller:yang:lowlevel:target","2017-02-15", "constant"); - private static final QName CONTEXT = - QName.create("tag:opendaylight.org,2017:controller:yang:lowlevel:target","2017-02-15", "context"); - private static final QName GET_SINGLETON_CONSTANT = - QName.create("tag:opendaylight.org,2017:controller:yang:lowlevel:target","2017-02-15", - "get-singleton-constant"); + private static final QNameModule MODULE = QNameModule.create( + URI.create("tag:opendaylight.org,2017:controller:yang:lowlevel:target"), Revision.of("2017-02-15")).intern(); + private static final QName OUTPUT = YangConstants.operationOutputQName(MODULE).intern(); + private static final QName CONSTANT = QName.create(MODULE, "constant").intern(); + private static final QName CONTEXT = QName.create(MODULE, "context").intern(); + private static final QName GET_SINGLETON_CONSTANT = QName.create(MODULE, "get-singleton-constant").intern(); private static final ServiceGroupIdentifier SERVICE_GROUP_IDENTIFIER = ServiceGroupIdentifier.create("get-singleton-constant-service"); @@ -53,10 +50,7 @@ public final class SingletonGetConstantService implements DOMRpcImplementation, private final String constant; private DOMRpcImplementationRegistration rpcRegistration; - private SingletonGetConstantService(final DOMRpcProviderService rpcProviderService, - final String constant) { - - + private SingletonGetConstantService(final DOMRpcProviderService rpcProviderService, final String constant) { this.rpcProviderService = rpcProviderService; this.constant = constant; } @@ -66,26 +60,21 @@ public final class SingletonGetConstantService implements DOMRpcImplementation, final String constant) { LOG.debug("Registering get-singleton-constant into ClusterSingletonService, value {}", constant); - return singletonService - .registerClusterSingletonService(new SingletonGetConstantService(rpcProviderService, constant)); + return singletonService.registerClusterSingletonService( + new SingletonGetConstantService(rpcProviderService, constant)); } @Override - public CheckedFuture invokeRpc(DOMRpcIdentifier rpc, - NormalizedNode input) { + public ListenableFuture invokeRpc(final DOMRpcIdentifier rpc, final NormalizedNode input) { LOG.debug("get-singleton-constant invoked, current value: {}", constant); - final LeafNode value = ImmutableLeafNodeBuilder.create() + return Futures.immediateFuture(new DefaultDOMRpcResult(ImmutableContainerNodeBuilder.create() + .withNodeIdentifier(new NodeIdentifier(OUTPUT)) + .withChild(ImmutableLeafNodeBuilder.create() .withNodeIdentifier(new NodeIdentifier(CONSTANT)) .withValue(constant) - .build(); - - final ContainerNode result = ImmutableContainerNodeBuilder.create() - .withNodeIdentifier(new NodeIdentifier(OUTPUT)) - .withChild(value) - .build(); - - return Futures.immediateCheckedFuture(new DefaultDOMRpcResult(result)); + .build()) + .build())); } @Override diff --git a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/WriteTransactionsHandler.java b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/WriteTransactionsHandler.java index b0503b2406..23c9e52d76 100644 --- a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/WriteTransactionsHandler.java +++ b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/WriteTransactionsHandler.java @@ -9,6 +9,7 @@ package org.opendaylight.controller.clustering.it.provider.impl; import static java.util.Objects.requireNonNull; +import com.google.common.util.concurrent.FluentFuture; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.SettableFuture; import java.util.LinkedHashSet; @@ -19,15 +20,15 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import java.util.concurrent.atomic.AtomicLong; -import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.OptimisticLockFailedException; -import org.opendaylight.controller.md.sal.common.api.data.TransactionChain; -import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener; -import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; -import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; -import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction; -import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain; +import org.eclipse.jdt.annotation.NonNull; +import org.opendaylight.mdsal.common.api.CommitInfo; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; +import org.opendaylight.mdsal.common.api.OptimisticLockFailedException; +import org.opendaylight.mdsal.dom.api.DOMDataBroker; +import org.opendaylight.mdsal.dom.api.DOMDataTreeTransaction; +import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction; +import org.opendaylight.mdsal.dom.api.DOMTransactionChain; +import org.opendaylight.mdsal.dom.api.DOMTransactionChainListener; import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.WriteTransactionsInput; import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.WriteTransactionsOutput; import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.WriteTransactionsOutputBuilder; @@ -46,7 +47,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public abstract class WriteTransactionsHandler extends AbstractTransactionHandler { - private static final class Chained extends WriteTransactionsHandler implements TransactionChainListener { + private static final class Chained extends WriteTransactionsHandler implements DOMTransactionChainListener { private final SplittableRandom random = new SplittableRandom(); private final DOMTransactionChain transactionChain; @@ -57,7 +58,7 @@ public abstract class WriteTransactionsHandler extends AbstractTransactionHandle } @Override - DOMDataWriteTransaction createTransaction() { + DOMDataTreeWriteTransaction createTransaction() { return transactionChain.newWriteOnlyTransaction(); } @@ -67,15 +68,15 @@ public abstract class WriteTransactionsHandler extends AbstractTransactionHandle } @Override - public void onTransactionChainFailed(final TransactionChain chain, - final AsyncTransaction transaction, final Throwable cause) { + public void onTransactionChainFailed(final DOMTransactionChain chain, final DOMDataTreeTransaction transaction, + final Throwable cause) { // This is expected to happen frequently in isolation testing. LOG.debug("Transaction chain failed.", cause); // Do not return RPC here, rely on transaction failure to call runFailed. } @Override - public void onTransactionChainSuccessful(final TransactionChain chain) { + public void onTransactionChainSuccessful(final DOMTransactionChain chain) { LOG.debug("Transaction chain closed successfully."); } } @@ -92,7 +93,7 @@ public abstract class WriteTransactionsHandler extends AbstractTransactionHandle } @Override - DOMDataWriteTransaction createTransaction() { + DOMDataTreeWriteTransaction createTransaction() { return dataBroker.newWriteOnlyTransaction(); } @@ -141,27 +142,35 @@ public abstract class WriteTransactionsHandler extends AbstractTransactionHandle .withChild(ImmutableNodes.mapNodeBuilder(ID_INT).build()) .build(); - DOMDataWriteTransaction tx = domDataBroker.newWriteOnlyTransaction(); + DOMDataTreeWriteTransaction tx = domDataBroker.newWriteOnlyTransaction(); // write only the top list tx.merge(LogicalDatastoreType.CONFIGURATION, ID_INTS_YID, containerNode); try { - tx.submit().checkedGet(INIT_TX_TIMEOUT_SECONDS, TimeUnit.SECONDS); - } catch (final OptimisticLockFailedException e) { - // when multiple write-transactions are executed concurrently we need to ignore this. - // If we get optimistic lock here it means id-ints already exists and we can continue. - LOG.debug("Got an optimistic lock when writing initial top level list element.", e); - } catch (final TransactionCommitFailedException | TimeoutException e) { + tx.commit().get(INIT_TX_TIMEOUT_SECONDS, TimeUnit.SECONDS); + } catch (InterruptedException | TimeoutException e) { LOG.error("Error writing top-level path {}: {}", ID_INTS_YID, containerNode, e); return RpcResultBuilder.failed().withError(RpcError.ErrorType.APPLICATION, String.format("Could not start write transactions - error writing top-level path %s: %s", ID_INTS_YID, containerNode), e).buildFuture(); + } catch (ExecutionException e) { + final Throwable cause = e.getCause(); + if (cause instanceof OptimisticLockFailedException) { + // when multiple write-transactions are executed concurrently we need to ignore this. + // If we get optimistic lock here it means id-ints already exists and we can continue. + LOG.debug("Got an optimistic lock when writing initial top level list element.", e); + } else { + LOG.error("Error writing top-level path {}: {}", ID_INTS_YID, containerNode, e); + return RpcResultBuilder.failed().withError(RpcError.ErrorType.APPLICATION, + String.format("Could not start write transactions - error writing top-level path %s: %s", + ID_INTS_YID, containerNode), e).buildFuture(); + } } tx = domDataBroker.newWriteOnlyTransaction(); tx.merge(LogicalDatastoreType.CONFIGURATION, idListItem, entry); try { - tx.submit().get(INIT_TX_TIMEOUT_SECONDS, TimeUnit.SECONDS); + tx.commit().get(INIT_TX_TIMEOUT_SECONDS, TimeUnit.SECONDS); } catch (InterruptedException | ExecutionException | TimeoutException e) { LOG.error("Error writing top-level path {}: {}", idListItem, entry, e); return RpcResultBuilder.failed().withError(RpcError.ErrorType.APPLICATION, @@ -179,7 +188,7 @@ public abstract class WriteTransactionsHandler extends AbstractTransactionHandle tx.put(LogicalDatastoreType.CONFIGURATION, itemListId, itemListNode); try { - tx.submit().get(INIT_TX_TIMEOUT_SECONDS, TimeUnit.SECONDS); + tx.commit().get(INIT_TX_TIMEOUT_SECONDS, TimeUnit.SECONDS); } catch (InterruptedException | ExecutionException | TimeoutException e) { LOG.error("Error filling initial item list path {}: {}", itemListId, itemListNode, e); return RpcResultBuilder.failed().withError(RpcError.ErrorType.APPLICATION, @@ -201,13 +210,13 @@ public abstract class WriteTransactionsHandler extends AbstractTransactionHandle } @Override - ListenableFuture execWrite(final long txId) { + FluentFuture execWrite(final long txId) { final int i = nextInt(MAX_ITEM + 1); final YangInstanceIdentifier entryId = idListItem.node(ITEM).node(YangInstanceIdentifier.NodeIdentifierWithPredicates.of(ITEM, NUMBER, i)); - final DOMDataWriteTransaction tx = createTransaction(); + final DOMDataTreeWriteTransaction tx = createTransaction(); if (usedValues.contains(i)) { LOG.debug("Deleting item: {}", i); @@ -223,7 +232,7 @@ public abstract class WriteTransactionsHandler extends AbstractTransactionHandle usedValues.add(i); } - return tx.submit(); + return tx.commit(); } @Override @@ -250,7 +259,7 @@ public abstract class WriteTransactionsHandler extends AbstractTransactionHandle .withError(RpcError.ErrorType.APPLICATION, cause).build()); } - abstract DOMDataWriteTransaction createTransaction(); + abstract DOMDataTreeWriteTransaction createTransaction(); abstract int nextInt(int bound); } diff --git a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/resources/OSGI-INF/blueprint/cluster-test-app.xml b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/resources/OSGI-INF/blueprint/cluster-test-app.xml index ba2e312c82..11bea1ab21 100644 --- a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/resources/OSGI-INF/blueprint/cluster-test-app.xml +++ b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/resources/OSGI-INF/blueprint/cluster-test-app.xml @@ -4,17 +4,16 @@ xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0" odl:use-default-for-reference-types="true"> - - + - - + + - + - - + + - + - + - + sal-common-util - org.opendaylight.controller - sal-binding-api + org.opendaylight.mdsal + mdsal-binding-api org.osgi -- 2.36.6