Delta propagation reduces the amount of data you send over the network. You do this by only sending the change, or delta, information about an object, instead of sending the entire changed object. If you do not use cloning when applying the deltas, you can also expect to generate less garbage in your receiving JVMs.
In most distributed data management systems, the data stored in the system tends to be created once and then updated frequently. These updates are sent to other members for event propagation, redundancy management, and cache consistency in general. Tracking only the changes in an updated object and sending only the deltas mean lower network transmission costs and lower object serialization/deserialization costs. Performance improvements can be significant, especially when changes to an object are small relative to its overall size.
Tanzu GemFire propagates object deltas using methods that you program. The methods are in the Delta
interface, which you implement in your cached objects’ classes. If any of your classes are plain old Java objects, you need to wrap them for this implementation.
This figure shows delta propagation for a change to an entry with key, k, and value object, v.
get
operation. The get
works as usual: the cache returns the full entry object from the local cache or, if it isn’t available there, from a remote cache or from a loader.put
operation. The put
works as usual in the local cache, using the full value, then calls hasDelta
to see if there are deltas and toDelta
to serialize the information. Distribution is the same as for full values, according to member and region configuration.fromDelta
extracts the delta information that was serialized by toDelta
and applies it to the object in the local cache. The delta is applied directly to the existing value or to a clone, depending on how you configure it for the region.toDelta
is only called in the originating member.To use the delta propagation feature, all updates on a key in a region must have value types that implement the Delta
interface. You cannot mix object types for an entry key where some of the types implement delta and some do not. This is because, when a type implementing the delta interface is received for an update, the existing value for the key is cast to a Delta
type to apply the received delta. If the existing type does not also implement the Delta
interface, the operation throws a ClassCastException
.
Note: Only the object itself being placed in the cache can implement the Delta
interface and propagate changes. Any sub-objects of the cache object do not propagate their changes.
Sometimes fromDelta
cannot be invoked because there is no object to apply the delta to in the receiving cache. When this happens, the system automatically does a full value distribution to the receiver. These are the possible scenarios: 1. If the system can determine beforehand that the receiver does not have a local copy, it sends the initial message with the full value. This is possible when regions are configured with no local data storage, such as with the region shortcut settings PARTITION_PROXY
and REPLICATE_PROXY
. These configurations are used to accomplish things like provide data update information to listeners and to pass updates forward to clients. 2. In less obvious cases, such as when an entry has been locally deleted, first the delta is sent, then the receiver requests a full value and that is sent. Whenever the full value is received, any further distributions to the receiver’s peers or clients uses the full value.
Tanzu GemFire also does not propagate deltas for:
putAll
operationThe following topologies support delta propagation (with some limitations):
distributed-ack
or global
. The region shortcut settings for distributed regions use distributed-ack
scope
. Delta propagation does not work for regions with distributed-no-ack
scope
because the receiver could not recover if an exception occurred while applying the delta.gemfire.properties
setting conflate-events
is set to true, the servers send full values for all regions.enable-subscription-conflation
is set to true and the client gemfire.properties
setting conflate-events
is set to server
, the servers send full values for the region.PROXY
client region shortcut setting (empty client region), servers send full values.