BUG 2464 : Shard dataSize does not seem to correspond to actual memory usage 49/13349/7
authorMoiz Raja <moraja@cisco.com>
Wed, 3 Dec 2014 17:58:35 +0000 (09:58 -0800)
committerMoiz Raja <moraja@cisco.com>
Tue, 16 Dec 2014 21:37:43 +0000 (21:37 +0000)
commitdeb9baa6423b052d51bb4ea354b8582aac76e41e
treede3fc77bd7ff8357cf576178833e0723e49be647
parent63d1393226781ef6fa1c2cf0cdba5f0b5240ab6e
BUG 2464 : Shard dataSize does not seem to correspond to actual memory usage

The dataSize that is reported is the "serialized" size of the payload. Since the replicated
log actually contains the CompositeModification object (which may hold on to a lot more memory)
the serialized size is not neccessarily the same as the object size.

To make the data size correspond to memory usage and to actually reduce memory usage this patch
creates a new payload class called CompositeModificationByteStringPayload which only stores the
ByteString which is an order of magnitude smaller. Custom serialization ensures that this object
is written and read correctly.

This patch is backward compatible in that a replicated log containing a CompositeModificationPayload
will be read correctly but is not forward compatible in that if a new controller instance were to send
a CompositeModificationPayload to an older instance it would not work.

To ensure that we do not need to immediately require a conversion from ByteString to PersistentMessages.CompositeModification we maintain a SoftReference to CompositeModification.

Change-Id: I32c921dea2d39ed689aa2fb6f68eb8528be920d0
Signed-off-by: Moiz Raja <moraja@cisco.com>
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/raft/protobuff/client/messages/CompositeModificationByteStringPayload.java [new file with mode: 0644]
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/Shard.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/CompositeModificationByteStringPayloadTest.java [new file with mode: 0644]
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTest.java