GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — geode-examples/colocation at develop · apache/geode-examples

Expand file tree

/

colocation

/
Copy path

Directory actions

More options

More options

Directory actions

More options

More options

Latest commit

 

History

History
History
/

colocation

/
Copy path

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
scripts
scripts
 
 
src/main/java/org/apache/geode_examples/colocation
src/main/java/org/apache/geode_examples/colocation
 
 
README.md
README.md
 
 

README.md

Outline

Geode colocation example

This is a simple example that illustrates how to colocate the data of two regions.

By default, Geode selects the data locations for a partitioned region independent of the data locations for any other partitioned region using a hashing policy on the key. This example shows how to modify this policy in order to store related data from two regions (orderand customer) in the same member.

customer region stores Customer objects using an int as key:

Region<Integer, Customer> customerRegion

order region stores Order object using an OrderKey object as key:

Region<OrderKey, Order> accountRegion

In order to store Order objects in the same member than their related customer info, a custom partition-resolved is needed: OrderPartitionResolved. When this partition resolver receives an OrderKey object, it returns the same key (the customer id) that was used to store the related customer. In this way, Geode applies the hashing policy over the same key for Orderand Customer related objects and as a consequence, they are stored in the same member.

Steps

  1. From the geode-examples/colocation directory, build the example.

     $ ../gradlew build
    
  2. Next start a locator, start two servers, create customer region, and create orderregion colocated with customer region.

     $ ../gradlew start
    
  3. Run the example to put entries into both regions.

     $ ../gradlew run
    
  4. Shut down the system.

     $ ../gradlew stop
    
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.