Merge "Initial implementation of the ClusteredDataStore"
authorEd Warnicke <eaw@cisco.com>
Fri, 8 Nov 2013 19:36:19 +0000 (19:36 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Fri, 8 Nov 2013 19:36:19 +0000 (19:36 +0000)
277 files changed:
opendaylight/commons/checkstyle/src/main/resources/controller/checkstyle.xml
opendaylight/commons/opendaylight/pom.xml
opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/DependencyResolver.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/ConfigTransactionControllerImpl.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/dependencyresolver/DependencyResolverImpl.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/dependencyresolver/DependencyResolverManager.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/dependencyresolver/ModulesHolder.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/dependencyresolver/TransactionHolder.java
opendaylight/config/netty-threadgroup-config/pom.xml [new file with mode: 0644]
opendaylight/config/netty-threadgroup-config/src/main/java/org/opendaylight/controller/config/yang/netty/threadgroup/NettyThreadgroupModule.java [new file with mode: 0644]
opendaylight/config/netty-threadgroup-config/src/main/java/org/opendaylight/controller/config/yang/netty/threadgroup/NettyThreadgroupModuleFactory.java [new file with mode: 0644]
opendaylight/config/netty-threadgroup-config/src/main/yang/nsos-netty-threadgroup.yang [new file with mode: 0644]
opendaylight/config/netty-threadgroup-config/src/test/java/org/opendaylight/controller/config/yang/netty/threadgroup/NettyThreadgroupModuleTest.java [new file with mode: 0644]
opendaylight/config/pom.xml
opendaylight/config/threadpool-config-api/pom.xml [new file with mode: 0644]
opendaylight/config/threadpool-config-api/src/main/java/org/opendaylight/controller/config/threadpool/ScheduledThreadPool.java [new file with mode: 0644]
opendaylight/config/threadpool-config-api/src/main/java/org/opendaylight/controller/config/threadpool/ThreadPool.java [new file with mode: 0644]
opendaylight/config/threadpool-config-api/src/main/yang/threadpool.yang [new file with mode: 0644]
opendaylight/config/threadpool-config-impl/pom.xml [new file with mode: 0644]
opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/threadpool/util/CloseableAsyncEventBus.java [new file with mode: 0644]
opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/threadpool/util/CloseableEventBus.java [new file with mode: 0644]
opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/threadpool/util/FixedThreadPoolWrapper.java [new file with mode: 0644]
opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/threadpool/util/FlexibleThreadPoolWrapper.java [new file with mode: 0644]
opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/threadpool/util/NamingThreadPoolFactory.java [new file with mode: 0644]
opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/threadpool/util/ScheduledThreadPoolWrapper.java [new file with mode: 0644]
opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/AsyncEventBusModule.java [new file with mode: 0644]
opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/AsyncEventBusModuleFactory.java [new file with mode: 0644]
opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/EventBusModule.java [new file with mode: 0644]
opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/EventBusModuleFactory.java [new file with mode: 0644]
opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/FixedThreadPoolModule.java [new file with mode: 0644]
opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/FixedThreadPoolModuleFactory.java [new file with mode: 0644]
opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/FlexibleThreadPoolModule.java [new file with mode: 0644]
opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/FlexibleThreadPoolModuleFactory.java [new file with mode: 0644]
opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/NamingThreadFactoryModule.java [new file with mode: 0644]
opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/NamingThreadFactoryModuleFactory.java [new file with mode: 0644]
opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/ScheduledThreadPoolModule.java [new file with mode: 0644]
opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/ScheduledThreadPoolModuleFactory.java [new file with mode: 0644]
opendaylight/config/threadpool-config-impl/src/main/yang/threadpool-impl.yang [new file with mode: 0644]
opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/async/AsyncEventBusConfigBeanTest.java [new file with mode: 0644]
opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/eventbus/SyncEventBusConfigBeanTest.java [new file with mode: 0644]
opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/eventbus/TestingEventBusModule.java [new file with mode: 0644]
opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/fixed/FixedThreadPoolConfigBeanTest.java [new file with mode: 0644]
opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/fixed/TestingFixedThreadPoolModule.java [new file with mode: 0644]
opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/flexible/FlexibleThreadPoolConfigBeanTest.java [new file with mode: 0644]
opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/naming/NamingThreadPoolFactoryConfigBeanTest.java [new file with mode: 0644]
opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/naming/TestingNamingThreadPoolFactoryModule.java [new file with mode: 0644]
opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/scheduled/ScheduledThreadPoolConfigBeanTest.java [new file with mode: 0644]
opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/scheduled/TestingScheduledThreadPoolModule.java [new file with mode: 0644]
opendaylight/distribution/opendaylight/pom.xml
opendaylight/forwardingrulesmanager_mdsal/openflow/pom.xml
opendaylight/forwardingrulesmanager_mdsal/openflow/src/main/java/org/opendaylight/controller/forwardingrulesmanager_mdsal/consumer/impl/FRMConsumerImpl.java
opendaylight/forwardingrulesmanager_mdsal/openflow/src/main/java/org/opendaylight/controller/forwardingrulesmanager_mdsal/consumer/impl/FRMUtil.java [new file with mode: 0644]
opendaylight/forwardingrulesmanager_mdsal/openflow/src/main/java/org/opendaylight/controller/forwardingrulesmanager_mdsal/consumer/impl/FlowConsumerImpl.java
opendaylight/forwardingrulesmanager_mdsal/openflow/src/main/java/org/opendaylight/controller/forwardingrulesmanager_mdsal/consumer/impl/GroupConsumerImpl.java
opendaylight/md-sal/compatibility/flow-management-compatibility/pom.xml [moved from opendaylight/md-sal/flow-management-compatibility/pom.xml with 94% similarity]
opendaylight/md-sal/compatibility/flow-management-compatibility/src/main/java/org/opendaylight/controller/md/frm/compatibility/FRMRuntimeDataProvider.xtend [moved from opendaylight/md-sal/flow-management-compatibility/src/main/java/org/opendaylight/controller/md/frm/compatibility/FRMRuntimeDataProvider.xtend with 98% similarity]
opendaylight/md-sal/compatibility/flow-management-compatibility/src/main/java/org/opendaylight/controller/md/frm/compatibility/FlowConfigMapping.xtend [moved from opendaylight/md-sal/flow-management-compatibility/src/main/java/org/opendaylight/controller/md/frm/compatibility/FlowConfigMapping.xtend with 89% similarity]
opendaylight/md-sal/compatibility/flow-management-compatibility/src/main/java/org/opendaylight/controller/md/frm/compatibility/FlowManagementReader.java [moved from opendaylight/md-sal/flow-management-compatibility/src/main/java/org/opendaylight/controller/md/frm/compatibility/FlowManagementReader.java with 100% similarity]
opendaylight/md-sal/compatibility/flow-management-compatibility/src/main/java/org/opendaylight/controller/md/frm/compatibility/SampleConsumer.java [new file with mode: 0644]
opendaylight/md-sal/compatibility/inventory-topology-compatibility/pom.xml [new file with mode: 0644]
opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/inventory/InventoryReader.xtend [new file with mode: 0644]
opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/switchmanager/CompatibleSwitchManager.xtend [new file with mode: 0644]
opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/switchmanager/ConfigurableSwitchManager.xtend [new file with mode: 0644]
opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/topology/TopologyMapping.xtend [new file with mode: 0644]
opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/topology/TopologyReader.xtend [new file with mode: 0644]
opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/topologymanager/AdSalTopologyMapping.xtend [new file with mode: 0644]
opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/topologymanager/CompatibleTopologyManager.xtend [new file with mode: 0644]
opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/topologymanager/ConfigurableLinkManager.xtend [new file with mode: 0644]
opendaylight/md-sal/compatibility/pom.xml [new file with mode: 0644]
opendaylight/md-sal/compatibility/sal-compatibility/pom.xml [moved from opendaylight/md-sal/sal-compability/pom.xml with 65% similarity]
opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/ComponentActivator.xtend [moved from opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/ComponentActivator.xtend with 97% similarity]
opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/DataPacketAdapter.xtend [moved from opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/DataPacketAdapter.xtend with 93% similarity]
opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/FlowProgrammerAdapter.xtend [moved from opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/FlowProgrammerAdapter.xtend with 93% similarity]
opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/FromSalConversionsUtils.java [moved from opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/FromSalConversionsUtils.java with 98% similarity]
opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/InventoryAndReadAdapter.xtend [moved from opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/InventoryAndReadAdapter.xtend with 98% similarity]
opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/InventoryMapping.xtend [new file with mode: 0644]
opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/MDFlowMapping.xtend [moved from opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/MDFlowMapping.xtend with 98% similarity]
opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/NodeMapping.xtend [moved from opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/NodeMapping.xtend with 98% similarity]
opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/ProtocolConstants.java [moved from opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/ProtocolConstants.java with 88% similarity]
opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/ToSalConversionsUtils.java [moved from opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/ToSalConversionsUtils.java with 98% similarity]
opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/adsal/DataPacketServiceAdapter.java [moved from opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/adsal/DataPacketServiceAdapter.java with 92% similarity]
opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/adsal/FlowServiceAdapter.java [new file with mode: 0644]
opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/adsal/FlowStatisticsAdapter.java [moved from opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/adsal/FlowStatisticsAdapter.java with 98% similarity]
opendaylight/md-sal/compatibility/sal-compatibility/src/test/java/org/opendaylight/controller/sal/compatibility/test/TestFromSalConversionsUtils.java [moved from opendaylight/md-sal/sal-compability/src/test/java/org/opendaylight/controller/sal/compability/TestFromSalConversionsUtils.java with 85% similarity]
opendaylight/md-sal/compatibility/sal-compatibility/src/test/java/org/opendaylight/controller/sal/compatibility/test/TestToSalConversionsUtils.java [moved from opendaylight/md-sal/sal-compability/src/test/java/org/opendaylight/controller/sal/compability/TestToSalConversionsUtils.java with 82% similarity]
opendaylight/md-sal/model/model-flow-base/src/main/yang/group-types.yang
opendaylight/md-sal/model/model-flow-base/src/main/yang/meter-types.yang
opendaylight/md-sal/model/model-flow-base/src/main/yang/port-types.yang
opendaylight/md-sal/model/model-flow-management/src/main/yang/meter-config.yang
opendaylight/md-sal/model/model-flow-service/src/main/yang/flow-capable-transaction.yang [new file with mode: 0644]
opendaylight/md-sal/model/model-flow-service/src/main/yang/group-service.yang
opendaylight/md-sal/model/model-flow-service/src/main/yang/meter-service.yang
opendaylight/md-sal/model/model-flow-service/src/main/yang/port-service.yang [new file with mode: 0644]
opendaylight/md-sal/model/model-flow-service/src/main/yang/table-service.yang
opendaylight/md-sal/model/model-topology/pom.xml [new file with mode: 0644]
opendaylight/md-sal/model/model-topology/src/main/yang/opendaylight-topology-inventory.yang [new file with mode: 0644]
opendaylight/md-sal/model/model-topology/src/main/yang/opendaylight-topology.yang [new file with mode: 0644]
opendaylight/md-sal/model/model-topology/src/main/yang/topology-view.yang [new file with mode: 0644]
opendaylight/md-sal/model/pom.xml
opendaylight/md-sal/pom.xml
opendaylight/md-sal/sal-binding-api/pom.xml
opendaylight/md-sal/sal-binding-broker/pom.xml
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/DataBrokerImpl.xtend
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/DataProviderContext.xtend [deleted file]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/DataTransactionImpl.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/util/BindingAwareDataReaderRouter.xtend [new file with mode: 0644]
opendaylight/md-sal/sal-binding-util/pom.xml [new file with mode: 0644]
opendaylight/md-sal/sal-binding-util/src/main/java/org/opendaylight/controller/md/sal/binding/util/TypeSafeDataReader.java [new file with mode: 0644]
opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/DataChange.java
opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/DataChangeEvent.java
opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/DataCommitHandler.java
opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/DataModification.java
opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/DataStore.java [new file with mode: 0644]
opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/routing/Route.java [new file with mode: 0644]
opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/routing/RouteChangeListener.java [new file with mode: 0644]
opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/routing/RouteChangePublisher.java [new file with mode: 0644]
opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/routing/Router.java [new file with mode: 0644]
opendaylight/md-sal/sal-common-impl/pom.xml
opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/AbstractDataModification.java
opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/routing/AbstractDataReadRouter.java [new file with mode: 0644]
opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/ToSalPropertyClassUtils.java [new file with mode: 0644]
opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/adsal/FlowServiceAdapter.java [deleted file]
opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/RpcConsumptionRegistry.java [new file with mode: 0644]
opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/RpcProvisionRegistry.java [new file with mode: 0644]
opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataProviderService.java
opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/model/SchemaService.java
opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/model/SchemaServiceListener.java [new file with mode: 0644]
opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/mount/MountProvisionInstance.java [new file with mode: 0644]
opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/mount/MountProvisionService.java [new file with mode: 0644]
opendaylight/md-sal/sal-dom-broker/pom.xml
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/BrokerActivator.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/BrokerImpl.xtend
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/ConsumerContextImpl.xtend
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/DataBrokerImpl.xtend [new file with mode: 0644]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/DataConsumerServiceImpl.xtend [deleted file]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/MountPointImpl.java [new file with mode: 0644]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/MountPointManagerImpl.xtend [new file with mode: 0644]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/ProviderContextImpl.xtend
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/SchemaServiceImpl.java [new file with mode: 0644]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/DataReaderRouter.xtend [new file with mode: 0644]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/NotificationRouterImpl.java [new file with mode: 0644]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/RpcRouterImpl.xtend [new file with mode: 0644]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/AbstractBrokerServiceProxy.java [new file with mode: 0644]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/DataBrokerServiceProxy.java [new file with mode: 0644]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/DataProviderServiceProxy.java [new file with mode: 0644]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/NotificationPublishServiceProxy.java [new file with mode: 0644]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/NotificationServiceProxy.java [new file with mode: 0644]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/ProxyFactory.xtend [new file with mode: 0644]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/SchemaServiceProxy.java [new file with mode: 0644]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/spi/NotificationRouter.java [new file with mode: 0644]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/spi/RoutedRpcProcessor.java [new file with mode: 0644]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/spi/RpcRouter.java [new file with mode: 0644]
opendaylight/md-sal/sal-netconf-connector/pom.xml
opendaylight/md-sal/sal-rest-connector/pom.xml
opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/api/RestconfService.java
opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/JsonMapper.java [new file with mode: 0644]
opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/JsonToCompositeNodeProvider.java
opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/RestconfProvider.java [new file with mode: 0644]
opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/StructuredDataToJsonProvider.java
opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/ControllerContext.xtend
opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/JsonMapper.xtend [deleted file]
opendaylight/md-sal/sal-rest-connector/src/main/resources/WEB-INF/web.xml [new file with mode: 0644]
opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/TestUtils.java
opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/XmlProvidersTest.java
opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/YangAndXmlToJsonConversionJsonReaderTest.java [new file with mode: 0644]
opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/YangAndXmlToJsonConversionRegExTest.java [new file with mode: 0644]
opendaylight/md-sal/sal-rest-connector/src/test/resources/yang-to-json-conversion/simple-yang-types/simple-yang-types.yang [new file with mode: 0644]
opendaylight/md-sal/sal-rest-connector/src/test/resources/yang-to-json-conversion/simple-yang-types/xml/awaited_output.json [new file with mode: 0644]
opendaylight/md-sal/sal-rest-connector/src/test/resources/yang-to-json-conversion/simple-yang-types/xml/data.xml [new file with mode: 0644]
opendaylight/md-sal/test/sal-rest-connector-it/pom.xml [new file with mode: 0644]
opendaylight/md-sal/test/sal-rest-connector-it/src/test/java/org/opendaylight/controller/test/restconf/it/ServiceProviderController.java [new file with mode: 0644]
opendaylight/md-sal/test/sal-rest-connector-it/src/test/resources/exam.properties [new file with mode: 0644]
opendaylight/md-sal/test/sal-rest-connector-it/src/test/resources/logback.xml [new file with mode: 0644]
opendaylight/md-sal/test/sal-rest-connector-it/src/test/resources/tomcat-server.xml [new file with mode: 0644]
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/NetconfOperationServiceImpl.java
opendaylight/netconf/config-netconf-connector/src/test/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/editconfig/EditConfigTest.java
opendaylight/netconf/config-persister-impl/src/main/resources/netconfOp/editConfig.xml
opendaylight/netconf/netconf-api/pom.xml
opendaylight/netconf/netconf-api/src/main/java/org/opendaylight/controller/netconf/api/NetconfOperationRouter.java
opendaylight/netconf/netconf-api/src/main/java/org/opendaylight/controller/netconf/api/NetconfSession.java
opendaylight/netconf/netconf-client/src/main/java/org/opendaylight/controller/netconf/client/NetconfClient.java
opendaylight/netconf/netconf-client/src/main/java/org/opendaylight/controller/netconf/client/NetconfClientSession.java
opendaylight/netconf/netconf-client/src/main/resources/client_hello.xml
opendaylight/netconf/netconf-impl/pom.xml
opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/NetconfServerSession.java
opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/NetconfServerSessionListener.java
opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/NetconfServerSessionListenerFactory.java
opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/mapping/ExiDecoderHandler.java [new file with mode: 0644]
opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/mapping/ExiEncoderHandler.java [new file with mode: 0644]
opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/mapping/operations/DefaultCloseSession.java
opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/mapping/operations/DefaultCommit.java
opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/mapping/operations/DefaultGetSchema.java
opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/mapping/operations/DefaultStartExi.java [new file with mode: 0644]
opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/mapping/operations/DefaultStopExi.java [new file with mode: 0644]
opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/osgi/NetconfOperationRouterImpl.java
opendaylight/netconf/netconf-impl/src/main/resources/server_hello.xml
opendaylight/netconf/netconf-impl/src/test/java/org/opendaylight/controller/netconf/impl/ExiEncodeDecodeTest.java [new file with mode: 0644]
opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfITTest.java
opendaylight/netconf/netconf-mapping-api/src/main/java/org/opendaylight/controller/netconf/mapping/api/DefaultNetconfOperation.java [new file with mode: 0644]
opendaylight/netconf/netconf-mapping-api/src/main/java/org/opendaylight/controller/netconf/mapping/api/NetconfOperationFilter.java
opendaylight/netconf/netconf-util/pom.xml
opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/handler/NetconfMessageAggregator.java
opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/handler/ssh/SshHandler.java [new file with mode: 0644]
opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/handler/ssh/authentication/AuthenticationHandler.java [new file with mode: 0644]
opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/handler/ssh/authentication/LoginPassword.java [new file with mode: 0644]
opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/handler/ssh/client/Invoker.java [new file with mode: 0644]
opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/handler/ssh/client/SshClient.java [new file with mode: 0644]
opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/handler/ssh/client/SshClientAdapter.java [new file with mode: 0644]
opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/handler/ssh/client/SshSession.java [new file with mode: 0644]
opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/handler/ssh/virtualsocket/ChannelInputStream.java [new file with mode: 0644]
opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/handler/ssh/virtualsocket/ChannelOutputStream.java [new file with mode: 0644]
opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/handler/ssh/virtualsocket/VirtualSocket.java [new file with mode: 0644]
opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/handler/ssh/virtualsocket/VirtualSocketException.java [new file with mode: 0644]
opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/mapping/AbstractNetconfOperation.java
opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/xml/ExiParameters.java [new file with mode: 0644]
opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/xml/ExiUtil.java [new file with mode: 0644]
opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/xml/XmlElement.java
opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/xml/XmlNetconfConstants.java
opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/xml/XmlUtil.java
opendaylight/netconf/netconf-util/src/test/java/org/opendaylight/controller/netconf/util/test/XmlFileLoader.java
opendaylight/netconf/netconf-util/src/test/resources/netconfMessages/startExi.xml [new file with mode: 0644]
opendaylight/netconf/netconf-util/src/test/resources/netconfMessages/stopExi.xml [new file with mode: 0644]
opendaylight/netconf/pom.xml
opendaylight/networkconfiguration/neutron/implementation/src/main/java/org/opendaylight/controller/networkconfig/neutron/implementation/Activator.java
opendaylight/networkconfiguration/neutron/implementation/src/main/java/org/opendaylight/controller/networkconfig/neutron/implementation/NeutronFloatingIPInterface.java
opendaylight/networkconfiguration/neutron/implementation/src/main/java/org/opendaylight/controller/networkconfig/neutron/implementation/NeutronNetworkInterface.java
opendaylight/networkconfiguration/neutron/implementation/src/main/java/org/opendaylight/controller/networkconfig/neutron/implementation/NeutronPortInterface.java
opendaylight/networkconfiguration/neutron/implementation/src/main/java/org/opendaylight/controller/networkconfig/neutron/implementation/NeutronRouterInterface.java
opendaylight/networkconfiguration/neutron/implementation/src/main/java/org/opendaylight/controller/networkconfig/neutron/implementation/NeutronSubnetInterface.java
opendaylight/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/INeutronFloatingIPAware.java
opendaylight/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/INeutronFloatingIPCRUD.java
opendaylight/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/INeutronNetworkAware.java
opendaylight/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/INeutronNetworkCRUD.java
opendaylight/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/INeutronPortAware.java
opendaylight/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/INeutronPortCRUD.java
opendaylight/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/INeutronRouterAware.java
opendaylight/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/INeutronRouterCRUD.java
opendaylight/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/INeutronSubnetAware.java
opendaylight/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/INeutronSubnetCRUD.java
opendaylight/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/NeutronCRUDInterfaces.java
opendaylight/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/NeutronFloatingIP.java
opendaylight/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/NeutronNetwork.java
opendaylight/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/NeutronPort.java
opendaylight/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/NeutronRouter.java
opendaylight/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/NeutronRouter_Interface.java
opendaylight/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/NeutronRouter_NetworkReference.java
opendaylight/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/NeutronSubnet.java
opendaylight/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/NeutronSubnet_HostRoute.java
opendaylight/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/NeutronSubnet_IPAllocationPool.java
opendaylight/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/Neutron_IPs.java
opendaylight/northbound/hosttracker/enunciate.xml
opendaylight/northbound/hosttracker/src/main/java/org/opendaylight/controller/hosttracker/northbound/HostTrackerNorthbound.java
opendaylight/northbound/networkconfiguration/bridgedomain/src/main/java/org/opendaylight/controller/networkconfig/bridgedomain/northbound/BridgeDomainNorthbound.java
opendaylight/northbound/networkconfiguration/bridgedomain/src/main/resources/WEB-INF/web.xml
opendaylight/northbound/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronFloatingIPRequest.java
opendaylight/northbound/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronFloatingIPsNorthbound.java
opendaylight/northbound/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronNetworkRequest.java
opendaylight/northbound/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronNetworksNorthbound.java
opendaylight/northbound/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronNorthboundRSApplication.java
opendaylight/northbound/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronPortRequest.java
opendaylight/northbound/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronPortsNorthbound.java
opendaylight/northbound/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronRouterRequest.java
opendaylight/northbound/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronRoutersNorthbound.java
opendaylight/northbound/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronSubnetRequest.java
opendaylight/northbound/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronSubnetsNorthbound.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/Bandwidth.java
opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/SubnetConfig.java
opendaylight/web/devices/pom.xml
opendaylight/web/devices/src/main/java/org/opendaylight/controller/devices/web/Devices.java
opendaylight/web/devices/src/main/java/org/opendaylight/controller/devices/web/NodeJsonBean.java
opendaylight/web/devices/src/main/resources/js/page.js
pom.xml
third-party/com.siemens.ct.exi/pom.xml [new file with mode: 0644]
third-party/commons/thirdparty/pom.xml
third-party/ganymed/pom.xml [new file with mode: 0644]
third-party/ganymed/src/main/java/ch/ethz/ssh2/Connection.java [new file with mode: 0644]
third-party/ganymed/src/main/java/ch/ethz/ssh2/transport/TransportManager.java [new file with mode: 0644]

index c810d65..2b7462a 100644 (file)
@@ -18,6 +18,8 @@
        <module name="UnusedImports"/>\r
        <module name="AvoidStarImport"/>\r
        <module name="UpperEll"/>\r
+       <module name="EmptyStatement"/>\r
+       <module name="EqualsHashCode"/>\r
     </module>\r
 \r
 </module>\r
index f7b2a01..58a6427 100644 (file)
     <java.version.target>1.7</java.version.target>
     <!-- enforcer version -->
     <enforcer.version>1.3.1</enforcer.version>
+    <exi.version>0.9.2-SNAPSHOT</exi.version>
   </properties>
 
   <dependencyManagement>
         <artifactId>org.openflow.openflowj</artifactId>
         <version>1.0.2</version>
       </dependency>
+      <dependency>
+        <groupId>org.opendaylight.controller.thirdparty</groupId>
+        <artifactId>exificient</artifactId>
+        <version>${exi.version}</version>
+      </dependency>
       <dependency>
         <groupId>org.opendaylight.controller.thirdparty</groupId>
         <artifactId>com.sun.jersey.jersey-servlet</artifactId>
         <artifactId>org.apache.catalina.filters.CorsFilter</artifactId>
         <version>7.0.42</version>
       </dependency>
+      <dependency>
+        <groupId>org.opendaylight.controller.thirdparty</groupId>
+        <artifactId>ganymed</artifactId>
+        <version>1.0-SNAPSHOT</version>
+      </dependency>
       <!-- yang model dependencies -->
       <dependency>
        <groupId>org.opendaylight.yangtools.model</groupId>
index 7cac106..3984545 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.controller.config.api;
 import javax.management.ObjectName;
 
 import org.opendaylight.controller.config.api.annotations.AbstractServiceInterface;
+import org.opendaylight.yangtools.concepts.Identifiable;
 
 /**
  * Each new {@link org.opendaylight.controller.config.spi.Module} can receive
@@ -18,7 +19,7 @@ import org.opendaylight.controller.config.api.annotations.AbstractServiceInterfa
  *
  * @see org.opendaylight.controller.config.spi.Module
  */
-public interface DependencyResolver {
+public interface DependencyResolver extends Identifiable<ModuleIdentifier> {
 
     /**
      * To be used during validation phase to validate serice interface of
index 343d45a..3f569ae 100644 (file)
@@ -138,8 +138,10 @@ class ConfigTransactionControllerImpl implements
         for (ModuleFactory moduleFactory : toBeAdded) {
             Set<? extends Module> defaultModules = moduleFactory.getDefaultModules(dependencyResolverManager, bundleContext);
             for (Module module : defaultModules) {
+                // ensure default module to be registered to jmx even if its module factory does not use dependencyResolverFactory
+                DependencyResolver dependencyResolver = dependencyResolverManager.getOrCreate(module.getIdentifier());
                 try {
-                    putConfigBeanToJMXAndInternalMaps(module.getIdentifier(), module, moduleFactory, null);
+                    putConfigBeanToJMXAndInternalMaps(module.getIdentifier(), module, moduleFactory, null, dependencyResolver);
                 } catch (InstanceAlreadyExistsException e) {
                     throw new IllegalStateException(e);
                 }
@@ -179,7 +181,7 @@ class ConfigTransactionControllerImpl implements
                     "Error while copying old configuration from %s to %s",
                     oldConfigBeanInfo, moduleFactory), e);
         }
-        putConfigBeanToJMXAndInternalMaps(moduleIdentifier, module, moduleFactory, oldConfigBeanInfo);
+        putConfigBeanToJMXAndInternalMaps(moduleIdentifier, module, moduleFactory, oldConfigBeanInfo, dependencyResolver);
     }
 
     @Override
@@ -196,19 +198,24 @@ class ConfigTransactionControllerImpl implements
         DependencyResolver dependencyResolver = dependencyResolverManager.getOrCreate(moduleIdentifier);
         Module module = moduleFactory.createModule(instanceName, dependencyResolver, bundleContext);
         return putConfigBeanToJMXAndInternalMaps(moduleIdentifier, module,
-                moduleFactory, null);
+                moduleFactory, null, dependencyResolver);
     }
 
     private synchronized ObjectName putConfigBeanToJMXAndInternalMaps(
             ModuleIdentifier moduleIdentifier, Module module,
             ModuleFactory moduleFactory,
-            @Nullable ModuleInternalInfo maybeOldConfigBeanInfo)
+            @Nullable ModuleInternalInfo maybeOldConfigBeanInfo, DependencyResolver dependencyResolver)
             throws InstanceAlreadyExistsException {
+
         logger.debug("Adding module {} to transaction {}", moduleIdentifier, this);
         if (moduleIdentifier.equals(module.getIdentifier())==false) {
             throw new IllegalStateException("Incorrect name reported by module. Expected "
              + moduleIdentifier + ", got " + module.getIdentifier());
         }
+        if (dependencyResolver.getIdentifier().equals(moduleIdentifier) == false ) {
+            throw new IllegalStateException("Incorrect name reported by dependency resolver. Expected "
+                    + moduleIdentifier + ", got " + dependencyResolver.getIdentifier());
+        }
         DynamicMBean writableDynamicWrapper = new DynamicWritableWrapper(
                 module, moduleIdentifier, transactionIdentifier,
                 readOnlyAtomicBoolean, transactionsMBeanServer,
@@ -224,8 +231,6 @@ class ConfigTransactionControllerImpl implements
                 maybeOldConfigBeanInfo, transactionModuleJMXRegistration);
 
         dependencyResolverManager.put(moduleInternalTransactionalInfo);
-        // ensure default module to be registered to jmx even if its module factory does not use dependencyResolverFactory
-        dependencyResolverManager.getOrCreate(moduleIdentifier);
         return writableON;
     }
 
index f817b41..065a0f8 100644 (file)
@@ -7,15 +7,6 @@
  */
 package org.opendaylight.controller.config.manager.impl.dependencyresolver;
 
-import static java.lang.String.format;
-
-import java.util.HashSet;
-import java.util.LinkedHashSet;
-import java.util.Set;
-
-import javax.annotation.concurrent.GuardedBy;
-import javax.management.ObjectName;
-
 import org.opendaylight.controller.config.api.DependencyResolver;
 import org.opendaylight.controller.config.api.JmxAttribute;
 import org.opendaylight.controller.config.api.JmxAttributeValidationException;
@@ -25,7 +16,14 @@ import org.opendaylight.controller.config.api.jmx.ObjectNameUtil;
 import org.opendaylight.controller.config.manager.impl.TransactionStatus;
 import org.opendaylight.controller.config.spi.Module;
 import org.opendaylight.controller.config.spi.ModuleFactory;
-import org.opendaylight.yangtools.concepts.Identifiable;
+
+import javax.annotation.concurrent.GuardedBy;
+import javax.management.ObjectName;
+import java.util.HashSet;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+import static java.lang.String.format;
 
 /**
  * Protect {@link org.opendaylight.controller.config.spi.Module#getInstance()}
@@ -33,7 +31,7 @@ import org.opendaylight.yangtools.concepts.Identifiable;
  * during validation. Tracks dependencies for ordering purposes.
  */
 final class DependencyResolverImpl implements DependencyResolver,
-       Identifiable<ModuleIdentifier>, Comparable<DependencyResolverImpl> {
+       Comparable<DependencyResolverImpl> {
     private final ModulesHolder modulesHolder;
     private final ModuleIdentifier name;
     private final TransactionStatus transactionStatus;
@@ -47,11 +45,6 @@ final class DependencyResolverImpl implements DependencyResolver,
         this.modulesHolder = modulesHolder;
     }
 
-    @Deprecated
-    public ModuleIdentifier getName() {
-        return name;
-    }
-
     /**
      * {@inheritDoc}
      */
@@ -177,7 +170,7 @@ final class DependencyResolverImpl implements DependencyResolver,
         int maxDepth = 0;
         LinkedHashSet<ModuleIdentifier> chainForDetectingCycles2 = new LinkedHashSet<>(
                 chainForDetectingCycles);
-        chainForDetectingCycles2.add(impl.getName());
+        chainForDetectingCycles2.add(impl.getIdentifier());
         for (ModuleIdentifier dependencyName : impl.dependencies) {
             DependencyResolverImpl dependentDRI = manager
                     .getOrCreate(dependencyName);
index 28f2e37..dea78c8 100644 (file)
@@ -7,15 +7,6 @@
  */
 package org.opendaylight.controller.config.manager.impl.dependencyresolver;
 
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.annotation.concurrent.GuardedBy;
-import javax.management.InstanceAlreadyExistsException;
-
 import org.opendaylight.controller.config.api.DependencyResolver;
 import org.opendaylight.controller.config.api.DependencyResolverFactory;
 import org.opendaylight.controller.config.api.JmxAttribute;
@@ -26,6 +17,14 @@ import org.opendaylight.controller.config.manager.impl.TransactionStatus;
 import org.opendaylight.controller.config.spi.Module;
 import org.opendaylight.controller.config.spi.ModuleFactory;
 
+import javax.annotation.concurrent.GuardedBy;
+import javax.management.InstanceAlreadyExistsException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 /**
  * Holds information about modules being created and destroyed within this
  * transaction. Observes usage of DependencyResolver within modules to figure
@@ -80,7 +79,7 @@ public class DependencyResolverManager implements TransactionHolder, DependencyR
         List<ModuleIdentifier> result = new ArrayList<>(
                 moduleIdentifiersToDependencyResolverMap.size());
         for (DependencyResolverImpl dri : getAllSorted()) {
-            ModuleIdentifier driName = dri.getName();
+            ModuleIdentifier driName = dri.getIdentifier();
             result.add(driName);
         }
         return result;
index f70c4bf..6bbd787 100644 (file)
@@ -7,18 +7,6 @@
  */
 package org.opendaylight.controller.config.manager.impl.dependencyresolver;
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.annotation.concurrent.GuardedBy;
-import javax.management.InstanceAlreadyExistsException;
-
 import org.opendaylight.controller.config.api.JmxAttribute;
 import org.opendaylight.controller.config.api.JmxAttributeValidationException;
 import org.opendaylight.controller.config.api.ModuleIdentifier;
@@ -28,6 +16,17 @@ import org.opendaylight.controller.config.manager.impl.ModuleInternalTransaction
 import org.opendaylight.controller.config.spi.Module;
 import org.opendaylight.controller.config.spi.ModuleFactory;
 
+import javax.annotation.concurrent.GuardedBy;
+import javax.management.InstanceAlreadyExistsException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
 /**
  * Represents modules to be committed.
  */
@@ -117,8 +116,7 @@ class ModulesHolder implements TransactionHolder {
             throws InstanceAlreadyExistsException {
         if (commitMap.containsKey(moduleIdentifier)) {
             throw new InstanceAlreadyExistsException(
-                    "There is an instance registered with name "
-                            + moduleIdentifier);
+                    "There is an instance registered with name " + moduleIdentifier);
         }
     }
 
index f81e747..8f05ed7 100644 (file)
@@ -7,10 +7,6 @@
  */
 package org.opendaylight.controller.config.manager.impl.dependencyresolver;
 
-import java.util.Map;
-
-import javax.management.InstanceAlreadyExistsException;
-
 import org.opendaylight.controller.config.api.JmxAttribute;
 import org.opendaylight.controller.config.api.ModuleIdentifier;
 import org.opendaylight.controller.config.manager.impl.CommitInfo;
@@ -18,6 +14,9 @@ import org.opendaylight.controller.config.manager.impl.ModuleInternalTransaction
 import org.opendaylight.controller.config.spi.Module;
 import org.opendaylight.controller.config.spi.ModuleFactory;
 
+import javax.management.InstanceAlreadyExistsException;
+import java.util.Map;
+
 interface TransactionHolder {
     CommitInfo toCommitInfo();
 
diff --git a/opendaylight/config/netty-threadgroup-config/pom.xml b/opendaylight/config/netty-threadgroup-config/pom.xml
new file mode 100644 (file)
index 0000000..e1b8fb3
--- /dev/null
@@ -0,0 +1,118 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <parent>
+        <groupId>org.opendaylight.controller</groupId>
+        <artifactId>config-subsystem</artifactId>
+        <version>0.2.2-SNAPSHOT</version>
+    </parent>
+
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>netty-threadgroup-config</artifactId>
+    <description>Configuration Wrapper around netty's event group</description>
+    <packaging>bundle</packaging>
+    <name>${project.artifactId}</name>
+    <prerequisites>
+        <maven>3.0.4</maven>
+    </prerequisites>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>config-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>threadpool-config-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+        </dependency>
+
+
+        <dependency>
+            <groupId>com.google.guava</groupId>
+            <artifactId>guava</artifactId>
+        </dependency>
+
+        <!--test dependencies -->
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>config-manager</artifactId>
+            <scope>test</scope>
+            <type>test-jar</type>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>config-manager</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>config-util</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.bgpcep</groupId>
+            <artifactId>mockito-configuration</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+    </dependencies>
+
+    <build>
+        <plugins>
+
+            <plugin>
+                <groupId>org.opendaylight.yangtools</groupId>
+                <artifactId>yang-maven-plugin</artifactId>
+            </plugin>
+
+
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <version>2.3.7</version>
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        <Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
+                        <Export-Package>
+                        </Export-Package>
+                        <Import-Package>
+                            com.google.common.base,
+                            io.netty.channel.nio,
+                            org.opendaylight.controller.config.yang.threadpool,
+                            io.netty.util.concurrent,
+                            org.opendaylight.controller.config.api,
+                            org.opendaylight.controller.config.api.annotations,
+                            org.opendaylight.controller.config.api.runtime,
+                            org.opendaylight.controller.config.spi,
+                            org.slf4j,
+                            org.osgi.framework
+                        </Import-Package>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+    <distributionManagement>
+        <site>
+            <id>${project.artifactId}</id>
+            <name>NETTY-THREADGROUP-CONFIG Module site</name>
+            <url>${basedir}/target/site/${project.artifactId}</url>
+        </site>
+    </distributionManagement>
+
+</project>
diff --git a/opendaylight/config/netty-threadgroup-config/src/main/java/org/opendaylight/controller/config/yang/netty/threadgroup/NettyThreadgroupModule.java b/opendaylight/config/netty-threadgroup-config/src/main/java/org/opendaylight/controller/config/yang/netty/threadgroup/NettyThreadgroupModule.java
new file mode 100644 (file)
index 0000000..fd6b216
--- /dev/null
@@ -0,0 +1,57 @@
+/**
+* Generated file
+
+* Generated from: yang module name: nsos-threadpool  yang module local name: netty-threadgroup-fixed
+* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+* Generated at: Fri Nov 08 08:31:45 CET 2013
+*
+* Do not modify this file unless it is present under src/main directory
+*/
+package org.opendaylight.controller.config.yang.netty.threadgroup;
+
+import com.google.common.base.Preconditions;
+import io.netty.channel.nio.NioEventLoopGroup;
+
+/**
+*
+*/
+public final class NettyThreadgroupModule extends org.opendaylight.controller.config.yang.netty.threadgroup.AbstractNettyThreadgroupModule
+{
+    public NettyThreadgroupModule(org.opendaylight.controller.config.api.ModuleIdentifier name, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+        super(name, dependencyResolver);
+    }
+
+    public NettyThreadgroupModule(org.opendaylight.controller.config.api.ModuleIdentifier name, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, NettyThreadgroupModule oldModule, java.lang.AutoCloseable oldInstance) {
+        super(name, dependencyResolver, oldModule, oldInstance);
+    }
+
+    @Override
+    public void validate(){
+        if(getThreadCount()!=null) {
+            Preconditions.checkArgument(getThreadCount() > 0, "Thread count cannot be < 0");
+        }
+    }
+
+    @Override
+    public java.lang.AutoCloseable createInstance() {
+        return getThreadCount()==null ? new NioEventLoopGroupCloseable() : new NioEventLoopGroupCloseable(getThreadCount());
+    }
+
+
+    private class NioEventLoopGroupCloseable extends NioEventLoopGroup implements AutoCloseable {
+
+
+        public NioEventLoopGroupCloseable(int threadCount) {
+            super(threadCount);
+        }
+
+        public NioEventLoopGroupCloseable() {
+            super();
+        }
+
+        @Override
+        public void close() throws Exception {
+            shutdownGracefully();
+        }
+    }
+}
diff --git a/opendaylight/config/netty-threadgroup-config/src/main/java/org/opendaylight/controller/config/yang/netty/threadgroup/NettyThreadgroupModuleFactory.java b/opendaylight/config/netty-threadgroup-config/src/main/java/org/opendaylight/controller/config/yang/netty/threadgroup/NettyThreadgroupModuleFactory.java
new file mode 100644 (file)
index 0000000..1dca381
--- /dev/null
@@ -0,0 +1,19 @@
+/**
+* Generated file
+
+* Generated from: yang module name: nsos-threadpool  yang module local name: netty-threadgroup-fixed
+* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+* Generated at: Fri Nov 08 08:31:45 CET 2013
+*
+* Do not modify this file unless it is present under src/main directory
+*/
+package org.opendaylight.controller.config.yang.netty.threadgroup;
+
+/**
+*
+*/
+public class NettyThreadgroupModuleFactory extends org.opendaylight.controller.config.yang.netty.threadgroup.AbstractNettyThreadgroupModuleFactory
+{
+
+
+}
diff --git a/opendaylight/config/netty-threadgroup-config/src/main/yang/nsos-netty-threadgroup.yang b/opendaylight/config/netty-threadgroup-config/src/main/yang/nsos-netty-threadgroup.yang
new file mode 100644 (file)
index 0000000..f13cf39
--- /dev/null
@@ -0,0 +1,53 @@
+// vi: set smarttab et sw=4 tabstop=4:
+module nsos-threadpool {
+    yang-version 1;
+       namespace "urn:opendaylight:params:xml:ns:yang:controller:netty:threadgroup";
+    prefix "netty-t";
+
+    import config { prefix config; revision-date 2013-04-05; }
+    import threadpool { prefix th; revision-date 2013-04-09; }
+
+    organization "Cisco Systems, Inc.";
+
+    contact "Robert Varga <rovarga@cisco.com>";
+
+    description
+        "This module contains the base YANG definitions for NS-OS
+         thread-related services.
+
+        Copyright (c)2013 Cisco Systems, Inc. All rights reserved.";
+
+    revision "2013-11-07" {
+        description
+            "Initial revision";
+    }
+
+    identity netty-threadgroup-fixed {
+        base config:module-type;
+        config:provided-service th:netty-threadgroup;
+        config:java-name-prefix NettyThreadgroup;
+    }
+
+    augment "/config:modules/config:module/config:configuration" {
+        case netty-threadgroup-fixed {
+            when "/config:modules/config:module/config:type = 'netty-threadgroup-fixed'";
+
+            leaf thread-count {
+                type uint16;
+
+                description "Number of threads to be used by NioEventLoopGroup. This attribute is optional and default value will be 2* Number of CPUs";
+            }
+
+            // TODO add optional thread factory dependency
+
+        }
+    }
+
+    augment "/config:modules/config:module/config:state" {
+        case netty-threadgroup-fixed {
+            when "/config:modules/config:module/config:type = 'netty-threadgroup-fixed'";
+        }
+    }
+
+
+}
diff --git a/opendaylight/config/netty-threadgroup-config/src/test/java/org/opendaylight/controller/config/yang/netty/threadgroup/NettyThreadgroupModuleTest.java b/opendaylight/config/netty-threadgroup-config/src/test/java/org/opendaylight/controller/config/yang/netty/threadgroup/NettyThreadgroupModuleTest.java
new file mode 100644 (file)
index 0000000..590bd91
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ * 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.config.yang.netty.threadgroup;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.controller.config.api.ConflictingVersionException;
+import org.opendaylight.controller.config.api.ValidationException;
+import org.opendaylight.controller.config.api.jmx.CommitStatus;
+import org.opendaylight.controller.config.manager.impl.AbstractConfigTest;
+import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;
+import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
+
+import javax.management.InstanceAlreadyExistsException;
+import javax.management.InstanceNotFoundException;
+import javax.management.ObjectName;
+
+public class NettyThreadgroupModuleTest extends AbstractConfigTest {
+
+    private NettyThreadgroupModuleFactory factory;
+    private final String instanceName = "netty1";
+
+    @Before
+    public void setUp() {
+        factory = new NettyThreadgroupModuleFactory();
+        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(factory));
+    }
+
+    @Test
+    public void testCreateBean() throws InstanceAlreadyExistsException, ValidationException, ConflictingVersionException {
+        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
+
+        createInstance(transaction, instanceName, 2);
+        createInstance(transaction, instanceName + 2, null);
+        transaction.validateConfig();
+        CommitStatus status = transaction.commit();
+
+        assertBeanCount(2, factory.getImplementationName());
+        assertStatus(status, 2, 0, 0);
+    }
+
+    @Test
+    public void testReusingOldInstance() throws InstanceAlreadyExistsException, ConflictingVersionException, ValidationException {
+
+        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
+        createInstance(transaction, instanceName, null);
+
+        transaction.commit();
+
+        transaction = configRegistryClient.createTransaction();
+        assertBeanCount(1, factory.getImplementationName());
+        CommitStatus status = transaction.commit();
+
+        assertBeanCount(1, factory.getImplementationName());
+        assertStatus(status, 0, 0, 1);
+    }
+
+    @Test
+    public void testReconfigure() throws InstanceAlreadyExistsException, ConflictingVersionException,
+            ValidationException, InstanceNotFoundException {
+
+        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
+        createInstance(transaction, instanceName, null);
+
+        transaction.commit();
+
+        transaction = configRegistryClient.createTransaction();
+        assertBeanCount(1, factory.getImplementationName());
+        NettyThreadgroupModuleMXBean mxBean = transaction.newMBeanProxy(
+                transaction.lookupConfigBean(AbstractNettyThreadgroupModuleFactory.NAME, instanceName),
+                NettyThreadgroupModuleMXBean.class);
+        mxBean.setThreadCount(1);
+        CommitStatus status = transaction.commit();
+
+        assertBeanCount(1, factory.getImplementationName());
+        assertStatus(status, 0, 1, 0);
+    }
+
+    private ObjectName createInstance(ConfigTransactionJMXClient transaction, String instanceName, Integer threads)
+            throws InstanceAlreadyExistsException {
+        ObjectName nameCreated = transaction.createModule(factory.getImplementationName(), instanceName);
+        NettyThreadgroupModuleMXBean mxBean = transaction.newMBeanProxy(nameCreated, NettyThreadgroupModuleMXBean.class);
+        mxBean.setThreadCount(threads);
+        return nameCreated;
+    }
+}
index 62b9ec3..6cf23e8 100755 (executable)
@@ -29,6 +29,9 @@
         <module>yang-store-impl</module>
         <module>yang-test</module>
         <module>logback-config</module>
+        <module>threadpool-config-api</module>
+        <module>threadpool-config-impl</module>
+        <module>netty-threadgroup-config</module>
     </modules>
 
     <profiles>
diff --git a/opendaylight/config/threadpool-config-api/pom.xml b/opendaylight/config/threadpool-config-api/pom.xml
new file mode 100644 (file)
index 0000000..1f8f1ea
--- /dev/null
@@ -0,0 +1,56 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+   <parent>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>config-subsystem</artifactId>
+      <version>0.2.2-SNAPSHOT</version>
+   </parent>
+   <modelVersion>4.0.0</modelVersion>
+   <artifactId>threadpool-config-api</artifactId>
+   <name>${project.artifactId}</name>
+   <packaging>bundle</packaging>
+   <prerequisites>
+      <maven>3.0.4</maven>
+   </prerequisites>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>config-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.google.guava</groupId>
+            <artifactId>guava</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>io.netty</groupId>
+            <artifactId>netty-transport</artifactId>
+        </dependency>
+    </dependencies>
+
+   <build>
+      <plugins>
+         <plugin>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>maven-bundle-plugin</artifactId>
+            <configuration>
+               <instructions>
+                  <Import-Package>
+                     org.opendaylight.controller.config.api.*,
+                     com.google.common.eventbus,
+                     io.netty.channel,
+                  </Import-Package>
+                  <Export-Package>
+                     org.opendaylight.controller.config.threadpool,
+                     org.opendaylight.controller.config.yang.threadpool
+                  </Export-Package>
+               </instructions>
+            </configuration>
+         </plugin>
+         <plugin>
+            <groupId>org.opendaylight.yangtools</groupId>
+            <artifactId>yang-maven-plugin</artifactId>
+         </plugin>
+      </plugins>
+   </build>
+</project>
\ No newline at end of file
diff --git a/opendaylight/config/threadpool-config-api/src/main/java/org/opendaylight/controller/config/threadpool/ScheduledThreadPool.java b/opendaylight/config/threadpool-config-api/src/main/java/org/opendaylight/controller/config/threadpool/ScheduledThreadPool.java
new file mode 100644 (file)
index 0000000..bf6c016
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * 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.config.threadpool;
+
+import java.util.concurrent.ScheduledExecutorService;
+
+/**
+ * Interface representing scheduled {@link ThreadPool}.
+ */
+public interface ScheduledThreadPool extends ThreadPool {
+
+    @Override
+    public ScheduledExecutorService getExecutor();
+}
\ No newline at end of file
diff --git a/opendaylight/config/threadpool-config-api/src/main/java/org/opendaylight/controller/config/threadpool/ThreadPool.java b/opendaylight/config/threadpool-config-api/src/main/java/org/opendaylight/controller/config/threadpool/ThreadPool.java
new file mode 100644 (file)
index 0000000..701b0bc
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * 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.config.threadpool;
+
+import java.util.concurrent.ExecutorService;
+
+/**
+ * Interface representing thread pool.
+ */
+public interface ThreadPool {
+
+    public ExecutorService getExecutor();
+
+    public int getMaxThreadCount();
+}
\ No newline at end of file
diff --git a/opendaylight/config/threadpool-config-api/src/main/yang/threadpool.yang b/opendaylight/config/threadpool-config-api/src/main/yang/threadpool.yang
new file mode 100644 (file)
index 0000000..5cc17e5
--- /dev/null
@@ -0,0 +1,87 @@
+// vi: set smarttab et sw=4 tabstop=4:
+module threadpool {
+       yang-version 1;
+       namespace "urn:opendaylight:params:xml:ns:yang:controller:threadpool";
+       prefix "th";
+
+       import config { prefix config; revision-date 2013-04-05; }
+
+       organization "Cisco Systems, Inc.";
+
+       contact "Robert Varga <rovarga@cisco.com>";
+
+    description
+        "This module contains the base YANG definitions for
+         thread-related services.
+
+        Copyright (c)2013 Cisco Systems, Inc. All rights reserved.;
+
+        This program and the accompanying materials are made available
+               under the 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 "2013-04-09" {
+        description
+            "Added eventbus service.";
+    }
+
+    revision "2013-04-05" {
+        description
+            "Updated with YANG extension for Java class specification.";
+    }
+
+    revision "2013-04-03" {
+        description
+            "Initial revision by Anton Tkacik, Tomas Olvecky and
+             Robert Varga.";
+    }
+
+    identity eventbus {
+        description
+            "Service representing an event bus. The service acts as message
+             router between event producers and event consumers";
+
+        base "config:service-type";
+        config:java-class "com.google.common.eventbus.EventBus";
+    }
+
+    identity threadfactory {
+        description
+            "Service representing a ThreadFactory instance. It is directly
+             useful in Java world, where various library pieces need to create
+             threads and you may want to inject a customized thread
+             implementation.";
+
+        base "config:service-type";
+        config:java-class "java.util.concurrent.ThreadFactory";
+    }
+
+       identity threadpool {
+        description
+            "A simple pool of threads able to execute work.";
+
+               base "config:service-type";
+        config:java-class "org.opendaylight.controller.config.threadpool.ThreadPool";
+       }
+
+       identity scheduled-threadpool {
+        description
+            "An extension of the simple pool of threads able to schedule
+             work to be executed at some point in time.";
+
+               base "threadpool";
+        config:java-class "org.opendaylight.controller.config.threadpool.ScheduledThreadPool";
+       }
+
+
+    identity netty-threadgroup {
+        description
+            "Configuration wrapper around netty's threadgroup";
+
+        base "config:service-type";
+        config:java-class "io.netty.channel.EventLoopGroup";
+    }
+
+
+}
diff --git a/opendaylight/config/threadpool-config-impl/pom.xml b/opendaylight/config/threadpool-config-impl/pom.xml
new file mode 100644 (file)
index 0000000..1bad023
--- /dev/null
@@ -0,0 +1,99 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+   <parent>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>config-subsystem</artifactId>
+      <version>0.2.2-SNAPSHOT</version>
+   </parent>
+   <modelVersion>4.0.0</modelVersion>
+   <artifactId>threadpool-config-impl</artifactId>
+   <name>${project.artifactId}</name>
+   <packaging>bundle</packaging>
+   <prerequisites>
+      <maven>3.0.4</maven>
+   </prerequisites>
+
+   <dependencies>
+      <dependency>
+         <groupId>${project.groupId}</groupId>
+         <artifactId>config-api</artifactId>
+      </dependency>
+      <dependency>
+         <groupId>${project.groupId}</groupId>
+         <artifactId>threadpool-config-api</artifactId>
+         <version>${project.version}</version>
+      </dependency>
+      <dependency>
+         <groupId>com.google.guava</groupId>
+         <artifactId>guava</artifactId>
+      </dependency>
+      <dependency>
+         <groupId>org.slf4j</groupId>
+         <artifactId>slf4j-api</artifactId>
+      </dependency>
+
+      <!--test dependencies -->
+      <dependency>
+         <groupId>org.opendaylight.controller</groupId>
+         <artifactId>config-manager</artifactId>
+         <scope>test</scope>
+         <type>test-jar</type>
+      </dependency>
+      <dependency>
+         <groupId>org.opendaylight.controller</groupId>
+         <artifactId>config-manager</artifactId>
+         <scope>test</scope>
+      </dependency>
+      <dependency>
+         <groupId>org.opendaylight.controller</groupId>
+         <artifactId>config-util</artifactId>
+         <scope>test</scope>
+      </dependency>
+      <dependency>
+         <groupId>org.opendaylight.bgpcep</groupId>
+         <artifactId>mockito-configuration</artifactId>
+         <scope>test</scope>
+      </dependency>
+   </dependencies>
+
+   <build>
+      <plugins>
+         <plugin>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>maven-bundle-plugin</artifactId>
+            <configuration>
+               <instructions>
+                  <Private-Package>
+                     org.opendaylight.controller.config.threadpool.util,
+                     javax.annotation.*,
+                     org.opendaylight.controller.config.yang.threadpool.impl,
+                  </Private-Package>
+                  <Import-Package>
+                     org.opendaylight.controller.config.api.*,
+                     org.opendaylight.controller.config.spi.*,
+                     org.opendaylight.controller.config.threadpool,
+                     org.opendaylight.controller.config.yang.threadpool,
+                     javax.management,
+                     org.osgi.framework,
+                     org.slf4j,
+                     com.google.common.*
+                  </Import-Package>
+                  <Export-Package>
+                     org.opendaylight.controller.config.threadpool.util
+                  </Export-Package>
+               </instructions>
+            </configuration>
+         </plugin>
+         <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-jar-plugin</artifactId>
+         </plugin>
+
+         <plugin>
+            <groupId>org.opendaylight.yangtools</groupId>
+            <artifactId>yang-maven-plugin</artifactId>
+         </plugin>
+      </plugins>
+   </build>
+
+</project>
\ No newline at end of file
diff --git a/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/threadpool/util/CloseableAsyncEventBus.java b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/threadpool/util/CloseableAsyncEventBus.java
new file mode 100644 (file)
index 0000000..93a08da
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * 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.config.threadpool.util;
+
+import com.google.common.eventbus.AsyncEventBus;
+import com.google.common.eventbus.DeadEvent;
+import com.google.common.eventbus.Subscribe;
+
+import java.io.Closeable;
+import java.io.IOException;
+
+import org.opendaylight.controller.config.threadpool.ThreadPool;
+import org.opendaylight.controller.config.yang.threadpool.impl.AsyncEventBusRuntimeMXBean;
+import org.opendaylight.controller.config.yang.threadpool.impl.AsyncEventBusRuntimeRegistration;
+import org.opendaylight.controller.config.yang.threadpool.impl.AsyncEventBusRuntimeRegistrator;
+
+/**
+ * Closeable version of {@link AsyncEventBus}.
+ */
+public class CloseableAsyncEventBus extends AsyncEventBus implements Closeable {
+    private final ThreadPool threadPool;
+    private final AsyncEventBusRuntimeRegistration rootRegistration;
+
+    public CloseableAsyncEventBus(String identifier, ThreadPool threadPool,
+            AsyncEventBusRuntimeRegistrator rootRegistrator) {
+        super(identifier, threadPool.getExecutor());
+        this.threadPool = threadPool;
+        rootRegistration = rootRegistrator.register(new AsyncEventBusRuntimeMXBean() {
+            private long deadEventsCounter = 0;
+
+            @Subscribe
+            public void increaseDeadEvents(DeadEvent deadEvent) {
+                deadEventsCounter++;
+            }
+
+            @Override
+            public Long countDeadEvents() {
+                return deadEventsCounter;
+            }
+
+        });
+    }
+
+    public ThreadPool getThreadPool() {
+        return threadPool;
+    }
+
+    @Override
+    public void close() throws IOException {
+        rootRegistration.close();
+    }
+
+}
diff --git a/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/threadpool/util/CloseableEventBus.java b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/threadpool/util/CloseableEventBus.java
new file mode 100644 (file)
index 0000000..b6dd77d
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * 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.config.threadpool.util;
+
+import java.io.Closeable;
+
+import org.opendaylight.controller.config.yang.threadpool.impl.EventBusRuntimeMXBean;
+import org.opendaylight.controller.config.yang.threadpool.impl.EventBusRuntimeRegistration;
+import org.opendaylight.controller.config.yang.threadpool.impl.EventBusRuntimeRegistrator;
+
+import com.google.common.eventbus.DeadEvent;
+import com.google.common.eventbus.EventBus;
+import com.google.common.eventbus.Subscribe;
+
+/**
+ * Closeable {@link EventBus}.
+ */
+public class CloseableEventBus extends EventBus implements Closeable {
+
+    private final EventBusRuntimeRegistration rootRegistration;
+
+    public CloseableEventBus(String identifier, EventBusRuntimeRegistrator rootRegistrator) {
+        super(identifier);
+        rootRegistration = rootRegistrator.register(new EventBusRuntimeMXBean() {
+            private long deadEventsCounter = 0;
+
+            @Subscribe
+            public void increaseDeadEvents(DeadEvent deadEvent) {
+                deadEventsCounter++;
+            }
+
+            @Override
+            public Long countDeadEvents() {
+                return deadEventsCounter;
+            }
+        });
+
+    }
+
+    @Override
+    public void close() {
+        rootRegistration.close();
+
+    }
+}
diff --git a/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/threadpool/util/FixedThreadPoolWrapper.java b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/threadpool/util/FixedThreadPoolWrapper.java
new file mode 100644 (file)
index 0000000..ca03443
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * 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.config.threadpool.util;
+
+import java.io.Closeable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.ThreadPoolExecutor;
+
+import org.opendaylight.controller.config.threadpool.ThreadPool;
+
+/**
+ * Implementation of {@link ThreadPool} using fixed number of threads wraps
+ * {@link ExecutorService}.
+ */
+public class FixedThreadPoolWrapper implements ThreadPool, Closeable {
+
+    private final ThreadPoolExecutor executor;
+
+    public FixedThreadPoolWrapper(int threadCount, ThreadFactory factory) {
+        this.executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(threadCount, factory);
+        executor.prestartAllCoreThreads();
+    }
+
+    @Override
+    public ExecutorService getExecutor() {
+        return Executors.unconfigurableExecutorService(executor);
+    }
+
+    @Override
+    public void close() {
+        executor.shutdown();
+    }
+
+    @Override
+    public int getMaxThreadCount() {
+        return executor.getMaximumPoolSize();
+    }
+
+    public void setMaxThreadCount(int maxThreadCount) {
+        executor.setCorePoolSize(maxThreadCount);
+        executor.setMaximumPoolSize(maxThreadCount);
+    }
+}
diff --git a/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/threadpool/util/FlexibleThreadPoolWrapper.java b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/threadpool/util/FlexibleThreadPoolWrapper.java
new file mode 100644 (file)
index 0000000..3dfa6e2
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * 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.config.threadpool.util;
+
+import java.io.Closeable;
+import java.io.IOException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.SynchronousQueue;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+
+import org.opendaylight.controller.config.threadpool.ThreadPool;
+
+/**
+ * Implementation of {@link ThreadPool} using flexible number of threads wraps
+ * {@link ExecutorService}.
+ */
+public class FlexibleThreadPoolWrapper implements ThreadPool, Closeable {
+    private final ThreadPoolExecutor executor;
+
+    public FlexibleThreadPoolWrapper(int minThreadCount, int maxThreadCount, long keepAlive, TimeUnit timeUnit,
+            ThreadFactory threadFactory) {
+
+        executor = new ThreadPoolExecutor(minThreadCount, maxThreadCount, keepAlive, timeUnit,
+                new SynchronousQueue<Runnable>(), threadFactory);
+        executor.prestartAllCoreThreads();
+    }
+
+    @Override
+    public ExecutorService getExecutor() {
+        return Executors.unconfigurableExecutorService(executor);
+    }
+
+    public int getMinThreadCount() {
+        return executor.getCorePoolSize();
+    }
+
+    public void setMinThreadCount(int minThreadCount) {
+        executor.setCorePoolSize(minThreadCount);
+    }
+
+    @Override
+    public int getMaxThreadCount() {
+        return executor.getMaximumPoolSize();
+    }
+
+    public void setMaxThreadCount(int maxThreadCount) {
+        executor.setMaximumPoolSize(maxThreadCount);
+    }
+
+    public long getKeepAliveMillis() {
+        return executor.getKeepAliveTime(TimeUnit.MILLISECONDS);
+    }
+
+    public void setKeepAliveMillis(long keepAliveMillis) {
+        executor.setKeepAliveTime(keepAliveMillis, TimeUnit.MILLISECONDS);
+    }
+
+    public void setThreadFactory(ThreadFactory threadFactory) {
+        executor.setThreadFactory(threadFactory);
+    }
+
+    public void prestartAllCoreThreads() {
+        executor.prestartAllCoreThreads();
+    }
+
+    @Override
+    public void close() throws IOException {
+        executor.shutdown();
+    }
+
+}
diff --git a/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/threadpool/util/NamingThreadPoolFactory.java b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/threadpool/util/NamingThreadPoolFactory.java
new file mode 100644 (file)
index 0000000..2e27d6c
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * 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.config.threadpool.util;
+
+import java.io.Closeable;
+import java.io.IOException;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.atomic.AtomicLong;
+
+import javax.annotation.concurrent.ThreadSafe;
+
+import com.google.common.base.Preconditions;
+
+/**
+ * Implementation of {@link ThreadFactory}.
+ */
+@ThreadSafe
+public class NamingThreadPoolFactory implements ThreadFactory, Closeable {
+
+    private final ThreadGroup group;
+    private final String namePrefix;
+    private final AtomicLong threadName = new AtomicLong();
+
+    public NamingThreadPoolFactory(String namePrefix) {
+        Preconditions.checkNotNull(namePrefix);
+        this.group = new ThreadGroup(namePrefix);
+        this.namePrefix = namePrefix;
+    }
+
+    @Override
+    public Thread newThread(Runnable r) {
+        return new Thread(group, r, String.format("%s-%d", group.getName(), threadName.incrementAndGet()));
+    }
+
+    @Override
+    public void close() throws IOException {
+    }
+
+    public String getNamePrefix() {
+        return namePrefix;
+    }
+
+}
diff --git a/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/threadpool/util/ScheduledThreadPoolWrapper.java b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/threadpool/util/ScheduledThreadPoolWrapper.java
new file mode 100644 (file)
index 0000000..ee3399e
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * 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.config.threadpool.util;
+
+import java.io.Closeable;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledThreadPoolExecutor;
+import java.util.concurrent.ThreadFactory;
+
+import org.opendaylight.controller.config.threadpool.ScheduledThreadPool;
+
+/**
+ * Implementation of {@link ScheduledThreadPool} wraps
+ * {@link ScheduledExecutorService}.
+ */
+public class ScheduledThreadPoolWrapper implements ScheduledThreadPool, Closeable {
+
+    private final ScheduledThreadPoolExecutor executor;
+    private final int threadCount;
+
+    public ScheduledThreadPoolWrapper(int threadCount, ThreadFactory factory) {
+        this.threadCount = threadCount;
+        this.executor = new ScheduledThreadPoolExecutor(threadCount, factory);
+        executor.prestartAllCoreThreads();
+    }
+
+    @Override
+    public ScheduledExecutorService getExecutor() {
+        return Executors.unconfigurableScheduledExecutorService(executor);
+    }
+
+    @Override
+    public void close() {
+        executor.shutdown();
+    }
+
+    @Override
+    public int getMaxThreadCount() {
+        return threadCount;
+    }
+
+}
diff --git a/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/AsyncEventBusModule.java b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/AsyncEventBusModule.java
new file mode 100644 (file)
index 0000000..f108303
--- /dev/null
@@ -0,0 +1,42 @@
+/**
+ * Generated file
+
+ * Generated from: yang module name: threadpool-impl  yang module local name: async-eventbus
+ * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+ * Generated at: Tue Nov 05 15:40:46 CET 2013
+ *
+ * Do not modify this file unless it is present under src/main directory
+ */
+package org.opendaylight.controller.config.yang.threadpool.impl;
+
+import org.opendaylight.controller.config.threadpool.util.CloseableAsyncEventBus;
+
+/**
+*
+*/
+public final class AsyncEventBusModule extends
+        org.opendaylight.controller.config.yang.threadpool.impl.AbstractAsyncEventBusModule {
+
+    public AsyncEventBusModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,
+            org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+        super(identifier, dependencyResolver);
+    }
+
+    public AsyncEventBusModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,
+            org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
+            AsyncEventBusModule oldModule, java.lang.AutoCloseable oldInstance) {
+        super(identifier, dependencyResolver, oldModule, oldInstance);
+    }
+
+    @Override
+    public void validate() {
+        super.validate();
+        // Add custom validation for module attributes here.
+    }
+
+    @Override
+    public java.lang.AutoCloseable createInstance() {
+        return new CloseableAsyncEventBus(getIdentifier().toString(), getThreadpoolDependency(),
+                getRootRuntimeBeanRegistratorWrapper());
+    }
+}
diff --git a/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/AsyncEventBusModuleFactory.java b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/AsyncEventBusModuleFactory.java
new file mode 100644 (file)
index 0000000..14fcf41
--- /dev/null
@@ -0,0 +1,18 @@
+/**
+ * Generated file
+
+ * Generated from: yang module name: threadpool-impl  yang module local name: async-eventbus
+ * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+ * Generated at: Tue Nov 05 15:40:46 CET 2013
+ *
+ * Do not modify this file unless it is present under src/main directory
+ */
+package org.opendaylight.controller.config.yang.threadpool.impl;
+
+/**
+*
+*/
+public class AsyncEventBusModuleFactory extends
+        org.opendaylight.controller.config.yang.threadpool.impl.AbstractAsyncEventBusModuleFactory {
+
+}
diff --git a/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/EventBusModule.java b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/EventBusModule.java
new file mode 100644 (file)
index 0000000..92eaee5
--- /dev/null
@@ -0,0 +1,41 @@
+/**
+ * Generated file
+
+ * Generated from: yang module name: threadpool-impl  yang module local name: eventbus
+ * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+ * Generated at: Tue Nov 05 15:40:46 CET 2013
+ *
+ * Do not modify this file unless it is present under src/main directory
+ */
+package org.opendaylight.controller.config.yang.threadpool.impl;
+
+import org.opendaylight.controller.config.threadpool.util.CloseableEventBus;
+
+/**
+*
+*/
+public final class EventBusModule extends
+        org.opendaylight.controller.config.yang.threadpool.impl.AbstractEventBusModule {
+
+    public EventBusModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,
+            org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+        super(identifier, dependencyResolver);
+    }
+
+    public EventBusModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,
+            org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, EventBusModule oldModule,
+            java.lang.AutoCloseable oldInstance) {
+        super(identifier, dependencyResolver, oldModule, oldInstance);
+    }
+
+    @Override
+    public void validate() {
+        super.validate();
+        // Add custom validation for module attributes here.
+    }
+
+    @Override
+    public java.lang.AutoCloseable createInstance() {
+        return new CloseableEventBus(getIdentifier().toString(), getRootRuntimeBeanRegistratorWrapper());
+    }
+}
diff --git a/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/EventBusModuleFactory.java b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/EventBusModuleFactory.java
new file mode 100644 (file)
index 0000000..e909998
--- /dev/null
@@ -0,0 +1,18 @@
+/**
+ * Generated file
+
+ * Generated from: yang module name: threadpool-impl  yang module local name: eventbus
+ * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+ * Generated at: Tue Nov 05 15:40:46 CET 2013
+ *
+ * Do not modify this file unless it is present under src/main directory
+ */
+package org.opendaylight.controller.config.yang.threadpool.impl;
+
+/**
+*
+*/
+public class EventBusModuleFactory extends
+        org.opendaylight.controller.config.yang.threadpool.impl.AbstractEventBusModuleFactory {
+
+}
diff --git a/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/FixedThreadPoolModule.java b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/FixedThreadPoolModule.java
new file mode 100644 (file)
index 0000000..a0a9add
--- /dev/null
@@ -0,0 +1,45 @@
+/**
+ * Generated file
+
+ * Generated from: yang module name: threadpool-impl  yang module local name: threadpool-fixed
+ * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+ * Generated at: Wed Nov 06 16:19:33 CET 2013
+ *
+ * Do not modify this file unless it is present under src/main directory
+ */
+package org.opendaylight.controller.config.yang.threadpool.impl;
+
+import org.opendaylight.controller.config.api.JmxAttributeValidationException;
+import org.opendaylight.controller.config.threadpool.util.FixedThreadPoolWrapper;
+
+/**
+*
+*/
+public final class FixedThreadPoolModule extends
+        org.opendaylight.controller.config.yang.threadpool.impl.AbstractFixedThreadPoolModule {
+
+    public FixedThreadPoolModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,
+            org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+        super(identifier, dependencyResolver);
+    }
+
+    public FixedThreadPoolModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,
+            org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
+            FixedThreadPoolModule oldModule, java.lang.AutoCloseable oldInstance) {
+        super(identifier, dependencyResolver, oldModule, oldInstance);
+    }
+
+    @Override
+    public void validate() {
+        super.validate();
+
+        JmxAttributeValidationException.checkNotNull(getMaxThreadCount(), maxThreadCountJmxAttribute);
+        JmxAttributeValidationException.checkCondition(getMaxThreadCount() > 0, "must be greater than zero",
+                maxThreadCountJmxAttribute);
+    }
+
+    @Override
+    public java.lang.AutoCloseable createInstance() {
+        return new FixedThreadPoolWrapper(getMaxThreadCount(), getThreadFactoryDependency());
+    }
+}
diff --git a/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/FixedThreadPoolModuleFactory.java b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/FixedThreadPoolModuleFactory.java
new file mode 100644 (file)
index 0000000..2803448
--- /dev/null
@@ -0,0 +1,18 @@
+/**
+ * Generated file
+
+ * Generated from: yang module name: threadpool-impl  yang module local name: threadpool-fixed
+ * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+ * Generated at: Wed Nov 06 16:19:33 CET 2013
+ *
+ * Do not modify this file unless it is present under src/main directory
+ */
+package org.opendaylight.controller.config.yang.threadpool.impl;
+
+/**
+*
+*/
+public class FixedThreadPoolModuleFactory extends
+        org.opendaylight.controller.config.yang.threadpool.impl.AbstractFixedThreadPoolModuleFactory {
+
+}
diff --git a/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/FlexibleThreadPoolModule.java b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/FlexibleThreadPoolModule.java
new file mode 100644 (file)
index 0000000..47b4eec
--- /dev/null
@@ -0,0 +1,55 @@
+/**
+ * Generated file
+
+ * Generated from: yang module name: threadpool-impl  yang module local name: threadpool-flexible
+ * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+ * Generated at: Wed Nov 06 16:19:33 CET 2013
+ *
+ * Do not modify this file unless it is present under src/main directory
+ */
+package org.opendaylight.controller.config.yang.threadpool.impl;
+
+import java.util.concurrent.TimeUnit;
+
+import org.opendaylight.controller.config.api.JmxAttributeValidationException;
+import org.opendaylight.controller.config.threadpool.util.FlexibleThreadPoolWrapper;
+
+/**
+*
+*/
+public final class FlexibleThreadPoolModule extends
+        org.opendaylight.controller.config.yang.threadpool.impl.AbstractFlexibleThreadPoolModule {
+
+    public FlexibleThreadPoolModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,
+            org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+        super(identifier, dependencyResolver);
+    }
+
+    public FlexibleThreadPoolModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,
+            org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
+            FlexibleThreadPoolModule oldModule, java.lang.AutoCloseable oldInstance) {
+        super(identifier, dependencyResolver, oldModule, oldInstance);
+    }
+
+    @Override
+    public void validate() {
+        super.validate();
+        JmxAttributeValidationException.checkNotNull(getKeepAliveMillis(), keepAliveMillisJmxAttribute);
+        JmxAttributeValidationException.checkCondition(getKeepAliveMillis() > 0, "must be greater than zero",
+                keepAliveMillisJmxAttribute);
+
+        JmxAttributeValidationException.checkNotNull(getMinThreadCount(), minThreadCountJmxAttribute);
+        JmxAttributeValidationException.checkCondition(getMinThreadCount() > 0, "must be greater than zero",
+                minThreadCountJmxAttribute);
+
+        JmxAttributeValidationException.checkNotNull(getMaxThreadCount(), maxThreadCountJmxAttribute);
+        JmxAttributeValidationException.checkCondition(getMaxThreadCount() > 0, "must be greater than zero",
+                maxThreadCountJmxAttribute);
+    }
+
+    @Override
+    public java.lang.AutoCloseable createInstance() {
+        return new FlexibleThreadPoolWrapper(getMinThreadCount(), getMaxThreadCount(), getKeepAliveMillis(),
+                TimeUnit.MILLISECONDS, getThreadFactoryDependency());
+    }
+}
diff --git a/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/FlexibleThreadPoolModuleFactory.java b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/FlexibleThreadPoolModuleFactory.java
new file mode 100644 (file)
index 0000000..ef6ebd2
--- /dev/null
@@ -0,0 +1,18 @@
+/**
+ * Generated file
+
+ * Generated from: yang module name: threadpool-impl  yang module local name: threadpool-flexible
+ * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+ * Generated at: Wed Nov 06 16:19:33 CET 2013
+ *
+ * Do not modify this file unless it is present under src/main directory
+ */
+package org.opendaylight.controller.config.yang.threadpool.impl;
+
+/**
+*
+*/
+public class FlexibleThreadPoolModuleFactory extends
+        org.opendaylight.controller.config.yang.threadpool.impl.AbstractFlexibleThreadPoolModuleFactory {
+
+}
diff --git a/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/NamingThreadFactoryModule.java b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/NamingThreadFactoryModule.java
new file mode 100644 (file)
index 0000000..a761727
--- /dev/null
@@ -0,0 +1,42 @@
+/**
+ * Generated file
+
+ * Generated from: yang module name: threadpool-impl  yang module local name: threadfactory-naming
+ * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+ * Generated at: Wed Nov 06 16:19:33 CET 2013
+ *
+ * Do not modify this file unless it is present under src/main directory
+ */
+package org.opendaylight.controller.config.yang.threadpool.impl;
+
+import org.opendaylight.controller.config.api.JmxAttributeValidationException;
+import org.opendaylight.controller.config.threadpool.util.NamingThreadPoolFactory;
+
+/**
+*
+*/
+public final class NamingThreadFactoryModule extends
+        org.opendaylight.controller.config.yang.threadpool.impl.AbstractNamingThreadFactoryModule {
+
+    public NamingThreadFactoryModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,
+            org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+        super(identifier, dependencyResolver);
+    }
+
+    public NamingThreadFactoryModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,
+            org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
+            NamingThreadFactoryModule oldModule, java.lang.AutoCloseable oldInstance) {
+        super(identifier, dependencyResolver, oldModule, oldInstance);
+    }
+
+    @Override
+    public void validate() {
+        super.validate();
+        JmxAttributeValidationException.checkNotNull(getNamePrefix(), namePrefixJmxAttribute);
+    }
+
+    @Override
+    public java.lang.AutoCloseable createInstance() {
+        return new NamingThreadPoolFactory(getNamePrefix());
+    }
+}
diff --git a/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/NamingThreadFactoryModuleFactory.java b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/NamingThreadFactoryModuleFactory.java
new file mode 100644 (file)
index 0000000..5e70afb
--- /dev/null
@@ -0,0 +1,18 @@
+/**
+ * Generated file
+
+ * Generated from: yang module name: threadpool-impl  yang module local name: threadfactory-naming
+ * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+ * Generated at: Wed Nov 06 16:19:33 CET 2013
+ *
+ * Do not modify this file unless it is present under src/main directory
+ */
+package org.opendaylight.controller.config.yang.threadpool.impl;
+
+/**
+*
+*/
+public class NamingThreadFactoryModuleFactory extends
+        org.opendaylight.controller.config.yang.threadpool.impl.AbstractNamingThreadFactoryModuleFactory {
+
+}
diff --git a/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/ScheduledThreadPoolModule.java b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/ScheduledThreadPoolModule.java
new file mode 100644 (file)
index 0000000..42739b4
--- /dev/null
@@ -0,0 +1,44 @@
+/**
+ * Generated file
+
+ * Generated from: yang module name: threadpool-impl  yang module local name: threadpool-scheduled
+ * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+ * Generated at: Wed Nov 06 16:19:33 CET 2013
+ *
+ * Do not modify this file unless it is present under src/main directory
+ */
+package org.opendaylight.controller.config.yang.threadpool.impl;
+
+import org.opendaylight.controller.config.api.JmxAttributeValidationException;
+import org.opendaylight.controller.config.threadpool.util.ScheduledThreadPoolWrapper;
+
+/**
+*
+*/
+public final class ScheduledThreadPoolModule extends
+        org.opendaylight.controller.config.yang.threadpool.impl.AbstractScheduledThreadPoolModule {
+
+    public ScheduledThreadPoolModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,
+            org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+        super(identifier, dependencyResolver);
+    }
+
+    public ScheduledThreadPoolModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,
+            org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
+            ScheduledThreadPoolModule oldModule, java.lang.AutoCloseable oldInstance) {
+        super(identifier, dependencyResolver, oldModule, oldInstance);
+    }
+
+    @Override
+    public void validate() {
+        super.validate();
+        JmxAttributeValidationException.checkNotNull(getMaxThreadCount(), maxThreadCountJmxAttribute);
+        JmxAttributeValidationException.checkCondition(getMaxThreadCount() > 0, "must be greater than zero",
+                maxThreadCountJmxAttribute);
+    }
+
+    @Override
+    public java.lang.AutoCloseable createInstance() {
+        return new ScheduledThreadPoolWrapper(getMaxThreadCount(), getThreadFactoryDependency());
+    }
+}
diff --git a/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/ScheduledThreadPoolModuleFactory.java b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/ScheduledThreadPoolModuleFactory.java
new file mode 100644 (file)
index 0000000..489af82
--- /dev/null
@@ -0,0 +1,18 @@
+/**
+ * Generated file
+
+ * Generated from: yang module name: threadpool-impl  yang module local name: threadpool-scheduled
+ * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+ * Generated at: Wed Nov 06 16:19:33 CET 2013
+ *
+ * Do not modify this file unless it is present under src/main directory
+ */
+package org.opendaylight.controller.config.yang.threadpool.impl;
+
+/**
+*
+*/
+public class ScheduledThreadPoolModuleFactory extends
+        org.opendaylight.controller.config.yang.threadpool.impl.AbstractScheduledThreadPoolModuleFactory {
+
+}
diff --git a/opendaylight/config/threadpool-config-impl/src/main/yang/threadpool-impl.yang b/opendaylight/config/threadpool-config-impl/src/main/yang/threadpool-impl.yang
new file mode 100644 (file)
index 0000000..a2366f2
--- /dev/null
@@ -0,0 +1,195 @@
+// vi: set smarttab et sw=4 tabstop=4:
+module threadpool-impl {
+    yang-version 1;
+    namespace "urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl";
+    prefix "th-java";
+
+    import threadpool { prefix th; revision-date 2013-04-09; }
+    import config { prefix config; revision-date 2013-04-05; }
+    import rpc-context { prefix rpcx; revision-date 2013-06-17; }
+
+    organization "Cisco Systems, Inc.";
+
+    contact "Robert Varga <rovarga@cisco.com>";
+
+    description
+        "This module contains the base YANG definitions for
+         thread services pure Java implementation.
+
+        Copyright (c)2013 Cisco Systems, Inc. All rights reserved.;
+        
+        This program and the accompanying materials are made available
+               under the 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 "2013-04-05" {
+        description
+            "Updated to work with new anchors.";
+    }
+
+    revision "2013-04-03" {
+        description
+            "Initial revision by Anton Tkacik, Tomas Olvecky and
+             Robert Varga.";
+    }
+
+    identity eventbus {
+        base config:module-type;
+        config:provided-service th:eventbus;
+        config:java-name-prefix EventBus;
+    }
+
+       augment "/config:modules/config:module/config:configuration" {
+               case eventbus {
+                       when "/config:modules/config:module/config:type = 'eventbus'";
+                       // No real configuration
+        }
+    }
+
+       augment "/config:modules/config:module/config:state" {
+               case eventbus {
+                       when "/config:modules/config:module/config:type = 'eventbus'";
+                       rpcx:rpc-context-instance "event-bus-rpc";
+        }
+    }
+
+       identity event-bus-rpc;
+
+    identity async-eventbus {
+        base config:module-type;
+        config:provided-service th:eventbus;
+        config:java-name-prefix AsyncEventBus;
+    }
+
+       augment "/config:modules/config:module/config:configuration" {
+               case async-eventbus {
+                       when "/config:modules/config:module/config:type = 'async-eventbus'";
+                       container threadpool {
+                               uses config:service-ref {
+                                       refine type {
+                                               //mandatory true;
+                                               config:required-identity th:threadpool;
+                                       }
+                               }
+                       }
+               }
+       }
+
+       augment "/config:modules/config:module/config:state" {
+               case async-eventbus {
+                       when "/config:modules/config:module/config:type = 'async-eventbus'";
+                       rpcx:rpc-context-instance "event-bus-rpc";
+        }
+    }
+
+       rpc get-dead-events-count {
+               config:java-name-prefix countDeadEvents;
+               input {
+                       uses rpcx:rpc-context-ref {
+                               refine context-instance {
+                                       rpcx:rpc-context-instance event-bus-rpc;
+                               }
+                       }
+               }
+               output {
+                       leaf result {
+                               type uint32;
+                       }
+               }
+       }
+       
+       identity threadfactory-naming {
+        base config:module-type;
+               config:provided-service th:threadfactory;
+        config:java-name-prefix NamingThreadFactory;
+    }
+
+       augment "/config:modules/config:module/config:configuration" {
+               case threadfactory-naming {
+                       when "/config:modules/config:module/config:type = 'threadfactory-naming'";
+                       leaf name-prefix {
+                               type string;
+                       }
+        }
+    }
+
+    identity threadpool-fixed {
+       base config:module-type;
+       config:provided-service th:threadpool;
+       config:java-name-prefix FixedThreadPool;
+    }
+
+       augment "/config:modules/config:module/config:configuration" {
+               case threadpool-fixed {
+                       when "/config:modules/config:module/config:type = 'threadpool-fixed'";
+                       leaf max-thread-count {
+                               type uint16;
+                       }
+
+                       container threadFactory {
+                               uses config:service-ref {
+                                       refine type {
+                                               //mandatory true;
+                                               config:required-identity th:threadfactory;
+                                       }
+                               }
+                       }
+        }
+       }
+
+       identity threadpool-flexible {
+               base config:module-type;
+               config:provided-service th:threadpool;
+               config:java-name-prefix FlexibleThreadPool;
+       }
+
+       augment "/config:modules/config:module/config:configuration" {
+               case threadpool-flexible {
+                       when "/config:modules/config:module/config:type = 'threadpool-flexible'";
+                       leaf max-thread-count {
+                               type uint16;
+                       }
+                       leaf minThreadCount {
+                               type uint16;
+                       }
+                       leaf keepAliveMillis {
+                               type uint32;
+                       }
+
+                       container threadFactory {
+                               uses config:service-ref {
+                                       refine type {
+                                          // mandatory true;
+                                               config:required-identity th:threadfactory;
+                                       }
+                               }
+                       }
+        }
+       }
+
+    identity threadpool-scheduled {
+               base config:module-type;
+               config:provided-service th:scheduled-threadpool;
+               config:java-name-prefix ScheduledThreadPool;
+       }
+
+       augment "/config:modules/config:module/config:configuration" {
+               case threadpool-scheduled {
+                       when "/config:modules/config:module/config:type = 'threadpool-scheduled'";
+                       leaf max-thread-count {
+                               type uint16;
+                       }
+
+                       container threadFactory {
+                               uses config:service-ref {
+                                       refine type {
+                                        //   mandatory true;
+                                               config:required-identity th:threadfactory;
+                                       }
+                               }
+                       }
+               }
+       }
+}
+
diff --git a/opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/async/AsyncEventBusConfigBeanTest.java b/opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/async/AsyncEventBusConfigBeanTest.java
new file mode 100644 (file)
index 0000000..b2fc75d
--- /dev/null
@@ -0,0 +1,100 @@
+package org.opendaylight.controller.config.threadpool.async;\r
+\r
+import static org.junit.Assert.assertThat;\r
+import static org.junit.Assert.fail;\r
+import static org.junit.matchers.JUnitMatchers.containsString;\r
+\r
+import javax.management.InstanceAlreadyExistsException;\r
+import javax.management.ObjectName;\r
+\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+import org.opendaylight.controller.config.api.ConflictingVersionException;\r
+import org.opendaylight.controller.config.api.ValidationException;\r
+import org.opendaylight.controller.config.api.jmx.CommitStatus;\r
+import org.opendaylight.controller.config.manager.impl.AbstractConfigTest;\r
+import org.opendaylight.controller.config.manager.impl.ClassBasedModuleFactory;\r
+import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;\r
+import org.opendaylight.controller.config.threadpool.scheduled.TestingScheduledThreadPoolModule;\r
+import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;\r
+import org.opendaylight.controller.config.yang.threadpool.impl.AsyncEventBusModuleFactory;\r
+import org.opendaylight.controller.config.yang.threadpool.impl.AsyncEventBusModuleMXBean;\r
+\r
+public class AsyncEventBusConfigBeanTest extends AbstractConfigTest {\r
+\r
+    private AsyncEventBusModuleFactory factory;\r
+    private final String instanceName = "async1";\r
+    private final String poolImplName = "fixed1";\r
+\r
+    @Before\r
+    public void setUp() {\r
+\r
+        ClassBasedModuleFactory scheduledThreadPoolConfigFactory = createClassBasedCBF(\r
+                TestingScheduledThreadPoolModule.class, poolImplName);\r
+\r
+        factory = new AsyncEventBusModuleFactory();\r
+        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(factory,\r
+                scheduledThreadPoolConfigFactory));\r
+    }\r
+\r
+    @Test\r
+    public void testCreateBean() throws InstanceAlreadyExistsException, ValidationException,\r
+            ConflictingVersionException {\r
+        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();\r
+\r
+        createAsynced(transaction, instanceName, transaction.createModule(poolImplName, "pool-test"));\r
+        transaction.validateConfig();\r
+        CommitStatus status = transaction.commit();\r
+\r
+        assertBeanCount(1, factory.getImplementationName());\r
+        assertStatus(status, 2, 0, 0);\r
+    }\r
+\r
+    @Test\r
+    public void testReusingOldInstance() throws InstanceAlreadyExistsException, ConflictingVersionException,\r
+            ValidationException {\r
+\r
+        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();\r
+        createAsynced(transaction, instanceName, transaction.createModule(poolImplName, "pool-test"));\r
+\r
+        transaction.commit();\r
+\r
+        assertBeanCount(1, factory.getImplementationName());\r
+\r
+        transaction = configRegistryClient.createTransaction();\r
+        CommitStatus status = transaction.commit();\r
+\r
+        assertBeanCount(1, factory.getImplementationName());\r
+        assertStatus(status, 0, 0, 2);\r
+\r
+    }\r
+\r
+    @Test\r
+    public void testInstanceAlreadyExistsException() throws ConflictingVersionException, ValidationException,\r
+            InstanceAlreadyExistsException {\r
+        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();\r
+\r
+        ObjectName poolCB = transaction.createModule(poolImplName, "pool-test");\r
+        createAsynced(transaction, instanceName, poolCB);\r
+        transaction.commit();\r
+\r
+        transaction = configRegistryClient.createTransaction();\r
+        try {\r
+            createAsynced(transaction, instanceName, poolCB);\r
+            fail();\r
+        } catch (InstanceAlreadyExistsException e) {\r
+            assertThat(\r
+                    e.getMessage(),\r
+                    containsString("There is an instance registered with name ModuleIdentifier{factoryName='async-eventbus', instanceName='async1'}"));\r
+        }\r
+    }\r
+\r
+    private ObjectName createAsynced(ConfigTransactionJMXClient transaction, String instanceName, ObjectName threadPool)\r
+            throws InstanceAlreadyExistsException {\r
+        ObjectName nameCreated = transaction.createModule(factory.getImplementationName(), instanceName);\r
+        AsyncEventBusModuleMXBean mxBean = transaction.newMBeanProxy(nameCreated, AsyncEventBusModuleMXBean.class);\r
+        mxBean.setThreadpool(threadPool);\r
+        return nameCreated;\r
+    }\r
+\r
+}\r
diff --git a/opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/eventbus/SyncEventBusConfigBeanTest.java b/opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/eventbus/SyncEventBusConfigBeanTest.java
new file mode 100644 (file)
index 0000000..4cd279f
--- /dev/null
@@ -0,0 +1,97 @@
+package org.opendaylight.controller.config.threadpool.eventbus;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.fail;
+import static org.junit.matchers.JUnitMatchers.containsString;
+
+import javax.management.InstanceAlreadyExistsException;
+import javax.management.ObjectName;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.controller.config.api.ConflictingVersionException;
+import org.opendaylight.controller.config.api.ValidationException;
+import org.opendaylight.controller.config.api.jmx.CommitStatus;
+import org.opendaylight.controller.config.manager.impl.AbstractConfigTest;
+import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;
+import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
+import org.opendaylight.controller.config.yang.threadpool.impl.EventBusModuleFactory;
+
+public class SyncEventBusConfigBeanTest extends AbstractConfigTest {
+
+    private EventBusModuleFactory factory;
+    private final String instanceName = "sync1";
+
+    @Before
+    public void setUp() {
+
+        factory = new EventBusModuleFactory();
+        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(factory));
+    }
+
+    @Test
+    public void testCreateBean() throws InstanceAlreadyExistsException, ValidationException,
+            ConflictingVersionException {
+        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
+
+        createSynced(transaction, instanceName);
+        transaction.validateConfig();
+        CommitStatus status = transaction.commit();
+
+        assertEquals(1, configRegistry.lookupConfigBeans(factory.getImplementationName()).size());
+        assertEquals(1, status.getNewInstances().size());
+        assertEquals(0, status.getRecreatedInstances().size());
+        assertEquals(0, status.getReusedInstances().size());
+        // TODO test dead event collector
+    }
+
+    @Test
+    public void testReusingOldInstance() throws InstanceAlreadyExistsException, ConflictingVersionException,
+            ValidationException {
+
+        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
+        createSynced(transaction, instanceName);
+
+        transaction.commit();
+
+        assertEquals(1, configRegistry.lookupConfigBeans(factory.getImplementationName()).size());
+
+        transaction = configRegistryClient.createTransaction();
+        CommitStatus status = transaction.commit();
+
+        assertEquals(1, configRegistry.lookupConfigBeans(factory.getImplementationName()).size());
+        assertEquals(0, status.getNewInstances().size());
+        assertEquals(0, status.getRecreatedInstances().size());
+        assertEquals(1, status.getReusedInstances().size());
+
+    }
+
+    @Test
+    public void testInstanceAlreadyExistsException() throws ConflictingVersionException, ValidationException {
+        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
+
+        try {
+            createSynced(transaction, instanceName);
+            transaction.commit();
+        } catch (InstanceAlreadyExistsException e1) {
+            fail();
+        }
+
+        transaction = configRegistryClient.createTransaction();
+        try {
+            createSynced(transaction, instanceName);
+            fail();
+        } catch (InstanceAlreadyExistsException e) {
+            assertThat(
+                    e.getMessage(),
+                    containsString("There is an instance registered with name ModuleIdentifier{factoryName='eventbus', instanceName='sync1'}"));
+        }
+    }
+
+    private ObjectName createSynced(ConfigTransactionJMXClient transaction, String instanceName)
+            throws InstanceAlreadyExistsException {
+        ObjectName nameCreated = transaction.createModule(factory.getImplementationName(), instanceName);
+        return nameCreated;
+    }
+}
diff --git a/opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/eventbus/TestingEventBusModule.java b/opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/eventbus/TestingEventBusModule.java
new file mode 100644 (file)
index 0000000..ee6bbc5
--- /dev/null
@@ -0,0 +1,28 @@
+package org.opendaylight.controller.config.threadpool.eventbus;\r
+\r
+import static org.mockito.Mockito.doNothing;\r
+import static org.mockito.Mockito.mock;\r
+\r
+import org.opendaylight.controller.config.api.DynamicMBeanWithInstance;\r
+import org.opendaylight.controller.config.api.ModuleIdentifier;\r
+import org.opendaylight.controller.config.manager.impl.AbstractMockedModule;\r
+import org.opendaylight.controller.config.spi.Module;\r
+import org.opendaylight.controller.config.threadpool.util.CloseableEventBus;\r
+import org.opendaylight.controller.config.yang.threadpool.EventBusServiceInterface;\r
+import org.opendaylight.controller.config.yang.threadpool.impl.EventBusModuleMXBean;\r
+\r
+public class TestingEventBusModule extends AbstractMockedModule implements Module, EventBusServiceInterface,\r
+        EventBusModuleMXBean {\r
+\r
+    public TestingEventBusModule(DynamicMBeanWithInstance old, ModuleIdentifier id) {\r
+        super(old, id);\r
+    }\r
+\r
+    @Override\r
+    protected AutoCloseable prepareMockedInstance() throws Exception {\r
+        CloseableEventBus bus = mock(CloseableEventBus.class);\r
+        doNothing().when(bus).close();\r
+        return bus;\r
+    }\r
+\r
+}\r
diff --git a/opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/fixed/FixedThreadPoolConfigBeanTest.java b/opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/fixed/FixedThreadPoolConfigBeanTest.java
new file mode 100644 (file)
index 0000000..4fda06b
--- /dev/null
@@ -0,0 +1,129 @@
+package org.opendaylight.controller.config.threadpool.fixed;\r
+\r
+import static org.junit.Assert.assertThat;\r
+import static org.junit.Assert.fail;\r
+import static org.junit.matchers.JUnitMatchers.containsString;\r
+\r
+import javax.management.InstanceAlreadyExistsException;\r
+import javax.management.InstanceNotFoundException;\r
+import javax.management.ObjectName;\r
+\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+import org.opendaylight.controller.config.api.ConflictingVersionException;\r
+import org.opendaylight.controller.config.api.ValidationException;\r
+import org.opendaylight.controller.config.api.jmx.CommitStatus;\r
+import org.opendaylight.controller.config.manager.impl.AbstractConfigTest;\r
+import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;\r
+import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;\r
+import org.opendaylight.controller.config.yang.threadpool.impl.FixedThreadPoolModuleFactory;\r
+import org.opendaylight.controller.config.yang.threadpool.impl.FixedThreadPoolModuleMXBean;\r
+import org.opendaylight.controller.config.yang.threadpool.impl.NamingThreadFactoryModuleFactory;\r
+import org.opendaylight.controller.config.yang.threadpool.impl.NamingThreadFactoryModuleMXBean;\r
+\r
+public class FixedThreadPoolConfigBeanTest extends AbstractConfigTest {\r
+\r
+    private FixedThreadPoolModuleFactory factory;\r
+    private final String nameInstance = "fixedInstance";\r
+\r
+    @Before\r
+    public void setUp() {\r
+        factory = new FixedThreadPoolModuleFactory();\r
+        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(factory,\r
+                new NamingThreadFactoryModuleFactory()));\r
+    }\r
+\r
+    @Test\r
+    public void testCreateBean() throws InstanceAlreadyExistsException, ValidationException,\r
+            ConflictingVersionException {\r
+        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();\r
+        createFixed(transaction, nameInstance, 2);\r
+\r
+        transaction.validateConfig();\r
+        CommitStatus status = transaction.commit();\r
+\r
+        assertBeanCount(1, factory.getImplementationName());\r
+        assertStatus(status, 2, 0, 0);\r
+    }\r
+\r
+    @Test\r
+    public void testReusingOldInstance() throws InstanceAlreadyExistsException, ConflictingVersionException,\r
+            ValidationException {\r
+        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();\r
+        createFixed(transaction, nameInstance, 4);\r
+\r
+        transaction.validateConfig();\r
+        transaction.commit();\r
+\r
+        assertBeanCount(1, factory.getImplementationName());\r
+\r
+        transaction = configRegistryClient.createTransaction();\r
+        CommitStatus status = transaction.commit();\r
+\r
+        assertBeanCount(1, factory.getImplementationName());\r
+        assertStatus(status, 0, 0, 2);\r
+    }\r
+\r
+    @Test\r
+    public void testNegative() throws ConflictingVersionException, ValidationException, InstanceAlreadyExistsException {\r
+        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();\r
+\r
+        createFixed(transaction, nameInstance, 5);\r
+        transaction.commit();\r
+\r
+        transaction = configRegistryClient.createTransaction();\r
+        try {\r
+            createFixed(transaction, nameInstance, 0);\r
+            fail();\r
+        } catch (InstanceAlreadyExistsException e) {\r
+            assertThat(\r
+                    e.getMessage(),\r
+                    containsString("There is an instance registered with name ModuleIdentifier{factoryName='threadpool-fixed', instanceName='fixedInstance'}"));\r
+        }\r
+    }\r
+\r
+    @Test\r
+    public void testDestroy() throws InstanceAlreadyExistsException, ValidationException, ConflictingVersionException,\r
+            InstanceNotFoundException {\r
+        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();\r
+        createFixed(transaction, nameInstance, 1);\r
+\r
+        transaction.commit();\r
+\r
+        transaction = configRegistryClient.createTransaction();\r
+        transaction.destroyConfigBean(factory.getImplementationName(), nameInstance);\r
+        CommitStatus status = transaction.commit();\r
+\r
+        assertBeanCount(0, factory.getImplementationName());\r
+        assertStatus(status, 0, 0, 1);\r
+    }\r
+\r
+    @Test\r
+    public void testValidationException() throws InstanceAlreadyExistsException {\r
+        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();\r
+        createFixed(transaction, nameInstance, -1);\r
+        try {\r
+            transaction.validateConfig();\r
+            fail();\r
+        } catch (ValidationException e) {\r
+            assertThat(e.getMessage(), containsString("MaxThreadCount must be greater than zero"));\r
+        }\r
+    }\r
+\r
+    private ObjectName createFixed(ConfigTransactionJMXClient transaction, String name, int numberOfThreads)\r
+            throws InstanceAlreadyExistsException {\r
+        ObjectName nameCreated = transaction.createModule(factory.getImplementationName(), name);\r
+        FixedThreadPoolModuleMXBean mxBean = transaction.newMXBeanProxy(nameCreated, FixedThreadPoolModuleMXBean.class);\r
+        mxBean.setMaxThreadCount(numberOfThreads);\r
+\r
+        ObjectName threadFactoryON = transaction.createModule(NamingThreadFactoryModuleFactory.NAME, "naming");\r
+        NamingThreadFactoryModuleMXBean namingThreadFactoryModuleMXBean = transaction.newMXBeanProxy(threadFactoryON,\r
+                NamingThreadFactoryModuleMXBean.class);\r
+        namingThreadFactoryModuleMXBean.setNamePrefix("prefix");\r
+\r
+        mxBean.setThreadFactory(threadFactoryON);\r
+\r
+        return nameCreated;\r
+    }\r
+\r
+}\r
diff --git a/opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/fixed/TestingFixedThreadPoolModule.java b/opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/fixed/TestingFixedThreadPoolModule.java
new file mode 100644 (file)
index 0000000..00be5d8
--- /dev/null
@@ -0,0 +1,30 @@
+package org.opendaylight.controller.config.threadpool.fixed;\r
+\r
+import static org.mockito.Mockito.doNothing;\r
+import static org.mockito.Mockito.doReturn;\r
+import static org.mockito.Mockito.mock;\r
+\r
+import java.util.concurrent.ExecutorService;\r
+\r
+import org.opendaylight.controller.config.api.DynamicMBeanWithInstance;\r
+import org.opendaylight.controller.config.api.ModuleIdentifier;\r
+import org.opendaylight.controller.config.manager.impl.AbstractMockedModule;\r
+import org.opendaylight.controller.config.spi.Module;\r
+import org.opendaylight.controller.config.threadpool.util.FixedThreadPoolWrapper;\r
+import org.opendaylight.controller.config.yang.threadpool.ThreadPoolServiceInterface;\r
+\r
+public class TestingFixedThreadPoolModule extends AbstractMockedModule implements ThreadPoolServiceInterface, Module {\r
+\r
+    public TestingFixedThreadPoolModule(DynamicMBeanWithInstance old, ModuleIdentifier id) {\r
+        super(old, id);\r
+    }\r
+\r
+    @Override\r
+    protected AutoCloseable prepareMockedInstance() throws Exception {\r
+        FixedThreadPoolWrapper pool = mock(FixedThreadPoolWrapper.class);\r
+        doNothing().when(pool).close();\r
+        doReturn(mock(ExecutorService.class)).when(pool).getExecutor();\r
+        return pool;\r
+    }\r
+\r
+}\r
diff --git a/opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/flexible/FlexibleThreadPoolConfigBeanTest.java b/opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/flexible/FlexibleThreadPoolConfigBeanTest.java
new file mode 100644 (file)
index 0000000..ee1de8f
--- /dev/null
@@ -0,0 +1,173 @@
+package org.opendaylight.controller.config.threadpool.flexible;\r
+\r
+import static org.junit.Assert.assertThat;\r
+import static org.junit.Assert.fail;\r
+import static org.junit.matchers.JUnitMatchers.containsString;\r
+\r
+import javax.management.InstanceAlreadyExistsException;\r
+import javax.management.InstanceNotFoundException;\r
+import javax.management.ObjectName;\r
+\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+import org.opendaylight.controller.config.api.ConflictingVersionException;\r
+import org.opendaylight.controller.config.api.ValidationException;\r
+import org.opendaylight.controller.config.api.jmx.CommitStatus;\r
+import org.opendaylight.controller.config.manager.impl.AbstractConfigTest;\r
+import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;\r
+import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;\r
+import org.opendaylight.controller.config.yang.threadpool.impl.FlexibleThreadPoolModuleFactory;\r
+import org.opendaylight.controller.config.yang.threadpool.impl.FlexibleThreadPoolModuleMXBean;\r
+import org.opendaylight.controller.config.yang.threadpool.impl.NamingThreadFactoryModuleFactory;\r
+import org.opendaylight.controller.config.yang.threadpool.impl.NamingThreadFactoryModuleMXBean;\r
+\r
+public class FlexibleThreadPoolConfigBeanTest extends AbstractConfigTest {\r
+\r
+    private FlexibleThreadPoolModuleFactory flexibleFactory;\r
+    private final String instanceName = "flexible1";\r
+    private final String threadFactoryName = "threadFactoryName";\r
+\r
+    @Before\r
+    public void setUp() {\r
+\r
+        flexibleFactory = new FlexibleThreadPoolModuleFactory();\r
+        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(flexibleFactory,\r
+                new NamingThreadFactoryModuleFactory()));\r
+    }\r
+\r
+    @Test\r
+    public void testCreateBean() throws InstanceAlreadyExistsException, ValidationException,\r
+            ConflictingVersionException {\r
+        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();\r
+\r
+        createFlexible(transaction, instanceName, threadFactoryName, 1, 20, 20);\r
+        transaction.validateConfig();\r
+        CommitStatus status = transaction.commit();\r
+\r
+        assertBeanCount(1, flexibleFactory.getImplementationName());\r
+        assertStatus(status, 2, 0, 0);\r
+    }\r
+\r
+    @Test\r
+    public void testReusingOldInstance() throws InstanceAlreadyExistsException, ConflictingVersionException,\r
+            ValidationException {\r
+\r
+        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();\r
+        createFlexible(transaction, instanceName, threadFactoryName, 1, 20, 10);\r
+\r
+        transaction.commit();\r
+\r
+        assertBeanCount(1, flexibleFactory.getImplementationName());\r
+\r
+        transaction = configRegistryClient.createTransaction();\r
+        CommitStatus status = transaction.commit();\r
+\r
+        assertBeanCount(1, flexibleFactory.getImplementationName());\r
+        assertStatus(status, 0, 0, 2);\r
+\r
+    }\r
+\r
+    @Test\r
+    public void testInstanceAlreadyExistsException() throws ConflictingVersionException, ValidationException {\r
+        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();\r
+\r
+        try {\r
+            createFlexible(transaction, instanceName, threadFactoryName, 1, 1, 2);\r
+            transaction.commit();\r
+        } catch (InstanceAlreadyExistsException e1) {\r
+            fail();\r
+        }\r
+\r
+        transaction = configRegistryClient.createTransaction();\r
+        try {\r
+            createFlexible(transaction, instanceName, "threadFactoryName1", 2, 2, 2);\r
+            fail();\r
+        } catch (InstanceAlreadyExistsException e) {\r
+            assertThat(\r
+                    e.getMessage(),\r
+                    containsString("There is an instance registered with name ModuleIdentifier{factoryName='threadpool-flexible', instanceName='flexible1'}"));\r
+        }\r
+    }\r
+\r
+    @Test\r
+    public void testValidationException() throws InstanceAlreadyExistsException {\r
+        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();\r
+\r
+        createFlexible(transaction, instanceName, threadFactoryName, 0, 10, 10);\r
+\r
+        try {\r
+            transaction.validateConfig();\r
+            fail();\r
+        } catch (ValidationException e) {\r
+            assertThat(e.getMessage(), containsString("MinThreadCount must be greater than zero"));\r
+        }\r
+    }\r
+\r
+    @Test\r
+    public void testValidationException2() throws InstanceAlreadyExistsException {\r
+        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();\r
+\r
+        createFlexible(transaction, instanceName, threadFactoryName, 0, 0, 10);\r
+\r
+        try {\r
+            transaction.validateConfig();\r
+            fail();\r
+        } catch (ValidationException e) {\r
+            assertThat(e.getMessage(), containsString("KeepAliveMillis must be greater than zero"));\r
+        }\r
+    }\r
+\r
+    @Test\r
+    public void testValidationException3() throws InstanceAlreadyExistsException {\r
+        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();\r
+\r
+        createFlexible(transaction, instanceName, threadFactoryName, 10, 50, 0);\r
+\r
+        try {\r
+            transaction.validateConfig();\r
+            fail();\r
+        } catch (ValidationException e) {\r
+            assertThat(e.getMessage(), containsString("MaxThreadCount must be greater than zero"));\r
+        }\r
+    }\r
+\r
+    private ObjectName createFlexible(ConfigTransactionJMXClient transaction, String instanceName,\r
+            String threadFactoryName, int minThreadCount, long keepAliveMillis, int maxThreadCount)\r
+            throws InstanceAlreadyExistsException {\r
+\r
+        ObjectName threadFactoryON = transaction.createModule(NamingThreadFactoryModuleFactory.NAME, threadFactoryName);\r
+        NamingThreadFactoryModuleMXBean namingThreadFactoryModuleMXBean = transaction.newMXBeanProxy(threadFactoryON,\r
+                NamingThreadFactoryModuleMXBean.class);\r
+        namingThreadFactoryModuleMXBean.setNamePrefix("prefix");\r
+\r
+        ObjectName flexibleON = transaction.createModule(flexibleFactory.getImplementationName(), instanceName);\r
+        FlexibleThreadPoolModuleMXBean mxBean = transaction.newMBeanProxy(flexibleON,\r
+                FlexibleThreadPoolModuleMXBean.class);\r
+        mxBean.setKeepAliveMillis(keepAliveMillis);\r
+        mxBean.setMaxThreadCount(maxThreadCount);\r
+        mxBean.setMinThreadCount(minThreadCount);\r
+        mxBean.setThreadFactory(threadFactoryON);\r
+        return flexibleON;\r
+    }\r
+\r
+    @Test\r
+    public void testReconfigurationInstance() throws InstanceAlreadyExistsException, ValidationException,\r
+            ConflictingVersionException, InstanceNotFoundException {\r
+        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();\r
+        createFlexible(transaction, instanceName, threadFactoryName, 2, 2, 2);\r
+\r
+        transaction.commit();\r
+\r
+        transaction = configRegistryClient.createTransaction();\r
+        ObjectName databaseNew = transaction.lookupConfigBean(flexibleFactory.getImplementationName(), instanceName);\r
+        FlexibleThreadPoolModuleMXBean proxy = transaction.newMXBeanProxy(databaseNew,\r
+                FlexibleThreadPoolModuleMXBean.class);\r
+        proxy.setMaxThreadCount(99);\r
+\r
+        CommitStatus status = transaction.commit();\r
+\r
+        assertBeanCount(1, flexibleFactory.getImplementationName());\r
+        assertStatus(status, 0, 1, 1);\r
+    }\r
+\r
+}\r
diff --git a/opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/naming/NamingThreadPoolFactoryConfigBeanTest.java b/opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/naming/NamingThreadPoolFactoryConfigBeanTest.java
new file mode 100644 (file)
index 0000000..9e9565a
--- /dev/null
@@ -0,0 +1,136 @@
+package org.opendaylight.controller.config.threadpool.naming;\r
+\r
+import static org.junit.Assert.assertEquals;\r
+import static org.junit.Assert.assertThat;\r
+import static org.junit.Assert.assertTrue;\r
+import static org.junit.Assert.fail;\r
+import static org.junit.matchers.JUnitMatchers.containsString;\r
+\r
+import javax.management.InstanceAlreadyExistsException;\r
+import javax.management.InstanceNotFoundException;\r
+import javax.management.ObjectName;\r
+\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+import org.opendaylight.controller.config.api.ConflictingVersionException;\r
+import org.opendaylight.controller.config.api.ValidationException;\r
+import org.opendaylight.controller.config.api.jmx.CommitStatus;\r
+import org.opendaylight.controller.config.manager.impl.AbstractConfigTest;\r
+import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;\r
+import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;\r
+import org.opendaylight.controller.config.yang.threadpool.ThreadFactoryServiceInterface;\r
+import org.opendaylight.controller.config.yang.threadpool.impl.NamingThreadFactoryModuleFactory;\r
+import org.opendaylight.controller.config.yang.threadpool.impl.NamingThreadFactoryModuleMXBean;\r
+\r
+public class NamingThreadPoolFactoryConfigBeanTest extends AbstractConfigTest {\r
+\r
+    private NamingThreadFactoryModuleFactory factory;\r
+    private final String instanceName = "named";\r
+\r
+    @Before\r
+    public void setUp() {\r
+\r
+        factory = new NamingThreadFactoryModuleFactory();\r
+        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(factory));\r
+    }\r
+\r
+    @Test\r
+    public void testCreateBean() throws InstanceAlreadyExistsException, ValidationException,\r
+            ConflictingVersionException {\r
+        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();\r
+\r
+        createNamed(transaction, instanceName, "prefixes");\r
+        transaction.validateConfig();\r
+        CommitStatus status = transaction.commit();\r
+\r
+        assertEquals(1, configRegistry.lookupConfigBeans(factory.getImplementationName()).size());\r
+        assertEquals(1, status.getNewInstances().size());\r
+        assertEquals(0, status.getRecreatedInstances().size());\r
+        assertEquals(0, status.getReusedInstances().size());\r
+    }\r
+\r
+    @Test\r
+    public void testReusingOldInstance() throws InstanceAlreadyExistsException, ConflictingVersionException,\r
+            ValidationException {\r
+\r
+        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();\r
+        createNamed(transaction, instanceName, "prefixes");\r
+\r
+        transaction.commit();\r
+\r
+        assertEquals(1, configRegistry.lookupConfigBeans(factory.getImplementationName()).size());\r
+\r
+        transaction = configRegistryClient.createTransaction();\r
+        CommitStatus status = transaction.commit();\r
+\r
+        assertEquals(1, configRegistry.lookupConfigBeans(factory.getImplementationName()).size());\r
+        assertEquals(0, status.getNewInstances().size());\r
+        assertEquals(0, status.getRecreatedInstances().size());\r
+        assertEquals(1, status.getReusedInstances().size());\r
+\r
+    }\r
+\r
+    @Test\r
+    public void testInstanceAlreadyExistsException() throws ConflictingVersionException, ValidationException,\r
+            InstanceAlreadyExistsException {\r
+        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();\r
+\r
+        createNamed(transaction, instanceName, "prefixes");\r
+        transaction.commit();\r
+\r
+        transaction = configRegistryClient.createTransaction();\r
+        try {\r
+            createNamed(transaction, instanceName, "prefixes1");\r
+            fail();\r
+        } catch (InstanceAlreadyExistsException e) {\r
+            assertThat(\r
+                    e.getMessage(),\r
+                    containsString("There is an instance registered with name ModuleIdentifier{factoryName='threadfactory-naming', instanceName='named'}"));\r
+        }\r
+    }\r
+\r
+    @Test\r
+    public void testValidationException() throws InstanceAlreadyExistsException {\r
+        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();\r
+\r
+        ObjectName nameCreated = transaction.createModule(factory.getImplementationName(), instanceName);\r
+        transaction.newMXBeanProxy(nameCreated, ThreadFactoryServiceInterface.class);\r
+        try {\r
+            transaction.validateConfig();\r
+            fail();\r
+        } catch (ValidationException e) {\r
+            assertTrue(e.getFailedValidations().containsKey(factory.getImplementationName()));\r
+            assertEquals(1, e.getFailedValidations().get(factory.getImplementationName()).keySet().size());\r
+        }\r
+    }\r
+\r
+    @Test\r
+    public void testReconfigurationInstance() throws InstanceAlreadyExistsException, ValidationException,\r
+            ConflictingVersionException, InstanceNotFoundException {\r
+        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();\r
+        createNamed(transaction, instanceName, "pref");\r
+\r
+        transaction.commit();\r
+\r
+        transaction = configRegistryClient.createTransaction();\r
+        ObjectName databaseNew = transaction.lookupConfigBean(factory.getImplementationName(), instanceName);\r
+        NamingThreadFactoryModuleMXBean proxy = transaction.newMXBeanProxy(databaseNew,\r
+                NamingThreadFactoryModuleMXBean.class);\r
+        proxy.setNamePrefix("pref1");\r
+\r
+        CommitStatus status = transaction.commit();\r
+\r
+        assertBeanCount(1, factory.getImplementationName());\r
+        assertStatus(status, 0, 1, 0);\r
+    }\r
+\r
+    private ObjectName createNamed(ConfigTransactionJMXClient transaction, String instanceName, String prefixes)\r
+            throws InstanceAlreadyExistsException {\r
+        ObjectName nameCreated = transaction.createModule(factory.getImplementationName(), instanceName);\r
+        NamingThreadFactoryModuleMXBean mxBean = transaction.newMBeanProxy(nameCreated,\r
+                NamingThreadFactoryModuleMXBean.class);\r
+        mxBean.setNamePrefix(prefixes);\r
+        return nameCreated;\r
+    }\r
+\r
+}\r
diff --git a/opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/naming/TestingNamingThreadPoolFactoryModule.java b/opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/naming/TestingNamingThreadPoolFactoryModule.java
new file mode 100644 (file)
index 0000000..5c717cc
--- /dev/null
@@ -0,0 +1,59 @@
+package org.opendaylight.controller.config.threadpool.naming;\r
+\r
+import static org.mockito.Matchers.any;\r
+import static org.mockito.Mockito.doNothing;\r
+import static org.mockito.Mockito.doReturn;\r
+import static org.mockito.Mockito.mock;\r
+\r
+import java.io.Closeable;\r
+import java.io.IOException;\r
+\r
+import org.opendaylight.controller.config.api.DynamicMBeanWithInstance;\r
+import org.opendaylight.controller.config.api.ModuleIdentifier;\r
+import org.opendaylight.controller.config.spi.Module;\r
+import org.opendaylight.controller.config.threadpool.util.NamingThreadPoolFactory;\r
+import org.opendaylight.controller.config.yang.threadpool.ThreadFactoryServiceInterface;\r
+import org.opendaylight.controller.config.yang.threadpool.impl.NamingThreadFactoryModuleMXBean;\r
+\r
+public class TestingNamingThreadPoolFactoryModule implements Module, ThreadFactoryServiceInterface,\r
+        NamingThreadFactoryModuleMXBean {\r
+\r
+    private final NamingThreadPoolFactory fact;\r
+\r
+    public TestingNamingThreadPoolFactoryModule() throws IOException {\r
+        fact = mock(NamingThreadPoolFactory.class);\r
+        Thread thread = mock(Thread.class);\r
+        doNothing().when(thread).start();\r
+        doReturn(thread).when(fact).newThread(any(Runnable.class));\r
+        doNothing().when(fact).close();\r
+    }\r
+\r
+    public TestingNamingThreadPoolFactoryModule(DynamicMBeanWithInstance old) {\r
+        fact = (NamingThreadPoolFactory) old.getInstance();\r
+    }\r
+\r
+    @Override\r
+    public ModuleIdentifier getIdentifier() {\r
+        return new ModuleIdentifier(TestingNamingThreadPoolFactoryModule.class.getCanonicalName(), "mock");\r
+    }\r
+\r
+    @Override\r
+    public String getNamePrefix() {\r
+        return null;\r
+    }\r
+\r
+    @Override\r
+    public void setNamePrefix(String arg) {\r
+        throw new UnsupportedOperationException();\r
+    }\r
+\r
+    @Override\r
+    public void validate() {\r
+    }\r
+\r
+    @Override\r
+    public Closeable getInstance() {\r
+        return fact;\r
+    }\r
+\r
+}\r
diff --git a/opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/scheduled/ScheduledThreadPoolConfigBeanTest.java b/opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/scheduled/ScheduledThreadPoolConfigBeanTest.java
new file mode 100644 (file)
index 0000000..b4b1b60
--- /dev/null
@@ -0,0 +1,154 @@
+package org.opendaylight.controller.config.threadpool.scheduled;\r
+\r
+import static org.junit.Assert.assertEquals;\r
+import static org.junit.Assert.assertThat;\r
+import static org.junit.Assert.assertTrue;\r
+import static org.junit.Assert.fail;\r
+import static org.junit.matchers.JUnitMatchers.containsString;\r
+\r
+import javax.management.InstanceAlreadyExistsException;\r
+import javax.management.InstanceNotFoundException;\r
+import javax.management.ObjectName;\r
+\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+import org.opendaylight.controller.config.api.ConflictingVersionException;\r
+import org.opendaylight.controller.config.api.ValidationException;\r
+import org.opendaylight.controller.config.api.jmx.CommitStatus;\r
+import org.opendaylight.controller.config.manager.impl.AbstractConfigTest;\r
+import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;\r
+import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;\r
+import org.opendaylight.controller.config.yang.threadpool.impl.NamingThreadFactoryModuleFactory;\r
+import org.opendaylight.controller.config.yang.threadpool.impl.NamingThreadFactoryModuleMXBean;\r
+import org.opendaylight.controller.config.yang.threadpool.impl.ScheduledThreadPoolModuleFactory;\r
+import org.opendaylight.controller.config.yang.threadpool.impl.ScheduledThreadPoolModuleMXBean;\r
+\r
+public class ScheduledThreadPoolConfigBeanTest extends AbstractConfigTest {\r
+\r
+    private ScheduledThreadPoolModuleFactory factory;\r
+    private final String instanceName = "scheduled1";\r
+\r
+    @Before\r
+    public void setUp() {\r
+\r
+        factory = new ScheduledThreadPoolModuleFactory();\r
+        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(factory,\r
+                new NamingThreadFactoryModuleFactory()));\r
+    }\r
+\r
+    @Test\r
+    public void testCreateBean() throws InstanceAlreadyExistsException, ValidationException,\r
+            ConflictingVersionException {\r
+        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();\r
+\r
+        createScheduled(transaction, instanceName, 1);\r
+        transaction.validateConfig();\r
+        CommitStatus status = transaction.commit();\r
+\r
+        assertBeanCount(1, factory.getImplementationName());\r
+        assertStatus(status, 2, 0, 0);\r
+    }\r
+\r
+    @Test\r
+    public void testReusingOldInstance() throws InstanceAlreadyExistsException, ConflictingVersionException,\r
+            ValidationException {\r
+\r
+        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();\r
+        createScheduled(transaction, instanceName, 1);\r
+\r
+        transaction.commit();\r
+\r
+        assertBeanCount(1, factory.getImplementationName());\r
+\r
+        transaction = configRegistryClient.createTransaction();\r
+        CommitStatus status = transaction.commit();\r
+\r
+        assertBeanCount(1, factory.getImplementationName());\r
+        assertStatus(status, 0, 0, 2);\r
+    }\r
+\r
+    @Test\r
+    public void testReconfigurationInstance() throws InstanceAlreadyExistsException, ValidationException,\r
+            ConflictingVersionException, InstanceNotFoundException {\r
+        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();\r
+        createScheduled(transaction, instanceName, 1);\r
+\r
+        transaction.commit();\r
+\r
+        transaction = configRegistryClient.createTransaction();\r
+        ObjectName databaseNew = transaction.lookupConfigBean(factory.getImplementationName(), instanceName);\r
+        ScheduledThreadPoolModuleMXBean proxy = transaction.newMXBeanProxy(databaseNew,\r
+                ScheduledThreadPoolModuleMXBean.class);\r
+        proxy.setMaxThreadCount(99);\r
+\r
+        CommitStatus status = transaction.commit();\r
+\r
+        assertBeanCount(1, factory.getImplementationName());\r
+        assertStatus(status, 0, 1, 1);\r
+    }\r
+\r
+    @Test\r
+    public void testDestroy() throws InstanceAlreadyExistsException, ValidationException, ConflictingVersionException,\r
+            InstanceNotFoundException {\r
+        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();\r
+        createScheduled(transaction, instanceName, 1);\r
+\r
+        transaction.commit();\r
+\r
+        transaction = configRegistryClient.createTransaction();\r
+        transaction.destroyConfigBean(factory.getImplementationName(), instanceName);\r
+        CommitStatus status = transaction.commit();\r
+\r
+        assertBeanCount(0, factory.getImplementationName());\r
+        assertStatus(status, 0, 0, 1);\r
+    }\r
+\r
+    @Test\r
+    public void testInstanceAlreadyExistsException() throws ConflictingVersionException, ValidationException,\r
+            InstanceAlreadyExistsException {\r
+        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();\r
+        createScheduled(transaction, instanceName, 1);\r
+        transaction.commit();\r
+        transaction = configRegistryClient.createTransaction();\r
+        try {\r
+            createScheduled(transaction, instanceName, 2);\r
+            fail();\r
+        } catch (InstanceAlreadyExistsException e) {\r
+            assertThat(\r
+                    e.getMessage(),\r
+                    containsString("There is an instance registered with name ModuleIdentifier{factoryName='threadpool-scheduled', instanceName='scheduled1'}"));\r
+        }\r
+    }\r
+\r
+    @Test\r
+    public void testValidationException() throws InstanceAlreadyExistsException {\r
+        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();\r
+        createScheduled(transaction, instanceName, 0);\r
+\r
+        try {\r
+            transaction.validateConfig();\r
+            fail();\r
+        } catch (ValidationException e) {\r
+            assertTrue(e.getFailedValidations().containsKey(factory.getImplementationName()));\r
+            assertEquals(1, e.getFailedValidations().get(factory.getImplementationName()).keySet().size());\r
+        }\r
+    }\r
+\r
+    private ObjectName createScheduled(ConfigTransactionJMXClient transaction, String instanceName, int maxThreadCount)\r
+            throws InstanceAlreadyExistsException {\r
+        ObjectName nameCreated = transaction.createModule(factory.getImplementationName(), instanceName);\r
+        ScheduledThreadPoolModuleMXBean mxBean = transaction.newMBeanProxy(nameCreated,\r
+                ScheduledThreadPoolModuleMXBean.class);\r
+        mxBean.setMaxThreadCount(maxThreadCount);\r
+\r
+        ObjectName threadFactoryON = transaction.createModule(NamingThreadFactoryModuleFactory.NAME, "naming");\r
+        NamingThreadFactoryModuleMXBean namingThreadFactoryModuleMXBean = transaction.newMXBeanProxy(threadFactoryON,\r
+                NamingThreadFactoryModuleMXBean.class);\r
+        namingThreadFactoryModuleMXBean.setNamePrefix("prefix");\r
+\r
+        mxBean.setThreadFactory(threadFactoryON);\r
+\r
+        return nameCreated;\r
+    }\r
+\r
+}\r
diff --git a/opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/scheduled/TestingScheduledThreadPoolModule.java b/opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/scheduled/TestingScheduledThreadPoolModule.java
new file mode 100644 (file)
index 0000000..27e60ee
--- /dev/null
@@ -0,0 +1,77 @@
+package org.opendaylight.controller.config.threadpool.scheduled;\r
+\r
+import static org.mockito.Matchers.any;\r
+import static org.mockito.Matchers.anyBoolean;\r
+import static org.mockito.Matchers.anyLong;\r
+import static org.mockito.Mockito.doNothing;\r
+import static org.mockito.Mockito.doReturn;\r
+import static org.mockito.Mockito.mock;\r
+\r
+import java.util.concurrent.ScheduledExecutorService;\r
+import java.util.concurrent.ScheduledFuture;\r
+import java.util.concurrent.TimeUnit;\r
+\r
+import javax.management.ObjectName;\r
+\r
+import org.opendaylight.controller.config.api.DynamicMBeanWithInstance;\r
+import org.opendaylight.controller.config.api.ModuleIdentifier;\r
+import org.opendaylight.controller.config.manager.impl.AbstractMockedModule;\r
+import org.opendaylight.controller.config.spi.Module;\r
+import org.opendaylight.controller.config.threadpool.util.ScheduledThreadPoolWrapper;\r
+import org.opendaylight.controller.config.yang.threadpool.ScheduledThreadPoolServiceInterface;\r
+import org.opendaylight.controller.config.yang.threadpool.impl.ScheduledThreadPoolModuleMXBean;\r
+\r
+import com.google.common.util.concurrent.ListenableFutureTask;\r
+\r
+public class TestingScheduledThreadPoolModule extends AbstractMockedModule implements\r
+        ScheduledThreadPoolServiceInterface, Module, ScheduledThreadPoolModuleMXBean {\r
+\r
+    public TestingScheduledThreadPoolModule(DynamicMBeanWithInstance old, ModuleIdentifier id) {\r
+        super(old, id);\r
+    }\r
+\r
+    @Override\r
+    protected AutoCloseable prepareMockedInstance() throws Exception {\r
+        ScheduledThreadPoolWrapper instance = mock(ScheduledThreadPoolWrapper.class);\r
+        ScheduledExecutorService ses = mock(ScheduledExecutorService.class);\r
+        {// mockFuture\r
+            ScheduledFuture<?> future = mock(ScheduledFuture.class);\r
+            doReturn(false).when(future).cancel(anyBoolean());\r
+            try {\r
+                doReturn(mock(Object.class)).when(future).get();\r
+            } catch (Exception e) {\r
+                throw new RuntimeException(e);\r
+            }\r
+            doReturn(future).when(ses).schedule(any(Runnable.class), any(Long.class), any(TimeUnit.class));\r
+            doReturn(future).when(ses).scheduleWithFixedDelay(any(Runnable.class), anyLong(), anyLong(),\r
+                    any(TimeUnit.class));\r
+\r
+        }\r
+        doNothing().when(ses).execute(any(Runnable.class));\r
+        doNothing().when(ses).execute(any(ListenableFutureTask.class));\r
+        doReturn(ses).when(instance).getExecutor();\r
+        doNothing().when(instance).close();\r
+\r
+        doReturn(1).when(instance).getMaxThreadCount();\r
+        return instance;\r
+    }\r
+\r
+    @Override\r
+    public ObjectName getThreadFactory() {\r
+        return any(ObjectName.class);\r
+    }\r
+\r
+    @Override\r
+    public void setThreadFactory(ObjectName threadFactory) {\r
+    }\r
+\r
+    @Override\r
+    public Integer getMaxThreadCount() {\r
+        return 1;\r
+    }\r
+\r
+    @Override\r
+    public void setMaxThreadCount(Integer maxThreadCount) {\r
+    }\r
+\r
+}\r
index 4482df0..1ebab9b 100644 (file)
@@ -81,7 +81,7 @@
         </dependency>
         <dependency>
           <groupId>org.opendaylight.controller</groupId>
-          <artifactId>sal-compability</artifactId>
+          <artifactId>sal-compatibility</artifactId>
           <version>${mdsal.version}</version>
         </dependency>
         <dependency>
           <artifactId>config-persister-impl</artifactId>
           <version>${netconf.version}</version>
         </dependency>
-
+        <dependency>
+          <groupId>org.opendaylight.controller.thirdparty</groupId>
+          <artifactId>exificient</artifactId>
+          <version>${exi.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.servicemix.bundles</groupId>
+            <artifactId>org.apache.servicemix.bundles.xerces</artifactId>
+            <version>2.11.0_1</version>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.birt.runtime.3_7_1</groupId>
+            <artifactId>org.apache.xml.resolver</artifactId>
+            <version>1.2.0</version>
+        </dependency>
 
           <!-- toaster example I'm pretty sure we should trim -->
-
          <dependency>
           <groupId>org.opendaylight.controller.samples</groupId>
           <artifactId>sample-toaster</artifactId>
            <version>2.4</version>
          </dependency>
 
-           <dependency>
+         <dependency>
           <groupId>org.opendaylight.yangtools.thirdparty</groupId>
           <artifactId>antlr4-runtime-osgi-nohead</artifactId>
           <version>4.0</version>
           <artifactId>yang-model-api</artifactId>
          </dependency>
 
-          <dependency>
-           <groupId>org.opendaylight.yangtools.model</groupId>
-           <artifactId>yang-ext</artifactId>
-          </dependency>
+         <dependency>
+          <groupId>org.opendaylight.yangtools.model</groupId>
+          <artifactId>yang-ext</artifactId>
+         </dependency>
 
+        <dependency>
+         <groupId>org.opendaylight.controller.thirdparty</groupId>
+         <artifactId>ganymed</artifactId>
+        </dependency>
       </dependencies>
     </profile>
   </profiles>
index 9b96f86..29de772 100644 (file)
             <Import-Package>
               org.opendaylight.controller.sal.binding.api,
               org.opendaylight.controller.sal.binding.api.data,
-              org.opendaylight.controller.md.sal.common.api.data,              
-              org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.flow,
+              org.opendaylight.controller.md.sal.common.api.data, 
+              org.opendaylight.controller.sal.utils, 
+              org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow, 
+              org.opendaylight.yang.gen.v1.urn.opendaylight.group.config.rev131024.groups, 
+              org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918, 
+              org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018, 
+              org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group, 
+              org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets, 
+              org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.bucket,
               org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819,
+              org.opendaylight.controller.clustering.services, org.opendaylight.controller.sal.core, 
+              org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction,
+              org.opendaylight.controller.switchmanager, 
+              org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list, 
+              org.opendaylight.yang.gen.v1.urn.opendaylight.group.config.rev131024,
               org.opendaylight.yangtools.concepts,              
               org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819,
               org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819,
index ae488b6..e48e038 100644 (file)
 package org.opendaylight.controller.forwardingrulesmanager_mdsal.consumer.impl;
 
 
+import org.eclipse.osgi.framework.console.CommandProvider;
+import org.opendaylight.controller.clustering.services.IClusterContainerServices;
 import org.opendaylight.controller.sal.binding.api.AbstractBindingAwareProvider;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
 import org.opendaylight.controller.sal.binding.api.NotificationService;
 import org.opendaylight.controller.sal.binding.api.data.DataBrokerService;
 import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
+import org.opendaylight.controller.sal.core.IContainer;
+import org.opendaylight.controller.sal.utils.ServiceHelper;
+import org.opendaylight.controller.switchmanager.ISwitchManager;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.FrameworkUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 
-public class FRMConsumerImpl extends AbstractBindingAwareProvider {
+public class FRMConsumerImpl extends AbstractBindingAwareProvider implements CommandProvider{
        protected static final Logger logger = LoggerFactory.getLogger(FRMConsumerImpl.class);
        private static ProviderContext p_session;
     private static DataBrokerService dataBrokerService;         
@@ -28,11 +35,21 @@ public class FRMConsumerImpl extends AbstractBindingAwareProvider {
        private GroupConsumerImpl groupImplRef;
        private static DataProviderService dataProviderService;  
 
+       private static IClusterContainerServices clusterContainerService = null;
+       private static ISwitchManager switchManager;
+       private static IContainer container;
+       
        @Override
     public void onSessionInitiated(ProviderContext session) {
        
         FRMConsumerImpl.p_session = session;
         
+        if (!getDependentModule()) {
+            logger.error("Unable to fetch handlers for dependent modules");
+            System.out.println("Unable to fetch handlers for dependent modules");
+            return;
+        }
+        
         if (null != session) {
                notificationService = session.getSALService(NotificationService.class);
                
@@ -44,7 +61,8 @@ public class FRMConsumerImpl extends AbstractBindingAwareProvider {
                                
                                if (null != dataProviderService) {
                                        flowImplRef = new FlowConsumerImpl();
-                                       groupImplRef = new GroupConsumerImpl();
+                       //              groupImplRef = new GroupConsumerImpl();
+                                       registerWithOSGIConsole();
                                }
                                else {
                                        logger.error("Data Provider Service is down or NULL. " +
@@ -68,18 +86,85 @@ public class FRMConsumerImpl extends AbstractBindingAwareProvider {
                System.out.println("Consumer session is NULL. Please check if provider is registered");
         }
   
+    }
+       
+       public static IClusterContainerServices getClusterContainerService() {
+        return clusterContainerService;
+    }
+
+    public static void setClusterContainerService(
+            IClusterContainerServices clusterContainerService) {
+        FRMConsumerImpl.clusterContainerService = clusterContainerService;
+    }
+
+    public static ISwitchManager getSwitchManager() {
+        return switchManager;
+    }
+
+    public static void setSwitchManager(ISwitchManager switchManager) {
+        FRMConsumerImpl.switchManager = switchManager;
+    }
+
+    public static IContainer getContainer() {
+        return container;
     }
 
-       public static DataProviderService getDataProviderService() {
+    public static void setContainer(IContainer container) {
+        FRMConsumerImpl.container = container;
+    }
+
+    private void registerWithOSGIConsole() {
+        BundleContext bundleContext = FrameworkUtil.getBundle(this.getClass()).getBundleContext();
+        bundleContext.registerService(CommandProvider.class.getName(), this, null);
+    }
+       
+       private boolean getDependentModule() {
+           do {
+        clusterContainerService = (IClusterContainerServices) ServiceHelper.getGlobalInstance(IClusterContainerServices.class, this);
+        try {
+            Thread.sleep(4);
+        } catch (InterruptedException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+           } while(clusterContainerService == null);
+           
+           do {
+               
+           
+        container = (IContainer) ServiceHelper.getGlobalInstance(IContainer.class, this);
+        try {
+            Thread.sleep(5);
+        } catch (InterruptedException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+           } while (container == null);
+           
+           do {
+               switchManager = (ISwitchManager) ServiceHelper.getInstance(ISwitchManager.class, container.getName(), this);
+               try {
+                   Thread.sleep(5);
+               } catch (InterruptedException e) {
+                   // TODO Auto-generated catch block
+                   e.printStackTrace();
+               }
+           } while(null == switchManager);
+        return true;
+       }
+
+       
+
+    public static DataProviderService getDataProviderService() {
                return dataProviderService;
        }
 
        public FlowConsumerImpl getFlowImplRef() {
-               return flowImplRef;
+           return flowImplRef;
        }
 
        public GroupConsumerImpl getGroupImplRef() {
-                       return groupImplRef;
+           return groupImplRef;
        }
         
        public static ProviderContext getProviderSession() {
@@ -93,6 +178,15 @@ public class FRMConsumerImpl extends AbstractBindingAwareProvider {
        public static DataBrokerService getDataBrokerService() {
                return dataBrokerService;
        }
+       
+       /*
+     * OSGI COMMANDS
+     */
+    @Override
+    public String getHelp() {
+        StringBuffer help = new StringBuffer();
+        return help.toString();
+    }
 
 }
        
diff --git a/opendaylight/forwardingrulesmanager_mdsal/openflow/src/main/java/org/opendaylight/controller/forwardingrulesmanager_mdsal/consumer/impl/FRMUtil.java b/opendaylight/forwardingrulesmanager_mdsal/openflow/src/main/java/org/opendaylight/controller/forwardingrulesmanager_mdsal/consumer/impl/FRMUtil.java
new file mode 100644 (file)
index 0000000..df34d19
--- /dev/null
@@ -0,0 +1,33 @@
+package org.opendaylight.controller.forwardingrulesmanager_mdsal.consumer.impl;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.bucket.Actions;
+
+public class FRMUtil {
+    private static final String NAMEREGEX = "^[a-zA-Z0-9]+$";
+    public enum operation {ADD, DELETE, UPDATE, GET};
+    
+    
+    public static boolean isNameValid(String name) {
+    
+        //  Name validation 
+        if (name == null || name.trim().isEmpty() || !name.matches(NAMEREGEX)) {
+            return false;
+        }
+        return true;
+        
+    }
+    
+    public static boolean areActionsValid(Actions actions) {
+     //   List<Action> actionList;
+       // Action actionRef;
+      //  if (null != actions && null != actions.getAction()) {
+       //     actionList = actions.getAction();
+            
+
+               
+       // }
+        
+        return true;
+    }
+}
index a6a3c71..59c7e04 100644 (file)
@@ -20,6 +20,7 @@ import org.opendaylight.controller.sal.common.util.Rpcs;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.Flows;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.Flow;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput;
+
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowAdded;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowRemoved;
@@ -27,6 +28,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.Flow
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.NodeFlow;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowListener;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
@@ -61,6 +63,7 @@ public class FlowConsumerImpl {
                }
                
                listener = new FlowDataListener();
+               
                if (null == FRMConsumerImpl.getDataBrokerService().registerDataChangeListener(path, listener)) {
                        logger.error("Failed to listen on flow data modifcation events");
                System.out.println("Consumer SAL Service is down or NULL.");
@@ -75,7 +78,7 @@ public class FlowConsumerImpl {
                System.out.println("Consumer SAL Service is down or NULL.");
                return;
                }
-               addFlowTest();
+               //addFlowTest();
                System.out.println("-------------------------------------------------------------------");
                allocateCaches();
                commitHandler = new FlowDataCommitHandler();
@@ -120,11 +123,19 @@ public class FlowConsumerImpl {
     private void addFlow(InstanceIdentifier<?> path, Flow dataObject) {
 
         AddFlowInputBuilder input = new AddFlowInputBuilder();
+        List<Instruction> inst = (dataObject).getInstructions().getInstruction();
         input.setNode((dataObject).getNode());
         input.setPriority((dataObject).getPriority());
         input.setMatch((dataObject).getMatch());
         input.setCookie((dataObject).getCookie());
-        input.setAction((dataObject).getAction());
+        input.setInstructions((dataObject).getInstructions());
+        dataObject.getMatch().getLayer3Match()
+        for (int i=0;i<inst.size();i++) {
+            System.out.println("i = "+ i + inst.get(i).getInstruction().toString());
+            System.out.println("i = "+ i + inst.get(i).toString());
+        }
+        
+        System.out.println("Instruction list" + (dataObject).getInstructions().getInstruction().toString());
 
         // We send flow to the sounthbound plugin
         flowService.addFlow(input.build());
@@ -132,9 +143,11 @@ public class FlowConsumerImpl {
     
     private void commitToPlugin(internalTransaction transaction) {
         for(Entry<InstanceIdentifier<?>, Flow> entry :transaction.additions.entrySet()) {
+            System.out.println("Coming add cc in FlowDatacommitHandler");
             addFlow(entry.getKey(),entry.getValue());
         }
-        for(@SuppressWarnings("unused") Entry<InstanceIdentifier<?>, Flow> entry :transaction.additions.entrySet()) {
+        for(@SuppressWarnings("unused") Entry<InstanceIdentifier<?>, Flow> entry :transaction.updates.entrySet()) {
+            System.out.println("Coming update cc in FlowDatacommitHandler");
            // updateFlow(entry.getKey(),entry.getValue());
         }
         
@@ -196,9 +209,11 @@ public class FlowConsumerImpl {
             Flow original = originalSwView.get(key);
             if (original != null) {
                 // It is update for us
+                System.out.println("Coming update  in FlowDatacommitHandler");
                 updates.put(key, flow);
             } else {
                 // It is addition for us
+                System.out.println("Coming add in FlowDatacommitHandler");
                 additions.put(key, flow);
             }
         }
@@ -273,7 +288,7 @@ public class FlowConsumerImpl {
                        for (DataObject dataObject : additions) {
                            if (dataObject instanceof NodeFlow) {
                                NodeRef nodeOne = createNodeRef("foo:node:1");
-                                       // validating the dataObject here
+                                       // validating the dataObject here                               
                                    AddFlowInputBuilder input = new AddFlowInputBuilder();
                                    input.setNode(((NodeFlow) dataObject).getNode());
                                    input.setNode(nodeOne);
@@ -300,18 +315,6 @@ public class FlowConsumerImpl {
         return new NodeRef(path);
     }
            
-         /*  private void loadFlowData() {
        
-                   DataModification modification = (DataModification) dataservice.beginTransaction();
-                   String id = "abc";
-                   FlowKey key = new FlowKey(id, new NodeRef());
-                   InstanceIdentifier<?> path1;
-                   FlowBuilder flow = new FlowBuilder();
-                   flow.setKey(key);
-                   path1 = InstanceIdentifier.builder().node(Flows.class).node(Flow.class, key).toInstance();
-                   DataObject cls = (DataObject) modification.readConfigurationData(path);
-                   modification.putConfigurationData(path, flow.build());
-                   modification.commit();
-               }*/
 
 }
index cc42e21..acc0dc6 100644 (file)
@@ -1,7 +1,478 @@
 package org.opendaylight.controller.forwardingrulesmanager_mdsal.consumer.impl;
 
+import java.util.ArrayList;
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+import org.opendaylight.controller.clustering.services.CacheConfigException;
+import org.opendaylight.controller.clustering.services.CacheExistException;
+import org.opendaylight.controller.clustering.services.IClusterContainerServices;
+import org.opendaylight.controller.clustering.services.IClusterServices;
+import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler;
+import org.opendaylight.controller.md.sal.common.api.data.DataModification;
+import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler.DataCommitTransaction;
+import org.opendaylight.controller.sal.common.util.Rpcs;
+import org.opendaylight.controller.sal.core.IContainer;
+import org.opendaylight.controller.sal.core.Node;
+import org.opendaylight.controller.sal.utils.GlobalConstants;
+import org.opendaylight.controller.sal.utils.Status;
+import org.opendaylight.controller.sal.utils.StatusCode;
+import org.opendaylight.controller.switchmanager.ISwitchManager;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.config.rev131024.Groups;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.config.rev131024.groups.Group;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.config.rev131024.groups.GroupKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.GroupAdded;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.GroupRemoved;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.GroupUpdated;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.SalGroupListener;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.SalGroupService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupTypes.GroupType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.Buckets;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket;
+import org.opendaylight.yangtools.concepts.Registration;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.NotificationListener;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@SuppressWarnings("unused")
 public class GroupConsumerImpl {
-       public GroupConsumerImpl() {
-               
+    
+    protected static final Logger logger = LoggerFactory.getLogger(GroupConsumerImpl.class);
+    private GroupEventListener groupEventListener = new GroupEventListener();
+    private Registration<NotificationListener> groupListener;
+    private SalGroupService groupService;    
+    private GroupDataCommitHandler commitHandler;
+    
+    private ConcurrentMap<GroupKey, Group> originalSwGroupView;
+    private ConcurrentMap<GroupKey, Group> installedSwGroupView;
+    
+    private ConcurrentMap<Node, List<Group>> nodeGroups;
+    private ConcurrentMap<GroupKey, Group> inactiveGroups;
+    
+    private IClusterContainerServices clusterGroupContainerService = null;
+    private ISwitchManager switchGroupManager;
+    private IContainer container;
+    
+    public GroupConsumerImpl() {
+           InstanceIdentifier<? extends DataObject> path = InstanceIdentifier.builder().node(Groups.class).toInstance();
+        groupService = FRMConsumerImpl.getProviderSession().getRpcService(SalGroupService.class);
+        
+        clusterGroupContainerService = FRMConsumerImpl.getClusterContainerService();
+        switchGroupManager = FRMConsumerImpl.getSwitchManager();
+        container = FRMConsumerImpl.getContainer();
+        
+        if (!(cacheStartup())) {
+            logger.error("Unanle to allocate/retrieve group cache");
+            System.out.println("Unable to allocate/retrieve group cache");
+        }
+        
+        if (null == groupService) {
+            logger.error("Consumer SAL Group Service is down or NULL. FRM may not function as intended");
+            System.out.println("Consumer SAL Group Service is down or NULL.");
+            return;
+        }     
+        
+        // For switch events
+        groupListener = FRMConsumerImpl.getNotificationService().registerNotificationListener(groupEventListener);
+        
+        if (null == groupListener) {
+            logger.error("Listener to listen on group data modifcation events");
+            System.out.println("Listener to listen on group data modifcation events.");
+            return;
+        }       
+        
+        commitHandler = new GroupDataCommitHandler();
+        FRMConsumerImpl.getDataProviderService().registerCommitHandler(path, commitHandler);
        }
+       
+    private boolean allocateGroupCaches() {
+        if (this.clusterGroupContainerService == null) {
+            logger.warn("Group: Un-initialized clusterGroupContainerService, can't create cache");
+            return false;
+        }       
+
+        try {
+            clusterGroupContainerService.createCache("frm.originalSwGroupView",
+                    EnumSet.of(IClusterServices.cacheMode.TRANSACTIONAL));
+
+            clusterGroupContainerService.createCache("frm.installedSwGroupView",
+                    EnumSet.of(IClusterServices.cacheMode.TRANSACTIONAL));
+
+            clusterGroupContainerService.createCache("frm.inactiveGroups",
+                    EnumSet.of(IClusterServices.cacheMode.TRANSACTIONAL));
+
+            clusterGroupContainerService.createCache("frm.nodeGroups",
+                    EnumSet.of(IClusterServices.cacheMode.TRANSACTIONAL));
+            
+//TODO for cluster mode
+           /* clusterGroupContainerService.createCache(WORK_STATUS_CACHE,
+                    EnumSet.of(IClusterServices.cacheMode.NON_TRANSACTIONAL, IClusterServices.cacheMode.ASYNC));
+
+            clusterGroupContainerService.createCache(WORK_ORDER_CACHE,
+                    EnumSet.of(IClusterServices.cacheMode.NON_TRANSACTIONAL, IClusterServices.cacheMode.ASYNC));*/
+            
+        } catch (CacheConfigException cce) {            
+            logger.error("Group CacheConfigException");
+            return false;
+            
+        } catch (CacheExistException cce) {
+            logger.error(" Group CacheExistException");           
+        }
+        
+        return true;
+    }
+    
+    private void nonClusterGroupObjectCreate() {
+        originalSwGroupView = new ConcurrentHashMap<GroupKey, Group>();
+        installedSwGroupView = new ConcurrentHashMap<GroupKey, Group>();
+        nodeGroups = new ConcurrentHashMap<Node, List<Group>>();        
+        inactiveGroups = new ConcurrentHashMap<GroupKey, Group>();
+    }
+    
+    @SuppressWarnings({ "unchecked" })
+    private boolean retrieveGroupCaches() {
+        ConcurrentMap<?, ?> map;
+
+        if (this.clusterGroupContainerService == null) {
+            logger.warn("Group: un-initialized clusterGroupContainerService, can't retrieve cache");
+            nonClusterGroupObjectCreate();
+            return false;
+        }       
+
+        map = clusterGroupContainerService.getCache("frm.originalSwGroupView");
+        if (map != null) {
+            originalSwGroupView = (ConcurrentMap<GroupKey, Group>) map;
+        } else {
+            logger.error("Retrieval of cache(originalSwGroupView) failed");
+            return false;
+        }
+
+        map = clusterGroupContainerService.getCache("frm.installedSwGroupView");
+        if (map != null) {
+            installedSwGroupView = (ConcurrentMap<GroupKey, Group>) map;
+        } else {
+            logger.error("Retrieval of cache(installedSwGroupView) failed");
+            return false;
+        }
+
+        map = clusterGroupContainerService.getCache("frm.inactiveGroups");
+        if (map != null) {
+            inactiveGroups = (ConcurrentMap<GroupKey, Group>) map;
+        } else {
+            logger.error("Retrieval of cache(inactiveGroups) failed");
+            return false;
+        }
+
+        map = clusterGroupContainerService.getCache("frm.nodeGroups");
+        if (map != null) {
+            nodeGroups = (ConcurrentMap<Node, List<Group>>) map;
+        } else {
+            logger.error("Retrieval of cache(nodeGroup) failed");
+            return false;
+        }
+        
+        return true;
+    }
+       
+    private boolean cacheStartup() {
+        if (allocateGroupCaches()) {
+            if (retrieveGroupCaches()) {
+                return true;
+            }
+        }
+        
+        return false;
+    }
+    
+    public Status validateGroup(Group group, FRMUtil.operation operation) {
+        String containerName;
+        String groupName;
+        Iterator<Bucket> bucketIterator;
+        boolean returnResult;
+        Buckets groupBuckets;
+        
+        if (null != group) {
+            containerName = group.getContainerName();
+            
+            if (null == containerName) {
+                containerName = GlobalConstants.DEFAULT.toString();
+            }
+            else if (!FRMUtil.isNameValid(containerName)) {
+                logger.error("Container Name is invalid %s" + containerName);
+                return new Status(StatusCode.BADREQUEST, "Container Name is invalid");
+            }
+            
+            groupName = group.getGroupName();
+            if (!FRMUtil.isNameValid(groupName)) {
+                logger.error("Group Name is invalid %s" + groupName);
+                return new Status(StatusCode.BADREQUEST, "Group Name is invalid");
+            }
+            
+            returnResult = doesGroupEntryExists(group.getKey(), groupName, containerName);
+            
+            if (FRMUtil.operation.ADD == operation && returnResult) {
+                logger.error("Record with same Group Name exists");
+                return new Status(StatusCode.BADREQUEST, "Group record exists");
+            }
+            else if (!returnResult) {
+                logger.error("Group record does not exist");
+                return new Status(StatusCode.BADREQUEST, "Group record does not exist");
+            }
+            
+            if (!(group.getGroupType().getIntValue() >= GroupType.GroupAll.getIntValue() && 
+                    group.getGroupType().getIntValue() <= GroupType.GroupFf.getIntValue())) {
+                logger.error("Invalid Group type %d" + group.getGroupType().getIntValue());
+                return new Status(StatusCode.BADREQUEST, "Invalid Group type");                
+            }
+            
+            groupBuckets = group.getBuckets();
+                    
+            if (null != groupBuckets && null != groupBuckets.getBucket()) {
+                bucketIterator = groupBuckets.getBucket().iterator();
+                
+                while (bucketIterator.hasNext()) {
+                    if(!(FRMUtil.areActionsValid(bucketIterator.next().getActions()))) {
+                        logger.error("Error in action bucket");
+                        return new Status(StatusCode.BADREQUEST, "Invalid Group bucket contents");
+                    }                                
+                }
+            }                
+        }
+        
+        return new Status(StatusCode.SUCCESS);
+        
+    }
+    
+    private boolean doesGroupEntryExists(GroupKey key, String groupName, String containerName) {
+        if (! originalSwGroupView.containsKey(key)) {
+            return false;
+        }
+        
+        for (ConcurrentMap.Entry<GroupKey, Group> entry : originalSwGroupView.entrySet()) {
+            if (entry.getValue().getGroupName().equals(groupName)) {
+                if (entry.getValue().getContainerName().equals(containerName)) {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+
+    
+    /**
+     * Update Group entries to the southbound plugin/inventory and our internal database
+     *
+     * @param path
+     * @param dataObject
+     */
+    private Status updateGroup(InstanceIdentifier<?> path, Group groupUpdateDataObject) {
+        GroupKey groupKey = groupUpdateDataObject.getKey();
+        Status groupOperationStatus = validateGroup(groupUpdateDataObject, FRMUtil.operation.UPDATE);
+        
+        if (!groupOperationStatus.isSuccess()) {
+            logger.error("Group data object validation failed %s" + groupUpdateDataObject.getGroupName());
+            return groupOperationStatus;
+        }
+            
+        originalSwGroupView.remove(groupKey);
+        originalSwGroupView.put(groupKey, groupUpdateDataObject);
+        
+        if (groupUpdateDataObject.isInstall()) {
+            UpdateGroupInputBuilder groupData = new UpdateGroupInputBuilder();
+            //TODO how to get original group and modified group. 
+            
+            if (installedSwGroupView.containsKey(groupKey)) {
+                installedSwGroupView.remove(groupKey);
+            }
+            
+            installedSwGroupView.put(groupKey, groupUpdateDataObject);
+            groupService.updateGroup(groupData.build());
+        }
+        
+        return groupOperationStatus;
+    }
+    
+    /**
+     * Adds Group to the southbound plugin and our internal database
+     *
+     * @param path
+     * @param dataObject
+     */
+    private Status addGroup(InstanceIdentifier<?> path, Group groupAddDataObject) {
+        GroupKey groupKey = groupAddDataObject.getKey();
+        Status groupOperationStatus = validateGroup(groupAddDataObject, FRMUtil.operation.ADD);
+        
+        if (!groupOperationStatus.isSuccess()) {
+            logger.error("Group data object validation failed %s" + groupAddDataObject.getGroupName());
+            return groupOperationStatus;
+        }
+        validateGroup(groupAddDataObject, FRMUtil.operation.ADD);
+        originalSwGroupView.put(groupKey, groupAddDataObject);
+        
+        if (groupAddDataObject.isInstall()) {
+            AddGroupInputBuilder groupData = new AddGroupInputBuilder();
+            groupData.setBuckets(groupAddDataObject.getBuckets());
+            groupData.setContainerName(groupAddDataObject.getContainerName());
+            groupData.setGroupId(groupAddDataObject.getGroupId());
+            groupData.setGroupType(groupAddDataObject.getGroupType());
+            groupData.setNode(groupAddDataObject.getNode());  
+            installedSwGroupView.put(groupKey, groupAddDataObject);
+            groupService.addGroup(groupData.build());
+        }
+        
+        return groupOperationStatus;
+    }
+    
+       private RpcResult<Void> commitToPlugin(internalTransaction transaction) {
+        for(Entry<InstanceIdentifier<?>, Group> entry :transaction.additions.entrySet()) {
+            
+            if (!addGroup(entry.getKey(),entry.getValue()).isSuccess()) {
+                return Rpcs.getRpcResult(false, null, null);
+            }
+        }
+        for(@SuppressWarnings("unused") Entry<InstanceIdentifier<?>, Group> entry :transaction.additions.entrySet()) {
+           
+            if (!updateGroup(entry.getKey(),entry.getValue()).isSuccess()) {
+                return Rpcs.getRpcResult(false, null, null);
+            }
+        }
+        
+        for(InstanceIdentifier<?> removal : transaction.removals) {
+           // removeFlow(removal);
+        }
+        
+        return Rpcs.getRpcResult(true, null, null);
+    }
+    
+    private final class GroupDataCommitHandler implements DataCommitHandler<InstanceIdentifier<?>, DataObject> {
+
+         @SuppressWarnings("unchecked")
+        @Override
+         public DataCommitTransaction requestCommit(DataModification<InstanceIdentifier<?>, DataObject> modification) {
+             // We should verify transaction
+             System.out.println("Coming in FlowDatacommitHandler");
+             internalTransaction transaction = new internalTransaction(modification);
+             transaction.prepareUpdate();
+             return transaction;
+         }
+    }
+
+    private final class internalTransaction implements DataCommitTransaction<InstanceIdentifier<?>, DataObject> {
+
+        private final DataModification<InstanceIdentifier<?>, DataObject> modification;
+
+        @Override
+        public DataModification<InstanceIdentifier<?>, DataObject> getModification() {
+            return modification;
+        }
+
+        public internalTransaction(DataModification<InstanceIdentifier<?>, DataObject> modification) {
+            this.modification = modification;
+        }
+
+        Map<InstanceIdentifier<?>, Group> additions = new HashMap<>();
+        Map<InstanceIdentifier<?>, Group> updates = new HashMap<>();
+        Set<InstanceIdentifier<?>> removals = new HashSet<>();
+
+        /**
+         * We create a plan which flows will be added, which will be updated and
+         * which will be removed based on our internal state.
+         * 
+         */
+        void prepareUpdate() {
+
+            Set<Entry<InstanceIdentifier<?>, DataObject>> puts = modification.getUpdatedConfigurationData().entrySet();
+            for (Entry<InstanceIdentifier<?>, DataObject> entry : puts) {
+                if (entry.getValue() instanceof Group) {                    
+                    Group group = (Group) entry.getValue();                    
+                    preparePutEntry(entry.getKey(), group);
+                }
+
+            }
+
+            removals = modification.getRemovedConfigurationData();
+        }
+
+        private void preparePutEntry(InstanceIdentifier<?> key, Group group) {
+            
+            Group original = originalSwGroupView.get(key);
+            if (original != null) {
+                // It is update for us
+                
+                updates.put(key, group);               
+            } else {
+                // It is addition for us
+                
+                additions.put(key, group);
+            }
+        }
+
+        /**
+         * We are OK to go with execution of plan
+         * 
+         */
+        @Override
+        public RpcResult<Void> finish() throws IllegalStateException {
+            
+            RpcResult<Void> rpcStatus = commitToPlugin(this);
+            // We return true if internal transaction is successful.
+          //  return Rpcs.getRpcResult(true, null, Collections.emptySet());
+            return rpcStatus;
+        }
+
+        /**
+         * 
+         * We should rollback our preparation
+         * 
+         */
+        @Override
+        public RpcResult<Void> rollback() throws IllegalStateException {
+            // NOOP - we did not modified any internal state during
+            // requestCommit phase
+           // return Rpcs.getRpcResult(true, null, Collections.emptySet());
+            return Rpcs.getRpcResult(true, null, null);
+            
+        }
+        
+    }
+    
+       
+       final class GroupEventListener implements SalGroupListener {
+           
+        List<GroupAdded> addedGroups = new ArrayList<>();
+        List<GroupRemoved> removedGroups = new ArrayList<>();
+        List<GroupUpdated> updatedGroups = new ArrayList<>();
+       
+
+        @Override
+        public void onGroupAdded(GroupAdded notification) {
+            System.out.println("added Group..........................");
+            addedGroups.add(notification);            
+        }
+
+        @Override
+        public void onGroupRemoved(GroupRemoved notification) {
+            // TODO Auto-generated method stub
+            
+        }
+
+        @Override
+        public void onGroupUpdated(GroupUpdated notification) {
+            // TODO Auto-generated method stub
+            
+        }    
+    }
 }
@@ -2,8 +2,8 @@
   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <parent>
-    <groupId>org.opendaylight.controller</groupId>
-    <artifactId>sal-parent</artifactId>
+     <groupId>org.opendaylight.controller</groupId>
+    <artifactId>compatibility-parent</artifactId>
     <version>1.0-SNAPSHOT</version>
   </parent>
   <artifactId>flow-management-compatibility</artifactId>
@@ -81,7 +81,7 @@
     </dependency>
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
-      <artifactId>sal-compability</artifactId>
+      <artifactId>sal-compatibility</artifactId>
       <version>1.0-SNAPSHOT</version>
     </dependency>
 
@@ -15,7 +15,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.Flows
 import org.opendaylight.controller.forwardingrulesmanager.IForwardingRulesManager
 import static com.google.common.base.Preconditions.*;
 import static extension org.opendaylight.controller.md.frm.compatibility.FlowConfigMapping.*;
-import static extension org.opendaylight.controller.sal.compability.NodeMapping.*;
+import static extension org.opendaylight.controller.sal.compatibility.NodeMapping.*;
 import org.opendaylight.controller.sal.common.util.Arguments
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.IdentifiableItem
 import org.opendaylight.yangtools.yang.common.RpcResult
@@ -3,9 +3,9 @@ package org.opendaylight.controller.md.frm.compatibility
 import org.opendaylight.controller.forwardingrulesmanager.FlowConfig
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.FlowBuilder
 
-import static extension org.opendaylight.controller.sal.compability.NodeMapping.*
-import static org.opendaylight.controller.sal.compability.MDFlowMapping.*
-import static org.opendaylight.controller.sal.compability.ToSalConversionsUtils.*
+import static extension org.opendaylight.controller.sal.compatibility.NodeMapping.*
+import static org.opendaylight.controller.sal.compatibility.MDFlowMapping.*
+import static org.opendaylight.controller.sal.compatibility.ToSalConversionsUtils.*
 
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.FlowKey
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.Flow
diff --git a/opendaylight/md-sal/compatibility/flow-management-compatibility/src/main/java/org/opendaylight/controller/md/frm/compatibility/SampleConsumer.java b/opendaylight/md-sal/compatibility/flow-management-compatibility/src/main/java/org/opendaylight/controller/md/frm/compatibility/SampleConsumer.java
new file mode 100644 (file)
index 0000000..a82eedc
--- /dev/null
@@ -0,0 +1,38 @@
+package org.opendaylight.controller.md.frm.compatibility;
+
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext;
+import org.opendaylight.controller.sal.binding.api.data.DataBrokerService;
+import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.Flows;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.Flow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.FlowBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.FlowKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public class SampleConsumer {
+
+    ConsumerContext context;
+
+    void addFlowExample() {
+
+        DataBrokerService dataService = context.getSALService(DataBrokerService.class);
+
+        DataModificationTransaction transaction = dataService.beginTransaction();
+        Flow flow = createSampleFlow("foo", null);
+        InstanceIdentifier<Flow> path = InstanceIdentifier.builder().node(Flows.class).node(Flow.class, flow.getKey())
+                .toInstance();
+        transaction.putConfigurationData(path, flow);
+
+        transaction.commit();
+
+        dataService.readConfigurationData(path);
+    }
+
+    Flow createSampleFlow(String name, NodeRef node) {
+        FlowBuilder ret = new FlowBuilder();
+        FlowKey key = new FlowKey(name, node);
+        ret.setKey(key);
+        return ret.build();
+    }
+}
diff --git a/opendaylight/md-sal/compatibility/inventory-topology-compatibility/pom.xml b/opendaylight/md-sal/compatibility/inventory-topology-compatibility/pom.xml
new file mode 100644 (file)
index 0000000..d9fb18f
--- /dev/null
@@ -0,0 +1,109 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.opendaylight.controller</groupId>
+        <artifactId>compatibility-parent</artifactId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+    <artifactId>inventory-topology-compatibility</artifactId>
+    <packaging>bundle</packaging>
+    <scm>
+        <connection>scm:git:ssh://git.opendaylight.org:29418/controller.git</connection>
+        <developerConnection>scm:git:ssh://git.opendaylight.org:29418/controller.git</developerConnection>
+        <url>https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL</url>
+    </scm>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        <Bundle-Name>Forwarding Rules Manager Adapter
+                            for MD-SAL</Bundle-Name>
+                    </instructions>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.eclipse.xtend</groupId>
+                <artifactId>xtend-maven-plugin</artifactId>
+            </plugin>
+            <plugin>
+                <artifactId>maven-clean-plugin</artifactId>
+            </plugin>
+        </plugins>
+    </build>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>sal-common-util</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>sal-binding-api</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>switchmanager</artifactId>
+            <version>0.6.1-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>topologymanager</artifactId>
+            <version>0.4.1-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.google.guava</groupId>
+            <artifactId>guava</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-all</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.xtend</groupId>
+            <artifactId>org.eclipse.xtend.lib</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller.model</groupId>
+            <artifactId>model-flow-management</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>sal-binding-util</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller.model</groupId>
+            <artifactId>model-topology</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>forwardingrulesmanager</artifactId>
+            <version>0.4.1-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>sal-compatibility</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
+    </dependencies>
+</project>
diff --git a/opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/inventory/InventoryReader.xtend b/opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/inventory/InventoryReader.xtend
new file mode 100644 (file)
index 0000000..262e848
--- /dev/null
@@ -0,0 +1,83 @@
+package org.opendaylight.controller.md.compatibility.inventory
+
+import org.opendaylight.controller.switchmanager.ISwitchManager
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier
+import org.opendaylight.yangtools.yang.binding.DataObject
+import org.opendaylight.controller.sal.binding.api.data.RuntimeDataProvider
+import java.util.ArrayList
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector
+import static extension org.opendaylight.controller.sal.compatibility.InventoryMapping.*;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodesBuilder
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorBuilder
+
+class InventoryReader implements RuntimeDataProvider {
+
+    @Property
+    var ISwitchManager switchManager;
+
+    override readConfigurationData(InstanceIdentifier<? extends DataObject> path) {
+
+        // Topology and Inventory are operational only
+        return null;
+    }
+
+    override readOperationalData(InstanceIdentifier<? extends DataObject> path) {
+        val type = path.targetType;
+        var DataObject data = null;
+        switch (type) {
+            case Nodes:
+                data = readNodes(path as InstanceIdentifier<Nodes>)
+            case Node:
+                data = readNode(path as InstanceIdentifier<Node>)
+            case NodeConnector:
+                data = readNodeConnector(path as InstanceIdentifier<NodeConnector>)
+        }
+        return data;
+    }
+
+    def DataObject readNodeConnector(InstanceIdentifier<NodeConnector> identifier) {
+        val nodeConnector = identifier.toAdNodeConnector();
+        return constructNodeConnector(nodeConnector)
+    }
+
+    def DataObject readNode(InstanceIdentifier<Node> identifier) {
+        val node = identifier.toAdNode();
+        return constructNode(node);
+    }
+
+
+    def Node constructNode(org.opendaylight.controller.sal.core.Node node) {
+        val connectors = switchManager.getNodeConnectors(node)
+
+        val tpList = new ArrayList<NodeConnector>(connectors.size)
+        for (connector : connectors) {
+            tpList.add(constructNodeConnector(connector));
+        }
+
+        val it = new NodeBuilder()
+        key = node.toNodeKey();
+        nodeConnector = tpList
+        return build();
+    }
+
+    def NodeConnector constructNodeConnector(org.opendaylight.controller.sal.core.NodeConnector connector) {
+        val it = new NodeConnectorBuilder()
+        key = connector.toNodeConnectorKey()
+        return build();
+    }
+
+    def readNodes(InstanceIdentifier<Nodes> identifier) {
+        val nodes = switchManager.nodes
+        val nodeList = new ArrayList<Node>(nodes.size)
+        for (node : nodes) {
+            nodeList.add(constructNode(node))
+        }
+        val it = new NodesBuilder();
+        node = nodeList
+        return build()
+
+    }
+}
diff --git a/opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/switchmanager/CompatibleSwitchManager.xtend b/opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/switchmanager/CompatibleSwitchManager.xtend
new file mode 100644 (file)
index 0000000..430b595
--- /dev/null
@@ -0,0 +1,289 @@
+package org.opendaylight.controller.md.compatibility.switchmanager
+
+import org.opendaylight.controller.switchmanager.ISwitchManager
+import org.opendaylight.controller.sal.core.NodeConnector
+import org.opendaylight.controller.sal.core.Property
+import java.util.List
+import org.opendaylight.controller.sal.core.Node
+import java.net.InetAddress
+import org.opendaylight.controller.sal.binding.api.data.DataBrokerService
+import static extension org.opendaylight.controller.sal.compatibility.NodeMapping.*
+import org.opendaylight.controller.sal.core.Description
+import org.opendaylight.controller.sal.core.Tier
+import org.opendaylight.controller.sal.core.Bandwidth
+import org.opendaylight.controller.sal.core.ForwardingMode
+import org.opendaylight.controller.sal.core.MacAddress
+
+import org.slf4j.LoggerFactory
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier
+import org.opendaylight.yangtools.yang.binding.DataObject
+import java.net.NetworkInterface
+import java.net.SocketException
+import java.util.Collections
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes
+import java.util.ArrayList
+import org.opendaylight.controller.switchmanager.Switch
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId
+import java.util.Map
+import java.util.HashSet
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortState
+
+class CompatibleSwitchManager extends ConfigurableSwitchManager implements ISwitchManager {
+
+    private static val log = LoggerFactory.getLogger(CompatibleSwitchManager)
+
+    @org.eclipse.xtend.lib.Property
+    var DataBrokerService dataService;
+
+    override addNodeConnectorProp(NodeConnector nodeConnector, Property prop) {
+        val it = dataService.beginTransaction
+        val path = nodeConnector.toNodeConnectorRef
+
+        // TODO: Update FlowCapableNode
+        return null;
+    }
+
+    override createProperty(String propName, String propValue) {
+        try {
+            if (propName.equalsIgnoreCase(Description.propertyName)) {
+                return new Description(propValue);
+            } else if (propName.equalsIgnoreCase(Tier.TierPropName)) {
+                val tier = Integer.parseInt(propValue);
+                return new Tier(tier);
+            } else if (propName.equalsIgnoreCase(Bandwidth.BandwidthPropName)) {
+                val bw = Long.parseLong(propValue);
+                return new Bandwidth(bw);
+            } else if (propName.equalsIgnoreCase(ForwardingMode.name)) {
+                val mode = Integer.parseInt(propValue);
+                return new ForwardingMode(mode);
+            } else if (propName.equalsIgnoreCase(MacAddress.name)) {
+                return new MacAddress(propValue);
+            } else {
+                log.debug("Not able to create {} property", propName);
+            }
+        } catch (Exception e) {
+            log.debug("createProperty caught exception {}", e.getMessage());
+        }
+        return null;
+    }
+
+    override doesNodeConnectorExist(NodeConnector nc) {
+        val ref = nc.toNodeConnectorRef
+        return dataService.readOperationalData(ref.value as InstanceIdentifier<? extends DataObject>) !== null
+    }
+
+    override getControllerMAC() {
+        var byte[] macAddress = null;
+
+        try {
+            val nis = NetworkInterface.getNetworkInterfaces();
+            while (nis.hasMoreElements()) {
+                val ni = nis.nextElement();
+                try {
+                    macAddress = ni.getHardwareAddress();
+                    return macAddress;
+                } catch (SocketException e) {
+                    log.error("Failed to acquire controller MAC: ", e);
+                }
+            }
+        } catch (SocketException e) {
+            log.error("Failed to acquire controller MAC: ", e);
+            return macAddress;
+        }
+
+        if (macAddress == null) {
+            log.warn("Failed to acquire controller MAC: No physical interface found");
+
+            // This happens when running controller on windows VM, for example
+            // Try parsing the OS command output
+            }
+            return macAddress;
+        }
+
+    override getControllerProperties() {
+        return Collections.emptyMap()
+    }
+
+    override getControllerProperty(String propertyName) {
+        return null;
+    }
+
+    override getNetworkDevices() {
+        val path = InstanceIdentifier.builder().node(Nodes).toInstance;
+        val data = dataService.readOperationalData(path) as Nodes;
+        val ret = new ArrayList<Switch>();
+        for (node : data.node) {
+            ret.add(node.toSwitch());
+        }
+        return ret;
+    }
+
+    override getNodeConnector(Node node, String nodeConnectorName) {
+        val key = new NodeConnectorKey(new NodeConnectorId(nodeConnectorName));
+        return new NodeConnector(MD_SAL_TYPE, key, node);
+    }
+
+    override getNodeConnectorProp(NodeConnector nodeConnector, String propName) {
+        getNodeConnectorProps(nodeConnector).get(propName);
+    }
+
+    override getNodeConnectorProps(NodeConnector nodeConnector) {
+        val ref = nodeConnector.toNodeConnectorRef
+        val data = readNodeConnector(ref.value);
+        return data.toAdProperties();
+    }
+
+    override getNodeConnectors(Node node) {
+        val ref = node.toNodeRef;
+        val data = readNode(ref.value);
+        val ret = new HashSet();
+        for (nc : data.nodeConnector) {
+
+            val adConnector = new NodeConnector(MD_SAL_TYPE, nc.key, node);
+            ret.add(adConnector);
+        }
+        return ret;
+    }
+
+    override getNodeDescription(Node node) {
+        (getNodeProps(node).get(Description.propertyName) as Description).value;
+    }
+
+    override getNodeMAC(Node node) {
+        (getNodeProps(node).get(MacAddress.name) as MacAddress).macAddress;
+    }
+
+    override getNodeProp(Node node, String propName) {
+        getNodeProps(node).get(propName)
+    }
+
+    override getNodeProps(Node node) {
+        val ref = node.toNodeRef;
+        val data = dataService.readOperationalData(ref.value as InstanceIdentifier<? extends DataObject>) as org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+        return data.toAdProperties();
+    }
+
+    override getNodes() {
+        val path = InstanceIdentifier.builder().node(Nodes).toInstance;
+        val data = dataService.readOperationalData(path) as Nodes;
+        val ret = new HashSet<Node>();
+        for (node : data.node) {
+            ret.add(new Node(MD_SAL_TYPE, node.key));
+        }
+        return ret;
+    }
+
+    def Switch toSwitch(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node node) {
+        val adNode = new Node(MD_SAL_TYPE, node.key);
+        val sw = new Switch(adNode)
+        return sw;
+    }
+
+    override getPhysicalNodeConnectors(Node node) {
+        val ref = node.toNodeRef;
+        val data = readNode(ref.value);
+        val ret = new HashSet();
+        for (nc : data.nodeConnector) {
+            val flowConnector = nc.getAugmentation(FlowCapableNodeConnector)
+            val adConnector = new NodeConnector(MD_SAL_TYPE, nc.key, node);
+            ret.add(adConnector);
+        }
+        return ret;
+    }
+
+    def Map<String, Property> toAdProperties(
+        org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector connector) {
+        return Collections.emptyMap
+    }
+
+    def Map<String, Property> toAdProperties(
+        org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node connector) {
+        return Collections.emptyMap
+    }
+
+    def readNode(InstanceIdentifier<?> ref) {
+        dataService.readOperationalData(ref as InstanceIdentifier<? extends DataObject>) as org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node
+    }
+
+    def readNodeConnector(InstanceIdentifier<?> ref) {
+        dataService.readOperationalData(ref as InstanceIdentifier<? extends DataObject>) as org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector
+    }
+
+    override getSpanPorts(Node node) {
+        throw new UnsupportedOperationException("TODO: auto-generated method stub")
+    }
+
+    override getSubnetByNetworkAddress(InetAddress networkAddress) {
+        throw new UnsupportedOperationException("TODO: auto-generated method stub")
+    }
+
+    override getUpNodeConnectors(Node node) {
+        val ref = node.toNodeRef
+        val data = readNode(ref.value);
+        val ret = new HashSet<NodeConnector>();
+        for (nc : data.nodeConnector) {
+            val flowConn = nc.getAugmentation(FlowCapableNodeConnector);
+            if (flowConn != null && flowConn.state == PortState.Live) {
+                ret.add(new NodeConnector(MD_SAL_TYPE, nc.key, node));
+            }
+        }
+        return ret;
+    }
+
+    override isNodeConnectorEnabled(NodeConnector nodeConnector) {
+        val ref = nodeConnector.toNodeConnectorRef
+        val data = readNodeConnector(ref.value);
+
+        return true;
+    }
+
+    override isSpecial(NodeConnector p) {
+        val ref = p.toNodeConnectorRef
+        val data = readNodeConnector(ref.value);
+
+        return true;
+    }
+
+    override removeControllerProperty(String propertyName) {
+        // NOOP
+    }
+
+    override removeNodeAllProps(Node node) {
+        // NOOP: not supported node has more properties than AD-SAL is capable to see
+    }
+
+    override removeNodeConnectorAllProps(NodeConnector nodeConnector) {
+        // NOOP: not supported node has more properties than AD-SAL is capable to see
+    }
+
+    override removeNodeConnectorProp(NodeConnector nc, String propName) {
+        // NOOP: not supported node has more properties than AD-SAL is capable to see
+    }
+
+    override removeNodeProp(Node node, String propName) {
+        // NOOP: not supported node has more properties than AD-SAL is capable to see
+    }
+
+    override removePortsFromSubnet(String name, List<String> nodeConnectors) {
+        // NOOP
+    }
+
+    override removeSubnet(String name) {
+        // NOOP
+    }
+
+    override setControllerProperty(Property property) {
+        // NOOP
+    }
+
+    override setNodeProp(Node node, Property prop) {
+        throw new UnsupportedOperationException("TODO: auto-generated method stub")
+    }
+
+    override addPortsToSubnet(String name, List<String> nodeConnectors) {
+        throw new UnsupportedOperationException("TODO: auto-generated method stub")
+    }
+
+    }
diff --git a/opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/switchmanager/ConfigurableSwitchManager.xtend b/opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/switchmanager/ConfigurableSwitchManager.xtend
new file mode 100644 (file)
index 0000000..122aa32
--- /dev/null
@@ -0,0 +1,71 @@
+package org.opendaylight.controller.md.compatibility.switchmanager
+
+import org.opendaylight.controller.switchmanager.ISwitchManager
+import org.opendaylight.controller.switchmanager.SpanConfig
+import org.opendaylight.controller.switchmanager.SwitchConfig
+import org.opendaylight.controller.switchmanager.SubnetConfig
+
+/**
+ * 
+ * THis methods should be backed by config subsystem.
+ * 
+ */
+abstract class ConfigurableSwitchManager implements ISwitchManager {
+
+    override saveSwitchConfig() {
+        throw new UnsupportedOperationException("TODO: auto-generated method stub")
+    }
+
+    override removeSpanConfig(SpanConfig cfgObject) {
+        throw new UnsupportedOperationException("TODO: auto-generated method stub")
+    }
+
+    override addSubnet(SubnetConfig configObject) {
+        throw new UnsupportedOperationException("TODO: auto-generated method stub")
+
+    }
+
+    final override addSpanConfig(SpanConfig configObject) {
+        throw new UnsupportedOperationException("TODO: auto-generated method stub")
+
+    }
+
+    final override getSpanConfigList() {
+        throw new UnsupportedOperationException("TODO: auto-generated method stub")
+
+    }
+
+    final override updateSwitchConfig(SwitchConfig cfgObject) {
+        throw new UnsupportedOperationException("TODO: auto-generated method stub")
+
+    }
+
+    final override updateNodeConfig(SwitchConfig switchConfig) {
+        throw new UnsupportedOperationException("TODO: auto-generated method stub")
+
+    }
+
+    final override getSubnetConfig(String subnet) {
+        throw new UnsupportedOperationException("TODO: auto-generated method stub")
+    }
+
+    final override removeNodeConfig(String nodeId) {
+        throw new UnsupportedOperationException("TODO: auto-generated method stub")
+    }
+
+    final override removeSubnet(SubnetConfig configObject) {
+        throw new UnsupportedOperationException("TODO: auto-generated method stub")
+    }
+
+    final override getSubnetsConfigList() {
+        throw new UnsupportedOperationException("TODO: auto-generated method stub")
+    }
+
+    final override getSwitchConfig(String nodeId) {
+        throw new UnsupportedOperationException("TODO: auto-generated method stub")
+    }
+
+    override modifySubnet(SubnetConfig configObject) {
+        throw new UnsupportedOperationException("TODO: auto-generated method stub")
+    }
+}
diff --git a/opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/topology/TopologyMapping.xtend b/opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/topology/TopologyMapping.xtend
new file mode 100644 (file)
index 0000000..5a4aae3
--- /dev/null
@@ -0,0 +1,67 @@
+package org.opendaylight.controller.md.compatibility.topology
+
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier
+import org.opendaylight.yangtools.yang.binding.DataObject
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.network.topology.TopologyKey
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.network.topology.Topology
+import org.opendaylight.controller.sal.core.Edge
+import java.util.Set
+import org.opendaylight.controller.sal.core.Property
+import org.opendaylight.controller.sal.core.NodeConnector
+
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.network.topology.topology.node.TerminationPoint
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.network.topology.topology.Link
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.network.topology.topology.node.TerminationPointKey
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.TpId
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.network.topology.topology.NodeKey
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.NodeId
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.network.topology.topology.LinkKey
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.LinkId
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.IdentifiableItem
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.network.topology.topology.Node
+import org.opendaylight.controller.sal.compatibility.InventoryMapping
+class TopologyMapping {
+
+    new(TopologyKey path, InstanceIdentifier<Topology> key) {
+        // NOOP
+    }
+
+    def Edge toAdTopologyEdge(InstanceIdentifier<Link> identifier) {
+        val linkKey = (identifier.path.last as IdentifiableItem<Link,LinkKey>).key;
+        val components = linkKey.linkId.value.split("::::");
+        val tail = InventoryMapping.nodeConnectorFromId(components.get(0));
+        val head = InventoryMapping.nodeConnectorFromId(components.get(1));
+        return new Edge(tail, head);
+    }
+
+    def NodeConnector toAdTopologyNodeConnector(InstanceIdentifier<TerminationPoint> identifier) {
+        val tpKey = (identifier.path.last as IdentifiableItem<TerminationPoint,TerminationPointKey>).key;
+        return InventoryMapping.nodeConnectorFromId(tpKey.tpId.value);
+    }
+
+    def org.opendaylight.controller.sal.core.Node toAdTopologyNode(
+        InstanceIdentifier<Node> identifier) {
+        val tpKey = (identifier.path.last as IdentifiableItem<Node,NodeKey>).key;
+        return InventoryMapping.nodeFromNodeId(tpKey.nodeId.value);
+    }
+    
+
+
+    def NodeKey toTopologyNodeKey(org.opendaylight.controller.sal.core.Node node) {
+        val nodeId = new NodeId(InventoryMapping.toNodeId(node));
+        return new NodeKey(nodeId);
+    }
+
+    def TerminationPointKey toTopologyTerminationPointKey(NodeConnector nc) {
+        val node = nc.node;
+        val nodeId = new TpId(InventoryMapping.toNodeConnectorId(nc))
+        return new TerminationPointKey(nodeId);
+    }
+
+    def LinkKey toTopologyLinkKey(Edge edge) {
+        val sourceTp = edge.tailNodeConnector.toTopologyTerminationPointKey;
+        val destTp = edge.headNodeConnector.toTopologyTerminationPointKey;
+        val linkId = new LinkId('''«sourceTp.tpId»::::«destTp.tpId»''')
+        return new LinkKey(linkId);
+    }
+}
diff --git a/opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/topology/TopologyReader.xtend b/opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/topology/TopologyReader.xtend
new file mode 100644 (file)
index 0000000..fb9d2b8
--- /dev/null
@@ -0,0 +1,151 @@
+package org.opendaylight.controller.md.compatibility.topology
+
+import org.opendaylight.controller.switchmanager.ISwitchManager
+import org.opendaylight.controller.topologymanager.ITopologyManager
+import org.opendaylight.controller.md.sal.common.api.data.DataReader
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier
+import org.opendaylight.yangtools.yang.binding.DataObject
+import org.opendaylight.controller.sal.binding.api.data.RuntimeDataProvider
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.network.topology.Topology
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.network.topology.topology.Node
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.network.topology.topology.node.TerminationPoint
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.network.topology.topology.Link
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.network.topology.TopologyKey
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.NetworkTopology
+import org.opendaylight.controller.md.compatibility.topology.TopologyMapping
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.network.topology.topology.LinkBuilder
+
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.network.topology.TopologyBuilder
+import java.util.ArrayList
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.network.topology.topology.NodeBuilder
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.network.topology.topology.NodeKey
+import org.opendaylight.controller.sal.core.NodeConnector
+import org.opendaylight.controller.sal.topology.TopoEdgeUpdate
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.TopologyId
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.network.topology.topology.node.TerminationPointBuilder
+import org.opendaylight.controller.sal.core.Edge
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.link.attributes.SourceBuilder
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.link.attributes.DestinationBuilder
+
+class TopologyReader implements RuntimeDataProvider {
+
+    @Property
+    var ISwitchManager switchManager;
+
+    @Property
+    var ITopologyManager topologyManager;
+
+    @Property
+    val TopologyKey topologyKey;
+
+    @Property
+    val InstanceIdentifier<Topology> topologyPath;
+
+    @Property
+    val extension TopologyMapping mapping;
+
+    new() {
+        _topologyKey = new TopologyKey(new TopologyId("compatibility:ad-sal"));
+        _topologyPath = InstanceIdentifier.builder().node(NetworkTopology).child(Topology, topologyKey).toInstance;
+        _mapping = new TopologyMapping(topologyKey, topologyPath);
+    }
+
+    override readConfigurationData(InstanceIdentifier<? extends DataObject> path) {
+
+        // Topology and Inventory are operational only
+        return null;
+    }
+
+    override readOperationalData(InstanceIdentifier<? extends DataObject> path) {
+        val type = path.targetType;
+        var DataObject data = null;
+        if (false == topologyPath.contains(path)) {
+            return null;
+        }
+        switch (type) {
+            case Topology:
+                data = readTopology(path as InstanceIdentifier<Topology>)
+            case Node:
+                data = readNode(path as InstanceIdentifier<Node>)
+            case TerminationPoint:
+                data = readTerminationPoint(path as InstanceIdentifier<TerminationPoint>)
+            case Link:
+                data = readLink(path as InstanceIdentifier<Link>)
+        }
+        return data;
+    }
+
+    def DataObject readLink(InstanceIdentifier<Link> identifier) {
+        val edge = identifier.toAdTopologyEdge();
+        val properties = topologyManager?.edges?.get(edge);
+
+        return constructLink(edge);
+    }
+
+    def DataObject readTerminationPoint(InstanceIdentifier<TerminationPoint> identifier) {
+        val nodeConnector = identifier.toAdTopologyNodeConnector();
+        return constructTerminationPoint(nodeConnector)
+    }
+
+    def DataObject readNode(InstanceIdentifier<Node> identifier) {
+        val node = identifier.toAdTopologyNode();
+        return constructNode(node);
+    }
+
+    def DataObject readTopology(InstanceIdentifier<Topology> identifier) {
+
+        //val nodeConnectors = switchManager.
+        val nodes = switchManager.nodes
+        val edges = topologyManager.edges
+
+        val nodeList = new ArrayList<Node>(nodes.size)
+        for (node : nodes) {
+            nodeList.add(constructNode(node))
+        }
+
+        val linkList = new ArrayList<Link>(edges.size)
+        for (edge : edges.keySet) {
+            linkList.add(constructLink(edge))
+        }
+
+        val it = new TopologyBuilder();
+        key = topologyKey
+        node = nodeList
+        link = linkList
+        return build()
+    }
+
+    def constructLink(Edge edge) {
+        val sourceNc = edge.tailNodeConnector
+        val destNc = edge.headNodeConnector
+
+        val it = new LinkBuilder()
+        key = edge.toTopologyLinkKey();
+        source = new SourceBuilder().setSourceNode(sourceNc.node.toTopologyNodeKey.nodeId).setSourceTp(
+            sourceNc.toTopologyTerminationPointKey.tpId).build()
+        destination = new DestinationBuilder().setDestNode(destNc.node.toTopologyNodeKey.nodeId).setDestTp(
+            destNc.toTopologyTerminationPointKey.tpId).build
+        return build()
+    }
+
+    def Node constructNode(org.opendaylight.controller.sal.core.Node node) {
+        val connectors = switchManager.getNodeConnectors(node)
+
+        val tpList = new ArrayList<TerminationPoint>(connectors.size)
+        for (connector : connectors) {
+            tpList.add(constructTerminationPoint(connector));
+        }
+
+        val it = new NodeBuilder()
+        key = node.toTopologyNodeKey();
+        terminationPoint = tpList
+        return build();
+    }
+
+    def TerminationPoint constructTerminationPoint(NodeConnector connector) {
+        val it = new TerminationPointBuilder()
+        key = connector.toTopologyTerminationPointKey
+        return build();
+    }
+
+}
diff --git a/opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/topologymanager/AdSalTopologyMapping.xtend b/opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/topologymanager/AdSalTopologyMapping.xtend
new file mode 100644 (file)
index 0000000..ad7537b
--- /dev/null
@@ -0,0 +1,94 @@
+package org.opendaylight.controller.md.compatibility.topologymanager
+
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.network.topology.TopologyKey
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.network.topology.topology.node.TerminationPoint
+import org.opendaylight.controller.sal.core.NodeConnector
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.network.topology.Topology
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.NetworkTopology
+import java.util.Map
+import org.opendaylight.controller.sal.core.Edge
+import java.util.Set
+import java.util.List
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.network.topology.topology.Node
+import java.util.Collections
+import com.google.common.collect.FluentIterable
+import java.util.HashSet
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId
+import org.opendaylight.controller.sal.compatibility.NodeMapping
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.network.topology.topology.Link
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.link.attributes.Source
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.link.attributes.Destination
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.TpId
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.network.topology.topology.node.TerminationPointKey
+import java.util.HashMap
+
+class AdSalTopologyMapping {
+
+    val TopologyKey topologyMapping;
+    @Property
+    val InstanceIdentifier<Topology> topologyPath;
+
+    new(TopologyKey topology) {
+        topologyMapping = topology;
+        _topologyPath = InstanceIdentifier.builder.node(NetworkTopology).child(Topology, topology).toInstance;
+    }
+
+    def InstanceIdentifier<TerminationPoint> toTerminationPoint(NodeConnector connector) {
+        InstanceIdentifier.builder(topologyPath).node(Node).child(TerminationPoint, connector.toTerminationPointKey()).toInstance;
+    }
+
+    def Map<Edge, Set<org.opendaylight.controller.sal.core.Property>> toEdgePropertiesMap(Iterable<Link> links) {
+        val ret = new HashMap<Edge, Set<org.opendaylight.controller.sal.core.Property>>
+        for (link : links) {
+            ret.put(link.toEdge(), link.toProperties())
+        }
+        return ret;
+    }
+
+    def Set<Edge> toEdges(Iterable<Link> links) {
+        val ret = new HashSet<Edge>
+        for (link : links) {
+            ret.add(link.toEdge)
+        }
+        return ret;
+    }
+
+    def Edge toEdge(Link link) {
+        val tail = link.source.toNodeConnector();
+        val head = link.destination.toNodeConnector();
+        return new Edge(tail, head);
+    }
+
+    def org.opendaylight.controller.sal.core.Node toAdNode(Node node) {
+        return node.nodeId.toAdNode;
+    }
+
+    def org.opendaylight.controller.sal.core.Node toAdNode(
+        org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.NodeId node) {
+        val key = new NodeKey(new NodeId(node))
+        return new org.opendaylight.controller.sal.core.Node(NodeMapping.MD_SAL_TYPE, key);
+    }
+
+    def NodeConnector toNodeConnector(Source ref) {
+        val adNode = ref.sourceNode.toAdNode();
+        val key = new NodeConnectorKey(new NodeConnectorId(ref.sourceTp))
+        return new NodeConnector(NodeMapping.MD_SAL_TYPE, key, adNode);
+    }
+
+    def NodeConnector toNodeConnector(Destination ref) {
+        val adNode = ref.destNode.toAdNode();
+        val key = new NodeConnectorKey(new NodeConnectorId(ref.destTp))
+        return new NodeConnector(NodeMapping.MD_SAL_TYPE, key, adNode);
+    }
+
+    def TerminationPointKey toTerminationPointKey(NodeConnector connector) {
+    }
+
+    def Set<org.opendaylight.controller.sal.core.Property> toProperties(Link link) {
+    }
+}
diff --git a/opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/topologymanager/CompatibleTopologyManager.xtend b/opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/topologymanager/CompatibleTopologyManager.xtend
new file mode 100644 (file)
index 0000000..c6a4912
--- /dev/null
@@ -0,0 +1,85 @@
+package org.opendaylight.controller.md.compatibility.topologymanager
+
+import org.opendaylight.controller.topologymanager.ITopologyManager
+import org.opendaylight.controller.sal.core.NodeConnector
+import org.opendaylight.controller.sal.core.Host
+import org.opendaylight.controller.sal.core.UpdateType
+import java.util.Set
+import org.opendaylight.controller.md.sal.binding.util.TypeSafeDataReader
+import java.util.HashMap
+import org.opendaylight.controller.sal.core.Edge
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.network.topology.topology.node.TerminationPoint
+import com.google.common.collect.FluentIterable
+
+class CompatibleTopologyManager extends ConfigurableLinkManager implements ITopologyManager {
+
+    @Property
+    var TypeSafeDataReader dataReader;
+
+    @Property
+    var extension AdSalTopologyMapping topologyMapping;
+
+    override getEdges() {
+        val topology = dataReader.readOperationalData(topologyPath);
+        return topology.link.toEdgePropertiesMap();
+    }
+
+    override getNodeEdges() {
+        val topology = dataReader.readOperationalData(topologyPath);
+        val ret = new HashMap<org.opendaylight.controller.sal.core.Node, Set<Edge>>;
+        for (node : topology.node) {
+            val adNode = node.toAdNode();
+            val adEdges = FluentIterable.from(topology.link).filter[
+                source.sourceNode == node.nodeId || destination.destNode == node.nodeId].toEdges();
+            ret.put(adNode, adEdges)
+        }
+        return ret;
+    }
+
+    /**
+     *   Returns true if point is connected to link
+    */
+    def isInternal(TerminationPoint point) {
+        val topology = dataReader.readConfigurationData(topologyPath);
+        val tpId = point.key.tpId;
+        return FluentIterable.from(topology.link).anyMatch(
+            [
+                source.sourceTp == tpId || destination.destTp == tpId
+            ])
+    }
+
+    override getNodeConnectorWithHost() {
+    }
+
+    override getHostAttachedToNodeConnector(NodeConnector p) {
+        val tpPath = p.toTerminationPoint();
+        throw new UnsupportedOperationException("TODO: auto-generated method stub")
+    }
+
+    override getHostsAttachedToNodeConnector(NodeConnector p) {
+        val topology = dataReader.readOperationalData(topologyPath);
+
+        throw new UnsupportedOperationException("Hosts not mapped yet")
+    }
+
+    override getNodesWithNodeConnectorHost() {
+        throw new UnsupportedOperationException("TODO: auto-generated method stub")
+
+    }
+
+    override isInternal(NodeConnector p) {
+        val tpPath = p.toTerminationPoint();
+        val connector = dataReader.readConfigurationData(tpPath);
+        return connector.isInternal();
+    }
+
+    override updateHostLink(NodeConnector p, Host h, UpdateType t,
+        Set<org.opendaylight.controller.sal.core.Property> props) {
+        // Update app defined topology
+    }
+
+    override saveConfig() {
+        // FIXME: commit configuration
+    }
+
+}
diff --git a/opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/topologymanager/ConfigurableLinkManager.xtend b/opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/topologymanager/ConfigurableLinkManager.xtend
new file mode 100644 (file)
index 0000000..da3bf66
--- /dev/null
@@ -0,0 +1,24 @@
+package org.opendaylight.controller.md.compatibility.topologymanager
+
+import org.opendaylight.controller.topologymanager.ITopologyManager
+import org.opendaylight.controller.topologymanager.TopologyUserLinkConfig
+
+abstract class ConfigurableLinkManager implements ITopologyManager {
+    
+    final override addUserLink(TopologyUserLinkConfig link) {
+        throw new UnsupportedOperationException("TODO: auto-generated method stub")
+        
+    }
+    
+    
+    final override deleteUserLink(String linkName) {
+        throw new UnsupportedOperationException("TODO: auto-generated method stub")
+        
+    }
+    
+    
+    final override getUserLinks() {
+        throw new UnsupportedOperationException("TODO: auto-generated method stub")
+        
+    }
+}
\ No newline at end of file
diff --git a/opendaylight/md-sal/compatibility/pom.xml b/opendaylight/md-sal/compatibility/pom.xml
new file mode 100644 (file)
index 0000000..a829380
--- /dev/null
@@ -0,0 +1,101 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.opendaylight.controller</groupId>
+        <artifactId>sal-parent</artifactId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+    <artifactId>compatibility-parent</artifactId>
+    <packaging>pom</packaging>
+    <name>MD-SAL to AD-SAL Adaptation</name>
+    <scm>
+        <connection>scm:git:ssh://git.opendaylight.org:29418/controller.git</connection>
+        <developerConnection>scm:git:ssh://git.opendaylight.org:29418/controller.git</developerConnection>
+        <url>https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL</url>
+    </scm>
+
+    <modules>
+        <module>sal-compatibility</module>
+        <module>inventory-topology-compatibility</module>
+        <module>flow-management-compatibility</module>
+    </modules>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>sal</artifactId>
+            <version>0.5.1-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller.model</groupId>
+            <artifactId>model-flow-service</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>sal-common-util</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>sal-binding-api</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>com.google.guava</groupId>
+            <artifactId>guava</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.xtend</groupId>
+            <artifactId>org.eclipse.xtend.lib</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.eclipse.xtend</groupId>
+                <artifactId>xtend-maven-plugin</artifactId>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <configuration>
+                    <instructions>
+                        <Bundle-Name>${project.name}</Bundle-Name>
+                        <Bundle-Activator>org.opendaylight.controller.sal.compability.ComponentActivator</Bundle-Activator>
+                    </instructions>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.jacoco</groupId>
+                <artifactId>jacoco-maven-plugin</artifactId>
+                <configuration>
+                    <includes>org.opendaylight.controller.*</includes>
+                </configuration>
+                <executions>
+                    <execution>
+                        <id>pre-test</id>
+                        <goals>
+                            <goal>prepare-agent</goal>
+                        </goals>
+                    </execution>
+                    <execution>
+                        <id>post-test</id>
+                        <phase>test</phase>
+                        <goals>
+                            <goal>report</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>
@@ -3,10 +3,10 @@
   <modelVersion>4.0.0</modelVersion>
   <parent>
     <groupId>org.opendaylight.controller</groupId>
-    <artifactId>sal-parent</artifactId>
+    <artifactId>compatibility-parent</artifactId>
     <version>1.0-SNAPSHOT</version>
   </parent>
-  <artifactId>sal-compability</artifactId>
+  <artifactId>sal-compatibility</artifactId>
   <name>MD-SAL to AD-SAL Adaptation</name>
   <scm>
     <connection>scm:git:ssh://git.opendaylight.org:29418/controller.git</connection>
   </scm>
 
   <dependencies>
-    <dependency>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>sal</artifactId>
-      <version>0.5.1-SNAPSHOT</version>
-    </dependency>
-    <dependency>
-      <groupId>org.opendaylight.controller.model</groupId>
-      <artifactId>model-flow-service</artifactId>
-      <version>1.0-SNAPSHOT</version>
-    </dependency>
     <dependency>
       <groupId>org.opendaylight.controller.model</groupId>
       <artifactId>model-flow-statistics</artifactId>
       <version>1.0-SNAPSHOT</version>
     </dependency>
-    <dependency>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>sal-common-util</artifactId>
-      <version>1.0-SNAPSHOT</version>
-    </dependency>
-    <dependency>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>sal-binding-api</artifactId>
-      <version>1.0-SNAPSHOT</version>
-    </dependency>
-    <dependency>
-      <groupId>com.google.guava</groupId>
-      <artifactId>guava</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.eclipse.xtend</groupId>
-      <artifactId>org.eclipse.xtend.lib</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-      <scope>test</scope>
-    </dependency>
   </dependencies>
   <packaging>bundle</packaging>
 
@@ -68,7 +35,7 @@
         <configuration>
           <instructions>
             <Bundle-Name>${project.name}</Bundle-Name>
-            <Bundle-Activator>org.opendaylight.controller.sal.compability.ComponentActivator</Bundle-Activator>
+            <Bundle-Activator>org.opendaylight.controller.sal.compatibility.ComponentActivator</Bundle-Activator>
           </instructions>
         </configuration>
       </plugin>
@@ -1,10 +1,10 @@
-package org.opendaylight.controller.sal.compability
+package org.opendaylight.controller.sal.compatibility
 
 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey
 import org.opendaylight.controller.sal.core.Node
 import org.opendaylight.controller.sal.core.NodeConnector
-import static org.opendaylight.controller.sal.compability.NodeMapping.*
+import static org.opendaylight.controller.sal.compatibility.NodeMapping.*
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey
 import org.apache.felix.dm.Component
 import java.util.Arrays
@@ -1,4 +1,4 @@
-package org.opendaylight.controller.sal.compability
+package org.opendaylight.controller.sal.compatibility
 
 import java.util.concurrent.ExecutionException
 import org.opendaylight.controller.sal.core.Node
@@ -15,10 +15,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalF
 import org.opendaylight.yangtools.yang.common.RpcResult
 import org.slf4j.LoggerFactory
 
-import static org.opendaylight.controller.sal.compability.MDFlowMapping.*
+import static org.opendaylight.controller.sal.compatibility.MDFlowMapping.*