29#include <unordered_map>
38 auto seed = std::hash<uint64_t>{}(oid.
lo);
39 seed ^= std::hash<uint64_t>{}(oid.
hi) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
47 return (lhs.
lo == rhs.
lo) && (lhs.
hi == rhs.
hi);
59class RDaosFakeObject {
61 std::mutex fMutexStorage;
62 std::unordered_map<std::string, std::string> fStorage;
72 RDaosFakeObject() =
default;
73 ~RDaosFakeObject() =
default;
83 std::lock_guard<std::mutex> lock(fMutexStorage);
85 for (
unsigned i = 0; i < nr; i++) {
87 auto data = fStorage.find(GetKey(dkey, &iods[i].iod_name));
88 if (
data == fStorage.end())
96 if (sgls[i].sg_nr != 1)
101 reinterpret_cast<char *
>(iov.
iov_buf));
110 std::lock_guard<std::mutex> lock(fMutexStorage);
112 for (
unsigned i = 0; i < nr; i++) {
113 auto &
data = fStorage[GetKey(dkey, &iods[i].iod_name)];
120 for (
unsigned j = 0; j < sgls[i].
sg_nr; j++) {
134class RDaosFakeContainer {
136 std::mutex fMutexObjects;
137 std::unordered_map<daos_obj_id_t, std::unique_ptr<RDaosFakeObject>> fObjects;
140 RDaosFakeContainer() =
default;
141 ~RDaosFakeContainer() =
default;
145 std::lock_guard<std::mutex> lock(fMutexObjects);
146 auto &obj = fObjects[oid];
148 obj = std::make_unique<RDaosFakeObject>();
161 static std::mutex fMutexPools;
162 static std::unordered_map<label_t, std::unique_ptr<RDaosFakePool>> fPools;
164 std::mutex fMutexContainers;
165 std::unordered_map<label_t, std::unique_ptr<RDaosFakeContainer>> fContainers;
170 static RDaosFakePool *GetPool(
const label_t &label)
172 std::lock_guard<std::mutex> lock(fMutexPools);
173 auto &pool = fPools[label];
175 pool = std::make_unique<RDaosFakePool>();
179 RDaosFakePool() =
default;
180 ~RDaosFakePool() =
default;
182 void CreateContainer(
const label_t &label)
184 std::lock_guard<std::mutex> lock(fMutexContainers);
185 fContainers.emplace(label, std::make_unique<RDaosFakeContainer>());
188 RDaosFakeContainer *GetContainer(
const label_t &label)
190 std::lock_guard<std::mutex> lock(fMutexContainers);
191 auto it = fContainers.find(label);
192 return (it != fContainers.end()) ? it->second.get() :
nullptr;
196std::mutex RDaosFakePool::fMutexPools;
197std::unordered_map<label_t, std::unique_ptr<RDaosFakePool>> RDaosFakePool::fPools;
214 Cookie(
void *
p) : fPointer(
p) {}
215 ~Cookie() { fPointer =
nullptr; }
216 void *GetPointer() {
return fPointer; }
222 template <
typename T>
228 template <
typename T>
229 static inline typename std::add_pointer<T>::type ToPointer(
const daos_handle_t h)
231 return reinterpret_cast<typename std::add_pointer<T>::type
>(
reinterpret_cast<Cookie *
>(
h.cookie)->GetPointer());
234 static inline void Invalidate(
daos_handle_t h) {
delete reinterpret_cast<Cookie *
>(
h.cookie); }
253 return rc ?
"DER_INVAL" :
"Success";
258 if (strcmp(
name,
"SX") == 0)
260 if (strcmp(
name,
"RP_XSF") == 0)
272 strcpy(
name,
"RP_XSF");
283 auto pool = RDaosHandle::ToPointer<RDaosFakePool>(poh);
290 pool->CreateContainer(
label_t(label));
297 auto pool = RDaosHandle::ToPointer<RDaosFakePool>(poh);
304 auto cont = pool->GetContainer(
label_t(label));
307 *coh = RDaosHandle::ToHandle(cont);
313 RDaosHandle::Invalidate(coh);
361 auto cont = RDaosHandle::ToPointer<RDaosFakeContainer>(coh);
364 auto obj = cont->GetObject(oid,
mode);
365 *oh = RDaosHandle::ToHandle(obj);
371 RDaosHandle::Invalidate(oh);
401 auto obj = RDaosHandle::ToPointer<RDaosFakeObject>(oh);
404 return obj->Fetch(dkey, nr, iods, sgls);
410 auto obj = RDaosHandle::ToPointer<RDaosFakeObject>(oh);
413 return obj->Update(dkey, nr, iods, sgls);
422 *poh = RDaosHandle::ToHandle(RDaosFakePool::GetPool(
label_t(label)));
428 RDaosHandle::Invalidate(poh);
#define R__LOG_WARNING(...)
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char mode
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
TRObject operator()(const T1 &t1) const
This file is a reduced version of daos_xxx.h headers that provides (simplified) declarations for use ...
daos_otype_t
DAOS object type.
uint16_t daos_oclass_hints_t
#define OID_FMT_META_SHIFT
static bool daos_label_is_valid(const char *)
uint16_t daos_oclass_id_t
#define OID_FMT_INTR_BITS
static bool daos_otype_t_is_valid(enum daos_otype_t type)
#define OID_FMT_CLASS_SHIFT
@ OC_RP_XSF
Replicated object class which is extremely scalable for fetch.
#define OID_FMT_TYPE_SHIFT
int daos_oclass_id2name(daos_oclass_id_t oc_id, char *name)
const char * d_errstr(int rc)
int daos_cont_create_with_label(daos_handle_t poh, const char *label, daos_prop_t *, uuid_t *, daos_event_t *)
int daos_eq_poll(daos_handle_t, int, int64_t, unsigned int nevents, daos_event_t **)
int daos_event_init(daos_event_t *, daos_handle_t, daos_event_t *)
int daos_oclass_name2id(const char *name)
int daos_obj_open(daos_handle_t coh, daos_obj_id_t oid, unsigned int mode, daos_handle_t *oh, daos_event_t *)
int daos_pool_connect(const char *label, const char *, unsigned int, daos_handle_t *poh, daos_pool_info_t *, daos_event_t *)
int daos_obj_fetch(daos_handle_t oh, daos_handle_t, uint64_t, daos_key_t *dkey, unsigned int nr, daos_iod_t *iods, d_sg_list_t *sgls, daos_iom_t *, daos_event_t *)
int daos_event_test(daos_event *, int64_t, bool *flag)
int daos_event_fini(daos_event_t *)
int daos_eq_create(daos_handle_t *)
int daos_obj_generate_oid(daos_handle_t, daos_obj_id_t *oid, enum daos_otype_t type, daos_oclass_id_t cid, daos_oclass_hints_t, uint32_t)
int daos_event_parent_barrier(daos_event_t *)
int daos_cont_open(daos_handle_t poh, const char *label, unsigned int, daos_handle_t *coh, daos_cont_info_t *, daos_event_t *)
int daos_obj_close(daos_handle_t oh, daos_event_t *)
bool operator==(const daos_obj_id_t &lhs, const daos_obj_id_t &rhs)
int daos_eq_destroy(daos_handle_t, int)
int daos_cont_close(daos_handle_t coh, daos_event_t *)
int daos_pool_disconnect(daos_handle_t poh, daos_event_t *)
int daos_obj_update(daos_handle_t oh, daos_handle_t, uint64_t, daos_key_t *dkey, unsigned int nr, daos_iod_t *iods, d_sg_list_t *sgls, daos_event_t *)
RLogChannel & NTupleLog()
Log channel for RNTuple diagnostics.
Scatter/gather list for memory buffers.
Generic handle for various DAOS components like container, object, etc.
daos properties, for pool or container