Infinispan HotRod C++ Client  8.3.1.Final
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
RemoteCacheManagerAdmin.h
Go to the documentation of this file.
1 /*
2  * RemoteCacheManagerAdmin.h
3  *
4  * Created on: Apr 10, 2018
5  * Author: rigazilla
6  */
7 
8 #ifndef INCLUDE_INFINISPAN_HOTROD_REMOTECACHEMANAGERADMIN_H_
9 #define INCLUDE_INFINISPAN_HOTROD_REMOTECACHEMANAGERADMIN_H_
10 
14 #include <vector>
15 #include <set>
16 
17 namespace infinispan {
18 namespace hotrod {
19 namespace transport {
20 class TransportFactory;
21 }
22 
23 namespace operations {
24 class OperationsFactory;
25 }
26 
27 namespace protocol {
28 class Codec;
29 }
30 
31 using namespace transport;
32 using namespace operations;
33 using namespace protocol;
34 
35 enum AdminFlag {
37 };
38 
40 public:
41  RemoteCacheManagerAdmin(RemoteCacheManager& cacheManager, std::function<void(std::string&)> remover, std::shared_ptr<OperationsFactory> of);
50  template <class K, class V> RemoteCache<K, V>& createCache(const std::string name, std::string model) {
51  createCache(name, model, "@@cache@create");
52  return cacheManager.getCache<K,V>(name);
53  }
54 
62  template <class K, class V> RemoteCache<K, V>& createCacheWithXml(const std::string name, std::string conf) {
63  createCacheWithXml(name, conf, "@@cache@create");
64  return cacheManager.getCache<K,V>(name);
65 
66  }
67 
77  template <class K, class V> RemoteCache<K, V>& getOrCreateCache(const std::string name, std::string model) {
78  createCache(name, model, "@@cache@getorcreate");
79  return cacheManager.getCache<K,V>(name);
80  }
81 
93  template <class K, class V> RemoteCache<K, V>& getOrCreateCacheWithXml(const std::string name, std::string conf) {
94  createCacheWithXml(name, conf, "@@cache@getorcreate");
95  return cacheManager.getCache<K,V>(name);
96  }
97 
103  void removeCache(std::string name);
104 
111  void reindexCache(std::string name);
112 
116  std::set<std::string> getCacheNames();
117 
118  RemoteCacheManagerAdmin& withFlags(std::set<AdminFlag> flags);
119  void createCache(const std::string name, std::string model, std::string command);
120  void createCacheWithXml(const std::string name, std::string conf, std::string command);
121 
122 private:
123  std::string flags2Params(const std::set<AdminFlag>& flags) const;
124 
125  std::vector<char> executeAdminOperation(std::string adminCmd, std::map<std::string, std::string >& param);
126 
127  static const std::vector<char> CACHE_NAME;
128  static const std::vector<char> CACHE_TEMPLATE;
129  static const std::vector<char> CACHE_CONFIGURATION;
130  static const std::vector<char> CACHE_FLAGS;
131  static const std::string FLAG_LABELS[];
132  std::shared_ptr<OperationsFactory> operationsFactory;
133  std::function<void(std::string&)> remover;
134 
135  RemoteCacheManager& cacheManager;
136 #ifdef SWIGJAVA // Swig needs public access to flags
137 public:
138 #endif
139  std::set<AdminFlag> flags;
140 };
141 
142 }} // namespace infinispan::hotrod
143 
144 
145 
146 #endif /* INCLUDE_INFINISPAN_HOTROD_REMOTECACHEMANAGERADMIN_H_ */
#define HR_EXTERN
Definition: ImportExport.h:35
RemoteCache< K, V > & getOrCreateCache(const std::string name, std::string model)
Definition: RemoteCacheManagerAdmin.h:77
Definition: CacheClientListener.h:28
RemoteCache< K, V > & getCache(bool forceReturnValue)
Definition: RemoteCacheManager.h:114
AdminFlag
Definition: RemoteCacheManagerAdmin.h:35
Definition: RemoteCacheManager.h:43
Definition: RemoteCacheManagerAdmin.h:36
Definition: RemoteCacheManagerAdmin.h:39
RemoteCache< K, V > & getOrCreateCacheWithXml(const std::string name, std::string conf)
Definition: RemoteCacheManagerAdmin.h:93
RemoteCache< K, V > & createCacheWithXml(const std::string name, std::string conf)
Definition: RemoteCacheManagerAdmin.h:62
RemoteCache< K, V > & createCache(const std::string name, std::string model)
Definition: RemoteCacheManagerAdmin.h:50