gemfire::PoolFactory Class Reference

Inherits gemfire::SharedBase.


Detailed Description

This interface provides for the configuration and creation of instances of Pool.

Every pool needs to have at least one locator or server added to it. Locators should be added unless direct connections to bridge servers are desired.

The setter methods are used to specify non-default values for the other pool properties.

Once it is configured create will produce an instance.

The factory can be restored to its default configuration by calling reset.

Instances of this interface can be created by calling Cache#getPoolFactory.

If a subscription is going to be made using a pool then subscriptions must be enabled on the pool. Subscriptions are made using these APIs:


Public Member Functions

void addLocator (const char *host, int port)
 Adds a locator, given its host and port, to this factory.
void addServer (const char *host, int port)
 Adds a server, given its host and port, to this factory.
PoolPtr create (const char *name)
 Creates a new Pool for connecting a client to a set of GemFire Cache Servers.
void preserveSB () const
 Atomically increment reference count.
int32_t refCount ()
 
Returns:
the reference count

void releaseSB () const
 Atomically decrement reference count, the SharedBase object is automatically deleted when its reference count goes to zero.
void reset ()
 Resets the configuration of this factory to its defaults.
void setFreeConnectionTimeout (int connectionTimeout)
 Sets the free connection timeout for this pool.
void setIdleTimeout (long idleTimeout)
 Sets the amount of time a connection can be idle before expiring the connection.
void setLoadConditioningInterval (int loadConditioningInterval)
 Sets the load conditioning interval for this pool.
void setMaxConnections (int maxConnections)
 Sets the max number of client to server connections that the pool will create.
void setMinConnections (int minConnections)
 Sets the minimum number of connections to keep available at all times.
void setMultiuserAuthentication (bool multiuserAuthentication)
 Sets whether Pool is in multi user secure mode.
void setPingInterval (long pingInterval)
 The frequency with which servers must be pinged to verify that they are still alive.
void setPRSingleHopEnabled (bool enabled)
 By default setPRSingleHopEnabled is true
The client is aware of location of partitions on servers hosting Regions.
void setReadTimeout (int timeout)
 Sets the number of milliseconds to wait for a response from a server before timing out the operation and trying another server (if any are available).
void setRetryAttempts (int retryAttempts)
 Set the number of times to retry a request after timeout/exception.
void setServerGroup (const char *group)
 Configures the group which contains all the servers that this pool connects to.
void setSocketBufferSize (int bufferSize)
 Sets the socket buffer size for each connection made in this pool.
void setStatisticInterval (int statisticInterval)
 The frequency with which the client statistics must be sent to the server.
void setSubscriptionAckInterval (int ackInterval)
 Sets the is the interval in milliseconds to wait before sending acknowledgements to the bridge server for events received from the server subscriptions.
void setSubscriptionEnabled (bool enabled)
 If set to true then the created pool will have server-to-client subscriptions enabled.
void setSubscriptionMessageTrackingTimeout (int messageTrackingTimeout)
 Sets the messageTrackingTimeout attribute which is the time-to-live period, in milliseconds, for subscription events the client has received from the server.
void setSubscriptionRedundancy (int redundancy)
 Sets the redundancy level for this pools server-to-client subscriptions.
void setThreadLocalConnections (bool threadLocalConnections)
 Sets the thread local connections policy for this pool.

Static Public Attributes

static const int DEFAULT_FREE_CONNECTION_TIMEOUT = 10000
 The default amount of time, in milliseconds, which we will wait for a free connection if max connections is set and all of the connections are in use.
static const long DEFAULT_IDLE_TIMEOUT = 5000
 The default amount of time in milliseconds, to wait for a connection to become idle.
static const int DEFAULT_LOAD_CONDITIONING_INTERVAL = 1000*60*5
 The default interval in which the pool will check to see if a connection to a given server should be moved to a different server to improve the load balance.
static const int DEFAULT_MAX_CONNECTIONS = -1
 The default maximum number of connections to be created.
static const int DEFAULT_MIN_CONNECTIONS = 1
 The default number of connections to be created initially.
static const bool DEFAULT_MULTIUSER_SECURE_MODE = false
 Whether client is in multi user secure mode.
static const long DEFAULT_PING_INTERVAL = 10000
 The default frequency, in milliseconds, to ping servers.
static const bool DEFAULT_PR_SINGLE_HOP_ENABLED = true
 The default value for whether to have single hop optimisations enabled.
static const int DEFAULT_READ_TIMEOUT = 10000
 The default amount of time, in milliseconds, to wait for a response from a server.
static const int DEFAULT_RETRY_ATTEMPTS = -1
 The default number of times to retry an operation after a timeout or exception.
static const char * DEFAULT_SERVER_GROUP
 The default server group.
static const int DEFAULT_SOCKET_BUFFER_SIZE = 32768
 The default size in bytes of the socket buffer on each connection established.
static const int DEFAULT_STATISTIC_INTERVAL = -1
 The default frequency, in milliseconds, that client statistics are sent to the server.
static const int DEFAULT_SUBSCRIPTION_ACK_INTERVAL = 100
 The default amount of time, in milliseconds, to wait before sending an acknowledgement to the server about events received from the subscriptions.
static const bool DEFAULT_SUBSCRIPTION_ENABLED = false
 The default value for whether connections should have affinity to the thread that last used them.
static const int DEFAULT_SUBSCRIPTION_MESSAGE_TRACKING_TIMEOUT = 900000
 The default amount of time, in milliseconds, that messages sent from a server to a client will be tracked.
static const int DEFAULT_SUBSCRIPTION_REDUNDANCY = 0
 The default redundancy for servers holding subscriptions established by this client.
static const bool DEFAULT_THREAD_LOCAL_CONN = false
 Whether thread local connection is enabled.

Member Function Documentation

void gemfire::PoolFactory::addLocator ( const char *  host,
int  port 
)

Adds a locator, given its host and port, to this factory.

The locator must be a server locator and will be used to discover other running bridge servers and locators.

Parameters:
host is the host name or ip address that the locator is listening on.
port is the port that the locator is listening on.
Returns:
a reference to this
Exceptions:
IllegalArgumentException if the host is an unknown host according to java.net.InetAddress#getByName or if the port is outside the valid range of [1..65535] inclusive.
IllegalStateException if the locator has already been added to this factory.

void gemfire::PoolFactory::addServer ( const char *  host,
int  port 
)

Adds a server, given its host and port, to this factory.

The server must be a bridge server and this client will directly connect to the server without consulting a server locator.

Parameters:
host is the host name or ip address that the server is listening on.
port is the port that the server is listening on.
Returns:
a reference to this
Exceptions:
IllegalArgumentException if the host is an unknown host according to java.net.InetAddress#getByName or if the port is outside the valid range of [1..65535] inclusive.
IllegalStateException if the server has already been added to this factory.

PoolPtr gemfire::PoolFactory::create ( const char *  name  ) 

Creates a new Pool for connecting a client to a set of GemFire Cache Servers.

using this factory's settings for attributes.

Parameters:
name is the name of the pool, used when connecting regions to it
Exceptions:
IllegalStateException if a pool with name already exists
IllegalStateException if a locator or server has not been added.
Returns:
the newly created pool.

void gemfire::SharedBase::preserveSB (  )  const [inherited]

Atomically increment reference count.

int32_t gemfire::SharedBase::refCount (  )  [inline, inherited]

Returns:
the reference count

void gemfire::SharedBase::releaseSB (  )  const [inherited]

Atomically decrement reference count, the SharedBase object is automatically deleted when its reference count goes to zero.

void gemfire::PoolFactory::reset (  ) 

Resets the configuration of this factory to its defaults.

Returns:
a reference to this

void gemfire::PoolFactory::setFreeConnectionTimeout ( int  connectionTimeout  ) 

Sets the free connection timeout for this pool.

If the pool has a max connections setting, operations will block if all of the connections are in use. The free connection timeout specifies how long those operations will block waiting for a free connection before receiving an AllConnectionsInUseException. If max connections is not set this setting has no effect.

See also:
setMaxConnections(int)
Parameters:
connectionTimeout is the connection timeout in milliseconds
Returns:
a reference to this
Exceptions:
IllegalArgumentException if connectionTimeout is less than or equal to 0.

void gemfire::PoolFactory::setIdleTimeout ( long  idleTimeout  ) 

Sets the amount of time a connection can be idle before expiring the connection.

If the pool size is greater than the minimum specified by PoolFactory#setMinConnections(int), connections which have been idle for longer than the idleTimeout will be closed.

Parameters:
idleTimeout is the amount of time in milliseconds that an idle connection should live before expiring. -1 indicates that connections should never expire.
Returns:
a reference to this
Exceptions:
IllegalArgumentException if idleTimout is less than 0.

void gemfire::PoolFactory::setLoadConditioningInterval ( int  loadConditioningInterval  ) 

Sets the load conditioning interval for this pool.

This interval controls how frequently the pool will check to see if a connection to a given server should be moved to a different server to improve the load balance.

A value of -1 disables load conditioning

Parameters:
loadConditioningInterval is the connection lifetime in milliseconds
Returns:
a reference to this
Exceptions:
IllegalArgumentException if connectionLifetime is less than -1.

void gemfire::PoolFactory::setMaxConnections ( int  maxConnections  ) 

Sets the max number of client to server connections that the pool will create.

If all of the connections are in use, an operation requiring a client to server connection will block until a connection is available.

See also:
setFreeConnectionTimeout(int)
Parameters:
maxConnections is the maximum number of connections in the pool. -1 indicates that there is no maximum number of connections
Returns:
a reference to this
Exceptions:
IllegalArgumentException if maxConnections is less than minConnections.

void gemfire::PoolFactory::setMinConnections ( int  minConnections  ) 

Sets the minimum number of connections to keep available at all times.

When the pool is created, it will create this many connections. If 0 then connections will not be made until an actual operation is done that requires client-to-server communication.

Parameters:
minConnections is the initial number of connections this pool will create.
Returns:
a reference to this
Exceptions:
IllegalArgumentException if minConnections is less than 0.

void gemfire::PoolFactory::setMultiuserAuthentication ( bool  multiuserAuthentication  ) 

Sets whether Pool is in multi user secure mode.

If its in multiuser mode then app needs to get RegionService instance of Cache. Deafult value is false.

void gemfire::PoolFactory::setPingInterval ( long  pingInterval  ) 

The frequency with which servers must be pinged to verify that they are still alive.

Each server will be sent a ping every pingInterval if there has not been any other communication with the server.

These pings are used by the server to monitor the health of the client. Make sure that the pingInterval is less than the maximum time between pings allowed by the bridge server.

Parameters:
pingInterval is the amount of time in milliseconds between pings.
Returns:
a reference to this
Exceptions:
IllegalArgumentException if pingInterval is less than 0.
See also:
CacheServer::setMaximumTimeBetweenPings(int)

void gemfire::PoolFactory::setPRSingleHopEnabled ( bool  enabled  ) 

By default setPRSingleHopEnabled is true
The client is aware of location of partitions on servers hosting Regions.

Using this information, the client routes the client cache operations directly to the server which is hosting the required partition for the cache operation. If setPRSingleHopEnabled is false the client can do an extra hop on servers to go to the required partition for that cache operation. The setPRSingleHopEnabled avoids extra hops only for following cache operations:
1. Region#put(Object, Object)
2. Region#get(Object)
3. Region#destroy(Object)
If true, works best when PoolFactory#setMaxConnections(int) is set to -1.

Parameters:
name is boolean whether PR Single Hop optimization is enabled or not.
Returns:
a reference to this

void gemfire::PoolFactory::setReadTimeout ( int  timeout  ) 

Sets the number of milliseconds to wait for a response from a server before timing out the operation and trying another server (if any are available).

Parameters:
timeout is the number of milliseconds to wait for a response from a server
Returns:
a reference to this
Exceptions:
IllegalArgumentException if timeout is less than or equal to 0.

void gemfire::PoolFactory::setRetryAttempts ( int  retryAttempts  ) 

Set the number of times to retry a request after timeout/exception.

Parameters:
retryAttempts is the number of times to retry a request after timeout/exception. -1 indicates that a request should be tried against every available server before failing
Returns:
a reference to this
Exceptions:
IllegalArgumentException if idleTimout is less than 0.

void gemfire::PoolFactory::setServerGroup ( const char *  group  ) 

Configures the group which contains all the servers that this pool connects to.

Parameters:
group is the server group that this pool will connect to. If the value is null or "" then the pool connects to all servers.
Returns:
a reference to this

void gemfire::PoolFactory::setSocketBufferSize ( int  bufferSize  ) 

Sets the socket buffer size for each connection made in this pool.

Large messages can be received and sent faster when this buffer is larger. Larger buffers also optimize the rate at which servers can send events for client subscriptions.

Parameters:
bufferSize is the size of the socket buffers used for reading and writing on each connection in this pool.
Returns:
a reference to this
Exceptions:
IllegalArgumentException if bufferSize is less than or equal to 0.

void gemfire::PoolFactory::setStatisticInterval ( int  statisticInterval  ) 

The frequency with which the client statistics must be sent to the server.

Doing this allows GFMon to monitor clients.

A value of -1 disables the sending of client statistics to the server.

Parameters:
statisticInterval is the amount of time in milliseconds between sends of client statistics to the server.
Returns:
a reference to this
Exceptions:
IllegalArgumentException if statisticInterval is less than -1.

void gemfire::PoolFactory::setSubscriptionAckInterval ( int  ackInterval  ) 

Sets the is the interval in milliseconds to wait before sending acknowledgements to the bridge server for events received from the server subscriptions.

Parameters:
ackInterval is the number of milliseconds to wait before sending event acknowledgements.
Returns:
a reference to this
Exceptions:
IllegalArgumentException if ackInterval is less than or equal to 0.

void gemfire::PoolFactory::setSubscriptionEnabled ( bool  enabled  ) 

If set to true then the created pool will have server-to-client subscriptions enabled.

If set to false then all Subscription* attributes are ignored at the time of creation.

Returns:
a reference to this

void gemfire::PoolFactory::setSubscriptionMessageTrackingTimeout ( int  messageTrackingTimeout  ) 

Sets the messageTrackingTimeout attribute which is the time-to-live period, in milliseconds, for subscription events the client has received from the server.

It is used to minimize duplicate events. Entries that have not been modified for this amount of time are expired from the list.

Parameters:
messageTrackingTimeout is the number of milliseconds to set the timeout to.
Returns:
a reference to this
Exceptions:
IllegalArgumentException if messageTrackingTimeout is less than or equal to 0.

void gemfire::PoolFactory::setSubscriptionRedundancy ( int  redundancy  ) 

Sets the redundancy level for this pools server-to-client subscriptions.

If 0 then no redundant copies are kept on the servers. Otherwise an effort is made to maintain the requested number of copies of the server-to-client subscriptions. At most, one copy per server is made up to the requested level.

Parameters:
redundancy is the number of redundant servers for this client's subscriptions.
Returns:
a reference to this
Exceptions:
IllegalArgumentException if redundancyLevel is less than -1.

void gemfire::PoolFactory::setThreadLocalConnections ( bool  threadLocalConnections  ) 

Sets the thread local connections policy for this pool.

If true then any time a thread goes to use a connection from this pool it will check a thread local cache and see if it already has a connection in it. If so it will use it. If not it will get one from this pool and cache it in the thread local. This gets rid of thread contention for the connections but increases the number of connections the servers see.

If false then connections are returned to the pool as soon as the operation being done with the connection completes. This allows connections to be shared amonst multiple threads keeping the number of connections down.

Parameters:
threadLocalConnections if true then enable thread local connections.
Returns:
a reference to this


Field Documentation

const int gemfire::PoolFactory::DEFAULT_FREE_CONNECTION_TIMEOUT = 10000 [static]

The default amount of time, in milliseconds, which we will wait for a free connection if max connections is set and all of the connections are in use.

Current value: 10000.

const long gemfire::PoolFactory::DEFAULT_IDLE_TIMEOUT = 5000 [static]

The default amount of time in milliseconds, to wait for a connection to become idle.

Current value: 5000.

const int gemfire::PoolFactory::DEFAULT_LOAD_CONDITIONING_INTERVAL = 1000*60*5 [static]

The default interval in which the pool will check to see if a connection to a given server should be moved to a different server to improve the load balance.

Current value: 300,000 (which is 5 minutes).

const int gemfire::PoolFactory::DEFAULT_MAX_CONNECTIONS = -1 [static]

The default maximum number of connections to be created.

Current value: -1.

const int gemfire::PoolFactory::DEFAULT_MIN_CONNECTIONS = 1 [static]

The default number of connections to be created initially.

Current value: 1.

const bool gemfire::PoolFactory::DEFAULT_MULTIUSER_SECURE_MODE = false [static]

Whether client is in multi user secure mode.

Current value: "false".

const long gemfire::PoolFactory::DEFAULT_PING_INTERVAL = 10000 [static]

The default frequency, in milliseconds, to ping servers.

Current value: 10000.

const bool gemfire::PoolFactory::DEFAULT_PR_SINGLE_HOP_ENABLED = true [static]

The default value for whether to have single hop optimisations enabled.

Current value: true.

const int gemfire::PoolFactory::DEFAULT_READ_TIMEOUT = 10000 [static]

The default amount of time, in milliseconds, to wait for a response from a server.

Current value: 10000.

const int gemfire::PoolFactory::DEFAULT_RETRY_ATTEMPTS = -1 [static]

The default number of times to retry an operation after a timeout or exception.

Current value: -1.

const char* gemfire::PoolFactory::DEFAULT_SERVER_GROUP [static]

The default server group.

Current value: "".

const int gemfire::PoolFactory::DEFAULT_SOCKET_BUFFER_SIZE = 32768 [static]

The default size in bytes of the socket buffer on each connection established.

Current value: 32768.

const int gemfire::PoolFactory::DEFAULT_STATISTIC_INTERVAL = -1 [static]

The default frequency, in milliseconds, that client statistics are sent to the server.

Current value: -1.

const int gemfire::PoolFactory::DEFAULT_SUBSCRIPTION_ACK_INTERVAL = 100 [static]

The default amount of time, in milliseconds, to wait before sending an acknowledgement to the server about events received from the subscriptions.

Current value: 100.

const bool gemfire::PoolFactory::DEFAULT_SUBSCRIPTION_ENABLED = false [static]

The default value for whether connections should have affinity to the thread that last used them.

Current value: false. The default value for whether to establish a server to client subscription.

Current value: false.

const int gemfire::PoolFactory::DEFAULT_SUBSCRIPTION_MESSAGE_TRACKING_TIMEOUT = 900000 [static]

The default amount of time, in milliseconds, that messages sent from a server to a client will be tracked.

The tracking is done to minimize duplicate events.

Current value: 900000.

const int gemfire::PoolFactory::DEFAULT_SUBSCRIPTION_REDUNDANCY = 0 [static]

The default redundancy for servers holding subscriptions established by this client.

Current value: 0.

const bool gemfire::PoolFactory::DEFAULT_THREAD_LOCAL_CONN = false [static]

Whether thread local connection is enabled.

Current value: "false".


GemFire C++ Cache API Documentation