Red Hat Data Grid HotRod C++ Client  7.2.0
ClientEvent.h
Go to the documentation of this file.
1 /*
2  * ClientEvent.h
3  *
4  * Created on: Aug 19, 2016
5  * Author: rigazilla
6  */
7 
8 #ifndef SRC_HOTROD_IMPL_EVENT_CLIENTEVENT_H_
9 #define SRC_HOTROD_IMPL_EVENT_CLIENTEVENT_H_
10 
11 #include <vector>
12 #include <cstdint>
13 
14 namespace infinispan {
15 namespace hotrod {
16 namespace event {
17 
18 struct EventHeaderParams {
19  uint8_t magic;
20  uint64_t messageId;
21  uint8_t opCode;
22  uint8_t status;
23 };
24 
25 class ClientEvent {
26 public:
27  enum Type {
28  CLIENT_CACHE_ENTRY_CREATED, CLIENT_CACHE_ENTRY_MODIFIED,
29  CLIENT_CACHE_ENTRY_REMOVED, CLIENT_CACHE_ENTRY_EXPIRED, CLIENT_CACHE_ENTRY_CUSTOM,
30  CLIENT_CACHE_FAILOVER
31  };
32 
33  virtual uint8_t getType() = 0;
34  virtual ~ClientEvent() {}
35 };
36 
37 template <class K>
39 {
40 public:
41  ClientCacheEntryCreatedEvent(K key, uint64_t version, int commandRetried) : key(key), version(version), commandRetried(commandRetried!=0) {}
46  K getKey() { return key; }
47 
52  uint64_t getVersion() { return version; }
53 
62  bool isCommandRetried() { return commandRetried; }
63  uint8_t getType() { return CLIENT_CACHE_ENTRY_CREATED; }
64 private:
65  const K key;
66  const uint64_t version;
67  const bool commandRetried;
68 };
69 
70 template <class K>
72 public:
73  ClientCacheEntryModifiedEvent(K key, uint64_t version, int commandRetried) : key(key), version(version), commandRetried(commandRetried!=0) {}
74 
79  K getKey() { return key; }
80 
85  uint64_t getVersion() { return version; }
86 
95  bool isCommandRetried() { return commandRetried; }
96  uint8_t getType() { return CLIENT_CACHE_ENTRY_MODIFIED; }
97 private:
98  const K key;
99  const uint64_t version;
100  const bool commandRetried;
101 };
102 
103 template <class K>
105 public:
106  ClientCacheEntryExpiredEvent(K key): key(key) {}
112  K getKey() { return key; }
113 
114  uint8_t getType() { return CLIENT_CACHE_ENTRY_EXPIRED; }
115 private:
116  const K key;
117 };
118 
119 template <class K>
121 public:
122  ClientCacheEntryRemovedEvent(K key, int commandRetried) : key(key), commandRetried(commandRetried!=0) {}
128  K getKey() { return key; }
129 
138  bool isCommandRetried() { return commandRetried; }
139  uint8_t getType() { return CLIENT_CACHE_ENTRY_REMOVED; }
140 private:
141  const K key;
142  const bool commandRetried;
143 };
144 
146 public:
147  ClientCacheEntryCustomEvent(std::vector<char> data, int commandRetried) : data(data), commandRetried(commandRetried!=0) {}
154  std::vector<char> getEventData() { return data; }
155 
164  bool isCommandRetried() { return commandRetried; }
165  uint8_t getType() { return CLIENT_CACHE_ENTRY_CUSTOM; }
166 private:
167  const std::vector<char> data;
168  bool commandRetried;
169 };
170 
172  uint8_t getType() { return CLIENT_CACHE_FAILOVER; }
173 
174 };
175 
176 
177 } /* namespace event */
178 } /* namespace hotrod */
179 } /* namespace infinispan */
180 
181 #endif /* SRC_HOTROD_IMPL_EVENT_CLIENTEVENT_H_ */
bool isCommandRetried()
Definition: ClientEvent.h:62
ClientCacheEntryRemovedEvent(K key, int commandRetried)
Definition: ClientEvent.h:122
uint8_t getType()
Definition: ClientEvent.h:139
uint8_t getType()
Definition: ClientEvent.h:165
uint8_t getType()
Definition: ClientEvent.h:114
ClientCacheEntryModifiedEvent(K key, uint64_t version, int commandRetried)
Definition: ClientEvent.h:73
bool isCommandRetried()
Definition: ClientEvent.h:164
virtual ~ClientEvent()
Definition: ClientEvent.h:34
bool isCommandRetried()
Definition: ClientEvent.h:138
uint8_t getType()
Definition: ClientEvent.h:96
Definition: AuthenticationConfiguration.h:10
ClientCacheEntryCustomEvent(std::vector< char > data, int commandRetried)
Definition: ClientEvent.h:147
ClientCacheEntryExpiredEvent(K key)
Definition: ClientEvent.h:106
uint8_t getType()
Definition: ClientEvent.h:63
ClientCacheEntryCreatedEvent(K key, uint64_t version, int commandRetried)
Definition: ClientEvent.h:41
Type
Definition: ClientEvent.h:27
Definition: ClientEvent.h:25
bool isCommandRetried()
Definition: ClientEvent.h:95
uint64_t getVersion()
Definition: ClientEvent.h:85
std::vector< char > getEventData()
Definition: ClientEvent.h:154
uint64_t getVersion()
Definition: ClientEvent.h:52