wan

GemStone® GemFire Enterprise®

WAN Example


The wan example is an application that simulates two WAN sites, namely a US site and an EU site. The example is located in the GemFire installation under examples/dist/wan.

The WAN example contains the following four components:

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/wan directory to run the application.

To run the WAN example, perform the following steps:

  1. Launch a shell for the US gateway hub

    The US WAN hub is a cache server gateway to the EU WAN. This gateway forwards any client updates to entries in the trades region to the EU WAN. Entry updates received from the EU WAN hub are distributed to its clients.

    Change to the examples/dist/wan/us-hub directory and run the following command:

    cacheserver start
    
    This command logs output like shown below:
    Starting CacheServer with pid: 18087
    CacheServer pid: 18087 status: running
      
  2. Launch a shell for the EU gateway hub

    The EU WAN hub is a cache server gateway to the US WAN. This gateway forwards any client updates to entries in the trades region to the US WAN. Entry updates received from the US WAN hub will be distributed to its clients.

    Change to the examples/dist/wan/eu-hub directory and run the following command:

    cacheserver start
    
    This command logs output like shown below:
    Starting CacheServer with pid: 18686
    CacheServer pid: 18686 status: running
    
  3. Launch a shell for the EU client

    Change to the examples/dist/wan/eu-client directory and run the following command:.

    The EU WAN client listens for updates to entries in trades region.

    java wan.WANClient eu
    

    The WANClient class has a main method that creates either a US or EU WAN client using the 'us' or 'eu' parameters. Shown below is the WANClient usage.

    $ java wan.WANClient
    
    ** Missing site name
    
    usage: java wan.WANClient 
      site   The name of the WAN site (either 'us' or 'eu')
    
    Launches a WAN client
    

    This command logs output like shown below:

    Created GemFire cache: eu-client
    Retrieved region: com.gemstone.gemfire.internal.cache.LocalRegion[path='/trades';scope=LOCAL';data-type=NORMAL]
    Registered interest in [] for region trades
    
  4. Launch a shell for the US client

    The US WAN client launches mulitple threads, each putting entries into the trades region.

    Change to the examples/dist/wan/us-client directory and run the following command:

    java wan.WANClient us
    

    This command logs output like shown below:

    Created GemFire cache: us-client
    Retrieved region: com.gemstone.gemfire.internal.cache.LocalRegion[path='/trades';scope=LOCAL';data-policy=NORMAL]
    Thread-1: Putting key-704->704
    Thread-3: Putting key-2663->2663
    Thread-2: Putting key-2822->2822
    Thread-4: Putting key-853->853
    Thread-5: Putting key-3612->3612
    Thread-6: Putting key-1668->1668
    Thread-7: Putting key-1872->1872
    Thread-8: Putting key-4540->4540
    Thread-9: Putting key-442->442
    Thread-10: Putting key-1494->1494
    Thread-8: Putting key-2661->2661
    .
    .
    .
    

    In addition, output like shown below is displayed in the EU client window:

    WANListener received afterCreate event (1) for region trades: key-853->853
    WANListener received afterUpdate event (2) for region trades: key-1494->1494
    WANListener received afterCreate event (3) for region trades: key-4540->4540
    WANListener received afterCreate event (4) for region trades: key-704->704
    WANListener received afterUpdate event (5) for region trades: key-2822->2822
    WANListener received afterCreate event (6) for region trades: key-442->442
    WANListener received afterCreate event (7) for region trades: key-1872->1872
    WANListener received afterCreate event (8) for region trades: key-2663->2663
    WANListener received afterUpdate event (9) for region trades: key-1668->1668
    WANListener received afterUpdate event (10) for region trades: key-3612->3612
    WANListener received afterCreate event (11) for region trades: key-1926->1926
    WANListener received afterUpdate event (12) for region trades: key-2661->2661
    WANListener received afterCreate event (13) for region trades: key-2372->2372
    .
    .
    .
    
  5. Stop the us-client and eu-client client VMs by pressing CTRL-C in both shells. Stop the us-hub and eu-hub cache server VMs by entering cacheserver stop in their shells. An example is shown below.
    cacheserver stop
    CacheServer stopped
    Close the four open shells by entering exit in each.