|Getting Started with Pivotal GemFire / QuickStart Examples|
Delta propagation lets you send deltas (changes) instead of full values when you propagate events from one cache to another.
In distributed data management systems, most data is created once and then updated frequently. The updates are sent to other members for event propagation, redundancy management, and cache consistency in general. With delta propagation, you track only the changes in an updated object and send only the parts that have changed: the deltas. This feature brings significant performance benefits because of lower network transmission and object serialization/deserialization costs. The cost savings can be significant, especially when changes to an object instance are relatively small compared to the overall size of the instance.
The example shows a very simple client/server installation with one feeder client, that gets and updates data in its cache, and one receiver client, that receives data events from the server. Both are connected to a single cacheserver. The feeder client requests data from the server and then updates the data in its cache. The update to the feeder client's cache also updates the server's cache. The server automatically forwards these data events to the receiver client, so the receiver's cache is updated as well. The clients have an asynchronous listener that reports local cache activity to standard out.
The key to delta propagation is in the coding of the object stored in the region entry value. The entry value object, DeltaObj, used in this example implements GemFire's com.gemstone.gemfire.Delta, so that it sends and receives only the object deltas, rather than the full object. So, when the feeder client changes the object, the object tracks what is being changed. When the feeder client puts the object into its cache and GemFire distributes the put event to the server, the object provides only the delta for the distribution. The server receives the delta, uses the same object implementation to read the delta and update its cached copy, then forwards the delta to the receiver client, who does the same.
In one session, start the GemFire cacheserver (see Pivotal GemFire Servers for more information):
$ gfsh start server --name=server_dp --cache-xml-file=xml/DeltaServer.xml
The gfsh command starts a cache server in the background, displays the status of the server and some environment information, and then exits to the command prompt.
In the same session, start the feeder client:
$ java quickstart.DeltaPropagationClientFeeder
The feeder prompts you to press Enter. Before you do, in another session, start the receiver client:
$ java quickstart.DeltaPropagationClientReceiver
Go back to the feeder session and press Enter.
Follow the instructions on the screens, noting the listener output from each client.
Stop the receiver by pressing Enter.
Stop the cache server:
$ gfsh stop server --dir=server_dp
You can also use the deprecated cacheserver command to stop the cache server:
$ cacheserver stop
Program and cache configuration files for the clients and the server, including the loader and listener declared in the Server.xml and Client.xml files. (The server is a GemFire cacheserver process and does not have an example source file.)
|DeltaServer.xml||Initializes a cache to serve the /root/cs_region region, waiting for client communication.|
|DeltaClient1.xml||Initializes a client of a cache server that runs on port 40404. Loads values and sends updates to the server.|
|DeltaClient2.xml||Initializes a client of a cache server that runs on port 40450. Loads values and sends updates to the server.|
|DeltaObj.java||A sample Object class that implements Delta.|
|DeltaPropagationClientFeeder.java||The client that connects to the DeltaPropagationServer.java.|
|DeltaPropagationClientReceiver.java||Sets up a new cache with a ReceiverListener.|
|DeltaSimpleListener.java||A Delta Propagation quick start cache listener for simple uses.|
|DeltaReceiverListener.java||A Delta Propagation quick start receiver cache listener.|