Merge "BUG 2317 : StatisticsManager does not unregister from yang notifications on...
authorTom Pantelis <tpanteli@brocade.com>
Fri, 7 Nov 2014 18:42:12 +0000 (18:42 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Fri, 7 Nov 2014 18:42:12 +0000 (18:42 +0000)
196 files changed:
opendaylight/commons/filter-valve/src/test/java/org/opendaylight/controller/filtervalve/cors/jaxb/ParserTest.java
opendaylight/commons/liblldp/src/test/java/org/opendaylight/controller/sal/packet/BitBufferHelperTest.java
opendaylight/commons/opendaylight/pom.xml
opendaylight/config/config-api/src/test/java/org/opendaylight/controller/config/api/IdentityAttributeRefTest.java
opendaylight/config/config-api/src/test/java/org/opendaylight/controller/config/api/JmxAttributeValidationExceptionTest.java
opendaylight/config/config-api/src/test/java/org/opendaylight/controller/config/api/ModuleIdentifierTest.java
opendaylight/config/config-api/src/test/java/org/opendaylight/controller/config/api/ValidationExceptionTest.java
opendaylight/config/config-api/src/test/java/org/opendaylight/controller/config/api/jmx/CommitStatusTest.java
opendaylight/config/config-api/src/test/java/org/opendaylight/controller/config/api/jmx/ObjectNameUtilTest.java
opendaylight/config/config-artifacts/pom.xml [new file with mode: 0644]
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/util/InterfacesHelper.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/util/OsgiRegistrationUtil.java
opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/dependencyresolver/DependencyResolverManagerTest.java
opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/osgi/BlankTransactionServiceTrackerTest.java
opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/osgi/BundleContextBackedModuleFactoriesResolverTest.java
opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/osgi/ModuleFactoryBundleTrackerTest.java
opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/osgi/RefreshingSCPModuleInfoRegistryTest.java
opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/util/InterfacesHelperTest.java
opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/util/OsgiRegistrationUtilTest.java
opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/testingservices/scheduledthreadpool/TestingScheduledThreadPoolModuleFactory.java
opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/testingservices/scheduledthreadpool/test/TwoInterfacesExportTest.java
opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/testingservices/threadpool/TestingFixedThreadPoolModuleFactory.java
opendaylight/config/config-netty-config/pom.xml
opendaylight/config/config-persister-directory-xml-adapter/src/main/java/org/opendaylight/controller/config/persist/storage/directory/xml/XmlDirectoryPersister.java
opendaylight/config/config-persister-directory-xml-adapter/src/main/java/org/opendaylight/controller/config/persist/storage/directory/xml/XmlDirectoryStorageAdapter.java
opendaylight/config/config-persister-directory-xml-adapter/src/test/java/org/opendaylight/controller/config/persist/storage/directory/xml/DirectoryStorageAdapterTest.java
opendaylight/config/config-persister-feature-adapter/src/main/java/org/opendaylight/controller/configpusherfeature/internal/ConfigPusherCustomizer.java
opendaylight/config/config-persister-feature-adapter/src/main/java/org/opendaylight/controller/configpusherfeature/internal/ConfigPushingRunnable.java
opendaylight/config/config-persister-feature-adapter/src/main/java/org/opendaylight/controller/configpusherfeature/internal/FeatureConfigPusher.java
opendaylight/config/config-persister-feature-adapter/src/main/java/org/opendaylight/controller/configpusherfeature/internal/FeatureConfigSnapshotHolder.java
opendaylight/config/config-persister-file-xml-adapter/src/test/java/org/opendaylight/controller/config/persist/storage/file/xml/FileStorageAdapterTest.java
opendaylight/config/config-util/src/test/java/org/opendaylight/controller/config/util/AttributeEntryTest.java
opendaylight/config/config-util/src/test/java/org/opendaylight/controller/config/util/ConfigRegistryClientsTest.java
opendaylight/config/config-util/src/test/java/org/opendaylight/controller/config/util/LookupTest.java
opendaylight/config/logback-config-loader/src/test/java/org/opendaylight/controller/logback/config/loader/test/LogbackConfigurationLoaderTest.java
opendaylight/config/logback-config-loader/src/test/resources/logback-test.xml
opendaylight/config/logback-config-loader/src/test/resources/logback.d/logback-alt.xml
opendaylight/config/logback-config-loader/src/test/resources/logback.d/logback-alt2.xml
opendaylight/config/logback-config-loader/src/test/resources/logback.d/logback-alt3.xml
opendaylight/config/logback-config/src/main/java/org/opendaylight/controller/config/yang/logback/config/ContextSetterImpl.java
opendaylight/config/logback-config/src/main/java/org/opendaylight/controller/config/yang/logback/config/LogbackModuleFactory.java
opendaylight/config/logback-config/src/test/java/org/opendaylight/controller/config/yang/logback/config/LogbackModuleTest.java
opendaylight/config/netconf-config-dispatcher/src/main/java/org/opendaylight/controller/config/yang/config/netconf/client/dispatcher/NetconfClientDispatcherModule.java
opendaylight/config/netty-timer-config/src/test/java/org/opendaylight/controller/config/yang/netty/timer/HashedWheelTimerModuleTest.java
opendaylight/config/pom.xml
opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/async/AsyncEventBusConfigBeanTest.java
opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/eventbus/SyncEventBusConfigBeanTest.java
opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/fixed/FixedThreadPoolConfigBeanTest.java
opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/flexible/FlexibleThreadPoolConfigBeanTest.java
opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/naming/NamingThreadPoolFactoryConfigBeanTest.java
opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/scheduled/ScheduledThreadPoolConfigBeanTest.java
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/TemplateFactory.java
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/gofactory/AbsModuleGeneratedObjectFactory.java
opendaylight/config/yang-jmx-generator-plugin/src/test/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/JMXGeneratorFileNamesValidationTest.java
opendaylight/config/yang-jmx-generator-plugin/src/test/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/JMXGeneratorGeneratedFilesTrackerTest.java
opendaylight/config/yang-jmx-generator-plugin/src/test/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/JMXGeneratorTest.java
opendaylight/config/yang-jmx-generator/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/attribute/Dependency.java
opendaylight/config/yang-jmx-generator/src/test/java/org/opendaylight/controller/config/yangjmxgenerator/AbstractYangTest.java
opendaylight/config/yang-jmx-generator/src/test/java/org/opendaylight/controller/config/yangjmxgenerator/RuntimeBeanEntryTest.java
opendaylight/config/yang-test/src/test/java/org/opendaylight/controller/config/yang/test/impl/NetconfTestImplModuleTest.java
opendaylight/karaf-branding/pom.xml
opendaylight/md-sal/benchmark-data-store/pom.xml
opendaylight/md-sal/compatibility/sal-compatibility/src/test/java/org/opendaylight/controller/sal/compatibility/test/MDFlowMappingTest.java
opendaylight/md-sal/compatibility/sal-compatibility/src/test/java/org/opendaylight/controller/sal/compatibility/test/TestToSalConversionsUtils.java
opendaylight/md-sal/compatibility/sal-compatibility/src/test/java/org/opendaylight/controller/sal/compatibility/topology/test/TopologyMappingTest.java
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/example/ExampleActor.java
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/example/ExampleConfigParamsImpl.java
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/example/TestDriver.java
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/AbstractReplicatedLogImpl.java
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/FollowerLogInformation.java
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/FollowerLogInformationImpl.java
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActor.java
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/ReplicatedLog.java
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/base/messages/CaptureSnapshot.java
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/base/messages/InitiateInstallSnapshot.java [new file with mode: 0644]
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/base/messages/SendInstallSnapshot.java
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/Leader.java
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/client/messages/AddRaftPeer.java [deleted file]
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/client/messages/RemoveRaftPeer.java [deleted file]
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/AbstractReplicatedLogImplTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/FollowerLogInformationImplTest.java [new file with mode: 0644]
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/RaftActorTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/CandidateTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/FollowerTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/LeaderTest.java
opendaylight/md-sal/sal-akka-raft/src/test/resources/application.conf
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/AbstractRuntimeCodeGenerator.java
opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/AugmentationVerifier.java
opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/CrossBrokerRpcTest.java
opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/DOMRpcServiceTestBugfix560.java
opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/MessageCapturingFlowService.java
opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/NormalizedNodeToNodeCodecTest.java
opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/NodeIdentifierFactoryTest.java
opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/QNameFactoryTest.java
opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/xml/codec/XmlUtilsTest.java
opendaylight/md-sal/sal-distributed-datastore/pom.xml
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ConfigurationImpl.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionProxy.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CanCommitTransactionReply.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CloseDataChangeListenerRegistration.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CloseDataChangeListenerRegistrationReply.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CloseTransaction.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CloseTransactionChain.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CloseTransactionChainReply.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CloseTransactionReply.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CreateTransactionReply.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/DataChangedReply.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/DataExists.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/DataExistsReply.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/DeleteData.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/DeleteDataReply.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/MergeDataReply.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/PreCommitTransaction.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/PreCommitTransactionReply.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/PrimaryFound.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/PrimaryNotFound.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/ReadData.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/ReadyTransaction.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/RegisterChangeListenerReply.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/WriteDataReply.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/MergeModification.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/WriteModification.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ShardStrategyFactory.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ConfigurationImplTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataChangeListenerProxyTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreIntegrationTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTransactionFailureTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTransactionTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/shardstrategy/DefaultShardStrategyTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ModuleShardStrategyTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ShardStrategyFactoryTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/MockConfiguration.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/MockDataChangeListener.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/TestUtils.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/CarsModel.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/PeopleModel.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/SampleModelsTest.java
opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataBroker.java
opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/sal/dom/broker/BackwardsCompatibleMountPointManagerTest.java
opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/sal/dom/broker/BackwardsCompatibleMountPointTest.java
opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMDataBroker.java [new file with mode: 0644]
opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMDataReadOnlyTransaction.java [new file with mode: 0644]
opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMDataReadWriteTransaction.java [new file with mode: 0644]
opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMDataWriteTransaction.java [new file with mode: 0644]
opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMTransactionChain.java [new file with mode: 0644]
opendaylight/md-sal/sal-dom-xsql-config/pom.xml
opendaylight/md-sal/sal-dom-xsql/pom.xml
opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/util/NetconfMessageTransformUtil.java
opendaylight/md-sal/sal-netconf-connector/src/test/java/org/opendaylight/controller/sal/connect/netconf/NetconfDeviceTest.java
opendaylight/md-sal/sal-netconf-connector/src/test/java/org/opendaylight/controller/sal/connect/netconf/NetconfStateSchemasTest.java
opendaylight/md-sal/sal-netconf-connector/src/test/java/org/opendaylight/controller/sal/connect/netconf/NetconfToNotificationTest.java
opendaylight/md-sal/sal-netconf-connector/src/test/java/org/opendaylight/controller/sal/connect/netconf/NetconfToRpcRequestTest.java
opendaylight/md-sal/sal-netconf-connector/src/test/java/org/opendaylight/controller/sal/connect/netconf/listener/NetconfSessionCapabilitiesTest.java
opendaylight/md-sal/sal-netconf-connector/src/test/java/org/opendaylight/controller/sal/connect/netconf/sal/tx/NetconfDeviceWriteOnlyTxTest.java
opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/utils/LatestEntryRoutingLogicTest.java
opendaylight/md-sal/sal-rest-docgen/src/test/java/org/opendaylight/controller/sal/rest/doc/impl/ApiDocGeneratorTest.java
opendaylight/netconf/config-netconf-connector/pom.xml
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/runtimerpc/RuntimeRpcElementResolved.java
opendaylight/netconf/config-netconf-connector/src/test/java/org/opendaylight/controller/netconf/confignetconfconnector/NetconfMappingTest.java
opendaylight/netconf/config-netconf-connector/src/test/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/runtimerpc/RuntimeRpcElementResolvedTest.java [new file with mode: 0644]
opendaylight/netconf/config-netconf-connector/src/test/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/NetconfOperationServiceImplTest.java
opendaylight/netconf/config-persister-impl/src/test/java/org/opendaylight/controller/netconf/persist/impl/PersisterAggregatorTest.java
opendaylight/netconf/config-persister-impl/src/test/java/org/opendaylight/controller/netconf/persist/impl/osgi/TestingExceptionHandler.java
opendaylight/netconf/netconf-client/src/test/java/org/opendaylight/controller/netconf/client/NetconfClientDispatcherImplTest.java
opendaylight/netconf/netconf-client/src/test/java/org/opendaylight/controller/netconf/client/NetconfClientSessionNegotiatorFactoryTest.java
opendaylight/netconf/netconf-client/src/test/java/org/opendaylight/controller/netconf/client/NetconfClientSessionNegotiatorTest.java
opendaylight/netconf/netconf-client/src/test/java/org/opendaylight/controller/netconf/client/NetconfClientSessionTest.java
opendaylight/netconf/netconf-client/src/test/java/org/opendaylight/controller/netconf/client/NetconfReconnectingClientConfigurationTest.java
opendaylight/netconf/netconf-client/src/test/java/org/opendaylight/controller/netconf/client/SimpleNetconfClientSessionListenerTest.java
opendaylight/netconf/netconf-client/src/test/java/org/opendaylight/controller/netconf/client/TcpClientChannelInitializerTest.java
opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/mapping/operations/DefaultNetconfOperation.java
opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/mapping/operations/DefaultStartExi.java
opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/mapping/operations/DefaultStopExi.java
opendaylight/netconf/netconf-impl/src/test/java/org/opendaylight/controller/netconf/impl/AdditionalHeaderParserTest.java
opendaylight/netconf/netconf-impl/src/test/java/org/opendaylight/controller/netconf/impl/ExiEncodeDecodeTest.java
opendaylight/netconf/netconf-impl/src/test/java/org/opendaylight/controller/netconf/impl/mapping/operations/DefaultCloseSessionTest.java
opendaylight/netconf/netconf-impl/src/test/java/org/opendaylight/controller/netconf/impl/mapping/operations/DefaultGetSchemaTest.java
opendaylight/netconf/netconf-impl/src/test/java/org/opendaylight/controller/netconf/impl/osgi/NetconfImplActivatorTest.java
opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfConfigPersisterITTest.java
opendaylight/netconf/netconf-monitoring/src/test/java/org/opendaylight/controller/netconf/monitoring/GetTest.java
opendaylight/netconf/netconf-monitoring/src/test/java/org/opendaylight/controller/netconf/monitoring/osgi/NetconfMonitoringActivatorTest.java
opendaylight/netconf/netconf-monitoring/src/test/java/org/opendaylight/controller/netconf/monitoring/osgi/NetconfMonitoringServiceTrackerTest.java
opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/exi/EXIParameters.java
opendaylight/netconf/netconf-netty-util/src/test/java/org/opendaylight/controller/netconf/nettyutil/handler/ChunkedFramingMechanismEncoderTest.java
opendaylight/netconf/netconf-netty-util/src/test/java/org/opendaylight/controller/netconf/nettyutil/handler/NetconfEXIHandlersTest.java
opendaylight/netconf/netconf-netty-util/src/test/java/org/opendaylight/controller/netconf/nettyutil/handler/ssh/client/AsyncSshHandlerTest.java
opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/mapping/AbstractNetconfOperation.java
opendaylight/netconf/netconf-util/src/test/java/org/opendaylight/controller/netconf/util/NetconfUtilTest.java
opendaylight/netconf/netconf-util/src/test/java/org/opendaylight/controller/netconf/util/messages/NetconfHelloMessageTest.java
opendaylight/netconf/netconf-util/src/test/java/org/opendaylight/controller/netconf/util/messages/NetconfMessageHeaderTest.java
opendaylight/netconf/netconf-util/src/test/java/org/opendaylight/controller/netconf/util/osgi/NetconfConfigUtilTest.java
opendaylight/netconf/netconf-util/src/test/resources/netconfMessages/startExi.xml
opendaylight/netconf/netconf-util/src/test/resources/netconfMessages/stopExi.xml
opendaylight/northbound/bundlescanner/implementation/src/test/java/org/opendaylight/controller/northbound/bundlescanner/internal/BundleScannerTest.java
opendaylight/northbound/topology/src/test/java/org/opendaylight/controller/topology/northbound/TopologyTest.java

index fc6c01b381bfd00cbd23a403b48f1d4fdd198ade..735cf3c5e5761c9b62ba0dba63ff0ec0ac747a05 100644 (file)
@@ -9,11 +9,11 @@
 package org.opendaylight.controller.filtervalve.cors.jaxb;
 
 import static org.hamcrest.core.Is.is;
+import static org.hamcrest.CoreMatchers.containsString;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
-import static org.junit.matchers.JUnitMatchers.containsString;
 
 import com.google.common.base.Optional;
 import java.io.File;
index 07fbf0599b889d6281e4f7e0b1819912969ea711..07b18d7725f3378e0a32e8bc8caeb842d66196db 100644 (file)
@@ -9,8 +9,7 @@
 
 package org.opendaylight.controller.sal.packet;
 
-import junit.framework.Assert;
-
+import org.junit.Assert;
 import org.junit.Test;
 import org.opendaylight.controller.liblldp.BitBufferHelper;
 
index 198d17a79a66931ebb8e19a55d97372c09485b14..ae37f4ae2aaed13ebbef886d17bca420dc9d92eb 100644 (file)
     <dependencies>
 
        <!-- project specific dependencies -->
+      <dependency>
+        <groupId>org.opendaylight.controller</groupId>
+        <artifactId>config-artifacts</artifactId>
+        <version>${config.version}</version>
+        <type>pom</type>
+        <scope>import</scope>
+      </dependency>
       <dependency>
         <groupId>org.opendaylight.controller</groupId>
         <artifactId>netconf-artifacts</artifactId>
         <type>pom</type>
         <scope>import</scope>
       </dependency>
+
       <dependency>
         <groupId>org.apache.sshd</groupId>
         <artifactId>sshd-core</artifactId>
       </dependency>
 
       <!-- config-->
-      <dependency>
-        <groupId>org.opendaylight.controller</groupId>
-        <artifactId>config-api</artifactId>
-        <version>${config.version}</version>
-      </dependency>
-      <dependency>
-        <groupId>org.opendaylight.controller</groupId>
-        <artifactId>config-manager</artifactId>
-        <version>${config.version}</version>
-        <type>test-jar</type>
-      </dependency>
-      <dependency>
-        <groupId>org.opendaylight.controller</groupId>
-        <artifactId>config-manager</artifactId>
-        <version>${config.version}</version>
-      </dependency>
-      <dependency>
-        <groupId>org.opendaylight.controller</groupId>
-        <artifactId>config-persister-api</artifactId>
-        <version>${config.version}</version>
-        <type>test-jar</type>
-      </dependency>
-      <dependency>
-        <groupId>org.opendaylight.controller</groupId>
-        <artifactId>config-persister-api</artifactId>
-        <version>${config.version}</version>
-      </dependency>
-      <dependency>
-        <groupId>org.opendaylight.controller</groupId>
-        <artifactId>config-persister-directory-xml-adapter</artifactId>
-        <version>${config.version}</version>
-      </dependency>
-      <dependency>
-        <groupId>org.opendaylight.controller</groupId>
-        <artifactId>config-persister-file-xml-adapter</artifactId>
-        <version>${config.version}</version>
-      </dependency>
-      <dependency>
-        <groupId>org.opendaylight.controller</groupId>
-        <artifactId>config-persister-feature-adapter</artifactId>
-        <version>${config.version}</version>
-      </dependency>
-
-      <dependency>
-        <groupId>org.opendaylight.controller</groupId>
-        <artifactId>config-util</artifactId>
-        <version>${config.version}</version>
-      </dependency>
-      <dependency>
-        <groupId>org.opendaylight.controller</groupId>
-        <artifactId>config-util</artifactId>
-        <version>${config.version}</version>
-        <type>test-jar</type>
-      </dependency>
       <dependency>
         <groupId>org.opendaylight.controller</groupId>
         <artifactId>configuration</artifactId>
         <artifactId>liblldp</artifactId>
         <version>${sal.version}</version>
       </dependency>
-      <dependency>
-        <groupId>org.opendaylight.controller</groupId>
-        <artifactId>logback-config</artifactId>
-        <version>${config.version}</version>
-      </dependency>
       <!-- Debug and logging -->
       <dependency>
         <groupId>org.opendaylight.controller</groupId>
         <version>${dummy-console.version}</version>
       </dependency>
 
-      <dependency>
-        <groupId>org.opendaylight.controller</groupId>
-        <artifactId>netty-config-api</artifactId>
-        <version>${config.version}</version>
-      </dependency>
-      <dependency>
-        <groupId>org.opendaylight.controller</groupId>
-        <artifactId>netty-event-executor-config</artifactId>
-        <version>${config.version}</version>
-      </dependency>
-      <dependency>
-        <groupId>org.opendaylight.controller</groupId>
-        <artifactId>netty-threadgroup-config</artifactId>
-        <version>${config.version}</version>
-      </dependency>
-      <dependency>
-        <groupId>org.opendaylight.controller</groupId>
-        <artifactId>netty-timer-config</artifactId>
-        <version>${config.version}</version>
-      </dependency>
       <dependency>
         <groupId>org.opendaylight.controller</groupId>
         <artifactId>networkconfig.bridgedomain.northbound</artifactId>
         <artifactId>sal-rest-connector-config</artifactId>
         <version>${mdsal.version}</version>
       </dependency>
-      <dependency>
-        <groupId>org.opendaylight.controller</groupId>
-        <artifactId>config-netty-config</artifactId>
-        <version>${config.version}</version>
-      </dependency>
       <dependency>
         <groupId>org.opendaylight.controller</groupId>
         <artifactId>md-sal-config</artifactId>
         <version>${karaf.security.version}</version>
       </dependency>
 
-      <dependency>
-        <groupId>org.opendaylight.controller</groupId>
-        <artifactId>shutdown-api</artifactId>
-        <version>${config.version}</version>
-      </dependency>
-      <dependency>
-        <groupId>org.opendaylight.controller</groupId>
-        <artifactId>shutdown-impl</artifactId>
-        <version>${config.version}</version>
-      </dependency>
       <dependency>
         <groupId>org.opendaylight.controller</groupId>
         <artifactId>statistics.northbound</artifactId>
         <version>${switchmanager.northbound.version}</version>
       </dependency>
 
-      <!-- threadpool -->
-      <dependency>
-        <groupId>org.opendaylight.controller</groupId>
-        <artifactId>threadpool-config-api</artifactId>
-        <version>${config.version}</version>
-      </dependency>
-      <dependency>
-        <groupId>org.opendaylight.controller</groupId>
-        <artifactId>threadpool-config-impl</artifactId>
-        <version>${config.version}</version>
-      </dependency>
       <dependency>
         <groupId>org.opendaylight.controller</groupId>
         <artifactId>topology.northbound</artifactId>
         <artifactId>web</artifactId>
         <version>${web.version}</version>
       </dependency>
-      <dependency>
-        <groupId>org.opendaylight.controller</groupId>
-        <artifactId>yang-jmx-generator</artifactId>
-        <version>${config.version}</version>
-      </dependency>
-      <dependency>
-        <groupId>org.opendaylight.controller</groupId>
-        <artifactId>yang-jmx-generator</artifactId>
-        <version>${config.version}</version>
-        <type>test-jar</type>
-      </dependency>
-      <dependency>
-        <groupId>org.opendaylight.controller</groupId>
-        <artifactId>yang-test</artifactId>
-        <version>${config.version}</version>
-      </dependency>
       <dependency>
         <groupId>org.opendaylight.controller.md</groupId>
         <artifactId>forwardingrules-manager</artifactId>
         <type>xml</type>
         <scope>runtime</scope>
       </dependency>
-      <dependency>
-        <groupId>org.opendaylight.controller</groupId>
-        <artifactId>features-config-netty</artifactId>
-        <version>${config.version}</version>
-        <classifier>features</classifier>
-        <type>xml</type>
-        <scope>runtime</scope>
-      </dependency>
       <dependency>
         <groupId>org.opendaylight.controller</groupId>
         <artifactId>features-flow</artifactId>
         <version>${mdsal.version}</version>
         <scope>test</scope>
       </dependency>
-      <dependency>
-        <groupId>org.opendaylight.controller</groupId>
-        <artifactId>features-config</artifactId>
-        <version>${config.version}</version>
-        <classifier>features</classifier>
-        <type>xml</type>
-        <scope>runtime</scope>
-      </dependency>
       <dependency>
         <groupId>org.opendaylight.controller</groupId>
         <artifactId>features-protocol-framework</artifactId>
         <type>xml</type>
         <scope>runtime</scope>
       </dependency>
-      <dependency>
-        <groupId>org.opendaylight.controller</groupId>
-        <artifactId>features-config-persister</artifactId>
-        <version>${config.version}</version>
-        <classifier>features</classifier>
-        <type>xml</type>
-        <scope>runtime</scope>
-      </dependency>
-      <dependency>
-        <groupId>org.opendaylight.controller</groupId>
-        <artifactId>config-netty-features</artifactId>
-        <version>${config.version}</version>
-        <classifier>features</classifier>
-        <type>xml</type>
-        <scope>runtime</scope>
-      </dependency>
       <dependency>
         <groupId>org.opendaylight.controller</groupId>
         <artifactId>features-base</artifactId>
index 6e8ece343f7ca6b0b0bdd126cb5b013fddc5d342..91e1f14849c03364f57f67b28eee5ff2d6017f8c 100644 (file)
@@ -1,17 +1,13 @@
 package org.opendaylight.controller.config.api;
 
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
 import org.junit.Assert;
 import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.opendaylight.controller.config.api.annotations.AbstractServiceInterface;
 import org.opendaylight.yangtools.yang.binding.BaseIdentity;
 
-import javax.management.*;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.*;
-
 public class IdentityAttributeRefTest {
 
     IdentityAttributeRef attr = new IdentityAttributeRef("attr");
index f6e7dfb505ed486fb80cb8a5bc7f6799536abed0..9ff74052579f14f70be71d9df771d61fccd06eb4 100644 (file)
@@ -1,23 +1,18 @@
 package org.opendaylight.controller.config.api;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+import com.google.common.collect.Lists;
 import java.nio.file.AccessDeniedException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
-
-import com.google.common.collect.Lists;
 import org.hamcrest.CoreMatchers;
-import org.junit.Assert;
-import org.junit.Before;
 import org.junit.Test;
 
-import javax.management.Query;
-
-import static org.junit.Assert.*;
-
 public class JmxAttributeValidationExceptionTest {
 
-    private JmxAttribute jmxAttribute = new JmxAttribute("attr1");
+    private final JmxAttribute jmxAttribute = new JmxAttribute("attr1");
 
     @Test
     public void testJmxAttributeValidationExceptionElement() throws Exception {
@@ -28,7 +23,7 @@ public class JmxAttributeValidationExceptionTest {
 
     @Test
     public void testJmxAttributeValidationExceptionList() throws Exception {
-        List attributeNames = new ArrayList<JmxAttribute>();
+        List<JmxAttribute> attributeNames = new ArrayList<>();
         attributeNames.add(new JmxAttribute("att1"));
         attributeNames.add(new JmxAttribute("att2"));
         attributeNames.add(new JmxAttribute("att3"));
@@ -38,7 +33,7 @@ public class JmxAttributeValidationExceptionTest {
 
     @Test
     public void testJmxAttributeValidationExceptionList2() throws Exception {
-        List attributeNames = new ArrayList<JmxAttribute>();
+        List<JmxAttribute> attributeNames = new ArrayList<>();
         attributeNames.add(new JmxAttribute("att1"));
         attributeNames.add(new JmxAttribute("att2"));
         attributeNames.add(new JmxAttribute("att3"));
@@ -84,7 +79,7 @@ public class JmxAttributeValidationExceptionTest {
         JmxAttributeValidationException.checkCondition(false, "message", jmxAttribute);
     }
 
-    private void assertJmxEx(JmxAttributeValidationException e, String message, JmxAttribute... attrNames) {
+    private void assertJmxEx(final JmxAttributeValidationException e, final String message, final JmxAttribute... attrNames) {
         assertEquals(message, e.getMessage());
         assertEquals(Lists.newArrayList(attrNames), e.getAttributeNames());
     }
index c0e584a0986009499b8dc6601c0f529318b95ee3..2771b407f46725461088d99e9e1a1d1c8dd7a82e 100644 (file)
@@ -1,11 +1,8 @@
 package org.opendaylight.controller.config.api;
 
-import junit.framework.Assert;
-import org.junit.Test;
-
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotEquals;
+import org.junit.Test;
 
 public class ModuleIdentifierTest {
     String fact = new String("factory");
index 30712c966dfdb1c5b61109f043ce552039b1d084..8b4f2fe25875149bae70d0d80157961549939c80 100644 (file)
@@ -1,23 +1,20 @@
 package org.opendaylight.controller.config.api;
 
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertTrue;
-import static junit.framework.Assert.fail;
-import static org.junit.Assert.assertNotEquals;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertThat;
-import static org.junit.matchers.JUnitMatchers.containsString;
-
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 import com.google.common.collect.Lists;
 import java.util.Map;
-
 import org.junit.Assert;
 import org.junit.Test;
 
 public class ValidationExceptionTest {
 
-    private String instance = "instance";
+    private final String instance = "instance";
     private final ModuleIdentifier mi = new ModuleIdentifier("module", instance);
-    private String instance2 = "instance2";
+    private final String instance2 = "instance2";
     private final ModuleIdentifier mi2 = new ModuleIdentifier("module", instance2);
     private final String message = "ex message";
     private final Exception e = new IllegalStateException(message);
index 36ebc9de9358b34473b9dc6feadda7cca35ff972..cb8271a581781ae94ac90ac577255128e6db4f1a 100644 (file)
@@ -1,17 +1,16 @@
 package org.opendaylight.controller.config.api.jmx;
 
+import java.util.ArrayList;
+import java.util.List;
+import javax.management.ObjectName;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 
-import javax.management.ObjectName;
-import java.util.ArrayList;
-import java.util.List;
-
 public class CommitStatusTest {
-    List newInst = new ArrayList<ObjectName>();
-    List reusedInst = new ArrayList<ObjectName>();
-    List recreatedInst = new ArrayList<ObjectName>();
+    List<ObjectName> newInst = new ArrayList<>();
+    List<ObjectName> reusedInst = new ArrayList<>();
+    List<ObjectName> recreatedInst = new ArrayList<>();
 
     @Before
     public void setUp() throws Exception {
@@ -43,9 +42,9 @@ public class CommitStatusTest {
 
     @Test
     public void testNotEqual() throws Exception {
-        List newInst2 = new ArrayList<ObjectName>();
-        List reusedInst2 = new ArrayList<ObjectName>();
-        List recreatedInst2 = new ArrayList<ObjectName>();
+        List<ObjectName> newInst2 = new ArrayList<>();
+        List<ObjectName> reusedInst2 = new ArrayList<>();
+        List<ObjectName> recreatedInst2 = new ArrayList<>();
 
         newInst2.add(new ObjectName("first: key1 = value1"));
         reusedInst2.add(new ObjectName("second: key = val"));
index 02c1c4b9815ff55843e1abb74e99b0b529d48349..e69ff921ccc4975994d8c542a738d84f33f96c34 100644 (file)
@@ -7,18 +7,15 @@
  */
 package org.opendaylight.controller.config.api.jmx;
 
-import static junit.framework.Assert.fail;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
-
+import static org.junit.Assert.fail;
 import com.google.common.base.Throwables;
 import com.google.common.collect.Maps;
-
 import java.util.HashMap;
 import java.util.Map;
 import javax.management.ObjectName;
-import junit.framework.Assert;
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.controller.config.api.ModuleIdentifier;
@@ -84,7 +81,7 @@ public class ObjectNameUtilTest {
         assertPattern(on, pattern);
     }
 
-    private void assertPattern(ObjectName test, ObjectName pattern) {
+    private void assertPattern(final ObjectName test, final ObjectName pattern) {
         assertTrue(pattern.isPattern());
         assertTrue(pattern.apply(test));
     }
@@ -150,11 +147,11 @@ public class ObjectNameUtilTest {
         }, IllegalArgumentException.class);
     }
 
-    private void assertFailure(Runnable test, Class<? extends Exception> ex) {
+    private void assertFailure(final Runnable test, final Class<? extends Exception> ex) {
         try {
             test.run();
         } catch(Exception e) {
-            Assert.assertTrue("Failed with wrong exception: " + Throwables.getStackTraceAsString(e),
+            assertTrue("Failed with wrong exception: " + Throwables.getStackTraceAsString(e),
                     e.getClass().isAssignableFrom(ex));
             return;
         }
diff --git a/opendaylight/config/config-artifacts/pom.xml b/opendaylight/config/config-artifacts/pom.xml
new file mode 100644 (file)
index 0000000..430d6b4
--- /dev/null
@@ -0,0 +1,224 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
+<!--
+    Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v1.0 which accompanies this distribution,
+    and is available at http://www.eclipse.org/legal/epl-v10.html
+ -->
+<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>
+    <groupId>org.opendaylight.controller</groupId>
+    <artifactId>config-artifacts</artifactId>
+    <version>0.3.0-SNAPSHOT</version>
+    <packaging>pom</packaging>
+
+    <dependencyManagement>
+        <dependencies>
+            <dependency>
+                <groupId>${project.groupId}</groupId>
+                <artifactId>config-api</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>${project.groupId}</groupId>
+                <artifactId>config-manager</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>${project.groupId}</groupId>
+                <artifactId>config-manager</artifactId>
+                <version>${project.version}</version>
+                <type>test-jar</type>
+                <scope>test</scope>
+            </dependency>
+            <dependency>
+                <groupId>${project.groupId}</groupId>
+                <artifactId>config-module-archetype</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>${project.groupId}</groupId>
+                <artifactId>config-netty-config</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>${project.groupId}</groupId>
+                <artifactId>config-persister-api</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>${project.groupId}</groupId>
+                <artifactId>config-persister-api</artifactId>
+                <version>${project.version}</version>
+                <type>test-jar</type>
+                <scope>test</scope>
+            </dependency>
+            <dependency>
+                <groupId>${project.groupId}</groupId>
+                <artifactId>config-persister-directory-adapter</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>${project.groupId}</groupId>
+                <artifactId>config-persister-directory-autodetect-adapter</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>${project.groupId}</groupId>
+                <artifactId>config-persister-directory-xml-adapter</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>${project.groupId}</groupId>
+                <artifactId>config-persister-feature-adapter</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>${project.groupId}</groupId>
+                <artifactId>config-persister-file-adapter</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>${project.groupId}</groupId>
+                <artifactId>config-persister-file-xml-adapter</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>${project.groupId}</groupId>
+                <artifactId>config-plugin-parent</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>${project.groupId}</groupId>
+                <artifactId>config-util</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>${project.groupId}</groupId>
+                <artifactId>config-util</artifactId>
+                <version>${project.version}</version>
+                <type>test-jar</type>
+                <scope>test</scope>
+            </dependency>
+            <dependency>
+                <groupId>${project.groupId}</groupId>
+                <artifactId>logback-config</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>${project.groupId}</groupId>
+                <artifactId>logback-config-loader</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>${project.groupId}</groupId>
+                <artifactId>netty-config-api</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>${project.groupId}</groupId>
+                <artifactId>netty-event-executor-config</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>${project.groupId}</groupId>
+                <artifactId>netty-threadgroup-config</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>${project.groupId}</groupId>
+                <artifactId>netty-timer-config</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>${project.groupId}</groupId>
+                <artifactId>shutdown-api</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>${project.groupId}</groupId>
+                <artifactId>shutdown-impl</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>${project.groupId}</groupId>
+                <artifactId>threadpool-config-api</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>${project.groupId}</groupId>
+                <artifactId>threadpool-config-impl</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>${project.groupId}</groupId>
+                <artifactId>yang-jmx-generator</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>${project.groupId}</groupId>
+                <artifactId>yang-jmx-generator</artifactId>
+                <version>${project.version}</version>
+                <type>test-jar</type>
+                <scope>test</scope>
+            </dependency>
+            <dependency>
+                <groupId>${project.groupId}</groupId>
+                <artifactId>yang-jmx-generator-plugin</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>${project.groupId}</groupId>
+                <artifactId>yang-store-api</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>${project.groupId}</groupId>
+                <artifactId>yang-store-impl</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>${project.groupId}</groupId>
+                <artifactId>yang-test</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+
+            <dependency>
+                <groupId>${project.groupId}</groupId>
+                <artifactId>features-config</artifactId>
+                <version>${project.version}</version>
+                <classifier>features</classifier>
+                <type>xml</type>
+                <scope>runtime</scope>
+            </dependency>
+            <dependency>
+                <groupId>${project.groupId}</groupId>
+                <artifactId>features-config-netty</artifactId>
+                <version>${project.version}</version>
+                <classifier>features</classifier>
+                <type>xml</type>
+                <scope>runtime</scope>
+            </dependency>
+            <dependency>
+                <groupId>${project.groupId}</groupId>
+                <artifactId>features-config-persister</artifactId>
+                <version>${project.version}</version>
+                <classifier>features</classifier>
+                <type>xml</type>
+                <scope>runtime</scope>
+            </dependency>
+            <dependency>
+                <groupId>${project.groupId}</groupId>
+                <artifactId>config-netty-features</artifactId>
+                <version>${project.version}</version>
+                <classifier>features</classifier>
+                <type>xml</type>
+                <scope>runtime</scope>
+            </dependency>
+        </dependencies>
+    </dependencyManagement>
+</project>
+
index 4d94c6d2655650ece2f9bcb1a26a3e0b872a7d60..5cb1513d9cfa037448d24937e30dfe0ac9bc5a95 100644 (file)
@@ -7,17 +7,16 @@
  */
 package org.opendaylight.controller.config.manager.impl.util;
 
-import org.opendaylight.controller.config.api.annotations.AbstractServiceInterface;
-import org.opendaylight.controller.config.api.annotations.ServiceInterfaceAnnotation;
-import org.opendaylight.controller.config.spi.Module;
-import org.opendaylight.controller.config.spi.ModuleFactory;
-
-import javax.management.JMX;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Set;
+import javax.management.JMX;
+import org.opendaylight.controller.config.api.annotations.AbstractServiceInterface;
+import org.opendaylight.controller.config.api.annotations.ServiceInterfaceAnnotation;
+import org.opendaylight.controller.config.spi.Module;
+import org.opendaylight.controller.config.spi.ModuleFactory;
 
 public class InterfacesHelper {
 
@@ -40,7 +39,7 @@ public class InterfacesHelper {
 
     }
 
-    private static Set<Class<?>> getAllSuperInterfaces(Set<Class<?>> ifcs) {
+    private static Set<Class<?>> getAllSuperInterfaces(final Set<? extends Class<?>> ifcs) {
         Set<Class<?>> interfaces = new HashSet<>(ifcs); // create copy to modify
         // each interface can extend other interfaces
         Set<Class<?>> result = new HashSet<>();
@@ -61,7 +60,7 @@ public class InterfacesHelper {
      * Get interfaces that this class is derived from that are JMX interfaces.
      */
     public static Set<Class<?>> getMXInterfaces(
-            Class<? extends Module> configBeanClass) {
+            final Class<? extends Module> configBeanClass) {
         Set<Class<?>> allInterfaces = getAllInterfaces(configBeanClass);
         Set<Class<?>> result = new HashSet<>();
         for (Class<?> clazz : allInterfaces) {
@@ -78,7 +77,7 @@ public class InterfacesHelper {
      * annotation.
      */
     public static Set<Class<?>> getServiceInterfaces(
-            Class<? extends Module> configBeanClass) {
+            final Class<? extends Module> configBeanClass) {
         Set<Class<?>> allInterfaces = getAllInterfaces(configBeanClass);
         Set<Class<?>> result = new HashSet<>();
         for (Class<?> clazz : allInterfaces) {
@@ -93,7 +92,7 @@ public class InterfacesHelper {
         return result;
     }
 
-    public static Set<Class<? extends AbstractServiceInterface>> getAllAbstractServiceClasses(Class<? extends Module> configBeanClass) {
+    public static Set<Class<? extends AbstractServiceInterface>> getAllAbstractServiceClasses(final Class<? extends Module> configBeanClass) {
 
         Set<Class<? extends AbstractServiceInterface>> foundGeneratedSIClasses = new HashSet<>();
         for (Class<?> clazz : getAllInterfaces(configBeanClass)) {
@@ -111,7 +110,7 @@ public class InterfacesHelper {
      * {@link org.opendaylight.controller.config.api.annotations.ServiceInterfaceAnnotation#osgiRegistrationType()}
      */
     public static Set<Class<?>> getOsgiRegistrationTypes(
-            Class<? extends Module> configBeanClass) {
+            final Class<? extends Module> configBeanClass) {
         Set<Class<?>> serviceInterfaces = getServiceInterfaces(configBeanClass);
         Set<Class<?>> result = new HashSet<>();
         for (Class<?> clazz : serviceInterfaces) {
@@ -122,7 +121,7 @@ public class InterfacesHelper {
         return result;
     }
 
-    public static Set<String> getQNames(Set<ServiceInterfaceAnnotation> siAnnotations) {
+    public static Set<String> getQNames(final Set<ServiceInterfaceAnnotation> siAnnotations) {
         Set<String> qNames = new HashSet<>();
         for (ServiceInterfaceAnnotation sia: siAnnotations) {
             qNames.add(sia.value());
@@ -130,12 +129,12 @@ public class InterfacesHelper {
         return Collections.unmodifiableSet(qNames);
     }
 
-    public static Set<ServiceInterfaceAnnotation> getServiceInterfaceAnnotations(ModuleFactory factory) {
+    public static Set<ServiceInterfaceAnnotation> getServiceInterfaceAnnotations(final ModuleFactory factory) {
         Set<Class<? extends AbstractServiceInterface>> implementedServiceIntefaces = Collections.unmodifiableSet(factory.getImplementedServiceIntefaces());
         return getServiceInterfaceAnnotations(implementedServiceIntefaces);
     }
 
-    private static Set<ServiceInterfaceAnnotation> getServiceInterfaceAnnotations(Set<Class<? extends AbstractServiceInterface>> implementedServiceIntefaces) {
+    private static Set<ServiceInterfaceAnnotation> getServiceInterfaceAnnotations(final Set<Class<? extends AbstractServiceInterface>> implementedServiceIntefaces) {
         Set<Class<? extends AbstractServiceInterface>> inspected = getAllAbstractServiceInterfaceClasses(implementedServiceIntefaces);
         Set<ServiceInterfaceAnnotation> result = new HashSet<>();
         // SIs can form hierarchies, inspect superclass until it does not extend AbstractSI
@@ -149,9 +148,9 @@ public class InterfacesHelper {
     }
 
     static Set<Class<? extends AbstractServiceInterface>> getAllAbstractServiceInterfaceClasses(
-            Set<Class<? extends AbstractServiceInterface>> directlyImplementedAbstractSIs) {
+            final Set<Class<? extends AbstractServiceInterface>> directlyImplementedAbstractSIs) {
 
-        Set<Class<?>> allInterfaces = getAllSuperInterfaces((Set) directlyImplementedAbstractSIs);
+        Set<Class<?>> allInterfaces = getAllSuperInterfaces(directlyImplementedAbstractSIs);
         Set<Class<? extends AbstractServiceInterface>> result = new HashSet<>();
         for(Class<?> ifc: allInterfaces){
             if (AbstractServiceInterface.class.isAssignableFrom(ifc) &&
index f839452dcadb8e1295e8a1669154ea51699af5f5..4f792e72b10ccb826acb99c3d4117b071bdeef84 100644 (file)
@@ -9,7 +9,6 @@
 package org.opendaylight.controller.config.manager.impl.util;
 
 import static com.google.common.base.Preconditions.checkNotNull;
-
 import java.util.ArrayList;
 import java.util.List;
 import java.util.ListIterator;
@@ -27,7 +26,7 @@ public class OsgiRegistrationUtil {
     }
 
     @SafeVarargs
-    public static <T> AutoCloseable registerService(BundleContext bundleContext, T service, Class<? super T> ... interfaces) {
+    public static <T> AutoCloseable registerService(final BundleContext bundleContext, final T service, final Class<? super T> ... interfaces) {
         checkNotNull(service);
         checkNotNull(interfaces);
         List<AutoCloseable> autoCloseableList = new ArrayList<>();
@@ -48,7 +47,7 @@ public class OsgiRegistrationUtil {
         };
     }
 
-    public static AutoCloseable wrap(final BundleTracker bundleTracker) {
+    public static AutoCloseable wrap(final BundleTracker<?> bundleTracker) {
         checkNotNull(bundleTracker);
         return new AutoCloseable() {
             @Override
index 48d7de0e82f200f0dae9a4480d5b317b8e0fe47b..83ee87ce0e4fefad73e46b78e236a0a45bc9b803 100644 (file)
@@ -100,10 +100,10 @@ public class DependencyResolverManagerTest extends AbstractLockedPlatformMBeanSe
 
         tested.put(moduleIdentifier,
         mockedModule(),
-         moduleFactory,
-         maybeOldInternalInfo,
-         transactionModuleJMXRegistration,
-         isDefaultBean, mock(BundleContext.class));
+        moduleFactory,
+        maybeOldInternalInfo,
+        transactionModuleJMXRegistration,
+        isDefaultBean, mock(BundleContext.class));
     }
 
     private static Module mockedModule() {
index 471c98a6769fdde5dffe3f9ddccd454ae9317bfa..8ceee0caf5596b798371436f0f81fc9c2294febc 100644 (file)
@@ -1,14 +1,13 @@
 package org.opendaylight.controller.config.manager.impl.osgi;
 
-import static junit.framework.Assert.assertNotNull;
-import static junit.framework.Assert.assertSame;
-import static junit.framework.Assert.fail;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.fail;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.doThrow;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
-
 import java.util.Collections;
 import javax.management.ObjectName;
 import org.junit.Before;
index dc3deddddc79dfa664232e5f540c74116844a181..44e6e9ab778fc89b063e176a13cdcfdd2ab71103 100644 (file)
@@ -1,13 +1,12 @@
 package org.opendaylight.controller.config.manager.impl.osgi;
 
-import static junit.framework.Assert.fail;
+import static org.hamcrest.CoreMatchers.containsString;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
-import static org.junit.matchers.JUnitMatchers.containsString;
+import static org.junit.Assert.fail;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
-
 import com.google.common.collect.Lists;
 import java.util.Map;
 import org.junit.Before;
@@ -24,8 +23,8 @@ public class BundleContextBackedModuleFactoriesResolverTest {
     @Mock
     private BundleContext bundleContext;
     private BundleContextBackedModuleFactoriesResolver resolver;
-    private ServiceReference s1;
-    private ServiceReference s2;
+    private ServiceReference<?> s1;
+    private ServiceReference<?> s2;
     private ModuleFactory f1;
     private ModuleFactory f2;
 
@@ -42,15 +41,15 @@ public class BundleContextBackedModuleFactoriesResolverTest {
         resolver = new BundleContextBackedModuleFactoriesResolver(bundleContext);
     }
 
-    private ModuleFactory getMockFactory(String name) {
+    private ModuleFactory getMockFactory(final String name) {
         ModuleFactory mock = mock(ModuleFactory.class);
         doReturn(name).when(mock).toString();
         doReturn(name).when(mock).getImplementationName();
         return mock;
     }
 
-    private ServiceReference getServiceRef() {
-        ServiceReference mock = mock(ServiceReference.class);
+    private ServiceReference<?> getServiceRef() {
+        ServiceReference<?> mock = mock(ServiceReference.class);
         doReturn("serviceRef").when(mock).toString();
         final Bundle bundle = mock(Bundle.class);
         doReturn(bundleContext).when(bundle).getBundleContext();
index 5b83412083c359b09c80b5c2caac7d78fec0a16f..25d770e6c9577b11d24651515fc3f432b87eae59 100644 (file)
@@ -1,8 +1,8 @@
 package org.opendaylight.controller.config.manager.impl.osgi;
 
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertNotNull;
-import static junit.framework.Assert.fail;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
 import static org.mockito.Matchers.any;
 import static org.mockito.Matchers.anyObject;
 import static org.mockito.Matchers.anyString;
@@ -11,10 +11,8 @@ import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.verifyZeroInteractions;
-
 import java.util.Dictionary;
 import java.util.Set;
-
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mock;
@@ -44,7 +42,7 @@ public class ModuleFactoryBundleTrackerTest {
     @Before
     public void setUp() throws Exception {
         MockitoAnnotations.initMocks(this);
-        doAnswer(new Answer() {
+        doAnswer(new Answer<Object>() {
             @Override
             public Object answer(final InvocationOnMock invocation) throws Throwable {
                 return getClass().getClassLoader().loadClass((String) invocation.getArguments()[0]);
@@ -141,7 +139,7 @@ public class ModuleFactoryBundleTrackerTest {
     }
 
     static class WrongConstructorTestingFactory extends TestingFactory {
-        WrongConstructorTestingFactory(String randomParam) {
+        WrongConstructorTestingFactory(final String randomParam) {
         }
     }
 
index 79391d4343a7d1a6dafa413c5fd18b1e93d8103e..9edb64ac6b8c83b594d85daad5cb3f2d48e6edd7 100644 (file)
@@ -1,5 +1,9 @@
 package org.opendaylight.controller.config.manager.impl.osgi;
 
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import java.util.Dictionary;
 import org.junit.Test;
 import org.mockito.Mockito;
 import org.opendaylight.controller.config.manager.impl.osgi.mapping.RefreshingSCPModuleInfoRegistry;
@@ -10,12 +14,6 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContextProvider;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceRegistration;
 
-import java.util.*;
-
-import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-
 public class RefreshingSCPModuleInfoRegistryTest {
     @Test
     public void testConstructor() throws Exception {
@@ -24,8 +22,7 @@ public class RefreshingSCPModuleInfoRegistryTest {
         doReturn("string").when(prov).toString();
 
         BundleContext ctxt = mock(BundleContext.class);
-        Dictionary dict = new Hashtable();
-        ServiceRegistration servReg = mock(ServiceRegistration.class);
+        ServiceRegistration<?> servReg = mock(ServiceRegistration.class);
         doReturn(servReg).when(ctxt).registerService(Mockito.any(Class.class), Mockito.any(SchemaContextProvider.class), Mockito.any(Dictionary.class));
         doReturn(servReg).when(ctxt).registerService(Mockito.anyString(), Mockito.any(Object.class), Mockito.any(Dictionary.class));
         RefreshingSCPModuleInfoRegistry scpreg = new RefreshingSCPModuleInfoRegistry(reg, prov, ctxt);
index 220bef03bc95eab1efbbe54122e7b42cb657927e..4be40a64f5a775e008e13ce592d9d7fdefb3eacb 100644 (file)
@@ -8,7 +8,7 @@
 package org.opendaylight.controller.config.manager.impl.util;
 
 import static org.junit.Assert.assertEquals;
-
+import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Sets;
 import java.util.Collections;
 import java.util.HashSet;
@@ -92,7 +92,7 @@ public class InterfacesHelperTest {
         input.add(clazz);
         Set<Class<? extends AbstractServiceInterface>> result = InterfacesHelper.getAllAbstractServiceInterfaceClasses(input);
 
-        Set<Class<?>> expected = Sets.newHashSet((Class<?>) TestingScheduledThreadPoolServiceInterface.class,
+        Set<Class<?>> expected = ImmutableSet.of((Class<?>) TestingScheduledThreadPoolServiceInterface.class,
                 TestingThreadPoolServiceInterface.class
                 );
         assertEquals(expected, result);
index fb59e3d51554d1f69d3bdc215478daf14a2d88e2..f1efc4787dfc3320fc1017c88f6819caf9f2ad5d 100644 (file)
@@ -4,7 +4,6 @@ import static org.mockito.Mockito.doNothing;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
-
 import org.junit.Test;
 import org.mockito.InOrder;
 import org.mockito.Mockito;
@@ -37,7 +36,7 @@ public class OsgiRegistrationUtilTest {
         OsgiRegistrationUtil.wrap(serviceReg).close();
         verify(serviceReg).unregister();
 
-        final BundleTracker tracker = mock(BundleTracker.class);
+        final BundleTracker<?> tracker = mock(BundleTracker.class);
         doNothing().when(tracker).close();
         OsgiRegistrationUtil.wrap(tracker).close();
         verify(tracker).close();
@@ -49,7 +48,7 @@ public class OsgiRegistrationUtilTest {
     }
 
     private ServiceRegistration<?> mockServiceRegistration() {
-        ServiceRegistration mock = mock(ServiceRegistration.class);
+        ServiceRegistration<?> mock = mock(ServiceRegistration.class);
         doNothing().when(mock).unregister();
         return mock;
     }
index e5306a4fa60272e23adac53af8f83f5454876b86..d34e73ec4723d8d1fa151b0dfe8f161ec6716b33 100644 (file)
@@ -7,7 +7,9 @@
  */
 package org.opendaylight.controller.config.manager.testingservices.scheduledthreadpool;
 
-import com.google.common.collect.Sets;
+import com.google.common.collect.ImmutableSet;
+import java.util.HashSet;
+import java.util.Set;
 import org.opendaylight.controller.config.api.DependencyResolver;
 import org.opendaylight.controller.config.api.DependencyResolverFactory;
 import org.opendaylight.controller.config.api.DynamicMBeanWithInstance;
@@ -19,20 +21,16 @@ import org.opendaylight.controller.config.spi.Module;
 import org.opendaylight.controller.config.spi.ModuleFactory;
 import org.osgi.framework.BundleContext;
 
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
 public class TestingScheduledThreadPoolModuleFactory implements ModuleFactory {
     public static final String NAME = "scheduled";
 
-    private static Set<Class<? extends AbstractServiceInterface>> ifc = Collections.unmodifiableSet(Sets.newHashSet(
+    private static Set<Class<? extends AbstractServiceInterface>> ifc = ImmutableSet.of(
             (Class<? extends AbstractServiceInterface>) TestingScheduledThreadPoolServiceInterface.class,
-                    TestingThreadPoolServiceInterface.class));
+                    TestingThreadPoolServiceInterface.class);
 
     @Override
     public boolean isModuleImplementingServiceInterface(
-            Class<? extends AbstractServiceInterface> serviceInterface) {
+            final Class<? extends AbstractServiceInterface> serviceInterface) {
         return ifc.contains(serviceInterface);
     }
 
@@ -42,15 +40,15 @@ public class TestingScheduledThreadPoolModuleFactory implements ModuleFactory {
     }
 
     @Override
-    public Module createModule(String instanceName,
-            DependencyResolver dependencyResolver, BundleContext bundleContext) {
+    public Module createModule(final String instanceName,
+            final DependencyResolver dependencyResolver, final BundleContext bundleContext) {
         return new TestingScheduledThreadPoolModule(new ModuleIdentifier(NAME,
                 instanceName), null, null);
     }
 
     @Override
-    public Module createModule(String instanceName,
-            DependencyResolver dependencyResolver, DynamicMBeanWithInstance old, BundleContext bundleContext)
+    public Module createModule(final String instanceName,
+            final DependencyResolver dependencyResolver, final DynamicMBeanWithInstance old, final BundleContext bundleContext)
             throws Exception {
         TestingScheduledThreadPoolImpl oldInstance;
         try {
@@ -68,7 +66,7 @@ public class TestingScheduledThreadPoolModuleFactory implements ModuleFactory {
     }
 
     @Override
-    public Set<Module> getDefaultModules(DependencyResolverFactory dependencyResolverFactory, BundleContext bundleContext) {
+    public Set<Module> getDefaultModules(final DependencyResolverFactory dependencyResolverFactory, final BundleContext bundleContext) {
         return new HashSet<Module>();
     }
 
index ca038f1f1caac171f77c7a3538172c70c7069ed9..9c8b575fe59a799ca13bd10dd3558a2270fa8596 100644 (file)
@@ -7,38 +7,35 @@
  */
 package org.opendaylight.controller.config.manager.testingservices.scheduledthreadpool.test;
 
+import static org.hamcrest.CoreMatchers.containsString;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
-import static org.junit.matchers.JUnitMatchers.containsString;
-
 import javax.annotation.Nullable;
 import javax.management.DynamicMBean;
 import javax.management.InstanceAlreadyExistsException;
 import javax.management.InstanceNotFoundException;
 import javax.management.ObjectName;
-
 import org.junit.Test;
 import org.opendaylight.controller.config.api.ValidationException;
 import org.opendaylight.controller.config.api.jmx.ObjectNameUtil;
 import org.opendaylight.controller.config.manager.testingservices.parallelapsp.TestingParallelAPSPConfigMXBean;
 import org.opendaylight.controller.config.manager.testingservices.parallelapsp.TestingParallelAPSPModuleFactory;
 import org.opendaylight.controller.config.manager.testingservices.scheduledthreadpool.TestingScheduledThreadPoolImpl;
-import org.opendaylight.controller.config.manager.testingservices.scheduledthreadpool
-        .TestingScheduledThreadPoolModuleFactory;
+import org.opendaylight.controller.config.manager.testingservices.scheduledthreadpool.TestingScheduledThreadPoolModuleFactory;
 import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
 
 public class TwoInterfacesExportTest extends AbstractScheduledTest {
 
-    private void assertExists(String moduleName, String instanceName)
+    private void assertExists(final String moduleName, final String instanceName)
             throws Exception {
         assertExists(null, moduleName, instanceName);
     }
 
-    private void assertExists(@Nullable ConfigTransactionJMXClient transaction,
-            String moduleName, String instanceName)
+    private void assertExists(@Nullable final ConfigTransactionJMXClient transaction,
+            final String moduleName, final String instanceName)
             throws InstanceNotFoundException {
         if (transaction != null) {
             transaction.lookupConfigBean(moduleName, instanceName);
@@ -56,13 +53,13 @@ public class TwoInterfacesExportTest extends AbstractScheduledTest {
         }
     }
 
-    private void assertNotExists(String moduleName, String instanceName) {
+    private void assertNotExists(final String moduleName, final String instanceName) {
         assertNotExists(null, moduleName, instanceName);
     }
 
     private void assertNotExists(
-            @Nullable ConfigTransactionJMXClient transaction,
-            String moduleName, String instanceName) {
+            @Nullable final ConfigTransactionJMXClient transaction,
+            final String moduleName, final String instanceName) {
 
         if (transaction != null) {
             try {
index bec28685576aba673422c32222acafc6aca34a23..d385a7db5a2d007bb6d4320f31d7247a4ecde1c1 100644 (file)
@@ -7,7 +7,9 @@
  */
 package org.opendaylight.controller.config.manager.testingservices.threadpool;
 
-import com.google.common.collect.Sets;
+import com.google.common.collect.ImmutableSet;
+import java.util.HashSet;
+import java.util.Set;
 import org.opendaylight.controller.config.api.DependencyResolver;
 import org.opendaylight.controller.config.api.DependencyResolverFactory;
 import org.opendaylight.controller.config.api.DynamicMBeanWithInstance;
@@ -19,16 +21,12 @@ import org.opendaylight.controller.config.spi.Module;
 import org.opendaylight.controller.config.spi.ModuleFactory;
 import org.osgi.framework.BundleContext;
 
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
 public class TestingFixedThreadPoolModuleFactory extends AbstractTestingFixedThreadPoolModuleFactory implements ModuleFactory {
     public static final String NAME = "fixed";
 
-    private static Set<Class<? extends AbstractServiceInterface>> ifc = Collections.unmodifiableSet(Sets.newHashSet(
+    private static final Set<Class<? extends AbstractServiceInterface>> ifc = ImmutableSet.of(
             (Class<? extends AbstractServiceInterface>) ModifiableThreadPoolServiceInterface.class,
-            TestingThreadPoolServiceInterface.class));
+            TestingThreadPoolServiceInterface.class);
 
     @Override
     public String getImplementationName() {
@@ -36,15 +34,15 @@ public class TestingFixedThreadPoolModuleFactory extends AbstractTestingFixedThr
     }
 
     @Override
-    public TestingFixedThreadPoolModule createModule(String instanceName,
-            DependencyResolver dependencyResolver, BundleContext bundleContext) {
+    public TestingFixedThreadPoolModule createModule(final String instanceName,
+            final DependencyResolver dependencyResolver, final BundleContext bundleContext) {
         return new TestingFixedThreadPoolModule(new ModuleIdentifier(NAME,
                 instanceName), null, null);
     }
 
     @Override
-    public Module createModule(String instanceName,
-            DependencyResolver dependencyResolver, DynamicMBeanWithInstance old, BundleContext bundleContext)
+    public Module createModule(final String instanceName,
+            final DependencyResolver dependencyResolver, final DynamicMBeanWithInstance old, final BundleContext bundleContext)
             throws Exception {
         int threadCount = (Integer) old.getAttribute("ThreadCount");
         // is the instance compatible?
@@ -65,12 +63,12 @@ public class TestingFixedThreadPoolModuleFactory extends AbstractTestingFixedThr
 
     @Override
     public boolean isModuleImplementingServiceInterface(
-            Class<? extends AbstractServiceInterface> serviceInterface) {
+            final Class<? extends AbstractServiceInterface> serviceInterface) {
         return ifc.contains(serviceInterface);
     }
 
     @Override
-    public Set<Module> getDefaultModules(DependencyResolverFactory dependencyResolverFactory, BundleContext bundleContext) {
+    public Set<Module> getDefaultModules(final DependencyResolverFactory dependencyResolverFactory, final BundleContext bundleContext) {
         return new HashSet<Module>();
     }
 
index 257c36779c9113a05dfe9fd20f82c8ddc288e84c..1e7a027b5b8a2f13a36111cbc22efa6386d1adfa 100644 (file)
@@ -1,4 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
 <!--
  Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
 
@@ -8,39 +9,39 @@
 -->
 <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>config-subsystem</artifactId>
-    <version>0.3.0-SNAPSHOT</version>
-  </parent>
-  <artifactId>config-netty-config</artifactId>
-  <description>Configuration files for sal-rest-connector</description>
-  <packaging>jar</packaging>
-  <build>
-       <plugins>
-               <plugin>
-        <groupId>org.codehaus.mojo</groupId>
-        <artifactId>build-helper-maven-plugin</artifactId>
-        <executions>
-          <execution>
-            <id>attach-artifacts</id>
-            <goals>
-              <goal>attach-artifact</goal>
-            </goals>
-            <phase>package</phase>
-            <configuration>
-              <artifacts>
-                <artifact>
-                  <file>${project.build.directory}/classes/initial/00-netty.xml</file>
-                  <type>xml</type>
-                  <classifier>config</classifier>
-                </artifact>
-              </artifacts>
-            </configuration>
-          </execution>
-        </executions>
-      </plugin>
-    </plugins>
-  </build>
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.opendaylight.controller</groupId>
+        <artifactId>config-subsystem</artifactId>
+        <version>0.3.0-SNAPSHOT</version>
+    </parent>
+    <artifactId>config-netty-config</artifactId>
+    <description>Configuration files for sal-rest-connector</description>
+    <packaging>jar</packaging>
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>build-helper-maven-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>attach-artifacts</id>
+                        <goals>
+                            <goal>attach-artifact</goal>
+                        </goals>
+                        <phase>package</phase>
+                        <configuration>
+                            <artifacts>
+                                <artifact>
+                                    <file>${project.build.directory}/classes/initial/00-netty.xml</file>
+                                    <type>xml</type>
+                                    <classifier>config</classifier>
+                                </artifact>
+                            </artifacts>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
 </project>
index 7f8ebd7fddf8e7ee93a665106040ef4c83c5fb96..92bf080662b1bc0ecc89e6427b5a0ad1cb8f63ce 100644 (file)
@@ -7,17 +7,9 @@
  */
 package org.opendaylight.controller.config.persist.storage.directory.xml;
 
+import static com.google.common.base.Preconditions.checkArgument;
 import com.google.common.base.Optional;
 import com.google.common.io.Files;
-import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder;
-import org.opendaylight.controller.config.persist.api.Persister;
-import org.opendaylight.controller.config.persist.storage.file.xml.model.ConfigSnapshot;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Unmarshaller;
 import java.io.File;
 import java.io.FilenameFilter;
 import java.io.IOException;
@@ -27,11 +19,17 @@ import java.util.Collections;
 import java.util.List;
 import java.util.Set;
 import java.util.SortedSet;
-
-import static com.google.common.base.Preconditions.checkArgument;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Unmarshaller;
+import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder;
+import org.opendaylight.controller.config.persist.api.Persister;
+import org.opendaylight.controller.config.persist.storage.file.xml.model.ConfigSnapshot;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class XmlDirectoryPersister implements Persister {
-    private static final Logger logger = LoggerFactory.getLogger(XmlDirectoryPersister.class);
+    private static final Logger LOG = LoggerFactory.getLogger(XmlDirectoryPersister.class);
 
     private final File storage;
     private final Optional<FilenameFilter> extensionsFilter;
@@ -39,25 +37,25 @@ public class XmlDirectoryPersister implements Persister {
     /**
      * Creates XmlDirectoryPersister that picks up all files in specified folder
      */
-    public XmlDirectoryPersister(File storage) {
+    public XmlDirectoryPersister(final File storage) {
         this(storage, Optional.<FilenameFilter>absent());
     }
 
     /**
      * Creates XmlDirectoryPersister that picks up files only with specified file extension
      */
-    public XmlDirectoryPersister(File storage, Set<String> fileExtensions) {
+    public XmlDirectoryPersister(final File storage, final Set<String> fileExtensions) {
         this(storage, Optional.of(getFilter(fileExtensions)));
     }
 
-    private XmlDirectoryPersister(File storage, Optional<FilenameFilter> extensionsFilter) {
+    private XmlDirectoryPersister(final File storage, final Optional<FilenameFilter> extensionsFilter) {
         checkArgument(storage.exists() && storage.isDirectory(), "Storage directory does not exist: " + storage);
         this.storage = storage;
         this.extensionsFilter = extensionsFilter;
     }
 
     @Override
-    public void persistConfig(ConfigSnapshotHolder holder) throws IOException {
+    public void persistConfig(final ConfigSnapshotHolder holder) throws IOException {
         throw new UnsupportedOperationException("This adapter is read only. Please set readonly=true on " + getClass());
     }
 
@@ -70,11 +68,11 @@ public class XmlDirectoryPersister implements Persister {
         List<File> sortedFiles = new ArrayList<>(Arrays.asList(filesArray));
         Collections.sort(sortedFiles);
         // combine all found files
-        logger.debug("Reading files in following order: {}", sortedFiles);
+        LOG.debug("Reading files in following order: {}", sortedFiles);
 
         List<ConfigSnapshotHolder> result = new ArrayList<>();
         for (File file : sortedFiles) {
-            logger.trace("Adding file '{}' to combined result", file);
+            LOG.trace("Adding file '{}' to combined result", file);
             Optional<ConfigSnapshotHolder> h = fromXmlSnapshot(file);
             // Ignore non valid snapshot
             if(h.isPresent() == false) {
@@ -86,12 +84,12 @@ public class XmlDirectoryPersister implements Persister {
         return result;
     }
 
-    private Optional<ConfigSnapshotHolder> fromXmlSnapshot(File file) {
+    private Optional<ConfigSnapshotHolder> fromXmlSnapshot(final File file) {
         try {
             return Optional.of(loadLastConfig(file));
         } catch (JAXBException e) {
             // In case of parse error, issue a warning, ignore and continue
-            logger.warn(
+            LOG.warn(
                     "Unable to parse configuration snapshot from {}. Initial config from {} will be IGNORED in this run. " +
                     "Note that subsequent config files may fail due to this problem. " +
                     "Xml markup in this file needs to be fixed, for detailed information see enclosed exception.",
@@ -101,7 +99,7 @@ public class XmlDirectoryPersister implements Persister {
         return Optional.absent();
     }
 
-    public static ConfigSnapshotHolder loadLastConfig(File file) throws JAXBException {
+    public static ConfigSnapshotHolder loadLastConfig(final File file) throws JAXBException {
         JAXBContext jaxbContext = JAXBContext.newInstance(ConfigSnapshot.class);
         Unmarshaller um = jaxbContext.createUnmarshaller();
 
@@ -132,7 +130,7 @@ public class XmlDirectoryPersister implements Persister {
 
         return new FilenameFilter() {
             @Override
-            public boolean accept(File dir, String name) {
+            public boolean accept(final File dir, final String name) {
                 String ext = Files.getFileExtension(name);
                 return fileExtensions.contains(ext);
             }
index 40f8c283ddd5a8e49ff7eb2c8464bddd65178a98..42ab93b585f32254269c8522584c8fe638ba5652 100644 (file)
@@ -11,21 +11,20 @@ package org.opendaylight.controller.config.persist.storage.directory.xml;
 import com.google.common.base.Preconditions;
 import com.google.common.base.Splitter;
 import com.google.common.collect.Sets;
+import java.io.File;
+import java.util.Set;
 import org.opendaylight.controller.config.persist.api.Persister;
 import org.opendaylight.controller.config.persist.api.PropertiesProvider;
 import org.opendaylight.controller.config.persist.api.StorageAdapter;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.io.File;
-import java.util.Set;
-
 /**
  * StorageAdapter that retrieves initial configuration from a directory. If multiple files are present, snapshot and
  * required capabilities will be merged together. Writing to this persister is not supported.
  */
 public class XmlDirectoryStorageAdapter implements StorageAdapter {
-    private static final Logger logger = LoggerFactory.getLogger(XmlDirectoryStorageAdapter.class);
+    private static final Logger LOG = LoggerFactory.getLogger(XmlDirectoryStorageAdapter.class);
 
     public static final String DIRECTORY_STORAGE_PROP = "directoryStorage";
     public static final String INCLUDE_EXT_PROP = "includeExtensions";
@@ -33,23 +32,23 @@ public class XmlDirectoryStorageAdapter implements StorageAdapter {
 
 
     @Override
-    public Persister instantiate(PropertiesProvider propertiesProvider) {
+    public Persister instantiate(final PropertiesProvider propertiesProvider) {
         String fileStorageProperty = propertiesProvider.getProperty(DIRECTORY_STORAGE_PROP);
         Preconditions.checkNotNull(fileStorageProperty, "Unable to find " + propertiesProvider.getFullKeyForReporting(DIRECTORY_STORAGE_PROP));
         File storage  = new File(fileStorageProperty);
         String fileExtensions = propertiesProvider.getProperty(INCLUDE_EXT_PROP);
 
-        logger.debug("Using storage: {}", storage);
+        LOG.debug("Using storage: {}", storage);
 
         if(fileExtensions != null) {
-            logger.debug("Using extensions: {}", fileExtensions);
+            LOG.debug("Using extensions: {}", fileExtensions);
             return new XmlDirectoryPersister(storage, splitExtensions(fileExtensions));
         } else {
             return new XmlDirectoryPersister(storage);
         }
     }
 
-    private Set<String> splitExtensions(String fileExtensions) {
+    private Set<String> splitExtensions(final String fileExtensions) {
         return Sets.newHashSet(Splitter.on(EXTENSIONS_SEPARATOR).trimResults().omitEmptyStrings()
                 .split(fileExtensions));
     }
index 7af06bd3e39cdd341e917779961150b21af4a6f9..11c7e1253a18226a374b5c079130adcc23db92c6 100644 (file)
@@ -12,13 +12,12 @@ import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
-
+import com.google.common.base.Optional;
 import java.io.File;
 import java.io.IOException;
 import java.util.Collections;
 import java.util.List;
 import java.util.SortedSet;
-
 import org.junit.Test;
 import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder;
 import org.opendaylight.controller.config.persist.api.Persister;
@@ -27,13 +26,11 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.xml.sax.SAXException;
 
-import com.google.common.base.Optional;
-
 public class DirectoryStorageAdapterTest {
+    private static final Logger LOG = LoggerFactory.getLogger(DirectoryStorageAdapterTest.class);
     Persister tested;
-    Logger logger = LoggerFactory.getLogger(DirectoryStorageAdapterTest.class.toString());
 
-    private Persister instantiatePersisterFromAdapter(File file, Optional<String> extensions){
+    private Persister instantiatePersisterFromAdapter(final File file, final Optional<String> extensions){
         PropertiesProviderTest pp = new PropertiesProviderTest();
         pp.addProperty(XmlDirectoryStorageAdapter.DIRECTORY_STORAGE_PROP,file.getPath());
         if(extensions.isPresent()) {
@@ -44,7 +41,7 @@ public class DirectoryStorageAdapterTest {
         return dsa.instantiate(pp);
     }
 
-    private Persister instantiatePersisterFromAdapter(File file){
+    private Persister instantiatePersisterFromAdapter(final File file){
         return instantiatePersisterFromAdapter(file, Optional.<String>absent());
     }
 
@@ -74,7 +71,7 @@ public class DirectoryStorageAdapterTest {
         }
     }
 
-    private File getFolder(String folderName) {
+    private File getFolder(final String folderName) {
         File result = new File(("src/test/resources/" +
                 folderName).replace("/", File.separator));
         assertTrue(result + " is not a directory", result.isDirectory());
@@ -86,7 +83,7 @@ public class DirectoryStorageAdapterTest {
         File folder = getFolder("oneFile");
         tested = instantiatePersisterFromAdapter(folder, Optional.of("xml"));
 
-        logger.info("Testing : " + tested.toString());
+        LOG.info("Testing : {}", tested);
         List<ConfigSnapshotHolder> results = tested.loadLastConfigs();
         assertEquals(1, results.size());
         ConfigSnapshotHolder result = results.get(0);
@@ -97,10 +94,10 @@ public class DirectoryStorageAdapterTest {
     public void testOneFileWrongExtension() throws Exception {
         File folder = getFolder("oneFile");
         tested = instantiatePersisterFromAdapter(folder, Optional.of("aa, bb"));
-        logger.info("Testing : " + tested.toString());
+        LOG.info("Testing : {}", tested);
     }
 
-    private void assertResult(ConfigSnapshotHolder result, String s, String... caps) throws SAXException, IOException {
+    private void assertResult(final ConfigSnapshotHolder result, final String s, final String... caps) throws SAXException, IOException {
         assertXMLEqual(s, result.getConfigSnapshot());
         int i = 0;
         for (String capFromSnapshot : result.getCapabilities()) {
@@ -112,7 +109,7 @@ public class DirectoryStorageAdapterTest {
     public void testTwoFilesAllExtensions() throws Exception {
         File folder = getFolder("twoFiles");
         tested = instantiatePersisterFromAdapter(folder);
-        logger.info("Testing : " + tested.toString());
+        LOG.info("Testing : {}", tested);
         List<ConfigSnapshotHolder> results = tested.loadLastConfigs();
         assertEquals(2, results.size());
 
@@ -124,7 +121,7 @@ public class DirectoryStorageAdapterTest {
     public void testTwoFilesTwoExtensions() throws Exception {
         File folder = getFolder("twoFiles");
         tested = instantiatePersisterFromAdapter(folder, Optional.of("xml, xml2"));
-        logger.info("Testing : " + tested.toString());
+        LOG.info("Testing : {}", tested);
         assertEquals(2, tested.loadLastConfigs().size());
     }
 
@@ -132,7 +129,7 @@ public class DirectoryStorageAdapterTest {
     public void testTwoFilesOnlyOneExtension() throws Exception {
         File folder = getFolder("twoFiles");
         tested = instantiatePersisterFromAdapter(folder, Optional.of("xml"));
-        logger.info("Testing : " + tested.toString());
+        LOG.info("Testing : ", tested);
         List<ConfigSnapshotHolder> results = tested.loadLastConfigs();
         assertEquals(1, results.size());
 
@@ -143,7 +140,7 @@ public class DirectoryStorageAdapterTest {
     public void testTwoFilesOneInvalid() throws Exception {
         File folder = getFolder("twoFiles_corrupt");
         tested = instantiatePersisterFromAdapter(folder, Optional.of("xml"));
-        logger.info("Testing : " + tested.toString());
+        LOG.info("Testing : {}", tested);
         List<ConfigSnapshotHolder> results = tested.loadLastConfigs();
         assertEquals(1, results.size());
 
index abb1dbe9aa060617fc5ac638cb0439a087b2a3a2..52bca765553420113c1db83efa1946351c4c9e04 100644 (file)
@@ -17,14 +17,14 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class ConfigPusherCustomizer implements ServiceTrackerCustomizer<ConfigPusher, ConfigPusher>, AutoCloseable {
-    private static final Logger LOGGER = LoggerFactory.getLogger(ConfigPusherCustomizer.class);
+    private static final Logger LOG = LoggerFactory.getLogger(ConfigPusherCustomizer.class);
     private ConfigFeaturesListener configFeaturesListener = null;
     private FeatureServiceCustomizer featureServiceCustomizer = null;
     private ServiceTracker<FeaturesService,FeaturesService> fsst = null;
 
     @Override
     public ConfigPusher addingService(ServiceReference<ConfigPusher> configPusherServiceReference) {
-        LOGGER.trace("Got ConfigPusherCustomizer.addingService {}", configPusherServiceReference);
+        LOG.trace("Got ConfigPusherCustomizer.addingService {}", configPusherServiceReference);
         BundleContext bc = configPusherServiceReference.getBundle().getBundleContext();
         ConfigPusher cpService = bc.getService(configPusherServiceReference);
         featureServiceCustomizer = new FeatureServiceCustomizer(cpService);
index b0e64b84d2adf4433fd378b8fca5d35eb97c4e19..1a40bb34d7b6fe1a8c296654dd1d6a448ae30421 100644 (file)
@@ -40,14 +40,14 @@ public class ConfigPushingRunnable implements Runnable {
         while(true) {
             try {
                 if(!interuppted) {
-                        if(toInstall.isEmpty()) {
-                            event = queue.take();
-                        } else {
-                            event = queue.poll(POLL_TIME, TimeUnit.MILLISECONDS);
-                        }
-                        if(event != null && event.getFeature() !=null) {
-                            processFeatureEvent(event,toInstall);
-                        }
+                    if(toInstall.isEmpty()) {
+                        event = queue.take();
+                    } else {
+                        event = queue.poll(POLL_TIME, TimeUnit.MILLISECONDS);
+                    }
+                    if(event != null && event.getFeature() !=null) {
+                        processFeatureEvent(event,toInstall);
+                    }
                 } else if(toInstall.isEmpty()) {
                     LOGGER.error("ConfigPushingRunnable - exiting");
                     return;
index 5c5061277b62f28c98e163f17c7fc1c721a91cd9..7b90580a660cac0a03a4b90c0c0f8d40a1d2eb68 100644 (file)
@@ -7,11 +7,11 @@
  */
 package org.opendaylight.controller.configpusherfeature.internal;
 
+import com.google.common.collect.LinkedHashMultimap;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.LinkedHashSet;
 import java.util.List;
-
 import org.apache.karaf.features.Feature;
 import org.apache.karaf.features.FeaturesService;
 import org.opendaylight.controller.config.persist.api.ConfigPusher;
@@ -19,13 +19,11 @@ import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.collect.LinkedHashMultimap;
-
 /*
  * Simple class to push configs to the config subsystem from Feature's configfiles
  */
 public class FeatureConfigPusher {
-    private static final Logger LOGGER = LoggerFactory.getLogger(FeatureConfigPusher.class);
+    private static final Logger LOG = LoggerFactory.getLogger(FeatureConfigPusher.class);
     private static final int MAX_RETRIES=100;
     private static final int RETRY_PAUSE_MILLIS=1;
     private FeaturesService featuresService = null;
@@ -46,7 +44,7 @@ public class FeatureConfigPusher {
     /*
      * @param p - ConfigPusher to push ConfigSnapshotHolders
      */
-    public FeatureConfigPusher(ConfigPusher p, FeaturesService f) {
+    public FeatureConfigPusher(final ConfigPusher p, final FeaturesService f) {
         pusher = p;
         featuresService = f;
     }
@@ -59,7 +57,7 @@ public class FeatureConfigPusher {
      * If a Feature is not in the returned LinkedHashMultimap then we couldn't push its configs
      * (Ususally because it was not yet installed)
      */
-    public LinkedHashMultimap<Feature,FeatureConfigSnapshotHolder> pushConfigs(List<Feature> features) throws Exception, InterruptedException {
+    public LinkedHashMultimap<Feature,FeatureConfigSnapshotHolder> pushConfigs(final List<Feature> features) throws Exception, InterruptedException {
         LinkedHashMultimap<Feature,FeatureConfigSnapshotHolder> pushedFeatures = LinkedHashMultimap.create();
         for(Feature feature: features) {
             LinkedHashSet<FeatureConfigSnapshotHolder> configSnapShots = pushConfig(feature);
@@ -70,7 +68,7 @@ public class FeatureConfigPusher {
         return pushedFeatures;
     }
 
-    private LinkedHashSet<FeatureConfigSnapshotHolder> pushConfig(Feature feature) throws Exception, InterruptedException {
+    private LinkedHashSet<FeatureConfigSnapshotHolder> pushConfig(final Feature feature) throws Exception, InterruptedException {
         LinkedHashSet<FeatureConfigSnapshotHolder> configs = new LinkedHashSet<FeatureConfigSnapshotHolder>();
         if(isInstalled(feature)) {
             ChildAwareFeatureWrapper wrappedFeature = new ChildAwareFeatureWrapper(feature,featuresService);
@@ -83,20 +81,20 @@ public class FeatureConfigPusher {
         return configs;
     }
 
-    private boolean isInstalled(Feature feature) {
+    private boolean isInstalled(final Feature feature) {
         for(int retries=0;retries<MAX_RETRIES;retries++) {
             try {
                 List<Feature> installedFeatures = Arrays.asList(featuresService.listInstalledFeatures());
                 if(installedFeatures.contains(feature)) {
                     return true;
                 } else {
-                    LOGGER.warn("Karaf featuresService.listInstalledFeatures() has not yet finished installing feature (retry {}) {} {}",retries,feature.getName(),feature.getVersion());
+                    LOG.warn("Karaf featuresService.listInstalledFeatures() has not yet finished installing feature (retry {}) {} {}",retries,feature.getName(),feature.getVersion());
                 }
             } catch (Exception e) {
                 if(retries < MAX_RETRIES) {
-                    LOGGER.warn("Karaf featuresService.listInstalledFeatures() has thrown an exception, retry {}, Exception {}", retries,e);
+                    LOG.warn("Karaf featuresService.listInstalledFeatures() has thrown an exception, retry {}", retries, e);
                 } else {
-                    LOGGER.error("Giving up on Karaf featuresService.listInstalledFeatures() which has thrown an exception, retry {}, Exception {}", retries,e);
+                    LOG.error("Giving up on Karaf featuresService.listInstalledFeatures() which has thrown an exception, retry {}", retries, e);
                     throw e;
                 }
             }
@@ -106,11 +104,11 @@ public class FeatureConfigPusher {
                 throw new IllegalStateException(e1);
             }
         }
-        LOGGER.error("Giving up (after {} retries) on Karaf featuresService.listInstalledFeatures() which has not yet finished installing feature {} {}",MAX_RETRIES,feature.getName(),feature.getVersion());
+        LOG.error("Giving up (after {} retries) on Karaf featuresService.listInstalledFeatures() which has not yet finished installing feature {} {}",MAX_RETRIES,feature.getName(),feature.getVersion());
         return false;
     }
 
-    private LinkedHashSet<FeatureConfigSnapshotHolder> pushConfig(LinkedHashSet<FeatureConfigSnapshotHolder> configs) throws InterruptedException {
+    private LinkedHashSet<FeatureConfigSnapshotHolder> pushConfig(final LinkedHashSet<FeatureConfigSnapshotHolder> configs) throws InterruptedException {
         LinkedHashSet<FeatureConfigSnapshotHolder> configsToPush = new LinkedHashSet<FeatureConfigSnapshotHolder>(configs);
         configsToPush.removeAll(pushedConfigs);
         if(!configsToPush.isEmpty()) {
index d1a92ebe7f72ac0785268af77104d5bebb1c6fb8..5ab5c959f7fcd02d7742866fc35e3a37d6bf3152 100644 (file)
@@ -106,16 +106,15 @@ public class FeatureConfigSnapshotHolder implements ConfigSnapshotHolder {
 
     @Override
     public String toString() {
-       StringBuilder b = new StringBuilder();
-       Path p = Paths.get(fileInfo.getFinalname());
-       b.append(p.getFileName())
-           .append("(")
-           .append(getCauseFeature())
-           .append(",")
-           .append(getFeature())
-           .append(")");
-       return b.toString();
-
+        StringBuilder b = new StringBuilder();
+        Path p = Paths.get(fileInfo.getFinalname());
+        b.append(p.getFileName())
+            .append("(")
+            .append(getCauseFeature())
+            .append(",")
+            .append(getFeature())
+            .append(")");
+        return b.toString();
     }
 
     @Override
index 2bfe70adb811d2c5575663540e4a194179f78dae..942ba4c4b3683f2590705b838c6fdf689fc26a76 100644 (file)
@@ -8,12 +8,12 @@
 
 package org.opendaylight.controller.config.persist.storage.file.xml;
 
-import static junit.framework.Assert.assertFalse;
+import static org.junit.Assert.assertFalse;
 import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
 import static org.hamcrest.CoreMatchers.is;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertThat;
-
+import com.google.common.base.Charsets;
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.IOException;
@@ -21,17 +21,12 @@ import java.nio.file.Files;
 import java.util.List;
 import java.util.SortedSet;
 import java.util.TreeSet;
-
-import junit.framework.Assert;
-
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mockito;
 import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder;
 import org.opendaylight.controller.config.persist.test.PropertiesProviderTest;
 
-import com.google.common.base.Charsets;
-
 public class FileStorageAdapterTest {
 
     private static int i;
@@ -42,8 +37,9 @@ public class FileStorageAdapterTest {
     @Before
     public void setUp() throws Exception {
         file = Files.createTempFile("testFilePersist", ".txt").toFile();
-        if (!file.exists())
+        if (!file.exists()) {
             return;
+        }
         com.google.common.io.Files.write("", file, Charsets.UTF_8);
         i = 1;
     }
@@ -71,7 +67,7 @@ public class FileStorageAdapterTest {
 
         storage.persistConfig(holder);
 
-        Assert.assertEquals(storage.toString().replace("\\","/"),"XmlFileStorageAdapter [storage="+NON_EXISTENT_DIRECTORY+NON_EXISTENT_FILE+"]");
+        assertEquals(storage.toString().replace("\\","/"),"XmlFileStorageAdapter [storage="+NON_EXISTENT_DIRECTORY+NON_EXISTENT_FILE+"]");
         delete(new File(NON_EXISTENT_DIRECTORY));
     }
     @Test
@@ -109,7 +105,7 @@ public class FileStorageAdapterTest {
         storage.setNumberOfBackups(Integer.MAX_VALUE);
 
         List<ConfigSnapshotHolder> last = storage.loadLastConfigs();
-        Assert.assertEquals(createCaps(), last.get(0).getCapabilities());
+        assertEquals(createCaps(), last.get(0).getCapabilities());
     }
 
     private SortedSet<String> createCaps() {
@@ -188,8 +184,9 @@ public class FileStorageAdapterTest {
     @Test
     public void testNoLastConfig() throws Exception {
         File file = Files.createTempFile("testFilePersist", ".txt").toFile();
-        if (!file.exists())
+        if (!file.exists()) {
             return;
+        }
         XmlFileStorageAdapter storage = new XmlFileStorageAdapter();
         storage.setFileStorage(file);
 
@@ -223,12 +220,14 @@ public class FileStorageAdapterTest {
         return "<config>" + i++ + "</config>";
     }
 
-    private void delete(File f) throws IOException {
+    private void delete(final File f) throws IOException {
         if (f.isDirectory()) {
-            for (File c : f.listFiles())
+            for (File c : f.listFiles()) {
                 delete(c);
+            }
         }
-        if (!f.delete())
+        if (!f.delete()) {
             throw new FileNotFoundException("Failed to delete file: " + f);
+        }
     }
 }
index b2afd3542ec6f208b433ec366def686fb475c0fe..200fa8854db4965fa60c759c8e15d199a9f75264 100644 (file)
@@ -2,8 +2,6 @@ package org.opendaylight.controller.config.util;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNull;
-
-import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
index 0524f0019a1414aa3282f515005b3e10df38aebd..fc1c3f8afe30c9ed8965a085611745bf5306d44f 100644 (file)
@@ -7,29 +7,25 @@
  */
 package org.opendaylight.controller.config.util;
 
+import static org.hamcrest.CoreMatchers.hasItem;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertThat;
-import static org.junit.matchers.JUnitMatchers.hasItem;
-
+import com.google.common.collect.Sets;
 import java.lang.management.ManagementFactory;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
-
 import javax.management.InstanceNotFoundException;
 import javax.management.MBeanServer;
 import javax.management.ObjectName;
-
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.controller.config.api.ConfigRegistry;
 
-import com.google.common.collect.Sets;
-
 public class ConfigRegistryClientsTest {
 
     private TestingConfigRegistry testingRegistry;
@@ -145,7 +141,7 @@ public class ConfigRegistryClientsTest {
         assertEquals(Sets.newHashSet(TestingConfigRegistry.run2, TestingConfigRegistry.run1, TestingConfigRegistry.run3), jmxLookup);
     }
 
-    private Set<ObjectName> lookupRuntimeBeans(ConfigRegistryClient client)
+    private Set<ObjectName> lookupRuntimeBeans(final ConfigRegistryClient client)
             throws Exception {
         Set<ObjectName> beans = client.lookupRuntimeBeans();
         for (ObjectName on : beans) {
@@ -178,7 +174,7 @@ public class ConfigRegistryClientsTest {
     }
 
     private Set<ObjectName> clientLookupRuntimeBeansWithModuleAndInstance(
-            ConfigRegistryClient client, String moduleName, String instanceName) {
+            final ConfigRegistryClient client, final String moduleName, final String instanceName) {
         Set<ObjectName> beans = client.lookupRuntimeBeans(moduleName, instanceName);
         if (beans.size() > 0) {
             assertEquals("RuntimeBean",
@@ -220,7 +216,7 @@ public class ConfigRegistryClientsTest {
         assertThat(clientLookupServiceInterfaceNames(testingRegistryON), hasItem(TestingConfigRegistry.serviceQName2));
     }
 
-    private Set<String> clientLookupServiceInterfaceNames(ObjectName client) throws InstanceNotFoundException{
+    private Set<String> clientLookupServiceInterfaceNames(final ObjectName client) throws InstanceNotFoundException{
         return jmxRegistryClient.lookupServiceInterfaceNames(client);
     }
 
index 4489762a47c7c83655201d3f357f2a9a15426ef7..3bc362b38c8bc9d0fa9b8e8ebb48185f72f1b07d 100644 (file)
@@ -93,8 +93,7 @@ public class LookupTest {
     public void testLookupConfigBeans2() throws Exception {
         Method method = LookupRegistry.class.getMethod("lookupConfigBeans",
                 String.class, String.class);
-        Object[] args = new Object[] { TestingConfigRegistry.moduleName1,
-                TestingConfigRegistry.instName1 };
+        Object[] args = new Object[] { TestingConfigRegistry.moduleName1, TestingConfigRegistry.instName1 };
         test(method, args);
     }
 
@@ -102,8 +101,7 @@ public class LookupTest {
     public void testLookupConfigBean() throws Exception {
         Method method = LookupRegistry.class.getMethod("lookupConfigBean",
                 String.class, String.class);
-        Object[] args = new Object[] { TestingConfigRegistry.moduleName1,
-                TestingConfigRegistry.instName1 };
+        Object[] args = new Object[] { TestingConfigRegistry.moduleName1, TestingConfigRegistry.instName1 };
         test(method, args);
     }
 
index 2e9bf1df00afd047a7fe21318e2b18834a26c601..adbb9f4cd63db212df666a68101f61459f76733f 100644 (file)
@@ -58,23 +58,22 @@ public class LogbackConfigurationLoaderTest {
 
         // check logs
         String[] expectedLogs = new String[] {
-                "LoggingEvent -> [INFO] org.opendaylight.controller.logback.config.loader.test.LogbackConfigurationLoaderTest: LOGBACK ready -> about to use it",
-                "LoggingEvent -> [TRACE] org.opendaylight.controller.logback.config.loader.test.logwork.Tracer: tracing",
-                "LoggingEvent -> [DEBUG] org.opendaylight.controller.logback.config.loader.test.logwork.Tracer: debugging",
-                "LoggingEvent -> [INFO] org.opendaylight.controller.logback.config.loader.test.logwork.Tracer: infoing",
-                "LoggingEvent -> [WARN] org.opendaylight.controller.logback.config.loader.test.logwork.Tracer: warning",
-                "LoggingEvent -> [ERROR] org.opendaylight.controller.logback.config.loader.test.logwork.Tracer: erroring",
-                "LoggingEvent -> [DEBUG] org.opendaylight.controller.logback.config.loader.test.logwork.Debugger: debugging",
-                "LoggingEvent -> [INFO] org.opendaylight.controller.logback.config.loader.test.logwork.Debugger: infoing",
-                "LoggingEvent -> [WARN] org.opendaylight.controller.logback.config.loader.test.logwork.Debugger: warning",
-                "LoggingEvent -> [ERROR] org.opendaylight.controller.logback.config.loader.test.logwork.Debugger: erroring",
-                "LoggingEvent -> [INFO] org.opendaylight.controller.logback.config.loader.test.logwork.Informer: infoing",
-                "LoggingEvent -> [WARN] org.opendaylight.controller.logback.config.loader.test.logwork.Informer: warning",
-                "LoggingEvent -> [ERROR] org.opendaylight.controller.logback.config.loader.test.logwork.Informer: erroring",
-                "LoggingEvent -> [WARN] org.opendaylight.controller.logback.config.loader.test.logwork.Warner: warning",
-                "LoggingEvent -> [ERROR] org.opendaylight.controller.logback.config.loader.test.logwork.Warner: erroring",
-                "LoggingEvent -> [ERROR] org.opendaylight.controller.logback.config.loader.test.logwork.Errorer: erroring"
-
+            "LoggingEvent -> [INFO] org.opendaylight.controller.logback.config.loader.test.LogbackConfigurationLoaderTest: LOGBACK ready -> about to use it",
+            "LoggingEvent -> [TRACE] org.opendaylight.controller.logback.config.loader.test.logwork.Tracer: tracing",
+            "LoggingEvent -> [DEBUG] org.opendaylight.controller.logback.config.loader.test.logwork.Tracer: debugging",
+            "LoggingEvent -> [INFO] org.opendaylight.controller.logback.config.loader.test.logwork.Tracer: infoing",
+            "LoggingEvent -> [WARN] org.opendaylight.controller.logback.config.loader.test.logwork.Tracer: warning",
+            "LoggingEvent -> [ERROR] org.opendaylight.controller.logback.config.loader.test.logwork.Tracer: erroring",
+            "LoggingEvent -> [DEBUG] org.opendaylight.controller.logback.config.loader.test.logwork.Debugger: debugging",
+            "LoggingEvent -> [INFO] org.opendaylight.controller.logback.config.loader.test.logwork.Debugger: infoing",
+            "LoggingEvent -> [WARN] org.opendaylight.controller.logback.config.loader.test.logwork.Debugger: warning",
+            "LoggingEvent -> [ERROR] org.opendaylight.controller.logback.config.loader.test.logwork.Debugger: erroring",
+            "LoggingEvent -> [INFO] org.opendaylight.controller.logback.config.loader.test.logwork.Informer: infoing",
+            "LoggingEvent -> [WARN] org.opendaylight.controller.logback.config.loader.test.logwork.Informer: warning",
+            "LoggingEvent -> [ERROR] org.opendaylight.controller.logback.config.loader.test.logwork.Informer: erroring",
+            "LoggingEvent -> [WARN] org.opendaylight.controller.logback.config.loader.test.logwork.Warner: warning",
+            "LoggingEvent -> [ERROR] org.opendaylight.controller.logback.config.loader.test.logwork.Warner: erroring",
+            "LoggingEvent -> [ERROR] org.opendaylight.controller.logback.config.loader.test.logwork.Errorer: erroring"
         };
 
         List<String> logSnapshot = new ArrayList<>(TestAppender.getLogRecord());
index 7fb760aca78c7977f2f387516bed2065a865f54f..52f25219691a94a928bf38c49d4bf3170ccaa713 100755 (executable)
@@ -1,17 +1,17 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<configuration debug="true">\r
-\r
-  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">\r
-    <encoder>\r
-      <pattern>%date{"yyyy-MM-dd HH:mm:ss.SSS z"} [%thread] %-5level %logger{36} - %msg%n</pattern>\r
-    </encoder>\r
-  </appender>\r
-\r
-  <root level="INFO">\r
-    <appender-ref ref="STDOUT" />\r
-  </root>\r
-\r
-  <!--  Base log level  -->\r
-  <logger name="org.opendaylight.controller.logback.config.loader" level="DEBUG"/>\r
-\r
-</configuration>\r
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration debug="true">
+
+  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+    <encoder>
+      <pattern>%date{"yyyy-MM-dd HH:mm:ss.SSS z"} [%thread] %-5level %logger{36} - %msg%n</pattern>
+    </encoder>
+  </appender>
+
+  <root level="INFO">
+    <appender-ref ref="STDOUT" />
+  </root>
+
+  <!--  Base log level  -->
+  <logger name="org.opendaylight.controller.logback.config.loader" level="DEBUG"/>
+
+</configuration>
index ca489d5c7864f371e499d1b5722cf4cb9cb5a026..e4f8dfc26b85893aacc3c7a98c546d2b61ef275b 100755 (executable)
@@ -1,19 +1,19 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<configuration debug="false">\r
-\r
-  <appender name="TEST" class="org.opendaylight.controller.logback.config.loader.test.TestAppender"/>\r
-  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">\r
-    <encoder>\r
-      <pattern>%date{"yyyy-MM-dd HH:mm:ss.SSS z"} [%thread] %-5level %logger{36} - %msg%n</pattern>\r
-    </encoder>\r
-  </appender>\r
-\r
-  <root level="INFO">\r
-    <appender-ref ref="TEST" />\r
-    <appender-ref ref="STDOUT" />\r
-  </root>\r
-\r
-  <!--  Base log level  -->\r
-  <logger name="org.opendaylight.controller.logback.config.loader" level="INFO"/>\r
-\r
-</configuration>\r
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration debug="false">
+
+  <appender name="TEST" class="org.opendaylight.controller.logback.config.loader.test.TestAppender"/>
+  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+    <encoder>
+      <pattern>%date{"yyyy-MM-dd HH:mm:ss.SSS z"} [%thread] %-5level %logger{36} - %msg%n</pattern>
+    </encoder>
+  </appender>
+
+  <root level="INFO">
+    <appender-ref ref="TEST" />
+    <appender-ref ref="STDOUT" />
+  </root>
+
+  <!--  Base log level  -->
+  <logger name="org.opendaylight.controller.logback.config.loader" level="INFO"/>
+
+</configuration>
index 89f82c50461969260003aa41a5ca6820c1f3cce9..83557f60721c074b32431d89380f102d8c91177a 100755 (executable)
@@ -1,12 +1,12 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<configuration debug="false">\r
-\r
-  <!--  Base log level  -->\r
-  <logger name="org.opendaylight.controller.logback.config.loader" level="DEBUG"/>\r
-  <logger name="org.opendaylight.controller.logback.config.loader.test.logwork.Tracer" level="TRACE"/>\r
-<!--   <logger name="org.opendaylight.controller.logback.config.loader.test.logwork.Debugger" level="DEBUG"/> -->\r
-  <logger name="org.opendaylight.controller.logback.config.loader.test.logwork.Informer" level="DEBUG"/>\r
-  <logger name="org.opendaylight.controller.logback.config.loader.test.logwork.Warner" level="ERROR"/>\r
-  <logger name="org.opendaylight.controller.logback.config.loader.test.logwork.Errorer" level="ERROR"/>\r
-\r
-</configuration>\r
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration debug="false">
+
+  <!--  Base log level  -->
+  <logger name="org.opendaylight.controller.logback.config.loader" level="DEBUG"/>
+  <logger name="org.opendaylight.controller.logback.config.loader.test.logwork.Tracer" level="TRACE"/>
+<!--   <logger name="org.opendaylight.controller.logback.config.loader.test.logwork.Debugger" level="DEBUG"/> -->
+  <logger name="org.opendaylight.controller.logback.config.loader.test.logwork.Informer" level="DEBUG"/>
+  <logger name="org.opendaylight.controller.logback.config.loader.test.logwork.Warner" level="ERROR"/>
+  <logger name="org.opendaylight.controller.logback.config.loader.test.logwork.Errorer" level="ERROR"/>
+
+</configuration>
index a37b6f7f2136b9b9e5ba704fc39352b65df8a3c8..a944cc28b594295f6c75587862e01b18b4cea958 100755 (executable)
@@ -1,11 +1,11 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<configuration debug="false">\r
-  <root level="INFO">\r
-    <appender-ref ref="TEST" />\r
-  </root>\r
-\r
-  <logger name="org.opendaylight.controller.logback.config.loader.test.logwork.Informer" level="INFO"/>\r
-  <logger name="org.opendaylight.controller.logback.config.loader.test.logwork.Warner" level="WARN"/>\r
-\r
-  <logger name="org.opendaylight.controller.logback.config.loader.test.LogbackConfigurationLoaderTest" level="TRACE"/>\r
-</configuration>\r
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration debug="false">
+  <root level="INFO">
+    <appender-ref ref="TEST" />
+  </root>
+
+  <logger name="org.opendaylight.controller.logback.config.loader.test.logwork.Informer" level="INFO"/>
+  <logger name="org.opendaylight.controller.logback.config.loader.test.logwork.Warner" level="WARN"/>
+
+  <logger name="org.opendaylight.controller.logback.config.loader.test.LogbackConfigurationLoaderTest" level="TRACE"/>
+</configuration>
index ff7da5df483556a9eb2a7bdb2e4e89a03bbff0df..087648cae7e2b6e80980caee648b124bcaae1179 100644 (file)
@@ -7,16 +7,6 @@
  */
 package org.opendaylight.controller.config.yang.logback.config;
 
-import java.io.Closeable;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.slf4j.LoggerFactory;
-
 import ch.qos.logback.classic.Level;
 import ch.qos.logback.classic.LoggerContext;
 import ch.qos.logback.classic.encoder.PatternLayoutEncoder;
@@ -26,10 +16,17 @@ import ch.qos.logback.core.Appender;
 import ch.qos.logback.core.rolling.FixedWindowRollingPolicy;
 import ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy;
 import ch.qos.logback.core.rolling.TimeBasedRollingPolicy;
-
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.Sets;
+import java.io.Closeable;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import org.slf4j.LoggerFactory;
 
 /**
  * Implementation of {@link ContextSetter}. Resets running logback
@@ -40,12 +37,13 @@ public class ContextSetterImpl implements ContextSetter, Closeable {
     private final LogbackStatusListener statusListener;
     private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(ContextSetterImpl.class);
 
-    public ContextSetterImpl(LogbackRuntimeRegistrator rootRuntimeBeanRegistratorWrapper) {
+    public ContextSetterImpl(final LogbackRuntimeRegistrator rootRuntimeBeanRegistratorWrapper) {
         statusListener = new LogbackStatusListener(rootRuntimeBeanRegistratorWrapper);
         statusListener.register();
     }
 
-    public void updateContext(LogbackModule module) {
+    @Override
+    public void updateContext(final LogbackModule module) {
         LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
 
         List<ch.qos.logback.classic.Logger> loggersBefore = context.getLoggerList();
@@ -53,12 +51,12 @@ public class ContextSetterImpl implements ContextSetter, Closeable {
         createLoggers(context, module, Sets.newHashSet(loggersBefore));
     }
 
-    private Map<String, Appender<ILoggingEvent>> createConsoleAppenders(LoggerContext context, LogbackModule module) {
+    private Map<String, Appender<ILoggingEvent>> createConsoleAppenders(final LoggerContext context, final LogbackModule module) {
         Map<String, Appender<ILoggingEvent>> appendersMap = new HashMap<>();
         for (ConsoleAppenderTO appender : module.getConsoleAppenderTO()) {
             Preconditions.checkState(appendersMap.containsKey(appender.getName()) == false,
                     "Duplicate appender name %s", appender.getName());
-            ch.qos.logback.core.ConsoleAppender app = new ch.qos.logback.core.ConsoleAppender();
+            ch.qos.logback.core.ConsoleAppender<ILoggingEvent> app = new ch.qos.logback.core.ConsoleAppender<>();
             app.setContext(context);
             PatternLayoutEncoder encoder = new PatternLayoutEncoder();
             encoder.setContext(context);
@@ -77,8 +75,8 @@ public class ContextSetterImpl implements ContextSetter, Closeable {
         return appendersMap;
     }
 
-    private void createLoggers(LoggerContext context, LogbackModule module,
-            Set<ch.qos.logback.classic.Logger> loggersBefore) {
+    private void createLoggers(final LoggerContext context, final LogbackModule module,
+            final Set<ch.qos.logback.classic.Logger> loggersBefore) {
 
         Map<String, Appender<ILoggingEvent>> appendersMap = getAppenders(module, context);
 
@@ -97,8 +95,8 @@ public class ContextSetterImpl implements ContextSetter, Closeable {
         }
     }
 
-    private void addNewAppenders(Map<String, Appender<ILoggingEvent>> appendersMap, LoggerTO logger,
-            ch.qos.logback.classic.Logger logbackLogger, Optional<Set<Appender<ILoggingEvent>>> appendersBefore) {
+    private void addNewAppenders(final Map<String, Appender<ILoggingEvent>> appendersMap, final LoggerTO logger,
+            final ch.qos.logback.classic.Logger logbackLogger, final Optional<Set<Appender<ILoggingEvent>>> appendersBefore) {
         if (logger.getAppenders() != null) {
             for (String appenderName : logger.getAppenders()) {
                 if (appendersMap.containsKey(appenderName)) {
@@ -112,8 +110,8 @@ public class ContextSetterImpl implements ContextSetter, Closeable {
         }
     }
 
-    private void removeBeforeAppenders(Set<ch.qos.logback.classic.Logger> loggersBefore, LoggerTO logger,
-            ch.qos.logback.classic.Logger logbackLogger, Optional<Set<Appender<ILoggingEvent>>> appendersBefore) {
+    private void removeBeforeAppenders(final Set<ch.qos.logback.classic.Logger> loggersBefore, final LoggerTO logger,
+            final ch.qos.logback.classic.Logger logbackLogger, final Optional<Set<Appender<ILoggingEvent>>> appendersBefore) {
         if (appendersBefore.isPresent()) {
             for (Appender<ILoggingEvent> appenderBefore : appendersBefore.get()) {
                 logbackLogger.detachAppender(appenderBefore);
@@ -125,8 +123,8 @@ public class ContextSetterImpl implements ContextSetter, Closeable {
         }
     }
 
-    private Optional<Set<Appender<ILoggingEvent>>> getAppendersBefore(Set<ch.qos.logback.classic.Logger> loggersBefore,
-            ch.qos.logback.classic.Logger logbackLogger) {
+    private Optional<Set<Appender<ILoggingEvent>>> getAppendersBefore(final Set<ch.qos.logback.classic.Logger> loggersBefore,
+            final ch.qos.logback.classic.Logger logbackLogger) {
         if (loggersBefore.contains(logbackLogger)) {
             Iterator<Appender<ILoggingEvent>> appenderIt = logbackLogger.iteratorForAppenders();
             Set<Appender<ILoggingEvent>> appendersBefore = Sets.newHashSet();
@@ -140,7 +138,7 @@ public class ContextSetterImpl implements ContextSetter, Closeable {
 
     }
 
-    private Map<String, Appender<ILoggingEvent>> getAppenders(LogbackModule module, LoggerContext context) {
+    private Map<String, Appender<ILoggingEvent>> getAppenders(final LogbackModule module, final LoggerContext context) {
         Map<String, Appender<ILoggingEvent>> appendersMap = new HashMap<>();
         addAllAppenders(appendersMap, createRollingAppenders(context, module));
         addAllAppenders(appendersMap, createFileAppenders(context, module));
@@ -149,8 +147,8 @@ public class ContextSetterImpl implements ContextSetter, Closeable {
         return appendersMap;
     }
 
-    private void addAllAppenders(Map<String, Appender<ILoggingEvent>> allAppenders,
-            Map<String, Appender<ILoggingEvent>> appendersToAdd) {
+    private void addAllAppenders(final Map<String, Appender<ILoggingEvent>> allAppenders,
+            final Map<String, Appender<ILoggingEvent>> appendersToAdd) {
         for (String appenderName : appendersToAdd.keySet()) {
             Preconditions.checkState(allAppenders.containsKey(appenderName) == false, "Duplicate appender name %s",
                     appenderName);
@@ -158,12 +156,12 @@ public class ContextSetterImpl implements ContextSetter, Closeable {
         }
     }
 
-    private Map<String, Appender<ILoggingEvent>> createFileAppenders(LoggerContext context, LogbackModule module) {
+    private Map<String, Appender<ILoggingEvent>> createFileAppenders(final LoggerContext context, final LogbackModule module) {
         Map<String, Appender<ILoggingEvent>> appendersMap = new HashMap<>();
         for (FileAppenderTO appender : module.getFileAppenderTO()) {
             Preconditions.checkState(appendersMap.containsKey(appender.getName()) == false,
                     "Duplicate appender name %s", appender.getName());
-            ch.qos.logback.core.FileAppender app = new ch.qos.logback.core.FileAppender<>();
+            ch.qos.logback.core.FileAppender<ILoggingEvent> app = new ch.qos.logback.core.FileAppender<>();
             app.setAppend(appender.getAppend());
             app.setContext(context);
             PatternLayoutEncoder encoder = new PatternLayoutEncoder();
@@ -180,12 +178,12 @@ public class ContextSetterImpl implements ContextSetter, Closeable {
         return appendersMap;
     }
 
-    private Map<String, Appender<ILoggingEvent>> createRollingAppenders(LoggerContext context, LogbackModule module) {
+    private Map<String, Appender<ILoggingEvent>> createRollingAppenders(final LoggerContext context, final LogbackModule module) {
         Map<String, Appender<ILoggingEvent>> appendersMap = new HashMap<>();
         for (RollingFileAppenderTO appender : module.getRollingFileAppenderTO()) {
             Preconditions.checkState(appendersMap.containsKey(appender.getName()) == false,
                     "Duplicate appender name %s", appender.getName());
-            ch.qos.logback.core.rolling.RollingFileAppender app = new ch.qos.logback.core.rolling.RollingFileAppender<>();
+            ch.qos.logback.core.rolling.RollingFileAppender<ILoggingEvent> app = new ch.qos.logback.core.rolling.RollingFileAppender<>();
             app.setAppend(appender.getAppend());
             app.setContext(context);
             PatternLayoutEncoder encoder = new PatternLayoutEncoder();
@@ -204,7 +202,7 @@ public class ContextSetterImpl implements ContextSetter, Closeable {
                 policy.start();
                 app.setRollingPolicy(policy);
             } else if (appender.getRollingPolicyType().equals("TimeBasedRollingPolicy")) {
-                TimeBasedRollingPolicy policy = new TimeBasedRollingPolicy();
+                TimeBasedRollingPolicy<ILoggingEvent> policy = new TimeBasedRollingPolicy<>();
                 policy.setContext(context);
                 policy.setMaxHistory(appender.getMaxHistory());
                 if (appender.getCleanHistoryOnStart() != null) {
@@ -215,7 +213,7 @@ public class ContextSetterImpl implements ContextSetter, Closeable {
                 policy.start();
                 app.setRollingPolicy(policy);
             }
-            SizeBasedTriggeringPolicy triggeringPolicy = new SizeBasedTriggeringPolicy();
+            SizeBasedTriggeringPolicy<ILoggingEvent> triggeringPolicy = new SizeBasedTriggeringPolicy<>();
             triggeringPolicy.setContext(context);
             triggeringPolicy.setMaxFileSize(appender.getMaxFileSize());
             triggeringPolicy.start();
index b5d0d1b4de0466e1d1c09d55e92644abf6bb4dd7..bd19d5eecdc6e0e087e947b3eb3324e6a574ff9e 100644 (file)
  */
 package org.opendaylight.controller.config.yang.logback.config;
 
+import ch.qos.logback.classic.Logger;
+import ch.qos.logback.classic.LoggerContext;
+import ch.qos.logback.classic.encoder.PatternLayoutEncoder;
+import ch.qos.logback.classic.spi.ILoggingEvent;
+import ch.qos.logback.classic.spi.LoggerComparator;
+import ch.qos.logback.core.Appender;
+import ch.qos.logback.core.rolling.FixedWindowRollingPolicy;
+import ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy;
+import ch.qos.logback.core.rolling.TimeBasedRollingPolicy;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
@@ -24,7 +36,6 @@ import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
-
 import org.apache.commons.lang3.StringUtils;
 import org.opendaylight.controller.config.api.DependencyResolver;
 import org.opendaylight.controller.config.api.DependencyResolverFactory;
@@ -32,20 +43,6 @@ import org.opendaylight.controller.config.api.ModuleIdentifier;
 import org.osgi.framework.BundleContext;
 import org.slf4j.LoggerFactory;
 
-import ch.qos.logback.classic.Logger;
-import ch.qos.logback.classic.LoggerContext;
-import ch.qos.logback.classic.encoder.PatternLayoutEncoder;
-import ch.qos.logback.classic.spi.ILoggingEvent;
-import ch.qos.logback.classic.spi.LoggerComparator;
-import ch.qos.logback.core.Appender;
-import ch.qos.logback.core.rolling.FixedWindowRollingPolicy;
-import ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy;
-import ch.qos.logback.core.rolling.TimeBasedRollingPolicy;
-
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
-
 /**
 *
 */
@@ -59,8 +56,8 @@ public class LogbackModuleFactory extends
     private Map<String, FileAppenderTO> fileDTOs;
 
     @Override
-    public LogbackModule instantiateModule(String instanceName, DependencyResolver dependencyResolver,
-            BundleContext bundleContext) {
+    public LogbackModule instantiateModule(final String instanceName, final DependencyResolver dependencyResolver,
+            final BundleContext bundleContext) {
         Preconditions.checkArgument(instanceName.equals(INSTANCE_NAME),
                 "There should be just one instance of logback, named " + INSTANCE_NAME);
         prepareDTOs();
@@ -74,8 +71,8 @@ public class LogbackModuleFactory extends
     }
 
     @Override
-    public LogbackModule instantiateModule(String instanceName, DependencyResolver dependencyResolver,
-            LogbackModule oldModule, AutoCloseable oldInstance, BundleContext bundleContext) {
+    public LogbackModule instantiateModule(final String instanceName, final DependencyResolver dependencyResolver,
+            final LogbackModule oldModule, final AutoCloseable oldInstance, final BundleContext bundleContext) {
         Preconditions.checkArgument(instanceName.equals(INSTANCE_NAME),
                 "There should be just one instance of logback, named " + INSTANCE_NAME);
         prepareDTOs();
@@ -97,7 +94,7 @@ public class LogbackModuleFactory extends
         prepareAppendersDTOs(context);
     }
 
-    private void prepareAppendersDTOs(LoggerContext context) {
+    private void prepareAppendersDTOs(final LoggerContext context) {
         this.rollingDTOs = new HashMap<>();
         this.consoleDTOs = new HashMap<>();
         this.fileDTOs = new HashMap<>();
@@ -131,7 +128,7 @@ public class LogbackModuleFactory extends
                         app.setFileNamePattern(rollingPolicy.getFileNamePattern());
                         app.setRollingPolicyType("FixedWindowRollingPolicy");
                     } else if (rollingApp.getRollingPolicy() instanceof TimeBasedRollingPolicy<?>) {
-                        TimeBasedRollingPolicy rollingPolicy = (TimeBasedRollingPolicy) rollingApp.getRollingPolicy();
+                        TimeBasedRollingPolicy<ILoggingEvent> rollingPolicy = (TimeBasedRollingPolicy<ILoggingEvent>) rollingApp.getRollingPolicy();
                         app.setRollingPolicyType("TimeBasedRollingPolicy");
                         app.setFileNamePattern(rollingPolicy.getFileNamePattern());
                         app.setMaxHistory(rollingPolicy.getMaxHistory());
@@ -166,7 +163,7 @@ public class LogbackModuleFactory extends
         }
     }
 
-    private Map<String, LoggerTO> prepareLoggersDTOs(LoggerContext context) {
+    private Map<String, LoggerTO> prepareLoggersDTOs(final LoggerContext context) {
         Map<String, LoggerTO> DTOs = new HashMap<>();
         List<String> appenders = new ArrayList<>();
         List<org.slf4j.Logger> loggersToBeAdd = removeUnusableLoggers(context.getLoggerList(),
@@ -192,7 +189,7 @@ public class LogbackModuleFactory extends
         return DTOs;
     }
 
-    private List<org.slf4j.Logger> removeUnusableLoggers(List<Logger> loggerList, Logger rootLogger) {
+    private List<org.slf4j.Logger> removeUnusableLoggers(final List<Logger> loggerList, final Logger rootLogger) {
         Collections.sort(loggerList, new LoggerComparator());
         Map<String, org.slf4j.Logger> loggersToReturn = new HashMap<>();
 
@@ -234,8 +231,8 @@ public class LogbackModuleFactory extends
     }
 
     @Override
-    public Set<LogbackModule> getDefaultModules(DependencyResolverFactory dependencyResolverFactory,
-            BundleContext bundleContext) {
+    public Set<LogbackModule> getDefaultModules(final DependencyResolverFactory dependencyResolverFactory,
+            final BundleContext bundleContext) {
         DependencyResolver resolver = dependencyResolverFactory.createDependencyResolver(new ModuleIdentifier(
                 getImplementationName(), INSTANCE_NAME));
         LogbackModule defaultLogback = instantiateModule(INSTANCE_NAME, resolver, bundleContext);
index 75323d256e73de143a35c75bbfe9df1faf806d24..9e07cc68cb94effc1cf697777a235c58728af84e 100644 (file)
@@ -7,9 +7,9 @@
  */
 package org.opendaylight.controller.config.yang.logback.config;
 
+import static org.hamcrest.CoreMatchers.containsString;
 import static org.junit.Assert.assertThat;
 import static org.junit.Assert.fail;
-import static org.junit.matchers.JUnitMatchers.containsString;
 
 import java.util.ArrayList;
 import java.util.Arrays;
index 344ef3dec32a90195e2285c019a552b35aadd72d..0a10c2d3a8b96db3eec0bde1b1f652abf89a556c 100644 (file)
@@ -12,8 +12,7 @@ import org.opendaylight.controller.netconf.client.NetconfClientDispatcherImpl;
 /**
 *
 */
-public final class NetconfClientDispatcherModule extends org.opendaylight.controller.config.yang.config.netconf.client.dispatcher.AbstractNetconfClientDispatcherModule
- {
+public final class NetconfClientDispatcherModule extends org.opendaylight.controller.config.yang.config.netconf.client.dispatcher.AbstractNetconfClientDispatcherModule {
 
     public NetconfClientDispatcherModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
         super(identifier, dependencyResolver);
index 5fe5f9496e2741beaf8721db19fac513acf5a37b..578476f0f7f0570cad38a8571d3b06670cb7a01a 100644 (file)
@@ -7,12 +7,11 @@
  */
 package org.opendaylight.controller.config.yang.netty.timer;
 
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 import javax.management.InstanceAlreadyExistsException;
 import javax.management.InstanceNotFoundException;
 import javax.management.ObjectName;
-
-import junit.framework.Assert;
-
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.controller.config.api.ConflictingVersionException;
@@ -42,9 +41,9 @@ public class HashedWheelTimerModuleTest extends AbstractConfigTest {
         try {
             createInstance(transaction, instanceName, 0L, 10, true);
             transaction.validateConfig();
-            Assert.fail();
+            fail();
         } catch (ValidationException e) {
-            Assert.assertTrue(e.getMessage().contains("TickDuration value must be greater than 0"));
+            assertTrue(e.getMessage().contains("TickDuration value must be greater than 0"));
         }
     }
 
@@ -53,9 +52,9 @@ public class HashedWheelTimerModuleTest extends AbstractConfigTest {
         try {
             createInstance(transaction, instanceName, 500L, 0, true);
             transaction.validateConfig();
-            Assert.fail();
+            fail();
         } catch (ValidationException e) {
-            Assert.assertTrue(e.getMessage().contains("TicksPerWheel value must be greater than 0"));
+            assertTrue(e.getMessage().contains("TicksPerWheel value must be greater than 0"));
         }
     }
 
@@ -112,7 +111,7 @@ public class HashedWheelTimerModuleTest extends AbstractConfigTest {
         assertStatus(status, 0, 1, 1);
     }
 
-    private ObjectName createInstance(ConfigTransactionJMXClient transaction, String instanceName,
+    private ObjectName createInstance(final ConfigTransactionJMXClient transaction, final String instanceName,
             final Long tickDuration, final Integer ticksPerWheel, final boolean hasThreadfactory)
             throws InstanceAlreadyExistsException {
         ObjectName nameCreated = transaction.createModule(factory.getImplementationName(), instanceName);
@@ -126,7 +125,7 @@ public class HashedWheelTimerModuleTest extends AbstractConfigTest {
         return nameCreated;
     }
 
-    private ObjectName createThreadfactoryInstance(ConfigTransactionJMXClient transaction, String instanceName,
+    private ObjectName createThreadfactoryInstance(final ConfigTransactionJMXClient transaction, final String instanceName,
             final String namePrefix) throws InstanceAlreadyExistsException {
         ObjectName nameCreated = transaction.createModule(threadFactory.getImplementationName(), instanceName);
         NamingThreadFactoryModuleMXBean mxBean = transaction.newMBeanProxy(nameCreated,
index ea7b24317932b308bf101df8736a8c514bc16418..ad2607a8db013b15d57184ee11e6d122a2efb41d 100644 (file)
@@ -41,6 +41,8 @@
     <module>netconf-config-dispatcher</module>
     <module>config-module-archetype</module>
     <module>config-netty-config</module>
+
+    <module>config-artifacts</module>
   </modules>
 
   <dependencies>
index 0b339fc6007834f9c8fad9cc9619457ee60fa9f1..92b81220ffa2dfc8c09aa43409edacf2ad7fa369 100644 (file)
@@ -7,9 +7,9 @@
  */
 package org.opendaylight.controller.config.threadpool.async;
 
+import static org.hamcrest.CoreMatchers.containsString;
 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;
index aeb6d6b959ab3ce70a662b7d2a6efbf773ce58f5..6d0449cf5aa3bb0f1f6e3802ff0ba28e4fefe76c 100644 (file)
@@ -20,10 +20,10 @@ import org.opendaylight.controller.config.yang.threadpool.impl.EventBusModuleFac
 import javax.management.InstanceAlreadyExistsException;
 import javax.management.ObjectName;
 
+import static org.hamcrest.CoreMatchers.containsString;
 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;
 
 public class SyncEventBusConfigBeanTest extends AbstractConfigTest {
 
index 62b295be8d1c53e8b648f7c352ab9b0c5244e875..f968e287c2ffa1411dbc67c89a01b2320ca0dcec 100644 (file)
@@ -7,10 +7,10 @@
  */
 package org.opendaylight.controller.config.threadpool.fixed;
 
+import static org.hamcrest.CoreMatchers.containsString;
 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 java.lang.management.ManagementFactory;
 import java.lang.management.ThreadInfo;
index a1d1c40655ec867f8d0d7404a1c3e65e80cab66c..9ae721ee877a599f29df586e0bf4e1f94d6a878b 100644 (file)
@@ -24,9 +24,9 @@ import javax.management.InstanceAlreadyExistsException;
 import javax.management.InstanceNotFoundException;
 import javax.management.ObjectName;
 
+import static org.hamcrest.CoreMatchers.containsString;
 import static org.junit.Assert.assertThat;
 import static org.junit.Assert.fail;
-import static org.junit.matchers.JUnitMatchers.containsString;
 
 public class FlexibleThreadPoolConfigBeanTest extends AbstractConfigTest {
 
index 499beced5f4511906f2d7cf0ecaffd4335eae63d..be3d59bf396c9c1f3f4f64f498159bf46b3c0eff 100644 (file)
@@ -7,11 +7,11 @@
  */
 package org.opendaylight.controller.config.threadpool.naming;
 
+import static org.hamcrest.CoreMatchers.containsString;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
-import static org.junit.matchers.JUnitMatchers.containsString;
 
 import javax.management.InstanceAlreadyExistsException;
 import javax.management.InstanceNotFoundException;
index 0fc2fd6eb3d0c5aa9c0bd4d0c4d45611417f4887..6482fe9c1bc06d0600c1db7c84668de66aa518a7 100644 (file)
@@ -7,11 +7,11 @@
  */
 package org.opendaylight.controller.config.threadpool.scheduled;
 
+import static org.hamcrest.CoreMatchers.containsString;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
-import static org.junit.matchers.JUnitMatchers.containsString;
 
 import javax.management.InstanceAlreadyExistsException;
 import javax.management.InstanceNotFoundException;
index f8f5cd6742a1182e47c7194fb3ec215316ce7ca5..ca1e823ec72169494034ef6bd3f7d44cc06e7579 100644 (file)
@@ -607,9 +607,8 @@ public class TemplateFactory {
 
                 String varName = BindingGeneratorUtil
                         .parseToValidParamName(attrEntry.getKey());
-                {
-                ModuleField field;
 
+                ModuleField field;
                 if (isIdentity) {
                     String identityBaseClass = getInnerTypeFromIdentity(((TypedAttribute) attributeIfc).getType());
                     IdentityRefModuleField identityField = new IdentityRefModuleField(type, varName,
@@ -641,7 +640,8 @@ public class TemplateFactory {
                             nullableDefaultWrapped, isDependency, dependency, isListOfDependencies, needsDepResolver);
                 }
                 moduleFields.add(field);
-                }
+
+
                 String getterName = "get"
                         + attributeIfc.getUpperCaseCammelCase();
                 MethodDefinition getter = new MethodDefinition(type,
index 33546b1e2ae6a4d6ede0dfaddfc307495f13a325..2378fac6e710a2aa8ee5df1e2688272b8bb0bd1e 100644 (file)
@@ -318,11 +318,11 @@ public class AbsModuleGeneratedObjectFactory {
                             .append("}\n");
                 } else {
                     result.append(format(
-                    "private %s %sDependency;\n"+
-                    "protected final %s get%sDependency(){\n"+
-                        "return %sDependency;\n"+
-                    "}",
-                    osgi, moduleField.getName(), osgi, moduleField.getAttributeName(), moduleField.getName()));
+                        "private %s %sDependency;\n"+
+                        "protected final %s get%sDependency(){\n"+
+                            "return %sDependency;\n"+
+                        "}",
+                        osgi, moduleField.getName(), osgi, moduleField.getAttributeName(), moduleField.getName()));
                 }
             }
         }
index e33f1cddc43c2ffc6bf48491dcc6612ae9e3078d..cdff5090bb2a07b4effb0d00e37d7ee03bfa8a36 100644 (file)
@@ -7,11 +7,11 @@
  */
 package org.opendaylight.controller.config.yangjmxgenerator.plugin;
 
+import static org.hamcrest.CoreMatchers.containsString;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
-import static org.junit.matchers.JUnitMatchers.containsString;
 
 import org.junit.Test;
 import org.opendaylight.controller.config.yangjmxgenerator.ConfigConstants;
index 4112ff017aca88aea673d422fa09b6c84e2320ee..589fe41f469bfbe2a9198e7c1de468e49782e424 100644 (file)
@@ -7,10 +7,8 @@
  */
 package org.opendaylight.controller.config.yangjmxgenerator.plugin;
 
+import static org.junit.Assert.assertEquals;
 import java.io.File;
-
-import junit.framework.Assert;
-
 import org.junit.Test;
 
 public class JMXGeneratorGeneratedFilesTrackerTest {
@@ -20,7 +18,7 @@ public class JMXGeneratorGeneratedFilesTrackerTest {
         JMXGenerator.GeneratedFilesTracker tracker = new JMXGenerator.GeneratedFilesTracker();
 
         tracker.addFile(new File("./a/b/c"));
-        Assert.assertEquals(1, tracker.getFiles().size());
+        assertEquals(1, tracker.getFiles().size());
         tracker.addFile(new File("./a/b/c"));
     }
 }
index 864ebdf95468173f79070e9fa8c4c3165a8a2bec..42112013e9d861529b97d8e62973a330e38ce63e 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.controller.config.yangjmxgenerator.plugin;
 
+import static org.hamcrest.CoreMatchers.containsString;
 import static org.hamcrest.CoreMatchers.equalTo;
 import static org.hamcrest.CoreMatchers.is;
 import static org.junit.Assert.assertEquals;
@@ -15,7 +16,6 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
-import static org.junit.matchers.JUnitMatchers.containsString;
 import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.doNothing;
 import static org.mockito.Mockito.doReturn;
index b3e7b90c966d0f3e12e4c097c18c44d7ae1dbc14..6ea2ea17243b4e5580e48fccc97eb77360ca6a31 100644 (file)
@@ -10,43 +10,43 @@ package org.opendaylight.controller.config.yangjmxgenerator.attribute;
 import org.opendaylight.controller.config.yangjmxgenerator.ServiceInterfaceEntry;
 
 public class Dependency {
-        private final ServiceInterfaceEntry sie;
-        private final boolean mandatory;
+    private final ServiceInterfaceEntry sie;
+    private final boolean mandatory;
 
-        public Dependency(ServiceInterfaceEntry sie, boolean mandatory) {
-            this.sie = sie;
-            this.mandatory = mandatory;
-        }
+    public Dependency(ServiceInterfaceEntry sie, boolean mandatory) {
+        this.sie = sie;
+        this.mandatory = mandatory;
+    }
 
-        public ServiceInterfaceEntry getSie() {
-            return sie;
-        }
+    public ServiceInterfaceEntry getSie() {
+        return sie;
+    }
 
-        public boolean isMandatory() {
-            return mandatory;
-        }
+    public boolean isMandatory() {
+        return mandatory;
+    }
 
-        @Override
-        public boolean equals(Object o) {
-            if (this == o)
-                return true;
-            if (o == null || getClass() != o.getClass())
-                return false;
+    @Override
+    public boolean equals(Object o) {
+        if (this == o)
+            return true;
+        if (o == null || getClass() != o.getClass())
+            return false;
 
-            Dependency that = (Dependency) o;
+        Dependency that = (Dependency) o;
 
-            if (mandatory != that.mandatory)
-                return false;
-            if (!sie.equals(that.sie))
-                return false;
+        if (mandatory != that.mandatory)
+            return false;
+        if (!sie.equals(that.sie))
+            return false;
 
-            return true;
-        }
-
-        @Override
-        public int hashCode() {
-            int result = sie.hashCode();
-            result = 31 * result + (mandatory ? 1 : 0);
-            return result;
-        }
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = sie.hashCode();
+        result = 31 * result + (mandatory ? 1 : 0);
+        return result;
     }
+}
index b9f2ba9cd1012c2d861212d9fc50ec02b32d051e..e3c3a3024c8b4819b6083fd480e3831f3fbfe292 100644 (file)
@@ -7,8 +7,7 @@
  */
 package org.opendaylight.controller.config.yangjmxgenerator;
 
-import static junit.framework.Assert.assertNotNull;
-import static junit.framework.Assert.format;
+import static org.junit.Assert.assertNotNull;
 import static org.hamcrest.CoreMatchers.is;
 import static org.junit.Assert.assertThat;
 
@@ -92,8 +91,8 @@ public abstract class AbstractYangTest {
             QName qName = identitySchemaNode.getQName();
             Preconditions.checkArgument(
                     result.containsKey(qName) == false,
-                    format("Two identities of %s contain same " + "qname %s",
-                            module, qName));
+                    "Two identities of %s contain same qname %s",
+                            module, qName);
             result.put(qName, identitySchemaNode);
         }
         return result;
index e80ebc67a566197294ac64e2c431dd07c5131b3c..38b0a3afece740c22e897dc3d9642a594981ac04 100644 (file)
@@ -7,10 +7,10 @@
  */
 package org.opendaylight.controller.config.yangjmxgenerator;
 
-import static junit.framework.Assert.assertNotNull;
-import static junit.framework.Assert.assertNull;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 import static org.mockito.Mockito.doReturn;
 
index 13a31f59766c7e4ecb1936aa8ca64c3d7c8b85ee..fb9264749b42026c5b100834828c6e3e20e70995 100644 (file)
@@ -9,8 +9,6 @@ package org.opendaylight.controller.config.yang.test.impl;
 
 import com.google.common.collect.Lists;
 
-import junit.framework.Assert;
-
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.controller.config.api.IdentityAttributeRef;
@@ -96,7 +94,7 @@ public class NetconfTestImplModuleTest  extends AbstractConfigTest {
         List<ObjectName> testingDeps = proxy.getTestingDeps();
         ObjectName testingDep = proxy.getTestingDep();
 
-        Assert.assertEquals(TESTING_DEP_PREFIX, ObjectNameUtil.getInstanceName(testingDep));
+        assertEquals(TESTING_DEP_PREFIX, ObjectNameUtil.getInstanceName(testingDep));
         assertTestingDeps(testingDeps, 4);
 
         transaction.abortConfig();
@@ -135,11 +133,11 @@ public class NetconfTestImplModuleTest  extends AbstractConfigTest {
     }
 
     private void assertTestingDeps(List<ObjectName> testingDeps, int i) {
-        Assert.assertEquals(i, testingDeps.size());
+        assertEquals(i, testingDeps.size());
 
         int c = 1;
         for (ObjectName testingDep : testingDeps) {
-            Assert.assertEquals(TESTING_DEP_PREFIX + Integer.toString(c++), ObjectNameUtil.getInstanceName(testingDep));
+            assertEquals(TESTING_DEP_PREFIX + Integer.toString(c++), ObjectNameUtil.getInstanceName(testingDep));
         }
     }
 
index dfdc3b76cbfd7ba3453e46e675534c5debaf72c6..7b2bd864f22171ee29e33c4ec641827962f5b269 100644 (file)
@@ -8,7 +8,6 @@
     <version>0.2.0-SNAPSHOT</version>
     <relativePath>../..</relativePath>
   </parent>
-  <groupId>org.opendaylight.controller</groupId>
   <artifactId>karaf.branding</artifactId>
   <version>1.1.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
index 7d47add017802bd1e077cd97b8178e16d2757784..b196c3180fc5c7429a338b66543d4307d0b51826 100644 (file)
@@ -16,7 +16,6 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
   </parent>
   <modelVersion>4.0.0</modelVersion>
 
-  <groupId>org.opendaylight.controller</groupId>
   <artifactId>benchmark-data-store</artifactId>
 
   <dependencies>
index 78e82c32de856c36178445d0638fab34af2880c6..2490ace648cd37436a710831142e219534587fdd 100644 (file)
@@ -7,8 +7,7 @@
  */
 package org.opendaylight.controller.sal.compatibility.test;
 
-import junit.framework.Assert;
-
+import org.junit.Assert;
 import org.junit.Test;
 import org.opendaylight.controller.sal.action.Action;
 import org.opendaylight.controller.sal.action.PushVlan;
index 45341fb734f26f7b1586d6984326f71e1a380a83..54ffddbbe3114a13c1de1cd46824f8a52823ee4f 100644 (file)
@@ -22,8 +22,6 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
-import junit.framework.Assert;
-
 import org.junit.Test;
 import org.opendaylight.controller.sal.action.Flood;
 import org.opendaylight.controller.sal.action.FloodAll;
@@ -198,7 +196,7 @@ public class TestToSalConversionsUtils {
     public void testFromNodeConnectorRef() throws ConstructionException {
         Node node = new Node(NodeIDType.OPENFLOW, 42L);
         NodeConnector nodeConnector = ToSalConversionsUtils.fromNodeConnectorRef(new Uri("1"), node);
-        Assert.assertEquals("OF|1@OF|00:00:00:00:00:00:00:2a", nodeConnector.toString());
+        assertEquals("OF|1@OF|00:00:00:00:00:00:00:2a", nodeConnector.toString());
     }
 
     private void checkSalMatch(org.opendaylight.controller.sal.match.Match match, MtchType mt) throws ConstructionException {
index 9369217d78058c43318f8799c61cdf1c3b70e39a..2a0d47e9c20aa6e365e8250aa974e66034699d38 100644 (file)
@@ -7,7 +7,7 @@
  */
 package org.opendaylight.controller.sal.compatibility.topology.test;
 
-import junit.framework.Assert;
+import static org.junit.Assert.assertEquals;
 
 import org.junit.Test;
 import org.opendaylight.controller.sal.compatibility.topology.TopologyMapping;
@@ -30,7 +30,7 @@ public class TopologyMappingTest {
         NodeId nodeId = new NodeId("openflow:1");
         String observedNodeId = TopologyMapping.toADNodeId(nodeId);
 
-        Assert.assertEquals("1", observedNodeId);
+        assertEquals("1", observedNodeId);
     }
 
     /**
@@ -43,7 +43,7 @@ public class TopologyMappingTest {
         TpId source = new TpId("foo:2");
         NodeConnector observedNodeConnector = TopologyMapping.toADNodeConnector(source, nodeId);
 
-        Assert.assertEquals("OF|2@OF|00:00:00:00:00:00:00:01", observedNodeConnector.toString());
+        assertEquals("OF|2@OF|00:00:00:00:00:00:00:01", observedNodeConnector.toString());
     }
 
     /**
@@ -54,7 +54,7 @@ public class TopologyMappingTest {
         TpId source = new TpId("foo:2");
         String observedNodeConnectorId = TopologyMapping.toADNodeConnectorId(source);
 
-        Assert.assertEquals("2", observedNodeConnectorId);
+        assertEquals("2", observedNodeConnectorId);
     }
 
     /**
@@ -66,7 +66,7 @@ public class TopologyMappingTest {
         NodeId nodeId = new NodeId("openflow:1");
         Node observedNode = TopologyMapping.toADNode(nodeId);
 
-        Assert.assertEquals("OF|00:00:00:00:00:00:00:01", observedNode.toString());
+        assertEquals("OF|00:00:00:00:00:00:00:01", observedNode.toString());
     }
 
     /**
@@ -79,7 +79,7 @@ public class TopologyMappingTest {
         TpId source = new TpId("192.168.0.1");
         NodeConnector observedNodeConnector = TopologyMapping.toADNodeConnector(source, nodeId);
 
-        Assert.assertEquals("MD_SAL_DEPRECATED|192.168.0.1@MD_SAL_DEPRECATED|some_unknown_node", observedNodeConnector.toString());
+        assertEquals("MD_SAL_DEPRECATED|192.168.0.1@MD_SAL_DEPRECATED|some_unknown_node", observedNodeConnector.toString());
     }
 
 }
index 06538fd2ae157618a167ef3096f2777981f7bae3..2437bb4b7d381ff34a58138a14a7723ee7289a64 100644 (file)
@@ -13,6 +13,13 @@ import akka.actor.Props;
 import akka.japi.Creator;
 import com.google.common.base.Optional;
 import com.google.protobuf.ByteString;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.HashMap;
+import java.util.Map;
 import org.opendaylight.controller.cluster.DataPersistenceProvider;
 import org.opendaylight.controller.cluster.example.messages.KeyValue;
 import org.opendaylight.controller.cluster.example.messages.KeyValueSaved;
@@ -20,30 +27,24 @@ import org.opendaylight.controller.cluster.example.messages.PrintRole;
 import org.opendaylight.controller.cluster.example.messages.PrintState;
 import org.opendaylight.controller.cluster.raft.ConfigParams;
 import org.opendaylight.controller.cluster.raft.RaftActor;
+import org.opendaylight.controller.cluster.raft.RaftState;
 import org.opendaylight.controller.cluster.raft.base.messages.CaptureSnapshotReply;
+import org.opendaylight.controller.cluster.raft.behaviors.Leader;
 import org.opendaylight.controller.cluster.raft.protobuff.client.messages.Payload;
 
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.util.HashMap;
-import java.util.Map;
-
 /**
  * A sample actor showing how the RaftActor is to be extended
  */
 public class ExampleActor extends RaftActor {
 
-    private final Map<String, String> state = new HashMap();
+    private final Map<String, String> state = new HashMap<>();
     private final DataPersistenceProvider dataPersistenceProvider;
 
     private long persistIdentifier = 1;
 
 
-    public ExampleActor(String id, Map<String, String> peerAddresses,
-        Optional<ConfigParams> configParams) {
+    public ExampleActor(final String id, final Map<String, String> peerAddresses,
+        final Optional<ConfigParams> configParams) {
         super(id, peerAddresses, configParams);
         this.dataPersistenceProvider = new PersistentDataProvider();
     }
@@ -58,7 +59,7 @@ public class ExampleActor extends RaftActor {
         });
     }
 
-    @Override public void onReceiveCommand(Object message) throws Exception{
+    @Override public void onReceiveCommand(final Object message) throws Exception{
         if(message instanceof KeyValue){
             if(isLeader()) {
                 String persistId = Long.toString(persistIdentifier++);
@@ -77,7 +78,15 @@ public class ExampleActor extends RaftActor {
 
         } else if (message instanceof PrintRole) {
             if(LOG.isDebugEnabled()) {
-                LOG.debug("{} = {}, Peers={}", getId(), getRaftState(), getPeers());
+                String followers = "";
+                if (getRaftState() == RaftState.Leader) {
+                    followers = ((Leader)this.getCurrentBehavior()).printFollowerStates();
+                    LOG.debug("{} = {}, Peers={}, followers={}", getId(), getRaftState(), getPeers(), followers);
+                } else {
+                    LOG.debug("{} = {}, Peers={}", getId(), getRaftState(), getPeers());
+                }
+
+
             }
 
         } else {
@@ -85,8 +94,8 @@ public class ExampleActor extends RaftActor {
         }
     }
 
-    @Override protected void applyState(ActorRef clientActor, String identifier,
-        Object data) {
+    @Override protected void applyState(final ActorRef clientActor, final String identifier,
+        final Object data) {
         if(data instanceof KeyValue){
             KeyValue kv = (KeyValue) data;
             state.put(kv.getKey(), kv.getValue());
@@ -106,7 +115,7 @@ public class ExampleActor extends RaftActor {
         getSelf().tell(new CaptureSnapshotReply(bs), null);
     }
 
-    @Override protected void applySnapshot(ByteString snapshot) {
+    @Override protected void applySnapshot(final ByteString snapshot) {
         state.clear();
         try {
             state.putAll((HashMap) toObject(snapshot));
@@ -118,7 +127,7 @@ public class ExampleActor extends RaftActor {
         }
     }
 
-    private ByteString fromObject(Object snapshot) throws Exception {
+    private ByteString fromObject(final Object snapshot) throws Exception {
         ByteArrayOutputStream b = null;
         ObjectOutputStream o = null;
         try {
@@ -138,7 +147,7 @@ public class ExampleActor extends RaftActor {
         }
     }
 
-    private Object toObject(ByteString bs) throws ClassNotFoundException, IOException {
+    private Object toObject(final ByteString bs) throws ClassNotFoundException, IOException {
         Object obj = null;
         ByteArrayInputStream bis = null;
         ObjectInputStream ois = null;
@@ -166,7 +175,7 @@ public class ExampleActor extends RaftActor {
         return dataPersistenceProvider;
     }
 
-    @Override public void onReceiveRecover(Object message)throws Exception {
+    @Override public void onReceiveRecover(final Object message)throws Exception {
         super.onReceiveRecover(message);
     }
 
@@ -175,11 +184,11 @@ public class ExampleActor extends RaftActor {
     }
 
     @Override
-    protected void startLogRecoveryBatch(int maxBatchSize) {
+    protected void startLogRecoveryBatch(final int maxBatchSize) {
     }
 
     @Override
-    protected void appendRecoveredLogEntry(Payload data) {
+    protected void appendRecoveredLogEntry(final Payload data) {
     }
 
     @Override
@@ -191,6 +200,6 @@ public class ExampleActor extends RaftActor {
     }
 
     @Override
-    protected void applyRecoverySnapshot(ByteString snapshot) {
+    protected void applyRecoverySnapshot(final ByteString snapshot) {
     }
 }
index 6192cad2307b99896326619233bf9903f7aeb41a..2faae48838abfdb068504463ccb823b243a05891 100644 (file)
@@ -15,7 +15,7 @@ import org.opendaylight.controller.cluster.raft.DefaultConfigParamsImpl;
 public class ExampleConfigParamsImpl extends DefaultConfigParamsImpl {
     @Override
     public long getSnapshotBatchCount() {
-        return 50;
+        return 25;
     }
 
     @Override
index cb51a8951a54f158bac9b7bf1cab769662568fc3..f202a8bb1d6bc9c12b71c013fc0fd5e9daf990bf 100644 (file)
@@ -6,7 +6,6 @@ import com.google.common.base.Optional;
 import org.opendaylight.controller.cluster.example.messages.PrintRole;
 import org.opendaylight.controller.cluster.example.messages.PrintState;
 import org.opendaylight.controller.cluster.raft.ConfigParams;
-import org.opendaylight.controller.cluster.raft.client.messages.AddRaftPeer;
 
 import java.io.BufferedReader;
 import java.io.InputStreamReader;
@@ -35,7 +34,6 @@ public class TestDriver {
      * Commands
      *  bye
      *  createNodes:{num}
-     *  addNodes:{num}
      *  stopNode:{nodeName}
      *  reinstateNode:{nodeName}
      *  addClients:{num}
@@ -66,11 +64,6 @@ public class TestDriver {
                 int n = Integer.parseInt(arr[1]);
                 td.createNodes(n);
 
-            } else if (command.startsWith("addNodes")) {
-                String[] arr = command.split(":");
-                int n = Integer.parseInt(arr[1]);
-                td.addNodes(n);
-
             } else if (command.startsWith("addClients")) {
                 String[] arr = command.split(":");
                 int n = Integer.parseInt(arr[1]);
@@ -134,32 +127,6 @@ public class TestDriver {
         }
     }
 
-    // add new nodes , pass in the count
-    public void addNodes(int num) {
-        Map<String, String> newPeers = new HashMap<>();
-        for (int i=0; i < num; i++)  {
-            nameCounter = nameCounter + 1;
-            newPeers.put("example-"+nameCounter, "akka://default/user/example-"+nameCounter);
-            allPeers.put("example-"+nameCounter, "akka://default/user/example-"+nameCounter);
-
-        }
-        Map<String, ActorRef> newActorRefs = new HashMap<String, ActorRef>(num);
-        for (Map.Entry<String, String> entry : newPeers.entrySet())  {
-            ActorRef exampleActor = createExampleActor(entry.getKey());
-            newActorRefs.put(entry.getKey(), exampleActor);
-
-            //now also add these new nodes as peers from the previous nodes
-            for (ActorRef actor : actorRefs.values()) {
-                actor.tell(new AddRaftPeer(entry.getKey(), entry.getValue()), null);
-            }
-
-            System.out.println("Added node:" + entry);
-        }
-
-        actorRefs.putAll(newActorRefs);
-    }
-
-
     // add num clients to all nodes in the system
     public void addClients(int num) {
         for(Map.Entry<String,ActorRef> actorRefEntry : actorRefs.entrySet()) {
index 2be4a0c36f91bb41be4d21f79f928ef1c0bfe71f..a2c9d660ad8d2472f7b9a83ab3f175b1883ad1f6 100644 (file)
@@ -7,8 +7,6 @@
  */
 package org.opendaylight.controller.cluster.raft;
 
-import com.google.protobuf.ByteString;
-
 import java.util.ArrayList;
 import java.util.List;
 
@@ -20,27 +18,23 @@ public abstract class AbstractReplicatedLogImpl implements ReplicatedLog {
 
     // We define this as ArrayList so we can use ensureCapacity.
     protected ArrayList<ReplicatedLogEntry> journal;
-    protected ByteString snapshot;
+
     protected long snapshotIndex = -1;
     protected long snapshotTerm = -1;
 
     // to be used for rollback during save snapshot failure
     protected ArrayList<ReplicatedLogEntry> snapshottedJournal;
-    protected ByteString previousSnapshot;
     protected long previousSnapshotIndex = -1;
     protected long previousSnapshotTerm = -1;
 
-    public AbstractReplicatedLogImpl(ByteString state, long snapshotIndex,
+    public AbstractReplicatedLogImpl(long snapshotIndex,
         long snapshotTerm, List<ReplicatedLogEntry> unAppliedEntries) {
-        this.snapshot = state;
         this.snapshotIndex = snapshotIndex;
         this.snapshotTerm = snapshotTerm;
         this.journal = new ArrayList<>(unAppliedEntries);
     }
 
-
     public AbstractReplicatedLogImpl() {
-        this.snapshot = null;
         this.journal = new ArrayList<>();
     }
 
@@ -154,11 +148,6 @@ public abstract class AbstractReplicatedLogImpl implements ReplicatedLog {
         return logEntryIndex <= snapshotIndex && snapshotIndex != -1;
     }
 
-    @Override
-    public ByteString getSnapshot() {
-        return snapshot;
-    }
-
     @Override
     public long getSnapshotIndex() {
         return snapshotIndex;
@@ -185,18 +174,13 @@ public abstract class AbstractReplicatedLogImpl implements ReplicatedLog {
         this.snapshotTerm = snapshotTerm;
     }
 
-    @Override
-    public void setSnapshot(ByteString snapshot) {
-        this.snapshot = snapshot;
-    }
-
     @Override
     public void clear(int startIndex, int endIndex) {
         journal.subList(startIndex, endIndex).clear();
     }
 
     @Override
-    public void snapshotPreCommit(ByteString snapshot, long snapshotCapturedIndex, long snapshotCapturedTerm) {
+    public void snapshotPreCommit(long snapshotCapturedIndex, long snapshotCapturedTerm) {
         snapshottedJournal = new ArrayList<>(journal.size());
 
         snapshottedJournal.addAll(journal.subList(0, (int)(snapshotCapturedIndex - snapshotIndex)));
@@ -207,9 +191,6 @@ public abstract class AbstractReplicatedLogImpl implements ReplicatedLog {
 
         previousSnapshotTerm = snapshotTerm;
         setSnapshotTerm(snapshotCapturedTerm);
-
-        previousSnapshot = getSnapshot();
-        setSnapshot(snapshot);
     }
 
     @Override
@@ -217,7 +198,6 @@ public abstract class AbstractReplicatedLogImpl implements ReplicatedLog {
         snapshottedJournal = null;
         previousSnapshotIndex = -1;
         previousSnapshotTerm = -1;
-        previousSnapshot = null;
     }
 
     @Override
@@ -231,9 +211,5 @@ public abstract class AbstractReplicatedLogImpl implements ReplicatedLog {
 
         snapshotTerm = previousSnapshotTerm;
         previousSnapshotTerm = -1;
-
-        snapshot = previousSnapshot;
-        previousSnapshot = null;
-
     }
 }
index f3de9835385eb0880bb567402f5bb493f8ad3a76..2c4304d404a57ca919cb0c71f274588c6654f6e5 100644 (file)
@@ -61,5 +61,16 @@ public interface FollowerLogInformation {
      */
     public AtomicLong getMatchIndex();
 
+    /**
+     * Checks if the follower is active by comparing the last updated with the duration
+     * @return boolean
+     */
+    public boolean isFollowerActive();
+
+    /**
+     * restarts the timeout clock of the follower
+     */
+    public void markFollowerActive();
+
 
 }
index 94f9a53a850ae22537fe0607b5a16a1328b12532..c0cfd7e862e189b42036a246cc81f32e3d253e01 100644 (file)
@@ -8,6 +8,10 @@
 
 package org.opendaylight.controller.cluster.raft;
 
+import com.google.common.base.Stopwatch;
+import scala.concurrent.duration.FiniteDuration;
+
+import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicLong;
 
 public class FollowerLogInformationImpl implements FollowerLogInformation{
@@ -18,11 +22,17 @@ public class FollowerLogInformationImpl implements FollowerLogInformation{
 
     private final AtomicLong matchIndex;
 
+    private final Stopwatch stopwatch;
+
+    private final long followerTimeoutMillis;
+
     public FollowerLogInformationImpl(String id, AtomicLong nextIndex,
-        AtomicLong matchIndex) {
+        AtomicLong matchIndex, FiniteDuration followerTimeoutDuration) {
         this.id = id;
         this.nextIndex = nextIndex;
         this.matchIndex = matchIndex;
+        this.stopwatch = new Stopwatch();
+        this.followerTimeoutMillis = followerTimeoutDuration.toMillis();
     }
 
     public long incrNextIndex(){
@@ -57,4 +67,17 @@ public class FollowerLogInformationImpl implements FollowerLogInformation{
         return matchIndex;
     }
 
+    @Override
+    public boolean isFollowerActive() {
+        long elapsed = stopwatch.elapsed(TimeUnit.MILLISECONDS);
+        return (stopwatch.isRunning()) && (elapsed <= followerTimeoutMillis);
+    }
+
+    @Override
+    public void markFollowerActive() {
+        if (stopwatch.isRunning()) {
+            stopwatch.reset();
+        }
+        stopwatch.start();
+    }
 }
index 2459c2ff8b1764d3cd3b56be90fc7ea5191d65b6..617bb7e53407420b0963e932ab624a85bc98c636 100644 (file)
@@ -18,6 +18,7 @@ import akka.persistence.SaveSnapshotFailure;
 import akka.persistence.SaveSnapshotSuccess;
 import akka.persistence.SnapshotOffer;
 import akka.persistence.SnapshotSelectionCriteria;
+import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Optional;
 import com.google.common.base.Stopwatch;
 import com.google.protobuf.ByteString;
@@ -30,12 +31,12 @@ import org.opendaylight.controller.cluster.raft.base.messages.CaptureSnapshot;
 import org.opendaylight.controller.cluster.raft.base.messages.CaptureSnapshotReply;
 import org.opendaylight.controller.cluster.raft.base.messages.Replicate;
 import org.opendaylight.controller.cluster.raft.base.messages.SendHeartBeat;
+import org.opendaylight.controller.cluster.raft.base.messages.SendInstallSnapshot;
+import org.opendaylight.controller.cluster.raft.behaviors.AbstractRaftActorBehavior;
 import org.opendaylight.controller.cluster.raft.behaviors.Follower;
 import org.opendaylight.controller.cluster.raft.behaviors.RaftActorBehavior;
-import org.opendaylight.controller.cluster.raft.client.messages.AddRaftPeer;
 import org.opendaylight.controller.cluster.raft.client.messages.FindLeader;
 import org.opendaylight.controller.cluster.raft.client.messages.FindLeaderReply;
-import org.opendaylight.controller.cluster.raft.client.messages.RemoveRaftPeer;
 import org.opendaylight.controller.cluster.raft.messages.AppendEntriesReply;
 import org.opendaylight.controller.cluster.raft.protobuff.client.messages.Payload;
 import org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages;
@@ -340,20 +341,6 @@ public abstract class RaftActor extends AbstractUntypedPersistentActor {
                 context.getReplicatedLog().getSnapshotTerm(),
                 context.getReplicatedLog().size());
 
-        } else if (message instanceof AddRaftPeer){
-
-            // FIXME : Do not add raft peers like this.
-            // When adding a new Peer we have to ensure that the a majority of
-            // the peers know about the new Peer. Doing it this way may cause
-            // a situation where multiple Leaders may emerge
-            AddRaftPeer arp = (AddRaftPeer)message;
-           context.addToPeers(arp.getName(), arp.getAddress());
-
-        } else if (message instanceof RemoveRaftPeer){
-
-            RemoveRaftPeer rrp = (RemoveRaftPeer)message;
-            context.removePeer(rrp.getName());
-
         } else if (message instanceof CaptureSnapshot) {
             LOG.info("CaptureSnapshot received by actor");
             CaptureSnapshot cs = (CaptureSnapshot)message;
@@ -388,6 +375,7 @@ public abstract class RaftActor extends AbstractUntypedPersistentActor {
     }
 
     public java.util.Set<String> getPeers() {
+
         return context.getPeerAddresses().keySet();
     }
 
@@ -636,7 +624,7 @@ public abstract class RaftActor extends AbstractUntypedPersistentActor {
         //be greedy and remove entries from in-mem journal which are in the snapshot
         // and update snapshotIndex and snapshotTerm without waiting for the success,
 
-        context.getReplicatedLog().snapshotPreCommit(stateInBytes,
+        context.getReplicatedLog().snapshotPreCommit(
             captureSnapshot.getLastAppliedIndex(),
             captureSnapshot.getLastAppliedTerm());
 
@@ -644,16 +632,19 @@ public abstract class RaftActor extends AbstractUntypedPersistentActor {
             "and term:{}", captureSnapshot.getLastAppliedIndex(),
             captureSnapshot.getLastAppliedTerm());
 
+        if (isLeader() && captureSnapshot.isInstallSnapshotInitiated()) {
+            // this would be call straight to the leader and won't initiate in serialization
+            currentBehavior.handleMessage(getSelf(), new SendInstallSnapshot(stateInBytes));
+        }
+
         captureSnapshot = null;
         hasSnapshotCaptureInitiated = false;
     }
 
-
     private class ReplicatedLogImpl extends AbstractReplicatedLogImpl {
 
         public ReplicatedLogImpl(Snapshot snapshot) {
-            super(ByteString.copyFrom(snapshot.getState()),
-                snapshot.getLastAppliedIndex(), snapshot.getLastAppliedTerm(),
+            super(snapshot.getLastAppliedIndex(), snapshot.getLastAppliedTerm(),
                 snapshot.getUnAppliedEntries());
         }
 
@@ -843,4 +834,12 @@ public abstract class RaftActor extends AbstractUntypedPersistentActor {
         }
     }
 
+    @VisibleForTesting
+    void setCurrentBehavior(AbstractRaftActorBehavior behavior) {
+        currentBehavior = behavior;
+    }
+
+    protected RaftActorBehavior getCurrentBehavior() {
+        return currentBehavior;
+    }
 }
index 85893333c2892eadf43e9aacc374f574c1b4a03a..7ee85322a60f9ec93a4effc6e9379bd52d77a6ed 100644 (file)
@@ -8,8 +8,6 @@
 
 package org.opendaylight.controller.cluster.raft;
 
-import com.google.protobuf.ByteString;
-
 import java.util.List;
 
 /**
@@ -122,13 +120,6 @@ public interface ReplicatedLog {
      */
     boolean isInSnapshot(long index);
 
-    /**
-     * Get the snapshot
-     *
-     * @return an object representing the snapshot if it exists. null otherwise
-     */
-    ByteString getSnapshot();
-
     /**
      * Get the index of the snapshot
      *
@@ -156,12 +147,6 @@ public interface ReplicatedLog {
      */
     public void setSnapshotTerm(long snapshotTerm);
 
-    /**
-     * sets the snapshot in bytes
-     * @param snapshot
-     */
-    public void setSnapshot(ByteString snapshot);
-
     /**
      * Clears the journal entries with startIndex(inclusive) and endIndex (exclusive)
      * @param startIndex
@@ -172,12 +157,10 @@ public interface ReplicatedLog {
     /**
      * Handles all the bookkeeping in order to perform a rollback in the
      * event of SaveSnapshotFailure
-     * @param snapshot
      * @param snapshotCapturedIndex
      * @param snapshotCapturedTerm
      */
-    public void snapshotPreCommit(ByteString snapshot,
-        long snapshotCapturedIndex, long snapshotCapturedTerm);
+    public void snapshotPreCommit(long snapshotCapturedIndex, long snapshotCapturedTerm);
 
     /**
      * Sets the Replicated log to state after snapshot success.
index bb86e1a37d9e1b1bb481dbcf78c48792d9ce312b..d4dd3350f30b120bf965c885e3319152db9a2c38 100644 (file)
@@ -13,13 +13,20 @@ public class CaptureSnapshot {
     private long lastAppliedTerm;
     private long lastIndex;
     private long lastTerm;
+    private boolean installSnapshotInitiated;
 
     public CaptureSnapshot(long lastIndex, long lastTerm,
         long lastAppliedIndex, long lastAppliedTerm) {
+        this(lastIndex, lastTerm, lastAppliedIndex, lastAppliedTerm, false);
+    }
+
+    public CaptureSnapshot(long lastIndex, long lastTerm,long lastAppliedIndex,
+        long lastAppliedTerm, boolean installSnapshotInitiated) {
         this.lastIndex = lastIndex;
         this.lastTerm = lastTerm;
         this.lastAppliedIndex = lastAppliedIndex;
         this.lastAppliedTerm = lastAppliedTerm;
+        this.installSnapshotInitiated = installSnapshotInitiated;
     }
 
     public long getLastAppliedIndex() {
@@ -37,4 +44,8 @@ public class CaptureSnapshot {
     public long getLastTerm() {
         return lastTerm;
     }
+
+    public boolean isInstallSnapshotInitiated() {
+        return installSnapshotInitiated;
+    }
 }
diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/base/messages/InitiateInstallSnapshot.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/base/messages/InitiateInstallSnapshot.java
new file mode 100644 (file)
index 0000000..7844914
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.cluster.raft.base.messages;
+
+/**
+ * Internal message by Leader to initiate an install snapshot
+ */
+public class InitiateInstallSnapshot {
+}
+
index 6c3313f316623c10fcdf7468e1181d5941044201..83c85d9135a773541b40889ecf81453d9607833b 100644 (file)
@@ -8,7 +8,16 @@
 
 package org.opendaylight.controller.cluster.raft.base.messages;
 
-import java.io.Serializable;
+import com.google.protobuf.ByteString;
 
-public class SendInstallSnapshot implements Serializable {
+public class SendInstallSnapshot {
+    private ByteString snapshot;
+
+    public SendInstallSnapshot(ByteString snapshot) {
+        this.snapshot = snapshot;
+    }
+
+    public ByteString getSnapshot() {
+        return snapshot;
+    }
 }
index de748675a7aae0ce4ab617cc8d0d698725dd3e6c..ef104e7f58527a4be47bda4351e69f00e320786c 100644 (file)
@@ -11,6 +11,8 @@ package org.opendaylight.controller.cluster.raft.behaviors;
 import akka.actor.ActorRef;
 import akka.actor.ActorSelection;
 import akka.actor.Cancellable;
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.protobuf.ByteString;
 import org.opendaylight.controller.cluster.raft.ClientRequestTracker;
@@ -20,6 +22,8 @@ import org.opendaylight.controller.cluster.raft.FollowerLogInformationImpl;
 import org.opendaylight.controller.cluster.raft.RaftActorContext;
 import org.opendaylight.controller.cluster.raft.RaftState;
 import org.opendaylight.controller.cluster.raft.ReplicatedLogEntry;
+import org.opendaylight.controller.cluster.raft.base.messages.CaptureSnapshot;
+import org.opendaylight.controller.cluster.raft.base.messages.InitiateInstallSnapshot;
 import org.opendaylight.controller.cluster.raft.base.messages.Replicate;
 import org.opendaylight.controller.cluster.raft.base.messages.SendHeartBeat;
 import org.opendaylight.controller.cluster.raft.base.messages.SendInstallSnapshot;
@@ -66,8 +70,7 @@ import java.util.concurrent.atomic.AtomicLong;
 public class Leader extends AbstractRaftActorBehavior {
 
 
-    protected final Map<String, FollowerLogInformation> followerToLog =
-        new HashMap();
+    protected final Map<String, FollowerLogInformation> followerToLog = new HashMap();
     protected final Map<String, FollowerToSnapshot> mapFollowerToSnapshot = new HashMap<>();
 
     private final Set<String> followers;
@@ -79,6 +82,8 @@ public class Leader extends AbstractRaftActorBehavior {
 
     private final int minReplicationCount;
 
+    private Optional<ByteString> snapshot;
+
     public Leader(RaftActorContext context) {
         super(context);
 
@@ -88,7 +93,8 @@ public class Leader extends AbstractRaftActorBehavior {
             FollowerLogInformation followerLogInformation =
                 new FollowerLogInformationImpl(followerId,
                     new AtomicLong(context.getCommitIndex()),
-                    new AtomicLong(-1));
+                    new AtomicLong(-1),
+                    context.getConfigParams().getElectionTimeOutInterval());
 
             followerToLog.put(followerId, followerLogInformation);
         }
@@ -103,6 +109,7 @@ public class Leader extends AbstractRaftActorBehavior {
             minReplicationCount = 0;
         }
 
+        snapshot = Optional.absent();
 
         // Immediately schedule a heartbeat
         // Upon election: send initial empty AppendEntries RPCs
@@ -117,6 +124,15 @@ public class Leader extends AbstractRaftActorBehavior {
 
     }
 
+    private Optional<ByteString> getSnapshot() {
+        return snapshot;
+    }
+
+    @VisibleForTesting
+    void setSnapshot(Optional<ByteString> snapshot) {
+        this.snapshot = snapshot;
+    }
+
     @Override protected RaftActorBehavior handleAppendEntries(ActorRef sender,
         AppendEntries appendEntries) {
 
@@ -146,6 +162,8 @@ public class Leader extends AbstractRaftActorBehavior {
             return this;
         }
 
+        followerLogInformation.markFollowerActive();
+
         if (appendEntriesReply.isSuccess()) {
             followerLogInformation
                 .setMatchIndex(appendEntriesReply.getLogLastIndex());
@@ -246,10 +264,18 @@ public class Leader extends AbstractRaftActorBehavior {
             if (message instanceof SendHeartBeat) {
                 sendHeartBeat();
                 return this;
-            } else if(message instanceof SendInstallSnapshot) {
+
+            } else if(message instanceof InitiateInstallSnapshot) {
                 installSnapshotIfNeeded();
+
+            } else if(message instanceof SendInstallSnapshot) {
+                // received from RaftActor
+                setSnapshot(Optional.of(((SendInstallSnapshot) message).getSnapshot()));
+                sendInstallSnapshot();
+
             } else if (message instanceof Replicate) {
                 replicate((Replicate) message);
+
             } else if (message instanceof InstallSnapshotReply){
                 handleInstallSnapshotReply(
                     (InstallSnapshotReply) message);
@@ -263,8 +289,9 @@ public class Leader extends AbstractRaftActorBehavior {
 
     private void handleInstallSnapshotReply(InstallSnapshotReply reply) {
         String followerId = reply.getFollowerId();
-        FollowerToSnapshot followerToSnapshot =
-            mapFollowerToSnapshot.get(followerId);
+        FollowerToSnapshot followerToSnapshot = mapFollowerToSnapshot.get(followerId);
+        FollowerLogInformation followerLogInformation = followerToLog.get(followerId);
+        followerLogInformation.markFollowerActive();
 
         if (followerToSnapshot != null &&
             followerToSnapshot.getChunkIndex() == reply.getChunkIndex()) {
@@ -280,8 +307,6 @@ public class Leader extends AbstractRaftActorBehavior {
                         );
                     }
 
-                    FollowerLogInformation followerLogInformation =
-                        followerToLog.get(followerId);
                     followerLogInformation.setMatchIndex(
                         context.getReplicatedLog().getSnapshotIndex());
                     followerLogInformation.setNextIndex(
@@ -293,6 +318,12 @@ public class Leader extends AbstractRaftActorBehavior {
                             followerToLog.get(followerId).getNextIndex().get());
                     }
 
+                    if (mapFollowerToSnapshot.isEmpty()) {
+                        // once there are no pending followers receiving snapshots
+                        // we can remove snapshot from the memory
+                        setSnapshot(Optional.<ByteString>absent());
+                    }
+
                 } else {
                     followerToSnapshot.markSendStatus(true);
                 }
@@ -344,64 +375,87 @@ public class Leader extends AbstractRaftActorBehavior {
             if (followerActor != null) {
                 FollowerLogInformation followerLogInformation = followerToLog.get(followerId);
                 long followerNextIndex = followerLogInformation.getNextIndex().get();
-                List<ReplicatedLogEntry> entries = Collections.emptyList();
+                boolean isFollowerActive = followerLogInformation.isFollowerActive();
+                List<ReplicatedLogEntry> entries = null;
 
                 if (mapFollowerToSnapshot.get(followerId) != null) {
-                    if (mapFollowerToSnapshot.get(followerId).canSendNextChunk()) {
+                    // if install snapshot is in process , then sent next chunk if possible
+                    if (isFollowerActive && mapFollowerToSnapshot.get(followerId).canSendNextChunk()) {
                         sendSnapshotChunk(followerActor, followerId);
+                    } else {
+                        // we send a heartbeat even if we have not received a reply for the last chunk
+                        sendAppendEntriesToFollower(followerActor, followerNextIndex,
+                            Collections.<ReplicatedLogEntry>emptyList());
                     }
 
                 } else {
+                    long leaderLastIndex = context.getReplicatedLog().lastIndex();
+                    long leaderSnapShotIndex = context.getReplicatedLog().getSnapshotIndex();
 
-                    if (context.getReplicatedLog().isPresent(followerNextIndex)) {
+                    if (isFollowerActive &&
+                        context.getReplicatedLog().isPresent(followerNextIndex)) {
                         // FIXME : Sending one entry at a time
                         entries = context.getReplicatedLog().getFrom(followerNextIndex, 1);
 
-                        followerActor.tell(
-                            new AppendEntries(currentTerm(), context.getId(),
-                                prevLogIndex(followerNextIndex),
-                                prevLogTerm(followerNextIndex), entries,
-                                context.getCommitIndex()).toSerializable(),
-                            actor()
-                        );
-
-                    } else {
-                        // if the followers next index is not present in the leaders log, then snapshot should be sent
-                        long leaderSnapShotIndex = context.getReplicatedLog().getSnapshotIndex();
-                        long leaderLastIndex = context.getReplicatedLog().lastIndex();
-                        if (followerNextIndex >= 0 && leaderLastIndex >= followerNextIndex ) {
-                            // if the follower is just not starting and leader's index
-                            // is more than followers index
-                            if(LOG.isDebugEnabled()) {
-                                LOG.debug("SendInstallSnapshot to follower:{}," +
-                                        "follower-nextIndex:{}, leader-snapshot-index:{},  " +
-                                        "leader-last-index:{}", followerId,
-                                    followerNextIndex, leaderSnapShotIndex, leaderLastIndex
-                                );
-                            }
-
-                            actor().tell(new SendInstallSnapshot(), actor());
-                        } else {
-                            followerActor.tell(
-                                new AppendEntries(currentTerm(), context.getId(),
-                                    prevLogIndex(followerNextIndex),
-                                    prevLogTerm(followerNextIndex), entries,
-                                    context.getCommitIndex()).toSerializable(),
-                                actor()
+                    } else if (isFollowerActive && followerNextIndex >= 0 &&
+                        leaderLastIndex >= followerNextIndex ) {
+                        // if the followers next index is not present in the leaders log, and
+                        // if the follower is just not starting and if leader's index is more than followers index
+                        // then snapshot should be sent
+
+                        if(LOG.isDebugEnabled()) {
+                            LOG.debug("InitiateInstallSnapshot to follower:{}," +
+                                    "follower-nextIndex:{}, leader-snapshot-index:{},  " +
+                                    "leader-last-index:{}", followerId,
+                                followerNextIndex, leaderSnapShotIndex, leaderLastIndex
                             );
                         }
+                        actor().tell(new InitiateInstallSnapshot(), actor());
+
+                        // we would want to sent AE as the capture snapshot might take time
+                        entries =  Collections.<ReplicatedLogEntry>emptyList();
+
+                    } else {
+                        //we send an AppendEntries, even if the follower is inactive
+                        // in-order to update the followers timestamp, in case it becomes active again
+                        entries =  Collections.<ReplicatedLogEntry>emptyList();
                     }
+
+                    sendAppendEntriesToFollower(followerActor, followerNextIndex, entries);
+
                 }
             }
         }
     }
 
+    private void sendAppendEntriesToFollower(ActorSelection followerActor, long followerNextIndex,
+        List<ReplicatedLogEntry> entries) {
+        followerActor.tell(
+            new AppendEntries(currentTerm(), context.getId(),
+                prevLogIndex(followerNextIndex),
+                prevLogTerm(followerNextIndex), entries,
+                context.getCommitIndex()).toSerializable(),
+            actor()
+        );
+    }
+
     /**
      * An installSnapshot is scheduled at a interval that is a multiple of
      * a HEARTBEAT_INTERVAL. This is to avoid the need to check for installing
      * snapshots at every heartbeat.
+     *
+     * Install Snapshot works as follows
+     * 1. Leader sends a InitiateInstallSnapshot message to self
+     * 2. Leader then initiates the capture snapshot by sending a CaptureSnapshot message to actor
+     * 3. RaftActor on receipt of the CaptureSnapshotReply (from Shard), stores the received snapshot in the replicated log
+     * and makes a call to Leader's handleMessage , with SendInstallSnapshot message.
+     * 4. Leader , picks the snapshot from im-mem ReplicatedLog and sends it in chunks to the Follower
+     * 5. On complete, Follower sends back a InstallSnapshotReply.
+     * 6. On receipt of the InstallSnapshotReply for the last chunk, Leader marks the install complete for that follower
+     * and replenishes the memory by deleting the snapshot in Replicated log.
+     *
      */
-    private void installSnapshotIfNeeded(){
+    private void installSnapshotIfNeeded() {
         for (String followerId : followers) {
             ActorSelection followerActor =
                 context.getPeerActorSelection(followerId);
@@ -412,6 +466,58 @@ public class Leader extends AbstractRaftActorBehavior {
 
                 long nextIndex = followerLogInformation.getNextIndex().get();
 
+                if (!context.getReplicatedLog().isPresent(nextIndex) &&
+                    context.getReplicatedLog().isInSnapshot(nextIndex)) {
+                    LOG.info("{} follower needs a snapshot install", followerId);
+                    if (snapshot.isPresent()) {
+                        // if a snapshot is present in the memory, most likely another install is in progress
+                        // no need to capture snapshot
+                        sendSnapshotChunk(followerActor, followerId);
+
+                    } else {
+                        initiateCaptureSnapshot();
+                        //we just need 1 follower who would need snapshot to be installed.
+                        // when we have the snapshot captured, we would again check (in SendInstallSnapshot)
+                        // who needs an install and send to all who need
+                        break;
+                    }
+
+                }
+            }
+        }
+    }
+
+    // on every install snapshot, we try to capture the snapshot.
+    // Once a capture is going on, another one issued will get ignored by RaftActor.
+    private void initiateCaptureSnapshot() {
+        LOG.info("Initiating Snapshot Capture to Install Snapshot, Leader:{}", getLeaderId());
+        ReplicatedLogEntry lastAppliedEntry = context.getReplicatedLog().get(context.getLastApplied());
+        long lastAppliedIndex = -1;
+        long lastAppliedTerm = -1;
+
+        if (lastAppliedEntry != null) {
+            lastAppliedIndex = lastAppliedEntry.getIndex();
+            lastAppliedTerm = lastAppliedEntry.getTerm();
+        } else if (context.getReplicatedLog().getSnapshotIndex() > -1)  {
+            lastAppliedIndex = context.getReplicatedLog().getSnapshotIndex();
+            lastAppliedTerm = context.getReplicatedLog().getSnapshotTerm();
+        }
+
+        boolean isInstallSnapshotInitiated = true;
+        actor().tell(new CaptureSnapshot(lastIndex(), lastTerm(),
+                lastAppliedIndex, lastAppliedTerm, isInstallSnapshotInitiated),
+            actor());
+    }
+
+
+    private void sendInstallSnapshot() {
+        for (String followerId : followers) {
+            ActorSelection followerActor = context.getPeerActorSelection(followerId);
+
+            if(followerActor != null) {
+                FollowerLogInformation followerLogInformation = followerToLog.get(followerId);
+                long nextIndex = followerLogInformation.getNextIndex().get();
+
                 if (!context.getReplicatedLog().isPresent(nextIndex) &&
                     context.getReplicatedLog().isInSnapshot(nextIndex)) {
                     sendSnapshotChunk(followerActor, followerId);
@@ -426,20 +532,21 @@ public class Leader extends AbstractRaftActorBehavior {
      */
     private void sendSnapshotChunk(ActorSelection followerActor, String followerId) {
         try {
-            followerActor.tell(
-                new InstallSnapshot(currentTerm(), context.getId(),
-                    context.getReplicatedLog().getSnapshotIndex(),
-                    context.getReplicatedLog().getSnapshotTerm(),
-                    getNextSnapshotChunk(followerId,
-                        context.getReplicatedLog().getSnapshot()),
-                    mapFollowerToSnapshot.get(followerId).incrementChunkIndex(),
-                    mapFollowerToSnapshot.get(followerId).getTotalChunks()
-                ).toSerializable(),
-                actor()
-            );
-            LOG.info("InstallSnapshot sent to follower {}, Chunk: {}/{}",
-                followerActor.path(), mapFollowerToSnapshot.get(followerId).getChunkIndex(),
-                mapFollowerToSnapshot.get(followerId).getTotalChunks());
+            if (snapshot.isPresent()) {
+                followerActor.tell(
+                    new InstallSnapshot(currentTerm(), context.getId(),
+                        context.getReplicatedLog().getSnapshotIndex(),
+                        context.getReplicatedLog().getSnapshotTerm(),
+                        getNextSnapshotChunk(followerId,snapshot.get()),
+                        mapFollowerToSnapshot.get(followerId).incrementChunkIndex(),
+                        mapFollowerToSnapshot.get(followerId).getTotalChunks()
+                    ).toSerializable(),
+                    actor()
+                );
+                LOG.info("InstallSnapshot sent to follower {}, Chunk: {}/{}",
+                    followerActor.path(), mapFollowerToSnapshot.get(followerId).getChunkIndex(),
+                    mapFollowerToSnapshot.get(followerId).getTotalChunks());
+            }
         } catch (IOException e) {
             LOG.error(e, "InstallSnapshot failed for Leader.");
         }
@@ -456,10 +563,9 @@ public class Leader extends AbstractRaftActorBehavior {
             mapFollowerToSnapshot.put(followerId, followerToSnapshot);
         }
         ByteString nextChunk = followerToSnapshot.getNextChunk();
-        if(LOG.isDebugEnabled()) {
+        if (LOG.isDebugEnabled()) {
             LOG.debug("Leader's snapshot nextChunk size:{}", nextChunk.size());
         }
-
         return nextChunk;
     }
 
@@ -495,14 +601,11 @@ public class Leader extends AbstractRaftActorBehavior {
         // Scheduling the heartbeat only once here because heartbeats do not
         // need to be sent if there are other messages being sent to the remote
         // actor.
-        heartbeatSchedule =
-            context.getActorSystem().scheduler().scheduleOnce(
-                interval,
-                context.getActor(), new SendHeartBeat(),
-                context.getActorSystem().dispatcher(), context.getActor());
+        heartbeatSchedule = context.getActorSystem().scheduler().scheduleOnce(
+            interval, context.getActor(), new SendHeartBeat(),
+            context.getActorSystem().dispatcher(), context.getActor());
     }
 
-
     private void scheduleInstallSnapshotCheck(FiniteDuration interval) {
         if(followers.size() == 0){
             // Optimization - do not bother scheduling a heartbeat as there are
@@ -517,7 +620,7 @@ public class Leader extends AbstractRaftActorBehavior {
         installSnapshotSchedule =
             context.getActorSystem().scheduler().scheduleOnce(
                 interval,
-                context.getActor(), new SendInstallSnapshot(),
+                context.getActor(), new InitiateInstallSnapshot(),
                 context.getActorSystem().dispatcher(), context.getActor());
     }
 
@@ -628,4 +731,19 @@ public class Leader extends AbstractRaftActorBehavior {
         }
     }
 
+    // called from example-actor for printing the follower-states
+    public String printFollowerStates() {
+        StringBuilder sb = new StringBuilder();
+        for(FollowerLogInformation followerLogInformation : followerToLog.values()) {
+            boolean isFollowerActive = followerLogInformation.isFollowerActive();
+            sb.append("{"+followerLogInformation.getId() + " state:" + isFollowerActive + "},");
+
+        }
+        return "[" + sb.toString() + "]";
+    }
+
+    @VisibleForTesting
+    void markFollowerActive(String followerId) {
+        followerToLog.get(followerId).markFollowerActive();
+    }
 }
diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/client/messages/AddRaftPeer.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/client/messages/AddRaftPeer.java
deleted file mode 100644 (file)
index d1f4c43..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-package org.opendaylight.controller.cluster.raft.client.messages;
-
-/**
- * Created by kramesha on 7/17/14.
- */
-public class AddRaftPeer {
-
-    private String name;
-    private String address;
-
-    public AddRaftPeer(String name, String address) {
-        this.name = name;
-        this.address = address;
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    public String getAddress() {
-        return address;
-    }
-}
diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/client/messages/RemoveRaftPeer.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/client/messages/RemoveRaftPeer.java
deleted file mode 100644 (file)
index 4b766e0..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-package org.opendaylight.controller.cluster.raft.client.messages;
-
-/**
- * Created by kramesha on 7/17/14.
- */
-public class RemoveRaftPeer {
-    private String name;
-
-    public RemoveRaftPeer(String name) {
-        this.name = name;
-    }
-
-    public String getName() {
-        return name;
-    }
-}
index 913665861d6f694dbb01c51d96978c05d6e9c5ea..398a2e9b3651de7846eb36830b5b3410f71a254f 100644 (file)
@@ -7,21 +7,19 @@
  */
 package org.opendaylight.controller.cluster.raft;
 
-import junit.framework.Assert;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
-import static org.opendaylight.controller.cluster.raft.MockRaftActorContext.MockPayload;
-import static org.opendaylight.controller.cluster.raft.MockRaftActorContext.MockReplicatedLogEntry;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.controller.cluster.raft.MockRaftActorContext.MockPayload;
+import org.opendaylight.controller.cluster.raft.MockRaftActorContext.MockReplicatedLogEntry;
 /**
 *
 */
@@ -65,7 +63,7 @@ public class AbstractReplicatedLogImplTest {
         // now create a snapshot of 3 entries, with 1 unapplied entry left in the log
         // It removes the entries which have made it to snapshot
         // and updates the snapshot index and term
-        Map state = takeSnapshot(3);
+        Map<Long, String> state = takeSnapshot(3);
 
         // check the values after the snapshot.
         // each index value passed in the test is the logical index (log entry index)
@@ -131,8 +129,8 @@ public class AbstractReplicatedLogImplTest {
     }
 
     // create a snapshot for test
-    public Map takeSnapshot(int numEntries) {
-        Map map = new HashMap(numEntries);
+    public Map<Long, String> takeSnapshot(final int numEntries) {
+        Map<Long, String> map = new HashMap<>(numEntries);
         List<ReplicatedLogEntry> entries = replicatedLogImpl.getEntriesTill(numEntries);
         for (ReplicatedLogEntry entry : entries) {
             map.put(entry.getIndex(), entry.getData().toString());
@@ -149,22 +147,24 @@ public class AbstractReplicatedLogImplTest {
     }
     class MockAbstractReplicatedLogImpl extends AbstractReplicatedLogImpl {
         @Override
-        public void appendAndPersist(ReplicatedLogEntry replicatedLogEntry) {
+        public void appendAndPersist(final ReplicatedLogEntry replicatedLogEntry) {
         }
 
         @Override
-        public void removeFromAndPersist(long index) {
+        public void removeFromAndPersist(final long index) {
         }
 
-        public void setSnapshotIndex(long snapshotIndex) {
+        @Override
+        public void setSnapshotIndex(final long snapshotIndex) {
             this.snapshotIndex = snapshotIndex;
         }
 
-        public void setSnapshotTerm(long snapshotTerm) {
+        @Override
+        public void setSnapshotTerm(final long snapshotTerm) {
             this.snapshotTerm = snapshotTerm;
         }
 
-        public List<ReplicatedLogEntry> getEntriesTill(int index) {
+        public List<ReplicatedLogEntry> getEntriesTill(final int index) {
             return journal.subList(0, index);
         }
     }
diff --git a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/FollowerLogInformationImplTest.java b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/FollowerLogInformationImplTest.java
new file mode 100644 (file)
index 0000000..7df9f37
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.cluster.raft;
+
+
+import com.google.common.base.Stopwatch;
+import com.google.common.util.concurrent.Uninterruptibles;
+import org.junit.Test;
+import scala.concurrent.duration.FiniteDuration;
+
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicLong;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class FollowerLogInformationImplTest {
+
+    @Test
+    public void testIsFollowerActive() {
+
+        FiniteDuration timeoutDuration =
+            new FiniteDuration(500, TimeUnit.MILLISECONDS);
+
+        FollowerLogInformation followerLogInformation =
+            new FollowerLogInformationImpl(
+                "follower1", new AtomicLong(10), new AtomicLong(9), timeoutDuration);
+
+
+
+        assertFalse("Follower should be termed inactive before stopwatch starts",
+            followerLogInformation.isFollowerActive());
+
+        followerLogInformation.markFollowerActive();
+        if (sleepWithElaspsedTimeReturned(200) > 200) {
+          return;
+        }
+        assertTrue("Follower should be active", followerLogInformation.isFollowerActive());
+
+        if (sleepWithElaspsedTimeReturned(400) > 400) {
+            return;
+        }
+        assertFalse("Follower should be inactive after time lapsed",
+            followerLogInformation.isFollowerActive());
+
+        followerLogInformation.markFollowerActive();
+        assertTrue("Follower should be active from inactive",
+            followerLogInformation.isFollowerActive());
+    }
+
+    // we cannot rely comfortably that the sleep will indeed sleep for the desired time
+    // hence getting the actual elapsed time and do a match.
+    // if the sleep has spilled over, then return the test gracefully
+    private long sleepWithElaspsedTimeReturned(long millis) {
+        Stopwatch stopwatch = new Stopwatch();
+        stopwatch.start();
+        Uninterruptibles.sleepUninterruptibly(millis, TimeUnit.MILLISECONDS);
+        stopwatch.stop();
+        return stopwatch.elapsed(TimeUnit.MILLISECONDS);
+    }
+}
index ca864eb426ca48925b4abc27d0fed75e9bde7ebc..87e40f236cf5c6dfee6e03ea711d61d342d9b345 100644 (file)
@@ -31,6 +31,8 @@ import org.opendaylight.controller.cluster.raft.base.messages.ApplySnapshot;
 import org.opendaylight.controller.cluster.raft.base.messages.ApplyState;
 import org.opendaylight.controller.cluster.raft.base.messages.CaptureSnapshot;
 import org.opendaylight.controller.cluster.raft.base.messages.CaptureSnapshotReply;
+import org.opendaylight.controller.cluster.raft.behaviors.Follower;
+import org.opendaylight.controller.cluster.raft.behaviors.Leader;
 import org.opendaylight.controller.cluster.raft.client.messages.FindLeader;
 import org.opendaylight.controller.cluster.raft.client.messages.FindLeaderReply;
 import org.opendaylight.controller.cluster.raft.protobuff.client.messages.Payload;
@@ -557,7 +559,6 @@ public class RaftActorTest extends AbstractActorTest {
 
                 config.setHeartBeatInterval(new FiniteDuration(1, TimeUnit.DAYS));
 
-
                 DataPersistenceProvider dataPersistenceProvider = mock(DataPersistenceProvider.class);
 
                 TestActorRef<MockRaftActor> mockActorRef = TestActorRef.create(getSystem(), MockRaftActor.props(persistenceId,
@@ -600,7 +601,6 @@ public class RaftActorTest extends AbstractActorTest {
 
                 verify(dataPersistenceProvider, times(2)).persist(anyObject(), any(Procedure.class));
 
-
                 mockActorRef.tell(PoisonPill.getInstance(), getRef());
 
             }
@@ -646,8 +646,9 @@ public class RaftActorTest extends AbstractActorTest {
 
                 DataPersistenceProvider dataPersistenceProvider = mock(DataPersistenceProvider.class);
 
-                TestActorRef<MockRaftActor> mockActorRef = TestActorRef.create(getSystem(), MockRaftActor.props(persistenceId,
-                        Collections.EMPTY_MAP, Optional.<ConfigParams>of(config), dataPersistenceProvider), persistenceId);
+                TestActorRef<MockRaftActor> mockActorRef = TestActorRef.create(getSystem(),
+                    MockRaftActor.props(persistenceId,Collections.EMPTY_MAP,
+                        Optional.<ConfigParams>of(config), dataPersistenceProvider), persistenceId);
 
                 MockRaftActor mockRaftActor = mockActorRef.underlyingActor();
 
@@ -659,6 +660,10 @@ public class RaftActorTest extends AbstractActorTest {
 
                 mockRaftActor.onReceiveCommand(new CaptureSnapshot(-1,1,-1,1));
 
+                RaftActorContext raftActorContext = mockRaftActor.getRaftActorContext();
+
+                mockRaftActor.setCurrentBehavior(new Leader(raftActorContext));
+
                 mockRaftActor.onReceiveCommand(new CaptureSnapshotReply(snapshotBytes));
 
                 verify(dataPersistenceProvider).saveSnapshot(anyObject());
@@ -698,6 +703,9 @@ public class RaftActorTest extends AbstractActorTest {
                         new MockRaftActorContext.MockPayload("C"),
                         new MockRaftActorContext.MockPayload("D")));
 
+                RaftActorContext raftActorContext = mockRaftActor.getRaftActorContext();
+                mockRaftActor.setCurrentBehavior(new Follower(raftActorContext));
+
                 mockRaftActor.onReceiveCommand(new CaptureSnapshot(-1, 1, 2, 1));
 
                 verify(mockRaftActor.delegate).createSnapshot();
@@ -710,8 +718,6 @@ public class RaftActorTest extends AbstractActorTest {
 
                 verify(dataPersistenceProvider).deleteMessages(100);
 
-                assertNotNull("Snapshot should not be null", mockRaftActor.getReplicatedLog().getSnapshot());
-
                 assertEquals(2, mockRaftActor.getReplicatedLog().size());
 
                 assertNotNull(mockRaftActor.getReplicatedLog().get(3));
@@ -755,8 +761,6 @@ public class RaftActorTest extends AbstractActorTest {
 
             }
         };
-
-
     }
 
     @Test
@@ -780,13 +784,15 @@ public class RaftActorTest extends AbstractActorTest {
 
                 oldReplicatedLog.append(new MockRaftActorContext.MockReplicatedLogEntry(1,0,mock(Payload.class)));
                 oldReplicatedLog.append(new MockRaftActorContext.MockReplicatedLogEntry(1,1,mock(Payload.class)));
-                oldReplicatedLog.append(new MockRaftActorContext.MockReplicatedLogEntry(1,2,mock(Payload.class)));
+                oldReplicatedLog.append(
+                    new MockRaftActorContext.MockReplicatedLogEntry(1, 2,
+                        mock(Payload.class)));
 
                 ByteString snapshotBytes = fromObject(Arrays.asList(
-                        new MockRaftActorContext.MockPayload("A"),
-                        new MockRaftActorContext.MockPayload("B"),
-                        new MockRaftActorContext.MockPayload("C"),
-                        new MockRaftActorContext.MockPayload("D")));
+                    new MockRaftActorContext.MockPayload("A"),
+                    new MockRaftActorContext.MockPayload("B"),
+                    new MockRaftActorContext.MockPayload("C"),
+                    new MockRaftActorContext.MockPayload("D")));
 
                 Snapshot snapshot = mock(Snapshot.class);
 
@@ -798,9 +804,11 @@ public class RaftActorTest extends AbstractActorTest {
 
                 verify(mockRaftActor.delegate).applySnapshot(eq(snapshotBytes));
 
-                assertTrue("The replicatedLog should have changed", oldReplicatedLog != mockRaftActor.getReplicatedLog());
+                assertTrue("The replicatedLog should have changed",
+                    oldReplicatedLog != mockRaftActor.getReplicatedLog());
 
-                assertEquals("lastApplied should be same as in the snapshot", (Long) 3L, mockRaftActor.getLastApplied());
+                assertEquals("lastApplied should be same as in the snapshot",
+                    (Long) 3L, mockRaftActor.getLastApplied());
 
                 assertEquals(0, mockRaftActor.getReplicatedLog().size());
 
@@ -833,6 +841,10 @@ public class RaftActorTest extends AbstractActorTest {
                         new MockRaftActorContext.MockPayload("C"),
                         new MockRaftActorContext.MockPayload("D")));
 
+                RaftActorContext raftActorContext = mockRaftActor.getRaftActorContext();
+
+                mockRaftActor.setCurrentBehavior(new Leader(raftActorContext));
+
                 mockRaftActor.onReceiveCommand(new CaptureSnapshot(-1,1,-1,1));
 
                 mockRaftActor.onReceiveCommand(new CaptureSnapshotReply(snapshotBytes));
@@ -843,8 +855,6 @@ public class RaftActorTest extends AbstractActorTest {
                 assertEquals("Snapshot index should not have advanced because save snapshot failed", -1,
                         mockRaftActor.getReplicatedLog().getSnapshotIndex());
 
-                assertNull("Snapshot should be null", mockRaftActor.getReplicatedLog().getSnapshot());
-
                 mockActorRef.tell(PoisonPill.getInstance(), getRef());
 
             }
index a8d47e2c60239a9a7f796a5afe93f7df0ef57d96..fb02481115d81320f042198d5b3ed3962713306f 100644 (file)
@@ -3,7 +3,7 @@ package org.opendaylight.controller.cluster.raft.behaviors;
 import akka.actor.ActorRef;
 import akka.actor.Props;
 import akka.testkit.JavaTestKit;
-import junit.framework.Assert;
+import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.controller.cluster.raft.DefaultConfigParamsImpl;
index edeab11e2a6421cfdbafc7661ddca1e5b059ac7c..83b9ad3ec7b7a5c7033f876c45d4db2788f50716 100644 (file)
@@ -4,7 +4,6 @@ import akka.actor.ActorRef;
 import akka.actor.Props;
 import akka.testkit.JavaTestKit;
 import com.google.protobuf.ByteString;
-import junit.framework.Assert;
 import org.junit.Test;
 import org.opendaylight.controller.cluster.raft.DefaultConfigParamsImpl;
 import org.opendaylight.controller.cluster.raft.MockRaftActorContext;
@@ -87,7 +86,7 @@ public class FollowerTest extends AbstractRaftActorBehaviorTest {
         RaftActorBehavior raftBehavior =
             follower.handleMessage(followerActor, new ElectionTimeout());
 
-        Assert.assertTrue(raftBehavior instanceof Candidate);
+        assertTrue(raftBehavior instanceof Candidate);
     }
 
     @Test
index 030b4b23763a15807f1e3ec143ea1f39bcc9c731..705c69607c658d16d03086b573230923e2ba05b4 100644 (file)
@@ -1,15 +1,14 @@
 package org.opendaylight.controller.cluster.raft.behaviors;
 
 import akka.actor.ActorRef;
-import akka.actor.ActorSystem;
 import akka.actor.Props;
 import akka.testkit.JavaTestKit;
+import com.google.common.base.Optional;
 import com.google.protobuf.ByteString;
 import org.junit.Assert;
 import org.junit.Test;
 import org.opendaylight.controller.cluster.raft.DefaultConfigParamsImpl;
 import org.opendaylight.controller.cluster.raft.FollowerLogInformation;
-import org.opendaylight.controller.cluster.raft.FollowerLogInformationImpl;
 import org.opendaylight.controller.cluster.raft.MockRaftActorContext;
 import org.opendaylight.controller.cluster.raft.RaftActorContext;
 import org.opendaylight.controller.cluster.raft.RaftState;
@@ -17,6 +16,8 @@ import org.opendaylight.controller.cluster.raft.ReplicatedLogImplEntry;
 import org.opendaylight.controller.cluster.raft.SerializationUtils;
 import org.opendaylight.controller.cluster.raft.base.messages.ApplyLogEntries;
 import org.opendaylight.controller.cluster.raft.base.messages.ApplyState;
+import org.opendaylight.controller.cluster.raft.base.messages.CaptureSnapshot;
+import org.opendaylight.controller.cluster.raft.base.messages.InitiateInstallSnapshot;
 import org.opendaylight.controller.cluster.raft.base.messages.Replicate;
 import org.opendaylight.controller.cluster.raft.base.messages.SendHeartBeat;
 import org.opendaylight.controller.cluster.raft.base.messages.SendInstallSnapshot;
@@ -29,6 +30,7 @@ import org.opendaylight.controller.cluster.raft.utils.DoNothingActor;
 import org.opendaylight.controller.cluster.raft.utils.MessageCollectorActor;
 import org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages;
 import org.opendaylight.controller.protobuff.messages.cluster.raft.InstallSnapshotMessages;
+import scala.concurrent.duration.FiniteDuration;
 
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
@@ -36,7 +38,7 @@ import java.io.ObjectOutputStream;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.concurrent.atomic.AtomicLong;
+import java.util.concurrent.TimeUnit;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
@@ -72,8 +74,7 @@ public class LeaderTest extends AbstractRaftActorBehaviorTest {
 
                     ActorRef followerActor = getTestActor();
 
-                    MockRaftActorContext actorContext =
-                        (MockRaftActorContext) createActorContext();
+                    MockRaftActorContext actorContext = (MockRaftActorContext) createActorContext();
 
                     Map<String, String> peerAddresses = new HashMap();
 
@@ -155,10 +156,7 @@ public class LeaderTest extends AbstractRaftActorBehaviorTest {
                         }.get(); // this extracts the received message
 
                     assertEquals("match", out);
-
                 }
-
-
             };
         }};
     }
@@ -214,229 +212,360 @@ public class LeaderTest extends AbstractRaftActorBehaviorTest {
     }
 
     @Test
-    public void testSendInstallSnapshot() {
-        new LeaderTestKit(getSystem()) {{
+    public void testSendAppendEntriesOnAnInProgressInstallSnapshot() throws Exception {
+        new JavaTestKit(getSystem()) {{
+            ActorRef followerActor = getSystem().actorOf(Props.create(MessageCollectorActor.class));
 
-            new Within(duration("1 seconds")) {
-                protected void run() {
-                    ActorRef followerActor = getTestActor();
+            Map<String, String> peerAddresses = new HashMap();
+            peerAddresses.put(followerActor.path().toString(),
+                followerActor.path().toString());
 
-                    Map<String, String> peerAddresses = new HashMap();
-                    peerAddresses.put(followerActor.path().toString(),
-                        followerActor.path().toString());
+            MockRaftActorContext actorContext =
+                (MockRaftActorContext) createActorContext(leaderActor);
+            actorContext.setPeerAddresses(peerAddresses);
 
+            Map<String, String> leadersSnapshot = new HashMap<>();
+            leadersSnapshot.put("1", "A");
+            leadersSnapshot.put("2", "B");
+            leadersSnapshot.put("3", "C");
 
-                    MockRaftActorContext actorContext =
-                        (MockRaftActorContext) createActorContext(getRef());
-                    actorContext.setPeerAddresses(peerAddresses);
+            //clears leaders log
+            actorContext.getReplicatedLog().removeFrom(0);
 
+            final int followersLastIndex = 2;
+            final int snapshotIndex = 3;
+            final int newEntryIndex = 4;
+            final int snapshotTerm = 1;
+            final int currentTerm = 2;
 
-                    Map<String, String> leadersSnapshot = new HashMap<>();
-                    leadersSnapshot.put("1", "A");
-                    leadersSnapshot.put("2", "B");
-                    leadersSnapshot.put("3", "C");
+            // set the snapshot variables in replicatedlog
+            actorContext.getReplicatedLog().setSnapshotIndex(snapshotIndex);
+            actorContext.getReplicatedLog().setSnapshotTerm(snapshotTerm);
+            actorContext.setCommitIndex(followersLastIndex);
+            //set follower timeout to 2 mins, helps during debugging
+            actorContext.setConfigParams(new MockConfigParamsImpl(120000L, 10));
 
-                    //clears leaders log
-                    actorContext.getReplicatedLog().removeFrom(0);
+            MockLeader leader = new MockLeader(actorContext);
 
-                    final int followersLastIndex = 2;
-                    final int snapshotIndex = 3;
-                    final int newEntryIndex = 4;
-                    final int snapshotTerm = 1;
-                    final int currentTerm = 2;
+            // new entry
+            ReplicatedLogImplEntry entry =
+                new ReplicatedLogImplEntry(newEntryIndex, currentTerm,
+                    new MockRaftActorContext.MockPayload("D"));
 
-                    // set the snapshot variables in replicatedlog
-                    actorContext.getReplicatedLog().setSnapshot(
-                        toByteString(leadersSnapshot));
-                    actorContext.getReplicatedLog().setSnapshotIndex(snapshotIndex);
-                    actorContext.getReplicatedLog().setSnapshotTerm(snapshotTerm);
+            //update follower timestamp
+            leader.markFollowerActive(followerActor.path().toString());
 
-                    MockLeader leader = new MockLeader(actorContext);
-                    // set the follower info in leader
-                    leader.addToFollowerToLog(followerActor.path().toString(), followersLastIndex, -1);
+            ByteString bs = toByteString(leadersSnapshot);
+            leader.setSnapshot(Optional.of(bs));
+            leader.createFollowerToSnapshot(followerActor.path().toString(), bs);
 
-                    // new entry
-                    ReplicatedLogImplEntry entry =
-                        new ReplicatedLogImplEntry(newEntryIndex, currentTerm,
-                            new MockRaftActorContext.MockPayload("D"));
+            //send first chunk and no InstallSnapshotReply received yet
+            leader.getFollowerToSnapshot().getNextChunk();
+            leader.getFollowerToSnapshot().incrementChunkIndex();
 
-                    // this should invoke a sendinstallsnapshot as followersLastIndex < snapshotIndex
-                    RaftActorBehavior raftBehavior = leader.handleMessage(
-                        senderActor, new Replicate(null, "state-id", entry));
+            leader.handleMessage(leaderActor, new SendHeartBeat());
 
-                    assertTrue(raftBehavior instanceof Leader);
+            AppendEntriesMessages.AppendEntries aeproto = (AppendEntriesMessages.AppendEntries)MessageCollectorActor.getFirstMatching(
+                followerActor, AppendEntries.SERIALIZABLE_CLASS);
 
-                    // we might receive some heartbeat messages, so wait till we SendInstallSnapshot
-                    Boolean[] matches = new ReceiveWhile<Boolean>(Boolean.class, duration("2 seconds")) {
-                        @Override
-                        protected Boolean match(Object o) throws Exception {
-                            if (o instanceof SendInstallSnapshot) {
-                                return true;
-                            }
-                            return false;
-                        }
-                    }.get();
+            assertNotNull("AppendEntries should be sent even if InstallSnapshotReply is not " +
+                "received", aeproto);
 
-                    boolean sendInstallSnapshotReceived = false;
-                    for (Boolean b: matches) {
-                        sendInstallSnapshotReceived = b | sendInstallSnapshotReceived;
-                    }
+            AppendEntries ae = (AppendEntries) SerializationUtils.fromSerializable(aeproto);
+
+            assertTrue("AppendEntries should be sent with empty entries", ae.getEntries().isEmpty());
+
+            //InstallSnapshotReply received
+            leader.getFollowerToSnapshot().markSendStatus(true);
+
+            leader.handleMessage(senderActor, new SendHeartBeat());
+
+            InstallSnapshotMessages.InstallSnapshot isproto = (InstallSnapshotMessages.InstallSnapshot)
+                MessageCollectorActor.getFirstMatching(followerActor,
+                    InstallSnapshot.SERIALIZABLE_CLASS);
+
+            assertNotNull("Installsnapshot should get called for sending the next chunk of snapshot",
+                isproto);
+
+            InstallSnapshot is = (InstallSnapshot) SerializationUtils.fromSerializable(isproto);
 
-                    assertTrue(sendInstallSnapshotReceived);
+            assertEquals(snapshotIndex, is.getLastIncludedIndex());
 
+        }};
+    }
+
+    @Test
+    public void testSendAppendEntriesSnapshotScenario() {
+        new JavaTestKit(getSystem()) {{
+
+            ActorRef followerActor = getTestActor();
+
+            Map<String, String> peerAddresses = new HashMap();
+            peerAddresses.put(followerActor.path().toString(),
+                followerActor.path().toString());
+
+            MockRaftActorContext actorContext =
+                (MockRaftActorContext) createActorContext(getRef());
+            actorContext.setPeerAddresses(peerAddresses);
+
+            Map<String, String> leadersSnapshot = new HashMap<>();
+            leadersSnapshot.put("1", "A");
+            leadersSnapshot.put("2", "B");
+            leadersSnapshot.put("3", "C");
+
+            //clears leaders log
+            actorContext.getReplicatedLog().removeFrom(0);
+
+            final int followersLastIndex = 2;
+            final int snapshotIndex = 3;
+            final int newEntryIndex = 4;
+            final int snapshotTerm = 1;
+            final int currentTerm = 2;
+
+            // set the snapshot variables in replicatedlog
+            actorContext.getReplicatedLog().setSnapshotIndex(snapshotIndex);
+            actorContext.getReplicatedLog().setSnapshotTerm(snapshotTerm);
+            actorContext.setCommitIndex(followersLastIndex);
+
+            Leader leader = new Leader(actorContext);
+
+            // new entry
+            ReplicatedLogImplEntry entry =
+                new ReplicatedLogImplEntry(newEntryIndex, currentTerm,
+                    new MockRaftActorContext.MockPayload("D"));
+
+            //update follower timestamp
+            leader.markFollowerActive(followerActor.path().toString());
+
+            // this should invoke a sendinstallsnapshot as followersLastIndex < snapshotIndex
+            RaftActorBehavior raftBehavior = leader.handleMessage(
+                senderActor, new Replicate(null, "state-id", entry));
+
+            assertTrue(raftBehavior instanceof Leader);
+
+            // we might receive some heartbeat messages, so wait till we InitiateInstallSnapshot
+            Boolean[] matches = new ReceiveWhile<Boolean>(Boolean.class, duration("2 seconds")) {
+                @Override
+                protected Boolean match(Object o) throws Exception {
+                    if (o instanceof InitiateInstallSnapshot) {
+                        return true;
+                    }
+                    return false;
                 }
-            };
+            }.get();
+
+            boolean initiateInitiateInstallSnapshot = false;
+            for (Boolean b: matches) {
+                initiateInitiateInstallSnapshot = b | initiateInitiateInstallSnapshot;
+            }
+
+            assertTrue(initiateInitiateInstallSnapshot);
         }};
     }
 
     @Test
-    public void testInstallSnapshot() {
-        new LeaderTestKit(getSystem()) {{
+    public void testInitiateInstallSnapshot() throws Exception {
+        new JavaTestKit(getSystem()) {{
 
-            new Within(duration("1 seconds")) {
-                protected void run() {
-                    ActorRef followerActor = getTestActor();
+            ActorRef leaderActor = getSystem().actorOf(Props.create(MessageCollectorActor.class));
 
-                    Map<String, String> peerAddresses = new HashMap();
-                    peerAddresses.put(followerActor.path().toString(),
-                        followerActor.path().toString());
+            ActorRef followerActor = getTestActor();
 
-                    MockRaftActorContext actorContext =
-                        (MockRaftActorContext) createActorContext();
-                    actorContext.setPeerAddresses(peerAddresses);
+            Map<String, String> peerAddresses = new HashMap();
+            peerAddresses.put(followerActor.path().toString(),
+                followerActor.path().toString());
 
 
-                    Map<String, String> leadersSnapshot = new HashMap<>();
-                    leadersSnapshot.put("1", "A");
-                    leadersSnapshot.put("2", "B");
-                    leadersSnapshot.put("3", "C");
+            MockRaftActorContext actorContext =
+                (MockRaftActorContext) createActorContext(leaderActor);
+            actorContext.setPeerAddresses(peerAddresses);
 
-                    //clears leaders log
-                    actorContext.getReplicatedLog().removeFrom(0);
+            Map<String, String> leadersSnapshot = new HashMap<>();
+            leadersSnapshot.put("1", "A");
+            leadersSnapshot.put("2", "B");
+            leadersSnapshot.put("3", "C");
 
-                    final int followersLastIndex = 2;
-                    final int snapshotIndex = 3;
-                    final int newEntryIndex = 4;
-                    final int snapshotTerm = 1;
-                    final int currentTerm = 2;
+            //clears leaders log
+            actorContext.getReplicatedLog().removeFrom(0);
 
-                    // set the snapshot variables in replicatedlog
-                    actorContext.getReplicatedLog().setSnapshot(toByteString(leadersSnapshot));
-                    actorContext.getReplicatedLog().setSnapshotIndex(snapshotIndex);
-                    actorContext.getReplicatedLog().setSnapshotTerm(snapshotTerm);
+            final int followersLastIndex = 2;
+            final int snapshotIndex = 3;
+            final int newEntryIndex = 4;
+            final int snapshotTerm = 1;
+            final int currentTerm = 2;
 
-                    actorContext.getTermInformation().update(currentTerm, leaderActor.path().toString());
+            // set the snapshot variables in replicatedlog
+            actorContext.getReplicatedLog().setSnapshotIndex(snapshotIndex);
+            actorContext.getReplicatedLog().setSnapshotTerm(snapshotTerm);
+            actorContext.setLastApplied(3);
+            actorContext.setCommitIndex(followersLastIndex);
 
-                    MockLeader leader = new MockLeader(actorContext);
-                    // set the follower info in leader
-                    leader.addToFollowerToLog(followerActor.path().toString(), followersLastIndex, -1);
+            Leader leader = new Leader(actorContext);
+            // set the snapshot as absent and check if capture-snapshot is invoked.
+            leader.setSnapshot(Optional.<ByteString>absent());
 
-                    // new entry
-                    ReplicatedLogImplEntry entry =
-                        new ReplicatedLogImplEntry(newEntryIndex, currentTerm,
-                            new MockRaftActorContext.MockPayload("D"));
+            // new entry
+            ReplicatedLogImplEntry entry =
+                new ReplicatedLogImplEntry(newEntryIndex, currentTerm,
+                    new MockRaftActorContext.MockPayload("D"));
 
-                    RaftActorBehavior raftBehavior = leader.handleMessage(senderActor, new SendInstallSnapshot());
+            actorContext.getReplicatedLog().append(entry);
 
-                    assertTrue(raftBehavior instanceof Leader);
+            // this should invoke a sendinstallsnapshot as followersLastIndex < snapshotIndex
+            RaftActorBehavior raftBehavior = leader.handleMessage(
+                leaderActor, new InitiateInstallSnapshot());
 
-                    // check if installsnapshot gets called with the correct values.
-                    final String out =
-                        new ExpectMsg<String>(duration("1 seconds"), "match hint") {
-                            // do not put code outside this method, will run afterwards
-                            protected String match(Object in) {
-                                if (in instanceof InstallSnapshotMessages.InstallSnapshot) {
-                                    InstallSnapshot is = (InstallSnapshot)
-                                        SerializationUtils.fromSerializable(in);
-                                    if (is.getData() == null) {
-                                        return "InstallSnapshot data is null";
-                                    }
-                                    if (is.getLastIncludedIndex() != snapshotIndex) {
-                                        return is.getLastIncludedIndex() + "!=" + snapshotIndex;
-                                    }
-                                    if (is.getLastIncludedTerm() != snapshotTerm) {
-                                        return is.getLastIncludedTerm() + "!=" + snapshotTerm;
-                                    }
-                                    if (is.getTerm() == currentTerm) {
-                                        return is.getTerm() + "!=" + currentTerm;
-                                    }
+            CaptureSnapshot cs = (CaptureSnapshot) MessageCollectorActor.
+                getFirstMatching(leaderActor, CaptureSnapshot.class);
 
-                                    return "match";
+            assertNotNull(cs);
 
-                               } else {
-                                    return "message mismatch:" + in.getClass();
-                                }
+            assertTrue(cs.isInstallSnapshotInitiated());
+            assertEquals(3, cs.getLastAppliedIndex());
+            assertEquals(1, cs.getLastAppliedTerm());
+            assertEquals(4, cs.getLastIndex());
+            assertEquals(2, cs.getLastTerm());
+        }};
+    }
+
+    @Test
+    public void testInstallSnapshot() {
+        new JavaTestKit(getSystem()) {{
+
+            ActorRef followerActor = getTestActor();
+
+            Map<String, String> peerAddresses = new HashMap();
+            peerAddresses.put(followerActor.path().toString(),
+                followerActor.path().toString());
+
+            MockRaftActorContext actorContext =
+                (MockRaftActorContext) createActorContext();
+            actorContext.setPeerAddresses(peerAddresses);
+
+
+            Map<String, String> leadersSnapshot = new HashMap<>();
+            leadersSnapshot.put("1", "A");
+            leadersSnapshot.put("2", "B");
+            leadersSnapshot.put("3", "C");
+
+            //clears leaders log
+            actorContext.getReplicatedLog().removeFrom(0);
+
+            final int followersLastIndex = 2;
+            final int snapshotIndex = 3;
+            final int newEntryIndex = 4;
+            final int snapshotTerm = 1;
+            final int currentTerm = 2;
+
+            // set the snapshot variables in replicatedlog
+            actorContext.getReplicatedLog().setSnapshotIndex(snapshotIndex);
+            actorContext.getReplicatedLog().setSnapshotTerm(snapshotTerm);
+            actorContext.getTermInformation().update(currentTerm, leaderActor.path().toString());
+            actorContext.setCommitIndex(followersLastIndex);
+
+            Leader leader = new Leader(actorContext);
+
+            // new entry
+            ReplicatedLogImplEntry entry =
+                new ReplicatedLogImplEntry(newEntryIndex, currentTerm,
+                    new MockRaftActorContext.MockPayload("D"));
+
+            RaftActorBehavior raftBehavior = leader.handleMessage(senderActor,
+                new SendInstallSnapshot(toByteString(leadersSnapshot)));
+
+            assertTrue(raftBehavior instanceof Leader);
+
+            // check if installsnapshot gets called with the correct values.
+            final String out =
+                new ExpectMsg<String>(duration("1 seconds"), "match hint") {
+                    // do not put code outside this method, will run afterwards
+                    protected String match(Object in) {
+                        if (in instanceof InstallSnapshotMessages.InstallSnapshot) {
+                            InstallSnapshot is = (InstallSnapshot)
+                                SerializationUtils.fromSerializable(in);
+                            if (is.getData() == null) {
+                                return "InstallSnapshot data is null";
+                            }
+                            if (is.getLastIncludedIndex() != snapshotIndex) {
+                                return is.getLastIncludedIndex() + "!=" + snapshotIndex;
+                            }
+                            if (is.getLastIncludedTerm() != snapshotTerm) {
+                                return is.getLastIncludedTerm() + "!=" + snapshotTerm;
+                            }
+                            if (is.getTerm() == currentTerm) {
+                                return is.getTerm() + "!=" + currentTerm;
                             }
-                        }.get(); // this extracts the received message
 
-                    assertEquals("match", out);
-                }
-            };
+                            return "match";
+
+                        } else {
+                            return "message mismatch:" + in.getClass();
+                        }
+                    }
+                }.get(); // this extracts the received message
+
+            assertEquals("match", out);
         }};
     }
 
     @Test
     public void testHandleInstallSnapshotReplyLastChunk() {
-        new LeaderTestKit(getSystem()) {{
-            new Within(duration("1 seconds")) {
-                protected void run() {
-                    ActorRef followerActor = getTestActor();
+        new JavaTestKit(getSystem()) {{
 
-                    Map<String, String> peerAddresses = new HashMap();
-                    peerAddresses.put(followerActor.path().toString(),
-                        followerActor.path().toString());
+            ActorRef followerActor = getTestActor();
 
-                    MockRaftActorContext actorContext =
-                        (MockRaftActorContext) createActorContext();
-                    actorContext.setPeerAddresses(peerAddresses);
+            Map<String, String> peerAddresses = new HashMap();
+            peerAddresses.put(followerActor.path().toString(),
+                followerActor.path().toString());
 
-                    final int followersLastIndex = 2;
-                    final int snapshotIndex = 3;
-                    final int newEntryIndex = 4;
-                    final int snapshotTerm = 1;
-                    final int currentTerm = 2;
-
-                    MockLeader leader = new MockLeader(actorContext);
-                    // set the follower info in leader
-                    leader.addToFollowerToLog(followerActor.path().toString(), followersLastIndex, -1);
-
-                    Map<String, String> leadersSnapshot = new HashMap<>();
-                    leadersSnapshot.put("1", "A");
-                    leadersSnapshot.put("2", "B");
-                    leadersSnapshot.put("3", "C");
-
-                    // set the snapshot variables in replicatedlog
-                    actorContext.getReplicatedLog().setSnapshot(
-                        toByteString(leadersSnapshot));
-                    actorContext.getReplicatedLog().setSnapshotIndex(snapshotIndex);
-                    actorContext.getReplicatedLog().setSnapshotTerm(snapshotTerm);
-                    actorContext.getTermInformation().update(currentTerm, leaderActor.path().toString());
-
-                    ByteString bs = toByteString(leadersSnapshot);
-                    leader.createFollowerToSnapshot(followerActor.path().toString(), bs);
-                    while(!leader.getFollowerToSnapshot().isLastChunk(leader.getFollowerToSnapshot().getChunkIndex())) {
-                        leader.getFollowerToSnapshot().getNextChunk();
-                        leader.getFollowerToSnapshot().incrementChunkIndex();
-                    }
+            final int followersLastIndex = 2;
+            final int snapshotIndex = 3;
+            final int newEntryIndex = 4;
+            final int snapshotTerm = 1;
+            final int currentTerm = 2;
 
-                    //clears leaders log
-                    actorContext.getReplicatedLog().removeFrom(0);
+            MockRaftActorContext actorContext =
+                (MockRaftActorContext) createActorContext();
+            actorContext.setPeerAddresses(peerAddresses);
+            actorContext.setCommitIndex(followersLastIndex);
 
-                    RaftActorBehavior raftBehavior = leader.handleMessage(senderActor,
-                        new InstallSnapshotReply(currentTerm, followerActor.path().toString(),
-                            leader.getFollowerToSnapshot().getChunkIndex(), true));
+            MockLeader leader = new MockLeader(actorContext);
 
-                    assertTrue(raftBehavior instanceof Leader);
+            Map<String, String> leadersSnapshot = new HashMap<>();
+            leadersSnapshot.put("1", "A");
+            leadersSnapshot.put("2", "B");
+            leadersSnapshot.put("3", "C");
 
-                    assertEquals(leader.mapFollowerToSnapshot.size(), 0);
-                    assertEquals(leader.followerToLog.size(), 1);
-                    assertNotNull(leader.followerToLog.get(followerActor.path().toString()));
-                    FollowerLogInformation fli = leader.followerToLog.get(followerActor.path().toString());
-                    assertEquals(snapshotIndex, fli.getMatchIndex().get());
-                    assertEquals(snapshotIndex, fli.getMatchIndex().get());
-                    assertEquals(snapshotIndex + 1, fli.getNextIndex().get());
-                }
-            };
+            // set the snapshot variables in replicatedlog
+
+            actorContext.getReplicatedLog().setSnapshotIndex(snapshotIndex);
+            actorContext.getReplicatedLog().setSnapshotTerm(snapshotTerm);
+            actorContext.getTermInformation().update(currentTerm, leaderActor.path().toString());
+
+            ByteString bs = toByteString(leadersSnapshot);
+            leader.setSnapshot(Optional.of(bs));
+            leader.createFollowerToSnapshot(followerActor.path().toString(), bs);
+            while(!leader.getFollowerToSnapshot().isLastChunk(leader.getFollowerToSnapshot().getChunkIndex())) {
+                leader.getFollowerToSnapshot().getNextChunk();
+                leader.getFollowerToSnapshot().incrementChunkIndex();
+            }
+
+            //clears leaders log
+            actorContext.getReplicatedLog().removeFrom(0);
+
+            RaftActorBehavior raftBehavior = leader.handleMessage(senderActor,
+                new InstallSnapshotReply(currentTerm, followerActor.path().toString(),
+                    leader.getFollowerToSnapshot().getChunkIndex(), true));
+
+            assertTrue(raftBehavior instanceof Leader);
+
+            assertEquals(leader.mapFollowerToSnapshot.size(), 0);
+            assertEquals(leader.followerToLog.size(), 1);
+            assertNotNull(leader.followerToLog.get(followerActor.path().toString()));
+            FollowerLogInformation fli = leader.followerToLog.get(followerActor.path().toString());
+            assertEquals(snapshotIndex, fli.getMatchIndex().get());
+            assertEquals(snapshotIndex, fli.getMatchIndex().get());
+            assertEquals(snapshotIndex + 1, fli.getNextIndex().get());
         }};
     }
 
@@ -584,6 +713,7 @@ public class LeaderTest extends AbstractRaftActorBehaviorTest {
             followerActorContext.setCommitIndex(1);
 
             Leader leader = new Leader(leaderActorContext);
+            leader.markFollowerActive(followerActor.path().toString());
 
             leader.handleMessage(leaderActor, new SendHeartBeat());
 
@@ -652,6 +782,7 @@ public class LeaderTest extends AbstractRaftActorBehaviorTest {
             followerActorContext.setCommitIndex(2);
 
             Leader leader = new Leader(leaderActorContext);
+            leader.markFollowerActive(followerActor.path().toString());
 
             leader.handleMessage(leaderActor, new SendHeartBeat());
 
@@ -816,30 +947,6 @@ public class LeaderTest extends AbstractRaftActorBehaviorTest {
 
     }
 
-    private static class LeaderTestKit extends JavaTestKit {
-
-        private LeaderTestKit(ActorSystem actorSystem) {
-            super(actorSystem);
-        }
-
-        protected void waitForLogMessage(final Class logLevel, ActorRef subject, String logMessage){
-            // Wait for a specific log message to show up
-            final boolean result =
-            new JavaTestKit.EventFilter<Boolean>(logLevel
-            ) {
-                @Override
-                protected Boolean run() {
-                    return true;
-                }
-            }.from(subject.path().toString())
-                .message(logMessage)
-                .occurrences(1).exec();
-
-            Assert.assertEquals(true, result);
-
-        }
-    }
-
     class MockLeader extends Leader {
 
         FollowerToSnapshot fts;
@@ -848,14 +955,6 @@ public class LeaderTest extends AbstractRaftActorBehaviorTest {
             super(context);
         }
 
-        public void addToFollowerToLog(String followerId, long nextIndex, long matchIndex) {
-            FollowerLogInformation followerLogInformation =
-                new FollowerLogInformationImpl(followerId,
-                    new AtomicLong(nextIndex),
-                    new AtomicLong(matchIndex));
-            followerToLog.put(followerId, followerLogInformation);
-        }
-
         public FollowerToSnapshot getFollowerToSnapshot() {
             return fts;
         }
@@ -866,4 +965,26 @@ public class LeaderTest extends AbstractRaftActorBehaviorTest {
 
         }
     }
+
+    private class MockConfigParamsImpl extends DefaultConfigParamsImpl {
+
+        private long electionTimeOutIntervalMillis;
+        private int snapshotChunkSize;
+
+        public MockConfigParamsImpl(long electionTimeOutIntervalMillis, int snapshotChunkSize) {
+            super();
+            this.electionTimeOutIntervalMillis = electionTimeOutIntervalMillis;
+            this.snapshotChunkSize = snapshotChunkSize;
+        }
+
+        @Override
+        public FiniteDuration getElectionTimeOutInterval() {
+            return new FiniteDuration(electionTimeOutIntervalMillis, TimeUnit.MILLISECONDS);
+        }
+
+        @Override
+        public int getSnapshotChunkSize() {
+            return snapshotChunkSize;
+        }
+    }
 }
index 8a45108f8b675b2442e2dd1ecb9195472095bda5..818ddf7d8572889e924a364c1203ca4892eb6029 100644 (file)
@@ -7,7 +7,7 @@ akka {
 
     actor {
         # enable to test serialization only.
-        serialize-messages = on
+        serialize-messages = off
 
         serializers {
           java  = "akka.serialization.JavaSerializer"
index 1fa54be2005b06d0be70226ac4abd30625f8a8bb..eba5b8756b88cfaa936e3aa20828706a29abaf5d 100644 (file)
@@ -8,17 +8,11 @@
 package org.opendaylight.controller.sal.binding.codegen.impl;
 
 import com.google.common.base.Supplier;
-
-import java.util.Map;
-import java.util.WeakHashMap;
-
+import com.google.common.collect.Iterables;
 import javassist.ClassPool;
 import javassist.CtClass;
 import javassist.CtMethod;
 import javassist.NotFoundException;
-
-import javax.annotation.concurrent.GuardedBy;
-
 import org.eclipse.xtext.xbase.lib.Extension;
 import org.opendaylight.controller.sal.binding.api.rpc.RpcRouter;
 import org.opendaylight.controller.sal.binding.codegen.RpcIsNotRoutedException;
@@ -31,6 +25,10 @@ import org.opendaylight.yangtools.yang.binding.RpcService;
 import org.opendaylight.yangtools.yang.binding.annotations.RoutingContext;
 import org.opendaylight.yangtools.yang.binding.util.ClassLoaderUtils;
 
+import javax.annotation.concurrent.GuardedBy;
+import java.util.Map;
+import java.util.WeakHashMap;
+
 abstract class AbstractRuntimeCodeGenerator implements org.opendaylight.controller.sal.binding.codegen.RuntimeCodeGenerator, NotificationInvokerFactory {
     @GuardedBy("this")
     private final Map<Class<? extends NotificationListener>, RuntimeGeneratedInvokerPrototype> invokerClasses = new WeakHashMap<>();
@@ -174,6 +172,10 @@ abstract class AbstractRuntimeCodeGenerator implements org.opendaylight.controll
             }
         });
 
+        if (Iterables.isEmpty(metadata.getContexts())) {
+            throw new RpcIsNotRoutedException("Service doesn't have routing context associated.");
+        }
+
         synchronized (utils) {
             final T instance = ClassLoaderUtils.withClassLoader(serviceType.getClassLoader(), routerSupplier(serviceType, metadata));
             return new RpcRouterCodegenInstance<T>(name, serviceType, instance, metadata.getContexts());
index 227354c41e1f50bfbd62b8edbd82c2928d83d0b3..c8129e6eca46c3a4aa4d83971e886b3691be1aaf 100644 (file)
@@ -7,9 +7,7 @@
  */
 package org.opendaylight.controller.sal.binding.test;
 
-import junit.framework.Assert;
-
-
+import static org.junit.Assert.assertNotNull;
 import org.opendaylight.yangtools.yang.binding.Augmentable;
 import org.opendaylight.yangtools.yang.binding.Augmentation;
 
@@ -28,8 +26,8 @@ public class AugmentationVerifier<T extends Augmentable<T>> {
 
     public static <T extends Augmentable<T>> void assertHasAugmentation(T object,
             Class<? extends Augmentation<T>> augmentation) {
-        Assert.assertNotNull(object);
-        Assert.assertNotNull("Augmentation " + augmentation.getSimpleName() + " is not present.", object.getAugmentation(augmentation));
+        assertNotNull(object);
+        assertNotNull("Augmentation " + augmentation.getSimpleName() + " is not present.", object.getAugmentation(augmentation));
     }
 
     public static <T extends Augmentable<T>> AugmentationVerifier<T> from(T obj) {
index 4cc3780c6f0ebff8b25c0043c845034d3a15aba1..ba75d578fbb770e94fc49ee18bed36739adb837c 100644 (file)
@@ -7,10 +7,10 @@
  */
 package org.opendaylight.controller.sal.binding.test.connect.dom;
 
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertNotNull;
-import static junit.framework.Assert.assertNotSame;
-import static junit.framework.Assert.assertTrue;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertTrue;
 
 import java.math.BigInteger;
 import java.util.Collections;
index 6686a83a2e26ed55ca2a2cb7e9f40c3bce679f19..7d616ca62cdaa02648927809a37468ca2a9702a3 100644 (file)
@@ -7,9 +7,9 @@
  */
 package org.opendaylight.controller.sal.binding.test.connect.dom;
 
-import static junit.framework.Assert.assertNotNull;
-import static junit.framework.Assert.assertTrue;
-import static junit.framework.Assert.fail;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 import java.io.InputStream;
 import java.util.Collections;
index 6de1083cbed63bbbf2f6ccff5f854c57dbc2c00a..5d5318f19a050bcb3b5c1e4550304f011ac8f40d 100644 (file)
@@ -26,8 +26,8 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
 import java.util.List;
 
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertNotNull;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
 public class NormalizedNodeToNodeCodecTest {
index 4da7d8c483e175de518cd0a9f8514a689f589db8..13dfff3a8acd4a5e8fe98fb184ca4805ac60e506 100644 (file)
@@ -10,7 +10,7 @@
 
 package org.opendaylight.controller.cluster.datastore.node.utils;
 
-import junit.framework.Assert;
+import static org.junit.Assert.assertTrue;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 
@@ -22,8 +22,7 @@ public class NodeIdentifierFactoryTest {
         NodeIdentifierFactory
             .getArgument("AugmentationIdentifier{childNames=[(urn:opendaylight:flow:table:statistics?revision=2013-12-15)flow-table-statistics]}");
 
-    Assert
-        .assertTrue(argument instanceof YangInstanceIdentifier.AugmentationIdentifier);
+    assertTrue(argument instanceof YangInstanceIdentifier.AugmentationIdentifier);
 
 
   }
index 76d4ceb2f5ec405200e9ce44a0c5665a2570f9c3..2ae83bd6c68b9f8c786b678ec632ec6c33335129 100644 (file)
@@ -4,9 +4,9 @@ import org.junit.Test;
 import org.opendaylight.controller.cluster.datastore.util.TestModel;
 import org.opendaylight.yangtools.yang.common.QName;
 
-import static junit.framework.Assert.assertTrue;
-import static junit.framework.TestCase.assertEquals;
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
 
 public class QNameFactoryTest {
 
index 0688bfbc5cddbe256a3e67839606d6efd811442b..60dbcb05163ab90ff4d436c48631e1d9b88b855f 100644 (file)
@@ -8,11 +8,16 @@
 
 package org.opendaylight.controller.xml.codec;
 
-
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Lists;
 import com.google.common.io.ByteSource;
-import junit.framework.Assert;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import javax.xml.parsers.DocumentBuilderFactory;
+import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
@@ -27,15 +32,6 @@ import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
 
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-
 public class XmlUtilsTest {
 
   private static final DocumentBuilderFactory BUILDERFACTORY;
index d7e7d56d495d4e66f24d6c85ca12fc9d46b10104..bd42a9cdd9a547ae572b017c4bb3c9ef467b5329 100644 (file)
@@ -80,7 +80,6 @@
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>sal-inmemory-datastore</artifactId>
-      <version>1.2.0-SNAPSHOT</version>
     </dependency>
 
     <dependency>
     <dependency>
         <groupId>org.opendaylight.controller</groupId>
         <artifactId>sal-clustering-commons</artifactId>
-        <version>1.2.0-SNAPSHOT</version>
     </dependency>
 
     <dependency>
     <dependency>
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-simple</artifactId>
-      <version>${slf4j.version}</version>
       <scope>test</scope>
     </dependency>
 
index 1a0a5dd6591c9a653ae2079b938d6448e59c036f..061e1ab448f97ce9ad08541be9b0b1b6d4e73c30 100644 (file)
@@ -13,12 +13,6 @@ import com.google.common.base.Preconditions;
 import com.typesafe.config.Config;
 import com.typesafe.config.ConfigFactory;
 import com.typesafe.config.ConfigObject;
-import org.opendaylight.controller.cluster.datastore.shardstrategy.DefaultShardStrategy;
-import org.opendaylight.controller.cluster.datastore.shardstrategy.ModuleShardStrategy;
-import org.opendaylight.controller.cluster.datastore.shardstrategy.ShardStrategy;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 import java.io.File;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -27,6 +21,11 @@ import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import org.opendaylight.controller.cluster.datastore.shardstrategy.DefaultShardStrategy;
+import org.opendaylight.controller.cluster.datastore.shardstrategy.ModuleShardStrategy;
+import org.opendaylight.controller.cluster.datastore.shardstrategy.ShardStrategy;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class ConfigurationImpl implements Configuration {
 
@@ -40,15 +39,15 @@ public class ConfigurationImpl implements Configuration {
     // Look up maps to speed things up
 
     // key = memberName, value = list of shardNames
-    private Map<String, List<String>> memberShardNames = new HashMap<>();
+    private final Map<String, List<String>> memberShardNames = new HashMap<>();
 
     // key = shardName, value = list of replicaNames (replicaNames are the same as memberNames)
-    private Map<String, List<String>> shardReplicaNames = new HashMap<>();
+    private final Map<String, List<String>> shardReplicaNames = new HashMap<>();
 
 
-    public ConfigurationImpl(String moduleShardsConfigPath,
+    public ConfigurationImpl(final String moduleShardsConfigPath,
 
-        String modulesConfigPath){
+        final String modulesConfigPath){
 
         Preconditions.checkNotNull(moduleShardsConfigPath, "moduleShardsConfigPath should not be null");
         Preconditions.checkNotNull(modulesConfigPath, "modulesConfigPath should not be null");
@@ -80,7 +79,7 @@ public class ConfigurationImpl implements Configuration {
         readModules(modulesConfig);
     }
 
-    @Override public List<String> getMemberShardNames(String memberName){
+    @Override public List<String> getMemberShardNames(final String memberName){
 
         Preconditions.checkNotNull(memberName, "memberName should not be null");
 
@@ -88,7 +87,7 @@ public class ConfigurationImpl implements Configuration {
             return memberShardNames.get(memberName);
         }
 
-        List<String> shards = new ArrayList();
+        List<String> shards = new ArrayList<>();
         for(ModuleShard ms : moduleShards){
             for(Shard s : ms.getShards()){
                 for(String m : s.getReplicas()){
@@ -105,7 +104,7 @@ public class ConfigurationImpl implements Configuration {
 
     }
 
-    @Override public Optional<String> getModuleNameFromNameSpace(String nameSpace) {
+    @Override public Optional<String> getModuleNameFromNameSpace(final String nameSpace) {
 
         Preconditions.checkNotNull(nameSpace, "nameSpace should not be null");
 
@@ -125,7 +124,7 @@ public class ConfigurationImpl implements Configuration {
         return map;
     }
 
-    @Override public List<String> getShardNamesFromModuleName(String moduleName) {
+    @Override public List<String> getShardNamesFromModuleName(final String moduleName) {
 
         Preconditions.checkNotNull(moduleName, "moduleName should not be null");
 
@@ -139,10 +138,10 @@ public class ConfigurationImpl implements Configuration {
             }
         }
 
-        return Collections.EMPTY_LIST;
+        return Collections.emptyList();
     }
 
-    @Override public List<String> getMembersFromShardName(String shardName) {
+    @Override public List<String> getMembersFromShardName(final String shardName) {
 
         Preconditions.checkNotNull(shardName, "shardName should not be null");
 
@@ -159,8 +158,8 @@ public class ConfigurationImpl implements Configuration {
                 }
             }
         }
-        shardReplicaNames.put(shardName, Collections.EMPTY_LIST);
-        return Collections.EMPTY_LIST;
+        shardReplicaNames.put(shardName, Collections.<String>emptyList());
+        return Collections.emptyList();
     }
 
     @Override public Set<String> getAllShardNames() {
@@ -175,7 +174,7 @@ public class ConfigurationImpl implements Configuration {
 
 
 
-    private void readModules(Config modulesConfig) {
+    private void readModules(final Config modulesConfig) {
         List<? extends ConfigObject> modulesConfigObjectList =
             modulesConfig.getObjectList("modules");
 
@@ -186,7 +185,7 @@ public class ConfigurationImpl implements Configuration {
         }
     }
 
-    private void readModuleShards(Config moduleShardsConfig) {
+    private void readModuleShards(final Config moduleShardsConfig) {
         List<? extends ConfigObject> moduleShardsConfigObjectList =
             moduleShardsConfig.getObjectList("module-shards");
 
@@ -214,7 +213,7 @@ public class ConfigurationImpl implements Configuration {
         private final String moduleName;
         private final List<Shard> shards;
 
-        public ModuleShard(String moduleName, List<Shard> shards) {
+        public ModuleShard(final String moduleName, final List<Shard> shards) {
             this.moduleName = moduleName;
             this.shards = shards;
         }
@@ -232,7 +231,7 @@ public class ConfigurationImpl implements Configuration {
         private final String name;
         private final List<String> replicas;
 
-        Shard(String name, List<String> replicas) {
+        Shard(final String name, final List<String> replicas) {
             this.name = name;
             this.replicas = replicas;
         }
@@ -252,7 +251,7 @@ public class ConfigurationImpl implements Configuration {
         private final String nameSpace;
         private final ShardStrategy shardStrategy;
 
-        Module(String name, String nameSpace, String shardStrategy) {
+        Module(final String name, final String nameSpace, final String shardStrategy) {
             this.name = name;
             this.nameSpace = nameSpace;
             if(ModuleShardStrategy.NAME.equals(shardStrategy)){
@@ -280,11 +279,11 @@ public class ConfigurationImpl implements Configuration {
 
         private final ConfigObject configObject;
 
-        ConfigObjectWrapper(ConfigObject configObject){
+        ConfigObjectWrapper(final ConfigObject configObject){
             this.configObject = configObject;
         }
 
-        public String stringValue(String name){
+        public String stringValue(final String name){
             return configObject.get(name).unwrapped().toString();
         }
     }
index 40880d907580bbaec6a81756d07b3b8b37210ade..d93bae22e08d9fddb3f1ac7d9c12aa4a278d0ff6 100644 (file)
@@ -236,6 +236,18 @@ public class TransactionProxy implements DOMStoreReadWriteTransaction {
         return recordedOperationFutures;
     }
 
+    @VisibleForTesting
+    boolean hasTransactionContext() {
+        for(TransactionFutureCallback txFutureCallback : txFutureCallbackMap.values()) {
+            TransactionContext transactionContext = txFutureCallback.getTransactionContext();
+            if(transactionContext != null) {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
     @Override
     public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read(
             final YangInstanceIdentifier path) {
@@ -640,29 +652,42 @@ public class TransactionProxy implements DOMStoreReadWriteTransaction {
             // respect to #addTxOperationOnComplete to handle timing issues and ensure no
             // TransactionOperation is missed and that they are processed in the order they occurred.
             synchronized(txOperationsOnComplete) {
+                // Store the new TransactionContext locally until we've completed invoking the
+                // TransactionOperations. This avoids thread timing issues which could cause
+                // out-of-order TransactionOperations. Eg, on a modification operation, if the
+                // TransactionContext is non-null, then we directly call the TransactionContext.
+                // However, at the same time, the code may be executing the cached
+                // TransactionOperations. So to avoid thus timing, we don't publish the
+                // TransactionContext until after we've executed all cached TransactionOperations.
+                TransactionContext localTransactionContext;
                 if(failure != null) {
                     LOG.debug("Tx {} Creating NoOpTransaction because of error: {}", identifier,
                             failure.getMessage());
 
-                    transactionContext = new NoOpTransactionContext(failure, identifier);
+                    localTransactionContext = new NoOpTransactionContext(failure, identifier);
                 } else if (response.getClass().equals(CreateTransactionReply.SERIALIZABLE_CLASS)) {
-                    createValidTransactionContext(CreateTransactionReply.fromSerializable(response));
+                    localTransactionContext = createValidTransactionContext(
+                            CreateTransactionReply.fromSerializable(response));
                 } else {
                     IllegalArgumentException exception = new IllegalArgumentException(String.format(
                         "Invalid reply type %s for CreateTransaction", response.getClass()));
 
-                    transactionContext = new NoOpTransactionContext(exception, identifier);
+                    localTransactionContext = new NoOpTransactionContext(exception, identifier);
                 }
 
                 for(TransactionOperation oper: txOperationsOnComplete) {
-                    oper.invoke(transactionContext);
+                    oper.invoke(localTransactionContext);
                 }
 
                 txOperationsOnComplete.clear();
+
+                // We're done invoking the TransactionOperations so we can now publish the
+                // TransactionContext.
+                transactionContext = localTransactionContext;
             }
         }
 
-        private void createValidTransactionContext(CreateTransactionReply reply) {
+        private TransactionContext createValidTransactionContext(CreateTransactionReply reply) {
             String transactionPath = reply.getTransactionPath();
 
             LOG.debug("Tx {} Received transaction actor path {}", identifier, transactionPath);
@@ -683,7 +708,7 @@ public class TransactionProxy implements DOMStoreReadWriteTransaction {
             // Check if TxActor is created in the same node
             boolean isTxActorLocal = actorContext.isLocalPath(transactionPath);
 
-            transactionContext = new TransactionContextImpl(transactionPath, transactionActor, identifier,
+            return new TransactionContextImpl(transactionPath, transactionActor, identifier,
                 actorContext, schemaContext, isTxActorLocal, reply.getVersion());
         }
     }
index 9c8909c2dd0f339e00ec64ccda57b098d1fd4567..4d121bae0adbc1aa0dee6d2888b0982293c70810 100644 (file)
@@ -11,12 +11,12 @@ package org.opendaylight.controller.cluster.datastore.messages;
 import org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages;
 
 public class CanCommitTransactionReply implements SerializableMessage {
-    public static Class<ThreePhaseCommitCohortMessages.CanCommitTransactionReply> SERIALIZABLE_CLASS =
+    public static final Class<ThreePhaseCommitCohortMessages.CanCommitTransactionReply> SERIALIZABLE_CLASS =
             ThreePhaseCommitCohortMessages.CanCommitTransactionReply.class;
 
     private final Boolean canCommit;
 
-    public CanCommitTransactionReply(Boolean canCommit) {
+    public CanCommitTransactionReply(final Boolean canCommit) {
         this.canCommit = canCommit;
     }
 
@@ -29,7 +29,7 @@ public class CanCommitTransactionReply implements SerializableMessage {
         return ThreePhaseCommitCohortMessages.CanCommitTransactionReply.newBuilder().setCanCommit(canCommit).build();
     }
 
-    public static CanCommitTransactionReply fromSerializable(Object message) {
+    public static CanCommitTransactionReply fromSerializable(final Object message) {
         return new CanCommitTransactionReply(
                 ((ThreePhaseCommitCohortMessages.CanCommitTransactionReply) message).getCanCommit());
     }
index a54ee6209c8d75b36681cfec470f44a7bcbae593..f711d6f7b5aa9a1c7230e47f4aa33caa8a538b5c 100644 (file)
@@ -11,7 +11,8 @@ package org.opendaylight.controller.cluster.datastore.messages;
 import org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages;
 
 public class CloseDataChangeListenerRegistration implements SerializableMessage {
-  public static final Class SERIALIZABLE_CLASS = ListenerRegistrationMessages.CloseDataChangeListenerRegistration.class;
+  public static final Class<ListenerRegistrationMessages.CloseDataChangeListenerRegistration> SERIALIZABLE_CLASS =
+          ListenerRegistrationMessages.CloseDataChangeListenerRegistration.class;
   @Override
   public Object toSerializable() {
     return ListenerRegistrationMessages.CloseDataChangeListenerRegistration.newBuilder().build();
index faf73c87ebe4ef6bdb8926ccfc3742ecc86d9ebe..9d8225c23a98b8d96dbc2307fe8653db9fc1a5d5 100644 (file)
@@ -11,7 +11,8 @@ package org.opendaylight.controller.cluster.datastore.messages;
 import org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages;
 
 public class CloseDataChangeListenerRegistrationReply implements SerializableMessage{
-  public static Class SERIALIZABLE_CLASS = ListenerRegistrationMessages.CloseDataChangeListenerRegistrationReply.class;
+  public static final Class<ListenerRegistrationMessages.CloseDataChangeListenerRegistrationReply> SERIALIZABLE_CLASS =
+          ListenerRegistrationMessages.CloseDataChangeListenerRegistrationReply.class;
 
   @Override
   public Object toSerializable() {
index 451e39cf6a75d2ac0777c60d25de969c0d0fd2ef..c73111f2dbde517989214c7bd5a17145df63bc2c 100644 (file)
@@ -11,7 +11,8 @@ package org.opendaylight.controller.cluster.datastore.messages;
 import org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages;
 
 public class CloseTransaction implements SerializableMessage{
-  public static final Class SERIALIZABLE_CLASS = ShardTransactionMessages.CloseTransaction.class;
+  public static final Class<ShardTransactionMessages.CloseTransaction> SERIALIZABLE_CLASS =
+          ShardTransactionMessages.CloseTransaction.class;
   @Override
   public Object toSerializable() {
     return ShardTransactionMessages.CloseTransaction.newBuilder().build();
index 74de6c5aeacd3a39e777512980745d9190d7838c..7db39b77a3063878f5fad44cbb61b3594b7b720f 100644 (file)
@@ -11,11 +11,11 @@ package org.opendaylight.controller.cluster.datastore.messages;
 import org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionChainMessages;
 
 public class CloseTransactionChain implements SerializableMessage {
-    public static final Class SERIALIZABLE_CLASS =
+    public static final Class<ShardTransactionChainMessages.CloseTransactionChain> SERIALIZABLE_CLASS =
         ShardTransactionChainMessages.CloseTransactionChain.class;
     private final String transactionChainId;
 
-    public CloseTransactionChain(String transactionChainId){
+    public CloseTransactionChain(final String transactionChainId){
         this.transactionChainId = transactionChainId;
     }
 
@@ -25,7 +25,7 @@ public class CloseTransactionChain implements SerializableMessage {
             .setTransactionChainId(transactionChainId).build();
     }
 
-    public static CloseTransactionChain fromSerializable(Object message){
+    public static CloseTransactionChain fromSerializable(final Object message){
         ShardTransactionChainMessages.CloseTransactionChain closeTransactionChain
             = (ShardTransactionChainMessages.CloseTransactionChain) message;
 
index 23699b7be6c64cb103241329ad9fa72a585cf10b..c001ae185a6dc9641f08f2440d7825624936cb1d 100644 (file)
@@ -11,7 +11,8 @@ package org.opendaylight.controller.cluster.datastore.messages;
 import org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionChainMessages;
 
 public class CloseTransactionChainReply implements SerializableMessage {
-  public static final Class SERIALIZABLE_CLASS = ShardTransactionChainMessages.CloseTransactionChainReply.class;
+  public static final Class<ShardTransactionChainMessages.CloseTransactionChainReply> SERIALIZABLE_CLASS =
+          ShardTransactionChainMessages.CloseTransactionChainReply.class;
   @Override
   public Object toSerializable() {
     return ShardTransactionChainMessages.CloseTransactionChainReply.newBuilder().build();
index 666d182aaff24c9e3d7a8da86a5de061dc4e0999..124eeb2235f04d64e30dd33c581166a1edb347fc 100644 (file)
@@ -11,7 +11,8 @@ package org.opendaylight.controller.cluster.datastore.messages;
 import org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages;
 
 public class CloseTransactionReply implements SerializableMessage {
-  public static final Class SERIALIZABLE_CLASS = ShardTransactionMessages.CloseTransactionReply.class;
+  public static final Class<ShardTransactionMessages.CloseTransactionReply> SERIALIZABLE_CLASS =
+          ShardTransactionMessages.CloseTransactionReply.class;
   @Override
   public Object toSerializable() {
     return ShardTransactionMessages.CloseTransactionReply.newBuilder().build();
index 14620f15d98ffece07905a73cdd7d18222e9c023..83e68c9cb41882c2b7c377f96aaecb5f5a07f328 100644 (file)
@@ -12,18 +12,19 @@ import org.opendaylight.controller.protobuff.messages.transaction.ShardTransacti
 
 public class CreateTransactionReply implements SerializableMessage {
 
-    public static final Class SERIALIZABLE_CLASS = ShardTransactionMessages.CreateTransactionReply.class;
+    public static final Class<ShardTransactionMessages.CreateTransactionReply> SERIALIZABLE_CLASS =
+            ShardTransactionMessages.CreateTransactionReply.class;
     private final String transactionPath;
     private final String transactionId;
     private final int version;
 
-    public CreateTransactionReply(String transactionPath,
-        String transactionId) {
+    public CreateTransactionReply(final String transactionPath,
+        final String transactionId) {
         this(transactionPath, transactionId, CreateTransaction.CURRENT_VERSION);
     }
 
-    public CreateTransactionReply(String transactionPath,
-                                  String transactionId, int version) {
+    public CreateTransactionReply(final String transactionPath,
+                                  final String transactionId, final int version) {
         this.transactionPath = transactionPath;
         this.transactionId = transactionId;
         this.version = version;
@@ -42,6 +43,7 @@ public class CreateTransactionReply implements SerializableMessage {
         return version;
     }
 
+    @Override
     public Object toSerializable(){
         return ShardTransactionMessages.CreateTransactionReply.newBuilder()
             .setTransactionActorPath(transactionPath)
@@ -50,7 +52,7 @@ public class CreateTransactionReply implements SerializableMessage {
             .build();
     }
 
-    public static CreateTransactionReply fromSerializable(Object serializable){
+    public static CreateTransactionReply fromSerializable(final Object serializable){
         ShardTransactionMessages.CreateTransactionReply o = (ShardTransactionMessages.CreateTransactionReply) serializable;
         return new CreateTransactionReply(o.getTransactionActorPath(), o.getTransactionId(), o.getMessageVersion());
     }
index cffe985d18630beff2ba53b48b35f532cd100db3..e10a40729220941761a925350b5ac25288b0e90c 100644 (file)
@@ -11,7 +11,8 @@ package org.opendaylight.controller.cluster.datastore.messages;
 import org.opendaylight.controller.protobuff.messages.datachange.notification.DataChangeListenerMessages;
 
 public class DataChangedReply implements SerializableMessage {
-  public static final Class SERIALIZABLE_CLASS = DataChangeListenerMessages.DataChangedReply.class;
+  public static final Class<DataChangeListenerMessages.DataChangedReply> SERIALIZABLE_CLASS =
+          DataChangeListenerMessages.DataChangedReply.class;
   @Override
   public Object toSerializable() {
     return DataChangeListenerMessages.DataChangedReply.newBuilder().build();
index d52daabd845456b990f4f79300906134ec3744bb..84b8df167607701ea35caf4c32fa301451744e83 100644 (file)
@@ -14,11 +14,12 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 
 public class DataExists implements SerializableMessage{
 
-    public static final Class SERIALIZABLE_CLASS = ShardTransactionMessages.DataExists.class;
+    public static final Class<ShardTransactionMessages.DataExists> SERIALIZABLE_CLASS =
+            ShardTransactionMessages.DataExists.class;
 
     private final YangInstanceIdentifier path;
 
-    public DataExists(YangInstanceIdentifier path) {
+    public DataExists(final YangInstanceIdentifier path) {
         this.path = path;
     }
 
@@ -32,7 +33,7 @@ public class DataExists implements SerializableMessage{
                 InstanceIdentifierUtils.toSerializable(path)).build();
     }
 
-    public static DataExists fromSerializable(Object serializable){
+    public static DataExists fromSerializable(final Object serializable){
         ShardTransactionMessages.DataExists o = (ShardTransactionMessages.DataExists) serializable;
         return new DataExists(InstanceIdentifierUtils.fromSerializable(o.getInstanceIdentifierPathArguments()));
     }
index 04fafa10e29fc66f66f89faca14f9021a33b50a1..24ca6464543911c9d4c6d05fe1f3f2d8731c920e 100644 (file)
@@ -11,13 +11,12 @@ package org.opendaylight.controller.cluster.datastore.messages;
 import org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages;
 
 public class DataExistsReply implements SerializableMessage{
-
-
-    public static final Class SERIALIZABLE_CLASS = ShardTransactionMessages.DataExistsReply.class;
+    public static final Class<ShardTransactionMessages.DataExistsReply> SERIALIZABLE_CLASS =
+            ShardTransactionMessages.DataExistsReply.class;
 
     private final boolean exists;
 
-    public DataExistsReply(boolean exists) {
+    public DataExistsReply(final boolean exists) {
         this.exists = exists;
     }
 
@@ -30,7 +29,7 @@ public class DataExistsReply implements SerializableMessage{
             .setExists(exists).build();
     }
 
-    public static DataExistsReply fromSerializable(Object serializable){
+    public static DataExistsReply fromSerializable(final Object serializable){
         ShardTransactionMessages.DataExistsReply o = (ShardTransactionMessages.DataExistsReply) serializable;
         return new DataExistsReply(o.getExists());
     }
index 6d3051c8c7ab9779ca252082868e95e30f8a962c..81bc1026e44e823dcb6485e32673fa52c27eeb84 100644 (file)
@@ -14,11 +14,11 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 
 public class DeleteData implements SerializableMessage {
 
-    public static final Class SERIALIZABLE_CLASS = ShardTransactionMessages.DeleteData.class;
+    public static final Class<ShardTransactionMessages.DeleteData> SERIALIZABLE_CLASS = ShardTransactionMessages.DeleteData.class;
 
     private final YangInstanceIdentifier path;
 
-    public DeleteData(YangInstanceIdentifier path) {
+    public DeleteData(final YangInstanceIdentifier path) {
         this.path = path;
     }
 
@@ -31,7 +31,7 @@ public class DeleteData implements SerializableMessage {
             .setInstanceIdentifierPathArguments(InstanceIdentifierUtils.toSerializable(path)).build();
     }
 
-    public static DeleteData fromSerializable(Object serializable){
+    public static DeleteData fromSerializable(final Object serializable){
         ShardTransactionMessages.DeleteData o = (ShardTransactionMessages.DeleteData) serializable;
         return new DeleteData(InstanceIdentifierUtils.fromSerializable(o.getInstanceIdentifierPathArguments()));
     }
index 8e2a7b72951a27b5d2b1fe039ed619db5ac62ffd..2e02664e1dcd41bc032fb2be2a2913baf0e000f5 100644 (file)
@@ -11,7 +11,8 @@ package org.opendaylight.controller.cluster.datastore.messages;
 import org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages;
 
 public class DeleteDataReply implements SerializableMessage{
-  public static final Class SERIALIZABLE_CLASS = ShardTransactionMessages.DeleteDataReply.class;
+  public static final Class<ShardTransactionMessages.DeleteDataReply> SERIALIZABLE_CLASS =
+          ShardTransactionMessages.DeleteDataReply.class;
   @Override
   public Object toSerializable() {
     return ShardTransactionMessages.DeleteDataReply.newBuilder().build();
index 81b1c3bbb1e3dab609b903ed5b40f57e8da07523..92d6d728477aac50dfb68975db69c299249537dc 100644 (file)
@@ -11,7 +11,8 @@ package org.opendaylight.controller.cluster.datastore.messages;
 import org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages;
 
 public class MergeDataReply implements SerializableMessage{
-  public static final Class SERIALIZABLE_CLASS = ShardTransactionMessages.MergeDataReply.class;
+  public static final Class<ShardTransactionMessages.MergeDataReply> SERIALIZABLE_CLASS =
+          ShardTransactionMessages.MergeDataReply.class;
 
   @Override
   public Object toSerializable() {
index dae4cec3c3a606c059771e9335317d1d75c233d7..3cec7e74a6793d47f5575fec2e151b84e1e7cd0b 100644 (file)
@@ -12,7 +12,8 @@ import org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommit
 
 public class PreCommitTransaction implements SerializableMessage{
 
-  public static final Class SERIALIZABLE_CLASS = ThreePhaseCommitCohortMessages.PreCommitTransaction.class;
+  public static final Class<ThreePhaseCommitCohortMessages.PreCommitTransaction> SERIALIZABLE_CLASS =
+          ThreePhaseCommitCohortMessages.PreCommitTransaction.class;
 
   @Override
   public Object toSerializable() {
index fc07bfcb4b786793f02125bfad01f77088bcfe33..d158049409a9a7e23230da76c16ab5b514377ae6 100644 (file)
@@ -12,7 +12,8 @@ import org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommit
 
 public class PreCommitTransactionReply implements SerializableMessage{
 
-  public static final Class SERIALIZABLE_CLASS = ThreePhaseCommitCohortMessages.PreCommitTransactionReply.class;
+  public static final Class<ThreePhaseCommitCohortMessages.PreCommitTransactionReply> SERIALIZABLE_CLASS =
+          ThreePhaseCommitCohortMessages.PreCommitTransactionReply.class;
 
   @Override
   public Object toSerializable() {
index a2f6701524a7f4d2f42a4ce93b4463d368414659..a5565020edc171e43d550f7ace0a8dc6a80739e3 100644 (file)
@@ -10,10 +10,10 @@ package org.opendaylight.controller.cluster.datastore.messages;
 
 
 public class PrimaryFound implements SerializableMessage {
-  public static final Class SERIALIZABLE_CLASS = PrimaryFound.class;
+  public static final Class<PrimaryFound> SERIALIZABLE_CLASS = PrimaryFound.class;
   private final String primaryPath;
 
-  public PrimaryFound(String primaryPath) {
+  public PrimaryFound(final String primaryPath) {
     this.primaryPath = primaryPath;
   }
 
@@ -22,13 +22,19 @@ public class PrimaryFound implements SerializableMessage {
   }
 
   @Override
-  public boolean equals(Object o) {
-    if (this == o) return true;
-    if (o == null || getClass() != o.getClass()) return false;
+  public boolean equals(final Object o) {
+    if (this == o) {
+        return true;
+    }
+    if (o == null || getClass() != o.getClass()) {
+        return false;
+    }
 
     PrimaryFound that = (PrimaryFound) o;
 
-    if (!primaryPath.equals(that.primaryPath)) return false;
+    if (!primaryPath.equals(that.primaryPath)) {
+        return false;
+    }
 
     return true;
   }
@@ -51,7 +57,7 @@ public class PrimaryFound implements SerializableMessage {
     return  this;
   }
 
-  public static PrimaryFound fromSerializable(Object message){
+  public static PrimaryFound fromSerializable(final Object message){
     return (PrimaryFound) message;
   }
 }
index 731a5364db247d52642e31da6e105ea655793196..b47c91b6e5802ee7896ff30ba2b7d1035d8fc338 100644 (file)
@@ -11,11 +11,11 @@ package org.opendaylight.controller.cluster.datastore.messages;
 import com.google.common.base.Preconditions;
 
 public class PrimaryNotFound implements SerializableMessage {
-  public static final Class SERIALIZABLE_CLASS = PrimaryNotFound.class;
+  public static final Class<PrimaryNotFound> SERIALIZABLE_CLASS = PrimaryNotFound.class;
 
     private final String shardName;
 
-    public PrimaryNotFound(String shardName){
+    public PrimaryNotFound(final String shardName){
 
         Preconditions.checkNotNull(shardName, "shardName should not be null");
 
@@ -23,13 +23,19 @@ public class PrimaryNotFound implements SerializableMessage {
     }
 
     @Override
-    public boolean equals(Object o) {
-        if (this == o) return true;
-        if (o == null || getClass() != o.getClass()) return false;
+    public boolean equals(final Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
 
         PrimaryNotFound that = (PrimaryNotFound) o;
 
-        if (shardName != null ? !shardName.equals(that.shardName) : that.shardName != null) return false;
+        if (shardName != null ? !shardName.equals(that.shardName) : that.shardName != null) {
+            return false;
+        }
 
         return true;
     }
@@ -44,7 +50,7 @@ public class PrimaryNotFound implements SerializableMessage {
     return this;
   }
 
-  public static PrimaryNotFound fromSerializable(Object message){
+  public static PrimaryNotFound fromSerializable(final Object message){
     return (PrimaryNotFound) message;
   }
 }
index d743d99fcc12cee6b4da25d306d9d97a567ede0a..a8a3e7d071b7af89135f529523caf8215b279cb0 100644 (file)
@@ -13,10 +13,11 @@ import org.opendaylight.controller.protobuff.messages.transaction.ShardTransacti
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 
 public class ReadData {
-  public static final Class SERIALIZABLE_CLASS = ShardTransactionMessages.ReadData.class;
+  public static final Class<ShardTransactionMessages.ReadData> SERIALIZABLE_CLASS =
+          ShardTransactionMessages.ReadData.class;
   private final YangInstanceIdentifier path;
 
-  public ReadData(YangInstanceIdentifier path) {
+  public ReadData(final YangInstanceIdentifier path) {
     this.path = path;
   }
 
@@ -30,7 +31,7 @@ public class ReadData {
         .build();
   }
 
-  public static ReadData fromSerializable(Object serializable){
+  public static ReadData fromSerializable(final Object serializable){
     ShardTransactionMessages.ReadData o = (ShardTransactionMessages.ReadData) serializable;
     return new ReadData(InstanceIdentifierUtils.fromSerializable(o.getInstanceIdentifierPathArguments()));
   }
index 3a51d9850b78ae1272fb419bbec7068bfd81bbea..581caefd04e9fb83263a06cba9b6014f3b92109d 100644 (file)
@@ -11,7 +11,8 @@ package org.opendaylight.controller.cluster.datastore.messages;
 import org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages;
 
 public class ReadyTransaction implements SerializableMessage{
-  public static final Class SERIALIZABLE_CLASS = ShardTransactionMessages.ReadyTransaction.class;
+  public static final Class<ShardTransactionMessages.ReadyTransaction> SERIALIZABLE_CLASS =
+          ShardTransactionMessages.ReadyTransaction.class;
 
   @Override
   public Object toSerializable() {
index 8d980d283db9c9187733e44c4f685287c83a97ea..bbfbbaa80b0f5966565f7156725e3eea0c1affcb 100644 (file)
@@ -13,10 +13,11 @@ import akka.actor.ActorSystem;
 import org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages;
 
 public class RegisterChangeListenerReply implements SerializableMessage{
-  public static final Class SERIALIZABLE_CLASS = ListenerRegistrationMessages.RegisterChangeListenerReply.class;
+  public static final Class<ListenerRegistrationMessages.RegisterChangeListenerReply> SERIALIZABLE_CLASS =
+          ListenerRegistrationMessages.RegisterChangeListenerReply.class;
   private final ActorPath listenerRegistrationPath;
 
-  public RegisterChangeListenerReply(ActorPath listenerRegistrationPath) {
+  public RegisterChangeListenerReply(final ActorPath listenerRegistrationPath) {
     this.listenerRegistrationPath = listenerRegistrationPath;
   }
 
@@ -30,7 +31,7 @@ public class RegisterChangeListenerReply implements SerializableMessage{
             .setListenerRegistrationPath(listenerRegistrationPath.toString()).build();
   }
 
-  public static RegisterChangeListenerReply fromSerializable(ActorSystem actorSystem,Object serializable){
+  public static RegisterChangeListenerReply fromSerializable(final ActorSystem actorSystem,final Object serializable){
     ListenerRegistrationMessages.RegisterChangeListenerReply o = (ListenerRegistrationMessages.RegisterChangeListenerReply) serializable;
     return new RegisterChangeListenerReply(
         actorSystem.actorFor(o.getListenerRegistrationPath()).path()
index 5404fb65103557235ae8e56f95eebd645ea11b9d..876105de18abf7c4beee7b1c7afca342fc4086b2 100644 (file)
@@ -11,7 +11,8 @@ package org.opendaylight.controller.cluster.datastore.messages;
 import org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages;
 
 public class WriteDataReply implements SerializableMessage{
-  public static final Class SERIALIZABLE_CLASS = ShardTransactionMessages.WriteDataReply.class;
+  public static final Class<ShardTransactionMessages.WriteDataReply> SERIALIZABLE_CLASS =
+          ShardTransactionMessages.WriteDataReply.class;
   @Override
   public Object toSerializable() {
     return ShardTransactionMessages.WriteDataReply.newBuilder().build();
index 24c4c6c50a63fe171ca001bafe25ec7ee62e0970..2f9d77660aba4d76b671b91df000baae5c5780ba 100644 (file)
@@ -20,18 +20,19 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContext;
  * MergeModification stores all the parameters required to merge data into the specified path
  */
 public class MergeModification extends WriteModification {
+    private static final long serialVersionUID = 1L;
 
-    public MergeModification(YangInstanceIdentifier path, NormalizedNode data,
-        SchemaContext schemaContext) {
+    public MergeModification(final YangInstanceIdentifier path, final NormalizedNode<?, ?> data,
+        final SchemaContext schemaContext) {
         super(path, data, schemaContext);
     }
 
     @Override
-    public void apply(DOMStoreWriteTransaction transaction) {
+    public void apply(final DOMStoreWriteTransaction transaction) {
         transaction.merge(path, data);
     }
 
-    public static MergeModification fromSerializable(Object serializable, SchemaContext schemaContext) {
+    public static MergeModification fromSerializable(final Object serializable, final SchemaContext schemaContext) {
         PersistentMessages.Modification o = (PersistentMessages.Modification) serializable;
         Decoded decoded = new NormalizedNodeToNodeCodec(schemaContext).decode(o.getPath(), o.getData());
         return new MergeModification(decoded.getDecodedPath(), decoded.getDecodedNode(), schemaContext);
index 53cc35a88be26f2ba9f9e0fda8994e8fdfb20584..b2964086fd976b03516df0872d007f2f0a124af6 100644 (file)
@@ -21,22 +21,22 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContext;
  * WriteModification stores all the parameters required to write data to the specified path
  */
 public class WriteModification extends AbstractModification {
-
-    protected final NormalizedNode data;
+    private static final long serialVersionUID = 1L;
+    protected final NormalizedNode<?, ?> data;
     private final SchemaContext schemaContext;
 
-    public WriteModification(YangInstanceIdentifier path, NormalizedNode data, SchemaContext schemaContext) {
+    public WriteModification(final YangInstanceIdentifier path, final NormalizedNode<?, ?> data, final SchemaContext schemaContext) {
         super(path);
         this.data = data;
         this.schemaContext = schemaContext;
     }
 
     @Override
-    public void apply(DOMStoreWriteTransaction transaction) {
+    public void apply(final DOMStoreWriteTransaction transaction) {
         transaction.write(path, data);
     }
 
-    public NormalizedNode getData() {
+    public NormalizedNode<?, ?> getData() {
         return data;
     }
 
@@ -51,7 +51,7 @@ public class WriteModification extends AbstractModification {
                 .build();
     }
 
-    public static WriteModification fromSerializable(Object serializable, SchemaContext schemaContext) {
+    public static WriteModification fromSerializable(final Object serializable, final SchemaContext schemaContext) {
         PersistentMessages.Modification o = (PersistentMessages.Modification) serializable;
         Decoded decoded = new NormalizedNodeToNodeCodec(schemaContext).decode(o.getPath(), o.getData());
         return new WriteModification(decoded.getDecodedPath(), decoded.getDecodedNode(), schemaContext);
index f4ab8fab6f768e84bd48c15ebc83e862315e09eb..62fb65482b09d366289107f93df14050340688c4 100644 (file)
@@ -10,26 +10,25 @@ package org.opendaylight.controller.cluster.datastore.shardstrategy;
 
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
-import org.opendaylight.controller.cluster.datastore.Configuration;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
+import org.opendaylight.controller.cluster.datastore.Configuration;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 
 public class ShardStrategyFactory {
     private static Map<String, ShardStrategy> moduleNameToStrategyMap =
-        new ConcurrentHashMap();
+        new ConcurrentHashMap<>();
 
     private static final String UNKNOWN_MODULE_NAME = "unknown";
     private static Configuration configuration;
 
 
-    public static void setConfiguration(Configuration configuration){
+    public static void setConfiguration(final Configuration configuration){
         ShardStrategyFactory.configuration = configuration;
         moduleNameToStrategyMap = configuration.getModuleNameToShardStrategyMap();
     }
 
-    public static ShardStrategy getStrategy(YangInstanceIdentifier path) {
+    public static ShardStrategy getStrategy(final YangInstanceIdentifier path) {
         Preconditions.checkState(configuration != null, "configuration should not be missing");
         Preconditions.checkNotNull(path, "path should not be null");
 
@@ -44,7 +43,7 @@ public class ShardStrategyFactory {
     }
 
 
-    private static String getModuleName(YangInstanceIdentifier path) {
+    private static String getModuleName(final YangInstanceIdentifier path) {
         String namespace = path.getPathArguments().iterator().next().getNodeType().getNamespace().toASCIIString();
 
         Optional<String> optional =
index 8c253596b8b752c264f81cced7090087fc02879b..afc060318ce783a8a8041e4b38c008181df3e16f 100644 (file)
@@ -1,17 +1,15 @@
 package org.opendaylight.controller.cluster.datastore;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
 import com.typesafe.config.ConfigFactory;
-import junit.framework.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
 import java.io.File;
 import java.util.List;
 import java.util.Set;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
 
 public class ConfigurationImplTest {
 
index c79d76203589c51126dbd281adfd7dcaf4712db4..55250dd5e9cd3ea71c0356f5313c09d930700c00 100644 (file)
@@ -3,6 +3,11 @@ package org.opendaylight.controller.cluster.datastore;
 
 import akka.actor.ActorRef;
 import akka.actor.Props;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
 import org.junit.Assert;
 import org.junit.Test;
 import org.opendaylight.controller.cluster.datastore.messages.DataChanged;
@@ -17,18 +22,12 @@ import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
 public class DataChangeListenerProxyTest extends AbstractActorTest {
 
   private static class MockDataChangedEvent implements AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> {
-    Map<YangInstanceIdentifier,NormalizedNode<?,?>> createdData = new HashMap();
-    Map<YangInstanceIdentifier,NormalizedNode<?,?>> updatedData = new HashMap();
-    Map<YangInstanceIdentifier,NormalizedNode<?,?>> originalData = new HashMap();
+    Map<YangInstanceIdentifier,NormalizedNode<?,?>> createdData = new HashMap<>();
+    Map<YangInstanceIdentifier,NormalizedNode<?,?>> updatedData = new HashMap<>();
+    Map<YangInstanceIdentifier,NormalizedNode<?,?>> originalData = new HashMap<>();
 
 
 
@@ -88,7 +87,7 @@ public class DataChangeListenerProxyTest extends AbstractActorTest {
 
         Assert.assertTrue(messages instanceof List);
 
-        List<Object> listMessages = (List<Object>) messages;
+        List<?> listMessages = (List<?>) messages;
 
         Assert.assertEquals(1, listMessages.size());
 
index 25915b198ca3cda368a92771356aaaca92ed57e4..12c566d33de786db62bfad3ec86a56939edbe1c2 100644 (file)
@@ -77,10 +77,7 @@ public class DistributedDataStoreIntegrationTest extends AbstractActorTest {
 
             DOMStoreThreePhaseCommitCohort cohort = writeTx.ready();
 
-            Boolean canCommit = cohort.canCommit().get(5, TimeUnit.SECONDS);
-            assertEquals("canCommit", true, canCommit);
-            cohort.preCommit().get(5, TimeUnit.SECONDS);
-            cohort.commit().get(5, TimeUnit.SECONDS);
+            doCommit(cohort);
 
             // Verify the data in the store
 
@@ -131,10 +128,7 @@ public class DistributedDataStoreIntegrationTest extends AbstractActorTest {
 
             // 5. Commit the Tx
 
-            Boolean canCommit = cohort.canCommit().get(5, TimeUnit.SECONDS);
-            assertEquals("canCommit", true, canCommit);
-            cohort.preCommit().get(5, TimeUnit.SECONDS);
-            cohort.commit().get(5, TimeUnit.SECONDS);
+            doCommit(cohort);
 
             // 6. Verify the data in the store
 
@@ -219,9 +213,7 @@ public class DistributedDataStoreIntegrationTest extends AbstractActorTest {
 
             // Wait for the Tx commit to complete.
 
-            assertEquals("canCommit", true, txCohort.get().canCommit().get(5, TimeUnit.SECONDS));
-            txCohort.get().preCommit().get(5, TimeUnit.SECONDS);
-            txCohort.get().commit().get(5, TimeUnit.SECONDS);
+            doCommit(txCohort.get());
 
             // Verify the data in the store
 
@@ -552,10 +544,8 @@ public class DistributedDataStoreIntegrationTest extends AbstractActorTest {
 
     @Test
     public void testTransactionChain() throws Exception{
-        System.setProperty("shard.persistent", "true");
         new IntegrationTestKit(getSystem()) {{
-            DistributedDataStore dataStore =
-                    setupDistributedDataStore("transactionChainIntegrationTest", "test-1");
+            DistributedDataStore dataStore = setupDistributedDataStore("testTransactionChain", "test-1");
 
             // 1. Create a Tx chain and write-only Tx
 
@@ -637,13 +627,6 @@ public class DistributedDataStoreIntegrationTest extends AbstractActorTest {
             assertEquals("Data node", outerNode, optional.get());
 
             cleanup(dataStore);
-        }
-
-        private void doCommit(final DOMStoreThreePhaseCommitCohort cohort1) throws Exception {
-            Boolean canCommit = cohort1.canCommit().get(5, TimeUnit.SECONDS);
-            assertEquals("canCommit", true, canCommit);
-            cohort1.preCommit().get(5, TimeUnit.SECONDS);
-            cohort1.commit().get(5, TimeUnit.SECONDS);
         }};
     }
 
@@ -653,7 +636,10 @@ public class DistributedDataStoreIntegrationTest extends AbstractActorTest {
             DistributedDataStore dataStore =
                     setupDistributedDataStore("testChangeListenerRegistration", "test-1");
 
-            MockDataChangeListener listener = new MockDataChangeListener(3);
+            testWriteTransaction(dataStore, TestModel.TEST_PATH,
+                    ImmutableNodes.containerNode(TestModel.TEST_QNAME));
+
+            MockDataChangeListener listener = new MockDataChangeListener(1);
 
             ListenerRegistration<MockDataChangeListener>
                     listenerReg = dataStore.registerChangeListener(TestModel.TEST_PATH, listener,
@@ -661,8 +647,13 @@ public class DistributedDataStoreIntegrationTest extends AbstractActorTest {
 
             assertNotNull("registerChangeListener returned null", listenerReg);
 
-            testWriteTransaction(dataStore, TestModel.TEST_PATH,
-                    ImmutableNodes.containerNode(TestModel.TEST_QNAME));
+            // Wait for the initial notification
+
+            listener.waitForChangeEvents(TestModel.TEST_PATH);
+
+            listener.reset(2);
+
+            // Write 2 updates.
 
             testWriteTransaction(dataStore, TestModel.OUTER_LIST_PATH,
                     ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME).build());
@@ -672,7 +663,9 @@ public class DistributedDataStoreIntegrationTest extends AbstractActorTest {
             testWriteTransaction(dataStore, listPath,
                     ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1));
 
-            listener.waitForChangeEvents(TestModel.TEST_PATH, TestModel.OUTER_LIST_PATH, listPath );
+            // Wait for the 2 updates.
+
+            listener.waitForChangeEvents(TestModel.OUTER_LIST_PATH, listPath);
 
             listenerReg.close();
 
@@ -747,10 +740,7 @@ public class DistributedDataStoreIntegrationTest extends AbstractActorTest {
 
             // 4. Commit the Tx
 
-            Boolean canCommit = cohort.canCommit().get(5, TimeUnit.SECONDS);
-            assertEquals("canCommit", true, canCommit);
-            cohort.preCommit().get(5, TimeUnit.SECONDS);
-            cohort.commit().get(5, TimeUnit.SECONDS);
+            doCommit(cohort);
 
             // 5. Verify the data in the store
 
@@ -761,6 +751,13 @@ public class DistributedDataStoreIntegrationTest extends AbstractActorTest {
             assertEquals("Data node", nodeToWrite, optional.get());
         }
 
+        void doCommit(final DOMStoreThreePhaseCommitCohort cohort) throws Exception {
+            Boolean canCommit = cohort.canCommit().get(5, TimeUnit.SECONDS);
+            assertEquals("canCommit", true, canCommit);
+            cohort.preCommit().get(5, TimeUnit.SECONDS);
+            cohort.commit().get(5, TimeUnit.SECONDS);
+        }
+
         void cleanup(DistributedDataStore dataStore) {
             dataStore.getActorContext().getShardManager().tell(PoisonPill.getInstance(), null);
         }
index c6bb0d6b37061b8055d4065a990cc2acad21c935..e5b5643297b88d49ab74bffdf90637a61988a72e 100644 (file)
@@ -1,5 +1,16 @@
 package org.opendaylight.controller.cluster.datastore;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.inOrder;
+import static org.mockito.Mockito.mock;
+import static org.opendaylight.controller.cluster.datastore.messages.CreateTransaction.CURRENT_VERSION;
 import akka.actor.ActorRef;
 import akka.actor.PoisonPill;
 import akka.actor.Props;
@@ -16,6 +27,16 @@ import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.MoreExecutors;
 import com.google.common.util.concurrent.Uninterruptibles;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicReference;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -80,29 +101,6 @@ import scala.concurrent.Await;
 import scala.concurrent.Future;
 import scala.concurrent.duration.FiniteDuration;
 
-import java.io.IOException;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicReference;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import static org.mockito.Mockito.doAnswer;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.inOrder;
-import static org.mockito.Mockito.mock;
-import static org.opendaylight.controller.cluster.datastore.messages.CreateTransaction.CURRENT_VERSION;
-
 
 public class ShardTest extends AbstractActorTest {
 
@@ -308,6 +306,7 @@ public class ShardTest extends AbstractActorTest {
         }};
     }
 
+    @SuppressWarnings("serial")
     @Test
     public void testPeerAddressResolved() throws Exception {
         new ShardTestKit(getSystem()) {{
@@ -509,7 +508,7 @@ public class ShardTest extends AbstractActorTest {
         shard.tell(PoisonPill.getInstance(), ActorRef.noSender());
     }
 
-    private CompositeModificationPayload newPayload(Modification... mods) {
+    private CompositeModificationPayload newPayload(final Modification... mods) {
         MutableCompositeModification compMod = new MutableCompositeModification();
         for(Modification mod: mods) {
             compMod.addModification(mod);
@@ -518,15 +517,15 @@ public class ShardTest extends AbstractActorTest {
         return new CompositeModificationPayload(compMod.toSerializable());
     }
 
-    private DOMStoreThreePhaseCommitCohort setupMockWriteTransaction(String cohortName,
-            InMemoryDOMDataStore dataStore, YangInstanceIdentifier path, NormalizedNode data,
-            MutableCompositeModification modification) {
+    private DOMStoreThreePhaseCommitCohort setupMockWriteTransaction(final String cohortName,
+            final InMemoryDOMDataStore dataStore, final YangInstanceIdentifier path, final NormalizedNode<?, ?> data,
+            final MutableCompositeModification modification) {
         return setupMockWriteTransaction(cohortName, dataStore, path, data, modification, null);
     }
 
-    private DOMStoreThreePhaseCommitCohort setupMockWriteTransaction(String cohortName,
-            InMemoryDOMDataStore dataStore, YangInstanceIdentifier path, NormalizedNode data,
-            MutableCompositeModification modification,
+    private DOMStoreThreePhaseCommitCohort setupMockWriteTransaction(final String cohortName,
+            final InMemoryDOMDataStore dataStore, final YangInstanceIdentifier path, final NormalizedNode<?, ?> data,
+            final MutableCompositeModification modification,
             final Function<DOMStoreThreePhaseCommitCohort,ListenableFuture<Void>> preCommit) {
 
         DOMStoreWriteTransaction tx = dataStore.newWriteOnlyTransaction();
@@ -536,14 +535,14 @@ public class ShardTest extends AbstractActorTest {
 
         doAnswer(new Answer<ListenableFuture<Boolean>>() {
             @Override
-            public ListenableFuture<Boolean> answer(InvocationOnMock invocation) {
+            public ListenableFuture<Boolean> answer(final InvocationOnMock invocation) {
                 return realCohort.canCommit();
             }
         }).when(cohort).canCommit();
 
         doAnswer(new Answer<ListenableFuture<Void>>() {
             @Override
-            public ListenableFuture<Void> answer(InvocationOnMock invocation) throws Throwable {
+            public ListenableFuture<Void> answer(final InvocationOnMock invocation) throws Throwable {
                 if(preCommit != null) {
                     return preCommit.apply(realCohort);
                 } else {
@@ -554,14 +553,14 @@ public class ShardTest extends AbstractActorTest {
 
         doAnswer(new Answer<ListenableFuture<Void>>() {
             @Override
-            public ListenableFuture<Void> answer(InvocationOnMock invocation) throws Throwable {
+            public ListenableFuture<Void> answer(final InvocationOnMock invocation) throws Throwable {
                 return realCohort.commit();
             }
         }).when(cohort).commit();
 
         doAnswer(new Answer<ListenableFuture<Void>>() {
             @Override
-            public ListenableFuture<Void> answer(InvocationOnMock invocation) throws Throwable {
+            public ListenableFuture<Void> answer(final InvocationOnMock invocation) throws Throwable {
                 return realCohort.abort();
             }
         }).when(cohort).abort();
@@ -658,12 +657,12 @@ public class ShardTest extends AbstractActorTest {
             class OnFutureComplete extends OnComplete<Object> {
                 private final Class<?> expRespType;
 
-                OnFutureComplete(Class<?> expRespType) {
+                OnFutureComplete(final Class<?> expRespType) {
                     this.expRespType = expRespType;
                 }
 
                 @Override
-                public void onComplete(Throwable error, Object resp) {
+                public void onComplete(final Throwable error, final Object resp) {
                     if(error != null) {
                         caughtEx.set(new AssertionError(getClass().getSimpleName() + " failure", error));
                     } else {
@@ -676,7 +675,7 @@ public class ShardTest extends AbstractActorTest {
                     }
                 }
 
-                void onSuccess(Object resp) throws Exception {
+                void onSuccess(final Object resp) throws Exception {
                 }
             }
 
@@ -686,7 +685,7 @@ public class ShardTest extends AbstractActorTest {
                 }
 
                 @Override
-                public void onComplete(Throwable error, Object resp) {
+                public void onComplete(final Throwable error, final Object resp) {
                     super.onComplete(error, resp);
                     commitLatch.countDown();
                 }
@@ -695,13 +694,13 @@ public class ShardTest extends AbstractActorTest {
             class OnCanCommitFutureComplete extends OnFutureComplete {
                 private final String transactionID;
 
-                OnCanCommitFutureComplete(String transactionID) {
+                OnCanCommitFutureComplete(final String transactionID) {
                     super(CanCommitTransactionReply.SERIALIZABLE_CLASS);
                     this.transactionID = transactionID;
                 }
 
                 @Override
-                void onSuccess(Object resp) throws Exception {
+                void onSuccess(final Object resp) throws Exception {
                     CanCommitTransactionReply canCommitReply =
                             CanCommitTransactionReply.fromSerializable(resp);
                     assertEquals("Can commit", true, canCommitReply.getCanCommit());
@@ -828,7 +827,7 @@ public class ShardTest extends AbstractActorTest {
             final CountDownLatch latch = new CountDownLatch(1);
             canCommitFuture.onComplete(new OnComplete<Object>() {
                 @Override
-                public void onComplete(Throwable t, Object resp) {
+                public void onComplete(final Throwable t, final Object resp) {
                     latch.countDown();
                 }
             }, getSystem().dispatcher());
@@ -948,7 +947,7 @@ public class ShardTest extends AbstractActorTest {
                             new AbortTransaction(transactionID).toSerializable(), timeout);
                     abortFuture.onComplete(new OnComplete<Object>() {
                         @Override
-                        public void onComplete(Throwable e, Object resp) {
+                        public void onComplete(final Throwable e, final Object resp) {
                             abortComplete.countDown();
                         }
                     }, getSystem().dispatcher());
@@ -1195,7 +1194,7 @@ public class ShardTest extends AbstractActorTest {
             final CountDownLatch latch = new CountDownLatch(1);
             canCommitFuture.onComplete(new OnComplete<Object>() {
                 @Override
-                public void onComplete(Throwable t, Object resp) {
+                public void onComplete(final Throwable t, final Object resp) {
                     latch.countDown();
                 }
             }, getSystem().dispatcher());
@@ -1220,7 +1219,8 @@ public class ShardTest extends AbstractActorTest {
         testCreateSnapshot(false, "testCreateSnapshotWithNonPersistentData");
     }
 
-    public void testCreateSnapshot(boolean persistent, final String shardActorName) throws IOException, InterruptedException {
+    @SuppressWarnings("serial")
+    public void testCreateSnapshot(final boolean persistent, final String shardActorName) throws IOException, InterruptedException {
         final DatastoreContext dataStoreContext = DatastoreContext.newBuilder().
                 shardJournalRecoveryLogBatchSize(3).shardSnapshotBatchCount(5000).persistent(persistent).build();
 
@@ -1232,7 +1232,7 @@ public class ShardTest extends AbstractActorTest {
                     return new Shard(shardID, Collections.<ShardIdentifier,String>emptyMap(),
                             dataStoreContext, SCHEMA_CONTEXT) {
                         @Override
-                        protected void commitSnapshot(long sequenceNumber) {
+                        protected void commitSnapshot(final long sequenceNumber) {
                             super.commitSnapshot(sequenceNumber);
                             latch.get().countDown();
                         }
@@ -1275,7 +1275,7 @@ public class ShardTest extends AbstractActorTest {
         commitTransaction(putTransaction);
 
 
-        NormalizedNode expected = readStore(store);
+        NormalizedNode<?, ?> expected = readStore(store);
 
         DOMStoreWriteTransaction writeTransaction = store.newWriteOnlyTransaction();
 
@@ -1284,7 +1284,7 @@ public class ShardTest extends AbstractActorTest {
 
         commitTransaction(writeTransaction);
 
-        NormalizedNode actual = readStore(store);
+        NormalizedNode<?, ?> actual = readStore(store);
 
         assertEquals(expected, actual);
 
@@ -1325,7 +1325,7 @@ public class ShardTest extends AbstractActorTest {
     }
 
 
-    private NormalizedNode readStore(InMemoryDOMDataStore store) throws ReadFailedException {
+    private NormalizedNode<?, ?> readStore(final InMemoryDOMDataStore store) throws ReadFailedException {
         DOMStoreReadTransaction transaction = store.newReadOnlyTransaction();
         CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read =
             transaction.read(YangInstanceIdentifier.builder().build());
@@ -1339,7 +1339,7 @@ public class ShardTest extends AbstractActorTest {
         return normalizedNode;
     }
 
-    private void commitTransaction(DOMStoreWriteTransaction transaction) {
+    private void commitTransaction(final DOMStoreWriteTransaction transaction) {
         DOMStoreThreePhaseCommitCohort commitCohort = transaction.ready();
         ListenableFuture<Void> future =
             commitCohort.preCommit();
@@ -1355,13 +1355,13 @@ public class ShardTest extends AbstractActorTest {
         return new AsyncDataChangeListener<YangInstanceIdentifier, NormalizedNode<?, ?>>() {
             @Override
             public void onDataChanged(
-                AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change) {
+                final AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change) {
 
             }
         };
     }
 
-    static NormalizedNode<?,?> readStore(TestActorRef<Shard> shard, YangInstanceIdentifier id)
+    static NormalizedNode<?,?> readStore(final TestActorRef<Shard> shard, final YangInstanceIdentifier id)
             throws ExecutionException, InterruptedException {
         DOMStoreReadTransaction transaction = shard.underlyingActor().getDataStore().newReadOnlyTransaction();
 
@@ -1376,7 +1376,7 @@ public class ShardTest extends AbstractActorTest {
         return node;
     }
 
-    private void writeToStore(TestActorRef<Shard> shard, YangInstanceIdentifier id, NormalizedNode<?,?> node)
+    private void writeToStore(final TestActorRef<Shard> shard, final YangInstanceIdentifier id, final NormalizedNode<?,?> node)
         throws ExecutionException, InterruptedException {
         DOMStoreWriteTransaction transaction = shard.underlyingActor().getDataStore().newWriteOnlyTransaction();
 
@@ -1387,10 +1387,11 @@ public class ShardTest extends AbstractActorTest {
         commitCohort.commit().get();
     }
 
+    @SuppressWarnings("serial")
     private static final class DelegatingShardCreator implements Creator<Shard> {
         private final Creator<Shard> delegate;
 
-        DelegatingShardCreator(Creator<Shard> delegate) {
+        DelegatingShardCreator(final Creator<Shard> delegate) {
             this.delegate = delegate;
         }
 
index 45b00f5f31b72c3d628be7957a09804c7e6b26be..5781c19b252717c24c1795d83131ea6c158bcf32 100644 (file)
 
 package org.opendaylight.controller.cluster.datastore;
 
+import akka.actor.ActorRef;
+import akka.actor.Props;
+import akka.pattern.AskTimeoutException;
+import akka.testkit.TestActorRef;
+import com.google.common.util.concurrent.ListeningExecutorService;
+import com.google.common.util.concurrent.MoreExecutors;
 import java.util.Collections;
 import java.util.concurrent.TimeUnit;
 import org.junit.BeforeClass;
@@ -29,12 +35,6 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import scala.concurrent.Await;
 import scala.concurrent.Future;
 import scala.concurrent.duration.Duration;
-import akka.actor.ActorRef;
-import akka.actor.Props;
-import akka.pattern.AskTimeoutException;
-import akka.testkit.TestActorRef;
-import com.google.common.util.concurrent.ListeningExecutorService;
-import com.google.common.util.concurrent.MoreExecutors;
 
 /**
  * Covers negative test cases
@@ -66,7 +66,7 @@ public class ShardTransactionFailureTest extends AbstractActorTest {
     }
 
     private ActorRef createShard(){
-        return getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP, datastoreContext,
+        return getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.<ShardIdentifier, String>emptyMap(), datastoreContext,
                 TestModel.createTestContext()));
     }
 
index c869be82d24bcbbd0cedca4b5a6e2a9001c46fad..4ccc9430ace37605e002fbcf8800279b85fa4fcd 100644 (file)
@@ -4,6 +4,13 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
+import akka.actor.ActorRef;
+import akka.actor.Props;
+import akka.actor.Terminated;
+import akka.testkit.JavaTestKit;
+import akka.testkit.TestActorRef;
+import com.google.common.util.concurrent.ListeningExecutorService;
+import com.google.common.util.concurrent.MoreExecutors;
 import java.util.Collections;
 import java.util.concurrent.TimeUnit;
 import org.junit.BeforeClass;
@@ -39,13 +46,6 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import scala.concurrent.duration.Duration;
-import akka.actor.ActorRef;
-import akka.actor.Props;
-import akka.actor.Terminated;
-import akka.testkit.JavaTestKit;
-import akka.testkit.TestActorRef;
-import com.google.common.util.concurrent.ListeningExecutorService;
-import com.google.common.util.concurrent.MoreExecutors;
 
 public class ShardTransactionTest extends AbstractActorTest {
     private static ListeningExecutorService storeExecutor =
@@ -71,7 +71,7 @@ public class ShardTransactionTest extends AbstractActorTest {
 
     private ActorRef createShard(){
         return getSystem().actorOf(Shard.props(SHARD_IDENTIFIER,
-            Collections.EMPTY_MAP, datastoreContext, TestModel.createTestContext()));
+            Collections.<ShardIdentifier, String>emptyMap(), datastoreContext, TestModel.createTestContext()));
     }
 
     @Test
index 3394cdc959757e167cb71988cf3d8e208fde041d..b895b75fcde1ee7421b324492319c59d0bfc6d93 100644 (file)
@@ -1,5 +1,6 @@
 package org.opendaylight.controller.cluster.datastore.shardstrategy;
 
+import static org.junit.Assert.assertEquals;
 import org.junit.BeforeClass;
 import org.junit.Rule;
 import org.junit.Test;
@@ -10,8 +11,6 @@ import org.opendaylight.controller.md.cluster.datastore.model.CarsModel;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 
-import static junit.framework.Assert.assertEquals;
-
 public class ModuleShardStrategyTest {
     @Rule
     public ExpectedException expectedEx = ExpectedException.none();
index ab74ba811a6348c4969a2408644b0e48502af076..10e832780d26ca7e8603e14ef82fbeac0e57b16e 100644 (file)
@@ -1,5 +1,7 @@
 package org.opendaylight.controller.cluster.datastore.shardstrategy;
 
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 import org.junit.BeforeClass;
 import org.junit.Rule;
 import org.junit.Test;
@@ -9,9 +11,6 @@ import org.opendaylight.controller.md.cluster.datastore.model.CarsModel;
 import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 
-import static junit.framework.Assert.assertNotNull;
-import static junit.framework.Assert.assertTrue;
-
 public class ShardStrategyFactoryTest {
 
     @Rule
index 06c5767bd030c1b5872969025902566a7cc3e27c..4ef7d65857b3c86a76d405eeca52c888f6f9fc55 100644 (file)
@@ -9,43 +9,42 @@
 package org.opendaylight.controller.cluster.datastore.utils;
 
 import com.google.common.base.Optional;
-import org.opendaylight.controller.cluster.datastore.Configuration;
-import org.opendaylight.controller.cluster.datastore.shardstrategy.ShardStrategy;
-
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import org.opendaylight.controller.cluster.datastore.Configuration;
+import org.opendaylight.controller.cluster.datastore.shardstrategy.ShardStrategy;
 
 public class MockConfiguration implements Configuration{
-    @Override public List<String> getMemberShardNames(String memberName) {
+    @Override public List<String> getMemberShardNames(final String memberName) {
         return Arrays.asList("default");
     }
 
     @Override public Optional<String> getModuleNameFromNameSpace(
-        String nameSpace) {
+        final String nameSpace) {
         return Optional.absent();
     }
 
     @Override
     public Map<String, ShardStrategy> getModuleNameToShardStrategyMap() {
-        return Collections.EMPTY_MAP;
+        return Collections.emptyMap();
     }
 
     @Override public List<String> getShardNamesFromModuleName(
-        String moduleName) {
-        return Collections.EMPTY_LIST;
+        final String moduleName) {
+        return Collections.emptyList();
     }
 
-    @Override public List<String> getMembersFromShardName(String shardName) {
+    @Override public List<String> getMembersFromShardName(final String shardName) {
         if("default".equals(shardName)) {
             return Arrays.asList("member-1", "member-2");
         } else if("astronauts".equals(shardName)){
             return Arrays.asList("member-2", "member-3");
         }
 
-        return Collections.EMPTY_LIST;
+        return Collections.emptyList();
     }
 
     @Override public Set<String> getAllShardNames() {
index f2f49d1bf3e21f048b393d5f5c14a6e9595e05d6..5bbdcae93c2241cd8b9e7a87613735b69841973d 100644 (file)
@@ -9,6 +9,10 @@ package org.opendaylight.controller.cluster.datastore.utils;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import com.google.common.collect.Lists;
+import com.google.common.util.concurrent.Uninterruptibles;
+import java.util.Collections;
 import java.util.List;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
@@ -16,8 +20,6 @@ import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeListener;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import com.google.common.collect.Lists;
-import com.google.common.util.concurrent.Uninterruptibles;
 
 /**
  * A mock DataChangeListener implementation.
@@ -27,14 +29,21 @@ import com.google.common.util.concurrent.Uninterruptibles;
 public class MockDataChangeListener implements
                          AsyncDataChangeListener<YangInstanceIdentifier, NormalizedNode<?, ?>> {
 
-    private final List<AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>>>
-                                                               changeList = Lists.newArrayList();
-    private final CountDownLatch changeLatch;
-    private final int expChangeEventCount;
+    private final List<AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>>> changeList =
+            Collections.synchronizedList(Lists.<AsyncDataChangeEvent<YangInstanceIdentifier,
+                                                NormalizedNode<?, ?>>>newArrayList());
+
+    private volatile CountDownLatch changeLatch;
+    private int expChangeEventCount;
 
     public MockDataChangeListener(int expChangeEventCount) {
+        reset(expChangeEventCount);
+    }
+
+    public void reset(int expChangeEventCount) {
         changeLatch = new CountDownLatch(expChangeEventCount);
         this.expChangeEventCount = expChangeEventCount;
+        changeList.clear();
     }
 
     @Override
@@ -44,8 +53,13 @@ public class MockDataChangeListener implements
     }
 
     public void waitForChangeEvents(YangInstanceIdentifier... expPaths) {
-        assertEquals("Change notifications complete", true,
-                Uninterruptibles.awaitUninterruptibly(changeLatch, 5, TimeUnit.SECONDS));
+        boolean done = Uninterruptibles.awaitUninterruptibly(changeLatch, 5, TimeUnit.SECONDS);
+        if(!done) {
+            fail(String.format("Missing change notifications. Expected: %d. Actual: %d",
+                    expChangeEventCount, (expChangeEventCount - changeLatch.getCount())));
+        }
+
+        assertEquals("Change notifications complete", true, done);
 
         for(int i = 0; i < expPaths.length; i++) {
             assertTrue(String.format("Change %d does not contain %s", (i+1), expPaths[i]),
index 3bad4689506525bf683254534d44036ff8a61d7e..a2c44b063091fd45829624cde07230e325222336 100644 (file)
@@ -11,13 +11,12 @@ package org.opendaylight.controller.cluster.datastore.utils;
 import akka.actor.ActorRef;
 import akka.actor.ActorSystem;
 import akka.actor.Props;
-import junit.framework.Assert;
-
 import java.util.List;
+import org.junit.Assert;
 
 public class TestUtils {
 
-    public static void assertFirstSentMessage(ActorSystem actorSystem, ActorRef actorRef, Class clazz){
+    public static void assertFirstSentMessage(final ActorSystem actorSystem, final ActorRef actorRef, final Class<?> clazz){
         ActorContext testContext = new ActorContext(actorSystem, actorSystem.actorOf(
             Props.create(DoNothingActor.class)), new MockClusterWrapper(), new MockConfiguration());
         Object messages = testContext
@@ -27,7 +26,7 @@ public class TestUtils {
 
         Assert.assertTrue(messages instanceof List);
 
-        List<Object> listMessages = (List<Object>) messages;
+        List<?> listMessages = (List<?>) messages;
 
         Assert.assertEquals(1, listMessages.size());
 
index 6860872b75fddaf0c952af3943a8713f977531f5..93b552a6dabad014d698146981d83ce27a644117 100644 (file)
@@ -31,7 +31,7 @@ public class CarsModel {
     public static final QName CAR_PRICE_QNAME = QName.create(CAR_QNAME, "price");
 
 
-    public static NormalizedNode create(){
+    public static NormalizedNode<?, ?> create(){
 
         // Create a list builder
         CollectionNodeBuilder<MapEntryNode, MapNode> cars =
@@ -63,7 +63,7 @@ public class CarsModel {
 
     }
 
-    public static NormalizedNode emptyContainer(){
+    public static NormalizedNode<?, ?> emptyContainer(){
         return ImmutableContainerNodeBuilder.create()
             .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(BASE_QNAME))
             .build();
index e637920e7855c9859ee9cab249f31b20766e9ef2..a7cb14f0b3ac1964c16008f67e8c443e182b0bc4 100644 (file)
@@ -30,7 +30,7 @@ public class PeopleModel {
 
 
 
-    public static NormalizedNode create(){
+    public static NormalizedNode<?, ?> create(){
 
         // Create a list builder
         CollectionNodeBuilder<MapEntryNode, MapNode> cars =
@@ -62,7 +62,7 @@ public class PeopleModel {
 
     }
 
-    public static NormalizedNode emptyContainer(){
+    public static NormalizedNode<?, ?> emptyContainer(){
         return ImmutableContainerNodeBuilder.create()
             .withNodeIdentifier(
                 new YangInstanceIdentifier.NodeIdentifier(BASE_QNAME))
index 2300f9d130bcea6049326b3e42b2ac3084df6051..b814bc392e365f8d9f0503eae6c3f81128d35f22 100644 (file)
@@ -8,7 +8,7 @@
 
 package org.opendaylight.controller.md.cluster.datastore.model;
 
-import junit.framework.Assert;
+import org.junit.Assert;
 import org.junit.Test;
 import org.opendaylight.controller.cluster.datastore.node.NormalizedNodeToNodeCodec;
 import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages;
index fdb864059fbca351bba441045d4a7a89810bb558..4632ed8a6f8e6ccaa86896c97f8998353f71bb2a 100644 (file)
@@ -14,7 +14,7 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 
 /**
- * Data Broker which provides data transaction and data change listener fuctionality
+ * Data Broker which provides data transaction and data change listener functionality
  * using {@link NormalizedNode} data format.
  *
  * This interface is type capture of generic interfaces and returns type captures
index 05c4793218646a85d238bd9ba6d4fc74f8269090..e876ccb3064454463767d9aa7f138b7b3e57a180 100644 (file)
@@ -8,14 +8,14 @@
 
 package org.opendaylight.controller.sal.dom.broker;
 
-import static junit.framework.Assert.fail;
+import static org.junit.Assert.fail;
 import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.doAnswer;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
-
+import com.google.common.base.Optional;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mock;
@@ -36,8 +36,6 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.base.Optional;
-
 public class BackwardsCompatibleMountPointManagerTest {
     private static final Logger log = LoggerFactory.getLogger(BackwardsCompatibleMountPointManagerTest.class);
 
@@ -106,7 +104,7 @@ public class BackwardsCompatibleMountPointManagerTest {
 
     private DOMMountPoint mockMountPoint() {
         final DOMMountPoint mock = mock(DOMMountPoint.class);
-        doAnswer(new Answer() {
+        doAnswer(new Answer<Object>() {
             @Override
             public Object answer(final InvocationOnMock invocation) throws Throwable {
                 return Optional.of(mock(((Class<?>) invocation.getArguments()[0])));
index 91ae0c24ddf9e664c596dc506bff371e5e90d2ef..cb1a99b4c0c14122d3ef7c98ae9d5f524523f9db 100644 (file)
@@ -8,15 +8,14 @@
 
 package org.opendaylight.controller.sal.dom.broker;
 
-import static junit.framework.Assert.fail;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
 import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.doNothing;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
-
 import com.google.common.base.Optional;
 import com.google.common.util.concurrent.ListenableFuture;
 import java.util.AbstractMap;
@@ -38,6 +37,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+@Deprecated
 public class BackwardsCompatibleMountPointTest {
     private static final Logger log = LoggerFactory.getLogger(BackwardsCompatibleMountPointManagerTest.class);
 
@@ -147,7 +147,7 @@ public class BackwardsCompatibleMountPointTest {
     }
 
     private NormalizedNode<?, ?> mockNormalizedNode() {
-        final NormalizedNode mock = mock(NormalizedNode.class);
+        final NormalizedNode<?, ?> mock = mock(NormalizedNode.class);
         doReturn("mockNormalizedNode").when(mock).toString();
         return mock;
     }
diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMDataBroker.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMDataBroker.java
new file mode 100644 (file)
index 0000000..e42cf10
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.md.sal.dom.spi;
+
+import com.google.common.collect.ForwardingObject;
+import javax.annotation.Nonnull;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataChangeListener;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
+import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+
+/**
+ * Utility {@link DOMDataBroker} implementation which forwards all interface
+ * method invocation to a delegate instance.
+ */
+public abstract class ForwardingDOMDataBroker extends ForwardingObject implements DOMDataBroker {
+    @Override
+    protected abstract @Nonnull DOMDataBroker delegate();
+
+    @Override
+    public ListenerRegistration<DOMDataChangeListener> registerDataChangeListener(final LogicalDatastoreType store,
+            final YangInstanceIdentifier path, final DOMDataChangeListener listener,
+            final DataChangeScope triggeringScope) {
+        return delegate().registerDataChangeListener(store, path, listener, triggeringScope);
+    }
+
+    @Override
+    public DOMDataReadOnlyTransaction newReadOnlyTransaction() {
+        return delegate().newReadOnlyTransaction();
+    }
+
+    @Override
+    public DOMDataReadWriteTransaction newReadWriteTransaction() {
+        return delegate().newReadWriteTransaction();
+    }
+
+    @Override
+    public DOMDataWriteTransaction newWriteOnlyTransaction() {
+        return delegate().newWriteOnlyTransaction();
+    }
+
+    @Override
+    public DOMTransactionChain createTransactionChain(final TransactionChainListener listener) {
+        return delegate().createTransactionChain(listener);
+    }
+}
diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMDataReadOnlyTransaction.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMDataReadOnlyTransaction.java
new file mode 100644 (file)
index 0000000..dcec6c3
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.md.sal.dom.spi;
+
+import com.google.common.base.Optional;
+import com.google.common.collect.ForwardingObject;
+import com.google.common.util.concurrent.CheckedFuture;
+import javax.annotation.Nonnull;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+
+/**
+ * Utility {@link DOMDataReadOnlyTransaction} implementation which forwards all interface
+ * method invocation to a delegate instance.
+ */
+public abstract class ForwardingDOMDataReadOnlyTransaction extends ForwardingObject implements DOMDataReadOnlyTransaction {
+    @Override
+    protected abstract @Nonnull DOMDataReadOnlyTransaction delegate();
+
+    @Override
+    public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read(final LogicalDatastoreType store, final YangInstanceIdentifier path) {
+        return delegate().read(store, path);
+    }
+
+    @Override
+    public CheckedFuture<Boolean, ReadFailedException> exists(final LogicalDatastoreType store, final YangInstanceIdentifier path) {
+        return delegate().exists(store, path);
+    }
+
+    @Override
+    public Object getIdentifier() {
+        return delegate().getIdentifier();
+    }
+
+    @Override
+    public void close() {
+        delegate().close();
+    }
+}
diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMDataReadWriteTransaction.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMDataReadWriteTransaction.java
new file mode 100644 (file)
index 0000000..923bef7
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.md.sal.dom.spi;
+
+import com.google.common.base.Optional;
+import com.google.common.collect.ForwardingObject;
+import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.ListenableFuture;
+import javax.annotation.Nonnull;
+import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+
+/**
+ * Utility {@link DOMDataReadWriteTransaction} implementation which forwards all interface
+ * method invocation to a delegate instance.
+ */
+public abstract class ForwardingDOMDataReadWriteTransaction extends ForwardingObject implements DOMDataReadWriteTransaction {
+    @Override
+    protected abstract @Nonnull DOMDataReadWriteTransaction delegate();
+
+    @Override
+    public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read(final LogicalDatastoreType store, final YangInstanceIdentifier path) {
+        return delegate().read(store, path);
+    }
+
+    @Override
+    public CheckedFuture<Boolean, ReadFailedException> exists(final LogicalDatastoreType store, final YangInstanceIdentifier path) {
+        return delegate().exists(store, path);
+    }
+
+    @Override
+    public Object getIdentifier() {
+        return delegate().getIdentifier();
+    }
+
+    @Override
+    public void put(final LogicalDatastoreType store, final YangInstanceIdentifier path, final NormalizedNode<?, ?> data) {
+        delegate().put(store, path, data);
+    }
+
+    @Override
+    public void merge(final LogicalDatastoreType store, final YangInstanceIdentifier path, final NormalizedNode<?, ?> data) {
+        delegate().merge(store, path, data);
+    }
+
+    @Override
+    public boolean cancel() {
+        return delegate().cancel();
+    }
+
+    @Override
+    public void delete(final LogicalDatastoreType store, final YangInstanceIdentifier path) {
+        delegate().delete(store, path);
+    }
+
+    @Override
+    public CheckedFuture<Void, TransactionCommitFailedException> submit() {
+        return delegate().submit();
+    }
+
+    @Override
+    @Deprecated
+    public ListenableFuture<RpcResult<TransactionStatus>> commit() {
+        return delegate().commit();
+    }
+}
diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMDataWriteTransaction.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMDataWriteTransaction.java
new file mode 100644 (file)
index 0000000..2afb478
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.md.sal.dom.spi;
+
+import com.google.common.collect.ForwardingObject;
+import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.ListenableFuture;
+import javax.annotation.Nonnull;
+import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+
+/**
+ * Utility {@link DOMDataWriteTransaction} implementation which forwards all interface
+ * method invocation to a delegate instance.
+ */
+public abstract class ForwardingDOMDataWriteTransaction extends ForwardingObject implements DOMDataWriteTransaction {
+    @Override
+    protected abstract @Nonnull DOMDataWriteTransaction delegate();
+
+    @Override
+    public Object getIdentifier() {
+        return delegate().getIdentifier();
+    }
+
+    @Override
+    public void put(final LogicalDatastoreType store, final YangInstanceIdentifier path, final NormalizedNode<?, ?> data) {
+        delegate().put(store, path, data);
+    }
+
+    @Override
+    public void merge(final LogicalDatastoreType store, final YangInstanceIdentifier path, final NormalizedNode<?, ?> data) {
+        delegate().merge(store, path, data);
+    }
+
+    @Override
+    public boolean cancel() {
+        return delegate().cancel();
+    }
+
+    @Override
+    public void delete(final LogicalDatastoreType store, final YangInstanceIdentifier path) {
+        delegate().delete(store, path);
+    }
+
+    @Override
+    public CheckedFuture<Void, TransactionCommitFailedException> submit() {
+        return delegate().submit();
+    }
+
+    @Override
+    @Deprecated
+    public ListenableFuture<RpcResult<TransactionStatus>> commit() {
+        return delegate().commit();
+    }
+}
diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMTransactionChain.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMTransactionChain.java
new file mode 100644 (file)
index 0000000..e709e67
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.md.sal.dom.spi;
+
+import com.google.common.collect.ForwardingObject;
+import javax.annotation.Nonnull;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
+import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
+
+/**
+ * Utility {@link DOMTransactionChain} implementation which forwards all interface
+ * method invocation to a delegate instance.
+ */
+public abstract class ForwardingDOMTransactionChain extends ForwardingObject implements DOMTransactionChain {
+    @Override
+    protected abstract @Nonnull DOMTransactionChain delegate();
+
+    @Override
+    public void close() {
+        delegate().close();
+    }
+
+    @Override
+    public DOMDataReadOnlyTransaction newReadOnlyTransaction() {
+        return delegate().newReadOnlyTransaction();
+    }
+
+    @Override
+    public DOMDataReadWriteTransaction newReadWriteTransaction() {
+        return delegate().newReadWriteTransaction();
+    }
+
+    @Override
+    public DOMDataWriteTransaction newWriteOnlyTransaction() {
+        return delegate().newWriteOnlyTransaction();
+    }
+}
index e8919d0ee1a4c277541d842b6763e9ca18a9f747..d2d864cd4f932146a9af95fb5e7c7afb75f18a2e 100644 (file)
@@ -15,7 +15,6 @@
     <version>1.2.0-SNAPSHOT</version>\r
   </parent>\r
   <artifactId>sal-dom-xsql-config</artifactId>\r
-  <groupId>org.opendaylight.controller</groupId>\r
   <description>Configuration files for md-sal</description>\r
   <packaging>jar</packaging>\r
   <properties>\r
index f5898a2bb9dfe15dd71ee560b2fe5bc8c581a1de..c7fd20248de7e14a5dfb70fcc4e671d959de4b91 100644 (file)
@@ -35,7 +35,6 @@
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>yang-jmx-generator-plugin</artifactId>
-      <version>${config.version}</version>
     </dependency>
     <dependency>
       <groupId>org.opendaylight.yangtools</groupId>
index 893a45aaa2df41eadc71a1a62215493fda3d4a04..2e5f8078a377e980d88e7c52e337f4fb265108e2 100644 (file)
@@ -43,6 +43,7 @@ import org.opendaylight.yangtools.yang.data.impl.SimpleNodeTOImpl;
 import org.opendaylight.yangtools.yang.data.impl.util.CompositeNodeBuilder;
 import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
@@ -344,9 +345,14 @@ public class NetconfMessageTransformUtil {
         Preconditions.checkNotNull(rpcName);
         Preconditions.checkNotNull(schemaContext);
 
-        final NodeContainerProxy rpcBodyProxy = new NodeContainerProxy(rpcName, schemaContext.getChildNodes());
-        return new NodeContainerProxy(NETCONF_RPC_QNAME, Sets.<DataSchemaNode>newHashSet(rpcBodyProxy));
+        for (final RpcDefinition rpcDefinition : schemaContext.getOperations()) {
+            if(rpcDefinition.getQName().equals(rpcName)) {
+                final NodeContainerProxy rpcBodyProxy = new NodeContainerProxy(rpcName, rpcDefinition.getInput().getChildNodes());
+                return new NodeContainerProxy(NETCONF_RPC_QNAME, Sets.<DataSchemaNode>newHashSet(rpcBodyProxy));
+            }
+        }
 
+        throw new IllegalArgumentException("Rpc " + rpcName + " not found in schema context " + schemaContext + ". Unable to invoke Rpc");
     }
 
     public static CompositeNodeTOImpl wrap(final QName name, final Node<?> node) {
index 218ec0be8d319b91abdb8a1054c93f09675dbc68..cbddac2caf1c85063f5c5975b3fe36aa16888749 100644 (file)
@@ -17,7 +17,6 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.timeout;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
-
 import com.google.common.base.Optional;
 import com.google.common.collect.HashMultimap;
 import com.google.common.collect.Lists;
@@ -134,7 +133,7 @@ public class NetconfDeviceTest {
 
         // Make fallback attempt to fail due to empty resolved sources
         final MissingSchemaSourceException schemaResolutionException = new MissingSchemaSourceException("fail first", TEST_SID);
-        doAnswer(new Answer() {
+        doAnswer(new Answer<Object>() {
             @Override
             public Object answer(final InvocationOnMock invocation) throws Throwable {
                 if(((Collection<?>) invocation.getArguments()[0]).size() == 2) {
@@ -158,7 +157,7 @@ public class NetconfDeviceTest {
 
     private SchemaSourceRegistry getSchemaRegistry() {
         final SchemaSourceRegistry mock = mock(SchemaSourceRegistry.class);
-        final SchemaSourceRegistration mockReg = mock(SchemaSourceRegistration.class);
+        final SchemaSourceRegistration<?> mockReg = mock(SchemaSourceRegistration.class);
         doNothing().when(mockReg).close();
         doReturn(mockReg).when(mock).registerSchemaSource(any(org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceProvider.class), any(PotentialSchemaSource.class));
         return mock;
index 3f9c8caa0ec4fbd07aeddf61a2b6da57f358a642..ccae5d4be86e76e1efd376653db97821ffdad754 100644 (file)
@@ -2,7 +2,7 @@ package org.opendaylight.controller.sal.connect.netconf;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertThat;
-import static org.junit.matchers.JUnitMatchers.hasItem;
+import static org.hamcrest.CoreMatchers.hasItem;
 
 import java.util.Set;
 import org.junit.Test;
index 127b0cbfcdd510f569af8b1d71d0e773d9e1f740..5d19188b12733a2127add593233477cd1ce4cd6a 100644 (file)
@@ -1,14 +1,12 @@
 package org.opendaylight.controller.sal.connect.netconf;
 
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertNotNull;
-import static junit.framework.Assert.assertTrue;
-
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 import java.io.InputStream;
 import java.util.Collections;
 import java.util.List;
 import java.util.Set;
-
 import javax.xml.parsers.DocumentBuilderFactory;
 import org.junit.Before;
 import org.junit.Test;
index e744e11bc9212fc58666654b454a804e1e7f06ce..bbb5038caf01773c8de4a96ecb9674d0b8e627ef 100644 (file)
@@ -1,8 +1,8 @@
 package org.opendaylight.controller.sal.connect.netconf;
 
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertNotNull;
-import static junit.framework.Assert.assertTrue;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 
 import java.io.InputStream;
 import java.util.Collections;
@@ -253,37 +253,4 @@ public class NetconfToRpcRequestTest {
         assertEquals(streamName.getLocalName(), "stream-name");
     }
 
-    @Test
-    public void testNoSchemaContextToRpcRequest() throws Exception {
-        final String exampleNamespace = "http://example.net/me/my-own/1.0";
-        final String exampleRevision = "2014-07-22";
-        final QName myOwnMethodRpcQName = QName.create(exampleNamespace, exampleRevision, "my-own-method");
-
-        final CompositeNodeBuilder<ImmutableCompositeNode> rootBuilder = ImmutableCompositeNode.builder();
-        rootBuilder.setQName(myOwnMethodRpcQName);
-
-        final CompositeNodeBuilder<ImmutableCompositeNode> inputBuilder = ImmutableCompositeNode.builder();
-        inputBuilder.setQName(QName.create(exampleNamespace, exampleRevision, "input"));
-        inputBuilder.addLeaf(QName.create(exampleNamespace, exampleRevision, "my-first-parameter"), "14");
-        inputBuilder.addLeaf(QName.create(exampleNamespace, exampleRevision, "another-parameter"), "fred");
-
-        rootBuilder.add(inputBuilder.toInstance());
-        final ImmutableCompositeNode root = rootBuilder.toInstance();
-
-        final NetconfMessage message = messageTransformer.toRpcRequest(myOwnMethodRpcQName, root);
-        assertNotNull(message);
-
-        final Document xmlDoc = message.getDocument();
-        final org.w3c.dom.Node rpcChild = xmlDoc.getFirstChild();
-        assertEquals(rpcChild.getLocalName(), "rpc");
-
-        final org.w3c.dom.Node myOwnMethodNode = rpcChild.getFirstChild();
-        assertEquals(myOwnMethodNode.getLocalName(), "my-own-method");
-
-        final org.w3c.dom.Node firstParamNode = myOwnMethodNode.getFirstChild();
-        assertEquals(firstParamNode.getLocalName(), "my-first-parameter");
-
-        final org.w3c.dom.Node secParamNode = firstParamNode.getNextSibling();
-        assertEquals(secParamNode.getLocalName(), "another-parameter");
-    }
 }
index 80bb08f5af399fee497465e8ad1e345726784b24..ae7d9c28acf2c159ce4991b3cf89a15cbcdaf200 100644 (file)
@@ -1,12 +1,12 @@
 package org.opendaylight.controller.sal.connect.netconf.listener;
 
+import static org.hamcrest.CoreMatchers.hasItem;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertThat;
 
 import com.google.common.collect.Lists;
 import java.util.List;
 import org.junit.Test;
-import org.junit.matchers.JUnitMatchers;
 import org.opendaylight.controller.sal.connect.netconf.util.NetconfMessageTransformUtil;
 import org.opendaylight.yangtools.yang.common.QName;
 
@@ -35,12 +35,12 @@ public class NetconfSessionCapabilitiesTest {
         final NetconfSessionCapabilities merged = sessionCaps1.replaceModuleCaps(sessionCaps2);
         assertCaps(merged, 2, 2 + 1 /*Preserved monitoring*/);
         for (final QName qName : sessionCaps2.getModuleBasedCaps()) {
-            assertThat(merged.getModuleBasedCaps(), JUnitMatchers.hasItem(qName));
+            assertThat(merged.getModuleBasedCaps(), hasItem(qName));
         }
-        assertThat(merged.getModuleBasedCaps(), JUnitMatchers.hasItem(NetconfMessageTransformUtil.IETF_NETCONF_MONITORING));
+        assertThat(merged.getModuleBasedCaps(), hasItem(NetconfMessageTransformUtil.IETF_NETCONF_MONITORING));
 
-        assertThat(merged.getNonModuleCaps(), JUnitMatchers.hasItem("urn:ietf:params:netconf:base:1.0"));
-        assertThat(merged.getNonModuleCaps(), JUnitMatchers.hasItem("urn:ietf:params:netconf:capability:rollback-on-error:1.0"));
+        assertThat(merged.getNonModuleCaps(), hasItem("urn:ietf:params:netconf:base:1.0"));
+        assertThat(merged.getNonModuleCaps(), hasItem("urn:ietf:params:netconf:capability:rollback-on-error:1.0"));
     }
 
     @Test
index a65e426d5998542a4f2220092178cfec3a12d07c..0607e4b6da401c7a4badb6801f69f6b1177c7754 100644 (file)
@@ -1,6 +1,6 @@
 package org.opendaylight.controller.sal.connect.netconf.sal.tx;
 
-import static junit.framework.Assert.fail;
+import static org.junit.Assert.fail;
 import static org.mockito.Matchers.any;
 import static org.mockito.Matchers.eq;
 import static org.mockito.Mockito.doReturn;
index cd031a1d0abcf330b3c63c90a576b65dc2cd2d1d..f74bfc3cffe5e666dccec01057c823f3b9feb673 100644 (file)
@@ -8,14 +8,13 @@
 
 package org.opendaylight.controller.remote.rpc.utils;
 
-
+import static org.junit.Assert.assertTrue;
 import akka.actor.ActorRef;
 import akka.actor.ActorSystem;
 import akka.japi.Pair;
 import akka.testkit.JavaTestKit;
 import akka.testkit.TestProbe;
 import com.typesafe.config.ConfigFactory;
-import junit.framework.Assert;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -23,7 +22,6 @@ import org.junit.Test;
 import java.util.ArrayList;
 import java.util.List;
 
-
 public class LatestEntryRoutingLogicTest {
 
   static ActorSystem system;
@@ -52,6 +50,6 @@ public class LatestEntryRoutingLogicTest {
     pairList.add(new Pair<ActorRef, Long>(actor2, 3000L));
     pairList.add(new Pair<ActorRef, Long>(actor3, 2000L));
     RoutingLogic logic = new LatestEntryRoutingLogic(pairList);
-    Assert.assertTrue(logic.select().equals(actor2));
+    assertTrue(logic.select().equals(actor2));
   }
 }
index 9165281f9d27cc29cc6b236f73e518c886452ed5..02c5137fe9dc3b788c1cd0feba54f44ecee9a8d5 100644 (file)
@@ -14,7 +14,6 @@ import java.util.Map.Entry;
 import java.util.Set;
 import java.util.TreeSet;
 import javax.ws.rs.core.UriInfo;
-import junit.framework.Assert;
 import org.json.JSONException;
 import org.json.JSONObject;
 import org.junit.After;
@@ -205,7 +204,7 @@ public class ApiDocGeneratorTest {
             if (m.getKey().getAbsolutePath().endsWith("toaster.yang")) {
                 ApiDeclaration doc = generator.getSwaggerDocSpec(m.getValue(), "http://localhost:8080/restconf", "",
                         schemaContext);
-                Assert.assertNotNull(doc);
+                assertNotNull(doc);
 
                 // testing bugs.opendaylight.org bug 1290. UnionType model type.
                 String jsonString = doc.getModels().toString();
index edba4e11da8661a69660b89051286b4faaa4854e..2b3015243fa175ebc48dc40a839af4b5bbf63fd6 100644 (file)
                             org.opendaylight.controller.netconf.confignetconfconnector.util,
                             org.opendaylight.controller.netconf.confignetconfconnector.osgi,
                             org.opendaylight.controller.netconf.confignetconfconnector.exception,</Private-Package>
-            <Import-Package>com.google.common.base,
-                            com.google.common.collect,
-                            javax.annotation,
-                            javax.management,
-                            javax.management.openmbean,
-                            org.opendaylight.controller.config.api,
-                            org.opendaylight.controller.config.api.jmx,
-                            org.opendaylight.controller.config.yangjmxgenerator,
-                            org.opendaylight.controller.config.yangjmxgenerator.attribute,
-                            org.opendaylight.controller.netconf.api,
-                            org.opendaylight.controller.netconf.mapping.api,
-                            org.opendaylight.controller.netconf.util.mapping,
-                            org.opendaylight.controller.netconf.util.xml,
-                            org.opendaylight.controller.netconf.util.exception,
-                            org.opendaylight.yangtools.yang.common,
-                            org.opendaylight.yangtools.yang.model.api,
-                            org.osgi.framework,
-                            org.osgi.util.tracker,
-                            org.slf4j,
-                            org.w3c.dom,
-                            com.google.common.io,
-                            org.opendaylight.yangtools.yang.model.api.type,
-                            org.opendaylight.yangtools.sal.binding.generator.spi,
-                            org.opendaylight.yangtools.sal.binding.yang.types,
-                            org.opendaylight.controller.config.util
-              </Import-Package>
+            <Import-Package>*</Import-Package>
             <Export-Package></Export-Package>
           </instructions>
         </configuration>
index 7fd8928928feb8814b0eb003c61e2c51152beef5..551da722c06732b60219d80044b3d6ca5319f3fa 100644 (file)
@@ -8,20 +8,23 @@
 
 package org.opendaylight.controller.netconf.confignetconfconnector.operations.runtimerpc;
 
-import com.google.common.base.Preconditions;
-import com.google.common.base.Strings;
-import com.google.common.collect.Maps;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.management.ObjectName;
 
 import org.opendaylight.controller.config.api.jmx.ObjectNameUtil;
 import org.opendaylight.controller.netconf.api.xml.XmlNetconfConstants;
 import org.opendaylight.controller.netconf.confignetconfconnector.mapping.rpc.ModuleRpcs;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.rev130405.Modules;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.rev130405.modules.Module;
 
-import javax.management.ObjectName;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Preconditions;
+import com.google.common.base.Strings;
+import com.google.common.collect.Maps;
 
 /**
  * Represents parsed xpath to runtime bean instance
@@ -46,6 +49,11 @@ public final class RuntimeRpcElementResolved {
         return moduleName;
     }
 
+    @VisibleForTesting
+    Map<String, String> getAdditionalAttributes() {
+        return additionalAttributes;
+    }
+
     public String getInstanceName() {
         return instanceName;
     }
@@ -70,22 +78,45 @@ public final class RuntimeRpcElementResolved {
         return ObjectNameUtil.createRuntimeBeanName(moduleName, instanceName, additionalAttributesJavaNames);
     }
 
+    /**
+     * Pattern for an absolute instance identifier xpath pointing to a runtime bean instance e.g:
+     * <pre>
+     * /modules/module[name=instanceName][type=moduleType]
+     * </pre>
+     * or
+     * <pre>
+     * /a:modules/a:module[a:name=instanceName][a:type=moduleType]
+     * </pre>
+     */
     private static final String xpathPatternBlueprint =
-            "/" + XmlNetconfConstants.MODULES_KEY
-            + "/" + XmlNetconfConstants.MODULE_KEY
-            + "\\["
-
-            + "(?<key1>type|name)"
-            + "='(?<value1>[^']+)'"
-            + "( and |\\]\\[)"
-            + "(?<key2>type|name)"
-            + "='(?<value2>[^']+)'"
-
-            + "\\]"
-            + "(?<additional>.*)";
+            "/" + getRegExForPrefixedName(Modules.QNAME.getLocalName())+ "/" + getRegExForPrefixedName(Module.QNAME.getLocalName())
+
+                    + "\\["
+                    + "(?<key1>" + getRegExForPrefixedName(XmlNetconfConstants.TYPE_KEY) + "|" + getRegExForPrefixedName(XmlNetconfConstants.NAME_KEY) + ")"
+                    + "=('|\")?(?<value1>[^'\"\\]]+)('|\")?"
+                    + "( and |\\]\\[)"
+                    + "(?<key2>" + getRegExForPrefixedName(XmlNetconfConstants.TYPE_KEY) + "|" + getRegExForPrefixedName(XmlNetconfConstants.NAME_KEY) + ")"
+                    + "=('|\")?(?<value2>[^'\"\\]]+)('|\")?"
+                    + "\\]"
+
+                    + "(?<additional>.*)";
+
+    /**
+     * Return reg ex that matches either the name with or without a prefix
+     */
+    private static String getRegExForPrefixedName(final String name) {
+        return "([^:]+:)?" + name;
+    }
 
     private static final Pattern xpathPattern = Pattern.compile(xpathPatternBlueprint);
-    private static final String additionalPatternBlueprint = "(?<additionalKey>.+)\\[(.+)='(?<additionalValue>.+)'\\]";
+
+    /**
+     * Pattern for additional path elements inside xpath for instance identifier pointing to an inner runtime bean e.g:
+     * <pre>
+     * /modules/module[name=instanceName and type=moduleType]/inner[key=b]
+     * </pre>
+     */
+    private static final String additionalPatternBlueprint = getRegExForPrefixedName("(?<additionalKey>.+)") + "\\[(?<prefixedKey>" + getRegExForPrefixedName("(.+)") + ")=('|\")?(?<additionalValue>[^'\"\\]]+)('|\")?\\]";
     private static final Pattern additionalPattern = Pattern.compile(additionalPatternBlueprint);
 
     public static RuntimeRpcElementResolved fromXpath(String xpath, String elementName, String namespace) {
@@ -115,20 +146,19 @@ public final class RuntimeRpcElementResolved {
         PatternGroupResolver(String key1, String value1,  String value2, String additional) {
             this.key1 = Preconditions.checkNotNull(key1);
             this.value1 = Preconditions.checkNotNull(value1);
-
             this.value2 = Preconditions.checkNotNull(value2);
-
             this.additional = Preconditions.checkNotNull(additional);
         }
 
         String getModuleName() {
-            return key1.equals(XmlNetconfConstants.TYPE_KEY) ? value1 : value2;
+            return key1.contains(XmlNetconfConstants.TYPE_KEY) ? value1 : value2;
         }
 
         String getInstanceName() {
-            return key1.equals(XmlNetconfConstants.NAME_KEY) ? value1 : value2;
+            return key1.contains(XmlNetconfConstants.NAME_KEY) ? value1 : value2;
         }
 
+
         Map<String, String> getAdditionalKeys(String elementName, String moduleName) {
             HashMap<String, String> additionalAttributes = Maps.newHashMap();
 
@@ -141,7 +171,7 @@ public final class RuntimeRpcElementResolved {
                 Preconditions
                         .checkState(
                                 matcher.matches(),
-                                "Attribute %s not in required form on rpc element %s, required format for additional attributes is  %s",
+                                "Attribute %s not in required form on rpc element %s, required format for additional attributes is: %s",
                                 additionalKeyValue, elementName, additionalPatternBlueprint);
                 String name = matcher.group("additionalKey");
                 runtimeBeanYangName = name;
index 641881cf9ee50b71119c930a495ded9920575f73..28849d0033d5c93a0bd98e6ee9d61cb8a00f5845 100644 (file)
@@ -55,10 +55,10 @@ import org.custommonkey.xmlunit.NodeTestException;
 import org.custommonkey.xmlunit.NodeTester;
 import org.custommonkey.xmlunit.XMLAssert;
 import org.custommonkey.xmlunit.XMLUnit;
+import org.hamcrest.CoreMatchers;
 import org.junit.Before;
 import org.junit.Ignore;
 import org.junit.Test;
-import org.junit.matchers.JUnitMatchers;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
 import org.opendaylight.controller.config.api.ConflictingVersionException;
@@ -569,7 +569,7 @@ public class NetconfMappingTest extends AbstractConfigTest {
     }
 
     private void assertContainsString(String string, String substring) {
-        assertThat(string, JUnitMatchers.containsString(substring));
+        assertThat(string, CoreMatchers.containsString(substring));
     }
 
     private void checkEnum(final Document response) throws Exception {
diff --git a/opendaylight/netconf/config-netconf-connector/src/test/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/runtimerpc/RuntimeRpcElementResolvedTest.java b/opendaylight/netconf/config-netconf-connector/src/test/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/runtimerpc/RuntimeRpcElementResolvedTest.java
new file mode 100644 (file)
index 0000000..816e118
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.netconf.confignetconfconnector.operations.runtimerpc;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+@RunWith(Parameterized.class)
+public class RuntimeRpcElementResolvedTest {
+
+    private static final String MODULE_TYPE = "moduleType";
+    private static final String INSTANCE_NAME = "instanceName";
+    @Parameterized.Parameter(0)
+    public String xpath;
+    @Parameterized.Parameter(1)
+    public Map<String, String> additional;
+
+    @Parameterized.Parameters(name = "{index}: parsed({0}) contains moduleName:{1} and instanceName:{2}")
+    public static Collection<Object[]> data() {
+        return Arrays.asList(new Object[][] {
+                // With namespaces
+                { "/a:modules/a:module[a:name='instanceName'][a:type='moduleType']/b:listener-state[b:peer-id='127.0.0.1']",
+                        new HashMap<String, String>() {{
+                            put("listener-state", "127.0.0.1");
+                        }}},
+                { "/a:modules/a:module[a:name='instanceName'][a:type='moduleType']",
+                        null},
+
+                // Without namespaces
+                { "/modules/module[name=instanceName][type=moduleType]", null},
+                { "/modules/module[type=moduleType][name='instanceName']", null},
+                { "/modules/module[name=\'instanceName\'][type=\"moduleType\"]", null},
+                { "/modules/module[type=moduleType and name=instanceName]", null},
+                { "/modules/module[name=\"instanceName\" and type=moduleType]", null},
+                { "/modules/module[type=\"moduleType\" and name=instanceName]", null},
+                { "/modules/module[name=\'instanceName\' and type=\"moduleType\"]", null},
+
+                // With inner beans
+                { "/modules/module[name=instanceName and type=\"moduleType\"]/inner[key=b]", Collections.singletonMap("inner", "b")},
+                { "/modules/module[name=instanceName and type=moduleType]/inner[key=b]", Collections.singletonMap("inner", "b")},
+                { "/modules/module[name=instanceName and type=moduleType]/inner[key=\'b\']", Collections.singletonMap("inner", "b")},
+                { "/modules/module[name=instanceName and type=moduleType]/inner[key=\"b\"]", Collections.singletonMap("inner", "b")},
+
+                { "/modules/module[name=instanceName and type=\"moduleType\"]/inner[key2=a]/inner2[key=b]",
+                        new HashMap<String, String>() {{
+                            put("inner", "a");
+                            put("inner2", "b");
+                        }}
+                },
+        });
+    }
+
+    @Test
+    public void testFromXpath() throws Exception {
+        final RuntimeRpcElementResolved resolved = RuntimeRpcElementResolved.fromXpath(xpath, "element", "namespace");
+        assertEquals(MODULE_TYPE, resolved.getModuleName());
+        assertEquals(INSTANCE_NAME, resolved.getInstanceName());
+        if (additional != null) {
+            assertEquals(additional, resolved.getAdditionalAttributes());
+        }
+    }
+}
index 1e650c08b124a460c7d19f65200c1b0868ccee17..b051c6c1c6237bb3d4816adbd6f86aa8b329487d 100644 (file)
@@ -24,7 +24,7 @@ import java.util.Set;
 
 import org.junit.Assert;
 import org.junit.Test;
-import org.junit.matchers.JUnitMatchers;
+import org.hamcrest.CoreMatchers;
 import org.opendaylight.controller.config.api.LookupRegistry;
 import org.opendaylight.controller.config.yangjmxgenerator.ModuleMXBeanEntry;
 import org.opendaylight.yangtools.yang.common.QName;
@@ -72,11 +72,11 @@ public class NetconfOperationServiceImplTest {
             String message = e.getMessage();
             Assert.assertThat(
                     message,
-                    JUnitMatchers
+                    CoreMatchers
                     .containsString("missing from config subsystem but present in yangstore: [(namespace?revision=1970-01-01)qname2]"));
             Assert.assertThat(
                     message,
-                    JUnitMatchers
+                    CoreMatchers
                     .containsString("All modules present in config: [(namespace?revision=1970-01-01)qname1]"));
         }
     }
index cd646aeb079100a72a230f9d62624504a72a5ad2..bef1237f980116f84f0f0ba8dc0f58b10028850b 100644 (file)
@@ -23,11 +23,11 @@ import java.util.Arrays;
 import java.util.List;
 import java.util.Properties;
 
+import static org.hamcrest.CoreMatchers.containsString;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertThat;
 import static org.junit.Assert.fail;
-import static org.junit.matchers.JUnitMatchers.containsString;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 import static org.opendaylight.controller.netconf.persist.impl.PersisterAggregator.PersisterWithConfiguration;
index 3f04010015e8291d8dbeb6e47415d6ab8a12ad3f..c8140973eb9d7ee0c890cbba77ffaa6b8c689327 100644 (file)
@@ -7,13 +7,13 @@
  */
 package org.opendaylight.controller.netconf.persist.impl.osgi;
 
+import static org.hamcrest.CoreMatchers.containsString;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertThat;
 import static org.junit.Assert.fail;
 
-import org.junit.matchers.JUnitMatchers;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -49,7 +49,7 @@ final class TestingExceptionHandler implements Thread.UncaughtExceptionHandler {
     private void assertException(Throwable t, Class<? extends Exception> exType, String exMessageToContain) {
         assertEquals("Expected exception of type " + exType + " but was " + t, exType, t.getClass());
         if(exMessageToContain!=null) {
-            assertThat(t.getMessage(), JUnitMatchers.containsString(exMessageToContain));
+            assertThat(t.getMessage(), containsString(exMessageToContain));
         }
     }
 
index 5a2ec5656f9e4884c801c71779c43bff3c18a18c..dfbb972e8c8f90b5e6f3285fea974c6924ff4640 100644 (file)
@@ -21,7 +21,6 @@ import org.opendaylight.controller.netconf.client.NetconfClientDispatcherImpl;
 import org.opendaylight.controller.netconf.client.NetconfClientSessionListener;
 import org.opendaylight.controller.netconf.client.SimpleNetconfClientSessionListener;
 import org.opendaylight.controller.netconf.client.conf.NetconfClientConfiguration;
-import org.opendaylight.controller.netconf.client.conf.NetconfClientConfigurationBuilder;
 import org.opendaylight.controller.netconf.client.conf.NetconfReconnectingClientConfiguration;
 import org.opendaylight.controller.netconf.client.conf.NetconfReconnectingClientConfigurationBuilder;
 import org.opendaylight.controller.netconf.nettyutil.handler.ssh.authentication.AuthenticationHandler;
@@ -32,7 +31,6 @@ import org.opendaylight.protocol.framework.ReconnectStrategyFactory;
 import java.net.InetSocketAddress;
 import java.util.concurrent.Future;
 
-import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.doReturn;
index 0557a0c26890f0a6c25c178745ea48aa27472f99..95fdcccab80a08f839666a152d89c722158bb949 100644 (file)
@@ -13,13 +13,11 @@ import io.netty.channel.Channel;
 import io.netty.util.HashedWheelTimer;
 import io.netty.util.Timer;
 import io.netty.util.concurrent.Promise;
-import org.apache.sshd.common.SessionListener;
 import org.junit.Test;
 import org.opendaylight.controller.netconf.util.messages.NetconfHelloMessageAdditionalHeader;
 import org.opendaylight.protocol.framework.SessionListenerFactory;
 import org.opendaylight.protocol.framework.SessionNegotiator;
 
-import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
index 333e9deae44e24b7a2850550b262d2b24954902c..9993f48a4d2029977c62c35a4e28de7a122ac422 100644 (file)
@@ -8,22 +8,35 @@
 
 package org.opendaylight.controller.netconf.client;
 
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
 import com.google.common.base.Optional;
-import io.netty.channel.*;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelFuture;
+import io.netty.channel.ChannelHandler;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.ChannelInboundHandlerAdapter;
+import io.netty.channel.ChannelPipeline;
+import io.netty.channel.ChannelProgressivePromise;
 import io.netty.handler.ssl.SslHandler;
 import io.netty.util.HashedWheelTimer;
+import io.netty.util.Timer;
 import io.netty.util.concurrent.GenericFutureListener;
 import io.netty.util.concurrent.Promise;
-import org.apache.mina.handler.demux.ExceptionHandler;
+import java.util.Set;
 import org.junit.Before;
 import org.junit.Test;
-import org.mockito.Mockito;
 import org.mockito.internal.util.collections.Sets;
 import org.mockito.invocation.InvocationOnMock;
 import org.mockito.stubbing.Answer;
 import org.opendaylight.controller.netconf.api.NetconfClientSessionPreferences;
 import org.opendaylight.controller.netconf.api.NetconfMessage;
-import io.netty.util.Timer;
 import org.opendaylight.controller.netconf.nettyutil.handler.ChunkedFramingMechanismEncoder;
 import org.opendaylight.controller.netconf.nettyutil.handler.NetconfXMLToHelloMessageDecoder;
 import org.opendaylight.controller.netconf.nettyutil.handler.NetconfXMLToMessageDecoder;
@@ -31,14 +44,8 @@ import org.opendaylight.controller.netconf.nettyutil.handler.exi.NetconfStartExi
 import org.opendaylight.controller.netconf.util.messages.NetconfHelloMessage;
 import org.opendaylight.controller.netconf.util.messages.NetconfHelloMessageAdditionalHeader;
 import org.opendaylight.controller.netconf.util.test.XmlFileLoader;
-import org.opendaylight.controller.netconf.util.xml.XmlUtil;
 import org.openexi.proc.common.EXIOptions;
 import org.w3c.dom.Document;
-import java.util.Set;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Mockito.*;
 
 public class NetconfClientSessionNegotiatorTest {
 
@@ -96,8 +103,8 @@ public class NetconfClientSessionNegotiatorTest {
         return pipeline;
     }
 
-    private NetconfClientSessionNegotiator createNetconfClientSessionNegotiator(Promise promise,
-                                                                                NetconfMessage startExi) {
+    private NetconfClientSessionNegotiator createNetconfClientSessionNegotiator(final Promise promise,
+                                                                                final NetconfMessage startExi) {
         ChannelProgressivePromise progressivePromise = mock(ChannelProgressivePromise.class);
         NetconfClientSessionPreferences preferences = new NetconfClientSessionPreferences(helloMessage, startExi);
         doReturn(progressivePromise).when(promise).setFailure(any(Throwable.class));
@@ -133,9 +140,9 @@ public class NetconfClientSessionNegotiatorTest {
         Set caps = Sets.newSet("exi:1.0");
         NetconfHelloMessage helloMessage = NetconfHelloMessage.createServerHello(caps, 10);
 
-        doAnswer(new Answer() {
+        doAnswer(new Answer<Object>() {
             @Override
-            public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
+            public Object answer(final InvocationOnMock invocationOnMock) throws Throwable {
                 channelInboundHandlerAdapter = ((ChannelInboundHandlerAdapter) invocationOnMock.getArguments()[2]);
                 return null;
             }
index 4175190e143aca575239c6f957d34a30f09458c2..731a3fe9606197f6ecf95fea28944fc09b435b69 100644 (file)
@@ -12,7 +12,6 @@ import com.google.common.collect.Lists;
 import io.netty.channel.Channel;
 import io.netty.channel.ChannelHandler;
 import io.netty.channel.ChannelPipeline;
-import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mock;
@@ -23,7 +22,6 @@ import org.opendaylight.controller.netconf.client.NetconfClientSessionListener;
 import org.opendaylight.controller.netconf.nettyutil.handler.NetconfEXICodec;
 import org.openexi.proc.common.EXIOptions;
 
-import java.util.ArrayList;
 import java.util.Collection;
 
 import static org.junit.Assert.assertEquals;
index e79a370ec755e617e364a176f9d6041fac7353a1..a9754654d5a7a4e1ee1e2588fb3a127bcc677d61 100644 (file)
@@ -12,7 +12,6 @@ import com.google.common.base.Optional;
 import org.junit.Assert;
 import org.junit.Test;
 import org.mockito.Mockito;
-import org.opendaylight.controller.config.yang.protocol.framework.NeverReconnectStrategyFactoryModule;
 import org.opendaylight.controller.netconf.client.NetconfClientSessionListener;
 import org.opendaylight.controller.netconf.client.SimpleNetconfClientSessionListener;
 import org.opendaylight.controller.netconf.client.conf.NetconfClientConfiguration;
index e067cc225fa081f24339513d008e29362b0d4f7b..29b903f235d190eae0c68cc563c4109335fe5a2b 100644 (file)
@@ -9,7 +9,6 @@
 package org.opendaylight.controller.netconf.client;
 import io.netty.channel.*;
 import io.netty.util.concurrent.Future;
-import io.netty.util.concurrent.Promise;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.internal.util.collections.Sets;
index e355cf45e7a51934e653c7f38161b6b0bc7fb038..369f0ed574184718bacc15da330be789f8a27936 100644 (file)
@@ -13,7 +13,6 @@ import io.netty.channel.ChannelHandler;
 import io.netty.channel.ChannelPipeline;
 import io.netty.util.concurrent.Promise;
 import org.junit.Test;
-import org.opendaylight.controller.netconf.nettyutil.AbstractChannelInitializer;
 import org.opendaylight.protocol.framework.SessionListenerFactory;
 import org.opendaylight.protocol.framework.SessionNegotiator;
 
index 13d4ab290b3c333d25e2e50ec66f15e79e19ec7f..2646b7e26ea4300b3f7a8ba770d0bd9243026b66 100644 (file)
@@ -1,14 +1,14 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.netconf.impl.mapping.operations;\r
-\r
-import org.opendaylight.controller.netconf.impl.NetconfServerSession;\r
-\r
-public interface DefaultNetconfOperation {\r
-    void setNetconfSession(NetconfServerSession s);\r
-}\r
+/*
+ * 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.netconf.impl.mapping.operations;
+
+import org.opendaylight.controller.netconf.impl.NetconfServerSession;
+
+public interface DefaultNetconfOperation {
+    void setNetconfSession(NetconfServerSession s);
+}
index cccb1a3ac362e35c6f0efcd5836b3c5a51e1a320..6de185ac1c1da4948fc343a4be19759362af03f0 100644 (file)
@@ -1,71 +1,71 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.netconf.impl.mapping.operations;\r
-\r
-import org.opendaylight.controller.netconf.api.NetconfDocumentedException;\r
-import org.opendaylight.controller.netconf.api.NetconfDocumentedException.ErrorSeverity;\r
-import org.opendaylight.controller.netconf.api.NetconfDocumentedException.ErrorTag;\r
-import org.opendaylight.controller.netconf.api.NetconfDocumentedException.ErrorType;\r
-import org.opendaylight.controller.netconf.api.xml.XmlNetconfConstants;\r
-import org.opendaylight.controller.netconf.api.NetconfMessage;\r
-import org.opendaylight.controller.netconf.impl.NetconfServerSession;\r
-import org.opendaylight.controller.netconf.mapping.api.NetconfOperationChainedExecution;\r
-import org.opendaylight.controller.netconf.util.mapping.AbstractSingletonNetconfOperation;\r
-import org.opendaylight.controller.netconf.util.xml.XmlElement;\r
-import org.opendaylight.controller.netconf.util.xml.XmlUtil;\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
-import org.w3c.dom.Document;\r
-import org.w3c.dom.Element;\r
-public class DefaultStartExi extends AbstractSingletonNetconfOperation implements DefaultNetconfOperation {\r
-    public static final String START_EXI = "start-exi";\r
-\r
-    private static final Logger logger = LoggerFactory.getLogger(DefaultStartExi.class);\r
-    private NetconfServerSession netconfSession;\r
-\r
-    public DefaultStartExi(String netconfSessionIdForReporting) {\r
-        super(netconfSessionIdForReporting);\r
-    }\r
-\r
-    @Override\r
-    public Document handle(Document message,\r
-                           NetconfOperationChainedExecution subsequentOperation) throws NetconfDocumentedException {\r
-        logger.debug("Received start-exi message {} ", XmlUtil.toString(message));\r
-\r
-        try {\r
-            netconfSession.startExiCommunication(new NetconfMessage(message));\r
-        } catch (IllegalArgumentException e) {\r
-            throw new NetconfDocumentedException("Failed to parse EXI parameters", ErrorType.protocol,\r
-                    ErrorTag.operation_failed, ErrorSeverity.error);\r
-        }\r
-\r
-        return super.handle(message, subsequentOperation);\r
-    }\r
-\r
-    @Override\r
-    protected Element handleWithNoSubsequentOperations(Document document, XmlElement operationElement) throws NetconfDocumentedException {\r
-        Element getSchemaResult = document.createElementNS( XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0, XmlNetconfConstants.OK);\r
-        logger.trace("{} operation successful", START_EXI);\r
-        return getSchemaResult;\r
-    }\r
-\r
-    @Override\r
-    protected String getOperationName() {\r
-        return START_EXI;\r
-    }\r
-\r
-    @Override\r
-    protected String getOperationNamespace() {\r
-        return XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_EXI_1_0;\r
-    }\r
-\r
-    @Override\r
-    public void setNetconfSession(NetconfServerSession s) {\r
-        netconfSession = s;\r
-    }\r
-}\r
+/*
+ * 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.netconf.impl.mapping.operations;
+
+import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
+import org.opendaylight.controller.netconf.api.NetconfDocumentedException.ErrorSeverity;
+import org.opendaylight.controller.netconf.api.NetconfDocumentedException.ErrorTag;
+import org.opendaylight.controller.netconf.api.NetconfDocumentedException.ErrorType;
+import org.opendaylight.controller.netconf.api.xml.XmlNetconfConstants;
+import org.opendaylight.controller.netconf.api.NetconfMessage;
+import org.opendaylight.controller.netconf.impl.NetconfServerSession;
+import org.opendaylight.controller.netconf.mapping.api.NetconfOperationChainedExecution;
+import org.opendaylight.controller.netconf.util.mapping.AbstractSingletonNetconfOperation;
+import org.opendaylight.controller.netconf.util.xml.XmlElement;
+import org.opendaylight.controller.netconf.util.xml.XmlUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+public class DefaultStartExi extends AbstractSingletonNetconfOperation implements DefaultNetconfOperation {
+    public static final String START_EXI = "start-exi";
+
+    private static final Logger logger = LoggerFactory.getLogger(DefaultStartExi.class);
+    private NetconfServerSession netconfSession;
+
+    public DefaultStartExi(String netconfSessionIdForReporting) {
+        super(netconfSessionIdForReporting);
+    }
+
+    @Override
+    public Document handle(Document message,
+                           NetconfOperationChainedExecution subsequentOperation) throws NetconfDocumentedException {
+        logger.debug("Received start-exi message {} ", XmlUtil.toString(message));
+
+        try {
+            netconfSession.startExiCommunication(new NetconfMessage(message));
+        } catch (IllegalArgumentException e) {
+            throw new NetconfDocumentedException("Failed to parse EXI parameters", ErrorType.protocol,
+                    ErrorTag.operation_failed, ErrorSeverity.error);
+        }
+
+        return super.handle(message, subsequentOperation);
+    }
+
+    @Override
+    protected Element handleWithNoSubsequentOperations(Document document, XmlElement operationElement) throws NetconfDocumentedException {
+        Element getSchemaResult = document.createElementNS( XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0, XmlNetconfConstants.OK);
+        logger.trace("{} operation successful", START_EXI);
+        return getSchemaResult;
+    }
+
+    @Override
+    protected String getOperationName() {
+        return START_EXI;
+    }
+
+    @Override
+    protected String getOperationNamespace() {
+        return XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_EXI_1_0;
+    }
+
+    @Override
+    public void setNetconfSession(NetconfServerSession s) {
+        netconfSession = s;
+    }
+}
index 2a24ae32fa0cad9bef292cd53cc8718424692b7c..233638d5b08d57b608957d1f18085535918f80f6 100644 (file)
@@ -1,58 +1,58 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.netconf.impl.mapping.operations;\r
-\r
-import org.opendaylight.controller.netconf.api.NetconfDocumentedException;\r
-import org.opendaylight.controller.netconf.api.xml.XmlNetconfConstants;\r
-import org.opendaylight.controller.netconf.impl.NetconfServerSession;\r
-import org.opendaylight.controller.netconf.util.mapping.AbstractSingletonNetconfOperation;\r
-import org.opendaylight.controller.netconf.util.xml.XmlElement;\r
-import org.opendaylight.controller.netconf.util.xml.XmlUtil;\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
-import org.w3c.dom.Document;\r
-import org.w3c.dom.Element;\r
-\r
-public class DefaultStopExi extends AbstractSingletonNetconfOperation implements DefaultNetconfOperation {\r
-\r
-    public static final String STOP_EXI = "stop-exi";\r
-    private NetconfServerSession netconfSession;\r
-\r
-    private static final Logger logger = LoggerFactory\r
-            .getLogger(DefaultStartExi.class);\r
-\r
-    public DefaultStopExi(String netconfSessionIdForReporting) {\r
-        super(netconfSessionIdForReporting);\r
-    }\r
-\r
-    @Override\r
-    protected Element handleWithNoSubsequentOperations(Document document, XmlElement operationElement) throws NetconfDocumentedException {\r
-        logger.debug("Received stop-exi message {} ", XmlUtil.toString(operationElement));\r
-\r
-        netconfSession.stopExiCommunication();\r
-\r
-        Element getSchemaResult = document.createElementNS( XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0, XmlNetconfConstants.OK);\r
-        logger.trace("{} operation successful", STOP_EXI);\r
-        return getSchemaResult;\r
-    }\r
-\r
-    @Override\r
-    protected String getOperationName() {\r
-        return STOP_EXI;\r
-    }\r
-\r
-    @Override\r
-    protected String getOperationNamespace() {\r
-        return XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_EXI_1_0;\r
-    }\r
-\r
-    @Override\r
-    public void setNetconfSession(NetconfServerSession s) {\r
-        this.netconfSession = s;\r
-    }\r
-}\r
+/*
+ * 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.netconf.impl.mapping.operations;
+
+import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
+import org.opendaylight.controller.netconf.api.xml.XmlNetconfConstants;
+import org.opendaylight.controller.netconf.impl.NetconfServerSession;
+import org.opendaylight.controller.netconf.util.mapping.AbstractSingletonNetconfOperation;
+import org.opendaylight.controller.netconf.util.xml.XmlElement;
+import org.opendaylight.controller.netconf.util.xml.XmlUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+public class DefaultStopExi extends AbstractSingletonNetconfOperation implements DefaultNetconfOperation {
+
+    public static final String STOP_EXI = "stop-exi";
+    private NetconfServerSession netconfSession;
+
+    private static final Logger logger = LoggerFactory
+            .getLogger(DefaultStartExi.class);
+
+    public DefaultStopExi(String netconfSessionIdForReporting) {
+        super(netconfSessionIdForReporting);
+    }
+
+    @Override
+    protected Element handleWithNoSubsequentOperations(Document document, XmlElement operationElement) throws NetconfDocumentedException {
+        logger.debug("Received stop-exi message {} ", XmlUtil.toString(operationElement));
+
+        netconfSession.stopExiCommunication();
+
+        Element getSchemaResult = document.createElementNS( XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0, XmlNetconfConstants.OK);
+        logger.trace("{} operation successful", STOP_EXI);
+        return getSchemaResult;
+    }
+
+    @Override
+    protected String getOperationName() {
+        return STOP_EXI;
+    }
+
+    @Override
+    protected String getOperationNamespace() {
+        return XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_EXI_1_0;
+    }
+
+    @Override
+    public void setNetconfSession(NetconfServerSession s) {
+        this.netconfSession = s;
+    }
+}
index c2dcd679210f1d66cd055e48a9c05494d3d8d374..444d4fe4abad44c6168d7ef2befff13f5d1af7fe 100644 (file)
@@ -7,8 +7,7 @@
  */
 package org.opendaylight.controller.netconf.impl;
 
-import junit.framework.Assert;
-
+import static org.junit.Assert.assertEquals;
 import org.junit.Test;
 import org.opendaylight.controller.netconf.util.messages.NetconfHelloMessageAdditionalHeader;
 
@@ -18,18 +17,18 @@ public class AdditionalHeaderParserTest {
     public void testParsing() throws Exception {
         String s = "[netconf;10.12.0.102:48528;ssh;;;;;;]";
         NetconfHelloMessageAdditionalHeader header = NetconfHelloMessageAdditionalHeader.fromString(s);
-        Assert.assertEquals("netconf", header.getUserName());
-        Assert.assertEquals("10.12.0.102", header.getAddress());
-        Assert.assertEquals("ssh", header.getTransport());
+        assertEquals("netconf", header.getUserName());
+        assertEquals("10.12.0.102", header.getAddress());
+        assertEquals("ssh", header.getTransport());
     }
 
     @Test
     public void testParsing2() throws Exception {
         String s = "[tomas;10.0.0.0/10000;tcp;1000;1000;;/home/tomas;;]";
         NetconfHelloMessageAdditionalHeader header = NetconfHelloMessageAdditionalHeader.fromString(s);
-        Assert.assertEquals("tomas", header.getUserName());
-        Assert.assertEquals("10.0.0.0", header.getAddress());
-        Assert.assertEquals("tcp", header.getTransport());
+        assertEquals("tomas", header.getUserName());
+        assertEquals("10.0.0.0", header.getAddress());
+        assertEquals("tcp", header.getTransport());
     }
 
     @Test(expected = IllegalArgumentException.class)
index 58c6566d91dfb7b86230e6fcd48cfd3f12d12912..b54b2180338eab2016200b4f23aad94e7f286167 100644 (file)
@@ -7,7 +7,7 @@
  */
 package org.opendaylight.controller.netconf.impl;
 
-import static junit.framework.Assert.assertNotNull;
+import static org.junit.Assert.assertNotNull;
 
 import org.junit.Test;
 import org.opendaylight.controller.netconf.api.NetconfMessage;
index ae3d65646f4f1c1775ec0e1714c937c7543a6f88..d6b0201ab88a0245e666b4bb7fe2e77552a0075b 100644 (file)
@@ -13,8 +13,6 @@ import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
 import org.opendaylight.controller.netconf.util.xml.XmlElement;
 import org.opendaylight.controller.netconf.util.xml.XmlUtil;
 import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
 import static org.mockito.Mockito.doNothing;
 import static org.mockito.Mockito.doThrow;
 import static org.mockito.Mockito.mock;
index b655e90f2bbbea10f0bc4958b6fab2ab57922a21..4218176f1d8ff7297f769c9c0f097287c5ae24a8 100644 (file)
@@ -8,8 +8,13 @@
 
 package org.opendaylight.controller.netconf.impl.mapping.operations;
 
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.mock;
 import com.google.common.base.Optional;
-import junit.framework.Assert;
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
@@ -18,13 +23,6 @@ import org.opendaylight.controller.netconf.util.xml.XmlElement;
 import org.opendaylight.controller.netconf.util.xml.XmlUtil;
 import org.w3c.dom.Document;
 
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.doThrow;
-import static org.mockito.Mockito.mock;
-
 public class DefaultGetSchemaTest {
 
     private CapabilityProvider cap;
index b59ea884c5631122f3689bf6b8a1e61ee2943d32..9470e6d09c9f0c4d24d989b77188e6d79f7db6bd 100644 (file)
@@ -9,18 +9,23 @@
 package org.opendaylight.controller.netconf.impl.osgi;
 
 import java.util.Arrays;
-import java.util.Collection;
 import java.util.Dictionary;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
-import org.opendaylight.controller.netconf.api.monitoring.NetconfMonitoringService;
-import org.opendaylight.controller.netconf.mapping.api.NetconfOperationProvider;
-import org.osgi.framework.*;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Filter;
+import org.osgi.framework.ServiceListener;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
 
 import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.*;
+import static org.mockito.Mockito.anyString;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
 
 public class NetconfImplActivatorTest {
 
index d8eb841a799faf1993f025126bb241d8ceba4c66..cc170358dd2c0e5e82fbbb644c889ebf9dc5c7ee 100644 (file)
@@ -7,7 +7,7 @@
  */
 package org.opendaylight.controller.netconf.it;
 
-import static junit.framework.Assert.assertEquals;
+import static org.junit.Assert.assertEquals;
 import static org.mockito.Matchers.any;
 import static org.mockito.Matchers.anyString;
 import static org.mockito.Mockito.doAnswer;
index 5fceac06dd51c4b0798159571764b4826191b906..5a744fda14f2f1bc5cac2e2a7aec57bde9817d04 100644 (file)
@@ -8,13 +8,12 @@
 
 package org.opendaylight.controller.netconf.monitoring;
 
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertTrue;
-import static junit.framework.TestCase.fail;
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.doThrow;
-
 import java.util.Collections;
 import org.hamcrest.CoreMatchers;
 import org.junit.Before;
index 40493569d68adaf9ec54f9249cbe7fac8ab11bdc..b5b9f3c060f5bdf6c98abf832c256ab894ad95c2 100644 (file)
@@ -8,6 +8,12 @@
 
 package org.opendaylight.controller.netconf.monitoring.osgi;
 
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
 import java.util.Arrays;
 import org.junit.Before;
 import org.junit.Test;
@@ -18,10 +24,6 @@ import org.osgi.framework.Filter;
 import org.osgi.framework.ServiceListener;
 import org.osgi.framework.ServiceReference;
 
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Mockito.*;
-
 public class NetconfMonitoringActivatorTest {
 
     @Mock
@@ -34,7 +36,7 @@ public class NetconfMonitoringActivatorTest {
         MockitoAnnotations.initMocks(this);
         doReturn(filter).when(context).createFilter(anyString());
         doNothing().when(context).addServiceListener(any(ServiceListener.class), anyString());
-        ServiceReference[] refs = new ServiceReference[2];
+        ServiceReference<?>[] refs = new ServiceReference[2];
         doReturn(Arrays.asList(refs)).when(context).getServiceReferences(any(Class.class), anyString());
         doReturn(refs).when(context).getServiceReferences(anyString(), anyString());
     }
index 2a53a6ce45925e0223f4c5df508e4b4bf1a1245b..b992b0e44f363deaba01eeca50d9194d40fefc81 100644 (file)
@@ -8,6 +8,12 @@
 
 package org.opendaylight.controller.netconf.monitoring.osgi;
 
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
 import java.util.Hashtable;
 import org.junit.Before;
 import org.junit.Test;
@@ -20,18 +26,14 @@ import org.osgi.framework.Filter;
 import org.osgi.framework.ServiceReference;
 import org.osgi.framework.ServiceRegistration;
 
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyCollection;
-import static org.mockito.Mockito.*;
-
 public class NetconfMonitoringServiceTrackerTest {
 
     @Mock
-    private ServiceReference reference;
+    private ServiceReference<NetconfMonitoringService> reference;
     @Mock
     private BundleContext context;
     @Mock
-    private ServiceRegistration serviceRegistration;
+    private ServiceRegistration<?> serviceRegistration;
     @Mock
     private Filter filter;
     @Mock
index 531ba3ccb725589d76725ebfc9ecdae7ecdd35bc..ccd7dead9f1a9a782743d423650fd5153005e1eb 100644 (file)
@@ -48,18 +48,18 @@ public final class EXIParameters {
             final String alignmentTextContent = alignmentElement.getTextContent().trim();
 
             switch (alignmentTextContent) {
-                case EXI_PARAMETER_BIT_PACKED:
-                    options.setAlignmentType(AlignmentType.bitPacked);
-                    break;
-                case EXI_PARAMETER_BYTE_ALIGNED:
-                    options.setAlignmentType(AlignmentType.byteAligned);
-                    break;
-                case EXI_PARAMETER_COMPRESSED:
-                    options.setAlignmentType(AlignmentType.compress);
-                    break;
-                case EXI_PARAMETER_PRE_COMPRESSION:
-                    options.setAlignmentType(AlignmentType.preCompress);
-                    break;
+            case EXI_PARAMETER_BIT_PACKED:
+                options.setAlignmentType(AlignmentType.bitPacked);
+                break;
+            case EXI_PARAMETER_BYTE_ALIGNED:
+                options.setAlignmentType(AlignmentType.byteAligned);
+                break;
+            case EXI_PARAMETER_COMPRESSED:
+                options.setAlignmentType(AlignmentType.compress);
+                break;
+            case EXI_PARAMETER_PRE_COMPRESSION:
+                options.setAlignmentType(AlignmentType.preCompress);
+                break;
             }
         }
 
index 93475129d2b61687968ee7c05ce8bef6ff58fa62..556bece43f372b28b5c0aea12d096152638dd2a3 100644 (file)
@@ -11,7 +11,6 @@ package org.opendaylight.controller.netconf.nettyutil.handler;
 import static org.junit.Assert.assertEquals;
 import static org.mockito.Matchers.anyObject;
 import static org.mockito.Mockito.doAnswer;
-
 import com.google.common.collect.Lists;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
@@ -50,7 +49,7 @@ public class ChunkedFramingMechanismEncoderTest {
     @Test
     public void testEncode() throws Exception {
         final List<ByteBuf> chunks = Lists.newArrayList();
-        doAnswer(new Answer() {
+        doAnswer(new Answer<Object>() {
             @Override
             public Object answer(final InvocationOnMock invocation) throws Throwable {
                 chunks.add((ByteBuf) invocation.getArguments()[0]);
index 4a8db176fed7e21c60ed9db6c9f3365343bc3cb8..8bc0fb8e8242efcc640ea4a1b1ffc4a9f88818f6 100644 (file)
@@ -8,15 +8,14 @@
 
 package org.opendaylight.controller.netconf.nettyutil.handler;
 
-import static org.junit.Assert.*;
-
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
 import com.google.common.collect.Lists;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
-import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 import org.custommonkey.xmlunit.XMLUnit;
index 212eabb290656cb676c6cf6f925ee132f2b43242..b4c9e1e95083dd94b21d57318ef989dca355bdd2 100644 (file)
@@ -22,10 +22,17 @@ import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.verifyNoMoreInteractions;
 import static org.mockito.Mockito.verifyZeroInteractions;
-
+import com.google.common.util.concurrent.FutureCallback;
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.SettableFuture;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.ChannelPromise;
 import java.io.IOException;
 import java.net.SocketAddress;
-
 import org.apache.sshd.ClientChannel;
 import org.apache.sshd.ClientSession;
 import org.apache.sshd.SshClient;
@@ -52,17 +59,6 @@ import org.mockito.invocation.InvocationOnMock;
 import org.mockito.stubbing.Answer;
 import org.opendaylight.controller.netconf.nettyutil.handler.ssh.authentication.AuthenticationHandler;
 
-import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.SettableFuture;
-
-import io.netty.buffer.ByteBuf;
-import io.netty.buffer.Unpooled;
-import io.netty.channel.Channel;
-import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.ChannelPromise;
-
 public class AsyncSshHandlerTest {
 
     @Mock
@@ -126,7 +122,7 @@ public class AsyncSshHandlerTest {
     private <T extends SshFuture<T>> ListenableFuture<SshFutureListener<T>> stubAddListener(final T future) {
         final SettableFuture<SshFutureListener<T>> listenerSettableFuture = SettableFuture.create();
 
-        doAnswer(new Answer() {
+        doAnswer(new Answer<Object>() {
             @Override
             public Object answer(final InvocationOnMock invocation) throws Throwable {
                 listenerSettableFuture.set((SshFutureListener<T>) invocation.getArguments()[0]);
index b6f5854aa331140cf21c1de433c5f4a9263e6201..b7ebc51b70712a5ebabc322018c5707636113d13 100644 (file)
@@ -8,8 +8,8 @@
 
 package org.opendaylight.controller.netconf.util.mapping;
 
+import com.google.common.base.Optional;
 import java.util.Map;
-
 import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
 import org.opendaylight.controller.netconf.api.xml.XmlNetconfConstants;
 import org.opendaylight.controller.netconf.mapping.api.HandlingPriority;
@@ -17,20 +17,15 @@ import org.opendaylight.controller.netconf.mapping.api.NetconfOperation;
 import org.opendaylight.controller.netconf.mapping.api.NetconfOperationChainedExecution;
 import org.opendaylight.controller.netconf.util.xml.XmlElement;
 import org.opendaylight.controller.netconf.util.xml.XmlUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.w3c.dom.Attr;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.NodeList;
 
-import com.google.common.base.Optional;
-
 public abstract class AbstractNetconfOperation implements NetconfOperation {
     private final String netconfSessionIdForReporting;
-    private static final Logger logger = LoggerFactory.getLogger(AbstractNetconfOperation.class);
 
-    protected AbstractNetconfOperation(String netconfSessionIdForReporting) {
+    protected AbstractNetconfOperation(final String netconfSessionIdForReporting) {
         this.netconfSessionIdForReporting = netconfSessionIdForReporting;
     }
 
@@ -39,7 +34,7 @@ public abstract class AbstractNetconfOperation implements NetconfOperation {
     }
 
     @Override
-    public HandlingPriority canHandle(Document message) throws NetconfDocumentedException {
+    public HandlingPriority canHandle(final Document message) throws NetconfDocumentedException {
         OperationNameAndNamespace operationNameAndNamespace = null;
         operationNameAndNamespace = new OperationNameAndNamespace(message);
         return canHandle(operationNameAndNamespace.getOperationName(), operationNameAndNamespace.getNamespace());
@@ -49,7 +44,7 @@ public abstract class AbstractNetconfOperation implements NetconfOperation {
         private final String operationName, namespace;
         private final XmlElement operationElement;
 
-        public OperationNameAndNamespace(Document message) throws NetconfDocumentedException {
+        public OperationNameAndNamespace(final Document message) throws NetconfDocumentedException {
             XmlElement requestElement = null;
             requestElement = getRequestElementWithCheck(message);
             operationElement = requestElement.getOnlyChildElement();
@@ -70,12 +65,12 @@ public abstract class AbstractNetconfOperation implements NetconfOperation {
         }
     }
 
-    protected static XmlElement getRequestElementWithCheck(Document message) throws NetconfDocumentedException {
+    protected static XmlElement getRequestElementWithCheck(final Document message) throws NetconfDocumentedException {
         return XmlElement.fromDomElementWithExpected(message.getDocumentElement(), XmlNetconfConstants.RPC_KEY,
                 XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0);
     }
 
-    protected HandlingPriority canHandle(String operationName, String operationNamespace) {
+    protected HandlingPriority canHandle(final String operationName, final String operationNamespace) {
         return operationName.equals(getOperationName()) && operationNamespace.equals(getOperationNamespace())
                 ? getHandlingPriority()
                 : HandlingPriority.CANNOT_HANDLE;
@@ -92,8 +87,8 @@ public abstract class AbstractNetconfOperation implements NetconfOperation {
     protected abstract String getOperationName();
 
     @Override
-    public Document handle(Document requestMessage,
-            NetconfOperationChainedExecution subsequentOperation) throws NetconfDocumentedException {
+    public Document handle(final Document requestMessage,
+            final NetconfOperationChainedExecution subsequentOperation) throws NetconfDocumentedException {
 
         XmlElement requestElement = getRequestElementWithCheck(requestMessage);
 
index b8605d823066330e2a4c0b0650a2024f12c063f6..47d0d4c7ccc56294d85e753f603e6c8bd951f2c0 100644 (file)
@@ -7,14 +7,13 @@
  */
 package org.opendaylight.controller.netconf.util;
 
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.fail;
 import org.junit.Test;
 import org.opendaylight.controller.netconf.util.xml.XmlUtil;
 import org.w3c.dom.Document;
 
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.fail;
-import static org.junit.matchers.JUnitMatchers.containsString;
-
 public class NetconfUtilTest {
 
     @Test
index c39ac8eb10ec043cbdbe6b2a9183b75def68436b..5a9d07f6b1689455eae43a6dff82f6c5984803b7 100644 (file)
@@ -9,32 +9,32 @@
 package org.opendaylight.controller.netconf.util.messages;
 
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 import com.google.common.base.Optional;
 import java.util.Set;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.internal.util.collections.Sets;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
 
 public class NetconfHelloMessageTest {
 
     Set<String> caps;
 
     @Before
-    public void setUp() throws Exception {
+    public void setUp() {
         caps = Sets.newSet("cap1");
     }
 
     @Test
-    public void testConstructor() throws Exception {
+    public void testConstructor() throws NetconfDocumentedException {
         NetconfHelloMessageAdditionalHeader additionalHeader = new NetconfHelloMessageAdditionalHeader("name","host","1","transp","id");
         NetconfHelloMessage message = NetconfHelloMessage.createClientHello(caps, Optional.of(additionalHeader));
-        assertTrue(message.isHelloMessage(message));
+        assertTrue(NetconfHelloMessage.isHelloMessage(message));
         assertEquals(Optional.of(additionalHeader), message.getAdditionalHeader());
 
         NetconfHelloMessage serverMessage = NetconfHelloMessage.createServerHello(caps, 100L);
-        assertTrue(serverMessage.isHelloMessage(serverMessage));
+        assertTrue(NetconfHelloMessage.isHelloMessage(serverMessage));
     }
 }
index cca89aed593b1857db18940ad93a57efd4ad53fe..d5ff3380d28b7493b1b7e18962fc1bdbc4505e16 100644 (file)
@@ -8,13 +8,12 @@
 
 package org.opendaylight.controller.netconf.util.messages;
 
-import com.google.common.base.Charsets;
-import java.util.Arrays;
-import org.junit.Test;
-
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
+import com.google.common.base.Charsets;
+import org.junit.Test;
 
+@Deprecated
 public class NetconfMessageHeaderTest {
     @Test
     public void testGet() throws Exception {
index 741d0d24520022cc5ee4cbb997f9140c6d1a1124..ebee41145ab1d77c2296bf21ded57c83b172d98e 100644 (file)
@@ -8,20 +8,18 @@
 
 package org.opendaylight.controller.netconf.util.osgi;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
 import com.google.common.base.Optional;
 import io.netty.channel.local.LocalAddress;
 import java.net.InetSocketAddress;
 import org.junit.Before;
 import org.junit.Test;
-import org.opendaylight.controller.netconf.util.NetconfUtil;
 import org.osgi.framework.BundleContext;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-
 public class NetconfConfigUtilTest {
 
     private BundleContext bundleContext;
index e7a483e4056a9f8c4ccb2aa1c1cbcc9e6d2b2032..5e94ac6110ca73d84817222f566cf965ff01d62d 100644 (file)
@@ -1,9 +1,9 @@
-<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" a="64" message-id="a">\r
-<start-exi xmlns="urn:ietf:params:xml:ns:netconf:exi:1.0">\r
-<alignment>pre-compression</alignment>\r
-<fidelity>\r
-<dtd/>\r
-<lexical-values/>\r
-</fidelity>\r
-</start-exi>\r
-</rpc>
\ No newline at end of file
+<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" a="64" message-id="a">
+<start-exi xmlns="urn:ietf:params:xml:ns:netconf:exi:1.0">
+<alignment>pre-compression</alignment>
+<fidelity>
+<dtd/>
+<lexical-values/>
+</fidelity>
+</start-exi>
+</rpc>
index 6c0524a4fce9d9059e8fd32b6fc2a21cd7c1ff60..170c753993f174d5aeeba66ca7e157ec5a7ad757 100644 (file)
@@ -1,3 +1,3 @@
-<rpc message-id="a" a="64" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">\r
-    <stop-exi xmlns="urn:ietf:params:xml:ns:netconf:exi:1.0"/>\r
-</rpc>
\ No newline at end of file
+<rpc message-id="a" a="64" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+    <stop-exi xmlns="urn:ietf:params:xml:ns:netconf:exi:1.0"/>
+</rpc>
index 1c35404c809f4fe18e735624e0e5a710e8c831e7..13431fbd86b7fdb11a6d2b9ac4027812f9ba7f8b 100644 (file)
@@ -7,8 +7,6 @@
  */
 package org.opendaylight.controller.northbound.bundlescanner.internal;
 
-
-
 import java.io.File;
 import java.io.FileFilter;
 import java.net.MalformedURLException;
@@ -37,8 +35,8 @@ import org.osgi.framework.Constants;
 import org.springframework.osgi.mock.MockBundle;
 import org.springframework.osgi.mock.MockBundleContext;
 
-import static junit.framework.Assert.assertNotNull;
 import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
 public class BundleScannerTest {
index 298f32877aede02d5e3c796b1edf1fe7cce86a64..bcfa2a9ee9bed058908a4f87ede45868c1e032c4 100644 (file)
@@ -7,8 +7,6 @@
  */
 package org.opendaylight.controller.topology.northbound;
 
-
-
 import org.junit.Test;
 import org.opendaylight.controller.sal.core.Bandwidth;
 import org.opendaylight.controller.sal.core.ConstructionException;
@@ -28,7 +26,7 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
-import static junit.framework.Assert.assertEquals;
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
 
 public class TopologyTest {