VMware Tanzu GemFire Native C++ Reference 10.2.7
|
This interface provides for the configuration and creation of instances of Pool
.
More...
#include <PoolFactory.hpp>
Public Member Functions | |
PoolFactory & | addLocator (const std::string &host, int port) |
Adds a locator, given its host and port, to this factory. More... | |
PoolFactory & | addServer (const std::string &host, int port) |
Adds a server, given its host and port, to this factory. More... | |
std::shared_ptr< Pool > | create (std::string name) |
Creates a new Pool for connecting a client to a set of Geode Cache Servers. More... | |
PoolFactory & | reset () |
Resets the configuration of this factory to its defaults. More... | |
PoolFactory & | setFreeConnectionTimeout (std::chrono::milliseconds connectionTimeout) |
Sets the free connection timeout for this pool. More... | |
PoolFactory & | setIdleTimeout (std::chrono::milliseconds) |
Sets the amount of time a connection can be idle before expiring the connection. More... | |
PoolFactory & | setLoadConditioningInterval (std::chrono::milliseconds loadConditioningInterval) |
Sets the load conditioning interval for this pool. More... | |
PoolFactory & | setMaxConnections (int maxConnections) |
Sets the max number of client to server connections that the pool will create. More... | |
PoolFactory & | setMinConnections (int minConnections) |
Sets the minimum number of connections to keep available at all times. More... | |
PoolFactory & | setMultiuserAuthentication (bool multiuserAuthentication) |
Sets whether Pool is in multi user secure mode. More... | |
PoolFactory & | setPingInterval (std::chrono::milliseconds pingInterval) |
The frequency with which servers must be pinged to verify that they are still alive. More... | |
PoolFactory & | setPRSingleHopEnabled (bool enabled) |
By default setPRSingleHopEnabled is true. More... | |
PoolFactory & | setReadTimeout (std::chrono::milliseconds timeout) |
Sets the duration to wait for a response from a server before timing out the operation and trying another server (if any are available). More... | |
PoolFactory & | setRetryAttempts (int retryAttempts) |
Set the number of times to retry a request after timeout/exception. More... | |
PoolFactory & | setServerGroup (std::string group) |
Configures the group which contains all the servers that this pool connects to. More... | |
PoolFactory & | setSniProxy (const std::string &hostname, const int port) |
Set proxy info for SNI connection. More... | |
PoolFactory & | setSocketBufferSize (int bufferSize) |
Sets the socket buffer size for each connection made in this pool. More... | |
PoolFactory & | setStatisticInterval (std::chrono::milliseconds statisticInterval) |
The frequency with which the client statistics must be sent to the server. More... | |
PoolFactory & | setSubscriptionAckInterval (std::chrono::milliseconds ackInterval) |
Sets the is the interval to wait before sending acknowledgements to the bridge server for events received from the server subscriptions. More... | |
PoolFactory & | setSubscriptionEnabled (bool enabled) |
If set to true then the created pool will have server-to-client subscriptions enabled. More... | |
PoolFactory & | setSubscriptionMessageTrackingTimeout (std::chrono::milliseconds messageTrackingTimeout) |
Sets the messageTrackingTimeout attribute which is the time-to-live period for subscription events the client has received from the server. More... | |
PoolFactory & | setSubscriptionRedundancy (int redundancy) |
Sets the redundancy level for this pools server-to-client subscriptions. More... | |
PoolFactory & | setThreadLocalConnections (bool threadLocalConnections) |
Sets the thread local connections policy for this pool. More... | |
PoolFactory & | setUpdateLocatorListInterval (std::chrono::milliseconds updateLocatorListInterval) |
The frequency with which client updates the locator list. More... | |
Static Public Attributes | |
static const std::chrono::milliseconds | DEFAULT_FREE_CONNECTION_TIMEOUT |
The default amount of time which we will wait for a free connection if max connections is set and all of the connections are in use. More... | |
static const std::chrono::milliseconds | DEFAULT_IDLE_TIMEOUT |
The default amount of time to wait for a connection to become idle. More... | |
static const std::chrono::milliseconds | DEFAULT_LOAD_CONDITIONING_INTERVAL |
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. More... | |
static const int | DEFAULT_MAX_CONNECTIONS = -1 |
The default maximum number of connections to be created. More... | |
static const int | DEFAULT_MIN_CONNECTIONS = 1 |
The default number of connections to be created initially. More... | |
static constexpr bool | DEFAULT_MULTIUSER_SECURE_MODE = false |
Whether client is in multi user secure mode. More... | |
static const std::chrono::milliseconds | DEFAULT_PING_INTERVAL |
The default frequency, to ping servers. More... | |
static constexpr bool | DEFAULT_PR_SINGLE_HOP_ENABLED = true |
The default value for whether to have single hop optimizations enabled. More... | |
static const std::chrono::milliseconds | DEFAULT_READ_TIMEOUT |
The default amount of time to wait for a response from a server. More... | |
static const int | DEFAULT_RETRY_ATTEMPTS = -1 |
The default number of times to retry an operation after a timeout or exception. More... | |
static const std::string | DEFAULT_SERVER_GROUP |
The default server group. More... | |
static const int | DEFAULT_SOCKET_BUFFER_SIZE = 32768 |
The default size in bytes of the socket buffer on each connection established. More... | |
static const std::chrono::milliseconds | DEFAULT_STATISTIC_INTERVAL |
The default frequency that client statistics are sent to the server. More... | |
static const std::chrono::milliseconds | DEFAULT_SUBSCRIPTION_ACK_INTERVAL |
The default amount of time to wait before sending an acknowledgement to the server about events received from the subscriptions. More... | |
static const bool | DEFAULT_SUBSCRIPTION_ENABLED = false |
The default value for whether to establish a server to client subscription. More... | |
static const std::chrono::milliseconds | DEFAULT_SUBSCRIPTION_MESSAGE_TRACKING_TIMEOUT |
The default amount of time that messages sent from a server to a client will be tracked. More... | |
static const int | DEFAULT_SUBSCRIPTION_REDUNDANCY = 0 |
The default redundancy for servers holding subscriptions established by this client. More... | |
static constexpr bool | DEFAULT_THREAD_LOCAL_CONN = false |
Whether thread local connection is enabled. More... | |
static const std::chrono::milliseconds | DEFAULT_UPDATE_LOCATOR_LIST_INTERVAL |
The default frequency to update the locator list. More... | |
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:
PoolFactory & apache::geode::client::PoolFactory::addLocator | ( | const std::string & | 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.
host | is the host name or ip address that the locator is listening on. |
port | is the port that the locator is listening on. |
this
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. |
PoolFactory & apache::geode::client::PoolFactory::addServer | ( | const std::string & | 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.
host | is the host name or ip address that the server is listening on. |
port | is the port that the server is listening on. |
this
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. |
std::shared_ptr< Pool > apache::geode::client::PoolFactory::create | ( | std::string | name | ) |
Creates a new Pool for connecting a client to a set of Geode Cache Servers.
using this factory's settings for attributes.
name | is the name of the pool, used when connecting regions to it |
IllegalStateException | if a pool with name already exists |
IllegalStateException | if a locator or server has not been added. |
PoolFactory & apache::geode::client::PoolFactory::reset | ( | ) |
Resets the configuration of this factory to its defaults.
this
PoolFactory & apache::geode::client::PoolFactory::setFreeConnectionTimeout | ( | std::chrono::milliseconds | 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.
connectionTimeout | is the connection timeout |
this
IllegalArgumentException | if connectionTimeout is less than or equal to std::chrono::milliseconds::zero() . |
PoolFactory & apache::geode::client::PoolFactory::setIdleTimeout | ( | std::chrono::milliseconds | ) |
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.
idleTimeout | is the duration that an idle connection should live no less than before expiring, actual time may be longer depending on clock resolution. A duration std::chrono::milliseconds::zero() indicates that connections should never expire. |
this
PoolFactory & apache::geode::client::PoolFactory::setLoadConditioningInterval | ( | std::chrono::milliseconds | 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 std::chrono::milliseconds::zero()
disables load conditioning.
loadConditioningInterval | is the connection lifetime |
this
IllegalArgumentException | if connectionLifetime is less than std::chrono::milliseconds::zero() . |
PoolFactory & apache::geode::client::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.
maxConnections | is the maximum number of connections in the pool. -1 indicates that there is no maximum number of connections |
this
IllegalArgumentException | if maxConnections is less than minConnections . |
PoolFactory & apache::geode::client::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.
minConnections | is the initial number of connections this pool will create. |
this
IllegalArgumentException | if minConnections is less than 0 . |
PoolFactory & apache::geode::client::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. Default value is false.
this
PoolFactory & apache::geode::client::PoolFactory::setPingInterval | ( | std::chrono::milliseconds | 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.
pingInterval | is the amount of time between pings. |
this
IllegalArgumentException | if pingInterval is less than 0 . |
PoolFactory & apache::geode::client::PoolFactory::setPRSingleHopEnabled | ( | bool | enabled | ) |
By default setPRSingleHopEnabled is true.
The client is aware of the locations of partitions on servers hosting partitioned regions. Using this information, the client routes 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 setting avoids extra hops only for the following cache operations:
Region#put(Object, Object)
Region#get(Object)
Region#destroy(Object)
PoolFactory#setMaxConnections(int)
is set to -1. enabled | is a boolean indicating whether PR Single Hop optimization should be enabled or not. |
this
PoolFactory & apache::geode::client::PoolFactory::setReadTimeout | ( | std::chrono::milliseconds | timeout | ) |
Sets the duration to wait for a response from a server before timing out the operation and trying another server (if any are available).
timeout | duration to wait for a response from a server |
this
IllegalArgumentException | if timeout is less than or equal to std::chrono::milliseconds::zero() . |
PoolFactory & apache::geode::client::PoolFactory::setRetryAttempts | ( | int | retryAttempts | ) |
Set the number of times to retry a request after timeout/exception.
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 |
this
IllegalArgumentException | if idleTimout is less than 0 . |
PoolFactory & apache::geode::client::PoolFactory::setServerGroup | ( | std::string | group | ) |
Configures the group which contains all the servers that this pool connects to.
group | is the server group that this pool will connect to. If the value is null or "" then the pool connects to all servers. |
this
PoolFactory & apache::geode::client::PoolFactory::setSniProxy | ( | const std::string & | hostname, |
const int | port | ||
) |
Set proxy info for SNI connection.
Used for connecting via SNI proxy.
PoolFactory & apache::geode::client::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.
bufferSize | is the size of the socket buffers used for reading and writing on each connection in this pool. |
this
IllegalArgumentException | if bufferSize is less than or equal to 0 . |
PoolFactory & apache::geode::client::PoolFactory::setStatisticInterval | ( | std::chrono::milliseconds | statisticInterval | ) |
The frequency with which the client statistics must be sent to the server.
Doing this allows GFMon
to monitor clients.
A value of std::chrono::milliseconds::zero()
disables the sending of client statistics to the server.
statisticInterval | is the amount of time between sends of client statistics to the server. |
this
IllegalArgumentException | if statisticInterval is less than std::chrono::milliseconds::zero() . |
PoolFactory & apache::geode::client::PoolFactory::setSubscriptionAckInterval | ( | std::chrono::milliseconds | ackInterval | ) |
Sets the is the interval to wait before sending acknowledgements to the bridge server for events received from the server subscriptions.
ackInterval | is the duration to wait before sending event acknowledgements. |
IllegalArgumentException | if ackInterval is less than or equal to 0 . |
this
PoolFactory & apache::geode::client::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.
this
PoolFactory & apache::geode::client::PoolFactory::setSubscriptionMessageTrackingTimeout | ( | std::chrono::milliseconds | messageTrackingTimeout | ) |
Sets the messageTrackingTimeout attribute which is the time-to-live period 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.
messageTrackingTimeout | is the duration to set the timeout to. |
this
IllegalArgumentException | if messageTrackingTimeout is less than or equal to 0 . |
PoolFactory & apache::geode::client::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.
redundancy | is the number of redundant servers for this client's subscriptions. |
this
IllegalArgumentException | if redundancyLevel is less than -1 . |
PoolFactory & apache::geode::client::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 among multiple threads keeping the number of connections down.
threadLocalConnections | if true then enable thread local connections. |
this
PoolFactory & apache::geode::client::PoolFactory::setUpdateLocatorListInterval | ( | std::chrono::milliseconds | updateLocatorListInterval | ) |
The frequency with which client updates the locator list.
To disable this set its value to std::chrono::milliseconds::zero().
updateLocatorListInterval | is the amount of time between checking locator list at locator. |
this
|
static |
The default amount of time which we will wait for a free connection if max connections is set and all of the connections are in use.
Current value: 10s
.
|
static |
The default amount of time to wait for a connection to become idle.
Current value: 5s
.
|
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: 5min
|
static |
The default maximum number of connections to be created.
Current value: -1
.
|
static |
The default number of connections to be created initially.
Current value: 1
.
|
staticconstexpr |
Whether client is in multi user secure mode.
Current value: "false"
.
|
static |
The default frequency, to ping servers.
Current value: 10s
.
|
staticconstexpr |
The default value for whether to have single hop optimizations enabled.
Current value: true
.
|
static |
The default amount of time to wait for a response from a server.
Current value: 10s
.
|
static |
The default number of times to retry an operation after a timeout or exception.
Current value: -1
.
|
static |
The default server group.
Current value: ""
.
|
static |
The default size in bytes of the socket buffer on each connection established.
Current value: 32768
.
|
static |
The default frequency that client statistics are sent to the server.
Current value: std::chrono::milliseconds::zero()
(disabled).
|
static |
The default amount of time to wait before sending an acknowledgement to the server about events received from the subscriptions.
Current value: 100ms
.
|
static |
The default value for whether to establish a server to client subscription.
Current value: false
.
|
static |
The default amount of time that messages sent from a server to a client will be tracked.
The tracking is done to minimize duplicate events.
Current value: 900s
.
|
static |
The default redundancy for servers holding subscriptions established by this client.
Current value: 0
.
|
staticconstexpr |
Whether thread local connection is enabled.
Current value: "false"
.
|
static |
The default frequency to update the locator list.
Current value: 5s
.