Table of Contents

Using the Polling Coherency Policy

Configure ScaleOut GeoServer to use Pull replication with a Polling coherency policy when every update to an object does not need to be replicated to other datacenters.

Background

Consider a branch office that needs to periodically refresh an object over a WAN link. The branch office does not need to see every update that is made to the primary object in the main office's datastore--it only needs its local replica of the object to be refreshed once every minute.

Using GeoServer's Polling coherency policy with a one-minute interval will conserve bandwidth over the WAN compared to a policy that replicates every update made to the primary object.

Prerequisites

  • GeoServer replication requires at least two independent ScaleOut stores. Each store must have at least one instance of the ScaleOut service running and active.
  • One of the stores (the "BranchOffice" store, in this scenario) must have GeoServer Pull replication configured and started. Bi-directional replication may be enabled, but this example will only use GeoServer replication in one direction.

GeoServer Configuration

  • Local Store: "BranchOffice"
  • Remote Store: "MainOffice"
  • GeoServer is configured in the BranchOffice store to perform Pull replication:
Console Polling Screenshot

Procedure

  1. Create the object in the remote store (the main office) and configure its coherency policy.
  • Use CacheBuilder methods to grant remote access to objects in a cache and set their coherency policies.
var mainOfficeConn = GridConnection.Connect("bootstrapGateways=MainOfficeServer1:721");

var builder = new CacheBuilder<string, decimal>("stock prices", mainOfficeConn)
                  .SetGeoServerPullPolicy(GeoServerPullPolicy.AllowRemoteAccess)
                  .SetGeoServerCoherencyPolicy(GeoServerCoherencyPolicy.Poll)
                  .SetGeoServerCoherencyInterval(TimeSpan.FromMinutes(1));

var stockPriceCache = builder.Build();

// Add object(s) to be accessed remotely by branch office:
stockPriceCache.AddOrUpdate("MSFT", 126.90m);
  1. Read the object in the local store (the branch office) to pull the object across the WAN.
  • Use CacheBuilder.SetRemoteStoreAccess to supply the name of the ScaleOut store that you want to pull objects from. The remote store name must match the configured remote store name in the ScaleOut Console management tool.
    • Not shown in this example: More than one remote store name can be supplied to CacheBuilder.SetRemoteStoreAccess if you have multiple datacenters that need to be checked for objects.
  • Reading a remote object causes the local "BranchOffice" store to create a proxy object that is periodically refreshed.
  • If there is a WAN outage between ScaleOut stores that prevents the local object from being refreshed, the response returned from the read operation will have its result set to ServerResult.RetrievedStale.
  • If the remote store does not contain the requested object, the branch's store will receive a NotFound result.
var branchConn = GridConnection.Connect("bootstrapGateways=BranchOfficeServer1:721");

var builder = new CacheBuilder<string, decimal>("stock prices", branchConn)
                  .SetRemoteStoreAccess(new [] { "MainOffice" });

var stockPriceCache = builder.Build();

var readResponse = stockPriceCache.Read("MSFT");
switch (readResponse.Result)
{
    case ServerResult.Retrieved:
        Console.WriteLine($"{readResponse.Key} price: {readResponse.Value}");
        break;
    case ServerResult.NotFound:
        Console.WriteLine($"Price not found in branch or main store.");
        break;
    case ServerResult.RetrievedStale:
        Console.WriteLine($"{readResponse.Key} price: {readResponse.Value}");
        Console.WriteLine("Warning: price not current due to WAN outage.");
        break;
    default:
        Console.WriteLine($"Read encountered unexpected {readResponse.Result} error.");
        break;
}

Result

Once an object has been pulled from a remote store with a polling coherency interval, it will continue to be refreshed periodically until the primary copy of the object is removed from the remote store.