Apache Geode Native .NET Framework CHANGELOG

Pool Configuration Example and Settings

Connection pools require standard client/server distributed system and cache configuration settings. You must also configure settings for the locator, server, and pool elements.

  • Locator. Host and port where a server locator is listening.
  • Server. Host and port where a server is listening.
  • Pool. Client/server connection pool.

This page shows examples of creating a pool configuration programmatically using C# code, and declaratively using XML.

Programmatic Pool Configuration

This example shows a programmatic pool configuration. For a list of the attributes you can configure, see PoolFactory in the API docs.

cache.GetPoolManager()
      .CreateFactory()
      .AddLocator("localhost", 34756)
      .SetFreeConnectionTimeout(new TimeSpan.FromMilliseconds(12345))
      .SetIdleTimeout(new TimeSpan.FromMilliseconds(5555))
      .SetLoadConditioningInterval(new TimeSpan.FromMilliseconds(23456))
      .SetMaxConnections(7)
      .SetMinConnections(3)
      .SetPingInterval(new TimeSpan.FromMilliseconds(12345))
      .SetReadTimeout(new TimeSpan.FromMilliseconds(23456))
      .SetRetryAttempts(3)
      .SetServerGroup("ServerGroup1")
      .SetSocketBufferSize(32768)
      .SetStatisticInterval(new TimeSpan.FromMilliseconds(10123))
      .SetSubscriptionAckInterval(new TimeSpan.FromMilliseconds(567))
      .SetSubscriptionEnabled(true)
      .SetSubscriptionMessageTrackingTimeout(new TimeSpan.FromMilliseconds(900123))
      .SetSubscriptionRedundancy(0)
      .SetThreadLocalConnections(true)
      .Create("test_pool_1");

Declarative (File-based) Pool Configuration

This example shows a file-based pool configuration using an XML configuration file. Following the example is a table that describes the XML pool attributes you can configure.

Note: You create an instance of PoolFactory through PoolManager.

<pool free-connection-timeout="12345" idle-timeout="5555"
      load-conditioning-interval="23456"
      max-connections="7" min-connections="3"
      name="test_pool_1" ping-interval="12345"
      read-timeout="23456" retry-attempts="3" server-group="ServerGroup1"
      socket-buffer-size="32768" statistic-interval="10123"
      subscription-ack-interval="567" subscription-enabled="true"
      subscription-message-tracking-timeout="900123"
      subscription-redundancy="0" thread-local-connections="true">
   <locator host="localhost" port="34756"/>
</pool>

Pool Attributes

Attribute Name Description Default
free-connection-timeout

Number of milliseconds (ms) that the client waits for a free connection if max-connections limit is configured and all connections are in use.

10000 ms

idle-timeout

Number of milliseconds to wait for a connection to become idle for load balancing

5000 ms

load-conditioning-interval

Interval in which the pool checks to see if a connection to a specific server should be moved to a different server to improve the load balance.

300000 ms (5 minutes)

max-connections

Maximum number of connections that the pool can create. If all connections are in use, an operation requiring a client-to server-connection is blocked until a connection is available or the free-connection-timeout is reached. If set to -1, there is no maximum. The setting must indicate a cap greater than min-connections.

Note:

If you use this setting to cap your pool connections, disable the pool attribute pr-single-hop-enabled. Leaving single hop enabled can increase thrashing and lower performance.

-1

min-connections

Number of connections that must be created initially.

5

name

Pool name.

ping-interval

Interval between pinging the server to show the client is alive, set in milliseconds. Pings are only sent when the ping-interval elapses between normal client messages. This must be set lower than the server’s maximum-time-between-pings.

10000 ms

pr-single-hop-enabled

Setting used for single-hop access to partitioned region data in the servers for some data operations. See PartitionResolver. See note in thread-local-connections below.

True

read-timeout

Number of milliseconds to wait for a response from a server before the connection times out.

10000

retry-attempts

Number of times to retry an operation after a time-out or exception for high availability. If set to -1, the pool tries every available server once until it succeeds or has tried all servers.

-1

server-group

Server group from which to select connections. If not specified, the global group of all connected servers is used.

empty

socket-buffer-size

Size of the socket buffer, in bytes, on each connection established.

32768

statistic-interval

Default frequency, in milliseconds, with which the client statistics are sent to the server. A value of -1 indicates that the statistics are not sent to the server.

-1

subscription-ack-interval

Number of milliseconds to wait before sending an acknowledgment to the server about events received from the subscriptions.

100

subscription-enabled

Whether to establish a server to client subscription.

False

subscription-message-tracking-timeout

Number of milliseconds for which messages sent from a server to a client are tracked. The tracking is done to minimize duplicate events.

90000

subscription-redundancy

Redundancy for servers that contain subscriptions established by the client. A value of -1 causes all available servers in the specified group to be made redundant.

0

thread-local-connections

Whether the connections must have affinity to the thread that last used them.

Note:

To set this to true, also set pr-single-hop-enabled to false. A true value in pr-single-hop-enabled automatically assigns a false value to thread-local-connections

False

update-locator-list-interval An integer number of milliseconds defining the interval between locator list updates. If the value is less than or equal to 0, the update will be disabled. 5000