All Downloads are FREE. Search and download functionalities are using the official Maven repository.

portableDataExchange.README.html Maven / Gradle / Ivy




 
 
  
  
  

vFabric GemFire®

Portable Data Exchange

Java Caching API Programming Example


The portableDataExchange example demonstrates how to use gemfires Portable Data eXchange (PDX) framework to serialize objects efficiently. There are two examples which each show a different technique for serializing objects using PDX. In the first example, the domain objects extend the PdxSerializable interface. In the second example, a PdxSerializer is used to serialize multiple domain objects. Finally, the second example also shows how to use the built in ReflectionBasedAutoSerializer to serialize many objects without needing to write serialization code.

In every shell used to run this example application, configure your environment according to the instructions provided in examples/EnvSetup.html.

Once your environment is set, change to the examples/dist/portableDataExchange directory to run the application.

Running the PdxSerializable example

In this example domain objects which implement the PdxSerializable interface are created on a client. The client sends puts the object in a region which is stored on the server. The client then executes queries against the server to retrieve the objects.

  1. Start a cache server using the given cache xml file.
    cacheserver start cache-xml-file=server.xml
  2. When that returns, start the client same session
  3. java portableDataExchange.pdxserializable.Client

    When the client finishes it exits automatically.

Sample Output
Created the GemFire Cache
Obtained the Region from the Cache
Populated some PortfolioPdx Objects
Got the QueryService from the Pool
ResultSet Query returned 3 rows
StructSet Query returned 2 rows
Row 1 Column 0 is named id, value is 2
Row 1 Column 1 is named status, value is active
Row 2 Column 0 is named id, value is 3
Row 2 Column 1 is named status, value is inactive
The server uses the LoggingCacheListener class to log create events to the log for the cacheserver. Look at cacheserver.log. The listener logged the following creates to the log, without fully deserializing the objects on the server.
LoggingCacheListener: - 1 created at Tue Jul 19 18:54:47 PDT 2011
LoggingCacheListener: - 2 created at Tue Jul 19 18:54:47 PDT 2011
LoggingCacheListener: - 3 created at Tue Jul 19 18:54:47 PDT 2011
Running the PdxSerializer example

This example is the same as the PdxSerialiable example, above, except that the domain objects are POJOs that do not implement any gemfire interface. Instead, a PdxSerializer that knows how to serialize these objects is registered with the cache

  1. Start a cache server using the given cache xml file.
    cacheserver start cache-xml-file=server.xml
  2. When that returns, start the client same session
  3. java portableDataExchange.serializer.Client

    When the client finishes it exits automatically.

  4. The sample output will be the same as the PdxSerializable example
Running the auto serializer example

In this example, the built in reflection based serializer is used to automatically serialize the domain objects, without needed to write any serialization code.

  1. Start a cache server using the given cache xml file.
    cacheserver start cache-xml-file=server.xml
  2. When that returns, start the client same session auto. Pass the auto parameter to tell the client to use the auto serializer.
  3. java portableDataExchange.serializer.Client auto

    When the client finishes it exits automatically.

  4. The sample output will be the same as the PdxSerializable example





© 2015 - 2024 Weber Informatics LLC | Privacy Policy