Apache Geode Native C++ Reference 1.15.0
PoolFactory.hpp
Go to the documentation of this file.
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#pragma once
19
20#ifndef GEODE_POOLFACTORY_H_
21#define GEODE_POOLFACTORY_H_
22
23#include <chrono>
24
25#include "Pool.hpp"
26#include "internal/chrono/duration.hpp"
27#include "internal/geode_globals.hpp"
28
33namespace apache {
34namespace geode {
35namespace client {
36
37class CacheImpl;
38class PoolAttributes;
39class Pool;
40
68class APACHE_GEODE_EXPORT PoolFactory {
69 public:
75 static const std::chrono::milliseconds DEFAULT_FREE_CONNECTION_TIMEOUT;
76
83 static const std::chrono::milliseconds DEFAULT_LOAD_CONDITIONING_INTERVAL;
84
90 static const int DEFAULT_SOCKET_BUFFER_SIZE = 32768;
91
96 static const std::chrono::milliseconds DEFAULT_READ_TIMEOUT;
97
102 static const int DEFAULT_MIN_CONNECTIONS = 1;
103
108 static const int DEFAULT_MAX_CONNECTIONS = -1;
109
114 static const std::chrono::milliseconds DEFAULT_IDLE_TIMEOUT;
115
121 static const int DEFAULT_RETRY_ATTEMPTS = -1;
122
127 static const std::chrono::milliseconds DEFAULT_PING_INTERVAL;
128
133 static const std::chrono::milliseconds DEFAULT_UPDATE_LOCATOR_LIST_INTERVAL;
134
140 static const std::chrono::milliseconds DEFAULT_STATISTIC_INTERVAL;
141
146 static const bool DEFAULT_SUBSCRIPTION_ENABLED = false;
147
154 static const int DEFAULT_SUBSCRIPTION_REDUNDANCY = 0;
155
161 static const std::chrono::milliseconds
163
169 static const std::chrono::milliseconds DEFAULT_SUBSCRIPTION_ACK_INTERVAL;
170
175 static const std::string DEFAULT_SERVER_GROUP;
180 static constexpr bool DEFAULT_THREAD_LOCAL_CONN = false;
181
186 static constexpr bool DEFAULT_MULTIUSER_SECURE_MODE = false;
187
192 static constexpr bool DEFAULT_PR_SINGLE_HOP_ENABLED = true;
193
212 std::chrono::milliseconds connectionTimeout);
213
229 std::chrono::milliseconds loadConditioningInterval);
230
245
264 PoolFactory& setThreadLocalConnections(bool threadLocalConnections);
265
276 PoolFactory& setReadTimeout(std::chrono::milliseconds timeout);
277
291 PoolFactory& setMinConnections(int minConnections);
292
309 PoolFactory& setMaxConnections(int maxConnections);
310
323 PoolFactory& setIdleTimeout(std::chrono::milliseconds);
324
334 PoolFactory& setRetryAttempts(int retryAttempts);
335
354 PoolFactory& setPingInterval(std::chrono::milliseconds pingInterval);
355
365 std::chrono::milliseconds updateLocatorListInterval);
366
381 std::chrono::milliseconds statisticInterval);
382
391 PoolFactory& setServerGroup(std::string group);
392
410 PoolFactory& addLocator(const std::string& host, int port);
411
427 PoolFactory& addServer(const std::string& host, int port);
428
432 PoolFactory& setSniProxy(std::string hostname, uint16_t port);
433
443
458
473 std::chrono::milliseconds messageTrackingTimeout);
474
487 std::chrono::milliseconds ackInterval);
488
496 PoolFactory& setMultiuserAuthentication(bool multiuserAuthentication);
497
503
515 std::shared_ptr<Pool> create(std::string name);
516
538
539 ~PoolFactory() = default;
540
541 PoolFactory(const PoolFactory&) = default;
542
543 private:
544 explicit PoolFactory(const Cache& cache);
545 std::shared_ptr<PoolAttributes> m_attrs;
546 bool m_isSubscriptionRedundancy;
547 bool m_addedServerOrLocator;
548 const Cache& m_cache;
549
550 friend class Cache;
551 friend class PoolManager;
552 friend class PoolManagerImpl;
553 friend class CacheFactory;
554 friend class CacheXmlCreation;
555};
556
557} // namespace client
558} // namespace geode
559} // namespace apache
560
561#endif // GEODE_POOLFACTORY_H_
Caches are obtained from the create method on the CacheFactory#create class.
Definition: Cache.hpp:65
Top level class for configuring and using Geode on a client.This should be called once to create Cach...
Definition: CacheFactory.hpp:48
This interface provides for the configuration and creation of instances of Pool.
Definition: PoolFactory.hpp:68
PoolFactory & setLoadConditioningInterval(std::chrono::milliseconds loadConditioningInterval)
Sets the load conditioning interval for this pool.
PoolFactory & reset()
Resets the configuration of this factory to its defaults.
PoolFactory & setStatisticInterval(std::chrono::milliseconds statisticInterval)
The frequency with which the client statistics must be sent to the server.
PoolFactory & setSubscriptionMessageTrackingTimeout(std::chrono::milliseconds messageTrackingTimeout)
Sets the messageTrackingTimeout attribute which is the time-to-live period for subscription events th...
PoolFactory & setIdleTimeout(std::chrono::milliseconds)
Sets the amount of time a connection can be idle before expiring the connection.
static const std::chrono::milliseconds DEFAULT_UPDATE_LOCATOR_LIST_INTERVAL
The default frequency to update the locator list.
Definition: PoolFactory.hpp:133
PoolFactory & setSubscriptionAckInterval(std::chrono::milliseconds ackInterval)
Sets the is the interval to wait before sending acknowledgements to the bridge server for events rece...
PoolFactory & setSubscriptionEnabled(bool enabled)
If set to true then the created pool will have server-to-client subscriptions enabled.
static const std::string DEFAULT_SERVER_GROUP
The default server group.
Definition: PoolFactory.hpp:175
PoolFactory & setThreadLocalConnections(bool threadLocalConnections)
Sets the thread local connections policy for this pool.
PoolFactory & setRetryAttempts(int retryAttempts)
Set the number of times to retry a request after timeout/exception.
PoolFactory & addServer(const std::string &host, int port)
Adds a server, given its host and port, to this factory.
static const std::chrono::milliseconds DEFAULT_READ_TIMEOUT
The default amount of time to wait for a response from a server.
Definition: PoolFactory.hpp:96
PoolFactory & setSocketBufferSize(int bufferSize)
Sets the socket buffer size for each connection made in this pool.
PoolFactory & setSubscriptionRedundancy(int redundancy)
Sets the redundancy level for this pools server-to-client subscriptions.
PoolFactory & setReadTimeout(std::chrono::milliseconds timeout)
Sets the duration to wait for a response from a server before timing out the operation and trying ano...
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.
Definition: PoolFactory.hpp:162
PoolFactory & addLocator(const std::string &host, int port)
Adds a locator, given its host and port, to this factory.
static const std::chrono::milliseconds DEFAULT_IDLE_TIMEOUT
The default amount of time to wait for a connection to become idle.
Definition: PoolFactory.hpp:114
PoolFactory & setFreeConnectionTimeout(std::chrono::milliseconds connectionTimeout)
Sets the free connection timeout for this pool.
PoolFactory & setPingInterval(std::chrono::milliseconds pingInterval)
The frequency with which servers must be pinged to verify that they are still alive.
static const std::chrono::milliseconds DEFAULT_STATISTIC_INTERVAL
The default frequency that client statistics are sent to the server.
Definition: PoolFactory.hpp:140
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 ...
Definition: PoolFactory.hpp:83
PoolFactory & setMaxConnections(int maxConnections)
Sets the max number of client to server connections that the pool will create.
PoolFactory & setServerGroup(std::string group)
Configures the group which contains all the servers that this pool connects to.
PoolFactory & setUpdateLocatorListInterval(std::chrono::milliseconds updateLocatorListInterval)
The frequency with which client updates the locator list.
PoolFactory & setMultiuserAuthentication(bool multiuserAuthentication)
Sets whether Pool is in multi user secure mode.
PoolFactory & setPRSingleHopEnabled(bool enabled)
By default setPRSingleHopEnabled is true.
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 recei...
Definition: PoolFactory.hpp:169
static const std::chrono::milliseconds DEFAULT_PING_INTERVAL
The default frequency, to ping servers.
Definition: PoolFactory.hpp:127
PoolFactory & setMinConnections(int minConnections)
Sets the minimum number of connections to keep available at all times.
PoolFactory & setSniProxy(std::string hostname, uint16_t port)
Set proxy info for SNI connection.
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...
Definition: PoolFactory.hpp:75
std::shared_ptr< Pool > create(std::string name)
Creates a new Pool for connecting a client to a set of Geode Cache Servers.
Manages creation and access to connection pools for clients.
Definition: PoolManager.hpp:61

Apache Geode C++ Cache API Documentation