Hazelcast C++ Client
MembershipListener.h
1 /*
2  * Copyright (c) 2008-2019, 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 //
17 // MembershipListener.h
18 // cpp-client
19 //
20 // Created by sancar koyunlu on 5/30/13.
21 // Copyright (c) 2013 hazelcast. All rights reserved.
22 //
23 
24 #ifndef HAZELCAST_MEMBERSHIP_LISTENER
25 #define HAZELCAST_MEMBERSHIP_LISTENER
26 
27 #include <string>
28 
29 #include "hazelcast/util/HazelcastDll.h"
30 
31 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
32 #pragma warning(push)
33 #pragma warning(disable: 4251) //for dll export
34 #endif
35 
36 namespace hazelcast {
37  namespace client {
38 
39  class MembershipEvent;
40 
41  class MemberAttributeEvent;
42 
43  namespace spi {
44  namespace impl {
45  class ClientClusterServiceImpl;
46  }
47  }
48 
64  class HAZELCAST_API MembershipListener {
65  friend class Cluster;
66  friend class MembershipListenerDelegator;
68  friend class spi::impl::ClientClusterServiceImpl;
69  public:
70  virtual ~MembershipListener();
71 
77  virtual void memberAdded(const MembershipEvent &membershipEvent) = 0;
78 
84  virtual void memberRemoved(const MembershipEvent &membershipEvent) = 0;
85 
91  virtual void memberAttributeChanged(const MemberAttributeEvent &memberAttributeEvent) = 0;
92 
93  private:
94  std::string registrationId;
95 
96  virtual bool shouldRequestInitialMembers() const;
97 
98  virtual const std::string &getRegistrationId() const;
99 
100  virtual void setRegistrationId(const std::string &registrationId);
101  };
102 
104  public:
106 
107  virtual void memberAdded(const MembershipEvent &membershipEvent);
108 
109  virtual void memberRemoved(const MembershipEvent &membershipEvent);
110 
111  virtual void memberAttributeChanged(const MemberAttributeEvent &memberAttributeEvent);
112 
113  protected:
114  MembershipListener *listener;
115 
116  virtual bool shouldRequestInitialMembers() const;
117 
118  virtual void setRegistrationId(const std::string &registrationId);
119 
120  virtual const std::string &getRegistrationId() const;
121  };
122  }
123 }
124 
125 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
126 #pragma warning(pop)
127 #endif
128 
129 #endif /* HAZELCAST_MEMBERSHIP_LISTENER */
130 
Definition: MemberAttributeEvent.h:41
Membership event fired when a new member is added to the cluster and/or when a member leaves the clus...
Definition: MembershipEvent.h:42
virtual void memberAttributeChanged(const MemberAttributeEvent &memberAttributeEvent)
Invoked when an attribute of a member was changed.
Definition: MembershipListener.cpp:50
Cluster membership listener.
Definition: MembershipListener.h:64
Definition: InitialMembershipListener.h:74
Hazelcast cluster interface.
Definition: Cluster.h:40
virtual void memberRemoved(const MembershipEvent &membershipEvent)
Invoked when an existing member leaves the cluster.
Definition: MembershipListener.cpp:45
Definition: MembershipListener.h:103
PN (Positive-Negative) CRDT counter.
Definition: MapEntryView.h:32
virtual void memberAdded(const MembershipEvent &membershipEvent)
Invoked when a new member is added to the cluster.
Definition: MembershipListener.cpp:40