LATEST VERSION: 8.2.7 - CHANGELOG
Pivotal GemFire® v8.2

Running the Connection Pool Code

Running the Connection Pool Code

Examples demonstrate a simple procedure to create a pool factory and then create a pool instance in C++ and C#. They also help you to execute a query.

The examples create a pool with locators. Ensure that you create a pool with locators or endpoints, but not both. The first example demonstrates creating a pool by adding locators. The second example demonstrates creating a pool by adding servers. For more information, see the example in the QuickStart Guide.

Connection Pool Creation and Execution Using C++

PropertiesPtr prptr = Properties::create();
systemPtr = CacheFactory::createCacheFactory(prptr);

cachePtr = systemPtr->create();
PoolFactoryPtr poolFacPtr = PoolManager::createFactory();
//to create pool add either endpoints or add locators or servers
//pool with endpoint, adding to pool factory
//poolFacPtr->addServer("localhost", 12345 /*port number*/);
//pool with locator, adding to pool factory
poolFacPtr->addLocator("localhost", 34756 /*port number*/);
PoolPtr pptr = NULLPTR;
if ((PoolManager::find("examplePool")) == NULLPTR) {
  // Pool does not exist with the same name.
  pptr = poolFacPtr->create("examplePool");
}
RegionFactoryPtr regionFactory =
    cachePtr->createRegionFactory(CACHING_PROXY);
regionPtr = regionFactory
    ->setPoolName("examplePool")
    ->create("regionName");
QueryServicePtr qs = cachePtr->getQueryService("examplePool");

Connection Pool Creation and Execution Using (C# .NET)

Properties prop = Properties.Create();
CacheFactory cacheFactory = CacheFactory.CreateCacheFactory(prop);
Cache cache = cacheFactory.Create();

PoolFactory poolFact = PoolManager.CreateFactory();
//to create pool add either endpoints or add locators
//pool with endpoint, adding to pool factory.
poolFact.AddServer("localhost", 40404 /*port number*/);
//pool with locator, adding to pool factory
//poolFact.AddLocator("hostname", 15000 /*port number*/);
Pool pool = null;
if (PoolManager.Find("poolName") == null) {
  pool = poolFact.Create("poolName");
}
int loadConditInterval = pool.LoadConditioningInterval;
RegionFactory regionFactory =
    cache.CreateRegionFactory(RegionShortcut.CACHING_PROXY);
IRegion<string, string> region =
    regionFactory.SetPoolName(poolName).Create<string, string>(regionName);