Adjust to yangtools-2.0.0 changes 75/64175/42
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 11 Oct 2017 19:31:07 +0000 (21:31 +0200)
committerStephen Kitt <skitt@redhat.com>
Thu, 11 Jan 2018 17:57:11 +0000 (18:57 +0100)
Change-Id: Ib86747e5ed19c0c00bb46b8d7e4936f4d90c4364
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Signed-off-by: Stephen Kitt <skitt@redhat.com>
135 files changed:
features/config/odl-config-netty-config-api/src/main/feature/feature.xml [new file with mode: 0644]
features/mdsal/odl-mdsal-broker-local/src/main/feature/feature.xml
features/mdsal/odl-mdsal-clustering-commons/src/main/feature/feature.xml [new file with mode: 0644]
features/mdsal/odl-mdsal-remoterpc-connector/src/main/feature/feature.xml [new file with mode: 0644]
opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/DataStoreAppConfigDefaultXMLReader.java
opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/RpcUtil.java
opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/ValidationException.java
opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/ConfigSubsystemFacade.java
opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/ConfigSubsystemFacadeFactory.java
opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/attributes/fromxml/ObjectXmlReader.java
opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/attributes/fromxml/SimpleIdentityRefAttributeReadingStrategy.java
opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/attributes/mapping/SimpleAttributeMappingStrategy.java
opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/attributes/resolving/SimpleAttributeResolvingStrategy.java
opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/config/Config.java
opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/config/InstanceConfig.java
opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/config/ModuleConfig.java
opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/osgi/YangStoreContext.java
opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/osgi/YangStoreService.java
opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/osgi/YangStoreSnapshot.java
opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/rpc/InstanceRuntimeRpc.java
opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/util/Util.java
opendaylight/config/config-manager-facade-xml/src/test/java/org/opendaylight/controller/config/facade/xml/mapping/attributes/fromxml/SimpleIdentityRefAttributeReadingStrategyTest.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/mapping/RefreshingSCPModuleInfoRegistry.java
opendaylight/config/config-persister-impl/src/test/java/org/opendaylight/controller/config/persist/impl/ConfigPusherImplTest.java
opendaylight/config/config-util/src/main/java/org/opendaylight/controller/config/util/capability/YangModuleCapability.java
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/JMXGenerator.java
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/model/Annotation.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/JMXGeneratorTest.java
opendaylight/config/yang-jmx-generator/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/ModuleMXBeanEntry.java
opendaylight/config/yang-jmx-generator/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/ModuleMXBeanEntryBuilder.java
opendaylight/config/yang-jmx-generator/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/ServiceInterfaceEntry.java
opendaylight/config/yang-jmx-generator/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/attribute/JavaAttribute.java
opendaylight/config/yang-jmx-generator/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/attribute/ListAttribute.java
opendaylight/config/yang-jmx-generator/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/attribute/TOAttribute.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/ModuleMXBeanEntryNameConflictTest.java
opendaylight/config/yang-jmx-generator/src/test/java/org/opendaylight/controller/config/yangjmxgenerator/ModuleMXBeanEntryTest.java
opendaylight/config/yang-jmx-generator/src/test/java/org/opendaylight/controller/config/yangjmxgenerator/RuntimeBeanEntryTest.java
opendaylight/config/yang-jmx-generator/src/test/java/org/opendaylight/controller/config/yangjmxgenerator/RuntimeRegistratorTest.java
opendaylight/config/yang-jmx-generator/src/test/java/org/opendaylight/controller/config/yangjmxgenerator/SchemaContextTest.java
opendaylight/config/yang-jmx-generator/src/test/java/org/opendaylight/controller/config/yangjmxgenerator/ServiceInterfaceEntryTest.java
opendaylight/config/yang-jmx-generator/src/test/java/org/opendaylight/controller/config/yangjmxgenerator/unknownextension/UnknownExtensionTest.java
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/ConnectClientSuccessTest.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingStructuralType.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingToNormalizedNodeCodec.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/FutureSchema.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/LazyDataObjectModification.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/LazySerializedContainerNode.java
opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/BindingNormalizedCodecTest.java
opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/WriteParentListenAugmentTest.java
opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/WriteParentReadChildTest.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-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/NormalizedNodeOutputStreamWriter.java
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/util/AbstractDataTreeModificationCursor.java
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/schema/provider/impl/YangTextSchemaSourceSerializationProxy.java
opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/NormalizedNodeStreamReaderWriterTest.java
opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/transformer/NormalizedNodePrunerTest.java
opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/util/TestModel.java
opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/schema/provider/impl/RemoteSchemaProviderTest.java
opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/schema/provider/impl/RemoteYangTextSourceProviderImplTest.java
opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/schema/provider/impl/YangTextSourceSerializationProxyTest.java
opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/util/compat/DataNormalizationOperation.java
opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/util/compat/DataSchemaContainerProxy.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/LocalProxyTransaction.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/FrontendReadOnlyTransaction.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/FrontendReadWriteTransaction.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/Shard.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTree.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardTransaction.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/AbstractEntityOwnerChangeListener.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/DistributedEntityOwnershipCandidateRegistration.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/DistributedEntityOwnershipListenerRegistration.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/DistributedEntityOwnershipService.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/EntityOwnerChangeListener.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/EntityOwnersModel.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/EntityOwnershipShard.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/EntityOwnershipStatistics.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/AbstractDataTreeCandidateNode.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/DeletedDataTreeCandidateNode.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/ModifiedDataTreeCandidateNode.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManager.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/NormalizedNodeAggregator.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/PruningDataTreeModification.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/DistributedShardChangePublisher.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/ShardProxyTransaction.java
opendaylight/md-sal/sal-distributed-datastore/src/main/resources/org/opendaylight/blueprint/clustered-datastore.xml
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/actors/dds/AbstractDataStoreClientBehaviorTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/actors/dds/ClientSnapshotTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/actors/dds/ClientTransactionTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/actors/dds/LocalReadOnlyProxyTransactionTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/actors/dds/LocalReadWriteProxyTransactionTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/AbstractShardTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DatastoreSnapshotRestoreTest.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/DistributedDataStoreRemotingIntegrationTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardDataTreeTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardRecoveryCoordinatorTest.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/TransactionProxyTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/entityownership/AbstractEntityOwnershipTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/entityownership/EntityOwnershipStatisticsTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/messages/ReadyLocalTransactionSerializerTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/persisted/CommitTransactionPayloadTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/MockDataTreeChangeListener.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/PruningDataTreeModificationTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/sharding/DistributedShardedDOMDataTreeTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/CompositeModel.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/SchemaContextHelper.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/TestModel.java
opendaylight/md-sal/sal-dom-api/src/test/java/org/opendaylight/controller/md/sal/dom/api/AbstractDOMDataTreeServiceTestSuite.java
opendaylight/md-sal/sal-dom-broker-config/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/impl/DomInmemoryDataBrokerModule.java
opendaylight/md-sal/sal-dom-broker-config/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/impl/SchemaServiceImplSingletonModule.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMRpcRoutingTable.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/RoutedDOMRpcRoutingTableEntry.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/legacy/sharded/adapter/ShardedDOMDataBrokerDelegatingReadWriteTransaction.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/mount/DOMMountPointServiceImpl.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/util/ProxySchemaContext.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/util/YangSchemaUtils.java
opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMBrokerTest.java
opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMDataTreeListenerTest.java
opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/TestModel.java
opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/SnapshotBackedReadTransaction.java
opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/SnapshotBackedWriteTransaction.java
opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStore.java
opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStoreFactory.java
opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMStoreTreeChangePublisher.java
opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/ResolveDataChangeEventsTask.java
opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/ListenerNode.java
opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/AbstractDataChangeListenerTest.java
opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/TestModel.java
opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/AbstractRpcTest.java
opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/registry/RpcRegistryTest.java
opendaylight/md-sal/sal-schema-service/src/main/java/org/opendaylight/controller/sal/schema/service/impl/GlobalBundleScanningSchemaServiceImpl.java
opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/CarEntryDataTreeCommitCohort.java

diff --git a/features/config/odl-config-netty-config-api/src/main/feature/feature.xml b/features/config/odl-config-netty-config-api/src/main/feature/feature.xml
new file mode 100644 (file)
index 0000000..63903bf
--- /dev/null
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Copyright © 2017 Red Hat, Inc. and others.
+  ~
+  ~ This program and the accompanying materials are made available under the
+  ~ terms of the Eclipse Public License v1.0 which accompanies this distribution,
+  ~ and is available at http://www.eclipse.org/legal/epl-v10.html
+  -->
+<features name="odl-controller-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.4.0">
+    <feature name="odl-config-netty-config-api" version="${project.version}">
+        <feature version="[3.0.0,4)">odl-netty-4</feature>
+    </feature>
+</features>
index 654311a..3593abf 100644 (file)
@@ -10,6 +10,7 @@
     <!-- This needs to be added manually until we resolve the odl-mdsal-common situation -->
     <repository>mvn:org.opendaylight.controller/odl-mdsal-common/${project.version}/xml/features</repository>
     <feature name="odl-mdsal-broker-local" version="${project.version}">
+        <feature version="[3.0.0,4)">odl-lmax-3</feature>
         <bundle start-level="70">mvn:org.opendaylight.controller/sal-schema-service/${project.version}</bundle>
         <bundle start-level="40">mvn:org.opendaylight.controller/blueprint/${blueprint.version}</bundle>
         <configfile finalname="${config.configfile.directory}/${config.mdsal.configfile}" override="true">
diff --git a/features/mdsal/odl-mdsal-clustering-commons/src/main/feature/feature.xml b/features/mdsal/odl-mdsal-clustering-commons/src/main/feature/feature.xml
new file mode 100644 (file)
index 0000000..2c9dfd0
--- /dev/null
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Copyright © 2017 Red Hat, Inc. and others.
+  ~
+  ~ This program and the accompanying materials are made available under the
+  ~ terms of the Eclipse Public License v1.0 which accompanies this distribution,
+  ~ and is available at http://www.eclipse.org/legal/epl-v10.html
+  -->
+<features name="odl-controller-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.4.0">
+    <feature name="odl-mdsal-clustering-commons" version="${project.version}">
+        <feature version="[3.0.0,4)">odl-akka-system-2.5</feature>
+        <feature version="[3.0.0,4)">odl-akka-persistence-2.5</feature>
+        <feature version="[3.0.0,4)">odl-akka-clustering-2.5</feature>
+    </feature>
+</features>
diff --git a/features/mdsal/odl-mdsal-remoterpc-connector/src/main/feature/feature.xml b/features/mdsal/odl-mdsal-remoterpc-connector/src/main/feature/feature.xml
new file mode 100644 (file)
index 0000000..e64822e
--- /dev/null
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Copyright © 2017 Red Hat, Inc. and others.
+  ~
+  ~ This program and the accompanying materials are made available under the
+  ~ terms of the Eclipse Public License v1.0 which accompanies this distribution,
+  ~ and is available at http://www.eclipse.org/legal/epl-v10.html
+  -->
+<features name="odl-controller-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.4.0">
+    <feature name="odl-mdsal-remoterpc-connector" version="${project.version}">
+        <feature version="[3.0.0,4)">odl-akka-leveldb-0.7</feature>
+    </feature>
+</features>
index ece6901..9f909c4 100644 (file)
@@ -112,8 +112,7 @@ public class DataStoreAppConfigDefaultXMLReader<T extends DataObject> {
 
         SchemaContext schemaContext = schemaService.getGlobalContext();
 
-        Module module = schemaContext.findModuleByNamespaceAndRevision(bindingContext.bindingQName.getNamespace(),
-                bindingContext.bindingQName.getRevision());
+        Module module = schemaContext.findModule(bindingContext.bindingQName.getModule()).orElse(null);
         checkNotNull(module, "%s: Could not obtain the module schema for namespace %s, revision %s",
                 logName, bindingContext.bindingQName.getNamespace(), bindingContext.bindingQName.getRevision());
 
@@ -138,13 +137,13 @@ public class DataStoreAppConfigDefaultXMLReader<T extends DataObject> {
         return (T) appConfig;
     }
 
-    private static void checkNotNull(Object reference, String errorMessageFormat, Object... formatArgs)
-            throws ConfigXMLReaderException {
+    private static void checkNotNull(final Object reference, final String errorMessageFormat,
+            final Object... formatArgs) throws ConfigXMLReaderException {
         checkCondition(reference != null, errorMessageFormat, formatArgs);
     }
 
-    private static void checkCondition(boolean expression, String errorMessageFormat, Object... formatArgs)
-            throws ConfigXMLReaderException {
+    private static void checkCondition(final boolean expression, final String errorMessageFormat,
+            final Object... formatArgs) throws ConfigXMLReaderException {
         if (!expression) {
             throw new ConfigXMLReaderException(String.format(errorMessageFormat, formatArgs));
         }
index ee9e36e..dc65d9b 100644 (file)
@@ -36,8 +36,7 @@ final class RpcUtil {
     static Collection<SchemaPath> decomposeRpcService(final Class<RpcService> service,
             final SchemaContext schemaContext, final Predicate<RpcRoutingStrategy> filter) {
         final QNameModule moduleName = BindingReflections.getQNameModule(service);
-        final Module module = schemaContext.findModuleByNamespaceAndRevision(moduleName.getNamespace(),
-                moduleName.getRevision());
+        final Module module = schemaContext.findModule(moduleName).get();
         LOG.debug("Resolved service {} to module {}", service, module);
 
         final Collection<RpcDefinition> rpcs = module.getRpcs();
index 760853e..9daacd1 100644 (file)
@@ -102,8 +102,8 @@ public class ValidationException extends Exception {
             this.message = message;
         }
 
-        public void setStackTrace(final String stackTrace) {
-            this.stackTrace = stackTrace;
+        public void setStackTrace(final String trace) {
+            this.stackTrace = trace;
         }
 
         @Override
index 0f9e6f3..4ee3c7a 100644 (file)
@@ -10,17 +10,13 @@ package org.opendaylight.controller.config.facade.xml;
 
 import com.google.common.base.Optional;
 import com.google.common.collect.Multimap;
-
 import java.io.Closeable;
-import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-
 import javax.management.InstanceNotFoundException;
 import javax.management.ObjectName;
-
 import org.opendaylight.controller.config.api.ConflictingVersionException;
 import org.opendaylight.controller.config.api.ValidationException;
 import org.opendaylight.controller.config.api.jmx.CommitStatus;
@@ -53,6 +49,7 @@ import org.opendaylight.controller.config.util.xml.XmlMappingConstants;
 import org.opendaylight.controller.config.util.xml.XmlUtil;
 import org.opendaylight.controller.config.yangjmxgenerator.ModuleMXBeanEntry;
 import org.opendaylight.controller.config.yangjmxgenerator.RuntimeBeanEntry;
+import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.slf4j.Logger;
@@ -205,7 +202,7 @@ public class ConfigSubsystemFacade implements Closeable {
         setOnTransaction(ta, configExecution);
     }
 
-    private void setServicesOnTransaction(final ConfigTransactionClient ta, final ConfigExecution execution)
+    private static void setServicesOnTransaction(final ConfigTransactionClient ta, final ConfigExecution execution)
             throws DocumentedException {
         Services services = execution.getServices();
 
@@ -244,11 +241,12 @@ public class ConfigSubsystemFacade implements Closeable {
         }
     }
 
-    private String getQname(final ConfigTransactionClient ta, final String namespace, final String serviceName) {
+    private static String getQname(final ConfigTransactionClient ta, final String namespace,
+            final String serviceName) {
         return ta.getServiceInterfaceName(namespace, serviceName);
     }
 
-    private void setOnTransaction(final ConfigTransactionClient ta, final ConfigExecution execution)
+    private static void setOnTransaction(final ConfigTransactionClient ta, final ConfigExecution execution)
             throws DocumentedException {
 
         for (Multimap<String, ModuleElementResolved> modulesToResolved : execution.getResolvedXmlElements(ta)
@@ -268,8 +266,8 @@ public class ConfigSubsystemFacade implements Closeable {
         }
     }
 
-    private void handleMisssingInstancesOnTransaction(final ConfigTransactionClient ta, final ConfigExecution execution)
-            throws DocumentedException {
+    private static void handleMisssingInstancesOnTransaction(final ConfigTransactionClient ta,
+            final ConfigExecution execution) throws DocumentedException {
 
         for (Multimap<String, ModuleElementDefinition> modulesToResolved : execution.getModulesDefinition(ta)
                 .values()) {
@@ -289,18 +287,20 @@ public class ConfigSubsystemFacade implements Closeable {
         final YangStoreContext snapshot = yangStoreService.getCurrentSnapshot();
         Map<String, Map<String, ModuleConfig>> factories = transformMbeToModuleConfigs(
                 snapshot.getModuleMXBeanEntryMap());
-        Map<String, Map<Date, IdentityMapping>> identitiesMap = transformIdentities(snapshot.getModules());
+        Map<String, Map<Optional<Revision>, IdentityMapping>> identitiesMap =
+            transformIdentities(snapshot.getModules());
         return new Config(factories, identitiesMap, snapshot.getEnumResolver());
     }
 
-    private static Map<String, Map<Date, IdentityMapping>> transformIdentities(final Set<Module> modules) {
-        Map<String, Map<Date, IdentityMapping>> mappedIds = new HashMap<>();
+    private static Map<String, Map<Optional<Revision>, IdentityMapping>> transformIdentities(
+            final Set<Module> modules) {
+        Map<String, Map<Optional<Revision>, IdentityMapping>> mappedIds = new HashMap<>();
         for (Module module : modules) {
             String namespace = module.getNamespace().toString();
-            Map<Date, IdentityMapping> revisionsByNamespace = mappedIds.computeIfAbsent(namespace,
+            Map<Optional<Revision>, IdentityMapping> revisionsByNamespace = mappedIds.computeIfAbsent(namespace,
                 k -> new HashMap<>());
 
-            Date revision = module.getRevision();
+            Optional<Revision> revision = Optional.fromJavaUtil(module.getRevision());
 
             IdentityMapping identityMapping = revisionsByNamespace.computeIfAbsent(revision,
                 k -> new IdentityMapping());
index 895bcc5..1d680a9 100644 (file)
@@ -16,6 +16,7 @@ import org.opendaylight.controller.config.util.ConfigRegistryJMXClient;
 import org.opendaylight.controller.config.util.capability.Capability;
 import org.opendaylight.controller.config.util.capability.YangModuleCapability;
 import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
 
 public class ConfigSubsystemFacadeFactory {
 
@@ -47,7 +48,8 @@ public class ConfigSubsystemFacadeFactory {
         Set<Module> modules = yangStoreService.getModules();
         final Set<Capability> capabilities = Sets.newHashSet();
         for (Module module : modules) {
-            capabilities.add(new YangModuleCapability(module, yangStoreService.getModuleSource(module)));
+            capabilities.add(new YangModuleCapability(module, yangStoreService.getModuleSource(
+                RevisionSourceIdentifier.create(module.getName(), module.getRevision()))));
         }
         return capabilities;
     }
index 4fa6796..c99d21d 100644 (file)
@@ -8,9 +8,9 @@
 
 package org.opendaylight.controller.config.facade.xml.mapping.attributes.fromxml;
 
+import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.Maps;
-import java.util.Date;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
@@ -25,15 +25,16 @@ import org.opendaylight.controller.config.yangjmxgenerator.attribute.JavaAttribu
 import org.opendaylight.controller.config.yangjmxgenerator.attribute.ListAttribute;
 import org.opendaylight.controller.config.yangjmxgenerator.attribute.ListDependenciesAttribute;
 import org.opendaylight.controller.config.yangjmxgenerator.attribute.TOAttribute;
+import org.opendaylight.yangtools.yang.common.Revision;
 
 public class ObjectXmlReader extends AttributeIfcSwitchStatement<AttributeReadingStrategy> {
 
     private String key;
-    private Map<String, Map<Date, IdentityMapping>> identityMap;
+    private Map<String, Map<Optional<Revision>, IdentityMapping>> identityMap;
 
     @SuppressWarnings("checkstyle:hiddenField")
     public Map<String, AttributeReadingStrategy> prepareReading(final Map<String, AttributeIfc> yangToAttrConfig,
-            final Map<String, Map<Date, IdentityMapping>> identityMap) {
+            final Map<String, Map<Optional<Revision>, IdentityMapping>> identityMap) {
         Map<String, AttributeReadingStrategy> strategies = Maps.newHashMap();
         this.identityMap = identityMap;
 
index c64731e..679631b 100644 (file)
@@ -8,24 +8,25 @@
 
 package org.opendaylight.controller.config.facade.xml.mapping.attributes.fromxml;
 
+import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.Maps;
 import java.net.URI;
-import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
 import org.opendaylight.controller.config.facade.xml.mapping.IdentityMapping;
 import org.opendaylight.controller.config.util.xml.DocumentedException;
 import org.opendaylight.controller.config.util.xml.XmlElement;
 import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.Revision;
 
 public class SimpleIdentityRefAttributeReadingStrategy extends SimpleAttributeReadingStrategy {
 
     private final String key;
-    private final Map<String, Map<Date, IdentityMapping>> identityMap;
+    private final Map<String, Map<Optional<Revision>, IdentityMapping>> identityMap;
 
     public SimpleIdentityRefAttributeReadingStrategy(final String nullableDefault, final String key,
-            final Map<String, Map<Date, IdentityMapping>> identityMap) {
+            final Map<String, Map<Optional<Revision>, IdentityMapping>> identityMap) {
         super(nullableDefault);
         this.key = key;
         this.identityMap = identityMap;
@@ -49,10 +50,10 @@ public class SimpleIdentityRefAttributeReadingStrategy extends SimpleAttributeRe
             namespace = namespaceOfTextContent.getValue();
         }
 
-        Date revision = null;
-        Map<Date, IdentityMapping> revisions = identityMap.get(namespace);
+        Optional<Revision> revision = null;
+        Map<Optional<Revision>, IdentityMapping> revisions = identityMap.get(namespace);
         if (revisions.keySet().size() > 1) {
-            for (Map.Entry<Date, IdentityMapping> revisionToIdentityEntry : revisions.entrySet()) {
+            for (Map.Entry<Optional<Revision>, IdentityMapping> revisionToIdentityEntry : revisions.entrySet()) {
                 if (revisionToIdentityEntry.getValue().containsIdName(localName)) {
                     Preconditions.checkState(revision == null,
                             "Duplicate identity %s, in namespace %s, "
@@ -64,7 +65,7 @@ public class SimpleIdentityRefAttributeReadingStrategy extends SimpleAttributeRe
         } else {
             revision = revisions.keySet().iterator().next();
         }
-        return QName.create(URI.create(namespace), revision, localName).toString();
+        return QName.create(URI.create(namespace), revision.toJavaUtil(), localName).toString();
     }
 
     @Override
index a79e96a..782d243 100644 (file)
@@ -11,10 +11,9 @@ package org.opendaylight.controller.config.facade.xml.mapping.attributes.mapping
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.Maps;
-import java.util.Date;
 import java.util.Map;
 import javax.management.openmbean.SimpleType;
-import org.opendaylight.controller.config.facade.xml.util.Util;
+import org.opendaylight.yangtools.yang.common.Revision;
 
 public class SimpleAttributeMappingStrategy extends AbstractAttributeMappingStrategy<String, SimpleType<?>> {
 
@@ -43,7 +42,7 @@ public class SimpleAttributeMappingStrategy extends AbstractAttributeMappingStra
 
     static {
         WRITER_PLUGINS.put(DEFAULT_WRITER_PLUGIN, new DefaultWriterPlugin());
-        WRITER_PLUGINS.put(Date.class.getCanonicalName(), new DatePlugin());
+        WRITER_PLUGINS.put(Revision.class.getCanonicalName(), new RevisionPlugin());
     }
 
     /**
@@ -61,12 +60,12 @@ public class SimpleAttributeMappingStrategy extends AbstractAttributeMappingStra
         }
     }
 
-    static class DatePlugin implements WriterPlugin {
+    static class RevisionPlugin implements WriterPlugin {
 
         @Override
         public String writeObject(final Object value) {
-            Preconditions.checkArgument(value instanceof Date, "Attribute must be Date");
-            return Util.writeDate((Date) value);
+            Preconditions.checkArgument(value instanceof Revision, "Attribute must be Date");
+            return ((Revision) value).toString();
         }
     }
 
index 12f48e3..f795252 100644 (file)
@@ -14,12 +14,13 @@ import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.math.BigDecimal;
 import java.math.BigInteger;
-import java.text.ParseException;
+import java.time.format.DateTimeParseException;
 import java.util.Date;
 import java.util.Map;
 import javax.management.openmbean.SimpleType;
 import org.opendaylight.controller.config.facade.xml.util.Util;
 import org.opendaylight.controller.config.util.xml.DocumentedException;
+import org.opendaylight.yangtools.yang.common.Revision;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -138,8 +139,8 @@ final class SimpleAttributeResolvingStrategy extends AbstractAttributeResolvingS
         @Override
         protected Object parseObject(final Class<?> type, final String value) throws DocumentedException {
             try {
-                return Util.readDate(value);
-            } catch (final ParseException e) {
+                return Revision.ofNullable(value).orElse(null);
+            } catch (final DateTimeParseException e) {
                 LOG.trace("Unable parse value {} due to ", value, e);
                 throw new DocumentedException("Unable to parse value " + value + " as date.", e,
                         DocumentedException.ErrorType.APPLICATION, DocumentedException.ErrorTag.OPERATION_FAILED,
index 1b62183..381934a 100644 (file)
@@ -18,7 +18,6 @@ import com.google.common.collect.Maps;
 import com.google.common.collect.Multimap;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.Date;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
@@ -32,6 +31,7 @@ import org.opendaylight.controller.config.util.xml.DocumentedException;
 import org.opendaylight.controller.config.util.xml.XmlElement;
 import org.opendaylight.controller.config.util.xml.XmlMappingConstants;
 import org.opendaylight.controller.config.util.xml.XmlUtil;
+import org.opendaylight.yangtools.yang.common.Revision;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
@@ -41,16 +41,16 @@ public class Config {
         Map<String /* Name of module entry from yang file */,
         ModuleConfig>> moduleConfigs;
 
-    private final Map<String, Map<Date, IdentityMapping>> identityMap;
+    private final Map<String, Map<Optional<Revision>, IdentityMapping>> identityMap;
 
     private final EnumResolver enumResolver;
 
     public Config(final Map<String, Map<String, ModuleConfig>> moduleConfigs, final EnumResolver enumResolver) {
-        this(moduleConfigs, Collections.<String, Map<Date, IdentityMapping>>emptyMap(), enumResolver);
+        this(moduleConfigs, Collections.<String, Map<Optional<Revision>, IdentityMapping>>emptyMap(), enumResolver);
     }
 
     public Config(final Map<String, Map<String, ModuleConfig>> moduleConfigs,
-            final Map<String, Map<Date, IdentityMapping>> identityMap, final EnumResolver enumResolver) {
+            final Map<String, Map<Optional<Revision>, IdentityMapping>> identityMap, final EnumResolver enumResolver) {
         this.moduleConfigs = moduleConfigs;
         this.identityMap = identityMap;
         this.enumResolver = enumResolver;
index ff9a9f6..1bea5c2 100644 (file)
@@ -11,15 +11,11 @@ package org.opendaylight.controller.config.facade.xml.mapping.config;
 import com.google.common.base.Optional;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
-
-import java.util.Date;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
-
 import javax.management.ObjectName;
 import javax.management.openmbean.OpenType;
-
 import org.opendaylight.controller.config.facade.xml.mapping.IdentityMapping;
 import org.opendaylight.controller.config.facade.xml.mapping.attributes.fromxml.AttributeConfigElement;
 import org.opendaylight.controller.config.facade.xml.mapping.attributes.fromxml.AttributeReadingStrategy;
@@ -39,6 +35,7 @@ import org.opendaylight.controller.config.util.xml.XmlMappingConstants;
 import org.opendaylight.controller.config.util.xml.XmlUtil;
 import org.opendaylight.controller.config.yangjmxgenerator.RuntimeBeanEntry;
 import org.opendaylight.controller.config.yangjmxgenerator.attribute.AttributeIfc;
+import org.opendaylight.yangtools.yang.common.Revision;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.w3c.dom.Document;
@@ -142,9 +139,9 @@ public final class InstanceConfig {
     }
 
     public InstanceConfigElementResolved fromXml(XmlElement moduleElement, final ServiceRegistryWrapper services,
-                                                 final String moduleNamespace, final EditStrategyType defaultStrategy,
-                                                 final Map<String, Map<Date, IdentityMapping>> identityMap,
-                                                 final EnumResolver enumResolver)
+            final String moduleNamespace, final EditStrategyType defaultStrategy,
+            final Map<String, Map<Optional<Revision>, IdentityMapping>> identityMap,
+            final EnumResolver enumResolver)
             throws DocumentedException {
         Map<String, AttributeConfigElement> retVal = Maps.newHashMap();
 
index ca01f86..3746c35 100644 (file)
@@ -9,7 +9,6 @@
 package org.opendaylight.controller.config.facade.xml.mapping.config;
 
 import com.google.common.base.Optional;
-import java.util.Date;
 import java.util.Map;
 import javax.management.ObjectName;
 import org.opendaylight.controller.config.api.jmx.ObjectNameUtil;
@@ -20,6 +19,7 @@ import org.opendaylight.controller.config.util.xml.DocumentedException;
 import org.opendaylight.controller.config.util.xml.XmlElement;
 import org.opendaylight.controller.config.util.xml.XmlMappingConstants;
 import org.opendaylight.controller.config.util.xml.XmlUtil;
+import org.opendaylight.yangtools.yang.common.Revision;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
@@ -59,7 +59,7 @@ public class ModuleConfig {
 
     public ModuleElementResolved fromXml(final XmlElement moduleElement, final ServiceRegistryWrapper depTracker,
             final String instanceName, final String moduleNamespace, final EditStrategyType defaultStrategy,
-            final Map<String, Map<Date, IdentityMapping>> identityMap, final EnumResolver enumResolver)
+            final Map<String, Map<Optional<Revision>, IdentityMapping>> identityMap, final EnumResolver enumResolver)
             throws DocumentedException {
 
         InstanceConfigElementResolved ice = instanceConfig.fromXml(moduleElement, depTracker, moduleNamespace,
index 868a5d8..8e97d76 100644 (file)
@@ -12,7 +12,7 @@ import java.util.Set;
 import org.opendaylight.controller.config.yangjmxgenerator.ModuleMXBeanEntry;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.ModuleIdentifier;
+import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
 
 public interface YangStoreContext {
 
@@ -38,7 +38,7 @@ public interface YangStoreContext {
      */
     Set<Module> getModules();
 
-    String getModuleSource(ModuleIdentifier moduleIdentifier);
+    String getModuleSource(SourceIdentifier moduleIdentifier);
 
     EnumResolver getEnumResolver();
 }
index 4eef7ee..02865c2 100644 (file)
@@ -26,8 +26,9 @@ import org.opendaylight.controller.config.yangjmxgenerator.ModuleMXBeanEntry;
 import org.opendaylight.mdsal.binding.generator.util.BindingRuntimeContext;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.ModuleIdentifier;
 import org.opendaylight.yangtools.yang.model.api.SchemaContextProvider;
+import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
+import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
 import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
 import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceProvider;
 
@@ -94,7 +95,7 @@ public class YangStoreService implements YangStoreContext {
     }
 
     @Override
-    public String getModuleSource(final ModuleIdentifier moduleIdentifier) {
+    public String getModuleSource(final SourceIdentifier moduleIdentifier) {
         return this.snap.getModuleSource(moduleIdentifier);
     }
 
@@ -146,6 +147,7 @@ public class YangStoreService implements YangStoreContext {
 
     private static Set<Capability> toCapabilities(final Set<Module> modules, final YangStoreContext current) {
         return ImmutableSet.copyOf(Collections2.transform(modules,
-            input -> new YangModuleCapability(input, current.getModuleSource(input))));
+            input -> new YangModuleCapability(input, current.getModuleSource(
+                RevisionSourceIdentifier.create(input.getName(), input.getRevision())))));
     }
 }
index ce34496..4520545 100644 (file)
@@ -8,13 +8,12 @@
 
 package org.opendaylight.controller.config.facade.xml.osgi;
 
-import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.BiMap;
 import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
 import com.google.common.io.ByteStreams;
-import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.ListenableFuture;
 import java.io.IOException;
 import java.io.InputStream;
 import java.lang.ref.SoftReference;
@@ -25,6 +24,7 @@ import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Objects;
 import java.util.Set;
+import java.util.concurrent.ExecutionException;
 import org.opendaylight.controller.config.yangjmxgenerator.ModuleMXBeanEntry;
 import org.opendaylight.controller.config.yangjmxgenerator.PackageTranslator;
 import org.opendaylight.controller.config.yangjmxgenerator.ServiceInterfaceEntry;
@@ -35,7 +35,7 @@ import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceException;
+import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
 import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
 import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
 import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceProvider;
@@ -151,17 +151,15 @@ public final class YangStoreSnapshot implements YangStoreContext, EnumResolver {
     }
 
     @Override
-    public String getModuleSource(final org.opendaylight.yangtools.yang.model.api.ModuleIdentifier moduleIdentifier) {
-        final CheckedFuture<? extends YangTextSchemaSource, SchemaSourceException> source = this.sourceProvider
-                .getSource(SourceIdentifier.create(moduleIdentifier.getName(),
-                        Optional.fromNullable(QName.formattedRevision(moduleIdentifier.getRevision()))));
-
+    public String getModuleSource(final SourceIdentifier moduleIdentifier) {
+        final ListenableFuture<? extends YangTextSchemaSource> source = this.sourceProvider.getSource(
+            RevisionSourceIdentifier.create(moduleIdentifier.getName(), moduleIdentifier.getRevision()));
         try {
-            final YangTextSchemaSource yangTextSchemaSource = source.checkedGet();
+            final YangTextSchemaSource yangTextSchemaSource = source.get();
             try (InputStream inStream = yangTextSchemaSource.openStream()) {
                 return new String(ByteStreams.toByteArray(inStream), StandardCharsets.UTF_8);
             }
-        } catch (SchemaSourceException | IOException e) {
+        } catch (ExecutionException | InterruptedException | IOException e) {
             LOG.warn("Unable to provide source for {}", moduleIdentifier, e);
             throw new IllegalArgumentException("Unable to provide source for " + moduleIdentifier, e);
         }
index e0c78f8..8c101be 100644 (file)
@@ -8,9 +8,9 @@
 
 package org.opendaylight.controller.config.facade.xml.rpc;
 
+import com.google.common.base.Optional;
 import com.google.common.collect.Maps;
 import java.util.Collections;
-import java.util.Date;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
@@ -27,6 +27,7 @@ import org.opendaylight.controller.config.util.xml.XmlElement;
 import org.opendaylight.controller.config.yangjmxgenerator.RuntimeBeanEntry.Rpc;
 import org.opendaylight.controller.config.yangjmxgenerator.attribute.AttributeIfc;
 import org.opendaylight.controller.config.yangjmxgenerator.attribute.JavaAttribute;
+import org.opendaylight.yangtools.yang.common.Revision;
 
 public final class InstanceRuntimeRpc {
 
@@ -75,7 +76,7 @@ public final class InstanceRuntimeRpc {
 
         // FIXME add identity map to runtime data
         Map<String, AttributeReadingStrategy> strats = new ObjectXmlReader().prepareReading(yangToAttrConfig,
-                Collections.<String, Map<Date, IdentityMapping>>emptyMap());
+                Collections.<String, Map<Optional<Revision>, IdentityMapping>>emptyMap());
 
         for (Entry<String, AttributeReadingStrategy> readStratEntry : strats.entrySet()) {
             List<XmlElement> configNodes = configRootNode.getChildElements(readStratEntry.getKey());
index 18ba37e..d704d63 100644 (file)
@@ -8,25 +8,13 @@
 
 package org.opendaylight.controller.config.facade.xml.util;
 
-import static org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil.getRevisionFormat;
-
 import com.google.common.base.Preconditions;
-import java.text.ParseException;
-import java.util.Date;
 
 public final class Util {
 
     private Util() {
     }
 
-    public static String writeDate(final Date date) {
-        return getRevisionFormat().format(date);
-    }
-
-    public static Date readDate(final String string) throws ParseException {
-        return getRevisionFormat().parse(string);
-    }
-
     public static void checkType(final Object value, final Class<?> clazz) {
         Preconditions.checkArgument(clazz.isAssignableFrom(value.getClass()),
                 "Unexpected type " + value.getClass() + " should be " + clazz + " of " + value);
index bf678ff..60d2118 100644 (file)
@@ -10,40 +10,37 @@ package org.opendaylight.controller.config.facade.xml.mapping.attributes.fromxml
 
 import static org.junit.Assert.assertEquals;
 
+import com.google.common.base.Optional;
 import com.google.common.collect.Maps;
 import java.net.URI;
 import java.util.Collections;
-import java.util.Date;
 import java.util.Map;
 import org.junit.Test;
 import org.opendaylight.controller.config.facade.xml.mapping.IdentityMapping;
 import org.opendaylight.controller.config.util.xml.XmlElement;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.Revision;
 
 public class SimpleIdentityRefAttributeReadingStrategyTest {
 
     @Test
     public void testReadIdRef() throws Exception {
-        final Map<String, Map<Date, IdentityMapping>> identityMapping = Maps.newHashMap();
+        final Map<String, Map<Optional<Revision>, IdentityMapping>> identityMapping = Maps.newHashMap();
         final IdentityMapping value = new IdentityMapping();
-        final Date rev = new Date();
+        final Optional<Revision> rev = Optional.of(Revision.of("2017-10-10"));
         identityMapping.put("namespace", Collections.singletonMap(rev, value));
         identityMapping.put("inner", Collections.singletonMap(rev, value));
         final SimpleIdentityRefAttributeReadingStrategy key = new SimpleIdentityRefAttributeReadingStrategy(null, "key",
                 identityMapping);
 
         String read = key.readElementContent(XmlElement.fromString("<el xmlns=\"namespace\">local</el>"));
-        assertEquals(
-                org.opendaylight.yangtools.yang.common.QName.create(URI.create("namespace"), rev, "local").toString(),
-                read);
+        assertEquals(QName.create(URI.create("namespace"), rev.toJavaUtil(), "local").toString(), read);
 
         read = key.readElementContent(XmlElement.fromString("<el xmlns:a=\"inner\" xmlns=\"namespace\">a:local</el>"));
-        assertEquals(org.opendaylight.yangtools.yang.common.QName.create(URI.create("inner"), rev, "local").toString(),
-                read);
+        assertEquals(QName.create(URI.create("inner"), rev.toJavaUtil(), "local").toString(), read);
 
         read = key.readElementContent(
-                XmlElement.fromString("<top xmlns=\"namespace\"><el>local</el></top>").getOnlyChildElement());
-        assertEquals(
-                org.opendaylight.yangtools.yang.common.QName.create(URI.create("namespace"), rev, "local").toString(),
-                read);
+            XmlElement.fromString("<top xmlns=\"namespace\"><el>local</el></top>").getOnlyChildElement());
+        assertEquals(QName.create(URI.create("namespace"), rev.toJavaUtil(), "local").toString(), read);
     }
 }
index 97042f2..d59232c 100644 (file)
@@ -89,7 +89,7 @@ public class RefreshingSCPModuleInfoRegistry implements ModuleInfoRegistry, Auto
         }
 
         @Override
-        public void close() throws Exception {
+        public void close() {
             this.inner.close();
             // send modify event when a bundle disappears
             updateService();
index bfb606e..28f6ce8 100644 (file)
@@ -19,6 +19,7 @@ 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 com.google.common.base.Throwables;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Sets;
@@ -46,7 +47,7 @@ import org.opendaylight.controller.config.persist.api.Persister;
 import org.opendaylight.controller.config.spi.Module;
 import org.opendaylight.controller.config.util.ConfigRegistryClient;
 import org.opendaylight.controller.config.util.capability.Capability;
-import org.opendaylight.yangtools.yang.model.api.ModuleIdentifier;
+import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
 import org.w3c.dom.Element;
 
 public class ConfigPusherImplTest {
@@ -71,7 +72,7 @@ public class ConfigPusherImplTest {
     @Before
     public void setUp() throws Exception {
         MockitoAnnotations.initMocks(this);
-        doReturn("content").when(yangStoreService).getModuleSource(any(ModuleIdentifier.class));
+        doReturn("content").when(yangStoreService).getModuleSource(any(SourceIdentifier.class));
         doReturn("mocked snapshot").when(mockedConfigSnapshot).toString();
         doReturn("<mocked-snapshot/>").when(mockedConfigSnapshot).getConfigSnapshot();
         doReturn(Collections.<Module>emptySet()).when(yangStoreService).getModules();
index dcf16b3..521a09f 100644 (file)
@@ -9,7 +9,7 @@
 package org.opendaylight.controller.config.util.capability;
 
 import com.google.common.base.Optional;
-import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
+import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.model.api.Module;
 
 /**
@@ -27,7 +27,7 @@ public final class YangModuleCapability extends BasicCapability {
         this.content = moduleContent;
         this.moduleName = module.getName();
         this.moduleNamespace = module.getNamespace().toString();
-        this.revision = SimpleDateFormatUtil.getRevisionFormat().format(module.getRevision());
+        this.revision = module.getRevision().map(Revision::toString).orElse(null);
     }
 
     @Override
@@ -36,8 +36,14 @@ public final class YangModuleCapability extends BasicCapability {
     }
 
     private static String toCapabilityURI(final Module module) {
-        return String.valueOf(module.getNamespace()) + "?module="
-                + module.getName() + "&revision=" + SimpleDateFormatUtil.getRevisionFormat().format(module.getRevision());
+        final StringBuilder sb = new StringBuilder();
+        sb.append(module.getNamespace()).append("?module=").append(module.getName());
+
+        final java.util.Optional<Revision> rev = module.getRevision();
+        if (rev.isPresent()) {
+            sb.append("&revision=").append(rev.get());
+        }
+        return sb.toString();
     }
 
     @Override
index 34480b9..18eb601 100644 (file)
@@ -9,19 +9,20 @@ package org.opendaylight.controller.config.yangjmxgenerator.plugin;
 
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Preconditions;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
 import com.google.common.io.Files;
 import java.io.File;
 import java.io.IOException;
 import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
+import java.util.Optional;
 import java.util.Set;
+import java.util.function.Function;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 import org.apache.maven.project.MavenProject;
@@ -80,15 +81,15 @@ public class JMXGenerator implements BasicCodeGenerator, MavenProjectAware {
     }
 
     @Override
-    public Collection<File> generateSources(final SchemaContext context,
-                                            final File outputBaseDir, final Set<Module> yangModulesInCurrentMavenModule) {
+    public Collection<File> generateSources(final SchemaContext context, final File outputBaseDir,
+            final Set<Module> currentModules, final Function<Module, Optional<String>> moduleResourcePathResolver) {
 
         Preconditions.checkArgument(context != null, "Null context received");
         Preconditions.checkArgument(outputBaseDir != null,
                 "Null outputBaseDir received");
 
         Preconditions
-                .checkArgument((this.namespaceToPackageMapping != null) && !this.namespaceToPackageMapping.isEmpty(),
+                .checkArgument(this.namespaceToPackageMapping != null && !this.namespaceToPackageMapping.isEmpty(),
                         "No namespace to package mapping provided in additionalConfiguration");
 
         final PackageTranslator packageTranslator = new PackageTranslator(this.namespaceToPackageMapping);
@@ -117,7 +118,7 @@ public class JMXGenerator implements BasicCodeGenerator, MavenProjectAware {
                                 + sieEntry.getValue());
                 }
             }
-            if (yangModulesInCurrentMavenModule.contains(module)) {
+            if (currentModules.contains(module)) {
                 // write this sie to disk
                 for (final ServiceInterfaceEntry sie : namesToSIEntries.values()) {
                     try {
@@ -138,7 +139,7 @@ public class JMXGenerator implements BasicCodeGenerator, MavenProjectAware {
 
         final StringBuilder fullyQualifiedNamesOfFactories = new StringBuilder();
         // create MBEs
-        for (final Module module : yangModulesInCurrentMavenModule) {
+        for (final Module module : currentModules) {
             final String packageName = packageTranslator.getPackageName(module);
             final Map<String /* MB identity local name */, ModuleMXBeanEntry> namesToMBEs = ModuleMXBeanEntry
                     .create(module, qNamesToSIEs, context, new TypeProviderWrapper(new TypeProviderImpl(context)),
@@ -162,7 +163,7 @@ public class JMXGenerator implements BasicCodeGenerator, MavenProjectAware {
             }
         }
         // create ModuleFactory file if needed
-        if ((fullyQualifiedNamesOfFactories.length() > 0)
+        if (fullyQualifiedNamesOfFactories.length() > 0
                 && this.generateModuleFactoryFile) {
             final File serviceLoaderFile = JMXGenerator.concatFolders(
                     this.resourceBaseDir, "META-INF", "services",
@@ -171,7 +172,8 @@ public class JMXGenerator implements BasicCodeGenerator, MavenProjectAware {
             serviceLoaderFile.getParentFile().mkdirs();
             try {
                 serviceLoaderFile.createNewFile();
-                Files.write(fullyQualifiedNamesOfFactories.toString(), serviceLoaderFile, StandardCharsets.UTF_8);
+                Files.asCharSink(serviceLoaderFile, StandardCharsets.UTF_8).write(
+                    fullyQualifiedNamesOfFactories.toString());
             } catch (final IOException e) {
                 final String message = "Cannot write to " + serviceLoaderFile;
                 LOG.error(message, e);
@@ -204,7 +206,7 @@ public class JMXGenerator implements BasicCodeGenerator, MavenProjectAware {
 
     private static Map<String, String> extractNamespaceMapping(
             final Map<String, String> additionalCfg) {
-        final Map<String, String> namespaceToPackage = Maps.newHashMap();
+        final Map<String, String> namespaceToPackage = new HashMap<>();
         for (final String key : additionalCfg.keySet()) {
             if (key.startsWith(NAMESPACE_TO_PACKAGE_PREFIX)) {
                 final String mapping = additionalCfg.get(key);
@@ -237,24 +239,21 @@ public class JMXGenerator implements BasicCodeGenerator, MavenProjectAware {
 
     @VisibleForTesting
     static class GeneratedFilesTracker {
-        private final Set<File> files = Sets.newHashSet();
+        private final Set<File> files = new HashSet<>();
 
         void addFile(final File file) {
             if (this.files.contains(file)) {
-                final List<File> undeletedFiles = Lists.newArrayList();
+                final List<File> undeletedFiles = new ArrayList<>();
                 for (final File presentFile : this.files) {
                     if (!presentFile.delete()) {
                         undeletedFiles.add(presentFile);
                     }
                 }
                 if (!undeletedFiles.isEmpty()) {
-                    LOG.error(
-                            "Illegal state occurred: Unable to delete already generated files, undeleted files: {}",
+                    LOG.error("Illegal state occurred: Unable to delete already generated files, undeleted files: {}",
                             undeletedFiles);
                 }
-                throw new IllegalStateException(
-                        "Name conflict in generated files, file" + file
-                                + " present twice");
+                throw new IllegalStateException("Name conflict in generated files, file" + file + " present twice");
             }
             this.files.add(file);
         }
index 8f00f90..541c28a 100644 (file)
@@ -21,12 +21,13 @@ import org.opendaylight.controller.config.api.annotations.ServiceInterfaceAnnota
 import org.opendaylight.controller.config.yangjmxgenerator.ServiceInterfaceEntry;
 import org.opendaylight.yangtools.yang.binding.annotations.ModuleQName;
 import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.Revision;
 
 public class Annotation {
     final String name;
     final List<Parameter> params;
 
-    public Annotation(String name, List<Parameter> params) {
+    public Annotation(final String name, final List<Parameter> params) {
         this.name = name;
         this.params = params;
     }
@@ -39,7 +40,7 @@ public class Annotation {
         return params;
     }
 
-    public static Annotation createFromMap(Class<?> annotationClass, Map<String, String> parameters) {
+    public static Annotation createFromMap(final Class<?> annotationClass, final Map<String, String> parameters) {
         List<Parameter> parameterList = new ArrayList<>();
         for(Entry<String, String> entry: parameters.entrySet()) {
             parameterList.add(new Parameter(entry.getKey(), entry.getValue()));
@@ -47,22 +48,22 @@ public class Annotation {
         return new Annotation(annotationClass.getCanonicalName(), parameterList);
     }
 
-    public static Annotation createDescriptionAnnotation(String description) {
+    public static Annotation createDescriptionAnnotation(final String description) {
         Preconditions.checkNotNull(description,
                 "Cannot create annotation from null description");
         return new Annotation(Description.class.getCanonicalName(),
                 Lists.newArrayList(new Parameter("value", q(description))));
     }
 
-    public static Annotation createModuleQNameANnotation(QName qName) {
+    public static Annotation createModuleQNameANnotation(final QName qName) {
         Map<String, String> parameters = new HashMap<>();
         parameters.put("namespace", q(qName.getNamespace().toString()));
-        parameters.put("revision", q(qName.getFormattedRevision()));
+        parameters.put("revision", q(qName.getRevision().map(Revision::toString).orElse(null)));
         parameters.put("name", q(qName.getLocalName()));
         return Annotation.createFromMap(ModuleQName.class, parameters);
     }
 
-    public static Collection<Annotation> createSieAnnotations(ServiceInterfaceEntry sie){
+    public static Collection<Annotation> createSieAnnotations(final ServiceInterfaceEntry sie){
 
         String exportedClassName = sie.getExportedOsgiClassName();
         Preconditions.checkNotNull(sie.getQName(),
@@ -75,7 +76,7 @@ public class Annotation {
             params.add(new Parameter("osgiRegistrationType", exportedClassName + ".class"));
             params.add(new Parameter("registerToOsgi", Boolean.toString(sie.isRegisterToOsgi())));
             params.add(new Parameter("namespace", q(sie.getQName().getNamespace().toString())));
-            params.add(new Parameter("revision", q(sie.getQName().getFormattedRevision())));
+            params.add(new Parameter("revision", q(sie.getQName().getRevision().map(Revision::toString).orElse(null))));
             params.add(new Parameter("localName", q(sie.getQName().getLocalName())));
 
             Annotation sieAnnotation = new Annotation(ServiceInterfaceAnnotation.class.getCanonicalName(), params);
@@ -85,7 +86,8 @@ public class Annotation {
         {
             List<Parameter> params = new ArrayList<>();
             params.add(new Parameter("namespace", q(sie.getYangModuleQName().getNamespace().toString())));
-            params.add(new Parameter("revision", q(sie.getYangModuleQName().getFormattedRevision())));
+            params.add(new Parameter("revision", q(sie.getYangModuleQName().getRevision()
+                .map(Revision::toString).orElse(null))));
             params.add(new Parameter("name", q(sie.getYangModuleQName().getLocalName())));
 
             Annotation moduleQNameAnnotation = new Annotation(ModuleQName.class.getCanonicalName(), params);
@@ -95,7 +97,7 @@ public class Annotation {
     }
 
     public static Annotation createRequireIfcAnnotation(
-            ServiceInterfaceEntry sie) {
+            final ServiceInterfaceEntry sie) {
         String reqIfc = sie.getFullyQualifiedName() + ".class";
         return new Annotation(RequireInterface.class.getCanonicalName(),
                 Lists.newArrayList(new Parameter("value", reqIfc)));
@@ -103,15 +105,14 @@ public class Annotation {
 
     private static final String quote = "\"";
 
-    public static String q(String nullableDescription) {
-        return nullableDescription == null ? null : quote + nullableDescription
-                + quote;
+    public static String q(final String nullableDescription) {
+        return nullableDescription == null ? null : quote + nullableDescription + quote;
     }
 
     public static class Parameter {
         private final String key, value;
 
-        public Parameter(String key, String value) {
+        public Parameter(final String key, final String value) {
             this.key = key;
             this.value = value;
         }
index 3a820fd..de868d6 100644 (file)
@@ -13,7 +13,8 @@ import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
-import com.google.common.collect.Sets;
+import com.google.common.collect.ImmutableSet;
+import java.util.Optional;
 import org.junit.Test;
 import org.opendaylight.controller.config.yangjmxgenerator.ConfigConstants;
 import org.opendaylight.controller.config.yangjmxgenerator.PackageTranslatorTest;
@@ -35,8 +36,8 @@ public class JMXGeneratorFileNamesValidationTest extends JMXGeneratorTest {
         map.put(JMXGenerator.MODULE_FACTORY_FILE_BOOLEAN, "randomValue");
         jmxGenerator.setAdditionalConfig(map);
         try {
-            jmxGenerator.generateSources(context, outputBaseDir,
-                    Sets.newHashSet(testFilesModule, testFiles1Module));
+            jmxGenerator.generateSources(context, outputBaseDir, ImmutableSet.of(testFilesModule, testFiles1Module),
+                m -> Optional.empty());
             fail();
         } catch (RuntimeException e) {
             final Throwable cause = e.getCause();
index 61647c4..c306a1b 100644 (file)
@@ -17,6 +17,7 @@ import static org.junit.Assert.fail;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 import static org.opendaylight.controller.config.yangjmxgenerator.PackageTranslatorTest.EXPECTED_PACKAGE_PREFIX;
+
 import com.github.javaparser.JavaParser;
 import com.github.javaparser.ParseException;
 import com.github.javaparser.ast.CompilationUnit;
@@ -31,6 +32,7 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
+import java.util.Optional;
 import java.util.Set;
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
@@ -106,8 +108,8 @@ public class JMXGeneratorTest extends AbstractGeneratorTest {
 
     @Test
     public void generateSIsMBsTest() {
-        Collection<File> files = jmxGenerator.generateSources(context,
-                outputBaseDir, context.getModules());
+        Collection<File> files = jmxGenerator.generateSources(context, outputBaseDir, context.getModules(),
+            m -> Optional.empty());
         List<String> expectedFileNames = new ArrayList<>();
         expectedFileNames
                 .addAll(ServiceInterfaceEntryTest.expectedSIEFileNames);
@@ -147,8 +149,8 @@ public class JMXGeneratorTest extends AbstractGeneratorTest {
 
     @Test
     public void generateSIEsTest() throws IOException, ParseException {
-        Collection<File> files = jmxGenerator.generateSources(context,
-                outputBaseDir, Collections.singleton(threadsModule));
+        Collection<File> files = jmxGenerator.generateSources(context, outputBaseDir,
+            Collections.singleton(threadsModule), m -> Optional.empty());
         assertEquals(ServiceInterfaceEntryTest.expectedSIEFileNames, toFileNames(files));
 
         for (File file : files) {
@@ -205,7 +207,7 @@ public class JMXGeneratorTest extends AbstractGeneratorTest {
         jmxGenerator.setAdditionalConfig(map);
 
         Collection<File> files = jmxGenerator.generateSources(context, outputBaseDir,
-            Collections.singleton(bgpListenerJavaModule));
+            Collections.singleton(bgpListenerJavaModule), m -> Optional.empty());
 
         assertEquals(expectedGenerateMBEsListNames, toFileNames(files));
     }
@@ -217,7 +219,7 @@ public class JMXGeneratorTest extends AbstractGeneratorTest {
         jmxGenerator.setAdditionalConfig(map);
 
         Collection<File> files = jmxGenerator.generateSources(context, outputBaseDir,
-            Collections.singleton(threadsJavaModule));
+            Collections.singleton(threadsJavaModule), m -> Optional.empty());
 
         assertEquals(expectedModuleFileNames, toFileNames(files));
 
index 3d50ac3..ebddb4f 100644 (file)
@@ -73,8 +73,8 @@ public class ModuleMXBeanEntry extends AbstractEntry {
     private Collection<RuntimeBeanEntry> runtimeBeans;
     private String nullableDummyContainerName;
 
-    ModuleMXBeanEntry(ModuleMXBeanEntryInitial initials, Map<String, AttributeIfc> yangToAttributes,
-            Map<String, QName> providedServices2, Collection<RuntimeBeanEntry> runtimeBeans) {
+    ModuleMXBeanEntry(final ModuleMXBeanEntryInitial initials, final Map<String, AttributeIfc> yangToAttributes,
+            final Map<String, QName> providedServices2, final Collection<RuntimeBeanEntry> runtimeBeans) {
         this.yangToAttributes = yangToAttributes;
         this.providedServices = Collections.unmodifiableMap(providedServices2);
         this.runtimeBeans = runtimeBeans;
@@ -101,7 +101,7 @@ public class ModuleMXBeanEntry extends AbstractEntry {
         return ABSTRACT_PREFIX + getStubModuleName();
     }
 
-    public String getFullyQualifiedName(String typeName) {
+    public String getFullyQualifiedName(final String typeName) {
         return FullyQualifiedNameHelper.getFullyQualifiedName(initial.packageName,
                 typeName);
     }
@@ -123,7 +123,7 @@ public class ModuleMXBeanEntry extends AbstractEntry {
         return providedServices;
     }
 
-    public void setRuntimeBeans(Collection<RuntimeBeanEntry> newRuntimeBeans) {
+    public void setRuntimeBeans(final Collection<RuntimeBeanEntry> newRuntimeBeans) {
         runtimeBeans = newRuntimeBeans;
     }
 
@@ -147,10 +147,10 @@ public class ModuleMXBeanEntry extends AbstractEntry {
      *         instances as values
      */
     public static Map<String/* identity local name */, ModuleMXBeanEntry> create(
-            Module currentModule,
-            Map<QName, ServiceInterfaceEntry> qNamesToSIEs,
-            SchemaContext schemaContext,
-            TypeProviderWrapper typeProviderWrapper, String packageName) {
+            final Module currentModule,
+            final Map<QName, ServiceInterfaceEntry> qNamesToSIEs,
+            final SchemaContext schemaContext,
+            final TypeProviderWrapper typeProviderWrapper, final String packageName) {
 
         ModuleMXBeanEntryBuilder builder = new ModuleMXBeanEntryBuilder().setModule(currentModule).setqNamesToSIEs(qNamesToSIEs)
                 .setSchemaContext(schemaContext).setTypeProviderWrapper(typeProviderWrapper)
@@ -163,7 +163,7 @@ public class ModuleMXBeanEntry extends AbstractEntry {
         return yangToAttributes;
     }
 
-    void setYangToAttributes(Map<String, AttributeIfc> newAttributes) {
+    void setYangToAttributes(final Map<String, AttributeIfc> newAttributes) {
         this.yangToAttributes = newAttributes;
     }
 
@@ -186,21 +186,21 @@ public class ModuleMXBeanEntry extends AbstractEntry {
         return nullableDummyContainerName;
     }
 
-    public void setNullableDummyContainerName(String nullableDummyContainerName) {
+    public void setNullableDummyContainerName(final String nullableDummyContainerName) {
         this.nullableDummyContainerName = nullableDummyContainerName;
     }
 
 
     static final class ModuleMXBeanEntryInitial {
 
-        private String localName;
-        private String description;
-        private String packageName;
-        private String javaNamePrefix;
-        private String namespace;
-        private QName qName;
+        private final String localName;
+        private final String description;
+        private final String packageName;
+        private final String javaNamePrefix;
+        private final String namespace;
+        private final QName qName;
 
-        ModuleMXBeanEntryInitial(String localName, String description, String packageName, String javaNamePrefix, String namespace, QName qName) {
+        ModuleMXBeanEntryInitial(final String localName, final String description, final String packageName, final String javaNamePrefix, final String namespace, final QName qName) {
             this.localName = localName;
             this.description = description;
             this.packageName = packageName;
@@ -218,22 +218,22 @@ public class ModuleMXBeanEntry extends AbstractEntry {
         private String namespace;
         private QName qName;
 
-        public ModuleMXBeanEntryInitialBuilder setPackageName(String packageName) {
+        public ModuleMXBeanEntryInitialBuilder setPackageName(final String packageName) {
             this.packageName = packageName;
             return this;
         }
 
-        public ModuleMXBeanEntryInitialBuilder setJavaNamePrefix(String javaNamePrefix) {
+        public ModuleMXBeanEntryInitialBuilder setJavaNamePrefix(final String javaNamePrefix) {
             this.javaNamePrefix = javaNamePrefix;
             return this;
         }
 
-        public ModuleMXBeanEntryInitialBuilder setNamespace(String namespace) {
+        public ModuleMXBeanEntryInitialBuilder setNamespace(final String namespace) {
             this.namespace = namespace;
             return this;
         }
 
-        public ModuleMXBeanEntryInitialBuilder setqName(QName qName) {
+        public ModuleMXBeanEntryInitialBuilder setqName(final QName qName) {
             this.qName = qName;
             return this;
         }
@@ -242,9 +242,9 @@ public class ModuleMXBeanEntry extends AbstractEntry {
             return new ModuleMXBeanEntry.ModuleMXBeanEntryInitial(localName, description, packageName, javaNamePrefix, namespace, qName);
         }
 
-        public ModuleMXBeanEntryInitialBuilder setIdSchemaNode(IdentitySchemaNode idSchemaNode) {
+        public ModuleMXBeanEntryInitialBuilder setIdSchemaNode(final IdentitySchemaNode idSchemaNode) {
             this.localName = idSchemaNode.getQName().getLocalName();
-            this.description = idSchemaNode.getDescription();
+            this.description = idSchemaNode.getDescription().orElse(null);
             return this;
         }
 
index 955e9b5..5f8f4e0 100644 (file)
@@ -37,8 +37,8 @@ import org.opendaylight.controller.config.yangjmxgenerator.attribute.TOAttribute
 import org.opendaylight.controller.config.yangjmxgenerator.plugin.util.NameConflictException;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.rev130405.ServiceRef;
 import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
-import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode;
+import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.CaseSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
@@ -131,12 +131,12 @@ final class ModuleMXBeanEntryBuilder {
 
         Map<String, ModuleMXBeanEntry> result = new HashMap<>();
 
-        for (AugmentationSchema augmentation : currentModule.getAugmentations()) {
+        for (AugmentationSchemaNode augmentation : currentModule.getAugmentations()) {
             Collection<DataSchemaNode> childNodes = augmentation.getChildNodes();
-            if (areAllChildrenChoiceCaseNodes(childNodes)) {
-                for (ChoiceCaseNode childCase : castChildNodesToChoiceCases(childNodes)) {
+            if (areAllChildrenCaseSchemaNodes(childNodes)) {
+                for (CaseSchemaNode childCase : castChildNodesToChoiceCases(childNodes)) {
                     // TODO refactor, extract to standalone builder class
-                    processChoiceCaseNode(result, uniqueGeneratedClassesNames, configModulePrefix, moduleIdentities,
+                    processCaseSchemaNode(result, uniqueGeneratedClassesNames, configModulePrefix, moduleIdentities,
                             unaugmentedModuleIdentities, augmentation, childCase);
                 }
             } // skip if child nodes are not all cases
@@ -172,7 +172,8 @@ final class ModuleMXBeanEntryBuilder {
         }
     }
 
-    private static void checkAttributeNamesUniqueness(final Map<String, QName> uniqueGeneratedClassesNames, final Map<String, ModuleMXBeanEntry> result) {
+    private static void checkAttributeNamesUniqueness(final Map<String, QName> uniqueGeneratedClassesNames,
+            final Map<String, ModuleMXBeanEntry> result) {
         for (Map.Entry<String, ModuleMXBeanEntry> entry : result.entrySet()) {
             checkUniqueRuntimeBeanAttributesName(entry.getValue(),
                     uniqueGeneratedClassesNames);
@@ -183,8 +184,8 @@ final class ModuleMXBeanEntryBuilder {
         Map<String, IdentitySchemaNode> moduleIdentities = Maps.newHashMap();
 
         for (IdentitySchemaNode id : currentModule.getIdentities()) {
-            if (id.getBaseIdentity() != null
-                    && ConfigConstants.MODULE_TYPE_Q_NAME.equals(id.getBaseIdentity().getQName())) {
+            if (!id.getBaseIdentities().isEmpty()
+                    && ConfigConstants.MODULE_TYPE_Q_NAME.equals(id.getBaseIdentities().iterator().next().getQName())) {
                 String identityLocalName = id.getQName().getLocalName();
                 if (moduleIdentities.containsKey(identityLocalName)) {
                     throw new IllegalStateException("Module name already defined in this currentModule: "
@@ -217,37 +218,39 @@ final class ModuleMXBeanEntryBuilder {
         return moduleIdentities;
     }
 
-    private static Collection<ChoiceCaseNode> castChildNodesToChoiceCases(final Collection<DataSchemaNode> childNodes) {
-        return Collections2.transform(childNodes, new Function<DataSchemaNode, ChoiceCaseNode>() {
+    private static Collection<CaseSchemaNode> castChildNodesToChoiceCases(final Collection<DataSchemaNode> childNodes) {
+        return Collections2.transform(childNodes, new Function<DataSchemaNode, CaseSchemaNode>() {
             @Nullable
             @Override
-            public ChoiceCaseNode apply(@Nullable final DataSchemaNode input) {
-                return (ChoiceCaseNode) input;
+            public CaseSchemaNode apply(@Nullable final DataSchemaNode input) {
+                return (CaseSchemaNode) input;
             }
         });
     }
 
-    private static boolean areAllChildrenChoiceCaseNodes(final Iterable<DataSchemaNode> childNodes) {
+    private static boolean areAllChildrenCaseSchemaNodes(final Iterable<DataSchemaNode> childNodes) {
         for (DataSchemaNode childNode : childNodes) {
-            if (childNode instanceof ChoiceCaseNode == false) {
+            if (childNode instanceof CaseSchemaNode == false) {
                 return false;
             }
         }
         return true;
     }
 
-    private <HAS_CHILDREN_AND_QNAME extends DataNodeContainer & SchemaNode> void processChoiceCaseNode(final Map<String, ModuleMXBeanEntry> result,
+    private <HAS_CHILDREN_AND_QNAME extends DataNodeContainer & SchemaNode> void processCaseSchemaNode(
+            final Map<String, ModuleMXBeanEntry> result,
             final Map<String, QName> uniqueGeneratedClassesNames, final String configModulePrefix,
             final Map<String, IdentitySchemaNode> moduleIdentities,
-            final Map<String, IdentitySchemaNode> unaugmentedModuleIdentities, final AugmentationSchema augmentation,
-            final DataSchemaNode when) {
+            final Map<String, IdentitySchemaNode> unaugmentedModuleIdentities,
+            final AugmentationSchemaNode augmentation, final DataSchemaNode when) {
 
-        ChoiceCaseNode choiceCaseNode = (ChoiceCaseNode) when;
-        if (choiceCaseNode.getConstraints() == null || choiceCaseNode.getConstraints().getWhenCondition() == null) {
+        CaseSchemaNode choiceCaseNode = (CaseSchemaNode) when;
+        if (!choiceCaseNode.getWhenCondition().isPresent()) {
             return;
         }
-        RevisionAwareXPath xPath = choiceCaseNode.getConstraints().getWhenCondition();
-        Matcher matcher = getWhenConditionMatcher(configModulePrefix, xPath);
+        java.util.Optional<RevisionAwareXPath> xPath = choiceCaseNode.getWhenCondition();
+        checkState(xPath.isPresent(), "Choice node %s does not have a when condition", choiceCaseNode);
+        Matcher matcher = getWhenConditionMatcher(configModulePrefix, xPath.get());
         if (matcher.matches() == false) {
             return;
         }
@@ -384,7 +387,7 @@ final class ModuleMXBeanEntryBuilder {
      * @param choiceCaseNode state or configuration case statement
      * @return either choiceCaseNode or its only child container
      */
-    private static <HAS_CHILDREN_AND_QNAME extends DataNodeContainer & SchemaNode> HAS_CHILDREN_AND_QNAME getDataNodeContainer(final ChoiceCaseNode choiceCaseNode) {
+    private static <HAS_CHILDREN_AND_QNAME extends DataNodeContainer & SchemaNode> HAS_CHILDREN_AND_QNAME getDataNodeContainer(final CaseSchemaNode choiceCaseNode) {
         Collection<DataSchemaNode> childNodes = choiceCaseNode.getChildNodes();
         if (childNodes.size() == 1) {
             DataSchemaNode onlyChild = childNodes.iterator().next();
@@ -479,14 +482,14 @@ final class ModuleMXBeanEntryBuilder {
                             qNamesToSIEs, schemaContext);
                     LeafSchemaNode refine = (LeafSchemaNode) usesNode.getRefines().values().iterator().next();
 
-                    boolean mandatory = refine.getConstraints().isMandatory();
+                    boolean mandatory = refine.isMandatory();
                     AbstractDependencyAttribute reference;
                     if (dataNodeContainer instanceof ContainerSchemaNode) {
                         reference = new DependencyAttribute(attrNode, serviceInterfaceEntry, mandatory,
-                                attrNode.getDescription());
+                                attrNode.getDescription().orElse(null));
                     } else {
                         reference = new ListDependenciesAttribute(attrNode, serviceInterfaceEntry, mandatory,
-                                attrNode.getDescription());
+                                attrNode.getDescription().orElse(null));
                     }
                     return Optional.of(reference);
                 }
@@ -528,7 +531,7 @@ final class ModuleMXBeanEntryBuilder {
             // Module from SchemaContext
             String prefix = m.group(1);
             ModuleImport moduleImport = findModuleImport(currentModule, prefix);
-            foundModule = schemaContext.findModuleByName(moduleImport.getModuleName(), moduleImport.getRevision());
+            foundModule = schemaContext.findModule(moduleImport.getModuleName(), moduleImport.getRevision()).orElse(null);
             checkNotNull(foundModule, format("Module not found in SchemaContext by %s", moduleImport));
             localSIName = m.group(2);
         } else {
index 4cd0feb..d7a8065 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.controller.config.yangjmxgenerator;
 import static com.google.common.base.Preconditions.checkNotNull;
 import static java.lang.String.format;
 import static org.opendaylight.controller.config.yangjmxgenerator.ConfigConstants.SERVICE_TYPE_Q_NAME;
+
 import com.google.common.base.Optional;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -56,12 +57,12 @@ public class ServiceInterfaceEntry extends AbstractEntry {
     private final QName yangModuleQName;
     private final boolean registerToOsgi;
 
-    private ServiceInterfaceEntry(IdentitySchemaNode id, String packageName, QName yangModuleQName) {
+    private ServiceInterfaceEntry(final IdentitySchemaNode id, final String packageName, final QName yangModuleQName) {
         this(Optional.<ServiceInterfaceEntry> absent(), id, packageName, yangModuleQName);
     }
 
-    private ServiceInterfaceEntry(Optional<ServiceInterfaceEntry> base,
-            IdentitySchemaNode id, String packageName, QName yangModuleQName) {
+    private ServiceInterfaceEntry(final Optional<ServiceInterfaceEntry> base,
+            final IdentitySchemaNode id, final String packageName, final QName yangModuleQName) {
         checkNotNull(base);
         this.maybeBaseCache = base;
         List<UnknownSchemaNode> unknownSchemaNodes = id.getUnknownSchemaNodes();
@@ -93,13 +94,13 @@ public class ServiceInterfaceEntry extends AbstractEntry {
         this.registerToOsgi = !disableOsgiServiceRegistration;
         this.exportedOsgiClassName = exportedOsgiClassNames.get(0);
         qName = id.getQName();
-        nullableDescription = id.getDescription();
+        nullableDescription = id.getDescription().orElse(null);
         typeName = getSimpleName(exportedOsgiClassName) + CLASS_NAME_SUFFIX;
         this.packageName = packageName;
         this.yangModuleQName = yangModuleQName;
     }
 
-    private static final String getSimpleName(String fullyQualifiedName) {
+    private static final String getSimpleName(final String fullyQualifiedName) {
         int lastDotPosition = fullyQualifiedName.lastIndexOf(".");
         return fullyQualifiedName.substring(lastDotPosition + 1);
     }
@@ -128,8 +129,8 @@ public class ServiceInterfaceEntry extends AbstractEntry {
      * @return Map of QNames as keys and ServiceInterfaceEntry instances as
      *         values
      */
-    public static Map<QName, ServiceInterfaceEntry> create(Module currentModule,
-            String packageName,Map<IdentitySchemaNode, ServiceInterfaceEntry> definedSEItracker) {
+    public static Map<QName, ServiceInterfaceEntry> create(final Module currentModule,
+            final String packageName,final Map<IdentitySchemaNode, ServiceInterfaceEntry> definedSEItracker) {
         LOG.debug("Generating ServiceInterfaces from {} to package {}",
                 currentModule.getNamespace(), packageName);
 
@@ -149,17 +150,17 @@ public class ServiceInterfaceEntry extends AbstractEntry {
                     .hasNext();) {
                 IdentitySchemaNode identity = iterator.next();
                 ServiceInterfaceEntry created = null;
-                if (identity.getBaseIdentity() == null) {
+                if (identity.getBaseIdentities().isEmpty()) {
                     // this can happen while loading config module, just skip
                     // the identity
                     continue;
-                } else if (identity.getBaseIdentity().getQName()
+                } else if (identity.getBaseIdentities().iterator().next().getQName()
                         .equals(SERVICE_TYPE_Q_NAME)) {
                     // this is a base type
                     created = new ServiceInterfaceEntry(identity, packageName, ModuleUtil.getQName(currentModule));
                 } else {
                     ServiceInterfaceEntry foundBase = definedSEItracker
-                            .get(identity.getBaseIdentity());
+                            .get(identity.getBaseIdentities().iterator().next());
                     // derived type, did we convert the parent?
                     if (foundBase != null) {
                         created = new ServiceInterfaceEntry(
@@ -206,7 +207,7 @@ public class ServiceInterfaceEntry extends AbstractEntry {
     }
 
     @Override
-    public boolean equals(Object o) {
+    public boolean equals(final Object o) {
         if (this == o) {
             return true;
         }
index 099d8ed..f1c23cb 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.controller.config.yangjmxgenerator.attribute;
 import com.google.common.base.Preconditions;
 import java.util.Arrays;
 import java.util.List;
+import java.util.Optional;
 import javax.management.openmbean.ArrayType;
 import javax.management.openmbean.CompositeType;
 import javax.management.openmbean.OpenDataException;
@@ -42,9 +43,17 @@ public class JavaAttribute extends AbstractAttribute implements TypedAttribute {
 
         this.typeDefinition = CompatUtils.compatLeafType(leaf);
         this.typeProviderWrapper = typeProviderWrapper;
-        this.nullableDefault = leaf.getDefault();
-        this.nullableDefaultWrappedForCode = leaf.getDefault() == null ? null : typeProviderWrapper.getDefault(leaf);
-        this.nullableDescription = leaf.getDescription();
+
+        final Optional<? extends Object> typeDefault = leaf.getType().getDefaultValue();
+        if (typeDefault.isPresent()) {
+            nullableDefault = (String) typeDefault.get();
+            nullableDefaultWrappedForCode = typeProviderWrapper.getDefault(leaf);
+        } else {
+            nullableDefault = null;
+            nullableDefaultWrappedForCode = null;
+        }
+
+        this.nullableDescription = leaf.getDescription().orElse(null);
     }
 
     public JavaAttribute(final LeafListSchemaNode leaf,
@@ -54,7 +63,7 @@ public class JavaAttribute extends AbstractAttribute implements TypedAttribute {
         this.typeDefinition = leaf.getType();
         this.typeProviderWrapper = typeProviderWrapper;
         this.nullableDefault = this.nullableDefaultWrappedForCode = null;
-        this.nullableDescription = leaf.getDescription();
+        this.nullableDescription = leaf.getDescription().orElse(null);
     }
 
     public boolean isUnion() {
@@ -105,7 +114,7 @@ public class JavaAttribute extends AbstractAttribute implements TypedAttribute {
         if (this == o) {
             return true;
         }
-        if ((o == null) || (getClass() != o.getClass())) {
+        if (o == null || getClass() != o.getClass()) {
             return false;
         }
         if (!super.equals(o)) {
@@ -133,12 +142,12 @@ public class JavaAttribute extends AbstractAttribute implements TypedAttribute {
     @Override
     public int hashCode() {
         int result = super.hashCode();
-        result = (31 * result) + (this.type != null ? this.type.hashCode() : 0);
-        result = (31
-                * result)
+        result = 31 * result + (this.type != null ? this.type.hashCode() : 0);
+        result = 31
+                * result
                 + (this.nullableDescription != null ? this.nullableDescription.hashCode()
                         : 0);
-        result = (31 * result)
+        result = 31 * result
                 + (this.nullableDefault != null ? this.nullableDefault.hashCode() : 0);
         return result;
     }
index f53beac..10971e7 100644 (file)
@@ -28,7 +28,7 @@ public class ListAttribute extends AbstractAttribute implements TypedAttribute {
 
         final TOAttribute innerAttribute = TOAttribute.create(node, typeProvider, packageName);
 
-        return new ListAttribute(node, innerAttribute, node.getDescription());
+        return new ListAttribute(node, innerAttribute, node.getDescription().orElse(null));
     }
 
     public static ListAttribute create(final LeafListSchemaNode node,
@@ -36,7 +36,7 @@ public class ListAttribute extends AbstractAttribute implements TypedAttribute {
 
         final JavaAttribute innerAttribute = new JavaAttribute(node, typeProvider);
 
-        return new ListAttribute(node, innerAttribute, node.getDescription());
+        return new ListAttribute(node, innerAttribute, node.getDescription().orElse(null));
     }
 
     ListAttribute(final DataSchemaNode attrNode, final TypedAttribute innerAttribute,
@@ -70,11 +70,11 @@ public class ListAttribute extends AbstractAttribute implements TypedAttribute {
     @Override
     public int hashCode() {
         int result = super.hashCode();
-        result = (31
-                * result)
+        result = 31
+                * result
                 + (this.nullableDescription != null ? this.nullableDescription.hashCode()
                         : 0);
-        result = (31 * result)
+        result = 31 * result
                 + (this.nullableDefault != null ? this.nullableDefault.hashCode() : 0);
         return result;
     }
@@ -84,7 +84,7 @@ public class ListAttribute extends AbstractAttribute implements TypedAttribute {
         if (this == o) {
             return true;
         }
-        if ((o == null) || (getClass() != o.getClass())) {
+        if (o == null || getClass() != o.getClass()) {
             return false;
         }
         if (!super.equals(o)) {
index 5b73858..2fa4379 100644 (file)
@@ -52,19 +52,16 @@ public class TOAttribute extends AbstractAttribute implements TypedAttribute {
         // Transfer Object: get the leaves
         final Map<String, AttributeIfc> map = new HashMap<>();
         final Map<String, String> attributeNameMap = new HashMap<>();
-        for (final DataSchemaNode dataSchemaNode : containerSchemaNode
-                .getChildNodes()) {
+        for (final DataSchemaNode dataSchemaNode : containerSchemaNode.getChildNodes()) {
             try {
                 final String yangName = dataSchemaNode.getQName().getLocalName();
-                map.put(yangName,
-                        createInnerAttribute(dataSchemaNode,
-                                typeProviderWrapper, packageName));
+                map.put(yangName, createInnerAttribute(dataSchemaNode, typeProviderWrapper, packageName));
             } catch (final IllegalArgumentException e) {
                 throw new IllegalStateException("Unable to create TO", e);
             }
         }
         return new TOAttribute(containerSchemaNode, map, attributeNameMap,
-                containerSchemaNode.getDescription(), packageName);
+                containerSchemaNode.getDescription().orElse(null), packageName);
     }
 
     private static AttributeIfc createInnerAttribute(
@@ -73,17 +70,13 @@ public class TOAttribute extends AbstractAttribute implements TypedAttribute {
         final Class<? extends DataSchemaNode> type = isAllowedType(dataSchemaNode);
 
         if (type.equals(LeafSchemaNode.class)) {
-            return new JavaAttribute((LeafSchemaNode) dataSchemaNode,
-                    typeProviderWrapper);
+            return new JavaAttribute((LeafSchemaNode) dataSchemaNode, typeProviderWrapper);
         } else if (type.equals(ListSchemaNode.class)) {
-            return ListAttribute.create((ListSchemaNode) dataSchemaNode,
-                    typeProviderWrapper, packageName);
+            return ListAttribute.create((ListSchemaNode) dataSchemaNode, typeProviderWrapper, packageName);
         } else if (type.equals(LeafListSchemaNode.class)) {
-            return ListAttribute.create((LeafListSchemaNode) dataSchemaNode,
-                    typeProviderWrapper);
+            return ListAttribute.create((LeafListSchemaNode) dataSchemaNode, typeProviderWrapper);
         } else if (type.equals(ContainerSchemaNode.class)) {
-            return TOAttribute.create((ContainerSchemaNode) dataSchemaNode,
-                    typeProviderWrapper, packageName);
+            return TOAttribute.create((ContainerSchemaNode) dataSchemaNode, typeProviderWrapper, packageName);
         }
 
         throw new IllegalStateException("This should never happen");
@@ -92,7 +85,7 @@ public class TOAttribute extends AbstractAttribute implements TypedAttribute {
     private static Class<? extends DataSchemaNode> isAllowedType(
             final DataSchemaNode dataSchemaNode) {
         for (final Class<? extends DataSchemaNode> allowedType : ALLOWED_CHILDREN) {
-            if (allowedType.isAssignableFrom(dataSchemaNode.getClass()) == true) {
+            if (allowedType.isAssignableFrom(dataSchemaNode.getClass())) {
                 return allowedType;
             }
         }
@@ -160,7 +153,7 @@ public class TOAttribute extends AbstractAttribute implements TypedAttribute {
         if (this == o) {
             return true;
         }
-        if ((o == null) || (getClass() != o.getClass())) {
+        if (o == null || getClass() != o.getClass()) {
             return false;
         }
         if (!super.equals(o)) {
@@ -190,14 +183,14 @@ public class TOAttribute extends AbstractAttribute implements TypedAttribute {
     @Override
     public int hashCode() {
         int result = super.hashCode();
-        result = (31
-                * result)
+        result = 31
+                * result
                 + (this.nullableDescription != null ? this.nullableDescription.hashCode()
                         : 0);
-        result = (31 * result)
+        result = 31 * result
                 + (this.nullableDefault != null ? this.nullableDefault.hashCode() : 0);
-        result = (31
-                * result)
+        result = 31
+                * result
                 + (this.yangNameToAttributeMap != null ? this.yangNameToAttributeMap
                         .hashCode() : 0);
         return result;
index 9a23221..c0e2668 100644 (file)
@@ -10,7 +10,9 @@ package org.opendaylight.controller.config.yangjmxgenerator;
 import static org.hamcrest.CoreMatchers.is;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertThat;
+
 import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Sets;
 import java.io.InputStream;
 import java.util.ArrayList;
@@ -46,20 +48,20 @@ public abstract class AbstractYangTest {
 
     @Before
     public void loadYangFiles() throws Exception {
-        final List<InputStream> yangISs = new ArrayList<>();
-        yangISs.addAll(getStreams("/test-config-threads.yang",
-                "/test-config-threads-java.yang",
-                "/config-bgp-listener-impl.yang", "/ietf-inet-types.yang",
-                "/config-jmx-it.yang", "/config-jmx-it-impl.yang",
-                "/test-config-files.yang", "/test-config-files1.yang"));
+        final List<String> yangResources = new ArrayList<>();
+        yangResources.add("/test-config-threads.yang");
+        yangResources.add("/test-config-threads-java.yang");
+        yangResources.add("/config-bgp-listener-impl.yang");
+        yangResources.add("/ietf-inet-types.yang");
+        yangResources.add("/config-jmx-it.yang");
+        yangResources.add("/config-jmx-it-impl.yang");
+        yangResources.add("/test-config-files.yang");
+        yangResources.add("/test-config-files1.yang");
 
-        yangISs.addAll(getConfigApiYangInputStreams());
+        yangResources.addAll(getConfigApiYangs());
+
+        this.context = YangParserTestUtils.parseYangResources(AbstractYangTest.class, yangResources);
 
-        this.context = YangParserTestUtils.parseYangStreams(yangISs);
-        // close ISs
-        for (final InputStream is : yangISs) {
-            is.close();
-        }
         this.namesToModules = YangModelSearchUtils.mapModulesByNames(this.context
                 .getModules());
         this.configModule = this.namesToModules.get(ConfigConstants.CONFIG_MODULE);
@@ -74,11 +76,10 @@ public abstract class AbstractYangTest {
         this.jmxImplModule = this.namesToModules.get("config-jmx-it-impl");
         this.testFilesModule = this.namesToModules.get("test-config-files");
         this.testFiles1Module = this.namesToModules.get("test-config-files1");
-
     }
 
-    public static List<InputStream> getConfigApiYangInputStreams() {
-        return getStreams("/META-INF/yang/config@2013-04-05.yang", "/META-INF/yang/rpc-context@2013-06-17.yang");
+    public static List<String> getConfigApiYangs() {
+        return ImmutableList.of("/META-INF/yang/config@2013-04-05.yang", "/META-INF/yang/rpc-context@2013-06-17.yang");
     }
 
     public Map<QName, IdentitySchemaNode> mapIdentitiesByQNames(final Module module) {
index 3eec98e..54a980a 100644 (file)
@@ -9,19 +9,20 @@ package org.opendaylight.controller.config.yangjmxgenerator;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
+
 import com.google.common.base.Preconditions;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStream;
+import com.google.common.collect.ImmutableList;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import org.junit.Before;
 import org.junit.Ignore;
 import org.junit.Test;
 import org.opendaylight.controller.config.yangjmxgenerator.plugin.util.NameConflictException;
 import org.opendaylight.controller.config.yangjmxgenerator.plugin.util.YangModelSearchUtils;
 import org.opendaylight.mdsal.binding.yang.types.TypeProviderImpl;
+import org.opendaylight.yangtools.yang.common.YangConstants;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 import org.slf4j.Logger;
@@ -29,106 +30,67 @@ import org.slf4j.LoggerFactory;
 
 public class ModuleMXBeanEntryNameConflictTest extends AbstractYangTest {
 
-    private static final Logger LOG = LoggerFactory
-            .getLogger(ModuleMXBeanEntryNameConflictTest.class);
+    private static final Logger LOG = LoggerFactory.getLogger(ModuleMXBeanEntryNameConflictTest.class);
 
     public static final String PACKAGE_NAME = "pack2";
-    Map<File, String> testedFilesToYangModules = new HashMap<>();
-    Map<String, String> testedYangModulesToExpectedConflictingName = new HashMap<>();
-
-    @Ignore
-    @Test
-    public void testNameConflicts() throws Exception {
-        prepareSamples();
-        prepareExceptionAssertions();
-
-        for (final Map.Entry<File, String> currentTestEntry : this.testedFilesToYangModules
-                .entrySet()) {
-            final String moduleName = currentTestEntry.getValue();
-            final File yangFile = currentTestEntry.getKey();
-            final Module testedModule = loadYangs(yangFile, moduleName);
-
-            try {
-                LOG.debug("Testing {}", yangFile);
-                ModuleMXBeanEntry.create(testedModule,
-                        new HashMap<>(), this.context,
-                        new TypeProviderWrapper(new TypeProviderImpl(this.context)),
-                        PACKAGE_NAME);
-                fail(yangFile.toString()
-                        + " did not cause a name conflict and should");
-            } catch (final NameConflictException e) {
-                assertEquals(
-                        this.testedYangModulesToExpectedConflictingName
-                                .get(moduleName),
-                        e.getConflictingName());
-            }
-        }
-    }
-
-    private void prepareSamples() {
-        final File first = new File(getClass().getResource(
-                "/duplicates/config-test-duplicate-attribute-in-list.yang")
-                .getFile());
-        final File dir = first.getParentFile();
-
-        for (final File testYang : dir.listFiles()) {
-            final String moduleName = getYangModuleName(testYang.getName());
-            this.testedFilesToYangModules.put(testYang, moduleName);
-        }
-    }
 
-    private void prepareExceptionAssertions() {
-        this.testedYangModulesToExpectedConflictingName.put(
-                "config-test-duplicate-attribute", "DtoA");
-        this.testedYangModulesToExpectedConflictingName.put(
-                "config-test-duplicate-attribute-in-list", "DtoA");
-        this.testedYangModulesToExpectedConflictingName.put(
-                "config-test-duplicate-attribute-runtime-bean", "DtoA");
-        this.testedYangModulesToExpectedConflictingName.put(
-                "config-test-generated-attributes-name-conflict", "StateB");
-        this.testedYangModulesToExpectedConflictingName.put(
-                "config-test-runtime-bean-list-name-conflict",
+    private final List<String> testedModules = ImmutableList.of(
+        "config-test-duplicate-attribute-in-list",
+        "config-test-duplicate-attribute-in-runtime-and-mxbean",
+        "config-test-duplicate-attribute-runtime-bean",
+        "config-test-duplicate-attribute",
+        "config-test-generated-attributes-name-conflict",
+        "config-test-runtime-bean-list-name-conflict2",
+        "config-test-runtime-bean-list-name-conflict",
+        "config-test-runtime-bean-name-conflict2",
+        "config-test-runtime-bean-name-conflict");
+    private final Map<String, String> testedYangModulesToExpectedConflictingName = new HashMap<>();
+
+    @Before
+    public void setup() {
+        testedYangModulesToExpectedConflictingName.put("config-test-duplicate-attribute", "DtoA");
+        testedYangModulesToExpectedConflictingName.put("config-test-duplicate-attribute-in-list", "DtoA");
+        testedYangModulesToExpectedConflictingName.put("config-test-duplicate-attribute-runtime-bean", "DtoA");
+        testedYangModulesToExpectedConflictingName.put("config-test-generated-attributes-name-conflict", "StateB");
+        testedYangModulesToExpectedConflictingName.put("config-test-runtime-bean-list-name-conflict",
                 "StateARuntimeMXBean");
-        this.testedYangModulesToExpectedConflictingName.put(
-                "config-test-runtime-bean-list-name-conflict2",
+        testedYangModulesToExpectedConflictingName.put("config-test-runtime-bean-list-name-conflict2",
                 "StateARuntimeMXBean");
-        this.testedYangModulesToExpectedConflictingName
-                .put("config-test-runtime-bean-name-conflict", "StateARuntimeMXBean");
-        this.testedYangModulesToExpectedConflictingName.put(
-                "config-test-runtime-bean-name-conflict2",
+        testedYangModulesToExpectedConflictingName.put("config-test-runtime-bean-name-conflict",
                 "StateARuntimeMXBean");
-        this.testedYangModulesToExpectedConflictingName.put(
-                "config-test-duplicate-attribute-in-runtime-and-mxbean",
-                "port");
-    }
-
-    private static String getYangModuleName(final String name) {
-        final int startIndex = 0;
-        final int endIndex = name.indexOf(".yang");
-        return name.substring(startIndex, endIndex);
+        testedYangModulesToExpectedConflictingName.put("config-test-runtime-bean-name-conflict2",
+                "StateARuntimeMXBean");
+        testedYangModulesToExpectedConflictingName.put("config-test-duplicate-attribute-in-runtime-and-mxbean", "port");
     }
 
-    private Module loadYangs(final File testedModule, final String moduleName)
-            throws Exception {
-        final List<InputStream> yangISs = new ArrayList<>();
-        yangISs.addAll(getStreams("/ietf-inet-types.yang"));
-
-        yangISs.add(new FileInputStream(testedModule));
+    private Module loadYangs(final String testedModule, final String moduleName) {
+        final List<String> yangs = new ArrayList<>();
+        yangs.add("/ietf-inet-types.yang");
+        yangs.add("/duplicates/" + testedModule + YangConstants.RFC6020_YANG_FILE_EXTENSION);
+        yangs.addAll(getConfigApiYangs());
 
-        yangISs.addAll(getConfigApiYangInputStreams());
-
-        this.context =  YangParserTestUtils.parseYangStreams(yangISs);
-        // close ISs
-        for (final InputStream is : yangISs) {
-            is.close();
-        }
-        this.namesToModules = YangModelSearchUtils.mapModulesByNames(this.context
-                .getModules());
+        this.context =  YangParserTestUtils.parseYangResources(ModuleMXBeanEntryNameConflictTest.class, yangs);
+        this.namesToModules = YangModelSearchUtils.mapModulesByNames(this.context.getModules());
         this.configModule = this.namesToModules.get(ConfigConstants.CONFIG_MODULE);
         final Module module = this.namesToModules.get(moduleName);
-        Preconditions.checkNotNull(module, "Cannot get module %s from %s",
-                moduleName, this.namesToModules.keySet());
+        Preconditions.checkNotNull(module, "Cannot get module %s from %s", moduleName, this.namesToModules.keySet());
         return module;
     }
 
+    @Ignore
+    @Test
+    public void testNameConflicts() {
+        for (final String moduleName : testedModules) {
+            final Module testedModule = loadYangs(moduleName, moduleName);
+
+            try {
+                LOG.debug("Testing {}", moduleName);
+                ModuleMXBeanEntry.create(testedModule, new HashMap<>(), this.context,
+                        new TypeProviderWrapper(new TypeProviderImpl(this.context)), PACKAGE_NAME);
+                fail(moduleName + " did not cause a name conflict and should");
+            } catch (final NameConflictException e) {
+                assertEquals(this.testedYangModulesToExpectedConflictingName.get(moduleName), e.getConflictingName());
+            }
+        }
+    }
 }
index fbd7fb5..d7fb213 100644 (file)
@@ -21,11 +21,8 @@ import static org.mockito.Mockito.mock;
 import com.google.common.collect.Sets;
 import java.net.URI;
 import java.net.URISyntaxException;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.Date;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
@@ -47,6 +44,7 @@ import org.opendaylight.mdsal.binding.model.api.Type;
 import org.opendaylight.mdsal.binding.model.util.Types;
 import org.opendaylight.mdsal.binding.yang.types.TypeProviderImpl;
 import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
 import org.opendaylight.yangtools.yang.model.api.RevisionAwareXPath;
@@ -56,20 +54,13 @@ public class ModuleMXBeanEntryTest extends AbstractYangTest {
     public static final String PACKAGE_NAME = "pack2";
 
     protected static final URI THREADS_NAMESPACE;
-    protected static final Date THREADS_REVISION_DATE;
+    protected static final Revision THREADS_REVISION_DATE = Revision.of("2013-04-09");
 
     static {
         try {
-            THREADS_NAMESPACE = new URI(ConfigConstants.CONFIG_NAMESPACE
-                    + ":threads");
+            THREADS_NAMESPACE = new URI(ConfigConstants.CONFIG_NAMESPACE + ":threads");
         } catch (final URISyntaxException e) {
-            throw new Error(e);
-        }
-        final SimpleDateFormat revisionFormat = new SimpleDateFormat("yyyy-MM-dd");
-        try {
-            THREADS_REVISION_DATE = revisionFormat.parse("2013-04-09");
-        } catch (final ParseException e) {
-            throw new Error(e);
+            throw new ExceptionInInitializerError(e);
         }
     }
 
index 629b154..bdacef8 100644 (file)
@@ -25,7 +25,7 @@ import org.mockito.Mockito;
 import org.opendaylight.controller.config.yangjmxgenerator.attribute.JavaAttribute;
 import org.opendaylight.mdsal.binding.yang.types.TypeProviderImpl;
 import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode;
+import org.opendaylight.yangtools.yang.model.api.CaseSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
@@ -45,7 +45,7 @@ public class RuntimeBeanEntryTest extends AbstractYangTest {
 
     @Test
     public void createRuntimeBean() {
-        final ChoiceCaseNode caseNode = Mockito.mock(ChoiceCaseNode.class);
+        final CaseSchemaNode caseNode = Mockito.mock(CaseSchemaNode.class);
         doReturn(new HashSet<LeafSchemaNode>()).when(caseNode).getChildNodes();
         doReturn(new ArrayList<UnknownSchemaNode>()).when(caseNode)
                 .getUnknownSchemaNodes();
index b3b0615..8228eb6 100644 (file)
@@ -10,17 +10,17 @@ package org.opendaylight.controller.config.yangjmxgenerator;
 import static org.apache.commons.lang3.StringUtils.capitalize;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
+
 import com.google.common.base.Optional;
 import java.net.URI;
 import java.util.Collections;
 import java.util.List;
 import org.junit.Test;
-import org.opendaylight.controller.config.yangjmxgenerator.RuntimeBeanEntry.Rpc;
-import org.opendaylight.controller.config.yangjmxgenerator.attribute.AttributeIfc;
 import org.opendaylight.mdsal.binding.model.api.Type;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.type.StringTypeDefinition;
 
 public class RuntimeRegistratorTest {
     // TODO add more tests
@@ -29,9 +29,8 @@ public class RuntimeRegistratorTest {
         final DataNodeContainer nodeContainer = mock(DataNodeContainer.class);
         doReturn("DataSchemaNode").when(nodeContainer).toString();
         return new RuntimeBeanEntry("pa.cka.ge", nodeContainer,
-                "module-name", "ModuleName", true, Optional.<String> absent(),
-                Collections.<AttributeIfc> emptyList(), children,
-                Collections.<Rpc> emptySet());
+                "module-name", "ModuleName", true, Optional.absent(),
+                Collections.emptyList(), children, Collections.emptySet());
     }
 
     protected RuntimeBeanEntry prepareChildRB(final List<RuntimeBeanEntry> children,
@@ -40,25 +39,24 @@ public class RuntimeRegistratorTest {
         doReturn("DataSchemaNode").when(nodeContainer).toString();
         return new RuntimeBeanEntry("pa.cka.ge", nodeContainer,
                 prefix + "child-name", capitalize(prefix) + "ChildName", false,
-                Optional.<String> absent(),
-                Collections.<AttributeIfc> emptyList(), children,
-                Collections.<Rpc> emptySet());
+                Optional.absent(), Collections.emptyList(), children, Collections.emptySet());
     }
 
     @Test
     public void testHierarchy() {
         final LeafSchemaNode leaf = mock(LeafSchemaNode.class);
-        doReturn(new QName(URI.create("urn:x"), "leaf-local-name")).when(leaf)
-                .getQName();
+        doReturn(QName.create(URI.create("urn:x"), "leaf-local-name")).when(leaf).getQName();
         doReturn(Collections.emptyList()).when(leaf).getUnknownSchemaNodes();
-        doReturn(null).when(leaf).getDefault();
-        doReturn(null).when(leaf).getDescription();
+        doReturn(java.util.Optional.empty()).when(leaf).getDescription();
+
+        final StringTypeDefinition leafType = mock(StringTypeDefinition.class);
+        doReturn(java.util.Optional.empty()).when(leafType).getDefaultValue();
+        doReturn(leafType).when(leaf).getType();
 
         final TypeProviderWrapper typeProviderWrapper = mock(TypeProviderWrapper.class);
         final Type mockedType = mock(Type.class);
         doReturn(mockedType).when(typeProviderWrapper).getType(leaf);
         doReturn("java.lang.String").when(mockedType).getFullyQualifiedName();
-
     }
 
 }
index b189db4..4ed0bc8 100644 (file)
@@ -29,7 +29,7 @@ import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
 
 public class SchemaContextTest extends AbstractYangTest {
 
-    IdentitySchemaNode findIdentityByQName(Module module, QName qName) {
+    IdentitySchemaNode findIdentityByQName(final Module module, final QName qName) {
         Map<QName, IdentitySchemaNode> mapIdentitiesByQNames = mapIdentitiesByQNames(module);
         IdentitySchemaNode found = mapIdentitiesByQNames.get(qName);
         assertNotNull(found);
@@ -60,7 +60,7 @@ public class SchemaContextTest extends AbstractYangTest {
             // all except scheduled-threadpool should have base set to
             // serviceType
             if (localName.equals("scheduled-threadpool") == false) {
-                assertEquals(serviceType, id.getBaseIdentity());
+                assertEquals(serviceType, id.getBaseIdentities().iterator().next());
             }
         }
         assertNotNull(eventBusSchemaNode);
@@ -75,9 +75,8 @@ public class SchemaContextTest extends AbstractYangTest {
                 usn.getNodeType());
     }
 
-    private void assertAllIdentitiesAreExpected(
-            Module module,
-            Map<String /* identity name */, Optional<QName>> expectedIdentitiesToBases) {
+    private static void assertAllIdentitiesAreExpected(final Module module,
+            final Map<String /* identity name */, Optional<QName>> expectedIdentitiesToBases) {
         Map<String /* identity name */, Optional<QName>> copyOfExpectedNames = new HashMap<>(
                 expectedIdentitiesToBases);
         for (IdentitySchemaNode id : module.getIdentities()) {
@@ -88,8 +87,7 @@ public class SchemaContextTest extends AbstractYangTest {
                     .remove(localName);
             if (maybeExpectedBaseQName.isPresent()) {
                 assertEquals("Unexpected base identity of " + localName,
-                        maybeExpectedBaseQName.get(), id.getBaseIdentity()
-                                .getQName());
+                        maybeExpectedBaseQName.get(), id.getBaseIdentities().iterator().next().getQName());
             }
         }
         assertEquals("Expected identities not found " + copyOfExpectedNames,
@@ -98,21 +96,14 @@ public class SchemaContextTest extends AbstractYangTest {
 
     @Test
     public void testReadingIdentities_threadsJavaModule() {
-        Map<String /* identity name */, Optional<QName>> expectedIdentitiesToBases = new HashMap<String, Optional<QName>>(){
-            private static final long serialVersionUID = 1L;
+        Map<String /* identity name */, Optional<QName>> expected = new HashMap<>();
+        expected.put(ModuleMXBeanEntryTest.EVENTBUS_MXB_NAME, Optional.of(MODULE_TYPE_Q_NAME));
+        expected.put(ModuleMXBeanEntryTest.ASYNC_EVENTBUS_MXB_NAME, Optional.of(MODULE_TYPE_Q_NAME));
+        expected.put(ModuleMXBeanEntryTest.THREADFACTORY_NAMING_MXB_NAME, Optional.of(MODULE_TYPE_Q_NAME));
+        expected.put(ModuleMXBeanEntryTest.THREADPOOL_DYNAMIC_MXB_NAME, Optional.of(MODULE_TYPE_Q_NAME));
+        expected.put("thread-rpc-context", Optional.<QName>absent());
+        expected.put(ModuleMXBeanEntryTest.THREADPOOL_REGISTRY_IMPL_NAME, Optional.of(MODULE_TYPE_Q_NAME));
 
-            {
-                put(ModuleMXBeanEntryTest.EVENTBUS_MXB_NAME, Optional.of(MODULE_TYPE_Q_NAME));
-                put(ModuleMXBeanEntryTest.ASYNC_EVENTBUS_MXB_NAME, Optional.of(MODULE_TYPE_Q_NAME));
-                put(ModuleMXBeanEntryTest.THREADFACTORY_NAMING_MXB_NAME, Optional.of(MODULE_TYPE_Q_NAME));
-                put(ModuleMXBeanEntryTest.THREADPOOL_DYNAMIC_MXB_NAME, Optional.of(MODULE_TYPE_Q_NAME));
-                put("thread-rpc-context", Optional.<QName>absent());
-                put(ModuleMXBeanEntryTest.THREADPOOL_REGISTRY_IMPL_NAME, Optional.of(MODULE_TYPE_Q_NAME));
-            }
-        };
-
-        assertAllIdentitiesAreExpected(threadsJavaModule,
-                expectedIdentitiesToBases);
+        assertAllIdentitiesAreExpected(threadsJavaModule, expected);
     }
-
 }
index f021c2c..ae81ce5 100644 (file)
@@ -14,10 +14,7 @@ import static org.junit.Assert.assertThat;
 import com.google.common.collect.Sets;
 import java.net.URI;
 import java.net.URISyntaxException;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
 import java.util.Arrays;
-import java.util.Date;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
@@ -27,6 +24,7 @@ import java.util.Set;
 import org.hamcrest.CoreMatchers;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
 
 public class ServiceInterfaceEntryTest extends AbstractYangTest {
@@ -37,20 +35,13 @@ public class ServiceInterfaceEntryTest extends AbstractYangTest {
             + ".java, ThreadFactoryServiceInterface.java, ThreadPoolServiceInterface.java]");
 
     private static final URI THREADS_NAMESPACE;
-    private static final Date THREADS_REVISION_DATE;
+    private static final Revision THREADS_REVISION_DATE = Revision.of("2013-04-09");
 
     static {
         try {
-            THREADS_NAMESPACE = new URI(ConfigConstants.CONFIG_NAMESPACE
-                    + ":threads");
+            THREADS_NAMESPACE = new URI(ConfigConstants.CONFIG_NAMESPACE + ":threads");
         } catch (URISyntaxException e) {
-            throw new Error(e);
-        }
-        SimpleDateFormat revisionFormat = new SimpleDateFormat("yyyy-MM-dd");
-        try {
-            THREADS_REVISION_DATE = revisionFormat.parse("2013-04-09");
-        } catch (ParseException e) {
-            throw new Error(e);
+            throw new ExceptionInInitializerError(e);
         }
     }
 
index 85a0ef0..5daaf0f 100644 (file)
@@ -10,8 +10,7 @@ package org.opendaylight.controller.config.yangjmxgenerator.unknownextension;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
-import com.google.common.collect.Lists;
-import java.io.InputStream;
+import java.util.ArrayList;
 import java.util.List;
 import org.junit.Test;
 import org.opendaylight.controller.config.yangjmxgenerator.ConfigConstants;
@@ -23,25 +22,20 @@ public class UnknownExtensionTest extends ServiceInterfaceEntryTest {
 
     @Test
     public void testStopOnUnknownLanguageExtension() throws Exception {
-        List<InputStream> yangISs = Lists.newArrayList(getClass()
-                .getResourceAsStream("test-ifcWithUnknownExtension.yang"));
-        yangISs.addAll(getConfigApiYangInputStreams());
+        List<String> yangs = new ArrayList<>();
+        yangs.addAll(getConfigApiYangs());
+        yangs.add("test-ifcWithUnknownExtension.yang");
+
+        context = YangParserTestUtils.parseYangResources(UnknownExtensionTest.class, yangs);
+        namesToModules = YangModelSearchUtils.mapModulesByNames(context.getModules());
+        configModule = namesToModules.get(ConfigConstants.CONFIG_MODULE);
+        threadsModule = namesToModules.get(ConfigConstants.CONFIG_THREADS_MODULE);
         try {
-            context = YangParserTestUtils.parseYangStreams(yangISs);
-            namesToModules = YangModelSearchUtils.mapModulesByNames(context.getModules());
-            configModule = namesToModules.get(ConfigConstants.CONFIG_MODULE);
-            threadsModule = namesToModules.get(ConfigConstants.CONFIG_THREADS_MODULE);
-            try {
-                super.testCreateFromIdentities();
-                fail();
-            } catch (IllegalStateException e) {
-                assertTrue(e.getMessage(),
-                        e.getMessage().startsWith("Unexpected unknown schema node."));
-            }
-        } finally {
-            for (InputStream is : yangISs) {
-                is.close();
-            }
+            super.testCreateFromIdentities();
+            fail();
+        } catch (IllegalStateException e) {
+            assertTrue(e.getMessage(),
+                e.getMessage().startsWith("Unexpected unknown schema node."));
         }
     }
 
index daaae4f..c7622bb 100644 (file)
@@ -23,12 +23,13 @@ import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.controller.cluster.access.ABIVersion;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeConfiguration;
 import org.opendaylight.yangtools.yang.data.impl.schema.tree.InMemoryDataTreeFactory;
 
 public class ConnectClientSuccessTest extends AbstractRequestSuccessTest<ConnectClientSuccess> {
 
-    private static final DataTree TREE = InMemoryDataTreeFactory.getInstance().create(TreeType.OPERATIONAL);
+    private static final DataTree TREE = new InMemoryDataTreeFactory().create(
+        DataTreeConfiguration.DEFAULT_OPERATIONAL);
     private static final ActorSystem SYSTEM = ActorSystem.create("test");
     private static final ActorRef ACTOR_REF = TestProbe.apply(SYSTEM).ref();
     private static final ActorSelection ACTOR_SELECTION =  ActorSelection.apply(ACTOR_REF, "foo");
index 7cd17dc..64d98ed 100644 (file)
@@ -7,7 +7,7 @@
  */
 package org.opendaylight.controller.md.sal.binding.impl;
 
-import com.google.common.base.Optional;
+import java.util.Optional;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
@@ -83,8 +83,11 @@ enum BindingStructuralType {
     UNKNOWN;
 
     static BindingStructuralType from(final DataTreeCandidateNode domChildNode) {
-        final Optional<NormalizedNode<?, ?>> dataBased = domChildNode.getDataAfter().or(domChildNode.getDataBefore());
-        if(dataBased.isPresent()) {
+        Optional<NormalizedNode<?, ?>> dataBased = domChildNode.getDataAfter();
+        if (!dataBased.isPresent()) {
+            dataBased = domChildNode.getDataBefore();
+        }
+        if (dataBased.isPresent()) {
             return from(dataBased.get());
         }
         return from(domChildNode.getIdentifier());
index e4e2053..2d4d9b8 100644 (file)
@@ -15,10 +15,8 @@ import com.google.common.cache.CacheLoader;
 import com.google.common.cache.LoadingCache;
 import com.google.common.collect.ImmutableBiMap;
 import java.lang.reflect.Method;
-import java.net.URI;
 import java.util.AbstractMap.SimpleEntry;
 import java.util.Collection;
-import java.util.Date;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Map;
@@ -309,11 +307,9 @@ public class BindingToNormalizedNodeCodec
 
     private Module getModuleBlocking(final Class<?> modeledClass) {
         final QNameModule moduleName = BindingReflections.getQNameModule(modeledClass);
-        final URI namespace = moduleName.getNamespace();
-        final Date revision = moduleName.getRevision();
-        Module module = runtimeContext().getSchemaContext().findModuleByNamespaceAndRevision(namespace, revision);
-        if ((module == null) && this.futureSchema.waitForSchema(namespace, revision)) {
-            module = runtimeContext().getSchemaContext().findModuleByNamespaceAndRevision(namespace, revision);
+        Module module = runtimeContext().getSchemaContext().findModule(moduleName).orElse(null);
+        if (module == null && this.futureSchema.waitForSchema(moduleName)) {
+            module = runtimeContext().getSchemaContext().findModule(moduleName).orElse(null);
         }
         Preconditions.checkState(module != null, "Schema for %s is not available.", modeledClass);
         return module;
@@ -332,7 +328,7 @@ public class BindingToNormalizedNodeCodec
     private Method findRpcMethod(final Class<? extends RpcService> key, final RpcDefinition rpcDef)
             throws NoSuchMethodException {
         final String methodName = BindingMapping.getMethodName(rpcDef.getQName());
-        if ((rpcDef.getInput() != null) && isExplicitStatement(rpcDef.getInput())) {
+        if (rpcDef.getInput() != null && isExplicitStatement(rpcDef.getInput())) {
             final Class<?> inputClz = runtimeContext().getClassForSchema(rpcDef.getInput());
             return key.getMethod(methodName, inputClz);
         }
@@ -340,8 +336,8 @@ public class BindingToNormalizedNodeCodec
     }
 
     private static boolean isExplicitStatement(final ContainerSchemaNode node) {
-        return (node instanceof EffectiveStatement)
-                && (((EffectiveStatement) node).getDeclared().getStatementSource() == StatementSource.DECLARATION);
+        return node instanceof EffectiveStatement
+                && ((EffectiveStatement) node).getDeclared().getStatementSource() == StatementSource.DECLARATION;
     }
 
     private BindingRuntimeContext runtimeContext() {
index e2fa7d1..0c316e8 100644 (file)
@@ -11,10 +11,8 @@ package org.opendaylight.controller.md.sal.binding.impl;
 import com.google.common.base.Predicate;
 import com.google.common.base.Throwables;
 import com.google.common.util.concurrent.SettableFuture;
-import java.net.URI;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.Date;
 import java.util.LinkedHashSet;
 import java.util.Set;
 import java.util.concurrent.ExecutionException;
@@ -23,6 +21,7 @@ import java.util.concurrent.TimeoutException;
 import javax.annotation.concurrent.GuardedBy;
 import org.opendaylight.mdsal.binding.generator.util.BindingRuntimeContext;
 import org.opendaylight.yangtools.yang.binding.Augmentation;
+import org.opendaylight.yangtools.yang.common.QNameModule;
 
 class FutureSchema implements AutoCloseable {
 
@@ -88,11 +87,11 @@ class FutureSchema implements AutoCloseable {
         return schema != null;
     }
 
-    boolean waitForSchema(final URI namespace, final Date revision) {
+    boolean waitForSchema(final QNameModule module) {
         return addPostponedOpAndWait(new FutureSchemaPredicate() {
             @Override
             public boolean apply(final BindingRuntimeContext input) {
-                return input.getSchemaContext().findModuleByNamespaceAndRevision(namespace, revision) != null;
+                return input.getSchemaContext().findModule(module).isPresent();
             }
         });
     }
index 4643323..74aa834 100644 (file)
@@ -7,12 +7,12 @@
  */
 package org.opendaylight.controller.md.sal.binding.impl;
 
-import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Optional;
 import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
 import org.opendaylight.mdsal.binding.dom.codec.api.BindingCodecTreeNode;
 import org.opendaylight.yangtools.yang.binding.Augmentation;
index a0e4530..8185446 100644 (file)
@@ -8,9 +8,9 @@
 
 package org.opendaylight.controller.md.sal.binding.impl;
 
-import com.google.common.base.Optional;
 import java.util.Collection;
 import java.util.Map;
+import java.util.Optional;
 import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.common.QName;
index 2f38ec7..b05e88b 100644 (file)
@@ -11,18 +11,21 @@ package org.opendaylight.controller.md.sal.binding.impl;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
+
 import com.google.common.collect.ImmutableBiMap;
-import com.google.common.collect.Multimaps;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.ImmutableSetMultimap;
 import com.google.common.collect.SetMultimap;
 import com.google.common.util.concurrent.Uninterruptibles;
 import java.lang.reflect.Method;
 import java.net.URI;
-import java.util.Collections;
 import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicReference;
+import javassist.ClassPool;
 import org.junit.Test;
 import org.opendaylight.controller.md.sal.binding.test.AbstractSchemaAwareTest;
 import org.opendaylight.mdsal.binding.dom.codec.gen.impl.DataObjectSerializerGenerator;
@@ -38,15 +41,14 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controll
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListKey;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
 import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.ModuleIdentifier;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.util.AbstractSchemaContext;
-import javassist.ClassPool;
 
 public class BindingNormalizedCodecTest extends AbstractSchemaAwareTest {
 
@@ -164,22 +166,22 @@ public class BindingNormalizedCodecTest extends AbstractSchemaAwareTest {
     static class EmptySchemaContext extends AbstractSchemaContext {
         @Override
         public Set<Module> getModules() {
-            return Collections.emptySet();
+            return ImmutableSet.of();
         }
 
         @Override
-        protected Map<ModuleIdentifier, String> getIdentifiersToSources() {
-            return Collections.emptyMap();
+        protected Map<QNameModule, Module> getModuleMap() {
+            return ImmutableMap.of();
         }
 
         @Override
         protected SetMultimap<URI, Module> getNamespaceToModules() {
-            return Multimaps.forMap(Collections.emptyMap());
+            return ImmutableSetMultimap.of();
         }
 
         @Override
         protected SetMultimap<String, Module> getNameToModules() {
-            return Multimaps.forMap(Collections.emptyMap());
+            return ImmutableSetMultimap.of();
         }
     }
 }
index a74b6ea..aba648c 100644 (file)
@@ -36,14 +36,14 @@ public class WriteParentListenAugmentTest extends AbstractDataServiceTest {
     private static final String TLL_NAME = "foo";
 
     private static final TopLevelListKey TLL_KEY = new TopLevelListKey(TLL_NAME);
-    private static final InstanceIdentifier<TopLevelList> TLL_INSTANCE_ID_BA = InstanceIdentifier.builder(Top.class) //
-            .child(TopLevelList.class, TLL_KEY).toInstance();
+    private static final InstanceIdentifier<TopLevelList> TLL_INSTANCE_ID_BA = InstanceIdentifier.builder(Top.class)
+            .child(TopLevelList.class, TLL_KEY).build();
 
     private static final InstanceIdentifier<TreeComplexUsesAugment> AUGMENT_WILDCARDED_PATH = InstanceIdentifier
-            .builder(Top.class).child(TopLevelList.class).augmentation(TreeComplexUsesAugment.class).toInstance();
+            .builder(Top.class).child(TopLevelList.class).augmentation(TreeComplexUsesAugment.class).build();
 
     private static final InstanceIdentifier<TreeComplexUsesAugment> AUGMENT_TLL_PATH = InstanceIdentifier
-            .builder(Top.class).child(TopLevelList.class, TLL_KEY).augmentation(TreeComplexUsesAugment.class).toInstance();
+            .builder(Top.class).child(TopLevelList.class, TLL_KEY).augmentation(TreeComplexUsesAugment.class).build();
 
     @Test
     public void writeNodeListenAugment() throws Exception {
@@ -56,8 +56,8 @@ public class WriteParentListenAugmentTest extends AbstractDataServiceTest {
 
         final WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
 
-        TopLevelList tll = new TopLevelListBuilder() //
-                .setKey(TLL_KEY) //
+        TopLevelList tll = new TopLevelListBuilder()
+                .setKey(TLL_KEY)
                 .addAugmentation(TreeComplexUsesAugment.class, treeComplexUsesAugment("one")).build();
         transaction.put(LogicalDatastoreType.OPERATIONAL, TLL_INSTANCE_ID_BA, tll, true);
         transaction.submit().get(5, TimeUnit.SECONDS);
@@ -72,13 +72,13 @@ public class WriteParentListenAugmentTest extends AbstractDataServiceTest {
         transaction2.submit().get(5, TimeUnit.SECONDS);
 
         TreeComplexUsesAugment readedAug = dataBroker.newReadOnlyTransaction().read(
-                LogicalDatastoreType.OPERATIONAL, AUGMENT_TLL_PATH).checkedGet(5, TimeUnit.SECONDS).get();
+                LogicalDatastoreType.OPERATIONAL, AUGMENT_TLL_PATH).get(5, TimeUnit.SECONDS).get();
         assertEquals("two", readedAug.getContainerWithUses().getLeafFromGrouping());
     }
 
-    private TreeComplexUsesAugment treeComplexUsesAugment(final String value) {
-        return new TreeComplexUsesAugmentBuilder() //
-                .setContainerWithUses(new ContainerWithUsesBuilder().setLeafFromGrouping(value).build()) //
+    private static TreeComplexUsesAugment treeComplexUsesAugment(final String value) {
+        return new TreeComplexUsesAugmentBuilder()
+                .setContainerWithUses(new ContainerWithUsesBuilder().setLeafFromGrouping(value).build())
                 .build();
     }
 }
index dca56ab..153d9d2 100644 (file)
@@ -44,7 +44,7 @@ public class WriteParentReadChildTest extends AbstractDataServiceTest {
     private static final List1Key LIST1_KEY = new List1Key(LIST1_NAME);
 
     private static final InstanceIdentifier<TopLevelList> TLL_INSTANCE_ID_BA = InstanceIdentifier.builder(Top.class) //
-            .child(TopLevelList.class, TLL_KEY).toInstance();
+            .child(TopLevelList.class, TLL_KEY).build();
 
     private static final InstanceIdentifier<List1> LIST1_INSTANCE_ID_BA = //
             TLL_INSTANCE_ID_BA.builder() //
@@ -75,11 +75,11 @@ public class WriteParentReadChildTest extends AbstractDataServiceTest {
         transaction.submit().get(5, TimeUnit.SECONDS);
 
         Optional<List1> readList1 = dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.OPERATIONAL,
-                LIST1_INSTANCE_ID_BA).checkedGet(1000, TimeUnit.MILLISECONDS);
+                LIST1_INSTANCE_ID_BA).get(1000, TimeUnit.MILLISECONDS);
         assertTrue(readList1.isPresent());
 
         Optional<? extends DataObject> readList11 = dataBroker.newReadOnlyTransaction().read(
-                LogicalDatastoreType.OPERATIONAL, LIST11_INSTANCE_ID_BA).checkedGet(5, TimeUnit.SECONDS);
+                LogicalDatastoreType.OPERATIONAL, LIST11_INSTANCE_ID_BA).get(5, TimeUnit.SECONDS);
         assertNotNull("Readed flow should not be null.",readList11);
         assertTrue(readList11.isPresent());
         assertEquals(list11, readList11.get());
index c7399e8..4b10353 100644 (file)
@@ -12,12 +12,12 @@ import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
 import com.google.common.base.Optional;
+import com.google.common.io.ByteSource;
 import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.MoreExecutors;
+import java.io.IOException;
 import java.io.InputStream;
-import java.util.Collections;
-import java.util.List;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
 import org.junit.After;
@@ -41,12 +41,17 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controll
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListKey;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
 import org.opendaylight.yangtools.yang.binding.util.BindingReflections;
 import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
+import org.opendaylight.yangtools.yang.model.repo.api.StatementParserMode;
+import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 /**
@@ -89,13 +94,18 @@ public class DOMRpcServiceTestBugfix560 {
         bindingMountPointService = testContext.getBindingMountPointService();
         assertNotNull(domMountPointService);
 
-        final InputStream moduleStream = BindingReflections.getModuleInfo(
-                OpendaylightTestRpcServiceService.class)
-                .getModuleSourceStream();
+        final YangModuleInfo moduleInfo = BindingReflections.getModuleInfo(OpendaylightTestRpcServiceService.class);
+        assertNotNull(moduleInfo);
 
-        assertNotNull(moduleStream);
-        final List<InputStream> rpcModels = Collections.singletonList(moduleStream);
-        schemaContext = YangParserTestUtils.parseYangStreams(rpcModels);
+        schemaContext = YangParserTestUtils.parseYangSources(StatementParserMode.DEFAULT_MODE, null,
+            YangTextSchemaSource.delegateForByteSource(RevisionSourceIdentifier.create(moduleInfo.getName(),
+                Revision.ofNullable(moduleInfo.getRevision())), new ByteSource() {
+
+                @Override
+                public InputStream openStream() throws IOException {
+                    return moduleInfo.getModuleSourceStream();
+                }
+            }));
     }
 
     private static org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier createBITllIdentifier(
index 94d1bad..b81de75 100644 (file)
@@ -13,6 +13,7 @@ import java.io.IOException;
 import java.util.HashMap;
 import java.util.Map;
 import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.Revision;
 
 /**
  * NormalizedNodeOutputStreamWriter will be used by distributed datastore to send normalized node in
@@ -44,7 +45,7 @@ final class NormalizedNodeOutputStreamWriter extends AbstractNormalizedNodeDataO
     protected void writeQName(final QName qname) throws IOException {
         writeString(qname.getLocalName());
         writeString(qname.getNamespace().toString());
-        writeString(qname.getFormattedRevision());
+        writeString(qname.getRevision().map(Revision::toString).orElse(null));
     }
 
     @Override
index f83f6af..8c81d60 100644 (file)
@@ -8,9 +8,9 @@
 package org.opendaylight.controller.cluster.datastore.util;
 
 import com.google.common.annotations.Beta;
-import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.base.Verify;
+import java.util.Optional;
 import javax.annotation.Nonnull;
 import javax.annotation.concurrent.NotThreadSafe;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
index 39302e4..202de58 100644 (file)
@@ -9,10 +9,10 @@
 package org.opendaylight.controller.cluster.schema.provider.impl;
 
 import com.google.common.annotations.Beta;
-import com.google.common.base.Optional;
 import com.google.common.io.ByteSource;
 import java.io.IOException;
 import java.io.Serializable;
+import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
 import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
 
@@ -24,17 +24,17 @@ public class YangTextSchemaSourceSerializationProxy implements Serializable {
     private static final long serialVersionUID = -6361268518176019477L;
 
     private final byte[] schemaSource;
-    private final String revision;
+    private final Revision revision;
     private final String name;
 
     public YangTextSchemaSourceSerializationProxy(final YangTextSchemaSource source) throws IOException {
-        this.revision = source.getIdentifier().getRevision();
+        this.revision = source.getIdentifier().getRevision().orElse(null);
         this.name = source.getIdentifier().getName();
         this.schemaSource = source.read();
     }
 
     public YangTextSchemaSource getRepresentation() {
         return YangTextSchemaSource.delegateForByteSource(
-                RevisionSourceIdentifier.create(name, Optional.fromNullable(revision)), ByteSource.wrap(schemaSource));
+                RevisionSourceIdentifier.create(name, revision), ByteSource.wrap(schemaSource));
     }
 }
index 81d9767..e2e5aa4 100644 (file)
@@ -10,12 +10,12 @@ package org.opendaylight.controller.cluster.datastore.node.utils.stream;
 
 import static org.junit.Assert.assertEquals;
 
-import com.google.common.base.Optional;
 import com.google.common.io.ByteStreams;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.StringReader;
 import java.io.StringWriter;
+import java.util.Optional;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.transform.OutputKeys;
 import javax.xml.transform.Transformer;
@@ -79,7 +79,7 @@ public class NormalizedNodeStreamReaderWriterTest {
     }
 
     private static NormalizedNode<?, ?> createTestContainer() {
-        byte[] bytes1 = {1,2,3};
+        byte[] bytes1 = {1, 2, 3};
         LeafSetEntryNode<Object> entry1 = ImmutableLeafSetEntryNodeBuilder.create().withNodeIdentifier(
                 new NodeWithValue<>(TestModel.BINARY_LEAF_LIST_QNAME, bytes1)).withValue(bytes1).build();
 
@@ -87,14 +87,11 @@ public class NormalizedNodeStreamReaderWriterTest {
         LeafSetEntryNode<Object> entry2 = ImmutableLeafSetEntryNodeBuilder.create().withNodeIdentifier(
                 new NodeWithValue<>(TestModel.BINARY_LEAF_LIST_QNAME, bytes2)).withValue(bytes2).build();
 
-        LeafSetEntryNode<Object> entry3 = ImmutableLeafSetEntryNodeBuilder.create().withNodeIdentifier(
-                new NodeWithValue<>(TestModel.BINARY_LEAF_LIST_QNAME, null)).withValue(null).build();
-
         return TestModel.createBaseTestContainerBuilder()
                 .withChild(ImmutableLeafSetNodeBuilder.create().withNodeIdentifier(
                         new NodeIdentifier(TestModel.BINARY_LEAF_LIST_QNAME))
-                        .withChild(entry1).withChild(entry2).withChild(entry3).build())
-                .withChild(ImmutableNodes.leafNode(TestModel.SOME_BINARY_DATA_QNAME, new byte[]{1,2,3,4}))
+                        .withChild(entry1).withChild(entry2).build())
+                .withChild(ImmutableNodes.leafNode(TestModel.SOME_BINARY_DATA_QNAME, new byte[]{1, 2, 3, 4}))
                 .withChild(Builders.orderedMapBuilder()
                       .withNodeIdentifier(new NodeIdentifier(TestModel.ORDERED_LIST_QNAME))
                       .withChild(ImmutableNodes.mapEntry(TestModel.ORDERED_LIST_ENTRY_QNAME,
index a961f6a..4715042 100644 (file)
@@ -52,15 +52,15 @@ public class NormalizedNodePrunerTest {
         MockitoAnnotations.initMocks(this);
     }
 
-    private static NormalizedNodePruner prunerFullSchema(YangInstanceIdentifier path) {
+    private static NormalizedNodePruner prunerFullSchema(final YangInstanceIdentifier path) {
         return new NormalizedNodePruner(path, FULL_SCHEMA);
     }
 
-    private static NormalizedNodePruner prunerNoAugSchema(YangInstanceIdentifier path) {
+    private static NormalizedNodePruner prunerNoAugSchema(final YangInstanceIdentifier path) {
         return new NormalizedNodePruner(path, NO_AUG_SCHEMA);
     }
 
-    private static NormalizedNodePruner prunerNoTestSchema(YangInstanceIdentifier path) {
+    private static NormalizedNodePruner prunerNoTestSchema(final YangInstanceIdentifier path) {
         return new NormalizedNodePruner(path, NO_TEST_SCHEMA);
     }
 
@@ -140,7 +140,7 @@ public class NormalizedNodePrunerTest {
 
     }
 
-    private static int countNodes(NormalizedNode<?,?> normalizedNode, final String namespaceFilter) {
+    private static int countNodes(final NormalizedNode<?,?> normalizedNode, final String namespaceFilter) {
         if (normalizedNode == null) {
             return 0;
         }
@@ -381,7 +381,7 @@ public class NormalizedNodePrunerTest {
     }
 
     private static NormalizedNode<?, ?> createTestContainer() {
-        byte[] bytes1 = {1,2,3};
+        byte[] bytes1 = {1, 2, 3};
         LeafSetEntryNode<Object> entry1 = ImmutableLeafSetEntryNodeBuilder.create().withNodeIdentifier(
                 new NodeWithValue<>(TestModel.BINARY_LEAF_LIST_QNAME, bytes1)).withValue(bytes1).build();
 
@@ -389,14 +389,10 @@ public class NormalizedNodePrunerTest {
         LeafSetEntryNode<Object> entry2 = ImmutableLeafSetEntryNodeBuilder.create().withNodeIdentifier(
                 new NodeWithValue<>(TestModel.BINARY_LEAF_LIST_QNAME, bytes2)).withValue(bytes2).build();
 
-        LeafSetEntryNode<Object> entry3 = ImmutableLeafSetEntryNodeBuilder.create().withNodeIdentifier(
-                new NodeWithValue<>(TestModel.BINARY_LEAF_LIST_QNAME, null)).withValue(null).build();
-
-
         return TestModel.createBaseTestContainerBuilder()
                 .withChild(ImmutableLeafSetNodeBuilder.create().withNodeIdentifier(
                         new NodeIdentifier(TestModel.BINARY_LEAF_LIST_QNAME))
-                        .withChild(entry1).withChild(entry2).withChild(entry3).build())
+                        .withChild(entry1).withChild(entry2).build())
                 .withChild(ImmutableNodes.leafNode(TestModel.SOME_BINARY_DATA_QNAME, new byte[]{1, 2, 3, 4}))
                 .build();
     }
index 22d4d20..72b8a3b 100644 (file)
@@ -17,10 +17,8 @@ import com.google.common.collect.ImmutableSet;
 import java.io.InputStream;
 import java.math.BigDecimal;
 import java.math.BigInteger;
-import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashSet;
-import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import org.opendaylight.yangtools.yang.common.QName;
@@ -49,7 +47,6 @@ import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLe
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetNodeBuilder;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableMapEntryNodeBuilder;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 public final class TestModel {
@@ -176,36 +173,17 @@ public final class TestModel {
     }
 
     public static SchemaContext createTestContext() {
-        List<InputStream> inputStreams = new ArrayList<>();
-        inputStreams.add(getDatastoreTestInputStream());
-        inputStreams.add(getDatastoreAugInputStream());
-        inputStreams.add(getDatastoreTestNotificationInputStream());
-
-        return resolveSchemaContext(inputStreams);
+        return YangParserTestUtils.parseYangResources(TestModel.class, DATASTORE_TEST_YANG, DATASTORE_AUG_YANG,
+            DATASTORE_TEST_NOTIFICATION_YANG);
     }
 
     public static SchemaContext createTestContextWithoutTestSchema() {
-        List<InputStream> inputStreams = new ArrayList<>();
-        inputStreams.add(getDatastoreTestNotificationInputStream());
-
-        return resolveSchemaContext(inputStreams);
+        return YangParserTestUtils.parseYangResource(DATASTORE_TEST_NOTIFICATION_YANG);
     }
 
-
     public static SchemaContext createTestContextWithoutAugmentationSchema() {
-        List<InputStream> inputStreams = new ArrayList<>();
-        inputStreams.add(getDatastoreTestInputStream());
-        inputStreams.add(getDatastoreTestNotificationInputStream());
-
-        return resolveSchemaContext(inputStreams);
-    }
-
-    private static SchemaContext resolveSchemaContext(final List<InputStream> streams) {
-        try {
-            return YangParserTestUtils.parseYangStreams(streams);
-        } catch (ReactorException e) {
-            throw new RuntimeException("Unable to build schema context from " + streams, e);
-        }
+        return YangParserTestUtils.parseYangResources(TestModel.class, DATASTORE_TEST_YANG,
+            DATASTORE_TEST_NOTIFICATION_YANG);
     }
 
     /**
index 5ce2d9b..0b41cdf 100644 (file)
@@ -14,7 +14,6 @@ import static org.junit.Assert.assertTrue;
 
 import akka.dispatch.ExecutionContexts;
 import akka.dispatch.Futures;
-import com.google.common.base.Optional;
 import com.google.common.io.ByteSource;
 import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.MoreExecutors;
@@ -23,6 +22,7 @@ import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mockito;
 import org.opendaylight.controller.cluster.schema.provider.RemoteYangTextSourceProvider;
+import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceException;
 import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
@@ -30,7 +30,7 @@ import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
 
 public class RemoteSchemaProviderTest {
 
-    private static final SourceIdentifier ID = RevisionSourceIdentifier.create("Test", Optional.of("2015-10-30"));
+    private static final SourceIdentifier ID = RevisionSourceIdentifier.create("Test", Revision.of("2015-10-30"));
 
     private RemoteSchemaProvider remoteSchemaProvider;
     private RemoteYangTextSourceProvider mockedRemoteSchemaRepository;
index 678bad7..90fc477 100644 (file)
@@ -12,7 +12,6 @@ import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
-import com.google.common.base.Optional;
 import com.google.common.io.ByteSource;
 import com.google.common.util.concurrent.Futures;
 import java.util.Collections;
@@ -20,6 +19,7 @@ import java.util.Set;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mockito;
+import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaRepository;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceException;
@@ -31,7 +31,7 @@ import scala.concurrent.duration.Duration;
 
 public class RemoteYangTextSourceProviderImplTest {
 
-    private static final SourceIdentifier ID = RevisionSourceIdentifier.create("Test", Optional.of("2015-10-30"));
+    private static final SourceIdentifier ID = RevisionSourceIdentifier.create("Test", Revision.of("2015-10-30"));
 
     private RemoteYangTextSourceProviderImpl remoteRepository;
     private SchemaRepository mockedLocalRepository;
index 95e141a..b2a86e1 100644 (file)
@@ -11,7 +11,6 @@ package org.opendaylight.controller.cluster.schema.provider.impl;
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
 
-import com.google.common.base.Optional;
 import com.google.common.io.ByteSource;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
@@ -21,6 +20,7 @@ import java.io.ObjectOutputStream;
 import java.nio.charset.StandardCharsets;
 import org.junit.Before;
 import org.junit.Test;
+import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
 import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
 
@@ -32,7 +32,7 @@ public class YangTextSourceSerializationProxyTest {
     public void setUp() {
         String source = "Test source.";
         schemaSource = YangTextSchemaSource.delegateForByteSource(
-                RevisionSourceIdentifier.create("test", Optional.of("2015-10-30")),
+                RevisionSourceIdentifier.create("test", Revision.of("2015-10-30")),
                 ByteSource.wrap(source.getBytes(StandardCharsets.UTF_8)));
     }
 
index ca344aa..5aa3ec6 100644 (file)
@@ -30,9 +30,9 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeAttrBuilder;
 import org.opendaylight.yangtools.yang.model.api.AnyXmlSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
+import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.AugmentationTarget;
-import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode;
+import org.opendaylight.yangtools.yang.model.api.CaseSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
@@ -326,7 +326,7 @@ public abstract class DataNormalizationOperation<T extends PathArgument> impleme
 
     private static final class AugmentationNormalization extends DataContainerNormalizationOperation<AugmentationIdentifier> {
 
-        public AugmentationNormalization(final AugmentationSchema augmentation, final DataNodeContainer schema) {
+        public AugmentationNormalization(final AugmentationSchemaNode augmentation, final DataNodeContainer schema) {
             super(augmentationIdentifierFrom(augmentation), augmentationProxy(augmentation,schema),null);
         }
 
@@ -347,7 +347,7 @@ public abstract class DataNormalizationOperation<T extends PathArgument> impleme
 
             final DataSchemaNode result = potential.get();
             // We try to look up if this node was added by augmentation
-            if ((schema instanceof DataSchemaNode) && result.isAugmenting()) {
+            if (schema instanceof DataSchemaNode && result.isAugmenting()) {
                 return fromAugmentation(schema, (AugmentationTarget) schema, result);
             }
             return fromDataSchemaNode(result);
@@ -454,7 +454,7 @@ public abstract class DataNormalizationOperation<T extends PathArgument> impleme
             final ImmutableMap.Builder<QName, DataNormalizationOperation<?>> byQNameBuilder = ImmutableMap.builder();
             final ImmutableMap.Builder<PathArgument, DataNormalizationOperation<?>> byArgBuilder = ImmutableMap.builder();
 
-            for (final ChoiceCaseNode caze : schema.getCases()) {
+            for (final CaseSchemaNode caze : schema.getCases().values()) {
                 for (final DataSchemaNode cazeChild : caze.getChildNodes()) {
                     final DataNormalizationOperation<?> childOp = fromDataSchemaNode(cazeChild);
                     byArgBuilder.put(childOp.getIdentifier(), childOp);
@@ -529,7 +529,7 @@ public abstract class DataNormalizationOperation<T extends PathArgument> impleme
 
         final DataSchemaNode result = potential.get();
         // We try to look up if this node was added by augmentation
-        if ((schema instanceof DataSchemaNode) && result.isAugmenting()) {
+        if (schema instanceof DataSchemaNode && result.isAugmenting()) {
             return fromAugmentation(schema, (AugmentationTarget) schema, result);
         }
         return fromDataSchemaNode(result);
@@ -538,7 +538,7 @@ public abstract class DataNormalizationOperation<T extends PathArgument> impleme
     private static ChoiceSchemaNode findChoice(final Iterable<ChoiceSchemaNode> choices, final QName child) {
         ChoiceSchemaNode foundChoice = null;
         choiceLoop: for (final ChoiceSchemaNode choice : choices) {
-            for (final ChoiceCaseNode caze : choice.getCases()) {
+            for (final CaseSchemaNode caze : choice.getCases().values()) {
                 if (findChildSchemaNode(caze, child).isPresent()) {
                     foundChoice = choice;
                     break choiceLoop;
@@ -548,7 +548,7 @@ public abstract class DataNormalizationOperation<T extends PathArgument> impleme
         return foundChoice;
     }
 
-    public static AugmentationIdentifier augmentationIdentifierFrom(final AugmentationSchema augmentation) {
+    public static AugmentationIdentifier augmentationIdentifierFrom(final AugmentationSchemaNode augmentation) {
         final ImmutableSet.Builder<QName> potentialChildren = ImmutableSet.builder();
         for (final DataSchemaNode child : augmentation.getChildNodes()) {
             potentialChildren.add(child.getQName());
@@ -556,7 +556,8 @@ public abstract class DataNormalizationOperation<T extends PathArgument> impleme
         return new AugmentationIdentifier(potentialChildren.build());
     }
 
-    private static DataNodeContainer augmentationProxy(final AugmentationSchema augmentation, final DataNodeContainer schema) {
+    private static DataNodeContainer augmentationProxy(final AugmentationSchemaNode augmentation,
+            final DataNodeContainer schema) {
         final Set<DataSchemaNode> children = new HashSet<>();
         for (final DataSchemaNode augNode : augmentation.getChildNodes()) {
             children.add(schema.getDataChildByName(augNode.getQName()));
@@ -580,8 +581,8 @@ public abstract class DataNormalizationOperation<T extends PathArgument> impleme
      */
     private static DataNormalizationOperation<?> fromAugmentation(final DataNodeContainer parent,
             final AugmentationTarget parentAug, final DataSchemaNode child) {
-        AugmentationSchema augmentation = null;
-        for (final AugmentationSchema aug : parentAug.getAvailableAugmentations()) {
+        AugmentationSchemaNode augmentation = null;
+        for (final AugmentationSchemaNode aug : parentAug.getAvailableAugmentations()) {
             final DataSchemaNode potential = aug.getDataChildByName(child.getQName());
             if (potential != null) {
                 augmentation = aug;
index 4c24c8a..fc3db54 100644 (file)
@@ -10,8 +10,8 @@ package org.opendaylight.controller.md.sal.common.impl.util.compat;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Optional;
 import java.util.Set;
-
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
@@ -28,13 +28,13 @@ class DataSchemaContainerProxy implements DataNodeContainer {
         realChildSchemas = realChildSchema;
         mappedChildSchemas = new HashMap<>();
         for(DataSchemaNode schema : realChildSchemas) {
-            mappedChildSchemas.put(schema.getQName(),schema);
+            mappedChildSchemas.put(schema.getQName(), schema);
         }
     }
 
     @Override
-    public DataSchemaNode getDataChildByName(final QName name) {
-        return mappedChildSchemas.get(name);
+    public Optional<DataSchemaNode> findDataChildByName(final QName name) {
+        return Optional.ofNullable(mappedChildSchemas.get(name));
     }
 
     @Override
@@ -56,5 +56,4 @@ class DataSchemaContainerProxy implements DataNodeContainer {
     public Set<UsesNode> getUses() {
         return Collections.emptySet();
     }
-
 }
index b6e9bfa..8940209 100644 (file)
@@ -85,7 +85,7 @@ abstract class LocalProxyTransaction extends AbstractProxyTransaction {
 
     @Override
     final CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> doRead(final YangInstanceIdentifier path) {
-        return Futures.immediateCheckedFuture(readOnlyView().readNode(path));
+        return Futures.immediateCheckedFuture(Optional.fromJavaUtil(readOnlyView().readNode(path)));
     }
 
     @Override
@@ -109,7 +109,7 @@ abstract class LocalProxyTransaction extends AbstractProxyTransaction {
         // listeners, which we do not want to execute while we are reconnecting.
         if (request instanceof ReadTransactionRequest) {
             final YangInstanceIdentifier path = ((ReadTransactionRequest) request).getPath();
-            final Optional<NormalizedNode<?, ?>> result = readOnlyView().readNode(path);
+            final Optional<NormalizedNode<?, ?>> result = Optional.fromJavaUtil(readOnlyView().readNode(path));
             if (callback != null) {
                 // XXX: FB does not see that callback is final, on stack and has be check for non-null.
                 final Consumer<Response<?, ?>> fbIsStupid = Preconditions.checkNotNull(callback);
index b245cee..8815183 100644 (file)
@@ -84,14 +84,16 @@ final class FrontendReadOnlyTransaction extends FrontendTransaction {
 
     private ExistsTransactionSuccess handleExistsTransaction(final ExistsTransactionRequest request)
             throws RequestException {
-        final Optional<NormalizedNode<?, ?>> data = openTransaction.getSnapshot().readNode(request.getPath());
+        final Optional<NormalizedNode<?, ?>> data = Optional.fromJavaUtil(openTransaction.getSnapshot()
+            .readNode(request.getPath()));
         return recordSuccess(request.getSequence(), new ExistsTransactionSuccess(openTransaction.getIdentifier(),
             request.getSequence(), data.isPresent()));
     }
 
     private ReadTransactionSuccess handleReadTransaction(final ReadTransactionRequest request)
             throws RequestException {
-        final Optional<NormalizedNode<?, ?>> data = openTransaction.getSnapshot().readNode(request.getPath());
+        final Optional<NormalizedNode<?, ?>> data = Optional.fromJavaUtil(openTransaction.getSnapshot().readNode(
+            request.getPath()));
         return recordSuccess(request.getSequence(), new ReadTransactionSuccess(openTransaction.getIdentifier(),
             request.getSequence(), data));
     }
index 2b444a6..5af7c79 100644 (file)
@@ -525,14 +525,16 @@ final class FrontendReadWriteTransaction extends FrontendTransaction {
 
     private ExistsTransactionSuccess handleExistsTransaction(final ExistsTransactionRequest request)
             throws RequestException {
-        final Optional<NormalizedNode<?, ?>> data = checkOpen().getSnapshot().readNode(request.getPath());
+        final Optional<NormalizedNode<?, ?>> data = Optional.fromJavaUtil(checkOpen().getSnapshot().readNode(
+            request.getPath()));
         return recordSuccess(request.getSequence(), new ExistsTransactionSuccess(getIdentifier(), request.getSequence(),
             data.isPresent()));
     }
 
     private ReadTransactionSuccess handleReadTransaction(final ReadTransactionRequest request)
             throws RequestException {
-        final Optional<NormalizedNode<?, ?>> data = checkOpen().getSnapshot().readNode(request.getPath());
+        final Optional<NormalizedNode<?, ?>> data = Optional.fromJavaUtil(checkOpen().getSnapshot().readNode(
+            request.getPath()));
         return recordSuccess(request.getSequence(), new ReadTransactionSuccess(getIdentifier(), request.getSequence(),
             data));
     }
index 3719f74..d7bbc1c 100644 (file)
@@ -103,8 +103,8 @@ import org.opendaylight.controller.cluster.raft.messages.RequestLeadership;
 import org.opendaylight.controller.cluster.raft.messages.ServerRemoved;
 import org.opendaylight.controller.cluster.raft.protobuff.client.messages.Payload;
 import org.opendaylight.yangtools.concepts.Identifier;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.TipProducingDataTree;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaContextProvider;
@@ -1025,7 +1025,7 @@ public class Shard extends RaftActor {
         private DatastoreContext datastoreContext;
         private SchemaContextProvider schemaContextProvider;
         private DatastoreSnapshot.ShardSnapshot restoreFromSnapshot;
-        private TipProducingDataTree dataTree;
+        private DataTree dataTree;
         private volatile boolean sealed;
 
         protected AbstractBuilder(final Class<S> shardClass) {
@@ -1071,7 +1071,7 @@ public class Shard extends RaftActor {
             return self();
         }
 
-        public T dataTree(final TipProducingDataTree newDataTree) {
+        public T dataTree(final DataTree newDataTree) {
             checkSealed();
             this.dataTree = newDataTree;
             return self();
@@ -1097,7 +1097,7 @@ public class Shard extends RaftActor {
             return restoreFromSnapshot;
         }
 
-        public TipProducingDataTree getDataTree() {
+        public DataTree getDataTree() {
             return dataTree;
         }
 
index e399cd4..9aca517 100644 (file)
@@ -68,15 +68,15 @@ import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.ConflictingModificationAppliedException;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateTip;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidates;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeConfiguration;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeTip;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.TipProducingDataTree;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.TipProducingDataTreeTip;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType;
 import org.opendaylight.yangtools.yang.data.impl.schema.tree.InMemoryDataTreeFactory;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
@@ -129,24 +129,24 @@ public class ShardDataTree extends ShardDataTreeTransactionParent {
     private final ShardDataTreeChangeListenerPublisher treeChangeListenerPublisher;
     private final ShardDataChangeListenerPublisher dataChangeListenerPublisher;
     private final Collection<ShardDataTreeMetadata<?>> metadata;
-    private final TipProducingDataTree dataTree;
+    private final DataTree dataTree;
     private final String logContext;
     private final Shard shard;
     private Runnable runOnPendingTransactionsComplete;
 
     /**
      * Optimistic {@link DataTreeCandidate} preparation. Since our DataTree implementation is a
-     * {@link TipProducingDataTree}, each {@link DataTreeCandidate} is also a {@link DataTreeTip}, e.g. another
+     * {@link DataTree}, each {@link DataTreeCandidate} is also a {@link DataTreeTip}, e.g. another
      * candidate can be prepared on top of it. They still need to be committed in sequence. Here we track the current
      * tip of the data tree, which is the last DataTreeCandidate we have in flight, or the DataTree itself.
      */
-    private TipProducingDataTreeTip tip;
+    private DataTreeTip tip;
 
     private SchemaContext schemaContext;
 
     private int currentTransactionBatch;
 
-    ShardDataTree(final Shard shard, final SchemaContext schemaContext, final TipProducingDataTree dataTree,
+    ShardDataTree(final Shard shard, final SchemaContext schemaContext, final DataTree dataTree,
             final ShardDataTreeChangeListenerPublisher treeChangeListenerPublisher,
             final ShardDataChangeListenerPublisher dataChangeListenerPublisher, final String logContext,
             final ShardDataTreeMetadata<?>... metadata) {
@@ -166,8 +166,17 @@ public class ShardDataTree extends ShardDataTreeTransactionParent {
             final ShardDataTreeChangeListenerPublisher treeChangeListenerPublisher,
             final ShardDataChangeListenerPublisher dataChangeListenerPublisher, final String logContext,
             final ShardDataTreeMetadata<?>... metadata) {
-        this(shard, schemaContext, InMemoryDataTreeFactory.getInstance().create(treeType, root),
-                treeChangeListenerPublisher, dataChangeListenerPublisher, logContext, metadata);
+        this(shard, schemaContext, createDataTree(treeType, root), treeChangeListenerPublisher,
+            dataChangeListenerPublisher, logContext, metadata);
+    }
+
+    private static DataTree createDataTree(final TreeType treeType, final YangInstanceIdentifier root) {
+        final DataTreeConfiguration baseConfig = DataTreeConfiguration.getDefault(treeType);
+        return new InMemoryDataTreeFactory().create(new DataTreeConfiguration.Builder(baseConfig.getTreeType())
+                .setMandatoryNodesValidation(baseConfig.isMandatoryNodesValidationEnabled())
+                .setUniqueIndexes(baseConfig.isUniqueIndexEnabled())
+                .setRootPath(root)
+                .build());
     }
 
     @VisibleForTesting
@@ -185,7 +194,7 @@ public class ShardDataTree extends ShardDataTreeTransactionParent {
         return shard.ticker().read();
     }
 
-    public TipProducingDataTree getDataTree() {
+    public DataTree getDataTree() {
         return dataTree;
     }
 
@@ -619,7 +628,7 @@ public class ShardDataTree extends ShardDataTreeTransactionParent {
     }
 
     Optional<DataTreeCandidate> readCurrentData() {
-        final Optional<NormalizedNode<?, ?>> currentState =
+        final java.util.Optional<NormalizedNode<?, ?>> currentState =
                 dataTree.takeSnapshot().readNode(YangInstanceIdentifier.EMPTY);
         return currentState.isPresent() ? Optional.of(DataTreeCandidates.fromNormalizedNode(
             YangInstanceIdentifier.EMPTY, currentState.get())) : Optional.<DataTreeCandidate>absent();
@@ -662,7 +671,7 @@ public class ShardDataTree extends ShardDataTreeTransactionParent {
     }
 
     public Optional<NormalizedNode<?, ?>> readNode(final YangInstanceIdentifier path) {
-        return dataTree.takeSnapshot().readNode(path);
+        return Optional.fromJavaUtil(dataTree.takeSnapshot().readNode(path));
     }
 
     DataTreeSnapshot takeSnapshot() {
@@ -1092,7 +1101,7 @@ public class ShardDataTree extends ShardDataTreeTransactionParent {
             return false;
         }
 
-        TipProducingDataTreeTip newTip = MoreObjects.firstNonNull(first.cohort.getCandidate(), dataTree);
+        DataTreeTip newTip = MoreObjects.firstNonNull(first.cohort.getCandidate(), dataTree);
         while (it.hasNext()) {
             final CommitEntry e = it.next();
             if (cohort.equals(e.cohort)) {
@@ -1114,7 +1123,7 @@ public class ShardDataTree extends ShardDataTreeTransactionParent {
     }
 
     @SuppressWarnings("checkstyle:IllegalCatch")
-    private void rebaseTransactions(final Iterator<CommitEntry> iter, @Nonnull final TipProducingDataTreeTip newTip) {
+    private void rebaseTransactions(final Iterator<CommitEntry> iter, @Nonnull final DataTreeTip newTip) {
         tip = Preconditions.checkNotNull(newTip);
         while (iter.hasNext()) {
             final SimpleShardDataTreeCohort cohort = iter.next().cohort;
index 0e82116..5b9c95f 100644 (file)
@@ -13,7 +13,6 @@ import akka.actor.PoisonPill;
 import akka.actor.Props;
 import akka.actor.ReceiveTimeout;
 import akka.japi.Creator;
-import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
@@ -28,7 +27,6 @@ import org.opendaylight.controller.cluster.datastore.messages.ReadData;
 import org.opendaylight.controller.cluster.datastore.messages.ReadDataReply;
 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 
 /**
  * The ShardTransaction Actor represents a remote transaction that delegates all actions to DOMDataReadWriteTransaction.
@@ -105,8 +103,8 @@ public abstract class ShardTransaction extends AbstractUntypedActorWithMetering
         }
 
         final YangInstanceIdentifier path = message.getPath();
-        Optional<NormalizedNode<?, ?>> optional = transaction.getSnapshot().readNode(path);
-        ReadDataReply readDataReply = new ReadDataReply(optional.orNull(), message.getVersion());
+        ReadDataReply readDataReply = new ReadDataReply(transaction.getSnapshot().readNode(path).orElse(null),
+            message.getVersion());
         sender().tell(readDataReply.toSerializable(), self());
     }
 
index 7d872b4..0b3ac7a 100644 (file)
@@ -24,13 +24,12 @@ public abstract class AbstractEntityOwnerChangeListener implements DOMDataTreeCh
             .node(EntityType.QNAME).node(EntityType.QNAME).node(ENTITY_QNAME).node(ENTITY_QNAME)
             .node(ENTITY_OWNER_QNAME).build();
 
-    void init(ShardDataTree shardDataTree) {
+    void init(final ShardDataTree shardDataTree) {
         shardDataTree.registerTreeChangeListener(EOS_PATH, this, Optional.absent(), noop -> { /* NOOP */ });
     }
 
-    protected static String extractOwner(LeafNode<?> ownerLeaf) {
-        Object value = ownerLeaf.getValue();
-        return value != null ? value.toString() : null;
+    protected static String extractOwner(final LeafNode<?> ownerLeaf) {
+        return ownerLeaf.getValue().toString();
     }
 
 }
index 398671e..4d65c55 100644 (file)
@@ -20,7 +20,8 @@ class DistributedEntityOwnershipCandidateRegistration extends AbstractObjectRegi
         implements DOMEntityOwnershipCandidateRegistration {
     private final DistributedEntityOwnershipService service;
 
-    DistributedEntityOwnershipCandidateRegistration(DOMEntity entity, DistributedEntityOwnershipService service) {
+    DistributedEntityOwnershipCandidateRegistration(final DOMEntity entity,
+            final DistributedEntityOwnershipService service) {
         super(entity);
         this.service = service;
     }
@@ -29,11 +30,4 @@ class DistributedEntityOwnershipCandidateRegistration extends AbstractObjectRegi
     protected void removeRegistration() {
         service.unregisterCandidate(getInstance());
     }
-
-    @Override
-    public String toString() {
-        return "DistributedEntityOwnershipCandidateRegistration [entity=" + getInstance() + "]";
-    }
-
-
 }
index 2e0f4b4..149551b 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.controller.cluster.datastore.entityownership;
 
+import com.google.common.base.MoreObjects.ToStringHelper;
 import com.google.common.base.Preconditions;
 import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipListener;
 import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipListenerRegistration;
@@ -22,8 +23,8 @@ class DistributedEntityOwnershipListenerRegistration extends AbstractObjectRegis
     private final DistributedEntityOwnershipService service;
     private final String entityType;
 
-    DistributedEntityOwnershipListenerRegistration(DOMEntityOwnershipListener listener, String entityType,
-            DistributedEntityOwnershipService service) {
+    DistributedEntityOwnershipListenerRegistration(final DOMEntityOwnershipListener listener, final String entityType,
+            final DistributedEntityOwnershipService service) {
         super(listener);
         this.entityType = Preconditions.checkNotNull(entityType, "entityType cannot be null");
         this.service = Preconditions.checkNotNull(service, "DOMEntityOwnershipListener cannot be null");
@@ -40,8 +41,7 @@ class DistributedEntityOwnershipListenerRegistration extends AbstractObjectRegis
     }
 
     @Override
-    public String toString() {
-        return "DistributedEntityOwnershipListenerRegistration [entityType=" + getEntityType()
-                + ", listener=" + getInstance() + "]";
+    protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
+        return toStringHelper.add("entityType", entityType);
     }
 }
index 944d14a..1cb7446 100644 (file)
@@ -187,7 +187,7 @@ public class DistributedEntityOwnershipService implements DOMEntityOwnershipServ
             return Optional.absent();
         }
 
-        Optional<NormalizedNode<?, ?>> entityNode = dataTree.takeSnapshot().readNode(
+        java.util.Optional<NormalizedNode<?, ?>> entityNode = dataTree.takeSnapshot().readNode(
                 entityPath(forEntity.getType(), forEntity.getIdentifier()));
         if (!entityNode.isPresent()) {
             return Optional.absent();
@@ -195,7 +195,7 @@ public class DistributedEntityOwnershipService implements DOMEntityOwnershipServ
 
         // Check if there are any candidates, if there are none we do not really have ownership state
         final MapEntryNode entity = (MapEntryNode) entityNode.get();
-        final Optional<DataContainerChild<? extends PathArgument, ?>> optionalCandidates =
+        final java.util.Optional<DataContainerChild<? extends PathArgument, ?>> optionalCandidates =
                 entity.getChild(CANDIDATE_NODE_ID);
         final boolean hasCandidates = optionalCandidates.isPresent()
                 && ((MapNode) optionalCandidates.get()).getValue().size() > 0;
@@ -204,7 +204,8 @@ public class DistributedEntityOwnershipService implements DOMEntityOwnershipServ
         }
 
         MemberName localMemberName = context.getCurrentMemberName();
-        Optional<DataContainerChild<? extends PathArgument, ?>> ownerLeaf = entity.getChild(ENTITY_OWNER_NODE_ID);
+        java.util.Optional<DataContainerChild<? extends PathArgument, ?>> ownerLeaf = entity.getChild(
+            ENTITY_OWNER_NODE_ID);
         String owner = ownerLeaf.isPresent() ? ownerLeaf.get().getValue().toString() : null;
         boolean hasOwner = !Strings.isNullOrEmpty(owner);
         boolean isOwner = hasOwner && localMemberName.getName().equals(owner);
index 04037b3..0201745 100644 (file)
@@ -9,12 +9,12 @@ package org.opendaylight.controller.cluster.datastore.entityownership;
 
 import static org.opendaylight.controller.cluster.datastore.entityownership.EntityOwnersModel.createEntity;
 
-import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.base.Strings;
 import com.google.common.base.Verify;
 import java.util.Collection;
 import java.util.Objects;
+import java.util.Optional;
 import org.opendaylight.controller.cluster.access.concepts.MemberName;
 import org.opendaylight.mdsal.eos.dom.api.DOMEntity;
 import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
index a392049..22d5935 100644 (file)
@@ -52,15 +52,15 @@ public final class EntityOwnersModel {
     private EntityOwnersModel() {
     }
 
-    static YangInstanceIdentifier entityPath(String entityType, YangInstanceIdentifier entityId) {
+    static YangInstanceIdentifier entityPath(final String entityType, final YangInstanceIdentifier entityId) {
         return YangInstanceIdentifier.builder(ENTITY_OWNERS_PATH).node(EntityType.QNAME)
                 .nodeWithKey(EntityType.QNAME, ENTITY_TYPE_QNAME, entityType).node(ENTITY_QNAME)
                         .nodeWithKey(ENTITY_QNAME, ENTITY_ID_QNAME, entityId).build();
 
     }
 
-    static YangInstanceIdentifier candidatePath(String entityType, YangInstanceIdentifier entityId,
-            String candidateName) {
+    static YangInstanceIdentifier candidatePath(final String entityType, final YangInstanceIdentifier entityId,
+            final String candidateName) {
         return YangInstanceIdentifier.builder(ENTITY_OWNERS_PATH).node(EntityType.QNAME)
                 .nodeWithKey(EntityType.QNAME, ENTITY_TYPE_QNAME, entityType).node(ENTITY_QNAME)
                         .nodeWithKey(ENTITY_QNAME, ENTITY_ID_QNAME, entityId).node(Candidate.QNAME)
@@ -68,53 +68,55 @@ public final class EntityOwnersModel {
 
     }
 
-    static YangInstanceIdentifier candidatePath(YangInstanceIdentifier entityPath, String candidateName) {
+    static YangInstanceIdentifier candidatePath(final YangInstanceIdentifier entityPath, final String candidateName) {
         return YangInstanceIdentifier.builder(entityPath).node(Candidate.QNAME).nodeWithKey(
                 Candidate.QNAME, CANDIDATE_NAME_QNAME, candidateName).build();
     }
 
-    static NodeIdentifierWithPredicates candidateNodeKey(String candidateName) {
+    static NodeIdentifierWithPredicates candidateNodeKey(final String candidateName) {
         return new NodeIdentifierWithPredicates(Candidate.QNAME, CANDIDATE_NAME_QNAME, candidateName);
     }
 
-    static NormalizedNode<?, ?> entityOwnersWithCandidate(String entityType, YangInstanceIdentifier entityId,
-            String candidateName) {
+    static NormalizedNode<?, ?> entityOwnersWithCandidate(final String entityType,
+            final YangInstanceIdentifier entityId, final String candidateName) {
         return entityOwnersWithEntityTypeEntry(entityTypeEntryWithEntityEntry(entityType,
                 entityEntryWithCandidateEntry(entityId, candidateName)));
     }
 
-    static ContainerNode entityOwnersWithEntityTypeEntry(MapEntryNode entityTypeNode) {
+    static ContainerNode entityOwnersWithEntityTypeEntry(final MapEntryNode entityTypeNode) {
         return ImmutableContainerNodeBuilder.create().withNodeIdentifier(
                 ENTITY_OWNERS_NODE_ID).addChild(ImmutableNodes.mapNodeBuilder(EntityType.QNAME)
                         .addChild(entityTypeNode).build()).build();
     }
 
-    static MapEntryNode entityTypeEntryWithEntityEntry(String entityType, MapEntryNode entityNode) {
+    static MapEntryNode entityTypeEntryWithEntityEntry(final String entityType, final MapEntryNode entityNode) {
         return ImmutableNodes.mapEntryBuilder(EntityType.QNAME,
                 ENTITY_TYPE_QNAME, entityType).addChild(ImmutableNodes.mapNodeBuilder(
                         ENTITY_QNAME).addChild(entityNode).build()).build();
     }
 
-    static MapEntryNode entityEntryWithCandidateEntry(YangInstanceIdentifier entityId, String candidateName) {
+    static MapEntryNode entityEntryWithCandidateEntry(final YangInstanceIdentifier entityId,
+            final String candidateName) {
         return ImmutableNodes.mapEntryBuilder(ENTITY_QNAME, ENTITY_ID_QNAME, entityId).addChild(
                 candidateEntry(candidateName)).build();
     }
 
-    static MapNode candidateEntry(String candidateName) {
+    static MapNode candidateEntry(final String candidateName) {
         return ImmutableOrderedMapNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(Candidate.QNAME))
                 .addChild(candidateMapEntry(candidateName)).build();
     }
 
-    static MapEntryNode candidateMapEntry(String candidateName) {
+    static MapEntryNode candidateMapEntry(final String candidateName) {
         return ImmutableNodes.mapEntry(Candidate.QNAME, CANDIDATE_NAME_QNAME, candidateName);
     }
 
-    static MapEntryNode entityEntryWithOwner(YangInstanceIdentifier entityId, String owner) {
-        return ImmutableNodes.mapEntryBuilder(ENTITY_QNAME, ENTITY_ID_QNAME, entityId).addChild(
-                ImmutableNodes.leafNode(ENTITY_OWNER_QNAME, owner)).build();
+    static MapEntryNode entityEntryWithOwner(final YangInstanceIdentifier entityId, final String owner) {
+        return ImmutableNodes.mapEntryBuilder(ENTITY_QNAME, ENTITY_ID_QNAME, entityId)
+                .addChild(ImmutableNodes.leafNode(ENTITY_OWNER_QNAME, owner != null ? owner : ""))
+                .build();
     }
 
-    public static String entityTypeFromEntityPath(YangInstanceIdentifier entityPath) {
+    public static String entityTypeFromEntityPath(final YangInstanceIdentifier entityPath) {
         YangInstanceIdentifier parent = entityPath;
         while (!parent.isEmpty()) {
             if (EntityType.QNAME.equals(parent.getLastPathArgument().getNodeType())) {
@@ -127,7 +129,7 @@ public final class EntityOwnersModel {
         return null;
     }
 
-    static DOMEntity createEntity(YangInstanceIdentifier entityPath) {
+    static DOMEntity createEntity(final YangInstanceIdentifier entityPath) {
         String entityType = null;
         YangInstanceIdentifier entityId = null;
         for (PathArgument pathArg: entityPath.getPathArguments()) {
index b20d91c..6f4c8db 100644 (file)
@@ -199,13 +199,13 @@ class EntityOwnershipShard extends Shard {
         getSender().tell(SuccessReply.INSTANCE, getSelf());
 
         searchForEntities((entityTypeNode, entityNode) -> {
-            Optional<DataContainerChild<?, ?>> possibleType = entityTypeNode.getChild(ENTITY_TYPE_NODE_ID);
+            java.util.Optional<DataContainerChild<?, ?>> possibleType = entityTypeNode.getChild(ENTITY_TYPE_NODE_ID);
             String entityType = possibleType.isPresent() ? possibleType.get().getValue().toString() : null;
             if (registerListener.getEntityType().equals(entityType)) {
                 final boolean hasOwner;
                 final boolean isOwner;
 
-                Optional<DataContainerChild<?, ?>> possibleOwner = entityNode.getChild(ENTITY_OWNER_NODE_ID);
+                java.util.Optional<DataContainerChild<?, ?>> possibleOwner = entityNode.getChild(ENTITY_OWNER_NODE_ID);
                 if (possibleOwner.isPresent()) {
                     isOwner = localMemberName.getName().equals(possibleOwner.get().getValue().toString());
                     hasOwner = true;
@@ -299,12 +299,12 @@ class EntityOwnershipShard extends Shard {
 
     private void notifyAllListeners() {
         searchForEntities((entityTypeNode, entityNode) -> {
-            Optional<DataContainerChild<?, ?>> possibleType = entityTypeNode.getChild(ENTITY_TYPE_NODE_ID);
+            java.util.Optional<DataContainerChild<?, ?>> possibleType = entityTypeNode.getChild(ENTITY_TYPE_NODE_ID);
             if (possibleType.isPresent()) {
                 final boolean hasOwner;
                 final boolean isOwner;
 
-                Optional<DataContainerChild<?, ?>> possibleOwner = entityNode.getChild(ENTITY_OWNER_NODE_ID);
+                java.util.Optional<DataContainerChild<?, ?>> possibleOwner = entityNode.getChild(ENTITY_OWNER_NODE_ID);
                 if (possibleOwner.isPresent()) {
                     isOwner = localMemberName.getName().equals(possibleOwner.get().getValue().toString());
                     hasOwner = true;
@@ -388,12 +388,12 @@ class EntityOwnershipShard extends Shard {
                     .node(entityTypeNode.getIdentifier()).node(ENTITY_NODE_ID).node(entityNode.getIdentifier())
                     .node(ENTITY_OWNER_NODE_ID).build();
 
-            Optional<String> possibleOwner = entityNode.getChild(ENTITY_OWNER_NODE_ID).transform(
-                node -> node.getValue().toString());
-            String newOwner = newOwner(possibleOwner.orNull(), getCandidateNames(entityNode),
+            java.util.Optional<String> possibleOwner =
+                    entityNode.getChild(ENTITY_OWNER_NODE_ID).map(node -> node.getValue().toString());
+            String newOwner = newOwner(possibleOwner.orElse(null), getCandidateNames(entityNode),
                     getEntityOwnerElectionStrategy(entityPath));
 
-            if (!newOwner.equals(possibleOwner.or(""))) {
+            if (!newOwner.equals(possibleOwner.orElse(""))) {
                 modifications.add(new WriteModification(entityPath,
                         ImmutableNodes.leafNode(ENTITY_OWNER_NODE_ID, newOwner)));
             }
@@ -556,7 +556,7 @@ class EntityOwnershipShard extends Shard {
         LOG.debug("{}: Searching for entities owned by {}", persistenceId(), ownedBy);
 
         searchForEntities((entityTypeNode, entityNode) -> {
-            Optional<DataContainerChild<? extends PathArgument, ?>> possibleOwner =
+            java.util.Optional<DataContainerChild<? extends PathArgument, ?>> possibleOwner =
                     entityNode.getChild(ENTITY_OWNER_NODE_ID);
             String currentOwner = possibleOwner.isPresent() ? possibleOwner.get().getValue().toString() : "";
             if (ownedBy.contains(currentOwner)) {
@@ -597,7 +597,7 @@ class EntityOwnershipShard extends Shard {
         }
 
         for (MapEntryNode entityType:  ((MapNode) possibleEntityTypes.get()).getValue()) {
-            Optional<DataContainerChild<?, ?>> possibleEntities = entityType.getChild(ENTITY_NODE_ID);
+            java.util.Optional<DataContainerChild<?, ?>> possibleEntities = entityType.getChild(ENTITY_NODE_ID);
             if (!possibleEntities.isPresent()) {
                 // shouldn't happen but handle anyway
                 continue;
index f18ae66..a96bbe3 100644 (file)
@@ -10,11 +10,11 @@ package org.opendaylight.controller.cluster.datastore.entityownership;
 
 import static org.opendaylight.controller.cluster.datastore.entityownership.EntityOwnersModel.entityTypeFromEntityPath;
 
-import com.google.common.base.Optional;
 import com.google.common.base.Strings;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Optional;
 import javax.annotation.Nonnull;
 import org.opendaylight.yangtools.triemap.TrieMap;
 import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
index 85c5403..6c6a5af 100644 (file)
@@ -7,9 +7,9 @@
  */
 package org.opendaylight.controller.cluster.datastore.persisted;
 
-import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import java.util.Collection;
+import java.util.Optional;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
index 085a845..ae88112 100644 (file)
@@ -7,8 +7,8 @@
  */
 package org.opendaylight.controller.cluster.datastore.persisted;
 
-import com.google.common.base.Optional;
 import java.util.Collection;
+import java.util.Optional;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
@@ -42,7 +42,7 @@ abstract class DeletedDataTreeCandidateNode extends AbstractDataTreeCandidateNod
 
     @Override
     public final Optional<NormalizedNode<?, ?>> getDataAfter() {
-        return Optional.absent();
+        return Optional.empty();
     }
 
     @Override
index 81f91aa..6820e1c 100644 (file)
@@ -7,9 +7,9 @@
  */
 package org.opendaylight.controller.cluster.datastore.persisted;
 
-import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import java.util.Collection;
+import java.util.Optional;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
index 0b3768f..187d252 100644 (file)
@@ -1125,7 +1125,7 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
     private void updateSchemaContext(final Object message) {
         schemaContext = ((UpdateSchemaContext) message).getSchemaContext();
 
-        LOG.debug("Got updated SchemaContext: # of modules {}", schemaContext.getAllModuleIdentifiers().size());
+        LOG.debug("Got updated SchemaContext: # of modules {}", schemaContext.getModules().size());
 
         for (ShardInformation info : localShards.values()) {
             info.setSchemaContext(schemaContext);
index 09b497f..f587889 100644 (file)
@@ -14,9 +14,9 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeConfiguration;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType;
 import org.opendaylight.yangtools.yang.data.impl.schema.tree.InMemoryDataTreeFactory;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
@@ -27,12 +27,12 @@ public final class NormalizedNodeAggregator {
 
     private NormalizedNodeAggregator(final YangInstanceIdentifier rootIdentifier,
             final List<Optional<NormalizedNode<?, ?>>> nodes, final SchemaContext schemaContext,
-            LogicalDatastoreType logicalDatastoreType) {
+            final LogicalDatastoreType logicalDatastoreType) {
         this.rootIdentifier = rootIdentifier;
         this.nodes = nodes;
-        this.dataTree = InMemoryDataTreeFactory.getInstance().create(
-                logicalDatastoreType == LogicalDatastoreType.CONFIGURATION ? TreeType.CONFIGURATION :
-                    TreeType.OPERATIONAL);
+        this.dataTree = new InMemoryDataTreeFactory().create(
+            logicalDatastoreType == LogicalDatastoreType.CONFIGURATION ? DataTreeConfiguration.DEFAULT_CONFIGURATION
+                    : DataTreeConfiguration.DEFAULT_OPERATIONAL);
         this.dataTree.setSchemaContext(schemaContext);
     }
 
@@ -41,7 +41,7 @@ public final class NormalizedNodeAggregator {
      */
     public static Optional<NormalizedNode<?,?>> aggregate(final YangInstanceIdentifier rootIdentifier,
             final List<Optional<NormalizedNode<?, ?>>> nodes, final SchemaContext schemaContext,
-            LogicalDatastoreType logicalDatastoreType) throws DataValidationFailedException {
+            final LogicalDatastoreType logicalDatastoreType) throws DataValidationFailedException {
         return new NormalizedNodeAggregator(rootIdentifier, nodes, schemaContext, logicalDatastoreType).aggregate();
     }
 
@@ -66,6 +66,6 @@ public final class NormalizedNodeAggregator {
     }
 
     private Optional<NormalizedNode<?, ?>> getRootNode() {
-        return dataTree.takeSnapshot().readNode(rootIdentifier);
+        return Optional.fromJavaUtil(dataTree.takeSnapshot().readNode(rootIdentifier));
     }
 }
index 0e97cd9..d0699fb 100644 (file)
@@ -9,10 +9,10 @@
 package org.opendaylight.controller.cluster.datastore.utils;
 
 import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.ForwardingObject;
 import java.io.IOException;
+import java.util.Optional;
 import org.opendaylight.controller.cluster.datastore.node.utils.transformer.NormalizedNodePruner;
 import org.opendaylight.controller.cluster.datastore.util.AbstractDataTreeModificationCursor;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
@@ -38,7 +38,8 @@ public class PruningDataTreeModification extends ForwardingObject implements Dat
     private final SchemaContext schemaContext;
     private final DataTree dataTree;
 
-    public PruningDataTreeModification(DataTreeModification delegate, DataTree dataTree, SchemaContext schemaContext) {
+    public PruningDataTreeModification(final DataTreeModification delegate, final DataTree dataTree,
+            final SchemaContext schemaContext) {
         this.delegate = Preconditions.checkNotNull(delegate);
         this.dataTree = Preconditions.checkNotNull(dataTree);
         this.schemaContext = Preconditions.checkNotNull(schemaContext);
@@ -50,7 +51,7 @@ public class PruningDataTreeModification extends ForwardingObject implements Dat
     }
 
     @Override
-    public void delete(YangInstanceIdentifier yangInstanceIdentifier) {
+    public void delete(final YangInstanceIdentifier yangInstanceIdentifier) {
         try {
             delegate.delete(yangInstanceIdentifier);
         } catch (SchemaValidationFailedException e) {
@@ -59,7 +60,7 @@ public class PruningDataTreeModification extends ForwardingObject implements Dat
     }
 
     @Override
-    public void merge(YangInstanceIdentifier yangInstanceIdentifier, NormalizedNode<?, ?> normalizedNode) {
+    public void merge(final YangInstanceIdentifier yangInstanceIdentifier, final NormalizedNode<?, ?> normalizedNode) {
         try {
             if (YangInstanceIdentifier.EMPTY.equals(yangInstanceIdentifier)) {
                 pruneAndMergeNode(yangInstanceIdentifier, normalizedNode);
@@ -75,7 +76,8 @@ public class PruningDataTreeModification extends ForwardingObject implements Dat
 
     }
 
-    private void pruneAndMergeNode(YangInstanceIdentifier yangInstanceIdentifier, NormalizedNode<?, ?> normalizedNode) {
+    private void pruneAndMergeNode(final YangInstanceIdentifier yangInstanceIdentifier,
+            final NormalizedNode<?, ?> normalizedNode) {
         NormalizedNode<?,?> pruned = pruneNormalizedNode(yangInstanceIdentifier, normalizedNode);
 
         if (pruned != null) {
@@ -84,7 +86,7 @@ public class PruningDataTreeModification extends ForwardingObject implements Dat
     }
 
     @Override
-    public void write(YangInstanceIdentifier yangInstanceIdentifier, NormalizedNode<?, ?> normalizedNode) {
+    public void write(final YangInstanceIdentifier yangInstanceIdentifier, final NormalizedNode<?, ?> normalizedNode) {
         try {
             if (YangInstanceIdentifier.EMPTY.equals(yangInstanceIdentifier)) {
                 pruneAndWriteNode(yangInstanceIdentifier, normalizedNode);
@@ -99,7 +101,8 @@ public class PruningDataTreeModification extends ForwardingObject implements Dat
         }
     }
 
-    private void pruneAndWriteNode(YangInstanceIdentifier yangInstanceIdentifier, NormalizedNode<?, ?> normalizedNode) {
+    private void pruneAndWriteNode(final YangInstanceIdentifier yangInstanceIdentifier,
+            final NormalizedNode<?, ?> normalizedNode) {
         NormalizedNode<?,?> pruned = pruneNormalizedNode(yangInstanceIdentifier, normalizedNode);
 
         if (pruned != null) {
@@ -121,12 +124,12 @@ public class PruningDataTreeModification extends ForwardingObject implements Dat
     }
 
     @Override
-    public void applyToCursor(DataTreeModificationCursor dataTreeModificationCursor) {
+    public void applyToCursor(final DataTreeModificationCursor dataTreeModificationCursor) {
         delegate.applyToCursor(dataTreeModificationCursor);
     }
 
     @Override
-    public Optional<NormalizedNode<?, ?>> readNode(YangInstanceIdentifier yangInstanceIdentifier) {
+    public Optional<NormalizedNode<?, ?>> readNode(final YangInstanceIdentifier yangInstanceIdentifier) {
         return delegate.readNode(yangInstanceIdentifier);
     }
 
@@ -136,7 +139,7 @@ public class PruningDataTreeModification extends ForwardingObject implements Dat
     }
 
     @VisibleForTesting
-    NormalizedNode<?, ?> pruneNormalizedNode(YangInstanceIdentifier path, NormalizedNode<?,?> input) {
+    NormalizedNode<?, ?> pruneNormalizedNode(final YangInstanceIdentifier path, final NormalizedNode<?,?> input) {
         NormalizedNodePruner pruner = new NormalizedNodePruner(path, schemaContext);
         try {
             NormalizedNodeWriter.forStreamWriter(pruner).write(input);
@@ -151,14 +154,14 @@ public class PruningDataTreeModification extends ForwardingObject implements Dat
         private final DataTreeModification toModification;
         private final PruningDataTreeModification pruningModification;
 
-        PruningDataTreeModificationCursor(DataTreeModification toModification,
-                PruningDataTreeModification pruningModification) {
+        PruningDataTreeModificationCursor(final DataTreeModification toModification,
+                final PruningDataTreeModification pruningModification) {
             this.toModification = toModification;
             this.pruningModification = pruningModification;
         }
 
         @Override
-        public void write(PathArgument child, NormalizedNode<?, ?> data) {
+        public void write(final PathArgument child, final NormalizedNode<?, ?> data) {
             YangInstanceIdentifier path = current().node(child);
             NormalizedNode<?, ?> prunedNode = pruningModification.pruneNormalizedNode(path, data);
             if (prunedNode != null) {
@@ -167,7 +170,7 @@ public class PruningDataTreeModification extends ForwardingObject implements Dat
         }
 
         @Override
-        public void merge(PathArgument child, NormalizedNode<?, ?> data) {
+        public void merge(final PathArgument child, final NormalizedNode<?, ?> data) {
             YangInstanceIdentifier path = current().node(child);
             NormalizedNode<?, ?> prunedNode = pruningModification.pruneNormalizedNode(path, data);
             if (prunedNode != null) {
@@ -176,7 +179,7 @@ public class PruningDataTreeModification extends ForwardingObject implements Dat
         }
 
         @Override
-        public void delete(PathArgument child) {
+        public void delete(final PathArgument child) {
             try {
                 toModification.delete(current().node(child));
             } catch (SchemaValidationFailedException e) {
index f91dc3b..759410a 100644 (file)
@@ -8,7 +8,6 @@
 
 package org.opendaylight.controller.cluster.sharding;
 
-import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -17,6 +16,7 @@ import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
+import java.util.Optional;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.stream.Collectors;
 import javax.annotation.Nonnull;
@@ -39,10 +39,10 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidates;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeConfiguration;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.ModificationType;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType;
 import org.opendaylight.yangtools.yang.data.impl.schema.tree.InMemoryDataTreeFactory;
 import org.opendaylight.yangtools.yang.data.impl.schema.tree.SchemaValidationFailedException;
 import org.slf4j.Logger;
@@ -70,11 +70,27 @@ public class DistributedShardChangePublisher
         // TODO keeping the whole dataTree thats contained in subshards doesn't seem like a good idea
         // maybe the whole listener logic would be better in the backend shards where we have direct access to the
         // dataTree and wont have to cache it redundantly.
-        this.dataTree = InMemoryDataTreeFactory.getInstance().create(
-                TreeType.valueOf(prefix.getDatastoreType().name()), prefix.getRootIdentifier());
 
-        dataTree.setSchemaContext(distributedDataStore.getActorContext().getSchemaContext());
+        final DataTreeConfiguration baseConfig;
+        switch (prefix.getDatastoreType()) {
+            case CONFIGURATION:
+                baseConfig = DataTreeConfiguration.DEFAULT_CONFIGURATION;
+                break;
+            case OPERATIONAL:
+                baseConfig = DataTreeConfiguration.DEFAULT_OPERATIONAL;
+                break;
+            default:
+                throw new UnsupportedOperationException("Unknown prefix type " + prefix.getDatastoreType());
+        }
+
+        this.dataTree = new InMemoryDataTreeFactory().create(new DataTreeConfiguration.Builder(baseConfig.getTreeType())
+                .setMandatoryNodesValidation(baseConfig.isMandatoryNodesValidationEnabled())
+                .setUniqueIndexes(baseConfig.isUniqueIndexEnabled())
+                .setRootPath(prefix.getRootIdentifier())
+                .build());
 
+        // XXX: can we guarantee that the root is present in the schemacontext?
+        this.dataTree.setSchemaContext(distributedDataStore.getActorContext().getSchemaContext());
         this.shardPath = prefix.getRootIdentifier();
         this.childShards = childShards;
     }
@@ -363,13 +379,13 @@ public class DistributedShardChangePublisher
         @Nonnull
         @Override
         public Optional<NormalizedNode<?, ?>> getDataAfter() {
-            return Optional.absent();
+            return Optional.empty();
         }
 
         @Nonnull
         @Override
         public Optional<NormalizedNode<?, ?>> getDataBefore() {
-            return Optional.absent();
+            return Optional.empty();
         }
     }
 }
index a614f92..dcb74fa 100644 (file)
@@ -8,7 +8,6 @@
 
 package org.opendaylight.controller.cluster.sharding;
 
-import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.util.concurrent.AsyncFunction;
 import com.google.common.util.concurrent.FutureCallback;
@@ -20,6 +19,7 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 import java.util.Map.Entry;
+import java.util.Optional;
 import java.util.stream.Collectors;
 import javax.annotation.Nonnull;
 import org.opendaylight.controller.cluster.databroker.actors.dds.ClientTransaction;
index 4bc117a..8c6723b 100644 (file)
     <argument value="${max-data-broker-future-callback-pool-size}"/>
     <argument value="${max-data-broker-future-callback-queue-size}"/>
     <argument value="CommitFutures"/>
+    <argument>
+    <!-- We should use a more specific class -->
+      <bean factory-ref="operDatastore" factory-method="getClass"/>
+    </argument>
   </bean>
 
   <bean id="commitStatsTracker" class="org.opendaylight.yangtools.util.DurationStatisticsTracker"
index 1961792..57cf9fb 100644 (file)
@@ -19,6 +19,7 @@ import akka.actor.Status;
 import akka.testkit.JavaTestKit;
 import akka.testkit.TestProbe;
 import java.util.Collections;
+import java.util.Optional;
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
@@ -135,7 +136,7 @@ public abstract class AbstractDataStoreClientBehaviorTest {
     public void testGetConnection() throws Exception {
         //set up data tree mock
         final CursorAwareDataTreeModification modification = mock(CursorAwareDataTreeModification.class);
-        when(modification.readNode(YangInstanceIdentifier.EMPTY)).thenReturn(com.google.common.base.Optional.absent());
+        when(modification.readNode(YangInstanceIdentifier.EMPTY)).thenReturn(Optional.empty());
         final DataTreeSnapshot snapshot = mock(DataTreeSnapshot.class);
         when(snapshot.newModification()).thenReturn(modification);
         final DataTree dataTree = mock(DataTree.class);
index d9b1e8e..8162484 100644 (file)
@@ -27,7 +27,7 @@ public class ClientSnapshotTest extends AbstractClientHandleTest<ClientSnapshot>
     @Override
     public void setUp() throws Exception {
         super.setUp();
-        when(getDataTreeSnapshot().readNode(PATH)).thenReturn(Optional.absent());
+        when(getDataTreeSnapshot().readNode(PATH)).thenReturn(java.util.Optional.empty());
     }
 
     @Override
index 5834833..04f706d 100644 (file)
@@ -49,7 +49,7 @@ public class ClientTransactionTest extends AbstractClientHandleTest<ClientTransa
     public void setUp() throws Exception {
         super.setUp();
         when(getDataTreeSnapshot().newModification()).thenReturn(modification);
-        when(modification.readNode(PATH)).thenReturn(Optional.of(DATA));
+        when(modification.readNode(PATH)).thenReturn(java.util.Optional.of(DATA));
     }
 
     @Override
index ba38cfe..1fd82fb 100644 (file)
@@ -13,6 +13,7 @@ import static org.opendaylight.controller.cluster.databroker.actors.dds.TestUtil
 import akka.testkit.TestProbe;
 import com.google.common.base.Ticker;
 import com.google.common.base.VerifyException;
+import java.util.Optional;
 import org.junit.Assert;
 import org.junit.Test;
 import org.opendaylight.controller.cluster.access.commands.AbortLocalTransactionRequest;
@@ -30,8 +31,8 @@ public class LocalReadOnlyProxyTransactionTest extends LocalProxyTransactionTest
     protected LocalReadOnlyProxyTransaction createTransaction(final ProxyHistory parent,
                                                               final TransactionIdentifier id,
                                                               final DataTreeSnapshot snapshot) {
-        when(snapshot.readNode(PATH_1)).thenReturn(com.google.common.base.Optional.of(DATA_1));
-        when(snapshot.readNode(PATH_3)).thenReturn(com.google.common.base.Optional.absent());
+        when(snapshot.readNode(PATH_1)).thenReturn(Optional.of(DATA_1));
+        when(snapshot.readNode(PATH_3)).thenReturn(Optional.empty());
         this.snapshot = snapshot;
         return new LocalReadOnlyProxyTransaction(parent, id, this.snapshot);
     }
index e1daac4..2ecbc9b 100644 (file)
@@ -18,6 +18,7 @@ import static org.opendaylight.controller.cluster.databroker.actors.dds.TestUtil
 import akka.testkit.TestProbe;
 import com.google.common.base.Ticker;
 import com.google.common.util.concurrent.ListenableFuture;
+import java.util.Optional;
 import java.util.function.Consumer;
 import org.junit.Assert;
 import org.junit.Test;
@@ -52,8 +53,8 @@ public class LocalReadWriteProxyTransactionTest extends LocalProxyTransactionTes
                                                                final TransactionIdentifier id,
                                                                final DataTreeSnapshot snapshot) {
         when(snapshot.newModification()).thenReturn(modification);
-        when(modification.readNode(PATH_1)).thenReturn(com.google.common.base.Optional.of(DATA_1));
-        when(modification.readNode(PATH_3)).thenReturn(com.google.common.base.Optional.absent());
+        when(modification.readNode(PATH_1)).thenReturn(Optional.of(DATA_1));
+        when(modification.readNode(PATH_3)).thenReturn(Optional.empty());
         return new LocalReadWriteProxyTransaction(parent, TestUtils.TRANSACTION_ID, snapshot);
     }
 
index 6f7d8fb..f2e0e0a 100644 (file)
@@ -28,7 +28,6 @@ import akka.japi.Creator;
 import akka.pattern.Patterns;
 import akka.testkit.TestActorRef;
 import akka.util.Timeout;
-import com.google.common.base.Optional;
 import com.google.common.primitives.UnsignedLong;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Uninterruptibles;
@@ -36,6 +35,7 @@ import java.io.IOException;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Optional;
 import java.util.Set;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ExecutionException;
@@ -73,11 +73,10 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateTip;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeConfiguration;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.ModificationType;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.TipProducingDataTree;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
 import org.opendaylight.yangtools.yang.data.impl.schema.tree.InMemoryDataTreeFactory;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
@@ -201,9 +200,9 @@ public abstract class AbstractShardTest extends AbstractActorTest {
         Assert.fail(String.format("Expected last applied: %d, Actual: %d", expectedValue, lastApplied));
     }
 
-    protected TipProducingDataTree createDelegatingMockDataTree() throws Exception {
-        TipProducingDataTree actual = InMemoryDataTreeFactory.getInstance().create(TreeType.CONFIGURATION);
-        final TipProducingDataTree mock = mock(TipProducingDataTree.class);
+    protected DataTree createDelegatingMockDataTree() throws Exception {
+        final DataTree actual = new InMemoryDataTreeFactory().create(DataTreeConfiguration.DEFAULT_CONFIGURATION);
+        final DataTree mock = mock(DataTree.class);
 
         doAnswer(invocation -> {
             actual.validate(invocation.getArgumentAt(0, DataTreeModification.class));
@@ -294,7 +293,7 @@ public abstract class AbstractShardTest extends AbstractActorTest {
     }
 
     public static NormalizedNode<?,?> readStore(final DataTree store, final YangInstanceIdentifier id) {
-        return store.takeSnapshot().readNode(id).orNull();
+        return store.takeSnapshot().readNode(id).orElse(null);
     }
 
     public void writeToStore(final TestActorRef<Shard> shard, final YangInstanceIdentifier id,
@@ -341,8 +340,8 @@ public abstract class AbstractShardTest extends AbstractActorTest {
     }
 
     DataTree setupInMemorySnapshotStore() throws DataValidationFailedException {
-        final DataTree testStore = InMemoryDataTreeFactory.getInstance().create(TreeType.OPERATIONAL);
-        testStore.setSchemaContext(SCHEMA_CONTEXT);
+        final DataTree testStore = new InMemoryDataTreeFactory().create(
+            DataTreeConfiguration.DEFAULT_OPERATIONAL, SCHEMA_CONTEXT);
 
         writeToStore(testStore, TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
 
index 96c45f3..a35a901 100644 (file)
@@ -35,11 +35,10 @@ import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeConfiguration;
 import org.opendaylight.yangtool