1 #ifndef ISPN_HOTROD_REMOTECACHEBASE_H 2 #define ISPN_HOTROD_REMOTECACHEBASE_H 25 namespace operations {
26 class OperationsFactory;
36 typedef void* (*UnmarshallHelperFn) (
void*,
const std::vector<char> &);
38 class KeyUnmarshallerFtor;
39 class ValueUnmarshallerFtor;
40 class RemoteCacheImpl;
45 virtual ~RemoteCacheBase() {}
48 HR_EXTERN void *base_get(
const void *key);
49 HR_EXTERN std::map<std::vector<char>,std::vector<char> > base_getAll(
const std::set<std::vector<char> >& keySet);
50 HR_EXTERN void *base_put(
const void *key,
const void *value, int64_t life, int64_t idle);
51 HR_EXTERN void *base_putIfAbsent(
const void *key,
const void *value, int64_t life, int64_t idle);
52 HR_EXTERN void *base_replace(
const void *key,
const void *value, int64_t life, int64_t idle);
53 HR_EXTERN void *base_remove(
const void *key);
54 HR_EXTERN bool base_containsKey(
const void *key);
56 HR_EXTERN bool base_replaceWithVersion(
const void *key,
const void *value, int64_t version, int64_t life, int64_t idle);
57 HR_EXTERN bool base_removeWithVersion(
const void *key, int64_t version);
60 HR_EXTERN void base_getBulk(
int size, std::map<void*, void*> &mbuf);
61 HR_EXTERN void base_keySet(
int scope, std::vector<void*> &sbuf);
62 HR_EXTERN void base_stats(std::map<std::string,std::string> &sbuf);
66 HR_EXTERN std::vector<unsigned char> base_execute(
const std::string &cmdName,
const std::map<std::string,std::string>& args);
67 HR_EXTERN std::vector<unsigned char> base_execute(
const std::string &cmdName,
const std::map<std::vector<char> ,std::vector<char> >& args);
68 HR_EXTERN std::vector<char> base_execute(
const std::vector<char> &cmdName,
const std::map<std::vector<char> ,std::vector<char> >& args);
69 HR_EXTERN CacheTopologyInfo base_getCacheTopologyInfo();
71 HR_EXTERN std::vector<unsigned char> base_query_char(std::vector<unsigned char> qr,
size_t size);
73 HR_EXTERN void base_addClientListener(
ClientListener &clientListener,
const std::vector<std::vector<char> > filterFactoryParam,
const std::vector<std::vector<char> > converterFactoryParams,
const std::function<
void()> &recoveryCallback);
75 HR_EXTERN void putScript(
const std::vector<char>& name,
const std::vector<char>& script);
81 template<
class K,
class V,
typename... Params>
83 static char CONTINUOUS_QUERY_FILTER_FACTORY_NAME[] =
84 "continuous-query-filter-converter-factory";
85 cql.cl.filterFactoryName = std::vector<char>(
86 CONTINUOUS_QUERY_FILTER_FACTORY_NAME,
87 CONTINUOUS_QUERY_FILTER_FACTORY_NAME
88 + strlen(CONTINUOUS_QUERY_FILTER_FACTORY_NAME));
89 cql.cl.converterFactoryName = std::vector<char>(
90 CONTINUOUS_QUERY_FILTER_FACTORY_NAME,
91 CONTINUOUS_QUERY_FILTER_FACTORY_NAME
92 + strlen(CONTINUOUS_QUERY_FILTER_FACTORY_NAME));
93 BasicTypesProtoStreamMarshaller<std::string> paramMarshaller;
94 std::vector<std::vector<char> > filterFactoryParams;
95 std::vector<char> param;
96 paramMarshaller.marshall(cql.getQuery(), param);
97 filterFactoryParams.push_back(param);
98 std::vector<std::vector<char> > converterFactoryParams;
99 cql.cl.useRawData =
true;
100 cql.listenerCustomEvent =
102 ContinuousQueryResult r;
104 wm.ParseFromArray(e.getEventData().data(), e.getEventData().size());
105 r.ParseFromString(wm.wrappedmessagebytes());
106 auto resultType = r.resulttype();
108 std::tuple<Params...> tp=
popTuple<Params...>(r.projection(), i) ;
109 K* k = (K*)this->baseKeyUnmarshall(std::vector<char>(r.key().begin(), r.key().end()));
110 switch (resultType) {
111 case ContinuousQueryResult_ResultType_JOINING:
112 cql.getJoiningListener()(*k, tp);
114 case ContinuousQueryResult_ResultType_LEAVING:
115 cql.getLeavingListener()(*k, tp);
117 case ContinuousQueryResult_ResultType_UPDATED:
118 cql.getUpdatedListener()(*k, tp);
125 cql.cl.add_listener(cql.listenerCustomEvent);
126 this->base_addClientListener(cql.cl, filterFactoryParams,
127 converterFactoryParams, cql.getFailoverListener());
129 template <
class K,
class V>
131 static char CONTINUOUS_QUERY_FILTER_FACTORY_NAME[] =
132 "continuous-query-filter-converter-factory";
133 cql.cl.filterFactoryName = std::vector<char>(
134 CONTINUOUS_QUERY_FILTER_FACTORY_NAME,
135 CONTINUOUS_QUERY_FILTER_FACTORY_NAME
136 + strlen(CONTINUOUS_QUERY_FILTER_FACTORY_NAME));
137 cql.cl.converterFactoryName = std::vector<char>(
138 CONTINUOUS_QUERY_FILTER_FACTORY_NAME,
139 CONTINUOUS_QUERY_FILTER_FACTORY_NAME
140 + strlen(CONTINUOUS_QUERY_FILTER_FACTORY_NAME));
141 BasicTypesProtoStreamMarshaller<std::string> paramMarshaller;
142 std::vector<std::vector<char> > filterFactoryParams;
143 std::vector<char> param;
144 paramMarshaller.marshall(cql.getQuery(), param);
145 filterFactoryParams.push_back(param);
146 std::vector<std::vector<char> > converterFactoryParams;
147 cql.cl.useRawData =
true;
148 cql.listenerCustomEvent =
150 ContinuousQueryResult r;
152 wm.ParseFromArray(e.getEventData().data(), e.getEventData().size());
153 r.ParseFromString(wm.wrappedmessagebytes());
154 auto resultType = r.resulttype();
155 K* k = (K*)this->baseKeyUnmarshall(std::vector<char>(r.key().begin(), r.key().end()));
156 V* v = (V*)this->baseValueUnmarshall(std::vector<char>(r.value().begin(), r.value().end()));
157 switch (resultType) {
158 case ContinuousQueryResult_ResultType_JOINING:
159 cql.getJoiningListener()(*k, *v);
161 case ContinuousQueryResult_ResultType_LEAVING:
162 cql.getLeavingListener()(*k, *v);
164 case ContinuousQueryResult_ResultType_UPDATED:
165 cql.getUpdatedListener()(*k, *v);
172 cql.cl.add_listener(cql.listenerCustomEvent);
173 this->base_addClientListener(cql.cl, filterFactoryParams,
174 converterFactoryParams, cql.getFailoverListener());
180 std::shared_ptr<RemoteCacheImpl> impl;
181 void *remoteCachePtr=
nullptr;
184 HR_EXTERN void baseKeyMarshall(
const void* k, std::vector<char> &buf);
185 HR_EXTERN void baseValueMarshall(
const void* v, std::vector<char> &buf);
189 HR_EXTERN void* baseKeyUnmarshall(
const std::vector<char> &buf);
190 HR_EXTERN void* baseValueUnmarshall(
const std::vector<char> &buf);
193 friend class RemoteCacheImpl;
194 friend class NearRemoteCacheImpl;
195 friend class KeyUnmarshallerFtor;
196 friend class ValueUnmarshallerFtor;
197 template <
class K,
class V>
198 friend class ::infinispan::hotrod::event::CacheClientListener;
200 template <
typename... Params>
201 friend class ::infinispan::hotrod::event::ContinuousQueryListener;
#define HR_EXTERN
Definition: ImportExport.h:35
Definition: CacheClientListener.h:30
Definition: ClientEvent.h:145
Definition: AuthenticationConfiguration.h:10
void(* MarshallHelperFn)(void *, const void *, std::vector< char > &)
Definition: RemoteCacheBase.h:35
void *(* UnmarshallHelperFn)(void *, const std::vector< char > &)
Definition: RemoteCacheBase.h:36
std::tuple< H, Params... > popTuple(const RepeatedPtrField< WrappedMessage > &wMsgs, int &k)
Definition: QueryUtils.h:94
Definition: RemoteCacheManager.h:38
Definition: ClientListener.h:35
Definition: CacheClientListener.h:33
Definition: ContinuousQueryListener.h:34
Definition: RemoteExecution.h:29
Definition: VersionedValue.h:9