StreamBase C++ API  10.6.4.2
ClientSettings.hpp
1 //
2 // Copyright (c) 2004-2023 TIBCO Software Inc. All rights reserved.
3 //
4 #ifndef CLIENT_SETTINGS_H
5 #define CLIENT_SETTINGS_H
6 
7 #include "StreamBase.hpp"
8 
9 #include "NMSTL/ntime.hpp"
10 
11 #include <string>
12 
13 SB_NAMESPACE_BEGIN;
14 
15 ///
16 /// This class loads all the environment variables
17 /// used by the C++ client API. It uses a global
18 /// static object to do the work.
19 ///
21  public:
22 
23  ///
24  /// Loads all the client settings
25  ///
26  ClientSettings(bool haModeOn);
27 
28  ///
29  /// Set the timeout used when opening a binary connection
30  ///
31  /// @param tupleOpenTimeout new value (in milliseconds) for the tuple open timeout
32  ///
33  void setOpenTimeout(const NMSTL::Time &tupleOpenTimeout) {
34  _openTimeout = tupleOpenTimeout;
35  }
36 
37  ///
38  /// Get the timeout used when opening a connection
39  ///
40  /// @return Time (in milliseconds) that the tuple i/o will wait before
41  /// assuming the server is down.
42  ///
43  NMSTL::Time getOpenTimeout() {
44  return _openTimeout;
45  }
46 
47  ///
48  /// Get the timeout used when writing to a connection
49  ///
50  /// @return Time (in milliseconds) that the tuple i/o will wait before
51  /// assuming the server is down.
52  ///
53  NMSTL::Time getWriteTimeout() {
54  return _writeTimeout;
55  }
56 
57  ///
58  /// Set the timeout used when writing to a connection
59  ///
60  /// @param tupleWriteTimeout new value (in milliseconds) for the tuple write timeout
61  ///
62  void setWriteTimeout(const NMSTL::Time &tupleWriteTimeout) {
63  _writeTimeout = tupleWriteTimeout;
64  }
65 
66  ///
67  /// Get the timeout used when making an xmlrpc request
68  ///
69  /// @return Time (in milliseconds) that the tuple i/o will wait before
70  /// assuming the server is down.
71  ///
72  NMSTL::Time getXmlRpcTimeout() {
73  return _xmlrpcTimeout;
74  }
75 
76  ///
77  /// Set the timeout used when making an xmlrpc request
78  ///
79  /// @param xmlrpcTimeout new value (in milliseconds) for the xmlrpc request timeout
80  ///
81  void setXmlRpcTimeout(const NMSTL::Time &xmlrpcTimeout) {
82  _xmlrpcTimeout = xmlrpcTimeout;
83  }
84 
85  ///
86  /// Get the amount of time to sleep between reconnect requests
87  ///
88  /// @return Time (in milliseconds) to sleep between reconnect
89  /// timeouts in the event that the TupleConnection is disconnected
90  /// from its server.
91  ///
92  NMSTL::Time getReconnectSleep() {
93  return _reconnectSleep;
94  }
95 
96  ///
97  /// Set the amount of time to sleep between reconnect requests
98  ///
99  /// @param reconnectSleep new value (in milliseconds) for reconnect sleep
100  ///
101  void setReconnectSleep(const NMSTL::Time &reconnectSleep) {
102  _reconnectSleep = reconnectSleep;
103  }
104 
105  ///
106  /// Get the heart beat timeout
107  ///
108  /// @return Time (in milliseconds) the tuple quiesent timeout
109  ///
110  NMSTL::Time getHeartbeatTimeout() {
111  return _heartbeatTimeout;
112  }
113 
114  ///
115  /// Set the heart beat timeout
116  ///
117  /// @param heartbeatTimeout new value (in milliseconds) for the heartbeat timeout
118  ///
119  void setHeartbeatTimeout(const NMSTL::Time &heartbeatTimeout) {
120  _heartbeatTimeout = heartbeatTimeout;
121  }
122 
123  ///
124  /// Get the timeout used when sending a request to the server to get the clients
125  /// exit status.
126  ///
127  /// @return Time (in milliseconds) of the time to wait for the clients exit status
128  ///
129  NMSTL::Time getExitStatusTimeout() {
130  return _exitStatusTimeout;
131  }
132 
133  ///
134  /// Set the timeout used when sending a request to the server to get the clients
135  /// exit status.
136  ///
137  /// @param exitStatusTimeout new value (in milliseconds) for the exit status timeout
138  ///
139  void setExitStatusTimeout(const NMSTL::Time &exitStatusTimeout) {
140  _exitStatusTimeout = exitStatusTimeout;
141  }
142 
143  ///
144  /// Get the maximum size of the input tuple in binary mode
145  ///
146  /// @return max size of the input tuple (in bytes)
147  ///
148  unsigned int getMaxInputPacketSize() {
149  return _maxInputPacketSize;
150  }
151 
152  ///
153  /// Set the maximum size of the input tuple in binary mode
154  ///
155  /// @param maxInputPacketSize new value (in milliseconds) for the maxInputPacket size
156  ///
157  void setMaxInputPacketSize(unsigned int maxInputPacketSize) {
158  _maxInputPacketSize = maxInputPacketSize;
159  }
160 
161  ///
162  /// Should we check the client exit status
163  ///
164  /// @return if we should check the client exit status
166  return _checkClientExitStatus;
167  }
168 
169  ///
170  /// Set the maximum number of tuples to be kept in the Dequeuer Thread's internal queue
171  /// before applying back-pressure to the server.
172  ///
173  /// @param maxDequeuerQueueSize maximum number of tuples to allow to wait in the
174  /// Dequeuer Thread's internal queue before blocking dequeues from the server.
175  ///
176  void setMaxDequeuerQueueSize(unsigned int maxDequeuerQueueSize) {
177  _maxDequeuerQueueSize = maxDequeuerQueueSize;
178  }
179 
180 
181  ///
182  /// Enable/disable TCP_NO_DELAY
183  ///
184  /// @param tcpNoDelay enable/disable TCP_NO_DELAY
185  ///
186  void setTcpNoDelay(bool tcpNoDelay) {
187  _tcpNoDelay = tcpNoDelay;
188  }
189 
190  ///
191  /// Is TCP_NODELAY set
192  ///
193  /// @return if tcpNoDealy set
194  bool tcpNoDelay() {
195  return _tcpNoDelay;
196  }
197 
198  unsigned int getMaxTupleBufferCacheSize() {
199  return _maxTupleBufferCacheSize;
200  }
201 
202  unsigned int getMaxDequeuerQueueSize() {
203  return _maxDequeuerQueueSize;
204  }
205 
206  private:
207  NMSTL::Time _reconnectSleep;
208  NMSTL::Time _openTimeout;
209  NMSTL::Time _writeTimeout;
210  NMSTL::Time _xmlrpcTimeout;
211  NMSTL::Time _heartbeatTimeout;
212  NMSTL::Time _exitStatusTimeout;
213  unsigned int _maxInputPacketSize;
214  bool _checkClientExitStatus;
215  bool _tcpNoDelay;
216  unsigned int _maxTupleBufferCacheSize;
217  unsigned int _maxDequeuerQueueSize;
218 };
219 
220 SB_NAMESPACE_END;
221 #endif