问题
1.How does gemfire internally performs co location?
2.How does co-location works with partitioned regions?
3.How does co-location works with replicated regions?
4.How does co-location works with replicated region and partitioned region together?
3.Is custom partitioning required to do co-location?
回答1:
Gemfire's co-location capability exists so that you can ensure that your transactions will happen at memory speed rather than network speed. For instance, say you want to partition your problem by CustomerId. Customers have Orders, Shipments and Payments associated with them. Lets say that when a Shipment occurs, you want to insert the Shipment record, update the Order and update the Customer record. What you will need to do in order to guarantee that the Orders are co-located with the Customer record is build a compound key for the Orders that contains both the OrderId AND the CustomerId. This can be as simple as a String containing the OrderId and CustomerId separated by a hyphen. Then you need to implement a PartitionResolver that returns the CustomerId portion of the key. When defining the Orders region you would need to add the following to the region configuration:
<cache>
<region name="Orders">
<region-attributes>
<partition-attributes colocated-with="Customers">
<partition-resolver=CustomerIdPartitionResolver">
<class-name>myPackage.CustomerIdPartitionResolver</class-name>
</region-attributes>
</region>
</cache>
来源:https://stackoverflow.com/questions/24677584/how-gemfire-does-colocation-of-replicated-and-partitioned-regions