InfinispanHotRodC++Client  8.2.0.Alpha1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
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 
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 {
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) {}
47  K getKey() { return key; }
48 
57  uint64_t getVersion() { return version; }
58 
67  bool isCommandRetried() { return commandRetried; }
68  uint8_t getType() { return CLIENT_CACHE_ENTRY_CREATED; }
69 private:
70  const K key;
71  const uint64_t version;
72  const bool commandRetried;
73 };
74 
75 template <class K>
77 public:
78  ClientCacheEntryModifiedEvent(K key, uint64_t version, int commandRetried) : key(key), version(version), commandRetried(commandRetried!=0) {}
79 
85  K getKey() { return key; }
86 
95  uint64_t getVersion() { return version; }
96 
105  bool isCommandRetried() { return commandRetried; }
106  uint8_t getType() { return CLIENT_CACHE_ENTRY_MODIFIED; }
107 private:
108  const K key;
109  const uint64_t version;
110  const bool commandRetried;
111 };
112 
113 template <class K>
115 public:
116  ClientCacheEntryExpiredEvent(K key): key(key) {}
122  K getKey() { return key; }
123 
124  uint8_t getType() { return CLIENT_CACHE_ENTRY_EXPIRED; }
125 private:
126  const K key;
127 };
128 
129 template <class K>
131 public:
132  ClientCacheEntryRemovedEvent(K key, int commandRetried) : key(key), commandRetried(commandRetried!=0) {}
138  K getKey() { return key; }
139 
148  bool isCommandRetried() { return commandRetried; }
149  uint8_t getType() { return CLIENT_CACHE_ENTRY_REMOVED; }
150 private:
151  const K key;
152  const bool commandRetried;
153 };
154 
156 public:
157  ClientCacheEntryCustomEvent(std::vector<char> data, int commandRetried) : data(data), commandRetried(commandRetried!=0) {}
164  std::vector<char> getEventData() { return data; }
165 
174  bool isCommandRetried() { return commandRetried; }
175  uint8_t getType() { return CLIENT_CACHE_ENTRY_CUSTOM; }
176 private:
177  const std::vector<char> data;
178  bool commandRetried;
179 };
180 
182  uint8_t getType() { return CLIENT_CACHE_FAILOVER; }
183 
184 };
185 
186 
187 } /* namespace event */
188 } /* namespace hotrod */
189 } /* namespace infinispan */
190 
191 #endif /* SRC_HOTROD_IMPL_EVENT_CLIENTEVENT_H_ */
bool isCommandRetried()
Definition: ClientEvent.h:67
uint8_t opCode
Definition: ClientEvent.h:21
ClientCacheEntryRemovedEvent(K key, int commandRetried)
Definition: ClientEvent.h:132
uint8_t getType()
Definition: ClientEvent.h:149
uint8_t getType()
Definition: ClientEvent.h:175
uint8_t getType()
Definition: ClientEvent.h:124
ClientCacheEntryModifiedEvent(K key, uint64_t version, int commandRetried)
Definition: ClientEvent.h:78
bool isCommandRetried()
Definition: ClientEvent.h:174
virtual ~ClientEvent()
Definition: ClientEvent.h:34
bool isCommandRetried()
Definition: ClientEvent.h:148
uint8_t getType()
Definition: ClientEvent.h:106
uint8_t magic
Definition: ClientEvent.h:19
ClientCacheEntryCustomEvent(std::vector< char > data, int commandRetried)
Definition: ClientEvent.h:157
uint64_t messageId
Definition: ClientEvent.h:20
uint8_t status
Definition: ClientEvent.h:22
ClientCacheEntryExpiredEvent(K key)
Definition: ClientEvent.h:116
uint8_t getType()
Definition: ClientEvent.h:68
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:105
uint64_t getVersion()
Definition: ClientEvent.h:95
std::vector< char > getEventData()
Definition: ClientEvent.h:164
uint64_t getVersion()
Definition: ClientEvent.h:57