Merge "neutron now works with jetty"
authorMoiz Raja <moraja@cisco.com>
Wed, 4 Feb 2015 22:31:43 +0000 (22:31 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Wed, 4 Feb 2015 22:31:43 +0000 (22:31 +0000)
217 files changed:
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/action/Action.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/action/ActionType.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/action/Controller.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/action/Drop.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/action/Enqueue.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/action/Flood.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/action/FloodAll.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/action/HwPath.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/action/Loopback.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/action/Output.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/action/PopVlan.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/action/PushVlan.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/action/SetDlDst.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/action/SetDlSrc.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/action/SetDlType.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/action/SetNextHop.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/action/SetNwDst.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/action/SetNwSrc.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/action/SetNwTos.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/action/SetTpDst.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/action/SetTpSrc.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/action/SetVlanCfi.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/action/SetVlanId.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/action/SetVlanPcp.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/action/SupportedFlowActions.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/action/SwPath.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/authorization/AppRole.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/authorization/AppRoleLevel.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/authorization/AuthResultEnum.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/authorization/IResourceAuthorization.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/authorization/Privilege.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/authorization/Resource.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/authorization/ResourceGroup.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/authorization/UserLevel.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/core/AdvertisedBandwidth.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/core/Bandwidth.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/core/Buffers.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/core/Capabilities.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/core/ComponentActivatorAbstractBase.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/core/Config.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/core/ConstructionException.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/core/ContainerFlow.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/core/ContainerServiceDependency.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/core/Description.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/core/Edge.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/core/ForwardingMode.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/core/Host.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/core/IContainer.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/core/IContainerAware.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/core/IContainerListener.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/core/IContainerLocalListener.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/core/Latency.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/core/MacAddress.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/core/Name.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/core/Node.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/core/NodeConnector.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/core/NodeTable.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/core/Path.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/core/PeerBandwidth.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/core/Property.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/core/State.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/core/SupportedBandwidth.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/core/Tables.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/core/Tier.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/core/TimeStamp.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/core/UpdateType.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/discovery/IDiscoveryService.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/flowprogrammer/Flow.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/flowprogrammer/IFlowProgrammerListener.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/flowprogrammer/IFlowProgrammerService.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/flowprogrammer/IPluginInFlowProgrammerService.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/flowprogrammer/IPluginOutFlowProgrammerService.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/inventory/IInventoryService.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/inventory/IListenInventoryUpdates.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/inventory/IPluginInInventoryService.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/inventory/IPluginOutInventoryService.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/match/Match.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/match/MatchField.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/match/MatchType.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/match/extensible/DlDst.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/match/extensible/DlSrc.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/match/extensible/DlType.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/match/extensible/DlVlan.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/match/extensible/DlVlanPriority.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/match/extensible/InPort.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/match/extensible/Match.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/match/extensible/MatchField.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/match/extensible/NwDst.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/match/extensible/NwProtocol.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/match/extensible/NwSrc.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/match/extensible/NwTos.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/match/extensible/TpDst.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/match/extensible/TpSrc.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/packet/ARP.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/packet/BitBufferHelper.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/packet/BufferException.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/packet/Ethernet.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/packet/ICMP.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/packet/IDataPacketService.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/packet/IEEE8021Q.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/packet/IListenDataPacket.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/packet/IPluginInDataPacketService.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/packet/IPluginOutDataPacketService.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/packet/IPv4.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/packet/LLDP.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/packet/LLDPTLV.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/packet/LinkEncap.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/packet/Packet.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/packet/PacketException.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/packet/PacketResult.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/packet/RawPacket.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/packet/TCP.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/packet/UDP.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/packet/address/DataLinkAddress.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/packet/address/EthernetAddress.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/reader/FlowOnNode.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/reader/IPluginInReadService.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/reader/IPluginOutReadService.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/reader/IReadService.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/reader/IReadServiceListener.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/reader/NodeConnectorStatistics.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/reader/NodeDescription.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/reader/NodeTableStatistics.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/routing/IListenRoutingUpdates.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/routing/IRouting.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/topology/IListenTopoUpdates.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/topology/IPluginInTopologyService.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/topology/IPluginOutTopologyService.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/topology/ITopologyService.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/topology/TopoEdgeUpdate.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/utils/ConfigurationObject.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/utils/Direction.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/utils/EtherTypes.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/utils/FilterIterator.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/utils/GUIField.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/utils/GlobalConstants.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/utils/HexEncode.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/utils/IListener.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/utils/INodeConnectorFactory.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/utils/INodeFactory.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/utils/IObjectReader.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/utils/IPProtocols.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/utils/IterableIterator.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/utils/ListenerDispatcher.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/utils/MultiIterator.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/utils/NetUtils.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/utils/NodeConnectorCreator.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/utils/NodeCreator.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/utils/NodeTableCreator.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/utils/ObjectReader.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/utils/ObjectWriter.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/utils/ReadFromFile.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/utils/ServiceHelper.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/utils/SingletonTask.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/utils/Status.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/utils/StatusCode.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/utils/TierHelper.java
opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/utils/WriteToFile.java
opendaylight/archetypes/opendaylight-startup/src/main/resources/archetype-resources/__artifactId__-features/pom.xml
opendaylight/archetypes/opendaylight-startup/src/main/resources/archetype-resources/__artifactId__-impl/pom.xml
opendaylight/md-sal/mdsal-artifacts/pom.xml
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/example/ExampleActor.java
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActor.java
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftVersions.java [new file with mode: 0644]
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/ReplicatedLogImplEntry.java
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/SerializationUtils.java
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/base/messages/CaptureSnapshotReply.java
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/AbstractRaftRPC.java
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/AppendEntries.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/MockRaftActorContext.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/RaftActorTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/ReplicatedLogImplEntryTest.java [new file with mode: 0644]
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/LeaderTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/messages/AppendEntriesTest.java [new file with mode: 0644]
opendaylight/md-sal/sal-akka-raft/src/test/resources/helium-serialized-ReplicatedLogImplEntry [new file with mode: 0644]
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/serialization/ValueSerializer.java
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/serialization/ValueType.java
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/NormalizedNodeInputStreamReader.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/node/utils/stream/ValueTypes.java
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/raft/protobuff/client/messages/CompositeModificationByteStringPayload.java
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/raft/protobuff/client/messages/CompositeModificationPayload.java
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/raft/protobuff/client/messages/Payload.java
opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/serialization/ValueSerializerTest.java
opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/serialization/ValueTypeTest.java
opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/NormalizedNodeStreamReaderWriterTest.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/NoOpTransactionContext.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/ShardReadTransaction.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardRecoveryCoordinator.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardWriteTransaction.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionContext.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionContextImpl.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionProxy.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CreateSnapshot.java [new file with mode: 0644]
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/AbstractModification.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/DeleteModification.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/ImmutableCompositeModification.java [deleted file]
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/MergeModification.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/Modification.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/ModificationPayload.java [new file with mode: 0644]
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/MutableCompositeModification.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/WriteModification.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/SerializationUtils.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/CompositeModificationByteStringPayloadTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/CompositeModificationPayloadTest.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/ShardTransactionTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/DeleteModificationTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/MergeModificationTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/ModificationPayloadTest.java [new file with mode: 0644]
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/MutableCompositeModificationTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/WriteModificationTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/programs/appendentries/Client.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/programs/appendentries/Server.java
opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/listener/PeopleCarListener.java
opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/PeopleProvider.java

index 981b175e197242a0e4347b3407ad3cfc86cb3576..cf303b965eea7aeb92653e0bd74f8a2522f9850e 100644 (file)
@@ -33,6 +33,7 @@ import org.slf4j.LoggerFactory;
  */
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
+@Deprecated
 public abstract class Action implements Serializable {
     private static final long serialVersionUID = 1L;
     private static final Logger logger = LoggerFactory.getLogger(Action.class);
index 8b6d3c4a1cd7fc98d6820562e73068be331e7372..0c059ea9d20e946c110db4c1df0fee6b9d5dcd54 100644 (file)
@@ -11,6 +11,7 @@ package org.opendaylight.controller.sal.action;
  * The enumeration of actions supported by the controller
  * Each entry has a unique id and the values range for the action element where applicable
  */
+@Deprecated
 public enum ActionType {
     DROP("drop", 0, 0),
     LOOPBACK("loopback", 0, 0),
index e7958ce0bc48f6d7ef0166afa480567d0d6b44e9..9de09c5f46cd9dd07383c59b598b5f40507ca83b 100644 (file)
@@ -17,6 +17,7 @@ import javax.xml.bind.annotation.XmlRootElement;
  */
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
+@Deprecated
 public class Controller extends Action {
     private static final long serialVersionUID = 1L;
 
index 2e72f047dba8b187982c109c8e4466a58b4deb51..bfef4c37da8de0cd2f7b49230b8a50d49cebdcae 100644 (file)
@@ -17,6 +17,7 @@ import javax.xml.bind.annotation.XmlRootElement;
  */
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
+@Deprecated
 public class Drop extends Action {
     private static final long serialVersionUID = 1L;
 
index c711e67f9ee33d91831194f05837094c8552de4e..d80e2e7d6851c4dd87cfa8e7eafd1ea363ddec7c 100644 (file)
@@ -17,6 +17,7 @@ import org.opendaylight.controller.sal.core.NodeConnector;
 
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
+@Deprecated
 public class Enqueue extends Action {
     private static final long serialVersionUID = 1L;
     @XmlElement
index ca307e23c64d568e4f5e2b4d867b2a71a03beb63..02f5fe8e153d8741292f5dbb4eeb49caa5149bb9 100644 (file)
@@ -17,6 +17,7 @@ import javax.xml.bind.annotation.XmlRootElement;
  */
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
+@Deprecated
 public class Flood extends Action {
     private static final long serialVersionUID = 1L;
 
index 086f5f2209b2afb7cba53159b3b5910c2ebd590a..a11156f0c4464daa6848e13cd0461edf90599e6f 100644 (file)
@@ -18,6 +18,7 @@ import javax.xml.bind.annotation.XmlRootElement;
  */
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
+@Deprecated
 public class FloodAll extends Action {
     private static final long serialVersionUID = 1L;
 
index 3b11a7cbf0cd8c8e8685cf481e988be858e73f54..56bcd230d99c43126f18f2d238973e04b0837c9d 100644 (file)
@@ -18,6 +18,7 @@ import javax.xml.bind.annotation.XmlRootElement;
  */
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
+@Deprecated
 public class HwPath extends Action {
     private static final long serialVersionUID = 1L;
 
index 05682c3e8f5d57ed1d02cc9423cec97534fa6455..7b3198ab153259627a1960b8eca113ada962ee0f 100644 (file)
@@ -17,6 +17,7 @@ import javax.xml.bind.annotation.XmlRootElement;
  */
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
+@Deprecated
 public class Loopback extends Action {
     private static final long serialVersionUID = 1L;
 
index 5bd9efb30b691ad2775c2687f15538ff2783f332..862f656c6b7ede8309143c8a21d290b98b7c5a36 100644 (file)
@@ -20,6 +20,7 @@ import org.opendaylight.controller.sal.core.NodeConnector;
  */
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
+@Deprecated
 public class Output extends Action {
     private static final long serialVersionUID = 1L;
     @XmlElement
index d0d2a94417a480c13de02ef9f3cab67039658d19..071ec71fed13975420f03c75b2d9c52bc695fb8b 100644 (file)
@@ -17,6 +17,7 @@ import javax.xml.bind.annotation.XmlRootElement;
  */
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
+@Deprecated
 public class PopVlan extends Action {
     private static final long serialVersionUID = 1L;
 
index a1b50edd5116fcc8a451d86ae2dff61d5f2b643e..7c7c585bf4834db91724136dc214927ae5f0c63f 100644 (file)
@@ -23,6 +23,7 @@ import org.opendaylight.controller.sal.utils.EtherTypes;
  */
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
+@Deprecated
 public class PushVlan extends Action {
     private static final long serialVersionUID = 1L;
     private int tag; // TPID - 16 bits
index da6dc93943e3ba6450b43b0995ee6458ee0fe7f0..23d0a226bcd63055c30a88bb210ccfc9e1a5ffc5 100644 (file)
@@ -22,6 +22,7 @@ import org.opendaylight.controller.sal.utils.HexEncode;
  */
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
+@Deprecated
 public class SetDlDst extends Action {
     private static final long serialVersionUID = 1L;
     private byte[] address;
index 2b70535ecfa0c1f2eaa5d6030aa373506767af72..735cda30f4e5a4d830821f419daa006c57fcd79a 100644 (file)
@@ -23,6 +23,7 @@ import org.opendaylight.controller.sal.utils.HexEncode;
  */
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
+@Deprecated
 public class SetDlSrc extends Action {
     private static final long serialVersionUID = 1L;
     private byte[] address;
index 225c4f7821895ff7cbabd35387b44aaac0c1290a..0c8762cbc002c52d79c4d02f2e94eb1cfd01f36e 100644 (file)
@@ -21,6 +21,7 @@ import org.opendaylight.controller.sal.utils.EtherTypes;
 
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
+@Deprecated
 public class SetDlType extends Action {
     private static final long serialVersionUID = 1L;
     @XmlElement
index 3250137c1091572ecebaa2f69e9392128a5696e5..7aa872d68664e5f5fd85468fc6bfdaa46d494561 100644 (file)
@@ -16,6 +16,7 @@ import javax.xml.bind.annotation.XmlRootElement;
 
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
+@Deprecated
 public class SetNextHop extends Action {
     private static final long serialVersionUID = 1L;
     @XmlElement
index db19cd6520879e7da302b43a1697172691f4248a..bff7b358516ff501c212145eede08c6f39a8e9b3 100644 (file)
@@ -21,6 +21,7 @@ import javax.xml.bind.annotation.XmlRootElement;
 
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
+@Deprecated
 public class SetNwDst extends Action {
     private static final long serialVersionUID = 1L;
     InetAddress address;
index dcd56f762a96c393074bc910776dc1a8a194dc85..b3d62bc2c17536d4a84c7c68dc09329e0e096053 100644 (file)
@@ -21,6 +21,7 @@ import javax.xml.bind.annotation.XmlRootElement;
 
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
+@Deprecated
 public class SetNwSrc extends Action {
     private static final long serialVersionUID = 1L;
     InetAddress address;
index e5a85db638d73c7544969e9bb3b5ec77a1df3be3..fcb11f0a73c113845a395b8ea9e2053e0028983d 100644 (file)
@@ -18,6 +18,7 @@ import javax.xml.bind.annotation.XmlRootElement;
  */
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
+@Deprecated
 public class SetNwTos extends Action {
     private static final long serialVersionUID = 1L;
     @XmlElement
index 32cffa57efc3d39d30774f3dd805348250b6c7b6..e352d1542ea6785b9b3a670c2b45bf7cace0796a 100644 (file)
@@ -18,6 +18,7 @@ import javax.xml.bind.annotation.XmlRootElement;
  */
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
+@Deprecated
 public class SetTpDst extends Action {
     private static final long serialVersionUID = 1L;
     @XmlElement
index faa32978c18688305b7daaf72a8dc8c09139c427..fa80c850f737425a9aa2b5ec90f3b6f0d5db0ffa 100644 (file)
@@ -19,6 +19,7 @@ import javax.xml.bind.annotation.XmlRootElement;
  */
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
+@Deprecated
 public class SetTpSrc extends Action {
     private static final long serialVersionUID = 1L;
     @XmlElement
index 0c90fb41fc97e185dc3ff56081f488f4186477aa..e71bb68729205558641b52cb1199c5d783525b7c 100644 (file)
@@ -19,6 +19,7 @@ import javax.xml.bind.annotation.XmlRootElement;
  */
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
+@Deprecated
 public class SetVlanCfi extends Action {
     private static final long serialVersionUID = 1L;
     @XmlElement
index fcc71f32d89da12ce27ad333c2d1f7fa8e1e0897..e06159bde2e7497eccc9758afc85c346aeaca4cf 100644 (file)
@@ -19,6 +19,7 @@ import javax.xml.bind.annotation.XmlRootElement;
 
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
+@Deprecated
 public class SetVlanId extends Action {
     private static final long serialVersionUID = 1L;
     @XmlElement
index 4930d0721d07a9601603a85fd507644e15bd7f30..31afbf3e92393c5dda733e6b0fb9bf682c87b15d 100644 (file)
@@ -18,6 +18,7 @@ import javax.xml.bind.annotation.XmlRootElement;
  */
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
+@Deprecated
 public class SetVlanPcp extends Action {
     private static final long serialVersionUID = 1L;
     @XmlElement
index 0a5d9c82cbe7c69bd1467151357f60c5a4e434bf..4fd65310cfba3d11558dc688a27c5298cefc867f 100644 (file)
@@ -27,6 +27,7 @@ import org.opendaylight.controller.sal.core.Property;
  */
 
 @XmlAccessorType(XmlAccessType.NONE)
+@Deprecated
 public class SupportedFlowActions extends Property {
     private static final long serialVersionUID = 1L;
     public static final String SupportedFlowActionsPropName = "supportedFlowActions";
index 152ad7d48625cf5d3dae43cbe0d21bc886b844d6..e700d25b62e0fb344c27510a8a457f61040935d6 100644 (file)
@@ -18,6 +18,7 @@ import javax.xml.bind.annotation.XmlRootElement;
  */
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
+@Deprecated
 public class SwPath extends Action {
     private static final long serialVersionUID = 1L;
 
index ae867c56d3649d9a1567f14450bc1bb59c1b419d..c36f98163228f19aa0f0d58ebcd24e5695b65e35 100644 (file)
@@ -16,6 +16,7 @@ import java.io.Serializable;
  * It contains the role name and the role level in the
  * application context as specified by {@link AppRoleLevel}
  */
+@Deprecated
 public class AppRole implements Serializable {
     private static final long serialVersionUID = 1L;
     String name;
index 124b495147db61d99b53b24138bf47e5dda4083c..98ac26e5328345a2ad6856d033fbd1e53df5a882 100644 (file)
@@ -17,6 +17,7 @@ import java.io.Serializable;
  * In the controller space such a role will be seen as <code>APPUSER<code>
  * as specified in {@link UserLevel}
  */
+@Deprecated
 public enum AppRoleLevel implements Serializable {
     APPADMIN(0, "App-Admin", "Application Administrator"), APPUSER(1,
             "App-User", "Application User"), APPOPERATOR(2, "App-Operator",
index cbcc2029cdb521addc99cfa93c26a3ef3db30fd1..05801bea292e3f28ad9cfe84224801ca5bfc97f9 100644 (file)
@@ -16,6 +16,7 @@ package org.opendaylight.controller.sal.authorization;
 
 import java.io.Serializable;
 
+@Deprecated
 public enum AuthResultEnum implements Serializable {
     AUTH_NONE("AUTH_NOT_ATTEMPTED"), AUTH_ACCEPT("AUTHENTICATION_ACCEPTED"), // request accepted
     AUTH_REJECT("AUTHENTICATION_REJECTED"), // request rejected
index b7b36fae375aa5dc96444dd1cf7f8a41b878514c..0468ebd75b348aca6135c2692bf08e0abef1f4d0 100644 (file)
@@ -20,6 +20,7 @@ import org.opendaylight.controller.sal.utils.Status;
  * and User Manager make use of this interface to retrieve
  * authorization information at user or and role level.
  */
+@Deprecated
 public interface IResourceAuthorization {
 
     /**
index fb9662366f455f98429e7647044d79caa2bc6417..e3d3217f21cb31f123de560f42b9b29630c0b326 100644 (file)
@@ -14,6 +14,7 @@ import java.io.Serializable;
 /**
  * It represents the group/resource access privilege
  */
+@Deprecated
 public enum Privilege implements Serializable {
     NONE(""), // no privilege
     READ("r"), // read only
index 9cf7420d1b01c7622d7d0576ccb0493456891001..9fa8b2ebb007e16c685ec7f2b2cdc1862d4986f9 100644 (file)
@@ -15,6 +15,7 @@ import java.io.Serializable;
  * It represents the elementary resource along with
  * the access privilege associated to it
  */
+@Deprecated
 public class Resource implements Serializable {
     private static final long serialVersionUID = 1L;
     Object resource; // the generic resource
index 5a2a17f6cf45b18604ce305d2e11fba276b18e33..f5b4448916c99f311a9846284c1c90fd7201b52a 100644 (file)
@@ -17,6 +17,7 @@ import java.io.Serializable;
  *
  *
  */
+@Deprecated
 public class ResourceGroup implements Serializable {
     private static final long serialVersionUID = 1L;
     private String groupName; // the resource group name
index 70b41cdd8aa6b082b28a510d0768ca0fc057bed5..f4db119d7633f5e77b99b78690fa22bb43156629 100644 (file)
@@ -14,6 +14,7 @@ import java.io.Serializable;
 /**
  * Describes the user role level in the controller space
  */
+@Deprecated
 public enum UserLevel implements Serializable {
     SYSTEMADMIN(0, "System-Admin", "System Administrator"),     // can do everything
     NETWORKADMIN(1, "Network-Admin", "Network Administrator"),  // can do everything but setting a system admin user profile
index a0b5c0a18c777d61fb884c3d440762a9193265f2..be42a59ab64cd16fa6df4a51b0f62da09637a259 100644 (file)
@@ -25,6 +25,7 @@ import javax.xml.bind.annotation.XmlRootElement;
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
 @SuppressWarnings("serial")
+@Deprecated
 public class AdvertisedBandwidth extends Bandwidth {
         public static final String AdvertisedBandwidthPropName = "advertisedBandwidth";
 
index 30f27793dea433b8c07defe6335c709024eb8184..4fd962a65b86d44f5864bea62820f83d0d84962f 100644 (file)
@@ -25,6 +25,7 @@ import javax.xml.bind.annotation.XmlRootElement;
  */
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
+@Deprecated
 public class Bandwidth extends Property {
     private static final long serialVersionUID = 1L;
 
index 274b0f481d397795651950b9abc75b7bab0ad0c1..010d9039f774a4ec465501208c3862d4f8881676 100644 (file)
@@ -23,6 +23,7 @@ import javax.xml.bind.annotation.XmlRootElement;
  */
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
+@Deprecated
 public class Buffers extends Property {
         private static final long serialVersionUID = 1L;
     @XmlElement(name="value")
index 147f1b13aedc32e6c3f50ebdf5badcaca010a85b..d6a9458fc0f19b8266bf1924859a2d38488c6a18 100644 (file)
@@ -23,6 +23,7 @@ import javax.xml.bind.annotation.XmlRootElement;
  */
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
+@Deprecated
 public class Capabilities extends Property {
         private static final long serialVersionUID = 1L;
     @XmlElement(name="value")
index 0cd1612808b4a67e8c0eb38c0dec013e4090dee3..eb4ed5f6d113941919ff2da64d10fa18811ef24b 100644 (file)
@@ -40,6 +40,7 @@ import org.slf4j.LoggerFactory;
  * register dependencies per-container
  *
  */
+@Deprecated
 abstract public class ComponentActivatorAbstractBase implements
         BundleActivator, IContainerAware {
     Logger logger = LoggerFactory
index 64562fa6ed9571098edad14c021cafbdd9496f2c..3f5b1734638aa4f9d95c10273932329ecc8a6805 100644 (file)
@@ -21,6 +21,7 @@ import javax.xml.bind.annotation.XmlRootElement;
 @XmlRootElement
 @SuppressWarnings("serial")
 @XmlAccessorType(XmlAccessType.NONE)
+@Deprecated
 public class Config extends Property {
     @XmlElement(name="value")
     private short configValue;
index 446debdc27e818485ce5e399704d904a55b3af05..2dadff7b71e17f7bea99e12c43cd5982130b0fb8 100644 (file)
@@ -19,6 +19,7 @@
  */
 package org.opendaylight.controller.sal.core;
 
+@Deprecated
 public class ConstructionException extends Exception {
     private static final long serialVersionUID = 1L;
 
index 468313c164384befcc5f9477f4a5670609d95caf..aeb9fe718b6c22c58deeed0810f011d8269855ef 100644 (file)
@@ -28,6 +28,7 @@ import org.opendaylight.controller.sal.match.MatchType;
  *
  *
  */
+@Deprecated
 public class ContainerFlow implements Serializable {
     private static final long serialVersionUID = 1L;
     private Match match;
index f37d0133e18ba7d23ce34447b9f102e7c36bee7c..2db83340fcf59f127bd4ba3d272f4159de2c90f1 100644 (file)
@@ -29,6 +29,7 @@ import org.apache.felix.dm.DependencyService;
  * Class representing a ServiceDependency on a container
  *
  */
+@Deprecated
 public class ContainerServiceDependency implements ServiceDependency,
         DependencyActivation {
     private ServiceDependency m_dep;
index 2e3707416a0fccd5636be5e53ddecd3b73cc3e5c..82ac8eb2a23805cac4447b14b5e2ad8a25481fe9 100644 (file)
@@ -18,6 +18,7 @@ import javax.xml.bind.annotation.XmlRootElement;
 @XmlRootElement
 @SuppressWarnings("serial")
 @XmlAccessorType(XmlAccessType.NONE)
+@Deprecated
 public class Description extends Property {
     @XmlElement(name="value")
     private String descriptionValue;
index 0dffee9c474de57797117a218f4aa019e6a33e85..18c38d9cd508aa4393ed130d984681b88ab80035 100644 (file)
@@ -34,6 +34,7 @@ import javax.xml.bind.annotation.XmlRootElement;
  */
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
+@Deprecated
 public class Edge implements Serializable {
     private static final long serialVersionUID = 1L;
     @XmlElement
index ef68e1182722577ba469e53637cbf98865e86dac..312a5981949e52ccc9ee8b5cf348aa0cd8e0c255 100644 (file)
@@ -18,6 +18,7 @@ import javax.xml.bind.annotation.XmlRootElement;
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
 @SuppressWarnings("serial")
+@Deprecated
 public class ForwardingMode extends Property {
     @XmlElement(name="value")
     private final int modeValue;
index 50036372afc041f106009834e676e7ab5f7037d5..3e863ad711c8563eeec711a044ceadec99d922fe 100644 (file)
@@ -21,6 +21,7 @@ import org.opendaylight.controller.sal.packet.address.DataLinkAddress;
 
 @XmlRootElement(name="host")
 @XmlAccessorType(XmlAccessType.NONE)
+@Deprecated
 public class Host implements Serializable {
     private static final long serialVersionUID = 1L;
     @XmlElement
index 6370537762e9d071dbfd6ef44ae853cbb8d40cec..98475d8e30d20ae6d6c71bfe1fc56709a5fe96ea 100644 (file)
@@ -24,6 +24,7 @@ import java.util.Set;
  *
  * Interface used to retrieve the status of a given Container
  */
+@Deprecated
 public interface IContainer {
     /**
      * Returns the Name of the container described
index ce6c00e7c036bbc8b929bbbcdc77df342ab84c13..164db91cd12ace83f270113eab97bc684ea8189d 100644 (file)
@@ -14,6 +14,7 @@ package org.opendaylight.controller.sal.core;
  * created/destroyed
  */
 
+@Deprecated
 public interface IContainerAware {
     /**
      * Method invoked to signal that a container is being created
index 1629c1dd17808e32ec868028d8fbcda77cad4585..ce94ee6de8b1e9e771b6c920589e54348c2458b5 100644 (file)
@@ -24,6 +24,7 @@ package org.opendaylight.controller.sal.core;
  * The interface describes methods used to retrieve the status of a given
  * Container
  */
+@Deprecated
 public interface IContainerListener {
     /**
      * Called to notify a change in the tag assigned to a switch
index eaa3f02b454ed3cf9e54ad5dc0675edda059b3c6..531f111509294ee7c7ab2175a4009e829dc9fca6 100644 (file)
@@ -19,6 +19,7 @@ package org.opendaylight.controller.sal.core;
  * The interface describes methods used to publish the changes to a given
  * Container configuration to listeners on the local cluster node only.
  */
+@Deprecated
 public interface IContainerLocalListener extends IContainerListener {
 
 }
index dbe12a1e0d2fca604981f65c77b855cb40d6677c..677431abcbc67c6a68904ee2b949a9e89adad209 100644 (file)
@@ -23,6 +23,7 @@ import javax.xml.bind.annotation.XmlRootElement;
  */
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
+@Deprecated
 public class Latency extends Property {
     private static final long serialVersionUID = 1L;
 
index 2dfa9168fe91905b52a2312e6f493692fe6d6172..737058a7be07375d596af64336c435841e4b260f 100644 (file)
@@ -20,6 +20,7 @@ import org.opendaylight.controller.sal.utils.HexEncode;
  */
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
+@Deprecated
 public class MacAddress extends Property implements Cloneable {
     private static final long serialVersionUID = 1L;
     @XmlElement(name="value")
index 65c089956a95eb876d21ee3e9f0a169f5b1f1c20..a1d80f28a76289bc9b7357f00f55a1e2603eae23 100644 (file)
@@ -20,6 +20,7 @@ import javax.xml.bind.annotation.XmlRootElement;
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
 @SuppressWarnings("serial")
+@Deprecated
 public class Name extends Property {
     @XmlElement(name="value")
     private String nameValue;
index ecb1f604d5e30c450f8613daf3328ea54f9e220a..be1ed0746a11dac0794f49c33d210788af859f5a 100644 (file)
@@ -41,6 +41,7 @@ import org.opendaylight.controller.sal.utils.ServiceHelper;
  */
 @XmlAccessorType(XmlAccessType.NONE)
 @XmlRootElement
+@Deprecated
 public class Node implements Serializable {
     private static final long serialVersionUID = 1L;
 
index d58be6771bb034d5cf7738b1eaa5c47caa4ec4ce..7b1058a3c9d090c36685a98014e58c3693efeec3 100644 (file)
@@ -42,6 +42,7 @@ import org.opendaylight.controller.sal.utils.ServiceHelper;
  */
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
+@Deprecated
 public class NodeConnector implements Serializable {
     private static final long serialVersionUID = 1L;
     public static final Short SPECIALNODECONNECTORID = (short) 0;
index 349e68d98d56eb5bc99c58060973508cf24883c8..7df20e4dcc3cc78d6820871e02d815bf24e14a62 100644 (file)
@@ -19,6 +19,7 @@ import javax.xml.bind.annotation.XmlRootElement;
 
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
+@Deprecated
 public class NodeTable implements Serializable {
 
     private static final long serialVersionUID = 1L;
index 3a4a192fc9b86c3df90576b393f7c23222974899..6049cee25684edbcbda3026b72bfd450dcac514f 100644 (file)
@@ -36,6 +36,7 @@ import javax.xml.bind.annotation.XmlRootElement;
  */
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
+@Deprecated
 public class Path implements Serializable {
     private static final long serialVersionUID = 1L;
     @XmlElement
index d01e528b57d0a54ecdf5982a105ffd11419b1811..3e448e45c6d687add1df5ef7e0958c9b54e55a0d 100644 (file)
@@ -23,6 +23,7 @@ import javax.xml.bind.annotation.XmlRootElement;
  */
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
+@Deprecated
 public class PeerBandwidth extends Bandwidth {
         private static final long serialVersionUID = 1L;
 
index 4af117ccf7243acd11950fbe0cf9f0d9d563fb3f..fe35ea5d325c6fa982a70c37806174d03e73e43a 100644 (file)
@@ -30,6 +30,7 @@ import javax.xml.bind.annotation.XmlRootElement;
  */
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
+@Deprecated
 abstract public class Property implements Serializable, Cloneable {
     private static final long serialVersionUID = 1L;
     private final String name;
index d74f7183deeac4c88cb822df21c3547d1c78e00d..4bda5000387a656b2c50c2c0119789777de5b875 100644 (file)
@@ -22,6 +22,7 @@ import javax.xml.bind.annotation.XmlRootElement;
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
 @SuppressWarnings("serial")
+@Deprecated
 public class State extends Property {
     @XmlElement(name="value")
     private short stateValue;
index 7bcc0e01aa7f922af538e688b18a0331199fe859..842104ff32eeb8f8d224ea6a461106ac71596eb3 100644 (file)
@@ -24,6 +24,7 @@ import javax.xml.bind.annotation.XmlRootElement;
  */
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
+@Deprecated
 public class SupportedBandwidth extends Bandwidth {
         private static final long serialVersionUID = 1L;
         public static final String SupportedBandwidthPropName = "supportedBandwidth";
index 724c8427f6edbe0003ed202930d0267cba04ede4..99a366119a22e7812982daa6c864bc5068b3064e 100644 (file)
@@ -23,6 +23,7 @@ import javax.xml.bind.annotation.XmlRootElement;
  */
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
+@Deprecated
 public class Tables extends Property {
         private static final long serialVersionUID = 1L;
     @XmlElement(name="value")
index 33c87db650404f9ca6b79c69e8703844ff047172..2e76e50c2253a2514155fd8015d2b98efcde0c37 100644 (file)
@@ -22,6 +22,7 @@ import javax.xml.bind.annotation.XmlRootElement;
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
 @SuppressWarnings("serial")
+@Deprecated
 public class Tier extends Property {
     @XmlElement(name="value")
     private int tierValue;
index 67f2b25bd272a67027a91174163d1b372dc41bb0..288f7657cd1e247d4f02d2640609c56bccfdac22 100644 (file)
@@ -28,6 +28,7 @@ import javax.xml.bind.annotation.XmlRootElement;
  */
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
+@Deprecated
 public class TimeStamp extends Property {
     private static final long serialVersionUID = 1L;
     @XmlElement(name = "value")
index 6642eaf44bb1a489d8ab06cb3717c980b251ff89..99a21a85a21860ae5f38350a6e4d7a8c4c6e7d53 100644 (file)
@@ -16,6 +16,7 @@ package org.opendaylight.controller.sal.core;
  * @brief  Describes update types
  *
  */
+@Deprecated
 public enum UpdateType {
     ADDED("added"), REMOVED("removed"), CHANGED("changed");
 
index f640ac2a33f80db4ea24dfbed440c5bb69e7b1ed..26e9ab596d041a43dbda94e9ab9a6cfa1f113888 100644 (file)
@@ -19,6 +19,7 @@ import org.opendaylight.controller.sal.core.UpdateType;
  * The interface provides the methods to notify the listener when an edge is
  * added/deleted/changed.
  */
+@Deprecated
 public interface IDiscoveryService {
     /**
      * The methods is called when an edge is added/deleted/changed
index a823864a67ad07f9ed055633e5c2ed7b1c9f48c7..85057935fe370f6fd1b6b4c332000b7e5c5fd277 100644 (file)
@@ -33,6 +33,7 @@ import java.util.List;
  */
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
+@Deprecated
 public class Flow implements Cloneable, Serializable {
     protected static final Logger logger = LoggerFactory.getLogger(Flow.class);
     private static final long serialVersionUID = 1L;
index c7eace3c98d41d5494285725e8ed2b5e9739c6db..c8aed91bc614b98b0924984ac2e5e1460a6568a5 100644 (file)
@@ -13,6 +13,7 @@ package org.opendaylight.controller.sal.flowprogrammer;
  * functional modules the asynchronous messages related to flow programming
  * coming from the network nodes.
  */
+@Deprecated
 public interface IFlowProgrammerListener extends IPluginOutFlowProgrammerService {
 
 }
index 0b38dda8cb6c4e8f02ee97494fd8bd201a4efeb4..de4c25e188c84ee54f304385c0a5bec0b83d4795 100644 (file)
@@ -15,6 +15,7 @@ import org.opendaylight.controller.sal.utils.Status;
  * Interface that defines the methods available to the functional modules above
  * SAL for installing/modifying/removing flows on a network node
  */
+@Deprecated
 public interface IFlowProgrammerService {
     /**
      * Synchronously add a flow to the network node
index dacec15d79534e418533197076b7c8594a2b4f4b..63481eee2ad2132ef64f513d8456dae62126888f 100644 (file)
@@ -15,6 +15,7 @@ import org.opendaylight.controller.sal.utils.Status;
  * This interface defines the flow programmer methods to be implemented by
  * protocol plugins
  */
+@Deprecated
 public interface IPluginInFlowProgrammerService {
     /**
      * Synchronously add a flow to the network node
index 1fc6741611495b42eb2beb3ad89e39f1103db117..83f45d46fde1bf2cf7a18bea3a3d1b156c610967 100644 (file)
@@ -15,6 +15,7 @@ import org.opendaylight.controller.sal.core.Node;
  * inform the SAL layer about the asynchronous messages related to flow
  * programming coming from the network nodes.
  */
+@Deprecated
 public interface IPluginOutFlowProgrammerService {
     /**
      * Inform SAL that the flow on the specified node has been removed Consumer
index fa3afd817301e46a2c5753cfcb8afb3d74c8036b..32eb232df25564971771cf861f58e5e6143a71fd 100644 (file)
@@ -21,6 +21,7 @@ import org.opendaylight.controller.sal.core.Property;
  * The Interface describes methods invoked from application toward SAL to
  * solicit existing inventory data.
  */
+@Deprecated
 public interface IInventoryService {
     /**
      * The method retrieves all the existing nodes and properties attached
index 0438023165a18293fa522041d1bf9fd3d6eb7da6..768d90c5c56868a389354e010c36bd1922698060 100644 (file)
@@ -20,6 +20,7 @@ import org.opendaylight.controller.sal.core.UpdateType;
  * The interface provides the methods to notify the upper applications in
  * regards to any inventory changes.
  */
+@Deprecated
 public interface IListenInventoryUpdates {
     /**
      * This method is called when some properties of a node are added/deleted/changed.
index 4007dc86e78974d7d36dc7540b4a3fc044d48fdc..203c411cca0f5dc47ea480eade18d14138b95e7d 100644 (file)
@@ -21,6 +21,7 @@ import org.opendaylight.controller.sal.core.Property;
  * The Interface describes methods invoked from SAL toward the protocol plugin
  * to solicit existing inventory data.
  */
+@Deprecated
 public interface IPluginInInventoryService {
     /**
      * The method retrieves all the existing nodes and properties attached
index bda32b88fa8796583b32019fc3f057b9ceff5ad4..56a0388b7b52ca8142d52ff71a7e033f7d0249ef 100644 (file)
@@ -20,6 +20,7 @@ import org.opendaylight.controller.sal.core.UpdateType;
  * The Interface describes Inventory update methods to be implemented by
  * protocol plugin.
  */
+@Deprecated
 public interface IPluginOutInventoryService {
     /**
      * This method is called when some properties of a node are added/deleted/changed.
index a00c3dcb3422d6e20c619bd35d616b62fb6bbab3..47f70b7005772ce7e241e70dd168db54cfd570ac 100644 (file)
@@ -41,6 +41,7 @@ import org.opendaylight.controller.sal.utils.NetUtils;
  */
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
+@Deprecated
 public class Match implements Cloneable, Serializable {
         private static final long serialVersionUID = 1L;
         private static final Map<MatchType, MatchType> reversableMatches;
index 554d7e2fb3df93564cc7575fe6a83486deaa131f..05e8462cdd20250f95ae3725c8ab84ea7d0fb3cd 100644 (file)
@@ -25,6 +25,7 @@ import org.slf4j.LoggerFactory;
 
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
+@Deprecated
 public class MatchField implements Cloneable, Serializable {
     private static final long serialVersionUID = 1L;
     private static final Logger logger = LoggerFactory.getLogger(MatchField.class);
index 800f6d5972bc257c8aecf1ad14b0d650b3797641..05baa213d5274ff70db5ffc33ed3bb2bdadd3795 100644 (file)
@@ -21,6 +21,7 @@ import org.opendaylight.controller.sal.utils.NetUtils;
  * values of the elements type that can be matched on the network
  * frame/packet/message
  */
+@Deprecated
 public enum MatchType {
     IN_PORT("inPort", 1 << 0, NodeConnector.class, 1, 0),
     DL_SRC("dlSrc", 1 << 1, Byte[].class, 0, 0xffffffffffffL),
index 381de8e23ade1d0777abc2ccbfb13473817e2539..b5c154d619e4516d94f903ea12bbde3c6c56e8c4 100644 (file)
@@ -12,6 +12,7 @@ import org.opendaylight.controller.sal.utils.NetUtils;
 
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
+@Deprecated
 public class DlDst extends MatchField<byte[]> {
     private static final long serialVersionUID = 1L;
     public static final String TYPE = "DL_DST";
index 962c4d38e99c64049c0bafc0ecf022c593d8317d..0248073f192b5b6e833554927d74e6ea5073b7ad 100644 (file)
@@ -12,6 +12,7 @@ import org.opendaylight.controller.sal.utils.NetUtils;
 
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
+@Deprecated
 public class DlSrc extends MatchField<byte[]> {
     private static final long serialVersionUID = 1L;
     public static final String TYPE = "DL_SRC";
index 468703d5522d7102136be1b04ad7498c5feeab16..e2433aa23a16845cd1af86acf455daac0673f180 100644 (file)
@@ -10,6 +10,7 @@ import org.opendaylight.controller.sal.utils.NetUtils;
 
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
+@Deprecated
 public class DlType extends MatchField<Short> {
     private static final long serialVersionUID = 1L;
     public static final String TYPE = "DL_TYPE";
index 30657a90bf996eb6edf868ccdc9d955059d227a9..bde32573f00d5b2ff0a226e9805c532ec032d25c 100644 (file)
@@ -8,6 +8,7 @@ import javax.xml.bind.annotation.XmlRootElement;
 
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
+@Deprecated
 public class DlVlan extends MatchField<Short> {
     private static final long serialVersionUID = 1L;
     public static final String TYPE = "DL_VLAN";
index 58dd5639a229c3bbf5b250c1047d1f1400f2457c..d899d643237f6af4eb1ddc21ea3663fe8bdca4c0 100644 (file)
@@ -9,6 +9,7 @@ import org.opendaylight.controller.sal.utils.NetUtils;
 
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
+@Deprecated
 public class DlVlanPriority extends MatchField<Byte> {
     private static final long serialVersionUID = 1L;
     public static final String TYPE = "DL_VLAN_PR";
index 2b5eb5b574ec966749997a03bef9f12da44eb62b..a0b899e524b7c4152154a394b293b1ab2d6801fb 100644 (file)
@@ -9,6 +9,7 @@ import org.opendaylight.controller.sal.core.NodeConnector;
 
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
+@Deprecated
 public class InPort extends MatchField<NodeConnector> {
     private static final long serialVersionUID = 1L;
     public static final String TYPE = "IN_PORT";
index b065444c53b873d9e176591caed47f12b87244db..7f4ddd00061ec47fe901b0c2ea430bc3ec8fbd5c 100644 (file)
@@ -37,6 +37,7 @@ import org.opendaylight.controller.sal.utils.NetUtils;
  */
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
+@Deprecated
 public class Match implements Cloneable, Serializable {
         private static final long serialVersionUID = 1L;
     private Map<String, MatchField<?>> fields;
index e7a5de38500533cc772234d659a7de8f977218f5..8b9a71b950230df3fd2297abc24538c99aee6a60 100644 (file)
@@ -20,6 +20,7 @@ import javax.xml.bind.annotation.XmlRootElement;
  */
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
+@Deprecated
 public abstract class MatchField<T> implements Cloneable, Serializable {
     private static final long serialVersionUID = 1L;
     private String type;
index 42b6ba6cc0c0c2adf7c35bb9adaafe7a4fe31673..4026bc2293f4b220184dac2984c4575d53bdc8c4 100644 (file)
@@ -13,6 +13,7 @@ import org.opendaylight.controller.sal.utils.NetUtils;
 
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
+@Deprecated
 public class NwDst extends MatchField<InetAddress> {
     private static final long serialVersionUID = 1L;
     public static final String TYPE = "NW_DST";
index c5b531590217fddb54f9d7306173611266ccbd31..ecaeff16e5b66a80940a93c86aadb4ec3fbccb31 100644 (file)
@@ -9,6 +9,7 @@ import org.opendaylight.controller.sal.utils.NetUtils;
 
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
+@Deprecated
 public class NwProtocol extends MatchField<Byte> {
     private static final long serialVersionUID = 1L;
     public static final String TYPE = "NW_PROTO";
index 4da43f53a04adbc5c1879b97f39e718dcea9e651..e74b51326eb0a28dee87c3ed0a43b959dae33939 100644 (file)
@@ -13,6 +13,7 @@ import org.opendaylight.controller.sal.utils.NetUtils;
 
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
+@Deprecated
 public class NwSrc extends MatchField<InetAddress> {
     private static final long serialVersionUID = 1L;
     public static final String TYPE = "NW_SRC";
index ba5b562bd279382a591d2ab053e3559c9ee3e74c..95137ae07051e5be79788bbf5951bfa78e9893f1 100644 (file)
@@ -9,6 +9,7 @@ import org.opendaylight.controller.sal.utils.NetUtils;
 
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
+@Deprecated
 public class NwTos extends MatchField<Byte> {
     private static final long serialVersionUID = 1L;
     public static final String TYPE = "NW_TOS";
index 022db4cc174648b4ac127dec22032e466d2d4739..3e698d8d3e0db331c35bb3818f29b212edb5db6e 100644 (file)
@@ -9,6 +9,7 @@ import org.opendaylight.controller.sal.utils.NetUtils;
 
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
+@Deprecated
 public class TpDst extends MatchField<Short> {
     private static final long serialVersionUID = 1L;
     public static final String TYPE = "TP_DST";
index 1c93d1e8475ca7837027897fbfe11f80b1993e09..d3e84270a56f5e5f4a14c8b5d2c0a5b271c6115a 100644 (file)
@@ -9,6 +9,7 @@ import org.opendaylight.controller.sal.utils.NetUtils;
 
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
+@Deprecated
 public class TpSrc extends MatchField<Short> {
     private static final long serialVersionUID = 1L;
     public static final String TYPE = "TP_SRC";
index 21c17b366c04c025683b5c032981f043428e326a..3c9e9b6a6c2a7f8e318aa88b75690fc078b9ec80 100644 (file)
@@ -21,7 +21,7 @@ import org.apache.commons.lang3.tuple.Pair;
  *
  *
  */
-
+@Deprecated
 public class ARP extends Packet {
     private static final String HWTYPE = "HardwareType";
     private static final String PTYPE = "ProtocolType";
index 5bf57a55c390da3dbf64fdbf2b6b9de9cf3bcb0d..176e446e98260a748a2c7e07d6bb843293a98365 100644 (file)
@@ -24,6 +24,7 @@ import org.slf4j.LoggerFactory;
  * - store bits in specified location in stream of bits
  * - convert primitive data types to stream of bits
  */
+@Deprecated
 public abstract class BitBufferHelper {
     protected static final Logger logger = LoggerFactory
     .getLogger(BitBufferHelper.class);
index 655147d7478d13a53064500bc2d03a3eef0e5890..63fd4ec8d14324da3532f482ef90bd177f0778f2 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.controller.sal.packet;
 /**
  * Describes an exception that is raised during BitBufferHelper operations.
  */
+@Deprecated
 public class BufferException extends Exception {
     private static final long serialVersionUID = 1L;
 
index 235e71a760faa01eb9cf9d2acf92a73c8acf00ce..a7ffbe7926118eda912a4e9ca880f718b8ad65b2 100644 (file)
@@ -23,6 +23,7 @@ import org.opendaylight.controller.sal.utils.NetUtils;
 /**
  * Class that represents the Ethernet frame objects
  */
+@Deprecated
 public class Ethernet extends Packet {
     private static final String DMAC = "DestinationMACAddress";
     private static final String SMAC = "SourceMACAddress";
index 987394402d7157f44a011c3d16ab77308855d8a6..79d6f6014f76c1ebccddfa78f740b2a0dd0389bc 100644 (file)
@@ -20,7 +20,7 @@ import org.opendaylight.controller.sal.utils.NetUtils;
 /**
  * Class that represents the ICMP packet objects
  */
-
+@Deprecated
 public class ICMP extends Packet {
     private static final String TYPE = "Type";
     private static final String CODE = "Code";
index c430518dd9e8d29eb90b0e52add4f6a0c2c161ab..41937b25372805fdc4cb9c65d620a9d0b4dfd1e0 100644 (file)
@@ -19,6 +19,7 @@ package org.opendaylight.controller.sal.packet;
 /**
  * Data Packet Services SAL provides to the components
  */
+@Deprecated
 public interface IDataPacketService {
     /**
      * Transmit a data Packet. Transmission will ONLY happen if the
index 4c0c94ccb82a50d5027b1be6ea23718939cc3a28..196d87f3cdb26627d681919da0df8af287c77f52 100644 (file)
@@ -20,6 +20,7 @@ import org.opendaylight.controller.sal.match.MatchType;
 /**
  * Class that represents the IEEE 802.1Q objects
  */
+@Deprecated
 public class IEEE8021Q extends Packet {
     private static final String PCP = "PriorityCodePoint";
     private static final String CFI = "CanonicalFormatIndicator";
index 76e2a6fbfeafbef703db05c950418f8c176f9178..a64de5b97a1aeba11f3ded6cd62e89777407bfd8 100644 (file)
@@ -51,6 +51,7 @@ package org.opendaylight.controller.sal.packet;
  * incoming DataPacket match the filter. If no filter is provided, the
  * handler is called for EVERY packet i.e. match All is implied!
  */
+@Deprecated
 public interface IListenDataPacket {
     /**
      * Handler for receiving the packet. The application can signal
index 8252715ab7885c0291b06639d3d5409c1294b4cb..863ed68cc9f8d2144ed1c74a4ddb743374d82110 100644 (file)
@@ -24,6 +24,7 @@ package org.opendaylight.controller.sal.packet;
  * - "protocoloPluginType"
  * the value of the property will org.opendaylight.controller.sal.core.Node.NodeIDType
  */
+@Deprecated
 public interface IPluginInDataPacketService {
     /**
      * Transmit a data Packet. Packet will go out ONLY if the packet
index 10667fdac8a79cb08333a584e80c92fbfb3e753e..d8852feed68a8cebf9c1ea2e4e98c5b15daeb4bd 100644 (file)
@@ -23,6 +23,7 @@ package org.opendaylight.controller.sal.packet;
  * Interface used by SAL to intercept any Data Packet coming from the
  * southbound protocol plugins
  */
+@Deprecated
 public interface IPluginOutDataPacketService {
     /**
      * Handler for receiving the packet. The SAL layer can signal back
index 56793c41f6ef624efedd743b9682bb13bede8018..148f3512e8f473319dfbcf91dd7befea902d6ac7 100644 (file)
@@ -30,7 +30,7 @@ import org.slf4j.LoggerFactory;
 /**
  * Class that represents the IPv4  packet objects
  */
-
+@Deprecated
 public class IPv4 extends Packet {
     protected static final Logger logger = LoggerFactory
             .getLogger(IPv4.class);
index 9b5dc082bb2303084775026131a11552b5614add..1f20e855564bbe41bbc6e2c83604ac1de1ecd63a 100644 (file)
@@ -19,7 +19,7 @@ import org.opendaylight.controller.sal.utils.NetUtils;
 /**
  * Class that represents the LLDP frame objects
  */
-
+@Deprecated
 public class LLDP extends Packet {
     private static final String CHASSISID = "ChassisId";
     private static final String SYSTEMNAMEID = "SystemNameID";
index 35244ea697d871617b09db6e232da95af0d51ebf..f03704caba28172fb18e87b1d6223b29d9dd0b7d 100644 (file)
@@ -23,7 +23,7 @@ import org.opendaylight.controller.sal.utils.NetUtils;
 /**
  * Class that represents the LLDPTLV objects
  */
-
+@Deprecated
 public class LLDPTLV extends Packet {
     private static final String TYPE = "Type";
     private static final String LENGTH = "Length";
index 6d295dddb9b0ee7b3e204f1068749bdb0f6fed2d..3c756946667013cd7d325b161f3cafd21e4dce4c 100644 (file)
@@ -19,6 +19,7 @@ package org.opendaylight.controller.sal.packet;
 /**
  * Describe a packet data link format
  */
+@Deprecated
 public enum LinkEncap {
     ETHERNET
 }
index 789aa126533c93c16660e5eafcfc995dc510fab1..45e3142e989a84a871010400df23fd23a28e4670 100644 (file)
@@ -24,7 +24,7 @@ import org.slf4j.LoggerFactory;
  * the basic methods which are common for all the packets, like serialize and
  * deserialize
  */
-
+@Deprecated
 public abstract class Packet {
     protected static final Logger logger = LoggerFactory
             .getLogger(Packet.class);
index 5685b0a58af2e16300104e9ccd7f482b311ec0be..14e1bbb6788ac170ce37cb1e6788a5663abb0dfe 100644 (file)
@@ -13,6 +13,7 @@ package org.opendaylight.controller.sal.packet;
  * packet/stream is malformed.
  *
  */
+@Deprecated
 public class PacketException extends Exception {
     private static final long serialVersionUID = 1L;
 
index c2926579ebb72c5faaef8c3e8cc1db1efd3cb02c..3583bd1f48309f02bba6afb2970de764add204fb 100644 (file)
@@ -18,6 +18,7 @@ package org.opendaylight.controller.sal.packet;
  * Possible results for Data packet processing handler
  *
  */
+@Deprecated
 public enum PacketResult {
     /**
      * Packet has been processed and noone in the chain after us is
index 590f5d923e792f03f4abc8498bd405c64e770204..2241774da527a05897bdc7765f2f265f7aefaadd 100644 (file)
@@ -29,6 +29,7 @@ import org.opendaylight.controller.sal.core.TimeStamp;
  * and how it will be transmitted. It essentially wraps the raw bytestream
  *
  */
+@Deprecated
 public class RawPacket {
     private byte[] packetData;
     private final LinkEncap encap;
index d27494599c280418044e4ef78210678562852cc0..91cd93ee52cb3c232fb039dc580e9acb582d230f 100644 (file)
@@ -21,6 +21,7 @@ import org.opendaylight.controller.sal.match.MatchType;
 /**
  * Class that represents the TCP segment objects
  */
+@Deprecated
 public class TCP extends Packet {
 
     public static final String SRCPORT = "SourcePort";
index 069a277f89d9ee44df2e4ca22d9783fb9b9a6404..4c7e0ffce82f49dfd202acd327aca700da85b111 100644 (file)
@@ -21,7 +21,7 @@ import org.opendaylight.controller.sal.match.MatchType;
 /**
  * Class that represents the UDP datagram objects
  */
-
+@Deprecated
 public class UDP extends Packet {
 
     private static final String SRCPORT = "SourcePort";
index dba2f37315daf39b1921cb9875bb185e8ddc9f78..3e75993cc81f6c132e45de2a06508ed8b726f9c6 100644 (file)
@@ -25,6 +25,7 @@ import javax.xml.bind.annotation.XmlRootElement;
  *
  */
 @XmlRootElement
+@Deprecated
 abstract public class DataLinkAddress implements Serializable {
     private static final long serialVersionUID = 1L;
     private String name;
index bd1949f380545a85c3bbf27bb874ae0c761f62da..731a731bbb28d591f7910ce3e305a63aebbb7bca 100644 (file)
@@ -22,6 +22,7 @@ import org.opendaylight.controller.sal.utils.HexEncode;
 
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
+@Deprecated
 public class EthernetAddress extends DataLinkAddress {
     private static final long serialVersionUID = 1L;
     @XmlTransient
index 994ee4533e077ab3ad74e65f08306d10a9910320..bcd404eaedcaad5a293e9578bfde1f65b50f77de 100644 (file)
@@ -25,6 +25,7 @@ import org.opendaylight.controller.sal.flowprogrammer.Flow;
 
 @XmlRootElement (name="FlowStat")
 @XmlAccessorType(XmlAccessType.NONE)
+@Deprecated
 public class FlowOnNode implements Serializable{
     private static final long serialVersionUID = 1L;
 
index e9efd382da09c35274c25cc613b6dd1c92fc8c5b..edaee5f35e67cf012a842791fddb9552eb4120a2 100644 (file)
@@ -19,6 +19,7 @@ import org.opendaylight.controller.sal.flowprogrammer.Flow;
 /**
  * The interface defines hardware view read methods to be implemented by protocol plugins
  */
+@Deprecated
 public interface IPluginInReadService {
 
     /**
index f6e92ad1a902877358166682df5893438f74e9aa..e5baa408b87c5ea71a710ad189c028732524b198 100644 (file)
@@ -17,6 +17,7 @@ import org.opendaylight.controller.sal.core.Node;
  * The interface defines hardware statistics updates service to be offered by
  * protocol plugins
  */
+@Deprecated
 public interface IPluginOutReadService {
 
     /**
index c3af91dd345035549e5138dbf4c1fd788ca18f35..d25a6f62f06aed3d1bd44f111a746653c09a9bb8 100644 (file)
@@ -20,6 +20,7 @@ import org.opendaylight.controller.sal.flowprogrammer.Flow;
  * This interface defines methods for retrieving the network node's
  * flow/port/queue hardware view
  */
+@Deprecated
 public interface IReadService {
     /**
      * Get the hardware view for the specified flow on the specified network
index 2c100643830035a7c02c097d346dd867e4e1cb4d..01eaf1eb371a38041b2851bded141332650cbb98 100644 (file)
@@ -11,6 +11,7 @@ package org.opendaylight.controller.sal.reader;
  * The interface describes SAL service to be consumed by functional modules that
  * are interested in reader updates
  */
+@Deprecated
 public interface IReadServiceListener extends IPluginOutReadService {
 
 }
index fc6a6d87f1c39139c9b29f1a55c060b53f78451d..1ef2fd5cb1205bedba5efac1fd7ec09868f5c52d 100644 (file)
@@ -22,6 +22,7 @@ import org.opendaylight.controller.sal.core.NodeConnector;
  */
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
+@Deprecated
 public class NodeConnectorStatistics implements Serializable {
     private static final long serialVersionUID = 1L;
 
index 12ce4d69482b3f32a61b3aade2b79079aa130f6d..afcd02ece9b0680722ca48b537c676fd9140786a 100644 (file)
@@ -15,6 +15,7 @@ import java.io.Serializable;
 /**
  * Represents the network node description information
  */
+@Deprecated
 public class NodeDescription implements Serializable, Cloneable{
     private static final long serialVersionUID = 1L;
 
index e4c3961a140da41ff0078c893fe198677c2353b7..e85bfd4da7d60705b3caa455714aab4998c81b3c 100644 (file)
@@ -24,6 +24,7 @@ import org.opendaylight.controller.sal.core.NodeTable;
 
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
+@Deprecated
 public class NodeTableStatistics implements Serializable {
     private static final long serialVersionUID = 1L;
 
index dde65108b1ef68c6c1ea3e950fc0312b714297d7..dd2262b2be5fd5dc7648ea258d27bfd3cb731b89 100644 (file)
@@ -14,7 +14,7 @@ package org.opendaylight.controller.sal.routing;
  * know events published by the routing engine
  *
  */
-
+@Deprecated
 public interface IListenRoutingUpdates {
     /**
      * Method invoked when the recalculation of the all shortest path
index d06dce6576014be4e3e1334067d91c3db56283af..b50f6169086a8979a56476b717296abcaa6eb16f 100644 (file)
@@ -19,6 +19,7 @@ import org.opendaylight.controller.sal.core.Path;
  * This interface provides APIs to manage and query the routing information
  *
  */
+@Deprecated
 public interface IRouting {
 
     /**
index 6850cc6373d0263fdb108bf35b652667c56fa1e0..3895993be5965f5c8f1fc5a5529bbeaa0b5dbafd 100644 (file)
@@ -19,6 +19,7 @@ import org.opendaylight.controller.sal.core.Edge;
  * registry. This interface (on a per-container base) and SAL will call it
  * providing the update.
  */
+@Deprecated
 public interface IListenTopoUpdates {
     /**
      * Called to update on Edge in the topology graph
index 3744d8099fc2e39dbccc1da0c7a772ae738fa318..35e0872b016c62534f9493e88b623c377157066b 100644 (file)
@@ -26,6 +26,7 @@ package org.opendaylight.controller.sal.topology;
  * plugin to sollicit Topoloy updates
  *
  */
+@Deprecated
 public interface IPluginInTopologyService {
     /**
      * Tell to protocol plugin that is time to send the updates of the
index 32851e86f6236cf6932ce982a504d7626caf5d2b..42d1a5e2c60b7d80e158d4d26ea78119cfb60d04 100644 (file)
@@ -17,6 +17,7 @@ import org.opendaylight.controller.sal.core.Edge;
  * this service provided by SAL so the update can migrate upward toward the
  * applications.
  */
+@Deprecated
 public interface IPluginOutTopologyService {
 
     /**
index c9b7a0189e7d0e82645ee4e0df7bdc4ee0ac8843..ffad2378ddc64190aa872512a6e4c5d694f28aa9 100644 (file)
@@ -22,6 +22,7 @@ package org.opendaylight.controller.sal.topology;
 /**
  * Topology methods provided by SAL toward the applications
  */
+@Deprecated
 public interface ITopologyService {
     /**
      * Tell to SAL that is time to send the updates of the
index f972ae6a6679b9b1d4cc55afe39a63b276d17ce0..90596bdb6bb0b753d38891d538f99a7cff42af4c 100644 (file)
@@ -18,6 +18,7 @@ import org.opendaylight.controller.sal.core.UpdateType;
  * The class represents an Edge, the Edge's Property Set and its UpdateType.
  * If update is on new properties added to an existing edge, appropriate type is CHANGED.
  */
+@Deprecated
 public class TopoEdgeUpdate {
     private Edge edge;
     private Set<Property> props;
index 2488c754b89e3d427c695f9caf9f147a9f0fb9b5..8f482283c092e7db0ee8e53417b58692efba74d1 100644 (file)
@@ -13,6 +13,7 @@ package org.opendaylight.controller.sal.utils;
  * This interface defines the methods for configuration object
  *
  */
+@Deprecated
 public interface ConfigurationObject {
 
 }
index 8541210614066e5b65bd406d8ff502886d732285..095997156a9cc1d0e3b079d178da31a8b60c7d14 100644 (file)
@@ -17,6 +17,7 @@ import java.io.Serializable;
  *
  *
  */
+@Deprecated
 public enum Direction implements Serializable {
     FORWARD("forward"), REVERSE("reverse");
     private Direction(String name) {
index dbdadffe34c9ca1c55d2e8ec19bfe496e0c83cb9..7f1955d84c229c37c784abba572e9ee411128f02 100644 (file)
@@ -18,6 +18,7 @@ import java.util.List;
  *
  *
  */
+@Deprecated
 public enum EtherTypes {
     PVSTP("PVSTP", 0x010B), // 802.2 + SNAP (Spanning Tree)
     CDP("CDP", 0x2000), // 802.2 + SNAP
index cdd8607b9928311851221d42f0b47c43d48f795b..d0de0be0487619fc1c17419aef4aa8dc4f24ff9d 100644 (file)
@@ -40,6 +40,7 @@ import java.util.NoSuchElementException;
  * An iterator that will filter values from an iterator and return only those
  * values that match the predicate.
  */
+@Deprecated
 public abstract class FilterIterator<T> implements Iterator<T> {
     protected Iterator<T> subIterator;
     protected T next;
index 9ebf8a22272d1d1b9564902de93399fd5d431933..6d69a27a8a6fa652c3bff7b96de3a3a578eb5286 100644 (file)
@@ -15,6 +15,7 @@ package org.opendaylight.controller.sal.utils;
  *
  *
  */
+@Deprecated
 public enum GUIField {
     USER("User"), PASSWORD("Password"), ROLE("Role"), SERVERIP("Server address"), SERVERSECRET(
             "Server secret"), SERVERPROTOCOL("Server protocol"), NAME("Name"), CONTAINER(
index ceb4553470933330516bd945652a07045dcf7e85..342a99b2d64d8f7fbc8e7a7bdbad34d3b98f473d 100644 (file)
@@ -12,6 +12,7 @@ package org.opendaylight.controller.sal.utils;
  * Global Constants
  *
  */
+@Deprecated
 public enum GlobalConstants {
     DEFAULT("default"),
     CONTAINERMANAGER("containermanager"),
index 37661358cd18a4eb0439db820efa5f42e3d8f8d4..4e6b59ed1c3589bd16e8170b085bee9bfb1a79dc 100644 (file)
@@ -16,6 +16,7 @@ import java.math.BigInteger;
  *
  *
  */
+@Deprecated
 public class HexEncode {
     /**
      * This method converts byte array into String format without ":" inserted.
index 406614d164b60a96a1a4dc8a0264858ffc4fde13..ae72643ff6628f2f852b3aaa7bd37943f58cd0e2 100644 (file)
@@ -37,7 +37,7 @@ package org.opendaylight.controller.sal.utils;
  * This interface defines the methods for callback ordering
  *
  */
-
+@Deprecated
 public interface IListener<T> {
     public enum Command {
         CONTINUE, STOP
index fd51a787aa2828e2fb766b902eb68b8a12cdb8de..5c8076b491d0ae211f7b792562113371aadae8f6 100644 (file)
@@ -16,7 +16,7 @@ import org.opendaylight.controller.sal.core.NodeConnector;
  * This interface defines the methods to be called when looking up custom node types
  *
  */
-
+@Deprecated
 public interface INodeConnectorFactory {
     /**
      * Method to get custom NodeConnector types from protocol plugins
index 1ccd04bedac69bd72201c4d6443170a9863a5df0..09339f87ceff65123daff7700ddd237505ba848c 100644 (file)
@@ -15,7 +15,7 @@ import org.opendaylight.controller.sal.core.Node;
  * This interface defines the methods to be called when looking up custom node types
  *
  */
-
+@Deprecated
 public interface INodeFactory {
     /**
      * Method to get custom node types from protocol plugins
index af73dc781595ab2ae2f96673ae221222b77e4439..4cd1c9f21d9bae858ccd53f22d9fead28f2c0c8b 100644 (file)
@@ -23,6 +23,7 @@ import java.io.ObjectInputStream;
  *
  *
  */
+@Deprecated
 public interface IObjectReader {
     public Object readObject(ObjectInputStream ois)
             throws FileNotFoundException, IOException, ClassNotFoundException;
index d3d3142cdfbcf7f06dc81d5cd49d95f0038ee971..dbe74efe1b72d373cca30f4ac610c16092bef3a4 100644 (file)
@@ -22,6 +22,7 @@ import java.util.List;
  * references:
  * http://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml
  */
+@Deprecated
 public enum IPProtocols {
      ANY("any", -1),
      HOPOPT("HOPOPT",0),
index 6d68f42c1bebc8ce9b7d6bf510e8e70214d92122..8a720289170d8d32a5ccde585d100a53dacc0d5d 100644 (file)
@@ -42,6 +42,7 @@ import java.util.NoSuchElementException;
  * @param <T>
  *            the type of elements returned by this iterator
  */
+@Deprecated
 public class IterableIterator<T> implements Iterator<T> {
     Iterator<? extends Iterable<T>> subIterator;
     Iterator<T> current = null;
index 282bac659173d78a8c8ad8d2ea392c6c5eb526fb..2a4ea3da607795ae33bdc70252654cf1f7198070 100644 (file)
@@ -46,6 +46,7 @@ import org.slf4j.LoggerFactory;
  * @author readams
  *
  */
+@Deprecated
 public class ListenerDispatcher<U, T extends IListener<U>> {
     protected static Logger logger = LoggerFactory
             .getLogger(ListenerDispatcher.class);
index 42d080d5df0299180b6ac33532bbdbc6bd6eb2d7..fbb40882dadbbb8858c87005b0dd1a37ca0b80ce 100644 (file)
@@ -42,6 +42,7 @@ import java.util.NoSuchElementException;
  * @param <T>
  *            the type of elements returned by this iterator
  */
+@Deprecated
 public class MultiIterator<T> implements Iterator<T> {
     Iterator<Iterator<T>> subIterator;
     Iterator<T> current = null;
index 6b303f09f11955a053f7bcf740bf9f647b5df2ce..79b17785fa8cdc3ff7628e7dc7864c9f65e65ec0 100644 (file)
@@ -23,6 +23,7 @@ import org.slf4j.LoggerFactory;
  * Utility class containing the common utility functions needed for operating on
  * networking data structures
  */
+@Deprecated
 public abstract class NetUtils {
     protected static final Logger logger = LoggerFactory.getLogger(NetUtils.class);
     /**
index 9cd551664cb945bb4a0c7ed279507a9870fe9b1e..df57e0e170756a6d0d4ebcaeb49d9adb5fbe2a47 100644 (file)
@@ -25,6 +25,7 @@ import org.slf4j.LoggerFactory;
  *
  *
  */
+@Deprecated
 public abstract class NodeConnectorCreator {
     protected static final Logger logger = LoggerFactory
     .getLogger(NodeConnectorCreator.class);
index b6346fb7502054daa171f8ad6e61463faef8c3e5..3e4339a4f24982fed1d4b4b102eb75763c6b9f3f 100644 (file)
@@ -21,6 +21,7 @@ import org.slf4j.LoggerFactory;
  *
  *
  */
+@Deprecated
 public abstract class NodeCreator {
     protected static final Logger logger = LoggerFactory.getLogger(NodeCreator.class);
 
index 5d69810c25454c9e74f70114f31e58f21effa86d..d6793d78f4aa75acfd5b73d6bd32f0d17a244ab0 100644 (file)
@@ -13,7 +13,7 @@ import org.opendaylight.controller.sal.core.NodeTable;
 import org.opendaylight.controller.sal.core.NodeTable.NodeTableIDType;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-
+@Deprecated
 public class NodeTableCreator {
     protected static final Logger logger = LoggerFactory
             .getLogger(NodeTableCreator.class);
index 1b2225c11ce052e360e4aba7f58ab7d42a19e488..042e71e8e375f6ccfa6f8907c49c28d9d38904b9 100644 (file)
@@ -22,6 +22,7 @@ import org.slf4j.LoggerFactory;
  *
  *
  */
+@Deprecated
 public class ObjectReader {
     private static Logger logger = LoggerFactory.getLogger(ObjectReader.class);
     private FileInputStream fis;
index 8e1dcd69f999fec5f2619c1f8e65d0fc511212f4..22a83caa5ab4b66140fc63efb440d8ccfbc2d0bd 100644 (file)
@@ -21,6 +21,7 @@ import org.slf4j.LoggerFactory;
  * Write object to write to file stream
  *
  */
+@Deprecated
 public class ObjectWriter {
     private static Logger logger = LoggerFactory.getLogger(ObjectWriter.class);
     private FileOutputStream fos;
index 343962bb24aabf3d58025c842b719bf4f102d4fb..8ec3f8a3d862440c5f982d368f0d1a391f1f045d 100644 (file)
@@ -24,6 +24,7 @@ import java.util.ArrayList;
  *
  *
  */
+@Deprecated
 public class ReadFromFile {
     private FileInputStream fileStream;
     private File filePointer;
index 26bdbcca84873f46de388b9b431b46a990a4e9db..95aa6830c375164c9a7624786fc042ba52d8d455 100644 (file)
@@ -28,6 +28,7 @@ import org.slf4j.LoggerFactory;
  *
  *
  */
+@Deprecated
 public class ServiceHelper {
     private static final Logger logger = LoggerFactory
             .getLogger(ServiceHelper.class);
index 5d363f128544056a3639f661634bab429896c3a9..664beff460d77c84d550f430452080a87cb2787a 100644 (file)
@@ -50,6 +50,7 @@ import org.slf4j.LoggerFactory;
  * new task * If the task has begun, set a bit to restart it after the current
  * task finishes
  */
+@Deprecated
 public class SingletonTask {
     protected static Logger logger = LoggerFactory
             .getLogger(SingletonTask.class);
index 0387f72f382da08bc1ec395e73158d11545e253c..44d1c5736aa4492aa3a37fda4c803a320018c0d9 100644 (file)
@@ -15,6 +15,7 @@ import java.io.Serializable;
  * It contains a code {@code StatusCode} representing the result of the call and
  * a string which describes a failure reason (if any) in human readable form.
  */
+@Deprecated
 public class Status implements Serializable {
     private static final long serialVersionUID = 0L;
     private StatusCode code;
index f8882bbd2f81663023c95dd2b8b980d2e9754687..81f0b76b95f0b4a41b20c5e58232b406b084fd8f 100644 (file)
@@ -13,6 +13,7 @@ package org.opendaylight.controller.sal.utils;
  * Each enum value is associated with a minimal description string.
  *
  */
+@Deprecated
 public enum StatusCode {
         SUCCESS("Success"),
         CREATED("Created"),
index f8b61b0dc470b3cd92c9999224d5f4a4df8690b9..c1ce6f49f05f9d11180eb3c80724c00624e75e20 100644 (file)
@@ -11,7 +11,7 @@ package org.opendaylight.controller.sal.utils;
 
 import java.util.ArrayList;
 import java.util.List;
-
+@Deprecated
 public final class TierHelper {
     private static TierHelper tierHelper;
     public static final int unknownTierNumber = 0;
index 3a42aa98b9bbe1f7dc8c1550d05d11297027a737..6b109bab8d38ffe3c8f09b339c5d4fe4ef9419ff 100644 (file)
@@ -23,6 +23,7 @@ import org.slf4j.LoggerFactory;
  *
  *
  */
+@Deprecated
 public class WriteToFile {
     protected static final Logger logger = LoggerFactory
     .getLogger(WriteToFile.class);
index 1ee28b8d5a2ed48b7540f09d41f1172fc2a2cb08..67cc60ab0ffa2ca4a6532d2d7056df269d5fa1bd 100644 (file)
@@ -64,12 +64,12 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
       <scope>runtime</scope>
     </dependency>
     <dependency>
-      <groupId>${symbol_dollar}{groupId}</groupId>
+      <groupId>${symbol_dollar}{project.groupId}</groupId>
       <artifactId>${artifactId}-impl</artifactId>
       <version>${symbol_dollar}{project.version}</version>
     </dependency>
     <dependency>
-      <groupId>${symbol_dollar}{groupId}</groupId>
+      <groupId>${symbol_dollar}{project.groupId}</groupId>
       <artifactId>${artifactId}-api</artifactId>
       <version>${symbol_dollar}{project.version}</version>
     </dependency>
index 56903d0409755c275a5e73b6776ab79cf2878e47..64d6834fef8ba708bbdbf1b9031d52b6333095e9 100644 (file)
@@ -25,7 +25,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
   <packaging>bundle</packaging>
   <dependencies>
     <dependency>
-      <groupId>${symbol_dollar}{groupId}</groupId>
+      <groupId>${symbol_dollar}{project.groupId}</groupId>
       <artifactId>${artifactId}-api</artifactId>
       <version>${symbol_dollar}{project.version}</version>
     </dependency>
index 01a55e883eaf88622f65d6fbda74b7c89d020e78..f88e09cecba5b456e73b9ce25e6fc09efa74bc7c 100644 (file)
                 <type>xml</type>
                 <scope>runtime</scope>
             </dependency>
+            <dependency>
+              <groupId>${project.groupId}</groupId>
+              <artifactId>features-restconf</artifactId>
+              <version>${project.version}</version>
+              <classifier>features</classifier>
+              <type>xml</type>
+              <scope>runtime</scope>
+            </dependency>
 
             <!-- FIXME: move this into netconf-artifacts -->
             <dependency>
         </dependencies>
     </dependencyManagement>
 </project>
-
index 8f416b3abc45145e2f95307332052b66cdb4b5a1..9aff86ba2b09572a44200ac2095331d03c687a66 100644 (file)
@@ -41,7 +41,7 @@ public class ExampleActor extends RaftActor {
     private final DataPersistenceProvider dataPersistenceProvider;
 
     private long persistIdentifier = 1;
-    private Optional<ActorRef> roleChangeNotifier;
+    private final Optional<ActorRef> roleChangeNotifier;
 
 
     public ExampleActor(String id, Map<String, String> peerAddresses,
@@ -127,10 +127,10 @@ public class ExampleActor extends RaftActor {
         } catch (Exception e) {
             LOG.error(e, "Exception in creating snapshot");
         }
-        getSelf().tell(new CaptureSnapshotReply(bs), null);
+        getSelf().tell(new CaptureSnapshotReply(bs.toByteArray()), null);
     }
 
-    @Override protected void applySnapshot(ByteString snapshot) {
+    @Override protected void applySnapshot(byte [] snapshot) {
         state.clear();
         try {
             state.putAll((HashMap) toObject(snapshot));
@@ -162,12 +162,12 @@ public class ExampleActor extends RaftActor {
         }
     }
 
-    private Object toObject(ByteString bs) throws ClassNotFoundException, IOException {
+    private Object toObject(byte [] bs) throws ClassNotFoundException, IOException {
         Object obj = null;
         ByteArrayInputStream bis = null;
         ObjectInputStream ois = null;
         try {
-            bis = new ByteArrayInputStream(bs.toByteArray());
+            bis = new ByteArrayInputStream(bs);
             ois = new ObjectInputStream(bis);
             obj = ois.readObject();
         } finally {
@@ -215,6 +215,6 @@ public class ExampleActor extends RaftActor {
     }
 
     @Override
-    protected void applyRecoverySnapshot(ByteString snapshot) {
+    protected void applyRecoverySnapshot(byte[] snapshot) {
     }
 }
index 164c2cea561349cf178d63965eccd0a313e29b4e..c256c822a420e3a22b5a351778d58a88e73a9e8d 100644 (file)
@@ -199,7 +199,7 @@ public abstract class RaftActor extends AbstractUntypedPersistentActor {
         timer.start();
 
         // Apply the snapshot to the actors state
-        applyRecoverySnapshot(ByteString.copyFrom(snapshot.getState()));
+        applyRecoverySnapshot(snapshot.getState());
 
         timer.stop();
         LOG.info("Recovery snapshot applied for {} in {}: snapshotIndex={}, snapshotTerm={}, journal-size=" +
@@ -317,7 +317,8 @@ public abstract class RaftActor extends AbstractUntypedPersistentActor {
                     snapshot.getLastAppliedTerm()
                 );
             }
-            applySnapshot(ByteString.copyFrom(snapshot.getState()));
+
+            applySnapshot(snapshot.getState());
 
             //clears the followers log, sets the snapshot index to ensure adjusted-index works
             replicatedLog = new ReplicatedLogImpl(snapshot);
@@ -354,17 +355,14 @@ public abstract class RaftActor extends AbstractUntypedPersistentActor {
 
         } else if (message instanceof CaptureSnapshot) {
             LOG.info("CaptureSnapshot received by actor");
-            CaptureSnapshot cs = (CaptureSnapshot)message;
-            captureSnapshot = cs;
-            createSnapshot();
 
-        } else if (message instanceof CaptureSnapshotReply){
-            LOG.info("CaptureSnapshotReply received by actor");
-            CaptureSnapshotReply csr = (CaptureSnapshotReply) message;
+            if(captureSnapshot == null) {
+                captureSnapshot = (CaptureSnapshot)message;
+                createSnapshot();
+            }
 
-            ByteString stateInBytes = csr.getSnapshot();
-            LOG.info("CaptureSnapshotReply stateInBytes size:{}", stateInBytes.size());
-            handleCaptureSnapshotReply(stateInBytes);
+        } else if (message instanceof CaptureSnapshotReply){
+            handleCaptureSnapshotReply(((CaptureSnapshotReply) message).getSnapshot());
 
         } else {
             if (!(message instanceof AppendEntriesMessages.AppendEntries)
@@ -583,7 +581,7 @@ public abstract class RaftActor extends AbstractUntypedPersistentActor {
      *
      * @param snapshot A snapshot of the state of the actor
      */
-    protected abstract void applyRecoverySnapshot(ByteString snapshot);
+    protected abstract void applyRecoverySnapshot(byte[] snapshotBytes);
 
     /**
      * This method is called during recovery at the end of a batch to apply the current batched
@@ -612,9 +610,9 @@ public abstract class RaftActor extends AbstractUntypedPersistentActor {
      * operations when the derived actor is out of sync with it's peers
      * and the only way to bring it in sync is by applying a snapshot
      *
-     * @param snapshot A snapshot of the state of the actor
+     * @param snapshotBytes A snapshot of the state of the actor
      */
-    protected abstract void applySnapshot(ByteString snapshot);
+    protected abstract void applySnapshot(byte[] snapshotBytes);
 
     /**
      * This method will be called by the RaftActor when the state of the
@@ -661,11 +659,13 @@ public abstract class RaftActor extends AbstractUntypedPersistentActor {
         return peerAddress;
     }
 
-    private void handleCaptureSnapshotReply(ByteString stateInBytes) {
+    private void handleCaptureSnapshotReply(byte[] snapshotBytes) {
+        LOG.info("CaptureSnapshotReply received by actor: snapshot size {}", snapshotBytes.length);
+
         // create a snapshot object from the state provided and save it
         // when snapshot is saved async, SaveSnapshotSuccess is raised.
 
-        Snapshot sn = Snapshot.create(stateInBytes.toByteArray(),
+        Snapshot sn = Snapshot.create(snapshotBytes,
             context.getReplicatedLog().getFrom(captureSnapshot.getLastAppliedIndex() + 1),
             captureSnapshot.getLastIndex(), captureSnapshot.getLastTerm(),
             captureSnapshot.getLastAppliedIndex(), captureSnapshot.getLastAppliedTerm());
@@ -687,7 +687,8 @@ public abstract class RaftActor extends AbstractUntypedPersistentActor {
 
         if (isLeader() && captureSnapshot.isInstallSnapshotInitiated()) {
             // this would be call straight to the leader and won't initiate in serialization
-            currentBehavior.handleMessage(getSelf(), new SendInstallSnapshot(stateInBytes));
+            currentBehavior.handleMessage(getSelf(), new SendInstallSnapshot(
+                    ByteString.copyFrom(snapshotBytes)));
         }
 
         captureSnapshot = null;
diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftVersions.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftVersions.java
new file mode 100644 (file)
index 0000000..4330a4c
--- /dev/null
@@ -0,0 +1,17 @@
+/*
+ * Copyright (c) 2015 Brocade Communications Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.cluster.raft;
+
+/**
+ * @author Thomas Pantelis
+ */
+public interface RaftVersions {
+    short HELIUM_VERSION = 0;
+    short LITHIUM_VERSION = 1;
+    short CURRENT_VERSION = LITHIUM_VERSION;
+}
index 986c7f382c44f00405abb7d62394cda548e2a66c..799e75ebfaffd4bba7b40974291680a5d9cf0f21 100644 (file)
@@ -11,9 +11,8 @@ package org.opendaylight.controller.cluster.raft;
 import java.io.Serializable;
 import org.opendaylight.controller.cluster.raft.protobuff.client.messages.Payload;
 
-public class ReplicatedLogImplEntry implements ReplicatedLogEntry,
-    Serializable {
-    private static final long serialVersionUID = 1L;
+public class ReplicatedLogImplEntry implements ReplicatedLogEntry, Serializable {
+    private static final long serialVersionUID = -9085798014576489130L;
 
     private final long index;
     private final long term;
@@ -26,15 +25,18 @@ public class ReplicatedLogImplEntry implements ReplicatedLogEntry,
         this.payload = payload;
     }
 
-    @Override public Payload getData() {
+    @Override
+    public Payload getData() {
         return payload;
     }
 
-    @Override public long getTerm() {
+    @Override
+    public long getTerm() {
         return term;
     }
 
-    @Override public long getIndex() {
+    @Override
+    public long getIndex() {
         return index;
     }
 
@@ -43,7 +45,8 @@ public class ReplicatedLogImplEntry implements ReplicatedLogEntry,
         return getData().size();
     }
 
-    @Override public String toString() {
+    @Override
+    public String toString() {
         return "Entry{" +
             "index=" + index +
             ", term=" + term +
index 2f5ba48f9258d9a47ebf62ac98966db5d1055d99..7ec32440e7fdfcbe24e2a252f9859860de634ff1 100644 (file)
@@ -14,7 +14,7 @@ import org.opendaylight.controller.cluster.raft.messages.InstallSnapshot;
 public class SerializationUtils {
 
     public static Object fromSerializable(Object serializable){
-        if(serializable.getClass().equals(AppendEntries.SERIALIZABLE_CLASS)){
+        if(AppendEntries.isSerializedType(serializable)){
             return AppendEntries.fromSerializable(serializable);
 
         } else if (serializable.getClass().equals(InstallSnapshot.SERIALIZABLE_CLASS)) {
index 96150db68982134881599f5114b6aa359ba82081..82f3e0dce02102034c54d127cdf83374313c61bc 100644 (file)
@@ -7,20 +7,15 @@
  */
 package org.opendaylight.controller.cluster.raft.base.messages;
 
-import com.google.protobuf.ByteString;
 
 public class CaptureSnapshotReply {
-    private ByteString snapshot;
+    private final byte [] snapshot;
 
-    public CaptureSnapshotReply(ByteString snapshot) {
+    public CaptureSnapshotReply(byte [] snapshot) {
         this.snapshot = snapshot;
     }
 
-    public ByteString getSnapshot() {
+    public byte [] getSnapshot() {
         return snapshot;
     }
-
-    public void setSnapshot(ByteString snapshot) {
-        this.snapshot = snapshot;
-    }
 }
index 0122d45c3095962161712643e6c3c4fb0fbf6e7b..3c9ebf47fd7178eca126ce962504153ca7f8ad21 100644 (file)
@@ -9,7 +9,8 @@
 package org.opendaylight.controller.cluster.raft.messages;
 
 public class AbstractRaftRPC implements RaftRPC {
-    private static final long serialVersionUID = 1L;
+    private static final long serialVersionUID = -6061342433962854822L;
+
     // term
     protected long term;
 
@@ -21,6 +22,7 @@ public class AbstractRaftRPC implements RaftRPC {
     public AbstractRaftRPC() {
     }
 
+    @Override
     public long getTerm() {
         return term;
     }
index e5aebaa6be9f01e4dd46bd7a38db2e210fd39773..81981062177510641c08edb243016075f388ae0f 100644 (file)
@@ -9,25 +9,30 @@
 package org.opendaylight.controller.cluster.raft.messages;
 
 import com.google.protobuf.GeneratedMessage;
-import org.opendaylight.controller.cluster.raft.ReplicatedLogEntry;
-import org.opendaylight.controller.cluster.raft.ReplicatedLogImplEntry;
-import org.opendaylight.controller.cluster.raft.protobuff.client.messages.Payload;
-import org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages;
-
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import org.opendaylight.controller.cluster.raft.RaftVersions;
+import org.opendaylight.controller.cluster.raft.ReplicatedLogEntry;
+import org.opendaylight.controller.cluster.raft.ReplicatedLogImplEntry;
+import org.opendaylight.controller.cluster.raft.protobuff.client.messages.Payload;
+import org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages;
 
 /**
  * Invoked by leader to replicate log entries (§5.3); also used as
  * heartbeat (§5.2).
  */
 public class AppendEntries extends AbstractRaftRPC {
-    public static final Class<AppendEntriesMessages.AppendEntries> SERIALIZABLE_CLASS = AppendEntriesMessages.AppendEntries.class;
+    private static final long serialVersionUID = 1L;
+
+    public static final Class<AppendEntriesMessages.AppendEntries> LEGACY_SERIALIZABLE_CLASS =
+            AppendEntriesMessages.AppendEntries.class;
 
     private static final org.slf4j.Logger LOG = org.slf4j.LoggerFactory.getLogger(AppendEntries.class);
-    private static final long serialVersionUID = 1L;
 
     // So that follower can redirect clients
     private final String leaderId;
@@ -40,7 +45,7 @@ public class AppendEntries extends AbstractRaftRPC {
 
     // log entries to store (empty for heartbeat;
     // may send more than one for efficiency)
-    private final List<ReplicatedLogEntry> entries;
+    private transient List<ReplicatedLogEntry> entries;
 
     // leader's commitIndex
     private final long leaderCommit;
@@ -55,6 +60,28 @@ public class AppendEntries extends AbstractRaftRPC {
         this.leaderCommit = leaderCommit;
     }
 
+    private void writeObject(ObjectOutputStream out) throws IOException {
+        out.writeShort(RaftVersions.CURRENT_VERSION);
+        out.defaultWriteObject();
+
+        out.writeInt(entries.size());
+        for(ReplicatedLogEntry e: entries) {
+            out.writeObject(e);
+        }
+    }
+
+    private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
+        in.readShort(); // version
+
+        in.defaultReadObject();
+
+        int size = in.readInt();
+        entries = new ArrayList<>(size);
+        for(int i = 0; i < size; i++) {
+            entries.add((ReplicatedLogEntry) in.readObject());
+        }
+    }
+
     public String getLeaderId() {
         return leaderId;
     }
@@ -75,7 +102,8 @@ public class AppendEntries extends AbstractRaftRPC {
         return leaderCommit;
     }
 
-    @Override public String toString() {
+    @Override
+    public String toString() {
         final StringBuilder sb =
             new StringBuilder("AppendEntries{");
         sb.append("term=").append(getTerm());
@@ -88,7 +116,20 @@ public class AppendEntries extends AbstractRaftRPC {
         return sb.toString();
     }
 
-    public <T extends Object> Object toSerializable(){
+    public <T extends Object> Object toSerializable() {
+        return toSerializable(RaftVersions.CURRENT_VERSION);
+    }
+
+    public <T extends Object> Object toSerializable(short version) {
+        if(version < RaftVersions.LITHIUM_VERSION) {
+            return toLegacySerializable();
+        } else {
+            return this;
+        }
+    }
+
+    @SuppressWarnings({ "rawtypes", "unchecked" })
+    private <T> Object toLegacySerializable() {
         AppendEntriesMessages.AppendEntries.Builder to = AppendEntriesMessages.AppendEntries.newBuilder();
         to.setTerm(this.getTerm())
             .setLeaderId(this.getLeaderId())
@@ -122,9 +163,16 @@ public class AppendEntries extends AbstractRaftRPC {
         return to.build();
     }
 
-    public static AppendEntries fromSerializable(Object o){
-        AppendEntriesMessages.AppendEntries from = (AppendEntriesMessages.AppendEntries) o;
+    public static AppendEntries fromSerializable(Object serialized) {
+        if(serialized instanceof AppendEntries) {
+            return (AppendEntries)serialized;
+        }
+        else {
+            return fromLegacySerializable((AppendEntriesMessages.AppendEntries) serialized);
+        }
+    }
 
+    private static AppendEntries fromLegacySerializable(AppendEntriesMessages.AppendEntries from) {
         List<ReplicatedLogEntry> logEntryList = new ArrayList<>();
         for (AppendEntriesMessages.AppendEntries.ReplicatedLogEntry leProtoBuff : from.getLogEntriesList()) {
 
@@ -134,7 +182,6 @@ public class AppendEntries extends AbstractRaftRPC {
                     String clientPayloadClassName = leProtoBuff.getData().getClientPayloadClassName();
                     payload = (Payload) Class.forName(clientPayloadClassName).newInstance();
                     payload = payload.decode(leProtoBuff.getData());
-                    payload.setClientPayloadClassName(clientPayloadClassName);
                 } else {
                     LOG.error("Payload is null or payload does not have client payload class name");
                 }
@@ -160,4 +207,8 @@ public class AppendEntries extends AbstractRaftRPC {
 
         return to;
     }
+
+    public static boolean isSerializedType(Object message) {
+        return message instanceof AppendEntries || LEGACY_SERIALIZABLE_CLASS.isInstance(message);
+    }
 }
index 2424d4d557f7f1dc58e65a1718e44a6a84db501f..cd852eaae2d247f8b484f435b54e73fd0b97f1c9 100644 (file)
@@ -55,14 +55,17 @@ public class MockRaftActorContext implements RaftActorContext {
             private long currentTerm = 0;
             private String votedFor = "";
 
+            @Override
             public long getCurrentTerm() {
                 return currentTerm;
             }
 
+            @Override
             public String getVotedFor() {
                 return votedFor;
             }
 
+            @Override
             public void update(long currentTerm, String votedFor){
                 this.currentTerm = currentTerm;
                 this.votedFor = votedFor;
@@ -127,6 +130,7 @@ public class MockRaftActorContext implements RaftActorContext {
         return lastApplied;
     }
 
+    @Override
     public void setReplicatedLog(ReplicatedLog replicatedLog) {
         this.replicatedLog = replicatedLog;
     }
@@ -202,7 +206,7 @@ public class MockRaftActorContext implements RaftActorContext {
     }
 
     public static class MockPayload extends Payload implements Serializable {
-        private static final long serialVersionUID = 1L;
+        private static final long serialVersionUID = 3121380393130864247L;
         private String value = "";
 
         public MockPayload(){
@@ -235,6 +239,7 @@ public class MockRaftActorContext implements RaftActorContext {
             return MockPayload.class.getName();
         }
 
+        @Override
         public String toString() {
             return value;
         }
@@ -273,7 +278,7 @@ public class MockRaftActorContext implements RaftActorContext {
     }
 
     public static class MockReplicatedLogBuilder {
-        private ReplicatedLog mockLog = new SimpleReplicatedLog();
+        private final ReplicatedLog mockLog = new SimpleReplicatedLog();
 
         public  MockReplicatedLogBuilder createEntries(int start, int end, int term) {
             for (int i=start; i<end; i++) {
index d999bb2ba1de79e59d65b5cd78614bc8b3fc2c7c..6b266d710e4aa44f793c4ed2bc809347944f1c15 100644 (file)
@@ -1,5 +1,17 @@
 package org.opendaylight.controller.cluster.raft;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
 import akka.actor.ActorRef;
 import akka.actor.ActorSystem;
 import akka.actor.PoisonPill;
@@ -57,18 +69,6 @@ import scala.concurrent.Await;
 import scala.concurrent.Future;
 import scala.concurrent.duration.Duration;
 import scala.concurrent.duration.FiniteDuration;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
 
 public class RaftActorTest extends AbstractActorTest {
 
@@ -177,11 +177,10 @@ public class RaftActorTest extends AbstractActorTest {
         }
 
         @Override
-        protected void applyRecoverySnapshot(ByteString snapshot) {
-            delegate.applyRecoverySnapshot(snapshot);
+        protected void applyRecoverySnapshot(byte[] bytes) {
+            delegate.applyRecoverySnapshot(bytes);
             try {
-                Object data = toObject(snapshot);
-                System.out.println("!!!!!applyRecoverySnapshot: "+data);
+                Object data = toObject(bytes);
                 if (data instanceof List) {
                     state.addAll((List<?>) data);
                 }
@@ -194,7 +193,7 @@ public class RaftActorTest extends AbstractActorTest {
             delegate.createSnapshot();
         }
 
-        @Override protected void applySnapshot(ByteString snapshot) {
+        @Override protected void applySnapshot(byte [] snapshot) {
             delegate.applySnapshot(snapshot);
         }
 
@@ -216,12 +215,12 @@ public class RaftActorTest extends AbstractActorTest {
             return this.getId();
         }
 
-        private Object toObject(ByteString bs) throws ClassNotFoundException, IOException {
+        private Object toObject(byte[] bs) throws ClassNotFoundException, IOException {
             Object obj = null;
             ByteArrayInputStream bis = null;
             ObjectInputStream ois = null;
             try {
-                bis = new ByteArrayInputStream(bs.toByteArray());
+                bis = new ByteArrayInputStream(bs);
                 ois = new ObjectInputStream(bis);
                 obj = ois.readObject();
             } finally {
@@ -431,7 +430,7 @@ public class RaftActorTest extends AbstractActorTest {
 
                 mockRaftActor.onReceiveRecover(new SnapshotOffer(new SnapshotMetadata(persistenceId, 100, 100), snapshot));
 
-                verify(mockRaftActor.delegate).applyRecoverySnapshot(eq(snapshotBytes));
+                verify(mockRaftActor.delegate).applyRecoverySnapshot(eq(snapshotBytes.toByteArray()));
 
                 mockRaftActor.onReceiveRecover(new ReplicatedLogImplEntry(0, 1, new MockRaftActorContext.MockPayload("A")));
 
@@ -500,7 +499,7 @@ public class RaftActorTest extends AbstractActorTest {
 
                 mockRaftActor.onReceiveRecover(new SnapshotOffer(new SnapshotMetadata(persistenceId, 100, 100), snapshot));
 
-                verify(mockRaftActor.delegate, times(0)).applyRecoverySnapshot(any(ByteString.class));
+                verify(mockRaftActor.delegate, times(0)).applyRecoverySnapshot(any(byte[].class));
 
                 mockRaftActor.onReceiveRecover(new ReplicatedLogImplEntry(0, 1, new MockRaftActorContext.MockPayload("A")));
 
@@ -676,7 +675,7 @@ public class RaftActorTest extends AbstractActorTest {
 
                 mockRaftActor.setCurrentBehavior(new Leader(raftActorContext));
 
-                mockRaftActor.onReceiveCommand(new CaptureSnapshotReply(snapshotBytes));
+                mockRaftActor.onReceiveCommand(new CaptureSnapshotReply(snapshotBytes.toByteArray()));
 
                 verify(dataPersistenceProvider).saveSnapshot(anyObject());
 
@@ -722,7 +721,7 @@ public class RaftActorTest extends AbstractActorTest {
 
                 verify(mockRaftActor.delegate).createSnapshot();
 
-                mockRaftActor.onReceiveCommand(new CaptureSnapshotReply(snapshotBytes));
+                mockRaftActor.onReceiveCommand(new CaptureSnapshotReply(snapshotBytes.toByteArray()));
 
                 mockRaftActor.onReceiveCommand(new SaveSnapshotSuccess(new SnapshotMetadata("foo", 100, 100)));
 
@@ -814,7 +813,7 @@ public class RaftActorTest extends AbstractActorTest {
 
                 mockRaftActor.onReceiveCommand(new ApplySnapshot(snapshot));
 
-                verify(mockRaftActor.delegate).applySnapshot(eq(snapshotBytes));
+                verify(mockRaftActor.delegate).applySnapshot(eq(snapshot.getState()));
 
                 assertTrue("The replicatedLog should have changed",
                     oldReplicatedLog != mockRaftActor.getReplicatedLog());
@@ -859,7 +858,7 @@ public class RaftActorTest extends AbstractActorTest {
 
                 mockRaftActor.onReceiveCommand(new CaptureSnapshot(-1,1,-1,1));
 
-                mockRaftActor.onReceiveCommand(new CaptureSnapshotReply(snapshotBytes));
+                mockRaftActor.onReceiveCommand(new CaptureSnapshotReply(snapshotBytes.toByteArray()));
 
                 mockRaftActor.onReceiveCommand(new SaveSnapshotFailure(new SnapshotMetadata("foobar", 10L, 1234L),
                         new Exception()));
diff --git a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/ReplicatedLogImplEntryTest.java b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/ReplicatedLogImplEntryTest.java
new file mode 100644 (file)
index 0000000..1fe22bc
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2015 Brocade Communications Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.cluster.raft;
+
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * Unit tests for ReplicatedLogImplEntry.
+ *
+ * @author Thomas Pantelis
+ */
+public class ReplicatedLogImplEntryTest {
+
+    @Test
+    public void testBackwardsCompatibleDeserializationFromHelium() throws Exception {
+        String expPayloadData = "This is a test";
+        int expIndex = 1;
+        int expTerm = 2;
+
+        try(FileInputStream fis = new FileInputStream("src/test/resources/helium-serialized-ReplicatedLogImplEntry")) {
+            ObjectInputStream ois = new ObjectInputStream(fis);
+
+            ReplicatedLogImplEntry entry = (ReplicatedLogImplEntry) ois.readObject();
+            ois.close();
+
+            Assert.assertEquals("getIndex", expIndex, entry.getIndex());
+            Assert.assertEquals("getTerm", expTerm, entry.getTerm());
+
+            MockRaftActorContext.MockPayload payload = (MockRaftActorContext.MockPayload) entry.getData();
+            Assert.assertEquals("data", expPayloadData, payload.toString());
+        }
+    }
+
+    /**
+     * Use this method to generate a file with a serialized ReplicatedLogImplEntry instance to be
+     * used in tests that verify backwards compatible de-serialization.
+     */
+    private void generateSerializedFile() throws IOException {
+        String expPayloadData = "This is a test";
+        int expIndex = 1;
+        int expTerm = 2;
+
+        ReplicatedLogImplEntry entry = new ReplicatedLogImplEntry(expIndex, expTerm,
+                new MockRaftActorContext.MockPayload(expPayloadData));
+        FileOutputStream fos = new FileOutputStream("src/test/resources/serialized-ReplicatedLogImplEntry");
+        ObjectOutputStream oos = new ObjectOutputStream(fos);
+        oos.writeObject(entry);
+        fos.close();
+    }
+}
index 151015e97ec785277beaf51b0bdb4fe0681f6582..b31cb621b3576b1a9bcbaff321465d4bd186674e 100644 (file)
@@ -43,15 +43,14 @@ import org.opendaylight.controller.cluster.raft.messages.InstallSnapshotReply;
 import org.opendaylight.controller.cluster.raft.messages.RequestVoteReply;
 import org.opendaylight.controller.cluster.raft.utils.DoNothingActor;
 import org.opendaylight.controller.cluster.raft.utils.MessageCollectorActor;
-import org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages;
 import org.opendaylight.controller.protobuff.messages.cluster.raft.InstallSnapshotMessages;
 import scala.concurrent.duration.FiniteDuration;
 
 public class LeaderTest extends AbstractRaftActorBehaviorTest {
 
-    private ActorRef leaderActor =
+    private final ActorRef leaderActor =
         getSystem().actorOf(Props.create(DoNothingActor.class));
-    private ActorRef senderActor =
+    private final ActorRef senderActor =
         getSystem().actorOf(Props.create(DoNothingActor.class));
 
     @Test
@@ -273,8 +272,8 @@ public class LeaderTest extends AbstractRaftActorBehaviorTest {
 
             leader.handleMessage(leaderActor, new SendHeartBeat());
 
-            AppendEntriesMessages.AppendEntries aeproto = (AppendEntriesMessages.AppendEntries)MessageCollectorActor.getFirstMatching(
-                followerActor, AppendEntries.SERIALIZABLE_CLASS);
+            AppendEntries aeproto = (AppendEntries)MessageCollectorActor.getFirstMatching(
+                followerActor, AppendEntries.class);
 
             assertNotNull("AppendEntries should be sent even if InstallSnapshotReply is not " +
                 "received", aeproto);
@@ -877,14 +876,13 @@ public class LeaderTest extends AbstractRaftActorBehaviorTest {
 
             leader.handleMessage(leaderActor, new SendHeartBeat());
 
-            AppendEntriesMessages.AppendEntries appendEntries =
-                (AppendEntriesMessages.AppendEntries) MessageCollectorActor
-                    .getFirstMatching(followerActor, AppendEntriesMessages.AppendEntries.class);
+            AppendEntries appendEntries = (AppendEntries) MessageCollectorActor
+                    .getFirstMatching(followerActor, AppendEntries.class);
 
             assertNotNull(appendEntries);
 
             assertEquals(1, appendEntries.getLeaderCommit());
-            assertEquals(1, appendEntries.getLogEntries(0).getIndex());
+            assertEquals(1, appendEntries.getEntries().get(0).getIndex());
             assertEquals(0, appendEntries.getPrevLogIndex());
 
             AppendEntriesReply appendEntriesReply =
@@ -946,14 +944,13 @@ public class LeaderTest extends AbstractRaftActorBehaviorTest {
 
             leader.handleMessage(leaderActor, new SendHeartBeat());
 
-            AppendEntriesMessages.AppendEntries appendEntries =
-                (AppendEntriesMessages.AppendEntries) MessageCollectorActor
-                    .getFirstMatching(followerActor, AppendEntriesMessages.AppendEntries.class);
+            AppendEntries appendEntries = (AppendEntries) MessageCollectorActor
+                    .getFirstMatching(followerActor, AppendEntries.class);
 
             assertNotNull(appendEntries);
 
             assertEquals(1, appendEntries.getLeaderCommit());
-            assertEquals(1, appendEntries.getLogEntries(0).getIndex());
+            assertEquals(1, appendEntries.getEntries().get(0).getIndex());
             assertEquals(0, appendEntries.getPrevLogIndex());
 
             AppendEntriesReply appendEntriesReply =
@@ -1193,8 +1190,8 @@ public class LeaderTest extends AbstractRaftActorBehaviorTest {
 
     private class MockConfigParamsImpl extends DefaultConfigParamsImpl {
 
-        private long electionTimeOutIntervalMillis;
-        private int snapshotChunkSize;
+        private final long electionTimeOutIntervalMillis;
+        private final int snapshotChunkSize;
 
         public MockConfigParamsImpl(long electionTimeOutIntervalMillis, int snapshotChunkSize) {
             super();
diff --git a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/messages/AppendEntriesTest.java b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/messages/AppendEntriesTest.java
new file mode 100644 (file)
index 0000000..abde51b
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2015 Brocade Communications Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.cluster.raft.messages;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertSame;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Iterator;
+import org.apache.commons.lang.SerializationUtils;
+import org.junit.Assert;
+import org.junit.Test;
+import org.opendaylight.controller.cluster.raft.MockRaftActorContext.MockPayload;
+import org.opendaylight.controller.cluster.raft.RaftVersions;
+import org.opendaylight.controller.cluster.raft.ReplicatedLogEntry;
+import org.opendaylight.controller.cluster.raft.ReplicatedLogImplEntry;
+import org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages;
+
+/**
+ * Unit tests for AppendEntries.
+ *
+ * @author Thomas Pantelis
+ */
+public class AppendEntriesTest {
+
+    @Test
+    public void testSerialization() {
+        ReplicatedLogEntry entry1 = new ReplicatedLogImplEntry(1, 2, new MockPayload("payload1"));
+
+        ReplicatedLogEntry entry2 = new ReplicatedLogImplEntry(3, 4, new MockPayload("payload2"));
+
+        AppendEntries expected = new AppendEntries(5L, "node1", 7L, 8L, Arrays.asList(entry1, entry2), 10L);
+
+        AppendEntries cloned = (AppendEntries) SerializationUtils.clone(expected);
+
+        verifyAppendEntries(expected, cloned);
+    }
+
+    @Test
+    public void testToAndFromSerializable() {
+        AppendEntries entries = new AppendEntries(5L, "node1", 7L, 8L,
+                Collections.<ReplicatedLogEntry>emptyList(), 10L);
+
+        assertSame("toSerializable", entries, entries.toSerializable());
+        assertSame("fromSerializable", entries,
+                org.opendaylight.controller.cluster.raft.SerializationUtils.fromSerializable(entries));
+    }
+
+    @Test
+    public void testToAndFromLegacySerializable() {
+        ReplicatedLogEntry entry = new ReplicatedLogImplEntry(3, 4, new MockPayload("payload"));
+        AppendEntries entries = new AppendEntries(5L, "node1", 7L, 8L, Arrays.asList(entry), 10L);
+
+        Object serializable = entries.toSerializable(RaftVersions.HELIUM_VERSION);
+        Assert.assertTrue(serializable instanceof AppendEntriesMessages.AppendEntries);
+
+        AppendEntries entries2 = (AppendEntries)
+                org.opendaylight.controller.cluster.raft.SerializationUtils.fromSerializable(serializable);
+
+        verifyAppendEntries(entries, entries2);
+    }
+
+    private void verifyAppendEntries(AppendEntries expected, AppendEntries actual) {
+        assertEquals("getLeaderId", expected.getLeaderId(), actual.getLeaderId());
+        assertEquals("getTerm", expected.getTerm(), actual.getTerm());
+        assertEquals("getLeaderCommit", expected.getLeaderCommit(), actual.getLeaderCommit());
+        assertEquals("getPrevLogIndex", expected.getPrevLogIndex(), actual.getPrevLogIndex());
+        assertEquals("getPrevLogTerm", expected.getPrevLogTerm(), actual.getPrevLogTerm());
+
+        assertEquals("getEntries size", expected.getEntries().size(), actual.getEntries().size());
+        Iterator<ReplicatedLogEntry> iter = expected.getEntries().iterator();
+        for(ReplicatedLogEntry e: actual.getEntries()) {
+            verifyReplicatedLogEntry(iter.next(), e);
+        }
+    }
+
+    private void verifyReplicatedLogEntry(ReplicatedLogEntry expected, ReplicatedLogEntry actual) {
+        assertEquals("getIndex", expected.getIndex(), actual.getIndex());
+        assertEquals("getTerm", expected.getTerm(), actual.getTerm());
+        assertEquals("getData", expected.getData().toString(), actual.getData().toString());
+    }
+}
diff --git a/opendaylight/md-sal/sal-akka-raft/src/test/resources/helium-serialized-ReplicatedLogImplEntry b/opendaylight/md-sal/sal-akka-raft/src/test/resources/helium-serialized-ReplicatedLogImplEntry
new file mode 100644 (file)
index 0000000..3e87f66
Binary files /dev/null and b/opendaylight/md-sal/sal-akka-raft/src/test/resources/helium-serialized-ReplicatedLogImplEntry differ
index 71946b0a7abe476241e3f1775ffa8e110da1d559..9e3230a623855d4add4249d68af0c2c216f4d79f 100644 (file)
@@ -16,6 +16,8 @@ import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessa
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 
 public class ValueSerializer {
+    private static final String NULL_VALUE = "";
+
     public static void serialize(NormalizedNodeMessages.Node.Builder builder,
             QNameSerializationContext context, Object value) {
         builder.setIntValueType(ValueType.getSerializableType(value).ordinal());
@@ -35,8 +37,10 @@ public class ValueSerializer {
                     }
                 }
             }
-        } else if(value instanceof byte[]){
+        } else if(value instanceof byte[]) {
             builder.setBytesValue(ByteString.copyFrom((byte[]) value));
+        } else if(value == null){
+            builder.setValue(NULL_VALUE);
         } else {
             builder.setValue(value.toString());
         }
@@ -64,6 +68,8 @@ public class ValueSerializer {
             }
         } else if(value instanceof byte[]){
             builder.setBytesValue(ByteString.copyFrom((byte[]) value));
+        } else if(value == null){
+            builder.setValue(NULL_VALUE);
         } else {
             builder.setValue(value.toString());
         }
index b9e46a3a570fd159d1c8b9284d2efc2ec95c214b..9eec8a300a81f2fc304beb7d9978ec7aef26b331 100644 (file)
@@ -8,7 +8,6 @@
 
 package org.opendaylight.controller.cluster.datastore.node.utils.serialization;
 
-import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableMap.Builder;
 import java.math.BigDecimal;
@@ -91,6 +90,12 @@ public enum ValueType {
         Object deserialize(final String str) {
             throw new UnsupportedOperationException("Should have been caught by caller");
         }
+    },
+    NULL_TYPE {
+        @Override
+        Object deserialize(final String str) {
+            return null;
+        }
     };
 
     private static final Map<Class<?>, ValueType> TYPES;
@@ -116,7 +121,9 @@ public enum ValueType {
     abstract Object deserialize(String str);
 
     public static final ValueType getSerializableType(Object node) {
-        Preconditions.checkNotNull(node, "node should not be null");
+        if(node == null){
+            return NULL_TYPE;
+        }
 
         final ValueType type = TYPES.get(node.getClass());
         if (type != null) {
index 2aa0027e55756b8d81cfe65f29b12044f7bf5c91..cde338179ba727903e35d4513195cbbddd9b1b1c 100644 (file)
@@ -284,7 +284,7 @@ public class NormalizedNodeInputStreamReader implements NormalizedNodeStreamRead
                 return bytes;
 
             case ValueTypes.YANG_IDENTIFIER_TYPE :
-            return readYangInstanceIdentifier();
+                return readYangInstanceIdentifier();
 
             default :
                 return null;
index 05858a87a12a20630c6bafb531844367e01e1907..088f4dfbe98a1358a980a84e8ad3adaa99736b57 100644 (file)
@@ -21,7 +21,9 @@ import java.util.Map;
 import java.util.Set;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter;
+import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWriter;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -52,6 +54,8 @@ public class NormalizedNodeOutputStreamWriter implements NormalizedNodeStreamWri
 
     private final Map<String, Integer> stringCodeMap = new HashMap<>();
 
+    private NormalizedNodeWriter normalizedNodeWriter;
+
     public NormalizedNodeOutputStreamWriter(OutputStream stream) throws IOException {
         Preconditions.checkNotNull(stream);
         output = new DataOutputStream(stream);
@@ -61,6 +65,18 @@ public class NormalizedNodeOutputStreamWriter implements NormalizedNodeStreamWri
         this.output = Preconditions.checkNotNull(output);
     }
 
+    private NormalizedNodeWriter normalizedNodeWriter() {
+        if(normalizedNodeWriter == null) {
+            normalizedNodeWriter = NormalizedNodeWriter.forStreamWriter(this);
+        }
+
+        return normalizedNodeWriter;
+    }
+
+    public void writeNormalizedNode(NormalizedNode<?, ?> node) throws IOException {
+        normalizedNodeWriter().write(node);
+    }
+
     @Override
     public void leafNode(YangInstanceIdentifier.NodeIdentifier name, Object value) throws IOException, IllegalArgumentException {
         Preconditions.checkNotNull(name, "Node identifier should not be null");
@@ -349,6 +365,8 @@ public class NormalizedNodeOutputStreamWriter implements NormalizedNodeStreamWri
             case ValueTypes.YANG_IDENTIFIER_TYPE:
                 writeYangInstanceIdentifier((YangInstanceIdentifier) value);
                 break;
+            case ValueTypes.NULL_TYPE :
+                break;
             default:
                 output.writeUTF(value.toString());
                 break;
index 3a2d2b49b3ac90c49a7855de4f64d3502d89c2e2..83099f8a5bd656b9c776d60108fd9b3e000e359b 100644 (file)
@@ -8,7 +8,6 @@
 
 package org.opendaylight.controller.cluster.datastore.node.utils.stream;
 
-import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableMap.Builder;
 import java.math.BigDecimal;
@@ -31,6 +30,7 @@ final class ValueTypes {
     public static final byte BIG_INTEGER_TYPE = 10;
     public static final byte BIG_DECIMAL_TYPE = 11;
     public static final byte BINARY_TYPE = 12;
+    public static final byte NULL_TYPE = 13;
 
     private static final Map<Class<?>, Byte> TYPES;
 
@@ -57,7 +57,9 @@ final class ValueTypes {
     }
 
     public static final byte getSerializableType(Object node) {
-        Preconditions.checkNotNull(node, "node should not be null");
+        if(node == null){
+            return NULL_TYPE;
+        }
 
         final Byte type = TYPES.get(node.getClass());
         if (type != null) {
index 99de5dde358ecb17ada94f8761f050c3c11ce6c7..83e10cf6afdf882a9df33e8de10f503536f0bba1 100644 (file)
@@ -24,6 +24,7 @@ import org.opendaylight.controller.protobuff.messages.persistent.PersistentMessa
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+@Deprecated
 public class CompositeModificationByteStringPayload extends Payload implements
         Serializable {
     private static final long serialVersionUID = 1L;
@@ -96,6 +97,7 @@ public class CompositeModificationByteStringPayload extends Payload implements
         return null;
     }
 
+    @Override
     public int size(){
         return byteString.size();
     }
index 075c6075a86b327775d23f4c217794700b69611f..fe5043e73d3593ac4b2966c8cfac6148d909d0d0 100644 (file)
@@ -18,9 +18,9 @@ import java.util.Map;
 import org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages;
 import org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages;
 
+@Deprecated
 public class CompositeModificationPayload extends Payload implements
     Serializable {
-    private static final long serialVersionUID = 1L;
 
     private final PersistentMessages.CompositeModification modification;
 
@@ -73,6 +73,7 @@ public class CompositeModificationPayload extends Payload implements
         return this.modification;
     }
 
+    @Override
     public int size(){
         return this.modification.getSerializedSize();
     }
index 7df53082948d0c69f4ea2c1223025821bd5946bd..d721494e15fcde76eb9b4f4e4f42a8e3e41bdd87 100644 (file)
@@ -51,16 +51,11 @@ import org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntries
  *
  */
 public abstract class Payload {
-    private String clientPayloadClassName;
 
     public String getClientPayloadClassName() {
         return this.getClass().getName();
     }
 
-    public void setClientPayloadClassName(String clientPayloadClassName) {
-        this.clientPayloadClassName = clientPayloadClassName;
-    }
-
     /**
      * Encode the payload data as a protocol buffer extension.
      * <p>
@@ -68,6 +63,7 @@ public abstract class Payload {
      * @param <T>
      * @return Map of <GeneratedMessage.GeneratedExtension, T>
      */
+    @Deprecated
     public abstract <T extends Object> Map<GeneratedMessage.GeneratedExtension, T> encode();
 
     /**
@@ -77,11 +73,9 @@ public abstract class Payload {
      * @param payload The payload in protocol buffer format
      * @return
      */
+    @Deprecated
     public abstract Payload decode(
         AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload payload);
 
     public abstract int size();
-
-
-
 }
index d9b7a18fdae51ab11899eda96da95a5ec2a81667..f5eecf33d90aa0df9afe164c3d72fc3663c2b14d 100644 (file)
@@ -291,6 +291,24 @@ public class ValueSerializerTest{
 
     }
 
+    @Test
+    public void testSerializeNull(){
+        NormalizedNodeMessages.Node.Builder builder = NormalizedNodeMessages.Node.newBuilder();
+        Object none = null;
+        ValueSerializer.serialize(builder, mock(QNameSerializationContext.class),none);
+
+        assertEquals(ValueType.NULL_TYPE.ordinal(), builder.getIntValueType());
+        assertEquals("", builder.getValue());
+
+        NormalizedNodeMessages.PathArgumentAttribute.Builder builder1 = NormalizedNodeMessages.PathArgumentAttribute.newBuilder();
+
+        ValueSerializer.serialize(builder1, mock(QNameSerializationContext.class),none);
+
+        assertEquals(ValueType.NULL_TYPE.ordinal(), builder1.getType());
+        assertEquals("", builder.getValue());
+
+    }
+
 
     @Test
     public void testDeSerializeShort(){
@@ -519,5 +537,31 @@ public class ValueSerializerTest{
 
     }
 
+    @Test
+    public void testDeSerializeNullType(){
+        NormalizedNodeMessages.Node.Builder nodeBuilder = NormalizedNodeMessages.Node.newBuilder();
+        nodeBuilder.setIntValueType(ValueType.NULL_TYPE.ordinal());
+        nodeBuilder.setValue("");
+
+        Object o = ValueSerializer
+                .deSerialize(mock(QNameDeSerializationContext.class),
+                        nodeBuilder.build());
+
+        assertEquals(null, o);
+
+        NormalizedNodeMessages.PathArgumentAttribute.Builder argumentBuilder
+                = NormalizedNodeMessages.PathArgumentAttribute.newBuilder();
+
+        argumentBuilder.setType(ValueType.NULL_TYPE.ordinal());
+        argumentBuilder.setValue("");
+
+        o = ValueSerializer
+                .deSerialize(mock(QNameDeSerializationContext.class),
+                        argumentBuilder.build());
+
+        assertEquals(null, o);
+
+    }
+
 
 }
index 8fe0633b6e3fbdaf6f4dba52d945cc6b6d014c78..1280559c00c1ecd26d2ce621ddb64e64479f6263 100644 (file)
@@ -1,8 +1,7 @@
 package org.opendaylight.controller.cluster.datastore.node.utils.serialization;
 
-import org.junit.Test;
-
 import static org.junit.Assert.assertEquals;
+import org.junit.Test;
 
 public class ValueTypeTest {
 
@@ -15,4 +14,12 @@ public class ValueTypeTest {
         ValueType serializableType = ValueType.getSerializableType(b);
         assertEquals(ValueType.BINARY_TYPE, serializableType);
     }
+
+    @Test
+    public void testNullType(){
+        ValueType serializableType = ValueType.getSerializableType(null);
+        assertEquals(ValueType.NULL_TYPE, serializableType);
+
+        assertEquals(null, ValueType.NULL_TYPE.deserialize(""));
+    }
 }
\ No newline at end of file
index a67e887a15cf7c9727ca7e9771acb231fdd4a6b1..6528f2e4d2e6524f2f08acb750aae764c86dbc0b 100644 (file)
@@ -59,10 +59,15 @@ public class NormalizedNodeStreamReaderWriterTest {
                 new YangInstanceIdentifier.NodeWithValue(TestModel.BINARY_LEAF_LIST_QNAME, bytes2)).
                 withValue(bytes2).build();
 
+        LeafSetEntryNode<Object> entry3 = ImmutableLeafSetEntryNodeBuilder.create().withNodeIdentifier(
+                new YangInstanceIdentifier.NodeWithValue(TestModel.BINARY_LEAF_LIST_QNAME, null)).
+                withValue(null).build();
+
+
         return TestModel.createBaseTestContainerBuilder().
                 withChild(ImmutableLeafSetNodeBuilder.create().withNodeIdentifier(
                         new YangInstanceIdentifier.NodeIdentifier(TestModel.BINARY_LEAF_LIST_QNAME)).
-                        withChild(entry1).withChild(entry2).build()).
+                        withChild(entry1).withChild(entry2).withChild(entry3).build()).
                 withChild(ImmutableNodes.leafNode(TestModel.SOME_BINARY_DATA_QNAME, new byte[]{1,2,3,4})).
                 withChild(Builders.orderedMapBuilder().
                       withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TestModel.ORDERED_LIST_QNAME)).
index fc10b9c23b215fd37012e75549a7b997bf41434f..84f07760f53f4a50b7fd3da61b2b3ddeb7f3fe31 100644 (file)
@@ -9,8 +9,7 @@ package org.opendaylight.controller.cluster.datastore;
 
 import akka.actor.ActorSelection;
 import com.google.common.base.Optional;
-import com.google.common.util.concurrent.CheckedFuture;
-import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.SettableFuture;
 import java.util.concurrent.Semaphore;
 import org.opendaylight.controller.cluster.datastore.identifiers.TransactionIdentifier;
 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
@@ -63,20 +62,16 @@ final class NoOpTransactionContext extends AbstractTransactionContext {
     }
 
     @Override
-    public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> readData(
-            YangInstanceIdentifier path) {
+    public void readData(final YangInstanceIdentifier path, SettableFuture<Optional<NormalizedNode<?, ?>>> proxyFuture) {
         LOG.debug("Tx {} readData called path = {}", identifier, path);
         operationLimiter.release();
-        return Futures.immediateFailedCheckedFuture(new ReadFailedException(
-                "Error reading data for path " + path, failure));
+        proxyFuture.setException(new ReadFailedException("Error reading data for path " + path, failure));
     }
 
     @Override
-    public CheckedFuture<Boolean, ReadFailedException> dataExists(
-            YangInstanceIdentifier path) {
+    public void dataExists(YangInstanceIdentifier path, SettableFuture<Boolean> proxyFuture) {
         LOG.debug("Tx {} dataExists called path = {}", identifier, path);
         operationLimiter.release();
-        return Futures.immediateFailedCheckedFuture(new ReadFailedException(
-                "Error checking exists for path " + path, failure));
+        proxyFuture.setException(new ReadFailedException("Error checking exists for path " + path, failure));
     }
-}
\ No newline at end of file
+}
index a3ef0339b7571172dfb0d5b2338f52911a86cf9c..9cd758ba30fdb94e85cd1703d99a8e0c55a50a17 100644 (file)
@@ -11,7 +11,6 @@ package org.opendaylight.controller.cluster.datastore;
 import akka.actor.ActorRef;
 import akka.actor.ActorSelection;
 import akka.actor.Cancellable;
-import akka.actor.PoisonPill;
 import akka.actor.Props;
 import akka.event.Logging;
 import akka.event.LoggingAdapter;
@@ -25,8 +24,7 @@ import com.google.common.collect.Lists;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
-import com.google.protobuf.ByteString;
-import com.google.protobuf.InvalidProtocolBufferException;
+import java.io.IOException;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
@@ -51,31 +49,29 @@ import org.opendaylight.controller.cluster.datastore.messages.CanCommitTransacti
 import org.opendaylight.controller.cluster.datastore.messages.CloseTransactionChain;
 import org.opendaylight.controller.cluster.datastore.messages.CommitTransaction;
 import org.opendaylight.controller.cluster.datastore.messages.CommitTransactionReply;
+import org.opendaylight.controller.cluster.datastore.messages.CreateSnapshot;
 import org.opendaylight.controller.cluster.datastore.messages.CreateTransaction;
 import org.opendaylight.controller.cluster.datastore.messages.CreateTransactionReply;
 import org.opendaylight.controller.cluster.datastore.messages.EnableNotification;
 import org.opendaylight.controller.cluster.datastore.messages.ForwardedReadyTransaction;
 import org.opendaylight.controller.cluster.datastore.messages.PeerAddressResolved;
-import org.opendaylight.controller.cluster.datastore.messages.ReadData;
-import org.opendaylight.controller.cluster.datastore.messages.ReadDataReply;
 import org.opendaylight.controller.cluster.datastore.messages.ReadyTransactionReply;
 import org.opendaylight.controller.cluster.datastore.messages.RegisterChangeListener;
 import org.opendaylight.controller.cluster.datastore.messages.RegisterChangeListenerReply;
 import org.opendaylight.controller.cluster.datastore.messages.UpdateSchemaContext;
 import org.opendaylight.controller.cluster.datastore.modification.Modification;
+import org.opendaylight.controller.cluster.datastore.modification.ModificationPayload;
 import org.opendaylight.controller.cluster.datastore.modification.MutableCompositeModification;
-import org.opendaylight.controller.cluster.datastore.node.NormalizedNodeToNodeCodec;
+import org.opendaylight.controller.cluster.datastore.utils.SerializationUtils;
 import org.opendaylight.controller.cluster.notifications.RoleChangeNotifier;
 import org.opendaylight.controller.cluster.raft.RaftActor;
 import org.opendaylight.controller.cluster.raft.ReplicatedLogEntry;
-import org.opendaylight.controller.cluster.raft.base.messages.CaptureSnapshotReply;
 import org.opendaylight.controller.cluster.raft.protobuff.client.messages.CompositeModificationByteStringPayload;
 import org.opendaylight.controller.cluster.raft.protobuff.client.messages.CompositeModificationPayload;
 import org.opendaylight.controller.cluster.raft.protobuff.client.messages.Payload;
 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeListener;
 import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore;
 import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStoreFactory;
-import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages;
 import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort;
 import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain;
 import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionFactory;
@@ -95,6 +91,8 @@ import scala.concurrent.duration.FiniteDuration;
  */
 public class Shard extends RaftActor {
 
+    private static final YangInstanceIdentifier DATASTORE_ROOT = YangInstanceIdentifier.builder().build();
+
     private static final Object TX_COMMIT_TIMEOUT_CHECK_MESSAGE = "txCommitTimeoutCheck";
 
     @VisibleForTesting
@@ -122,8 +120,6 @@ public class Shard extends RaftActor {
 
     private SchemaContext schemaContext;
 
-    private ActorRef createSnapshotTransaction;
-
     private int createSnapshotTransactionCounter;
 
     private final ShardCommitCoordinator commitCoordinator;
@@ -242,9 +238,7 @@ public class Shard extends RaftActor {
             LOG.debug("onReceiveCommand: Received message {} from {}", message, getSender());
         }
 
-        if(message.getClass().equals(ReadDataReply.SERIALIZABLE_CLASS)) {
-            handleReadDataReply(message);
-        } else if (message.getClass().equals(CreateTransaction.SERIALIZABLE_CLASS)) {
+        if (message.getClass().equals(CreateTransaction.SERIALIZABLE_CLASS)) {
             handleCreateTransaction(message);
         } else if(message instanceof ForwardedReadyTransaction) {
             handleForwardedReadyTransaction((ForwardedReadyTransaction)message);
@@ -326,9 +320,9 @@ public class Shard extends RaftActor {
                 applyModificationToState(getSender(), transactionID, cohortEntry.getModification());
             } else {
                 Shard.this.persistData(getSender(), transactionID,
-                        new CompositeModificationByteStringPayload(cohortEntry.getModification().toSerializable()));
+                        new ModificationPayload(cohortEntry.getModification()));
             }
-        } catch (InterruptedException | ExecutionException e) {
+        } catch (InterruptedException | ExecutionException | IOException e) {
             LOG.error(e, "An exception occurred while preCommitting transaction {}",
                     cohortEntry.getTransactionID());
             shardMBean.incrementFailedTransactionsCount();
@@ -475,20 +469,6 @@ public class Shard extends RaftActor {
         }
     }
 
-    private void handleReadDataReply(final Object message) {
-        // This must be for install snapshot. Don't want to open this up and trigger
-        // deSerialization
-
-        self().tell(new CaptureSnapshotReply(ReadDataReply.fromSerializableAsByteString(message)),
-                self());
-
-        createSnapshotTransaction = null;
-
-        // Send a PoisonPill instead of sending close transaction because we do not really need
-        // a response
-        getSender().tell(PoisonPill.getInstance(), self());
-    }
-
     private void closeTransactionChain(final CloseTransactionChain closeTransactionChain) {
         DOMStoreTransactionChain chain =
             transactionChains.remove(closeTransactionChain.getTransactionChainId());
@@ -684,7 +664,13 @@ public class Shard extends RaftActor {
 
     @Override
     protected void appendRecoveredLogEntry(final Payload data) {
-        if (data instanceof CompositeModificationPayload) {
+        if(data instanceof ModificationPayload) {
+            try {
+                currentLogRecoveryBatch.add(((ModificationPayload) data).getModification());
+            } catch (ClassNotFoundException | IOException e) {
+                LOG.error(e, "Error extracting ModificationPayload");
+            }
+        } else if (data instanceof CompositeModificationPayload) {
             currentLogRecoveryBatch.add(((CompositeModificationPayload) data).getModification());
         } else if (data instanceof CompositeModificationByteStringPayload) {
             currentLogRecoveryBatch.add(((CompositeModificationByteStringPayload) data).getModification());
@@ -694,12 +680,12 @@ public class Shard extends RaftActor {
     }
 
     @Override
-    protected void applyRecoverySnapshot(final ByteString snapshot) {
+    protected void applyRecoverySnapshot(final byte[] snapshotBytes) {
         if(recoveryCoordinator == null) {
             recoveryCoordinator = new ShardRecoveryCoordinator(persistenceId(), schemaContext);
         }
 
-        recoveryCoordinator.submit(snapshot, store.newWriteOnlyTransaction());
+        recoveryCoordinator.submit(snapshotBytes, store.newWriteOnlyTransaction());
 
         if(LOG.isDebugEnabled()) {
             LOG.debug("{} : submitted recovery sbapshot", persistenceId());
@@ -761,7 +747,14 @@ public class Shard extends RaftActor {
     @Override
     protected void applyState(final ActorRef clientActor, final String identifier, final Object data) {
 
-        if (data instanceof CompositeModificationPayload) {
+        if(data instanceof ModificationPayload) {
+            try {
+                applyModificationToState(clientActor, identifier, ((ModificationPayload) data).getModification());
+            } catch (ClassNotFoundException | IOException e) {
+                LOG.error(e, "Error extracting ModificationPayload");
+            }
+        }
+        else if (data instanceof CompositeModificationPayload) {
             Object modification = ((CompositeModificationPayload) data).getModification();
 
             applyModificationToState(clientActor, identifier, modification);
@@ -769,7 +762,6 @@ public class Shard extends RaftActor {
             Object modification = ((CompositeModificationByteStringPayload) data).getModification();
 
             applyModificationToState(clientActor, identifier, modification);
-
         } else {
             LOG.error("Unknown state received {} Class loader = {} CompositeNodeMod.ClassLoader = {}",
                     data, data.getClass().getClassLoader(),
@@ -788,8 +780,7 @@ public class Shard extends RaftActor {
         } else if(clientActor == null) {
             // There's no clientActor to which to send a commit reply so we must be applying
             // replicated state from the leader.
-            commitWithNewTransaction(MutableCompositeModification.fromSerializable(
-                    modification, schemaContext));
+            commitWithNewTransaction(MutableCompositeModification.fromSerializable(modification));
         } else {
             // This must be the OK to commit after replication consensus.
             finishCommit(clientActor, identifier);
@@ -811,24 +802,21 @@ public class Shard extends RaftActor {
 
     @Override
     protected void createSnapshot() {
-        if (createSnapshotTransaction == null) {
+        // Create a transaction actor. We are really going to treat the transaction as a worker
+        // so that this actor does not get block building the snapshot. THe transaction actor will
+        // after processing the CreateSnapshot message.
 
-            // Create a transaction. We are really going to treat the transaction as a worker
-            // so that this actor does not get block building the snapshot
-            createSnapshotTransaction = createTransaction(
+        ActorRef createSnapshotTransaction = createTransaction(
                 TransactionProxy.TransactionType.READ_ONLY.ordinal(),
                 "createSnapshot" + ++createSnapshotTransactionCounter, "",
                 DataStoreVersions.CURRENT_VERSION);
 
-            createSnapshotTransaction.tell(
-                new ReadData(YangInstanceIdentifier.builder().build()).toSerializable(), self());
-
-        }
+        createSnapshotTransaction.tell(CreateSnapshot.INSTANCE, self());
     }
 
     @VisibleForTesting
     @Override
-    protected void applySnapshot(final ByteString snapshot) {
+    protected void applySnapshot(final byte[] snapshotBytes) {
         // Since this will be done only on Recovery or when this actor is a Follower
         // we can safely commit everything in here. We not need to worry about event notifications
         // as they would have already been disabled on the follower
@@ -836,17 +824,16 @@ public class Shard extends RaftActor {
         LOG.info("Applying snapshot");
         try {
             DOMStoreWriteTransaction transaction = store.newWriteOnlyTransaction();
-            NormalizedNodeMessages.Node serializedNode = NormalizedNodeMessages.Node.parseFrom(snapshot);
-            NormalizedNode<?, ?> node = new NormalizedNodeToNodeCodec(schemaContext)
-                .decode(serializedNode);
+
+            NormalizedNode<?, ?> node = SerializationUtils.deserializeNormalizedNode(snapshotBytes);
 
             // delete everything first
-            transaction.delete(YangInstanceIdentifier.builder().build());
+            transaction.delete(DATASTORE_ROOT);
 
             // Add everything from the remote node back
-            transaction.write(YangInstanceIdentifier.builder().build(), node);
+            transaction.write(DATASTORE_ROOT, node);
             syncCommitTransaction(transaction);
-        } catch (InvalidProtocolBufferException | InterruptedException | ExecutionException e) {
+        } catch (InterruptedException | ExecutionException e) {
             LOG.error(e, "An exception occurred when applying snapshot");
         } finally {
             LOG.info("Done applying snapshot");
index be9c4d80e311484d0e6edea2050d85a0ebf28d1f..6f8d0567d9aa162d4080361162fe709decd544ce 100644 (file)
 package org.opendaylight.controller.cluster.datastore;
 
 import akka.actor.ActorRef;
+import akka.actor.PoisonPill;
+import com.google.common.base.Optional;
+import com.google.common.util.concurrent.FutureCallback;
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
 import org.opendaylight.controller.cluster.datastore.jmx.mbeans.shard.ShardStats;
+import org.opendaylight.controller.cluster.datastore.messages.CreateSnapshot;
 import org.opendaylight.controller.cluster.datastore.messages.DataExists;
 import org.opendaylight.controller.cluster.datastore.messages.ReadData;
+import org.opendaylight.controller.cluster.datastore.utils.SerializationUtils;
+import org.opendaylight.controller.cluster.raft.base.messages.CaptureSnapshotReply;
 import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction;
 import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransaction;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
 /**
@@ -23,6 +33,8 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContext;
  * Date: 8/6/14
  */
 public class ShardReadTransaction extends ShardTransaction {
+    private static final YangInstanceIdentifier DATASTORE_ROOT = YangInstanceIdentifier.builder().build();
+
     private final DOMStoreReadTransaction transaction;
 
     public ShardReadTransaction(DOMStoreReadTransaction transaction, ActorRef shardActor,
@@ -39,7 +51,8 @@ public class ShardReadTransaction extends ShardTransaction {
 
         } else if (message instanceof DataExists) {
             dataExists(transaction, (DataExists) message, !SERIALIZED_REPLY);
-
+        } else if (message instanceof CreateSnapshot) {
+            createSnapshot();
         } else if(ReadData.SERIALIZABLE_CLASS.equals(message.getClass())) {
             readData(transaction, ReadData.fromSerializable(message), SERIALIZED_REPLY);
 
@@ -51,6 +64,34 @@ public class ShardReadTransaction extends ShardTransaction {
         }
     }
 
+    private void createSnapshot() {
+
+        // This is a special message sent by the shard to send back a serialized snapshot of the whole
+        // data store tree. This transaction was created for that purpose only so we can
+        // self-destruct after sending the reply.
+
+        final ActorRef sender = getSender();
+        final ActorRef self = getSelf();
+        final ListenableFuture<Optional<NormalizedNode<?, ?>>> future = transaction.read(DATASTORE_ROOT);
+
+        Futures.addCallback(future, new FutureCallback<Optional<NormalizedNode<?, ?>>>() {
+            @Override
+            public void onSuccess(Optional<NormalizedNode<?, ?>> result) {
+                byte[] serialized = SerializationUtils.serializeNormalizedNode(result.get());
+                sender.tell(new CaptureSnapshotReply(serialized), self);
+
+                self.tell(PoisonPill.getInstance(), self);
+            }
+
+            @Override
+            public void onFailure(Throwable t) {
+                sender.tell(new akka.actor.Status.Failure(t), self);
+
+                self.tell(PoisonPill.getInstance(), self);
+            }
+        });
+    }
+
     @Override
     protected DOMStoreTransaction getDOMStoreTransaction() {
         return transaction;
index 94fb5841021ea994e019d946e3e106f7d95256c3..238b4e46dce041add47117503fcb68feb54e8e27 100644 (file)
@@ -7,16 +7,16 @@
  */
 package org.opendaylight.controller.cluster.datastore;
 
+import com.google.common.collect.Lists;
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.TimeUnit;
-
 import org.opendaylight.controller.cluster.datastore.modification.MutableCompositeModification;
-import org.opendaylight.controller.cluster.datastore.node.NormalizedNodeToNodeCodec;
-import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages;
+import org.opendaylight.controller.cluster.datastore.utils.SerializationUtils;
 import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
@@ -24,11 +24,6 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.collect.Lists;
-import com.google.common.util.concurrent.ThreadFactoryBuilder;
-import com.google.protobuf.ByteString;
-import com.google.protobuf.InvalidProtocolBufferException;
-
 /**
  * Coordinates persistence recovery of journal log entries and snapshots for a shard. Each snapshot
  * and journal log entry batch are de-serialized and applied to their own write transaction
@@ -73,11 +68,11 @@ class ShardRecoveryCoordinator {
     /**
      * Submits a snapshot.
      *
-     * @param snapshot the serialized snapshot
+     * @param snapshotBytes the serialized snapshot
      * @param resultingTx the write Tx to which to apply the entries
      */
-    void submit(ByteString snapshot, DOMStoreWriteTransaction resultingTx) {
-        SnapshotRecoveryTask task = new SnapshotRecoveryTask(snapshot, resultingTx);
+    void submit(byte[] snapshotBytes, DOMStoreWriteTransaction resultingTx) {
+        SnapshotRecoveryTask task = new SnapshotRecoveryTask(snapshotBytes, resultingTx);
         resultingTxList.add(resultingTx);
         executor.execute(task);
     }
@@ -121,7 +116,7 @@ class ShardRecoveryCoordinator {
         public void run() {
             for(int i = 0; i < logEntries.size(); i++) {
                 MutableCompositeModification.fromSerializable(
-                        logEntries.get(i), schemaContext).apply(resultingTx);
+                        logEntries.get(i)).apply(resultingTx);
                 // Null out to GC quicker.
                 logEntries.set(i, null);
             }
@@ -130,28 +125,22 @@ class ShardRecoveryCoordinator {
 
     private class SnapshotRecoveryTask extends ShardRecoveryTask {
 
-        private final ByteString snapshot;
+        private final byte[] snapshotBytes;
 
-        SnapshotRecoveryTask(ByteString snapshot, DOMStoreWriteTransaction resultingTx) {
+        SnapshotRecoveryTask(byte[] snapshotBytes, DOMStoreWriteTransaction resultingTx) {
             super(resultingTx);
-            this.snapshot = snapshot;
+            this.snapshotBytes = snapshotBytes;
         }
 
         @Override
         public void run() {
-            try {
-                NormalizedNodeMessages.Node serializedNode = NormalizedNodeMessages.Node.parseFrom(snapshot);
-                NormalizedNode<?, ?> node = new NormalizedNodeToNodeCodec(schemaContext).decode(
-                        serializedNode);
-
-                // delete everything first
-                resultingTx.delete(YangInstanceIdentifier.builder().build());
-
-                // Add everything from the remote node back
-                resultingTx.write(YangInstanceIdentifier.builder().build(), node);
-            } catch (InvalidProtocolBufferException e) {
-                LOG.error("Error deserializing snapshot", e);
-            }
+            NormalizedNode<?, ?> node = SerializationUtils.deserializeNormalizedNode(snapshotBytes);
+
+            // delete everything first
+            resultingTx.delete(YangInstanceIdentifier.builder().build());
+
+            // Add everything from the remote node back
+            resultingTx.write(YangInstanceIdentifier.builder().build(), node);
         }
     }
 }
index 95c7ae10c0c4f394a219cd4ae2afec78c62ed1c7..a4a2f45fdbdda87cc1166aa0e169214eea0df313 100644 (file)
@@ -23,7 +23,6 @@ import org.opendaylight.controller.cluster.datastore.messages.WriteData;
 import org.opendaylight.controller.cluster.datastore.messages.WriteDataReply;
 import org.opendaylight.controller.cluster.datastore.modification.CompositeModification;
 import org.opendaylight.controller.cluster.datastore.modification.DeleteModification;
-import org.opendaylight.controller.cluster.datastore.modification.ImmutableCompositeModification;
 import org.opendaylight.controller.cluster.datastore.modification.MergeModification;
 import org.opendaylight.controller.cluster.datastore.modification.MutableCompositeModification;
 import org.opendaylight.controller.cluster.datastore.modification.WriteModification;
@@ -82,8 +81,7 @@ public class ShardWriteTransaction extends ShardTransaction {
 
         } else if (message instanceof GetCompositedModification) {
             // This is here for testing only
-            getSender().tell(new GetCompositeModificationReply(
-                    new ImmutableCompositeModification(modification)), getSelf());
+            getSender().tell(new GetCompositeModificationReply(modification), getSelf());
         } else {
             super.handleReceive(message);
         }
@@ -94,7 +92,7 @@ public class ShardWriteTransaction extends ShardTransaction {
         LOG.debug("writeData at path : {}", message.getPath());
 
         modification.addModification(
-                new WriteModification(message.getPath(), message.getData(), getSchemaContext()));
+                new WriteModification(message.getPath(), message.getData()));
         try {
             transaction.write(message.getPath(), message.getData());
             WriteDataReply writeDataReply = WriteDataReply.INSTANCE;
@@ -110,7 +108,7 @@ public class ShardWriteTransaction extends ShardTransaction {
         LOG.debug("mergeData at path : {}", message.getPath());
 
         modification.addModification(
-                new MergeModification(message.getPath(), message.getData(), getSchemaContext()));
+                new MergeModification(message.getPath(), message.getData()));
 
         try {
             transaction.merge(message.getPath(), message.getData());
index b6af31e641ce48e95903f935984181340a9eaf72..1b8e65e02d6d1bad037a02beaa77310088b6e67d 100644 (file)
@@ -9,9 +9,8 @@ package org.opendaylight.controller.cluster.datastore;
 
 import akka.actor.ActorSelection;
 import com.google.common.base.Optional;
-import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.SettableFuture;
 import java.util.List;
-import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import scala.concurrent.Future;
@@ -31,10 +30,9 @@ interface TransactionContext {
 
     void mergeData(YangInstanceIdentifier path, NormalizedNode<?, ?> data);
 
-    CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> readData(
-            final YangInstanceIdentifier path);
+    void readData(final YangInstanceIdentifier path, SettableFuture<Optional<NormalizedNode<?, ?>>> proxyFuture);
 
-    CheckedFuture<Boolean, ReadFailedException> dataExists(YangInstanceIdentifier path);
+    void dataExists(YangInstanceIdentifier path, SettableFuture<Boolean> proxyFuture);
 
     List<Future<Object>> getRecordedOperationFutures();
-}
\ No newline at end of file
+}
index ce2c99ef52b2f6d76ee005accc60f4a9475e3253..530a36cff657304005ebd4b43a5bb1e46449951b 100644 (file)
@@ -12,7 +12,6 @@ import akka.dispatch.Mapper;
 import akka.dispatch.OnComplete;
 import com.google.common.base.Optional;
 import com.google.common.collect.Lists;
-import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.SettableFuture;
 import java.util.List;
 import org.opendaylight.controller.cluster.datastore.identifiers.TransactionIdentifier;
@@ -30,7 +29,6 @@ import org.opendaylight.controller.cluster.datastore.messages.VersionedSerializa
 import org.opendaylight.controller.cluster.datastore.messages.WriteData;
 import org.opendaylight.controller.cluster.datastore.utils.ActorContext;
 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
-import org.opendaylight.yangtools.util.concurrent.MappingCheckedFuture;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
@@ -179,13 +177,11 @@ final class TransactionContextImpl extends AbstractTransactionContext {
     }
 
     @Override
-    public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> readData(
-            final YangInstanceIdentifier path) {
+    public void readData(
+            final YangInstanceIdentifier path,final SettableFuture<Optional<NormalizedNode<?, ?>>> returnFuture ) {
 
         LOG.debug("Tx {} readData called path = {}", identifier, path);
 
-        final SettableFuture<Optional<NormalizedNode<?, ?>>> returnFuture = SettableFuture.create();
-
         // If there were any previous recorded put/merge/delete operation reply Futures then we
         // must wait for them to successfully complete. This is necessary to honor the read
         // uncommitted semantics of the public API contract. If any one fails then fail the read.
@@ -223,7 +219,6 @@ final class TransactionContextImpl extends AbstractTransactionContext {
             combinedFutures.onComplete(onComplete, actorContext.getActorSystem().dispatcher());
         }
 
-        return MappingCheckedFuture.create(returnFuture, ReadFailedException.MAPPER);
     }
 
     private void finishReadData(final YangInstanceIdentifier path,
@@ -264,13 +259,10 @@ final class TransactionContextImpl extends AbstractTransactionContext {
     }
 
     @Override
-    public CheckedFuture<Boolean, ReadFailedException> dataExists(
-            final YangInstanceIdentifier path) {
+    public void dataExists(final YangInstanceIdentifier path, final SettableFuture<Boolean> returnFuture) {
 
         LOG.debug("Tx {} dataExists called path = {}", identifier, path);
 
-        final SettableFuture<Boolean> returnFuture = SettableFuture.create();
-
         // If there were any previous recorded put/merge/delete operation reply Futures then we
         // must wait for them to successfully complete. This is necessary to honor the read
         // uncommitted semantics of the public API contract. If any one fails then fail this
@@ -307,8 +299,6 @@ final class TransactionContextImpl extends AbstractTransactionContext {
 
             combinedFutures.onComplete(onComplete, actorContext.getActorSystem().dispatcher());
         }
-
-        return MappingCheckedFuture.create(returnFuture, ReadFailedException.MAPPER);
     }
 
     private void finishDataExists(final YangInstanceIdentifier path,
@@ -344,4 +334,4 @@ final class TransactionContextImpl extends AbstractTransactionContext {
 
         future.onComplete(onComplete, actorContext.getActorSystem().dispatcher());
     }
-}
\ No newline at end of file
+}
index d79cd6f69f4b0e3e4f1171a332b45c36adbbd515..5bc53442aeff04aa43c299a49890b3ecfe70b974 100644 (file)
@@ -18,8 +18,6 @@ import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.Lists;
 import com.google.common.util.concurrent.CheckedFuture;
-import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.SettableFuture;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -257,14 +255,17 @@ public class TransactionProxy implements DOMStoreReadWriteTransaction {
 
         throttleOperation();
 
+        final SettableFuture<Optional<NormalizedNode<?, ?>>> proxyFuture = SettableFuture.create();
+
         TransactionFutureCallback txFutureCallback = getOrCreateTxFutureCallback(path);
-        return txFutureCallback.enqueueReadOperation(new ReadOperation<Optional<NormalizedNode<?, ?>>>() {
+        txFutureCallback.enqueueTransactionOperation(new TransactionOperation() {
             @Override
-            public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> invoke(
-                    TransactionContext transactionContext) {
-                return transactionContext.readData(path);
+            public void invoke(TransactionContext transactionContext) {
+                transactionContext.readData(path, proxyFuture);
             }
         });
+
+        return MappingCheckedFuture.create(proxyFuture, ReadFailedException.MAPPER);
     }
 
     @Override
@@ -277,15 +278,18 @@ public class TransactionProxy implements DOMStoreReadWriteTransaction {
 
         throttleOperation();
 
+        final SettableFuture<Boolean> proxyFuture = SettableFuture.create();
+
         TransactionFutureCallback txFutureCallback = getOrCreateTxFutureCallback(path);
-        return txFutureCallback.enqueueReadOperation(new ReadOperation<Boolean>() {
+        txFutureCallback.enqueueTransactionOperation(new TransactionOperation() {
             @Override
-            public CheckedFuture<Boolean, ReadFailedException> invoke(TransactionContext transactionContext) {
-                return transactionContext.dataExists(path);
+            public void invoke(TransactionContext transactionContext) {
+                transactionContext.dataExists(path, proxyFuture);
             }
         });
-    }
 
+        return MappingCheckedFuture.create(proxyFuture, ReadFailedException.MAPPER);
+    }
 
     private void checkModificationState() {
         Preconditions.checkState(transactionType != TransactionType.READ_ONLY,
@@ -323,7 +327,7 @@ public class TransactionProxy implements DOMStoreReadWriteTransaction {
         throttleOperation();
 
         TransactionFutureCallback txFutureCallback = getOrCreateTxFutureCallback(path);
-        txFutureCallback.enqueueModifyOperation(new TransactionOperation() {
+        txFutureCallback.enqueueTransactionOperation(new TransactionOperation() {
             @Override
             public void invoke(TransactionContext transactionContext) {
                 transactionContext.writeData(path, data);
@@ -341,7 +345,7 @@ public class TransactionProxy implements DOMStoreReadWriteTransaction {
         throttleOperation();
 
         TransactionFutureCallback txFutureCallback = getOrCreateTxFutureCallback(path);
-        txFutureCallback.enqueueModifyOperation(new TransactionOperation() {
+        txFutureCallback.enqueueTransactionOperation(new TransactionOperation() {
             @Override
             public void invoke(TransactionContext transactionContext) {
                 transactionContext.mergeData(path, data);
@@ -359,7 +363,7 @@ public class TransactionProxy implements DOMStoreReadWriteTransaction {
         throttleOperation();
 
         TransactionFutureCallback txFutureCallback = getOrCreateTxFutureCallback(path);
-        txFutureCallback.enqueueModifyOperation(new TransactionOperation() {
+        txFutureCallback.enqueueTransactionOperation(new TransactionOperation() {
             @Override
             public void invoke(TransactionContext transactionContext) {
                 transactionContext.deleteData(path);
@@ -386,12 +390,21 @@ public class TransactionProxy implements DOMStoreReadWriteTransaction {
             LOG.debug("Tx {} Readying transaction for shard {} chain {}", identifier,
                         txFutureCallback.getShardName(), transactionChainId);
 
-            Future<ActorSelection> future = txFutureCallback.enqueueFutureOperation(new FutureOperation<ActorSelection>() {
-                @Override
-                public Future<ActorSelection> invoke(TransactionContext transactionContext) {
-                    return transactionContext.readyTransaction();
-                }
-            });
+            final TransactionContext transactionContext = txFutureCallback.getTransactionContext();
+            final Future<ActorSelection> future;
+            if (transactionContext != null) {
+                // avoid the creation of a promise and a TransactionOperation
+                future = transactionContext.readyTransaction();
+            } else {
+                final Promise<ActorSelection> promise = akka.dispatch.Futures.promise();
+                txFutureCallback.enqueueTransactionOperation(new TransactionOperation() {
+                    @Override
+                    public void invoke(TransactionContext transactionContext) {
+                        promise.completeWith(transactionContext.readyTransaction());
+                    }
+                });
+                future = promise.future();
+            }
 
             cohortFutures.add(future);
         }
@@ -430,7 +443,7 @@ public class TransactionProxy implements DOMStoreReadWriteTransaction {
     @Override
     public void close() {
         for (TransactionFutureCallback txFutureCallback : txFutureCallbackMap.values()) {
-            txFutureCallback.enqueueModifyOperation(new TransactionOperation() {
+            txFutureCallback.enqueueTransactionOperation(new TransactionOperation() {
                 @Override
                 public void invoke(TransactionContext transactionContext) {
                     transactionContext.closeTransaction();
@@ -492,20 +505,6 @@ public class TransactionProxy implements DOMStoreReadWriteTransaction {
         void invoke(TransactionContext transactionContext);
     }
 
-    /**
-     * This interface returns a Guava Future
-     */
-    private static interface ReadOperation<T> {
-        CheckedFuture<T, ReadFailedException> invoke(TransactionContext transactionContext);
-    }
-
-    /**
-     * This interface returns a Scala Future
-     */
-    private static interface FutureOperation<T> {
-        Future<T> invoke(TransactionContext transactionContext);
-    }
-
     /**
      * Implements a Future OnComplete callback for a CreateTransaction message. This class handles
      * retries, up to a limit, if the shard doesn't have a leader yet. This is done by scheduling a
@@ -582,64 +581,7 @@ public class TransactionProxy implements DOMStoreReadWriteTransaction {
             }
         }
 
-
-        <T> Future<T> enqueueFutureOperation(final FutureOperation<T> op) {
-
-            Future<T> future;
-
-            if (transactionContext != null) {
-                future = op.invoke(transactionContext);
-            } else {
-                // The shard Tx hasn't been created yet so add the Tx operation to the Tx Future
-                // callback to be executed after the Tx is created.
-                final Promise<T> promise = akka.dispatch.Futures.promise();
-                addTxOperationOnComplete(new TransactionOperation() {
-                    @Override
-                    public void invoke(TransactionContext transactionContext) {
-                        promise.completeWith(op.invoke(transactionContext));
-                    }
-                });
-
-                future = promise.future();
-            }
-
-            return future;
-        }
-
-        <T> CheckedFuture<T, ReadFailedException> enqueueReadOperation(final ReadOperation<T> op) {
-
-            CheckedFuture<T, ReadFailedException> future;
-
-            if (transactionContext != null) {
-                future = op.invoke(transactionContext);
-            } else {
-                // The shard Tx hasn't been created yet so add the Tx operation to the Tx Future
-                // callback to be executed after the Tx is created.
-                final SettableFuture<T> proxyFuture = SettableFuture.create();
-                addTxOperationOnComplete(new TransactionOperation() {
-                    @Override
-                    public void invoke(TransactionContext transactionContext) {
-                        Futures.addCallback(op.invoke(transactionContext), new FutureCallback<T>() {
-                            @Override
-                            public void onSuccess(T data) {
-                                proxyFuture.set(data);
-                            }
-
-                            @Override
-                            public void onFailure(Throwable t) {
-                                proxyFuture.setException(t);
-                            }
-                        });
-                    }
-                });
-
-                future = MappingCheckedFuture.create(proxyFuture, ReadFailedException.MAPPER);
-            }
-
-            return future;
-        }
-
-        void enqueueModifyOperation(final TransactionOperation op) {
+        void enqueueTransactionOperation(final TransactionOperation op) {
 
             if (transactionContext != null) {
                 op.invoke(transactionContext);
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CreateSnapshot.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CreateSnapshot.java
new file mode 100644 (file)
index 0000000..c0d19af
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * Copyright (c) 2015 Brocade Communications Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.cluster.datastore.messages;
+
+/**
+ * Message sent to a transaction actor to create a snapshot of the data store.
+ *
+ * @author Thomas Pantelis
+ */
+public class CreateSnapshot {
+    // Note: This class does not need to Serializable as it's only sent locally.
+
+    public static final CreateSnapshot INSTANCE = new CreateSnapshot();
+}
index 4f4f0fb8f17b3baf065c2340e97819ff97f2a43e..f04d00440405deab7e5a8be141fd624fd3c30f35 100644 (file)
@@ -11,22 +11,24 @@ package org.opendaylight.controller.cluster.datastore.modification;
 
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 
-import java.io.Serializable;
-
 /**
  * Base class to be used for all simple modifications that can be applied to a DOMStoreTransaction
  */
-public abstract class AbstractModification implements Modification,
-    Serializable {
+public abstract class AbstractModification implements Modification {
 
-    private static final long serialVersionUID = 1638042650152084457L;
+    private YangInstanceIdentifier path;
 
-    protected final YangInstanceIdentifier path;
+    protected AbstractModification() {
+    }
 
     protected AbstractModification(YangInstanceIdentifier path) {
         this.path = path;
     }
 
+    protected void setPath(YangInstanceIdentifier path) {
+        this.path = path;
+    }
+
     public YangInstanceIdentifier getPath() {
         return path;
     }
index 056fe756371589c7d055d054b8884f50db5bd60f..833f86fb981f1179ce326c4d3703f17c3449aa73 100644 (file)
@@ -8,7 +8,12 @@
 
 package org.opendaylight.controller.cluster.datastore.modification;
 
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import org.opendaylight.controller.cluster.datastore.DataStoreVersions;
 import org.opendaylight.controller.cluster.datastore.util.InstanceIdentifierUtils;
+import org.opendaylight.controller.cluster.datastore.utils.SerializationUtils;
 import org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages;
 import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
@@ -19,23 +24,51 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 public class DeleteModification extends AbstractModification {
     private static final long serialVersionUID = 1L;
 
+    public DeleteModification() {
+    }
+
     public DeleteModification(YangInstanceIdentifier path) {
         super(path);
     }
 
     @Override
     public void apply(DOMStoreWriteTransaction transaction) {
-        transaction.delete(path);
+        transaction.delete(getPath());
     }
 
     @Override
+    public byte getType() {
+        return DELETE;
+    }
+
+    @Override
+    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+        in.readShort();
+        setPath(SerializationUtils.deserializePath(in));
+    }
+
+    @Override
+    public void writeExternal(ObjectOutput out) throws IOException {
+        out.writeShort(DataStoreVersions.CURRENT_VERSION);
+        SerializationUtils.serializePath(getPath(), out);
+    }
+
+    @Override
+    @Deprecated
     public Object toSerializable() {
         return PersistentMessages.Modification.newBuilder().setType(this.getClass().toString())
-                .setPath(InstanceIdentifierUtils.toSerializable(this.path)).build();
+                .setPath(InstanceIdentifierUtils.toSerializable(getPath())).build();
     }
 
+    @Deprecated
     public static DeleteModification fromSerializable(Object serializable) {
         PersistentMessages.Modification o = (PersistentMessages.Modification) serializable;
         return new DeleteModification(InstanceIdentifierUtils.fromSerializable(o.getPath()));
     }
+
+    public static DeleteModification fromStream(ObjectInput in) throws ClassNotFoundException, IOException {
+        DeleteModification mod = new DeleteModification();
+        mod.readExternal(in);
+        return mod;
+    }
 }
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/ImmutableCompositeModification.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/ImmutableCompositeModification.java
deleted file mode 100644 (file)
index 2d11500..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.controller.cluster.datastore.modification;
-
-import org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
-
-import java.util.List;
-
-public class ImmutableCompositeModification implements CompositeModification {
-
-    private final CompositeModification modification;
-
-    public ImmutableCompositeModification(CompositeModification modification) {
-        this.modification = modification;
-    }
-
-    @Override
-    public List<Modification> getModifications() {
-        return modification.getModifications();
-    }
-
-    @Override
-    public void apply(DOMStoreWriteTransaction transaction) {
-        modification.apply(transaction);
-    }
-
-    @Override public Object toSerializable() {
-
-        PersistentMessages.CompositeModification.Builder builder =
-            PersistentMessages.CompositeModification.newBuilder();
-
-        for (Modification m : modification.getModifications()) {
-            builder.addModification(
-                (PersistentMessages.Modification) m.toSerializable());
-        }
-
-        return builder.build();
-    }
-}
index 2f9d77660aba4d76b671b91df000baae5c5780ba..571443eedd3a89f2ce9d474cbfbd883919a8d7ff 100644 (file)
@@ -8,13 +8,14 @@
 
 package org.opendaylight.controller.cluster.datastore.modification;
 
+import java.io.IOException;
+import java.io.ObjectInput;
 import org.opendaylight.controller.cluster.datastore.node.NormalizedNodeToNodeCodec;
 import org.opendaylight.controller.cluster.datastore.node.NormalizedNodeToNodeCodec.Decoded;
 import org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages;
 import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
 /**
  * MergeModification stores all the parameters required to merge data into the specified path
@@ -22,19 +23,33 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 public class MergeModification extends WriteModification {
     private static final long serialVersionUID = 1L;
 
-    public MergeModification(final YangInstanceIdentifier path, final NormalizedNode<?, ?> data,
-        final SchemaContext schemaContext) {
-        super(path, data, schemaContext);
+    public MergeModification() {
+    }
+
+    public MergeModification(final YangInstanceIdentifier path, final NormalizedNode<?, ?> data) {
+        super(path, data);
     }
 
     @Override
     public void apply(final DOMStoreWriteTransaction transaction) {
-        transaction.merge(path, data);
+        transaction.merge(getPath(), getData());
     }
 
-    public static MergeModification fromSerializable(final Object serializable, final SchemaContext schemaContext) {
+    @Override
+    public byte getType() {
+        return MERGE;
+    }
+
+    @Deprecated
+    public static MergeModification fromSerializable(final Object serializable) {
         PersistentMessages.Modification o = (PersistentMessages.Modification) serializable;
-        Decoded decoded = new NormalizedNodeToNodeCodec(schemaContext).decode(o.getPath(), o.getData());
-        return new MergeModification(decoded.getDecodedPath(), decoded.getDecodedNode(), schemaContext);
+        Decoded decoded = new NormalizedNodeToNodeCodec(null).decode(o.getPath(), o.getData());
+        return new MergeModification(decoded.getDecodedPath(), decoded.getDecodedNode());
+    }
+
+    public static MergeModification fromStream(ObjectInput in) throws ClassNotFoundException, IOException {
+        MergeModification mod = new MergeModification();
+        mod.readExternal(in);
+        return mod;
     }
 }
index ed9b1fe3b9548f9b529b4e1e9ce6929e41fcda11..2dfcdf028785aeb5f35369b983b59e314469289f 100644 (file)
@@ -8,7 +8,7 @@
 
 package org.opendaylight.controller.cluster.datastore.modification;
 
-import org.opendaylight.controller.cluster.datastore.messages.SerializableMessage;
+import java.io.Externalizable;
 import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
 
 /**
@@ -25,10 +25,22 @@ import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
  * which can then be applied to a write transaction
  * </p>
  */
-public interface Modification extends SerializableMessage {
-  /**
-   * Apply the modification to the specified transaction
-   * @param transaction
-   */
-  void apply(DOMStoreWriteTransaction transaction);
+public interface Modification extends Externalizable {
+
+    byte COMPOSITE = 1;
+    byte WRITE = 2;
+    byte MERGE = 3;
+    byte DELETE = 4;
+
+    /**
+     * Apply the modification to the specified transaction
+     *
+     * @param transaction
+     */
+    void apply(DOMStoreWriteTransaction transaction);
+
+    byte getType();
+
+    @Deprecated
+    Object toSerializable();
 }
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/ModificationPayload.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/ModificationPayload.java
new file mode 100644 (file)
index 0000000..2e39157
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2015 Brocade Communications Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.cluster.datastore.modification;
+
+import com.google.protobuf.GeneratedMessage.GeneratedExtension;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutput;
+import java.io.ObjectOutputStream;
+import java.util.Map;
+import org.opendaylight.controller.cluster.raft.protobuff.client.messages.Payload;
+import org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry;
+
+/**
+ * Payload implementation for MutableCompositeModification used for persistence and replication.
+ *
+ * @author Thomas Pantelis
+ */
+public class ModificationPayload extends Payload implements Externalizable {
+    private static final long serialVersionUID = 1L;
+
+    private transient byte[] serializedPayload;
+
+    public ModificationPayload() {
+    }
+
+    public ModificationPayload(Modification from) throws IOException {
+        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        ObjectOutputStream out = new ObjectOutputStream(bos);
+        out.writeObject(from);
+        out.close();
+        serializedPayload = bos.toByteArray();
+    }
+
+    public Modification getModification() throws IOException, ClassNotFoundException {
+        ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(serializedPayload));
+        Modification to = (Modification) in.readObject();
+        in.close();
+        return to;
+    }
+
+    @Override
+    public int size() {
+        return serializedPayload.length;
+    }
+
+    @Override
+    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+        int size = in.readInt();
+        serializedPayload = new byte[size];
+        in.readFully(serializedPayload);
+    }
+
+    @Override
+    public void writeExternal(ObjectOutput out) throws IOException {
+        out.writeInt(serializedPayload.length);
+        out.write(serializedPayload);
+    }
+
+    @SuppressWarnings("rawtypes")
+    @Override
+    @Deprecated
+    public <T> Map<GeneratedExtension, T> encode() {
+        return null;
+    }
+
+    @Override
+    @Deprecated
+    public Payload decode(ReplicatedLogEntry.Payload payload) {
+        return null;
+    }
+}
index 04854d26b2c060ae3b231481d1933a663e6d0b49..5d7947b19fc6ddaeafe133ec546dfc879dd07855 100644 (file)
@@ -8,24 +8,30 @@
 
 package org.opendaylight.controller.cluster.datastore.modification;
 
-import org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.List;
+import org.opendaylight.controller.cluster.datastore.DataStoreVersions;
+import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeInputStreamReader;
+import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeOutputStreamWriter;
+import org.opendaylight.controller.cluster.datastore.utils.SerializationUtils;
+import org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages;
+import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
 
 /**
  * MutableCompositeModification is just a mutable version of a
  * CompositeModification {@link org.opendaylight.controller.cluster.datastore.modification.MutableCompositeModification#addModification(Modification)}
  */
-public class MutableCompositeModification
-    implements CompositeModification {
+public class MutableCompositeModification implements CompositeModification {
+    private static final long serialVersionUID = 1L;
 
-    private static final long serialVersionUID = 1163377899140186790L;
+    private final List<Modification> modifications;
 
-    private final List<Modification> modifications = new ArrayList<>();
+    public MutableCompositeModification() {
+        modifications = new ArrayList<>();
+    }
 
     @Override
     public void apply(DOMStoreWriteTransaction transaction) {
@@ -34,6 +40,11 @@ public class MutableCompositeModification
         }
     }
 
+    @Override
+    public byte getType() {
+        return COMPOSITE;
+    }
+
     /**
      * Add a new Modification to the list of Modifications represented by this
      * composite
@@ -44,25 +55,88 @@ public class MutableCompositeModification
         modifications.add(modification);
     }
 
+    @Override
     public List<Modification> getModifications() {
-        return Collections.unmodifiableList(modifications);
+        return modifications;
+    }
+
+    @Override
+    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+        in.readShort();
+
+        int size = in.readInt();
+
+        if(size > 1) {
+            SerializationUtils.REUSABLE_READER_TL.set(new NormalizedNodeInputStreamReader(in));
+        }
+
+        try {
+            for(int i = 0; i < size; i++) {
+                byte type = in.readByte();
+                switch(type) {
+                case Modification.WRITE:
+                    modifications.add(WriteModification.fromStream(in));
+                    break;
+
+                case Modification.MERGE:
+                    modifications.add(MergeModification.fromStream(in));
+                    break;
+
+                case Modification.DELETE:
+                    modifications.add(DeleteModification.fromStream(in));
+                    break;
+                }
+            }
+        } finally {
+            SerializationUtils.REUSABLE_READER_TL.remove();
+        }
+    }
+
+    @Override
+    public void writeExternal(ObjectOutput out) throws IOException {
+        out.writeShort(DataStoreVersions.CURRENT_VERSION);
+
+        out.writeInt(modifications.size());
+
+        if(modifications.size() > 1) {
+            SerializationUtils.REUSABLE_WRITER_TL.set(new NormalizedNodeOutputStreamWriter(out));
+        }
+
+        try {
+            for(Modification mod: modifications) {
+                out.writeByte(mod.getType());
+                mod.writeExternal(out);
+            }
+        } finally {
+            SerializationUtils.REUSABLE_WRITER_TL.remove();
+        }
     }
 
-    @Override public Object toSerializable() {
+    @Override
+    @Deprecated
+    public Object toSerializable() {
         PersistentMessages.CompositeModification.Builder builder =
-            PersistentMessages.CompositeModification.newBuilder();
+                PersistentMessages.CompositeModification.newBuilder();
 
         builder.setTimeStamp(System.nanoTime());
 
         for (Modification m : modifications) {
             builder.addModification(
-                (PersistentMessages.Modification) m.toSerializable());
+                    (PersistentMessages.Modification) m.toSerializable());
         }
 
         return builder.build();
     }
 
-    public static MutableCompositeModification fromSerializable(Object serializable, SchemaContext schemaContext){
+    public static MutableCompositeModification fromSerializable(Object serializable) {
+        if(serializable instanceof MutableCompositeModification) {
+            return (MutableCompositeModification)serializable;
+        } else {
+            return fromLegacySerializable(serializable);
+        }
+    }
+
+    private static MutableCompositeModification fromLegacySerializable(Object serializable) {
         PersistentMessages.CompositeModification o = (PersistentMessages.CompositeModification) serializable;
         MutableCompositeModification compositeModification = new MutableCompositeModification();
 
@@ -70,9 +144,9 @@ public class MutableCompositeModification
             if(m.getType().equals(DeleteModification.class.toString())){
                 compositeModification.addModification(DeleteModification.fromSerializable(m));
             } else if(m.getType().equals(WriteModification.class.toString())){
-                compositeModification.addModification(WriteModification.fromSerializable(m, schemaContext));
+                compositeModification.addModification(WriteModification.fromSerializable(m));
             } else if(m.getType().equals(MergeModification.class.toString())){
-                compositeModification.addModification(MergeModification.fromSerializable(m, schemaContext));
+                compositeModification.addModification(MergeModification.fromSerializable(m));
             }
         }
 
index b2964086fd976b03516df0872d007f2f0a124af6..9c122c9adeef8a14cf05bfa877d38a5cbe310ae2 100644 (file)
@@ -8,32 +8,39 @@
 
 package org.opendaylight.controller.cluster.datastore.modification;
 
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import org.opendaylight.controller.cluster.datastore.DataStoreVersions;
 import org.opendaylight.controller.cluster.datastore.node.NormalizedNodeToNodeCodec;
 import org.opendaylight.controller.cluster.datastore.node.NormalizedNodeToNodeCodec.Decoded;
 import org.opendaylight.controller.cluster.datastore.node.NormalizedNodeToNodeCodec.Encoded;
+import org.opendaylight.controller.cluster.datastore.utils.SerializationUtils;
+import org.opendaylight.controller.cluster.datastore.utils.SerializationUtils.Applier;
 import org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages;
 import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
 /**
  * WriteModification stores all the parameters required to write data to the specified path
  */
 public class WriteModification extends AbstractModification {
     private static final long serialVersionUID = 1L;
-    protected final NormalizedNode<?, ?> data;
-    private final SchemaContext schemaContext;
 
-    public WriteModification(final YangInstanceIdentifier path, final NormalizedNode<?, ?> data, final SchemaContext schemaContext) {
+    private NormalizedNode<?, ?> data;
+
+    public WriteModification() {
+    }
+
+    public WriteModification(final YangInstanceIdentifier path, final NormalizedNode<?, ?> data) {
         super(path);
         this.data = data;
-        this.schemaContext = schemaContext;
     }
 
     @Override
     public void apply(final DOMStoreWriteTransaction transaction) {
-        transaction.write(path, data);
+        transaction.write(getPath(), data);
     }
 
     public NormalizedNode<?, ?> getData() {
@@ -41,19 +48,51 @@ public class WriteModification extends AbstractModification {
     }
 
     @Override
-    public Object toSerializable() {
-        Encoded encoded = new NormalizedNodeToNodeCodec(schemaContext).encode(path, data);
+    public byte getType() {
+        return WRITE;
+    }
 
-        return PersistentMessages.Modification.newBuilder()
-                .setType(this.getClass().toString())
-                .setPath(encoded.getEncodedPath())
-                .setData(encoded.getEncodedNode().getNormalizedNode())
-                .build();
+    @Override
+    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+        in.readShort(); // version
+
+        SerializationUtils.deserializePathAndNode(in, this, APPLIER);
     }
 
-    public static WriteModification fromSerializable(final Object serializable, final SchemaContext schemaContext) {
+    @Override
+    public void writeExternal(ObjectOutput out) throws IOException {
+        out.writeShort(DataStoreVersions.CURRENT_VERSION);
+        SerializationUtils.serializePathAndNode(getPath(), data, out);
+    }
+
+    @Override
+    @Deprecated
+    public Object toSerializable() {
+        Encoded encoded = new NormalizedNodeToNodeCodec(null).encode(getPath(), getData());
+        return PersistentMessages.Modification.newBuilder().setType(this.getClass().toString())
+                .setPath(encoded.getEncodedPath()).setData(encoded.getEncodedNode()
+                        .getNormalizedNode()).build();
+    }
+
+    @Deprecated
+    public static WriteModification fromSerializable(final Object serializable) {
         PersistentMessages.Modification o = (PersistentMessages.Modification) serializable;
-        Decoded decoded = new NormalizedNodeToNodeCodec(schemaContext).decode(o.getPath(), o.getData());
-        return new WriteModification(decoded.getDecodedPath(), decoded.getDecodedNode(), schemaContext);
+        Decoded decoded = new NormalizedNodeToNodeCodec(null).decode(o.getPath(), o.getData());
+        return new WriteModification(decoded.getDecodedPath(), decoded.getDecodedNode());
+    }
+
+    public static WriteModification fromStream(ObjectInput in) throws ClassNotFoundException, IOException {
+        WriteModification mod = new WriteModification();
+        mod.readExternal(in);
+        return mod;
     }
+
+    private static final Applier<WriteModification> APPLIER = new Applier<WriteModification>() {
+        @Override
+        public void apply(WriteModification instance, YangInstanceIdentifier path,
+                NormalizedNode<?, ?> node) {
+            instance.setPath(path);
+            instance.data = node;
+        }
+    };
 }
index 87c78bd27535cdbd08ed2e86c3af3b59abb7c8ca..5854932a6fa0d999fe368aa61bfdd252821739c6 100644 (file)
@@ -8,14 +8,20 @@
 package org.opendaylight.controller.cluster.datastore.utils;
 
 import com.google.common.base.Preconditions;
+import com.google.protobuf.InvalidProtocolBufferException;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
 import java.io.DataInput;
+import java.io.DataInputStream;
 import java.io.DataOutput;
+import java.io.DataOutputStream;
 import java.io.IOException;
+import org.opendaylight.controller.cluster.datastore.node.NormalizedNodeToNodeCodec;
 import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeInputStreamReader;
 import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeOutputStreamWriter;
+import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages;
 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.stream.NormalizedNodeWriter;
 
 /**
  * Provides various utility methods for serialization and de-serialization.
@@ -23,18 +29,38 @@ import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWrit
  * @author Thomas Pantelis
  */
 public final class SerializationUtils {
+    public static ThreadLocal<NormalizedNodeOutputStreamWriter> REUSABLE_WRITER_TL = new ThreadLocal<>();
+    public static ThreadLocal<NormalizedNodeInputStreamReader> REUSABLE_READER_TL = new ThreadLocal<>();
 
     public static interface Applier<T> {
         void apply(T instance, YangInstanceIdentifier path, NormalizedNode<?, ?> node);
     }
 
+    private static NormalizedNodeOutputStreamWriter streamWriter(DataOutput out) throws IOException {
+        NormalizedNodeOutputStreamWriter streamWriter = REUSABLE_WRITER_TL.get();
+        if(streamWriter == null) {
+            streamWriter = new NormalizedNodeOutputStreamWriter(out);
+        }
+
+        return streamWriter;
+    }
+
+    private static NormalizedNodeInputStreamReader streamReader(DataInput in) throws IOException {
+        NormalizedNodeInputStreamReader streamWriter = REUSABLE_READER_TL.get();
+        if(streamWriter == null) {
+            streamWriter = new NormalizedNodeInputStreamReader(in);
+        }
+
+        return streamWriter;
+    }
+
     public static void serializePathAndNode(YangInstanceIdentifier path, NormalizedNode<?, ?> node,
             DataOutput out) {
         Preconditions.checkNotNull(path);
         Preconditions.checkNotNull(node);
         try {
-            NormalizedNodeOutputStreamWriter streamWriter = new NormalizedNodeOutputStreamWriter(out);
-            NormalizedNodeWriter.forStreamWriter(streamWriter).write(node);
+            NormalizedNodeOutputStreamWriter streamWriter = streamWriter(out);
+            streamWriter.writeNormalizedNode(node);
             streamWriter.writeYangInstanceIdentifier(path);
         } catch (IOException e) {
             throw new IllegalArgumentException(String.format("Error serializing path %s and Node %s",
@@ -44,7 +70,7 @@ public final class SerializationUtils {
 
     public static <T> void deserializePathAndNode(DataInput in, T instance, Applier<T> applier) {
         try {
-            NormalizedNodeInputStreamReader streamReader = new NormalizedNodeInputStreamReader(in);
+            NormalizedNodeInputStreamReader streamReader = streamReader(in);
             NormalizedNode<?, ?> node = streamReader.readNormalizedNode();
             YangInstanceIdentifier path = streamReader.readYangInstanceIdentifier();
             applier.apply(instance, path, node);
@@ -57,8 +83,8 @@ public final class SerializationUtils {
         try {
             out.writeBoolean(node != null);
             if(node != null) {
-                NormalizedNodeOutputStreamWriter streamWriter = new NormalizedNodeOutputStreamWriter(out);
-                NormalizedNodeWriter.forStreamWriter(streamWriter).write(node);
+                NormalizedNodeOutputStreamWriter streamWriter = streamWriter(out);
+                streamWriter.writeNormalizedNode(node);
             }
         } catch (IOException e) {
             throw new IllegalArgumentException(String.format("Error serializing NormalizedNode %s",
@@ -70,7 +96,7 @@ public final class SerializationUtils {
             try {
                 boolean present = in.readBoolean();
                 if(present) {
-                    NormalizedNodeInputStreamReader streamReader = new NormalizedNodeInputStreamReader(in);
+                    NormalizedNodeInputStreamReader streamReader = streamReader(in);
                     return streamReader.readNormalizedNode();
                 }
             } catch (IOException e) {
@@ -80,19 +106,45 @@ public final class SerializationUtils {
         return null;
     }
 
+    public static NormalizedNode<?, ?> deserializeNormalizedNode(byte [] bytes) {
+        NormalizedNode<?, ?> node = null;
+        try {
+            node = deserializeNormalizedNode(new DataInputStream(new ByteArrayInputStream(bytes)));
+        } catch(Exception e) {
+        }
+
+        if(node == null) {
+            // Must be from legacy protobuf serialization - try that.
+            try {
+                NormalizedNodeMessages.Node serializedNode = NormalizedNodeMessages.Node.parseFrom(bytes);
+                node =  new NormalizedNodeToNodeCodec(null).decode(serializedNode);
+            } catch (InvalidProtocolBufferException e) {
+                throw new IllegalArgumentException("Error deserializing NormalizedNode", e);
+            }
+        }
+
+        return node;
+    }
+
+    public static byte [] serializeNormalizedNode(NormalizedNode<?, ?> node) {
+        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        serializeNormalizedNode(node, new DataOutputStream(bos));
+        return bos.toByteArray();
+    }
+
     public static void serializePath(YangInstanceIdentifier path, DataOutput out) {
         Preconditions.checkNotNull(path);
         try {
-            NormalizedNodeOutputStreamWriter streamWriter = new NormalizedNodeOutputStreamWriter(out);
+            NormalizedNodeOutputStreamWriter streamWriter = streamWriter(out);
             streamWriter.writeYangInstanceIdentifier(path);
         } catch (IOException e) {
-            throw new IllegalArgumentException(String.format("Error serializing path {}", path), e);
+            throw new IllegalArgumentException(String.format("Error serializing path %s", path), e);
         }
     }
 
     public static YangInstanceIdentifier deserializePath(DataInput in) {
         try {
-            NormalizedNodeInputStreamReader streamReader = new NormalizedNodeInputStreamReader(in);
+            NormalizedNodeInputStreamReader streamReader = streamReader(in);
             return streamReader.readYangInstanceIdentifier();
         } catch (IOException e) {
             throw new IllegalArgumentException("Error deserializing path", e);
index db9f3d1801c6698c863e3a5582059b493b0d05ee..5b7002eda2aafe923c0ad5d3b20addfd095b8a3e 100644 (file)
@@ -14,7 +14,6 @@ import java.util.ArrayList;
 import java.util.List;
 import org.apache.commons.lang.SerializationUtils;
 import org.junit.Test;
-import org.opendaylight.controller.cluster.datastore.modification.Modification;
 import org.opendaylight.controller.cluster.datastore.modification.MutableCompositeModification;
 import org.opendaylight.controller.cluster.datastore.modification.WriteModification;
 import org.opendaylight.controller.cluster.raft.ReplicatedLogEntry;
@@ -25,6 +24,7 @@ import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
+@Deprecated
 public class CompositeModificationByteStringPayloadTest {
 
     private static final SchemaContext SCHEMA_CONTEXT = TestModel.createTestContext();
@@ -33,8 +33,7 @@ public class CompositeModificationByteStringPayloadTest {
     public void testSerialization(){
         WriteModification writeModification =
                 new WriteModification(TestModel.TEST_PATH, ImmutableNodes
-                        .containerNode(TestModel.TEST_QNAME),
-                        TestModel.createTestContext());
+                        .containerNode(TestModel.TEST_QNAME));
 
         MutableCompositeModification compositeModification =
                 new MutableCompositeModification();
@@ -56,28 +55,20 @@ public class CompositeModificationByteStringPayloadTest {
     public void testAppendEntries(){
         List<ReplicatedLogEntry> entries = new ArrayList<>();
 
-        CompositeModificationByteStringPayload payload = newByteStringPayload(
-                new WriteModification(TestModel.OUTER_LIST_PATH,
-                        ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME).build(),
-                        SCHEMA_CONTEXT));
+        WriteModification writeModification = new WriteModification(TestModel.OUTER_LIST_PATH,
+                ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME).build());
 
-        payload.clearModificationReference();
-
-        entries.add(new ReplicatedLogImplEntry(0, 1, payload));
+        MutableCompositeModification compositeModification = new MutableCompositeModification();
 
+        compositeModification.addModification(writeModification);
 
-        assertNotNull(new AppendEntries(10, "foobar", 10, 10, entries, 10).toSerializable());
-    }
-
+        CompositeModificationByteStringPayload payload =
+                new CompositeModificationByteStringPayload(compositeModification.toSerializable());
 
+        payload.clearModificationReference();
 
-    private CompositeModificationByteStringPayload newByteStringPayload(final Modification... mods) {
-        MutableCompositeModification compMod = new MutableCompositeModification();
-        for(Modification mod: mods) {
-            compMod.addModification(mod);
-        }
+        entries.add(new ReplicatedLogImplEntry(0, 1, payload));
 
-        return new CompositeModificationByteStringPayload(compMod.toSerializable());
+        assertNotNull(new AppendEntries(10, "foobar", 10, 10, entries, 10).toSerializable());
     }
-
 }
index 9e02223f54e18d4d844f8b2be9af188df261a901..a55f6b865d127b9f6f4abe33cd9cbb227ab2839f 100644 (file)
@@ -1,16 +1,15 @@
 package org.opendaylight.controller.cluster.datastore;
 
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
-import org.junit.After;
 import org.junit.Assert;
 import org.junit.Test;
 import org.opendaylight.controller.cluster.datastore.modification.MutableCompositeModification;
 import org.opendaylight.controller.cluster.datastore.modification.WriteModification;
+import org.opendaylight.controller.cluster.raft.RaftVersions;
 import org.opendaylight.controller.cluster.raft.ReplicatedLogEntry;
 import org.opendaylight.controller.cluster.raft.messages.AppendEntries;
 import org.opendaylight.controller.cluster.raft.protobuff.client.messages.CompositeModificationPayload;
@@ -19,19 +18,9 @@ import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
 import org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
 
+@Deprecated
 public class CompositeModificationPayloadTest {
 
-
-    private static final String SERIALIZE_OUT = "serialize.out";
-
-    @After
-    public void shutDown(){
-        File f = new File(SERIALIZE_OUT);
-        if(f.exists()){
-            f.delete();
-        }
-    }
-
     @Test
     public void testBasic() throws IOException {
 
@@ -41,8 +30,7 @@ public class CompositeModificationPayloadTest {
             @Override public Payload getData() {
                 WriteModification writeModification =
                     new WriteModification(TestModel.TEST_PATH, ImmutableNodes
-                        .containerNode(TestModel.TEST_QNAME),
-                        TestModel.createTestContext());
+                        .containerNode(TestModel.TEST_QNAME));
 
                 MutableCompositeModification compositeModification =
                     new MutableCompositeModification();
@@ -69,13 +57,15 @@ public class CompositeModificationPayloadTest {
         AppendEntries appendEntries =
             new AppendEntries(1, "member-1", 0, 100, entries, 1);
 
-        AppendEntriesMessages.AppendEntries o = (AppendEntriesMessages.AppendEntries) appendEntries.toSerializable();
+        AppendEntriesMessages.AppendEntries o = (AppendEntriesMessages.AppendEntries)
+                appendEntries.toSerializable(RaftVersions.HELIUM_VERSION);
 
-        o.writeDelimitedTo(new FileOutputStream(SERIALIZE_OUT));
+        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        o.writeDelimitedTo(bos);
 
         AppendEntriesMessages.AppendEntries appendEntries2 =
             AppendEntriesMessages.AppendEntries
-                .parseDelimitedFrom(new FileInputStream(SERIALIZE_OUT));
+                .parseDelimitedFrom(new ByteArrayInputStream(bos.toByteArray()));
 
         AppendEntries appendEntries1 = AppendEntries.fromSerializable(appendEntries2);
 
@@ -83,7 +73,5 @@ public class CompositeModificationPayloadTest {
 
 
         Assert.assertTrue(((CompositeModificationPayload) data).getModification().toString().contains(TestModel.TEST_QNAME.getNamespace().toString()));
-
     }
-
 }
index 42f30437c9061b916169365e2cfa506a65e8de9a..94b9698abf3a06f41527a83e5cec2461b2658266 100644 (file)
@@ -17,7 +17,9 @@ import akka.actor.Props;
 import akka.dispatch.Dispatchers;
 import akka.dispatch.OnComplete;
 import akka.japi.Creator;
+import akka.japi.Procedure;
 import akka.pattern.Patterns;
+import akka.persistence.SnapshotSelectionCriteria;
 import akka.testkit.TestActorRef;
 import akka.util.Timeout;
 import com.google.common.base.Function;
@@ -43,6 +45,7 @@ import org.junit.Test;
 import org.mockito.InOrder;
 import org.mockito.invocation.InvocationOnMock;
 import org.mockito.stubbing.Answer;
+import org.opendaylight.controller.cluster.DataPersistenceProvider;
 import org.opendaylight.controller.cluster.datastore.DatastoreContext.Builder;
 import org.opendaylight.controller.cluster.datastore.identifiers.ShardIdentifier;
 import org.opendaylight.controller.cluster.datastore.messages.AbortTransaction;
@@ -60,12 +63,14 @@ import org.opendaylight.controller.cluster.datastore.messages.RegisterChangeList
 import org.opendaylight.controller.cluster.datastore.messages.UpdateSchemaContext;
 import org.opendaylight.controller.cluster.datastore.modification.MergeModification;
 import org.opendaylight.controller.cluster.datastore.modification.Modification;
+import org.opendaylight.controller.cluster.datastore.modification.ModificationPayload;
 import org.opendaylight.controller.cluster.datastore.modification.MutableCompositeModification;
 import org.opendaylight.controller.cluster.datastore.modification.WriteModification;
 import org.opendaylight.controller.cluster.datastore.node.NormalizedNodeToNodeCodec;
 import org.opendaylight.controller.cluster.datastore.utils.InMemoryJournal;
 import org.opendaylight.controller.cluster.datastore.utils.InMemorySnapshotStore;
 import org.opendaylight.controller.cluster.datastore.utils.MockDataChangeListener;
+import org.opendaylight.controller.cluster.datastore.utils.SerializationUtils;
 import org.opendaylight.controller.cluster.raft.ReplicatedLogEntry;
 import org.opendaylight.controller.cluster.raft.ReplicatedLogImplEntry;
 import org.opendaylight.controller.cluster.raft.Snapshot;
@@ -78,7 +83,6 @@ import org.opendaylight.controller.cluster.raft.client.messages.FindLeader;
 import org.opendaylight.controller.cluster.raft.client.messages.FindLeaderReply;
 import org.opendaylight.controller.cluster.raft.protobuff.client.messages.CompositeModificationByteStringPayload;
 import org.opendaylight.controller.cluster.raft.protobuff.client.messages.CompositeModificationPayload;
-import org.opendaylight.controller.cluster.raft.protobuff.client.messages.Payload;
 import org.opendaylight.controller.md.cluster.datastore.model.SchemaContextHelper;
 import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker;
@@ -364,13 +368,41 @@ public class ShardTest extends AbstractActorTest {
         TestActorRef<Shard> shard = TestActorRef.create(getSystem(), newShardProps(),
                 "testApplySnapshot");
 
-        NormalizedNodeToNodeCodec codec =
-            new NormalizedNodeToNodeCodec(SCHEMA_CONTEXT);
+        InMemoryDOMDataStore store = new InMemoryDOMDataStore("OPER", MoreExecutors.sameThreadExecutor());
+        store.onGlobalContextUpdated(SCHEMA_CONTEXT);
+
+        writeToStore(store, TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
+
+        YangInstanceIdentifier root = YangInstanceIdentifier.builder().build();
+        NormalizedNode<?,?> expected = readStore(store, root);
+
+        ApplySnapshot applySnapshot = new ApplySnapshot(Snapshot.create(
+                SerializationUtils.serializeNormalizedNode(expected),
+                Collections.<ReplicatedLogEntry>emptyList(), 1, 2, 3, 4));
+
+        shard.underlyingActor().onReceiveCommand(applySnapshot);
+
+        NormalizedNode<?,?> actual = readStore(shard, root);
+
+        assertEquals("Root node", expected, actual);
+
+        shard.tell(PoisonPill.getInstance(), ActorRef.noSender());
+    }
+
+    @Test
+    public void testApplyHelium2VersionSnapshot() throws Exception {
+        TestActorRef<Shard> shard = TestActorRef.create(getSystem(), newShardProps(),
+                "testApplySnapshot");
+
+        NormalizedNodeToNodeCodec codec = new NormalizedNodeToNodeCodec(SCHEMA_CONTEXT);
 
-        writeToStore(shard, TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
+        InMemoryDOMDataStore store = new InMemoryDOMDataStore("OPER", MoreExecutors.sameThreadExecutor());
+        store.onGlobalContextUpdated(SCHEMA_CONTEXT);
+
+        writeToStore(store, TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
 
         YangInstanceIdentifier root = YangInstanceIdentifier.builder().build();
-        NormalizedNode<?,?> expected = readStore(shard, root);
+        NormalizedNode<?,?> expected = readStore(store, root);
 
         NormalizedNodeMessages.Container encode = codec.encode(expected);
 
@@ -382,7 +414,7 @@ public class ShardTest extends AbstractActorTest {
 
         NormalizedNode<?,?> actual = readStore(shard, root);
 
-        assertEquals(expected, actual);
+        assertEquals("Root node", expected, actual);
 
         shard.tell(PoisonPill.getInstance(), ActorRef.noSender());
     }
@@ -394,11 +426,26 @@ public class ShardTest extends AbstractActorTest {
 
         NormalizedNode<?, ?> node = ImmutableNodes.containerNode(TestModel.TEST_QNAME);
 
-        MutableCompositeModification compMod = new MutableCompositeModification();
-        compMod.addModification(new WriteModification(TestModel.TEST_PATH, node, SCHEMA_CONTEXT));
-        Payload payload = new CompositeModificationPayload(compMod.toSerializable());
-        ApplyState applyState = new ApplyState(null, "test",
-                new ReplicatedLogImplEntry(1, 2, payload));
+        ApplyState applyState = new ApplyState(null, "test", new ReplicatedLogImplEntry(1, 2,
+                newModificationPayload(new WriteModification(TestModel.TEST_PATH, node))));
+
+        shard.underlyingActor().onReceiveCommand(applyState);
+
+        NormalizedNode<?,?> actual = readStore(shard, TestModel.TEST_PATH);
+        assertEquals("Applied state", node, actual);
+
+        shard.tell(PoisonPill.getInstance(), ActorRef.noSender());
+    }
+
+    @Test
+    public void testApplyStateLegacy() throws Exception {
+
+        TestActorRef<Shard> shard = TestActorRef.create(getSystem(), newShardProps(), "testApplyStateLegacy");
+
+        NormalizedNode<?, ?> node = ImmutableNodes.containerNode(TestModel.TEST_QNAME);
+
+        ApplyState applyState = new ApplyState(null, "test", new ReplicatedLogImplEntry(1, 2,
+                newLegacyByteStringPayload(new WriteModification(TestModel.TEST_PATH, node))));
 
         shard.underlyingActor().onReceiveCommand(applyState);
 
@@ -408,7 +455,6 @@ public class ShardTest extends AbstractActorTest {
         shard.tell(PoisonPill.getInstance(), ActorRef.noSender());
     }
 
-    @SuppressWarnings("serial")
     @Test
     public void testRecovery() throws Exception {
 
@@ -417,61 +463,102 @@ public class ShardTest extends AbstractActorTest {
         InMemoryDOMDataStore testStore = InMemoryDOMDataStoreFactory.create("Test", null, null);
         testStore.onGlobalContextUpdated(SCHEMA_CONTEXT);
 
-        DOMStoreWriteTransaction writeTx = testStore.newWriteOnlyTransaction();
-        writeTx.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
-        DOMStoreThreePhaseCommitCohort commitCohort = writeTx.ready();
-        commitCohort.preCommit().get();
-        commitCohort.commit().get();
+        writeToStore(testStore, TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
 
-        DOMStoreReadTransaction readTx = testStore.newReadOnlyTransaction();
-        NormalizedNode<?, ?> root = readTx.read(YangInstanceIdentifier.builder().build()).get().get();
+        NormalizedNode<?, ?> root = readStore(testStore, YangInstanceIdentifier.builder().build());
 
         InMemorySnapshotStore.addSnapshot(shardID.toString(), Snapshot.create(
-                new NormalizedNodeToNodeCodec(SCHEMA_CONTEXT).encode(
-                        root).
+                SerializationUtils.serializeNormalizedNode(root),
+                Collections.<ReplicatedLogEntry>emptyList(), 0, 1, -1, -1));
+
+        // Set up the InMemoryJournal.
+
+        InMemoryJournal.addEntry(shardID.toString(), 0, new ReplicatedLogImplEntry(0, 1, newLegacyPayload(
+                  new WriteModification(TestModel.OUTER_LIST_PATH,
+                          ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME).build()))));
+
+        int nListEntries = 16;
+        Set<Integer> listEntryKeys = new HashSet<>();
+
+        // Add some ModificationPayload entries
+        for(int i = 1; i <= nListEntries; i++) {
+            listEntryKeys.add(Integer.valueOf(i));
+            YangInstanceIdentifier path = YangInstanceIdentifier.builder(TestModel.OUTER_LIST_PATH)
+                    .nodeWithKey(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, i).build();
+            Modification mod = new MergeModification(path,
+                    ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, i));
+            InMemoryJournal.addEntry(shardID.toString(), i, new ReplicatedLogImplEntry(i, 1,
+                    newModificationPayload(mod)));
+        }
+
+        InMemoryJournal.addEntry(shardID.toString(), nListEntries + 1,
+                new ApplyLogEntries(nListEntries));
+
+        testRecovery(listEntryKeys);
+    }
+
+    @Test
+    public void testHelium2VersionRecovery() throws Exception {
+
+        // Set up the InMemorySnapshotStore.
+
+        InMemoryDOMDataStore testStore = InMemoryDOMDataStoreFactory.create("Test", null, null);
+        testStore.onGlobalContextUpdated(SCHEMA_CONTEXT);
+
+        writeToStore(testStore, TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
+
+        NormalizedNode<?, ?> root = readStore(testStore, YangInstanceIdentifier.builder().build());
+
+        InMemorySnapshotStore.addSnapshot(shardID.toString(), Snapshot.create(
+                new NormalizedNodeToNodeCodec(SCHEMA_CONTEXT).encode(root).
                                 getNormalizedNode().toByteString().toByteArray(),
                                 Collections.<ReplicatedLogEntry>emptyList(), 0, 1, -1, -1));
 
         // Set up the InMemoryJournal.
 
-        InMemoryJournal.addEntry(shardID.toString(), 0, new ReplicatedLogImplEntry(0, 1, newPayload(
+        InMemoryJournal.addEntry(shardID.toString(), 0, new ReplicatedLogImplEntry(0, 1, newLegacyPayload(
                   new WriteModification(TestModel.OUTER_LIST_PATH,
-                          ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME).build(),
-                          SCHEMA_CONTEXT))));
+                          ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME).build()))));
 
         int nListEntries = 16;
         Set<Integer> listEntryKeys = new HashSet<>();
-        for(int i = 1; i <= nListEntries-5; i++) {
+        int i = 1;
+
+        // Add some CompositeModificationPayload entries
+        for(; i <= 8; i++) {
             listEntryKeys.add(Integer.valueOf(i));
             YangInstanceIdentifier path = YangInstanceIdentifier.builder(TestModel.OUTER_LIST_PATH)
                     .nodeWithKey(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, i).build();
             Modification mod = new MergeModification(path,
-                    ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, i),
-                    SCHEMA_CONTEXT);
+                    ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, i));
             InMemoryJournal.addEntry(shardID.toString(), i, new ReplicatedLogImplEntry(i, 1,
-                    newPayload(mod)));
+                    newLegacyPayload(mod)));
         }
 
-        // Add some of the new CompositeModificationByteStringPayload
-        for(int i = 11; i <= nListEntries; i++) {
+        // Add some CompositeModificationByteStringPayload entries
+        for(; i <= nListEntries; i++) {
             listEntryKeys.add(Integer.valueOf(i));
             YangInstanceIdentifier path = YangInstanceIdentifier.builder(TestModel.OUTER_LIST_PATH)
                     .nodeWithKey(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, i).build();
             Modification mod = new MergeModification(path,
-                    ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, i),
-                    SCHEMA_CONTEXT);
+                    ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, i));
             InMemoryJournal.addEntry(shardID.toString(), i, new ReplicatedLogImplEntry(i, 1,
-                    newByteStringPayload(mod)));
+                    newLegacyByteStringPayload(mod)));
         }
 
+        InMemoryJournal.addEntry(shardID.toString(), nListEntries + 1, new ApplyLogEntries(nListEntries));
 
-        InMemoryJournal.addEntry(shardID.toString(), nListEntries + 1,
-                new ApplyLogEntries(nListEntries));
+        testRecovery(listEntryKeys);
+    }
 
+    private void testRecovery(Set<Integer> listEntryKeys) throws Exception {
         // Create the actor and wait for recovery complete.
 
+        int nListEntries = listEntryKeys.size();
+
         final CountDownLatch recoveryComplete = new CountDownLatch(1);
 
+        @SuppressWarnings("serial")
         Creator<Shard> creator = new Creator<Shard>() {
             @Override
             public Shard create() throws Exception {
@@ -527,7 +614,7 @@ public class ShardTest extends AbstractActorTest {
         shard.tell(PoisonPill.getInstance(), ActorRef.noSender());
     }
 
-    private CompositeModificationPayload newPayload(final Modification... mods) {
+    private CompositeModificationPayload newLegacyPayload(final Modification... mods) {
         MutableCompositeModification compMod = new MutableCompositeModification();
         for(Modification mod: mods) {
             compMod.addModification(mod);
@@ -536,7 +623,7 @@ public class ShardTest extends AbstractActorTest {
         return new CompositeModificationPayload(compMod.toSerializable());
     }
 
-    private CompositeModificationByteStringPayload newByteStringPayload(final Modification... mods) {
+    private CompositeModificationByteStringPayload newLegacyByteStringPayload(final Modification... mods) {
         MutableCompositeModification compMod = new MutableCompositeModification();
         for(Modification mod: mods) {
             compMod.addModification(mod);
@@ -545,6 +632,14 @@ public class ShardTest extends AbstractActorTest {
         return new CompositeModificationByteStringPayload(compMod.toSerializable());
     }
 
+    private ModificationPayload newModificationPayload(final Modification... mods) throws IOException {
+        MutableCompositeModification compMod = new MutableCompositeModification();
+        for(Modification mod: mods) {
+            compMod.addModification(mod);
+        }
+
+        return new ModificationPayload(compMod);
+    }
 
     private DOMStoreThreePhaseCommitCohort setupMockWriteTransaction(final String cohortName,
             final InMemoryDOMDataStore dataStore, final YangInstanceIdentifier path, final NormalizedNode<?, ?> data,
@@ -594,7 +689,7 @@ public class ShardTest extends AbstractActorTest {
             }
         }).when(cohort).abort();
 
-        modification.addModification(new WriteModification(path, data, SCHEMA_CONTEXT));
+        modification.addModification(new WriteModification(path, data));
 
         return cohort;
     }
@@ -1286,19 +1381,54 @@ public class ShardTest extends AbstractActorTest {
     }
 
     @Test
-    public void testCreateSnapshot() throws IOException, InterruptedException {
-            testCreateSnapshot(true, "testCreateSnapshot");
+    public void testCreateSnapshot() throws Exception {
+        testCreateSnapshot(true, "testCreateSnapshot");
     }
 
     @Test
-    public void testCreateSnapshotWithNonPersistentData() throws IOException, InterruptedException {
+    public void testCreateSnapshotWithNonPersistentData() throws Exception {
         testCreateSnapshot(false, "testCreateSnapshotWithNonPersistentData");
     }
 
     @SuppressWarnings("serial")
-    public void testCreateSnapshot(final boolean persistent, final String shardActorName) throws IOException, InterruptedException {
-        final DatastoreContext dataStoreContext = DatastoreContext.newBuilder().
-                shardJournalRecoveryLogBatchSize(3).shardSnapshotBatchCount(5000).persistent(persistent).build();
+    public void testCreateSnapshot(final boolean persistent, final String shardActorName) throws Exception{
+
+        final AtomicReference<Object> savedSnapshot = new AtomicReference<>();
+        class DelegatingPersistentDataProvider implements DataPersistenceProvider {
+            DataPersistenceProvider delegate;
+
+            DelegatingPersistentDataProvider(DataPersistenceProvider delegate) {
+                this.delegate = delegate;
+            }
+
+            @Override
+            public boolean isRecoveryApplicable() {
+                return delegate.isRecoveryApplicable();
+            }
+
+            @Override
+            public <T> void persist(T o, Procedure<T> procedure) {
+                delegate.persist(o, procedure);
+            }
+
+            @Override
+            public void saveSnapshot(Object o) {
+                savedSnapshot.set(o);
+                delegate.saveSnapshot(o);
+            }
+
+            @Override
+            public void deleteSnapshots(SnapshotSelectionCriteria criteria) {
+                delegate.deleteSnapshots(criteria);
+            }
+
+            @Override
+            public void deleteMessages(long sequenceNumber) {
+                delegate.deleteMessages(sequenceNumber);
+            }
+        }
+
+        dataStoreContextBuilder.persistent(persistent);
 
         new ShardTestKit(getSystem()) {{
             final AtomicReference<CountDownLatch> latch = new AtomicReference<>(new CountDownLatch(1));
@@ -1307,6 +1437,18 @@ public class ShardTest extends AbstractActorTest {
                 public Shard create() throws Exception {
                     return new Shard(shardID, Collections.<ShardIdentifier,String>emptyMap(),
                             newDatastoreContext(), SCHEMA_CONTEXT) {
+
+                        DelegatingPersistentDataProvider delegating;
+
+                        @Override
+                        protected DataPersistenceProvider persistence() {
+                            if(delegating == null) {
+                                delegating = new DelegatingPersistentDataProvider(super.persistence());
+                            }
+
+                            return delegating;
+                        }
+
                         @Override
                         protected void commitSnapshot(final long sequenceNumber) {
                             super.commitSnapshot(sequenceNumber);
@@ -1321,16 +1463,40 @@ public class ShardTest extends AbstractActorTest {
 
             waitUntilLeader(shard);
 
-            shard.tell(new CaptureSnapshot(-1,-1,-1,-1), getRef());
+            writeToStore(shard, TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
+
+            NormalizedNode<?,?> expectedRoot = readStore(shard, YangInstanceIdentifier.builder().build());
+
+            CaptureSnapshot capture = new CaptureSnapshot(-1, -1, -1, -1);
+            shard.tell(capture, getRef());
 
             assertEquals("Snapshot saved", true, latch.get().await(5, TimeUnit.SECONDS));
 
+            assertTrue("Invalid saved snapshot " + savedSnapshot.get(),
+                    savedSnapshot.get() instanceof Snapshot);
+
+            verifySnapshot((Snapshot)savedSnapshot.get(), expectedRoot);
+
             latch.set(new CountDownLatch(1));
-            shard.tell(new CaptureSnapshot(-1,-1,-1,-1), getRef());
+            savedSnapshot.set(null);
+
+            shard.tell(capture, getRef());
 
             assertEquals("Snapshot saved", true, latch.get().await(5, TimeUnit.SECONDS));
 
+            assertTrue("Invalid saved snapshot " + savedSnapshot.get(),
+                    savedSnapshot.get() instanceof Snapshot);
+
+            verifySnapshot((Snapshot)savedSnapshot.get(), expectedRoot);
+
             shard.tell(PoisonPill.getInstance(), ActorRef.noSender());
+        }
+
+        private void verifySnapshot(Snapshot snapshot, NormalizedNode<?,?> expectedRoot) {
+
+            NormalizedNode<?, ?> actual = SerializationUtils.deserializeNormalizedNode(snapshot.getState());
+            assertEquals("Root node", expectedRoot, actual);
+
         }};
     }
 
@@ -1437,7 +1603,12 @@ public class ShardTest extends AbstractActorTest {
 
     static NormalizedNode<?,?> readStore(final TestActorRef<Shard> shard, final YangInstanceIdentifier id)
             throws ExecutionException, InterruptedException {
-        DOMStoreReadTransaction transaction = shard.underlyingActor().getDataStore().newReadOnlyTransaction();
+        return readStore(shard.underlyingActor().getDataStore(), id);
+    }
+
+    public static NormalizedNode<?,?> readStore(final InMemoryDOMDataStore store, final YangInstanceIdentifier id)
+            throws ExecutionException, InterruptedException {
+        DOMStoreReadTransaction transaction = store.newReadOnlyTransaction();
 
         CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> future =
             transaction.read(id);
@@ -1450,9 +1621,14 @@ public class ShardTest extends AbstractActorTest {
         return node;
     }
 
-    private void writeToStore(final TestActorRef<Shard> shard, final YangInstanceIdentifier id, final NormalizedNode<?,?> node)
-        throws ExecutionException, InterruptedException {
-        DOMStoreWriteTransaction transaction = shard.underlyingActor().getDataStore().newWriteOnlyTransaction();
+    static void writeToStore(final TestActorRef<Shard> shard, final YangInstanceIdentifier id,
+            final NormalizedNode<?,?> node) throws ExecutionException, InterruptedException {
+        writeToStore(shard.underlyingActor().getDataStore(), id, node);
+    }
+
+    public static void writeToStore(final InMemoryDOMDataStore store, final YangInstanceIdentifier id,
+            final NormalizedNode<?,?> node) throws ExecutionException, InterruptedException {
+        DOMStoreWriteTransaction transaction = store.newWriteOnlyTransaction();
 
         transaction.write(id, node);
 
index efae106617c2a656ce560aa14de53e1d8c609c9f..69dd706f37cb3bd8c1e7c75d91ec05e2b0fe1f13 100644 (file)
@@ -12,7 +12,7 @@ import akka.testkit.TestActorRef;
 import com.google.common.util.concurrent.MoreExecutors;
 import java.util.Collections;
 import java.util.concurrent.TimeUnit;
-import org.junit.BeforeClass;
+import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.controller.cluster.datastore.ShardWriteTransaction.GetCompositeModificationReply;
 import org.opendaylight.controller.cluster.datastore.exceptions.UnknownMessageException;
@@ -20,6 +20,7 @@ import org.opendaylight.controller.cluster.datastore.identifiers.ShardIdentifier
 import org.opendaylight.controller.cluster.datastore.jmx.mbeans.shard.ShardStats;
 import org.opendaylight.controller.cluster.datastore.messages.CloseTransaction;
 import org.opendaylight.controller.cluster.datastore.messages.CloseTransactionReply;
+import org.opendaylight.controller.cluster.datastore.messages.CreateSnapshot;
 import org.opendaylight.controller.cluster.datastore.messages.DataExists;
 import org.opendaylight.controller.cluster.datastore.messages.DataExistsReply;
 import org.opendaylight.controller.cluster.datastore.messages.DeleteData;
@@ -39,17 +40,19 @@ import org.opendaylight.controller.cluster.datastore.modification.Modification;
 import org.opendaylight.controller.cluster.datastore.modification.WriteModification;
 import org.opendaylight.controller.cluster.datastore.node.NormalizedNodeToNodeCodec;
 import org.opendaylight.controller.cluster.datastore.node.NormalizedNodeToNodeCodec.Encoded;
+import org.opendaylight.controller.cluster.datastore.utils.SerializationUtils;
+import org.opendaylight.controller.cluster.raft.base.messages.CaptureSnapshotReply;
 import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
 import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore;
 import org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages;
+import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransaction;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import scala.concurrent.duration.Duration;
 
 public class ShardTransactionTest extends AbstractActorTest {
-    private static final InMemoryDOMDataStore store =
-        new InMemoryDOMDataStore("OPER", MoreExecutors.sameThreadExecutor());
 
     private static final SchemaContext testSchemaContext = TestModel.createTestContext();
 
@@ -61,8 +64,11 @@ public class ShardTransactionTest extends AbstractActorTest {
 
     private final ShardStats shardStats = new ShardStats(SHARD_IDENTIFIER.toString(), "DataStore");
 
-    @BeforeClass
-    public static void staticSetup() {
+    private final InMemoryDOMDataStore store =
+            new InMemoryDOMDataStore("OPER", MoreExecutors.sameThreadExecutor());
+
+    @Before
+    public void setup() {
         store.onGlobalContextUpdated(testSchemaContext);
     }
 
@@ -71,21 +77,33 @@ public class ShardTransactionTest extends AbstractActorTest {
             Collections.<ShardIdentifier, String>emptyMap(), datastoreContext, TestModel.createTestContext()));
     }
 
+    private ActorRef newTransactionActor(DOMStoreTransaction transaction, String name) {
+        return newTransactionActor(transaction, name, DataStoreVersions.CURRENT_VERSION);
+    }
+
+    private ActorRef newTransactionActor(DOMStoreTransaction transaction, String name, short version) {
+        return newTransactionActor(transaction, null, name, version);
+    }
+
+    private ActorRef newTransactionActor(DOMStoreTransaction transaction, ActorRef shard, String name) {
+        return newTransactionActor(transaction, null, name, DataStoreVersions.CURRENT_VERSION);
+    }
+
+    private ActorRef newTransactionActor(DOMStoreTransaction transaction, ActorRef shard, String name,
+            short version) {
+        Props props = ShardTransaction.props(transaction, shard != null ? shard : createShard(),
+                testSchemaContext, datastoreContext, shardStats, "txn", version);
+        return getSystem().actorOf(props, name);
+    }
+
     @Test
     public void testOnReceiveReadData() throws Exception {
         new JavaTestKit(getSystem()) {{
             final ActorRef shard = createShard();
-            Props props = ShardTransaction.props(store.newReadOnlyTransaction(), shard,
-                    testSchemaContext, datastoreContext, shardStats, "txn",
-                    DataStoreVersions.CURRENT_VERSION);
 
-            testOnReceiveReadData(getSystem().actorOf(props, "testReadDataRO"));
+            testOnReceiveReadData(newTransactionActor(store.newReadOnlyTransaction(), shard, "testReadDataRO"));
 
-            props = ShardTransaction.props(store.newReadWriteTransaction(), shard,
-                    testSchemaContext, datastoreContext, shardStats, "txn",
-                    DataStoreVersions.CURRENT_VERSION);
-
-            testOnReceiveReadData(getSystem().actorOf(props, "testReadDataRW"));
+            testOnReceiveReadData(newTransactionActor(store.newReadWriteTransaction(), shard, "testReadDataRW"));
         }
 
         private void testOnReceiveReadData(final ActorRef transaction) {
@@ -111,19 +129,12 @@ public class ShardTransactionTest extends AbstractActorTest {
     public void testOnReceiveReadDataWhenDataNotFound() throws Exception {
         new JavaTestKit(getSystem()) {{
             final ActorRef shard = createShard();
-            Props props = ShardTransaction.props( store.newReadOnlyTransaction(), shard,
-                    testSchemaContext, datastoreContext, shardStats, "txn",
-                    DataStoreVersions.CURRENT_VERSION);
-
-            testOnReceiveReadDataWhenDataNotFound(getSystem().actorOf(
-                    props, "testReadDataWhenDataNotFoundRO"));
 
-            props = ShardTransaction.props( store.newReadWriteTransaction(), shard,
-                    testSchemaContext, datastoreContext, shardStats, "txn",
-                    DataStoreVersions.CURRENT_VERSION);
+            testOnReceiveReadDataWhenDataNotFound(newTransactionActor(
+                    store.newReadOnlyTransaction(), shard, "testReadDataWhenDataNotFoundRO"));
 
-            testOnReceiveReadDataWhenDataNotFound(getSystem().actorOf(
-                    props, "testReadDataWhenDataNotFoundRW"));
+            testOnReceiveReadDataWhenDataNotFound(newTransactionActor(
+                    store.newReadWriteTransaction(), shard, "testReadDataWhenDataNotFoundRW"));
         }
 
         private void testOnReceiveReadDataWhenDataNotFound(final ActorRef transaction) {
@@ -147,12 +158,8 @@ public class ShardTransactionTest extends AbstractActorTest {
     @Test
     public void testOnReceiveReadDataHeliumR1() throws Exception {
         new JavaTestKit(getSystem()) {{
-            final ActorRef shard = createShard();
-            Props props = ShardTransaction.props(store.newReadOnlyTransaction(), shard,
-                    testSchemaContext, datastoreContext, shardStats, "txn",
-                    DataStoreVersions.HELIUM_1_VERSION);
-
-            ActorRef transaction = getSystem().actorOf(props, "testOnReceiveReadDataHeliumR1");
+            ActorRef transaction = newTransactionActor(store.newReadOnlyTransaction(),
+                    "testOnReceiveReadDataHeliumR1", DataStoreVersions.HELIUM_1_VERSION);
 
             transaction.tell(new ReadData(YangInstanceIdentifier.builder().build()).toSerializable(),
                     getRef());
@@ -168,17 +175,12 @@ public class ShardTransactionTest extends AbstractActorTest {
     public void testOnReceiveDataExistsPositive() throws Exception {
         new JavaTestKit(getSystem()) {{
             final ActorRef shard = createShard();
-            Props props = ShardTransaction.props(store.newReadOnlyTransaction(), shard,
-                    testSchemaContext, datastoreContext, shardStats, "txn",
-                    DataStoreVersions.CURRENT_VERSION);
-
-            testOnReceiveDataExistsPositive(getSystem().actorOf(props, "testDataExistsPositiveRO"));
 
-            props = ShardTransaction.props(store.newReadWriteTransaction(), shard,
-                    testSchemaContext, datastoreContext, shardStats, "txn",
-                    DataStoreVersions.CURRENT_VERSION);
+            testOnReceiveDataExistsPositive(newTransactionActor(store.newReadOnlyTransaction(), shard,
+                    "testDataExistsPositiveRO"));
 
-            testOnReceiveDataExistsPositive(getSystem().actorOf(props, "testDataExistsPositiveRW"));
+            testOnReceiveDataExistsPositive(newTransactionActor(store.newReadWriteTransaction(), shard,
+                    "testDataExistsPositiveRW"));
         }
 
         private void testOnReceiveDataExistsPositive(final ActorRef transaction) {
@@ -203,17 +205,12 @@ public class ShardTransactionTest extends AbstractActorTest {
     public void testOnReceiveDataExistsNegative() throws Exception {
         new JavaTestKit(getSystem()) {{
             final ActorRef shard = createShard();
-            Props props = ShardTransaction.props(store.newReadOnlyTransaction(), shard,
-                    testSchemaContext, datastoreContext, shardStats, "txn",
-                    DataStoreVersions.CURRENT_VERSION);
 
-            testOnReceiveDataExistsNegative(getSystem().actorOf(props, "testDataExistsNegativeRO"));
+            testOnReceiveDataExistsNegative(newTransactionActor(store.newReadOnlyTransaction(), shard,
+                    "testDataExistsNegativeRO"));
 
-            props = ShardTransaction.props(store.newReadWriteTransaction(), shard,
-                    testSchemaContext, datastoreContext, shardStats, "txn",
-                    DataStoreVersions.CURRENT_VERSION);
-
-            testOnReceiveDataExistsNegative(getSystem().actorOf(props, "testDataExistsNegativeRW"));
+            testOnReceiveDataExistsNegative(newTransactionActor(store.newReadWriteTransaction(), shard,
+                    "testDataExistsNegativeRW"));
         }
 
         private void testOnReceiveDataExistsNegative(final ActorRef transaction) {
@@ -249,11 +246,8 @@ public class ShardTransactionTest extends AbstractActorTest {
     @Test
     public void testOnReceiveWriteData() throws Exception {
         new JavaTestKit(getSystem()) {{
-            final ActorRef shard = createShard();
-            final Props props = ShardTransaction.props(store.newWriteOnlyTransaction(), shard,
-                    testSchemaContext, datastoreContext, shardStats, "txn",
-                    DataStoreVersions.CURRENT_VERSION);
-            final ActorRef transaction = getSystem().actorOf(props, "testOnReceiveWriteData");
+            final ActorRef transaction = newTransactionActor(store.newWriteOnlyTransaction(),
+                    "testOnReceiveWriteData");
 
             transaction.tell(new WriteData(TestModel.TEST_PATH,
                     ImmutableNodes.containerNode(TestModel.TEST_QNAME)).toSerializable(
@@ -275,11 +269,8 @@ public class ShardTransactionTest extends AbstractActorTest {
     @Test
     public void testOnReceiveHeliumR1WriteData() throws Exception {
         new JavaTestKit(getSystem()) {{
-            final ActorRef shard = createShard();
-            final Props props = ShardTransaction.props(store.newWriteOnlyTransaction(), shard,
-                    testSchemaContext, datastoreContext, shardStats, "txn",
-                    DataStoreVersions.HELIUM_1_VERSION);
-            final ActorRef transaction = getSystem().actorOf(props, "testOnReceiveHeliumR1WriteData");
+            final ActorRef transaction = newTransactionActor(store.newWriteOnlyTransaction(),
+                    "testOnReceiveHeliumR1WriteData", DataStoreVersions.HELIUM_1_VERSION);
 
             Encoded encoded = new NormalizedNodeToNodeCodec(null).encode(TestModel.TEST_PATH,
                     ImmutableNodes.containerNode(TestModel.TEST_QNAME));
@@ -298,11 +289,8 @@ public class ShardTransactionTest extends AbstractActorTest {
     @Test
     public void testOnReceiveMergeData() throws Exception {
         new JavaTestKit(getSystem()) {{
-            final ActorRef shard = createShard();
-            final Props props = ShardTransaction.props(store.newReadWriteTransaction(), shard,
-                    testSchemaContext, datastoreContext, shardStats, "txn",
-                    DataStoreVersions.CURRENT_VERSION);
-            final ActorRef transaction = getSystem().actorOf(props, "testMergeData");
+            final ActorRef transaction = newTransactionActor(store.newReadWriteTransaction(),
+                    "testMergeData");
 
             transaction.tell(new MergeData(TestModel.TEST_PATH,
                     ImmutableNodes.containerNode(TestModel.TEST_QNAME)).toSerializable(
@@ -324,11 +312,8 @@ public class ShardTransactionTest extends AbstractActorTest {
     @Test
     public void testOnReceiveHeliumR1MergeData() throws Exception {
         new JavaTestKit(getSystem()) {{
-            final ActorRef shard = createShard();
-            final Props props = ShardTransaction.props(store.newWriteOnlyTransaction(), shard,
-                    testSchemaContext, datastoreContext, shardStats, "txn",
-                    DataStoreVersions.HELIUM_1_VERSION);
-            final ActorRef transaction = getSystem().actorOf(props, "testOnReceiveHeliumR1MergeData");
+            final ActorRef transaction = newTransactionActor(store.newWriteOnlyTransaction(),
+                    "testOnReceiveHeliumR1MergeData", DataStoreVersions.HELIUM_1_VERSION);
 
             Encoded encoded = new NormalizedNodeToNodeCodec(null).encode(TestModel.TEST_PATH,
                     ImmutableNodes.containerNode(TestModel.TEST_QNAME));
@@ -347,11 +332,8 @@ public class ShardTransactionTest extends AbstractActorTest {
     @Test
     public void testOnReceiveDeleteData() throws Exception {
         new JavaTestKit(getSystem()) {{
-            final ActorRef shard = createShard();
-            final Props props = ShardTransaction.props( store.newWriteOnlyTransaction(), shard,
-                    testSchemaContext, datastoreContext, shardStats, "txn",
-                    DataStoreVersions.CURRENT_VERSION);
-            final ActorRef transaction = getSystem().actorOf(props, "testDeleteData");
+            final ActorRef transaction = newTransactionActor(store.newWriteOnlyTransaction(),
+                    "testDeleteData");
 
             transaction.tell(new DeleteData(TestModel.TEST_PATH).toSerializable(
                     DataStoreVersions.HELIUM_2_VERSION), getRef());
@@ -371,11 +353,8 @@ public class ShardTransactionTest extends AbstractActorTest {
     @Test
     public void testOnReceiveReadyTransaction() throws Exception {
         new JavaTestKit(getSystem()) {{
-            final ActorRef shard = createShard();
-            final Props props = ShardTransaction.props( store.newReadWriteTransaction(), shard,
-                    testSchemaContext, datastoreContext, shardStats, "txn",
-                    DataStoreVersions.CURRENT_VERSION);
-            final ActorRef transaction = getSystem().actorOf(props, "testReadyTransaction");
+            final ActorRef transaction = newTransactionActor(store.newReadWriteTransaction(),
+                    "testReadyTransaction");
 
             watch(transaction);
 
@@ -389,11 +368,8 @@ public class ShardTransactionTest extends AbstractActorTest {
 
         // test
         new JavaTestKit(getSystem()) {{
-            final ActorRef shard = createShard();
-            final Props props = ShardTransaction.props( store.newReadWriteTransaction(), shard,
-                testSchemaContext, datastoreContext, shardStats, "txn",
-                DataStoreVersions.CURRENT_VERSION);
-            final ActorRef transaction = getSystem().actorOf(props, "testReadyTransaction2");
+            final ActorRef transaction = newTransactionActor(store.newReadWriteTransaction(),
+                    "testReadyTransaction2");
 
             watch(transaction);
 
@@ -404,18 +380,42 @@ public class ShardTransactionTest extends AbstractActorTest {
             expectMsgAnyClassOf(duration("5 seconds"), ReadyTransactionReply.class,
                     Terminated.class);
         }};
+    }
 
+    @Test
+    public void testOnReceiveCreateSnapshot() throws Exception {
+        new JavaTestKit(getSystem()) {{
+            ShardTest.writeToStore(store, TestModel.TEST_PATH,
+                    ImmutableNodes.containerNode(TestModel.TEST_QNAME));
+
+            NormalizedNode<?,?> expectedRoot = ShardTest.readStore(store,
+                    YangInstanceIdentifier.builder().build());
+
+            final ActorRef transaction = newTransactionActor(store.newReadOnlyTransaction(),
+                    "testOnReceiveCreateSnapshot");
+
+            watch(transaction);
+
+            transaction.tell(CreateSnapshot.INSTANCE, getRef());
+
+            CaptureSnapshotReply reply = expectMsgClass(duration("3 seconds"), CaptureSnapshotReply.class);
+
+            assertNotNull("getSnapshot is null", reply.getSnapshot());
+
+            NormalizedNode<?,?> actualRoot = SerializationUtils.deserializeNormalizedNode(
+                    reply.getSnapshot());
+
+            assertEquals("Root node", expectedRoot, actualRoot);
+
+            expectTerminated(duration("3 seconds"), transaction);
+        }};
     }
 
-    @SuppressWarnings("unchecked")
     @Test
     public void testOnReceiveCloseTransaction() throws Exception {
         new JavaTestKit(getSystem()) {{
-            final ActorRef shard = createShard();
-            final Props props = ShardTransaction.props(store.newReadWriteTransaction(), shard,
-                    testSchemaContext, datastoreContext, shardStats, "txn",
-                    DataStoreVersions.CURRENT_VERSION);
-            final ActorRef transaction = getSystem().actorOf(props, "testCloseTransaction");
+            final ActorRef transaction = newTransactionActor(store.newReadWriteTransaction(),
+                    "testCloseTransaction");
 
             watch(transaction);
 
@@ -445,12 +445,8 @@ public class ShardTransactionTest extends AbstractActorTest {
                 Duration.create(500, TimeUnit.MILLISECONDS)).build();
 
         new JavaTestKit(getSystem()) {{
-            final ActorRef shard = createShard();
-            final Props props = ShardTransaction.props(store.newReadWriteTransaction(), shard,
-                    testSchemaContext, datastoreContext, shardStats, "txn",
-                    DataStoreVersions.CURRENT_VERSION);
-            final ActorRef transaction =
-                getSystem().actorOf(props, "testShardTransactionInactivity");
+            final ActorRef transaction = newTransactionActor(store.newReadWriteTransaction(),
+                    "testShardTransactionInactivity");
 
             watch(transaction);
 
index b33f902929a470eae42bb51f19718a5846d7c5e4..9daaa0da9739640d35cfac49fe7323d27378735c 100644 (file)
@@ -1,35 +1,49 @@
 package org.opendaylight.controller.cluster.datastore.modification;
 
+import static org.junit.Assert.assertEquals;
 import com.google.common.base.Optional;
+import org.apache.commons.lang.SerializationUtils;
 import org.junit.Assert;
 import org.junit.Test;
 import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
 import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
 import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
 
-public class DeleteModificationTest extends AbstractModificationTest{
-
-  @Test
-  public void testApply() throws Exception {
-    //Write something into the datastore
-    DOMStoreReadWriteTransaction writeTransaction = store.newReadWriteTransaction();
-    WriteModification writeModification = new WriteModification(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME), TestModel.createTestContext());
-    writeModification.apply(writeTransaction);
-    commitTransaction(writeTransaction);
-
-    //Check if it's in the datastore
-    Optional<NormalizedNode<?,?>> data = readData(TestModel.TEST_PATH);
-    Assert.assertTrue(data.isPresent());
-
-    //Delete stuff from the datastore
-    DOMStoreWriteTransaction deleteTransaction = store.newWriteOnlyTransaction();
-    DeleteModification deleteModification = new DeleteModification(TestModel.TEST_PATH);
-    deleteModification.apply(deleteTransaction);
-    commitTransaction(deleteTransaction);
-
-    data = readData(TestModel.TEST_PATH);
-    Assert.assertFalse(data.isPresent());
-  }
+public class DeleteModificationTest extends AbstractModificationTest {
+
+    @Test
+    public void testApply() throws Exception {
+        // Write something into the datastore
+        DOMStoreReadWriteTransaction writeTransaction = store.newReadWriteTransaction();
+        WriteModification writeModification = new WriteModification(TestModel.TEST_PATH,
+                ImmutableNodes.containerNode(TestModel.TEST_QNAME));
+        writeModification.apply(writeTransaction);
+        commitTransaction(writeTransaction);
+
+        // Check if it's in the datastore
+        Optional<NormalizedNode<?, ?>> data = readData(TestModel.TEST_PATH);
+        Assert.assertTrue(data.isPresent());
+
+        // Delete stuff from the datastore
+        DOMStoreWriteTransaction deleteTransaction = store.newWriteOnlyTransaction();
+        DeleteModification deleteModification = new DeleteModification(TestModel.TEST_PATH);
+        deleteModification.apply(deleteTransaction);
+        commitTransaction(deleteTransaction);
+
+        data = readData(TestModel.TEST_PATH);
+        Assert.assertFalse(data.isPresent());
+    }
+
+    @Test
+    public void testSerialization() {
+        YangInstanceIdentifier path = TestModel.TEST_PATH;
+
+        DeleteModification expected = new DeleteModification(path);
+
+        DeleteModification clone = (DeleteModification) SerializationUtils.clone(expected);
+        assertEquals("getPath", expected.getPath(), clone.getPath());
+    }
 }
index 5d2021167b52564c76a636fc29dc8c94e2d80e66..a69d9388a7b1e25f8d19f22ba426785aeae8e375 100644 (file)
@@ -1,13 +1,16 @@
 package org.opendaylight.controller.cluster.datastore.modification;
 
+import static org.junit.Assert.assertEquals;
 import com.google.common.base.Optional;
+import org.apache.commons.lang.SerializationUtils;
 import org.junit.Assert;
 import org.junit.Test;
 import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
 import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
 
 public class MergeModificationTest extends AbstractModificationTest{
 
@@ -17,7 +20,8 @@ public class MergeModificationTest extends AbstractModificationTest{
 
         //Write something into the datastore
         DOMStoreReadWriteTransaction writeTransaction = store.newReadWriteTransaction();
-        MergeModification writeModification = new MergeModification(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME), TestModel.createTestContext());
+        MergeModification writeModification = new MergeModification(TestModel.TEST_PATH,
+                ImmutableNodes.containerNode(TestModel.TEST_QNAME));
         writeModification.apply(writeTransaction);
         commitTransaction(writeTransaction);
 
@@ -29,16 +33,15 @@ public class MergeModificationTest extends AbstractModificationTest{
 
     @Test
     public void testSerialization() {
-        SchemaContext schemaContext = TestModel.createTestContext();
-        NormalizedNode<?, ?> node = ImmutableNodes.containerNode(TestModel.TEST_QNAME);
-        MergeModification mergeModification = new MergeModification(TestModel.TEST_PATH,
-                node, schemaContext);
+        YangInstanceIdentifier path = TestModel.TEST_PATH;
+        NormalizedNode<?, ?> data = ImmutableContainerNodeBuilder.create().withNodeIdentifier(
+                new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME)).
+                withChild(ImmutableNodes.leafNode(TestModel.DESC_QNAME, "foo")).build();
 
-        Object serialized = mergeModification.toSerializable();
+        MergeModification expected = new MergeModification(path, data);
 
-        MergeModification newModification = MergeModification.fromSerializable(serialized, schemaContext);
-
-        Assert.assertEquals("getPath", TestModel.TEST_PATH, newModification.getPath());
-        Assert.assertEquals("getData", node, newModification.getData());
+        MergeModification clone = (MergeModification) SerializationUtils.clone(expected);
+        assertEquals("getPath", expected.getPath(), clone.getPath());
+        assertEquals("getData", expected.getData(), clone.getData());
     }
 }
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/ModificationPayloadTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/ModificationPayloadTest.java
new file mode 100644 (file)
index 0000000..bbfff70
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2015 Brocade Communications Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.cluster.datastore.modification;
+
+import static org.junit.Assert.assertEquals;
+import org.apache.commons.lang.SerializationUtils;
+import org.junit.Test;
+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.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
+
+/**
+ * Unit tests for ModificationPayload.
+ *
+ * @author Thomas Pantelis
+ */
+public class ModificationPayloadTest {
+
+    @Test
+    public void test() throws Exception {
+
+        YangInstanceIdentifier writePath = TestModel.TEST_PATH;
+        NormalizedNode<?, ?> writeData = ImmutableContainerNodeBuilder.create().withNodeIdentifier(
+                new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME)).
+                withChild(ImmutableNodes.leafNode(TestModel.DESC_QNAME, "foo")).build();
+
+        MutableCompositeModification compositeModification = new MutableCompositeModification();
+        compositeModification.addModification(new WriteModification(writePath, writeData));
+
+        ModificationPayload payload = new ModificationPayload(compositeModification);
+
+        MutableCompositeModification deserialized = (MutableCompositeModification) payload.getModification();
+
+        assertEquals("getModifications size", 1, deserialized.getModifications().size());
+        WriteModification write = (WriteModification)deserialized.getModifications().get(0);
+        assertEquals("getPath", writePath, write.getPath());
+        assertEquals("getData", writeData, write.getData());
+
+        ModificationPayload cloned =
+                (ModificationPayload) SerializationUtils.clone(payload);
+
+        deserialized = (MutableCompositeModification) payload.getModification();
+
+        assertEquals("getModifications size", 1, deserialized.getModifications().size());
+        write = (WriteModification)deserialized.getModifications().get(0);
+        assertEquals("getPath", writePath, write.getPath());
+        assertEquals("getData", writeData, write.getData());
+    }
+}
index f8116aa78d72f4b08597cee693d592ca8c32ed87..8ae2a8657d2ec05abd439c6f60376d28b4516114 100644 (file)
@@ -1,15 +1,18 @@
 package org.opendaylight.controller.cluster.datastore.modification;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
 import com.google.common.base.Optional;
+import com.google.common.base.Stopwatch;
+import org.apache.commons.lang.SerializationUtils;
+import org.junit.Ignore;
 import org.junit.Test;
 import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
 import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
+import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
 
 public class MutableCompositeModificationTest extends AbstractModificationTest {
 
@@ -18,7 +21,7 @@ public class MutableCompositeModificationTest extends AbstractModificationTest {
 
         MutableCompositeModification compositeModification = new MutableCompositeModification();
         compositeModification.addModification(new WriteModification(TestModel.TEST_PATH,
-            ImmutableNodes.containerNode(TestModel.TEST_QNAME), TestModel.createTestContext()));
+            ImmutableNodes.containerNode(TestModel.TEST_QNAME)));
 
         DOMStoreReadWriteTransaction transaction = store.newReadWriteTransaction();
         compositeModification.apply(transaction);
@@ -31,13 +34,68 @@ public class MutableCompositeModificationTest extends AbstractModificationTest {
     }
 
     @Test
-    public void testEverySerializedCompositeModificationObjectMustBeDifferent(){
+    public void testSerialization() {
+        YangInstanceIdentifier writePath = TestModel.TEST_PATH;
+        NormalizedNode<?, ?> writeData = ImmutableContainerNodeBuilder.create().withNodeIdentifier(
+                new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME)).
+                withChild(ImmutableNodes.leafNode(TestModel.DESC_QNAME, "foo")).build();
+
+        YangInstanceIdentifier mergePath = TestModel.OUTER_LIST_PATH;
+        NormalizedNode<?, ?> mergeData = ImmutableContainerNodeBuilder.create().withNodeIdentifier(
+                new YangInstanceIdentifier.NodeIdentifier(TestModel.OUTER_LIST_QNAME)).build();
+
+        YangInstanceIdentifier deletePath = TestModel.TEST_PATH;
+
         MutableCompositeModification compositeModification = new MutableCompositeModification();
-        compositeModification.addModification(new WriteModification(TestModel.TEST_PATH,
-            ImmutableNodes.containerNode(TestModel.TEST_QNAME), TestModel.createTestContext()));
-        Object one = compositeModification.toSerializable();
-        try{Thread.sleep(10);}catch(Exception err){}
-        Object two = compositeModification.toSerializable();
-        assertNotEquals(one,two);
+        compositeModification.addModification(new WriteModification(writePath, writeData));
+        compositeModification.addModification(new MergeModification(mergePath, mergeData));
+        compositeModification.addModification(new DeleteModification(deletePath));
+
+        MutableCompositeModification clone = (MutableCompositeModification) SerializationUtils.clone(compositeModification);
+
+        assertEquals("getModifications size", 3, clone.getModifications().size());
+
+        WriteModification write = (WriteModification)clone.getModifications().get(0);
+        assertEquals("getPath", writePath, write.getPath());
+        assertEquals("getData", writeData, write.getData());
+
+        MergeModification merge = (MergeModification)clone.getModifications().get(1);
+        assertEquals("getPath", mergePath, merge.getPath());
+        assertEquals("getData", mergeData, merge.getData());
+
+        DeleteModification delete = (DeleteModification)clone.getModifications().get(2);
+        assertEquals("getPath", deletePath, delete.getPath());
+    }
+
+    @Test
+    @Ignore
+    public void testSerializationScale() throws Exception {
+        YangInstanceIdentifier writePath = TestModel.TEST_PATH;
+        NormalizedNode<?, ?> writeData = ImmutableContainerNodeBuilder.create().withNodeIdentifier(
+                new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME)).
+                withChild(ImmutableNodes.leafNode(TestModel.DESC_QNAME, "foo")).build();
+
+        MutableCompositeModification compositeModification = new MutableCompositeModification();
+        for(int i = 0; i < 1000; i++) {
+            compositeModification.addModification(new WriteModification(writePath, writeData));
+        }
+
+        Stopwatch sw = new Stopwatch();
+        sw.start();
+        for(int i = 0; i < 1000; i++) {
+            new ModificationPayload(compositeModification);
+        }
+
+        sw.stop();
+        System.out.println("Elapsed: "+sw);
+
+        ModificationPayload p = new ModificationPayload(compositeModification);
+        sw.start();
+        for(int i = 0; i < 1000; i++) {
+            p.getModification();
+        }
+
+        sw.stop();
+        System.out.println("Elapsed: "+sw);
     }
 }
index 3a82fffccb16ffe9e02b3e85c2106213e749dce1..2e9ce224b7e482edf32cefd5b4f590afef04d4c7 100644 (file)
@@ -1,22 +1,25 @@
 package org.opendaylight.controller.cluster.datastore.modification;
 
+import static org.junit.Assert.assertEquals;
 import com.google.common.base.Optional;
+import org.apache.commons.lang.SerializationUtils;
 import org.junit.Assert;
 import org.junit.Test;
 import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
 import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
 
-public class WriteModificationTest extends AbstractModificationTest{
+public class WriteModificationTest extends AbstractModificationTest {
 
     @Test
     public void testApply() throws Exception {
         //Write something into the datastore
         DOMStoreReadWriteTransaction writeTransaction = store.newReadWriteTransaction();
         WriteModification writeModification = new WriteModification(TestModel.TEST_PATH,
-                ImmutableNodes.containerNode(TestModel.TEST_QNAME), TestModel.createTestContext());
+                ImmutableNodes.containerNode(TestModel.TEST_QNAME));
         writeModification.apply(writeTransaction);
         commitTransaction(writeTransaction);
 
@@ -27,16 +30,15 @@ public class WriteModificationTest extends AbstractModificationTest{
 
     @Test
     public void testSerialization() {
-        SchemaContext schemaContext = TestModel.createTestContext();
-        NormalizedNode<?, ?> node = ImmutableNodes.containerNode(TestModel.TEST_QNAME);
-        WriteModification writeModification = new WriteModification(TestModel.TEST_PATH,
-                node, schemaContext);
-
-        Object serialized = writeModification.toSerializable();
+        YangInstanceIdentifier path = TestModel.TEST_PATH;
+        NormalizedNode<?, ?> data = ImmutableContainerNodeBuilder.create().withNodeIdentifier(
+                new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME)).
+                withChild(ImmutableNodes.leafNode(TestModel.DESC_QNAME, "foo")).build();
 
-        WriteModification newModification = WriteModification.fromSerializable(serialized, schemaContext);
+        WriteModification expected = new WriteModification(path, data);
 
-        Assert.assertEquals("getPath", TestModel.TEST_PATH, newModification.getPath());
-        Assert.assertEquals("getData", node, newModification.getData());
+        WriteModification clone = (WriteModification) SerializationUtils.clone(expected);
+        assertEquals("getPath", expected.getPath(), clone.getPath());
+        assertEquals("getData", expected.getData(), clone.getData());
     }
 }
index a3041e89dbf9ac2a9139552c6cafff7437bc0390..79c1bb4720e9790599b99bb17c6cf6d823275b86 100644 (file)
@@ -20,6 +20,7 @@ import org.opendaylight.controller.cluster.datastore.modification.WriteModificat
 import org.opendaylight.controller.cluster.example.messages.KeyValue;
 import org.opendaylight.controller.cluster.raft.ReplicatedLogEntry;
 import org.opendaylight.controller.cluster.raft.messages.AppendEntries;
+import org.opendaylight.controller.cluster.raft.protobuff.client.messages.CompositeModificationByteStringPayload;
 import org.opendaylight.controller.cluster.raft.protobuff.client.messages.CompositeModificationPayload;
 import org.opendaylight.controller.cluster.raft.protobuff.client.messages.Payload;
 import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
@@ -72,16 +73,14 @@ public class Client {
             @Override public Payload getData() {
                 WriteModification writeModification =
                     new WriteModification(TestModel.TEST_PATH, ImmutableNodes
-                        .containerNode(TestModel.TEST_QNAME),
-                        TestModel.createTestContext()
-                    );
+                        .containerNode(TestModel.TEST_QNAME));
 
                 MutableCompositeModification compositeModification =
                     new MutableCompositeModification();
 
                 compositeModification.addModification(writeModification);
 
-                return new CompositeModificationPayload(
+                return new CompositeModificationByteStringPayload(
                     compositeModification.toSerializable());
             }
 
index e6bdf5aac379571ba0b130c1b3076e9c25f75299..6b6cf326be240421f44591d3a0b7bcc7591d3fef 100644 (file)
@@ -24,7 +24,7 @@ public class Server {
     public static class ServerActor extends UntypedActor {
 
         @Override public void onReceive(Object message) throws Exception {
-            if(AppendEntries.SERIALIZABLE_CLASS.equals(message.getClass())){
+            if(AppendEntries.LEGACY_SERIALIZABLE_CLASS.equals(message.getClass())){
                 AppendEntries appendEntries =
                     AppendEntries.fromSerializable(message);
 
index 4737d6eb49254ed6a2ded147d3429848d9a2bb4c..bbaf6becf4b10ceef502005578f1f4311d9ca2cb 100644 (file)
@@ -38,7 +38,6 @@ public class PeopleCarListener implements CarPurchaseListener {
 
   @Override
   public void onCarBought(CarBought notification) {
-    log.info("onCarBought notification : Adding car person entry");
 
     final CarPersonBuilder carPersonBuilder = new CarPersonBuilder();
     carPersonBuilder.setCarId(notification.getCarId());
@@ -47,6 +46,8 @@ public class PeopleCarListener implements CarPurchaseListener {
     carPersonBuilder.setKey(key);
     final CarPerson carPerson = carPersonBuilder.build();
 
+    log.info("Car bought, adding car-person entry: [{}]", carPerson);
+
     InstanceIdentifier<CarPerson> carPersonIId =
         InstanceIdentifier.<CarPeople>builder(CarPeople.class).child(CarPerson.class, carPerson.getKey()).build();
 
@@ -57,12 +58,12 @@ public class PeopleCarListener implements CarPurchaseListener {
     Futures.addCallback(tx.submit(), new FutureCallback<Void>() {
       @Override
       public void onSuccess(final Void result) {
-        log.info("Car bought, entry added to map of people and car [{}]", carPerson);
+        log.info("Successfully added car-person entry: [{}]", carPerson);
       }
 
       @Override
       public void onFailure(final Throwable t) {
-        log.info("Car bought, Failed entry addition to map of people and car [{}]", carPerson);
+        log.error(String.format("Failed to add car-person entry: [%s]", carPerson), t);
       }
     });
 
index e0d3f753499468fe6294d128df7040fa1a005952..ef666817e82c21c9b7941b9c3657c166b5502d61 100644 (file)
@@ -11,6 +11,7 @@ package org.opendaylight.controller.clustering.it.provider;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.SettableFuture;
+import java.util.concurrent.Future;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
@@ -22,15 +23,13 @@ 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.config.sal.clustering.it.people.rev140818.PersonContext;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.people.rev140818.people.Person;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.people.rev140818.people.PersonBuilder;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.common.RpcError;
 import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.concurrent.Future;
-
 public class PeopleProvider implements PeopleService, AutoCloseable {
 
   private static final Logger log = LoggerFactory.getLogger(PeopleProvider.class);
@@ -76,7 +75,7 @@ public class PeopleProvider implements PeopleService, AutoCloseable {
 
       @Override
       public void onFailure(final Throwable t) {
-        log.info("RPC addPerson : person addition failed [{}]", person);
+        log.error(String.format("RPC addPerson : person addition failed [%s]", person), t);
         futureResult.set(RpcResultBuilder.<Void>failed()
             .withError(RpcError.ErrorType.APPLICATION, t.getMessage()).build());
       }