Hazelcast C++ Client
 All Classes Functions Variables Enumerations Pages
ClientConfig.h
1 /*
2  * Copyright (c) 2008-2015, Hazelcast, Inc. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #ifndef HAZELCAST_CLIENT_CONFIG
17 #define HAZELCAST_CLIENT_CONFIG
18 
19 #include "hazelcast/client/Address.h"
20 #include "hazelcast/client/GroupConfig.h"
21 #include "hazelcast/client/SerializationConfig.h"
22 #include "hazelcast/client/Credentials.h"
23 #include "hazelcast/client/SocketInterceptor.h"
24 #include "hazelcast/client/LoadBalancer.h"
25 #include "hazelcast/client/impl/RoundRobinLB.h"
26 #include "hazelcast/util/ILogger.h"
27 #include "hazelcast/client/config/ReliableTopicConfig.h"
28 
29 #include <vector>
30 #include <set>
31 #include <memory>
32 
33 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
34 #pragma warning(push)
35 #pragma warning(disable: 4251) //for dll export
36 #endif
37 
38 namespace hazelcast {
39  namespace client {
40  class MembershipListener;
41 
42  class InitialMembershipListener;
43 
44  class LifecycleListener;
45 
49  class HAZELCAST_API ClientConfig {
50  public:
51 
61  ClientConfig();
62 
70  ClientConfig& addAddress(const Address& address);
71 
79  ClientConfig& addAddresses(const std::vector<Address>& addresses);
80 
87  std::set<Address, addressComparator>& getAddresses();
88 
96  ClientConfig& setGroupConfig(GroupConfig& groupConfig);
97 
102  GroupConfig& getGroupConfig();
103 
109  ClientConfig& setCredentials(Credentials *credentials);
110 
114  const Credentials *getCredentials();
115 
124  ClientConfig& setConnectionAttemptLimit(int connectionAttemptLimit);
125 
133  int getConnectionAttemptLimit() const;
134 
141  ClientConfig& setConnectionTimeout(int connectionTimeoutInMillis);
142 
148  int getConnectionTimeout() const;
149 
156  ClientConfig& setAttemptPeriod(int attemptPeriodInMillis);
157 
163  int getAttemptPeriod() const;
164 
176  ClientConfig& setRedoOperation(bool redoOperation);
177 
183  bool isRedoOperation() const;
184 
189  bool isSmart() const;
190 
201  ClientConfig& setSmart(bool smart);
202 
208  ClientConfig& setSocketInterceptor(SocketInterceptor *socketInterceptor);
209 
213  SocketInterceptor* getSocketInterceptor();
214 
225  ClientConfig& addListener(LifecycleListener *listener);
226 
231  const std::set<LifecycleListener *>& getLifecycleListeners() const;
232 
243  ClientConfig& addListener(MembershipListener *listener);
244 
250  const std::set<MembershipListener *>& getMembershipListeners() const;
251 
258  ClientConfig& addListener(InitialMembershipListener *listener);
259 
265  const std::set<InitialMembershipListener *>& getInitialMembershipListeners() const;
266 
272  LoadBalancer *const getLoadBalancer();
273 
282  ClientConfig& setLoadBalancer(LoadBalancer *loadBalancer);
283 
293  ClientConfig& setLogLevel(LogLevel loggerLevel);
294 
295 
300  SerializationConfig const& getSerializationConfig() const;
301 
311  ClientConfig& setSerializationConfig(SerializationConfig const& serializationConfig);
312 
318  std::map<std::string, std::string>& getProperties();
319 
329  ClientConfig& setProperty(const std::string& name, const std::string& value);
330 
337  ClientConfig &addReliableTopicConfig(const config::ReliableTopicConfig &reliableTopicConfig);
338 
345  const config::ReliableTopicConfig *getReliableTopicConfig(const std::string &name);
346  private:
347 
348  GroupConfig groupConfig;
349 
350  SerializationConfig serializationConfig;
351 
352  std::set<Address, addressComparator> addressList;
353 
354  LoadBalancer *loadBalancer;
355 
356  std::auto_ptr<impl::RoundRobinLB> defaultLoadBalancer;
357 
358  std::set<MembershipListener *> membershipListeners;
359 
360  std::set<InitialMembershipListener *> initialMembershipListeners;
361 
362  std::set<LifecycleListener *> lifecycleListeners;
363 
364  std::map<std::string, std::string> properties;
365 
366  bool smart;
367 
368  bool redoOperation;
369 
370  int connectionTimeout;
371 
372  int connectionAttemptLimit;
373 
374  int attemptPeriod;
375 
376  SocketInterceptor *socketInterceptor;
377 
378  Credentials *credentials;
379 
380  std::auto_ptr<Credentials> defaultCredentials;
381 
382  std::map<std::string, config::ReliableTopicConfig> reliableTopicConfigMap;
383  };
384 
385  }
386 }
387 
388 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
389 #pragma warning(pop)
390 #endif
391 
392 #endif /* HAZELCAST_CLIENT_CONFIG */
Credentials is a container object for endpoint (Members and Clients) security attributes.
Definition: Credentials.h:35
Base class for socketInterceptor classes to inherit from.
Definition: SocketInterceptor.h:37
Contains the configuration for Hazelcast groups.
Definition: GroupConfig.h:36
Cluster membership listener.
Definition: MembershipListener.h:51
IP Address.
Definition: Address.h:36
SerializationConfig is used to.
Definition: SerializationConfig.h:44
Listener object for listening lifecycle events of hazelcast instance.
Definition: LifecycleListener.h:44
The InitializingMembershipListener is a MembershipListener that will first receives a InitialMembersh...
Definition: InitialMembershipListener.h:50
LoadBalancer allows you to send operations to one of a number of endpoints(Members).
Definition: LoadBalancer.h:40
HazelcastClient configuration class.
Definition: ClientConfig.h:49
Definition: ReliableTopicConfig.h:30