Hermes  0.9.5-beta
Hierarchical Distributed I/O Buffering System
vbucket.h
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2  * Distributed under BSD 3-Clause license. *
3  * Copyright by The HDF Group. *
4  * Copyright by the Illinois Institute of Technology. *
5  * All rights reserved. *
6  * *
7  * This file is part of Hermes. The full Hermes copyright notice, including *
8  * terms governing use, modification, and redistribution, is contained in *
9  * the COPYING file, which can be found at the top directory. If you do not *
10  * have access to the file, you may request a copy from help@hdfgroup.org. *
11  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
12 
13 #ifndef VBUCKET_H_
14 #define VBUCKET_H_
15 
16 #include <glog/logging.h>
17 
18 #include <list>
19 #include <memory>
20 #include <string>
21 #include <utility>
22 #include <vector>
23 
24 #include "hermes.h"
25 #include "traits.h"
26 
27 namespace hermes {
28 
29 namespace api {
30 
35 class VBucket {
36  private:
38  std::string name_;
42  std::list<Trait *> attached_traits_;
44  std::shared_ptr<Hermes> hermes_;
47 
48  public:
62  VBucket(std::string initial_name, std::shared_ptr<Hermes> const &hermes,
63  Context ctx = Context());
64 
71  ~VBucket();
72 
80  bool IsValid() const;
81 
86  std::string GetName() const;
87 
93 
106  Status Link(std::string blob_name, std::string bucket_name);
107 
114  Status Link(std::string blob_name, std::string bucket_name, Context &ctx);
115 
125  Status Unlink(std::string blob_name, std::string bucket_name, Context &ctx);
127  Status Unlink(std::string blob_name, std::string bucket_name);
128 
130  bool ContainsBlob(std::string blob_name, std::string bucket_name);
131 
137  size_t Get(const std::string &name, Bucket &bkt, Blob &user_blob,
138  const Context &ctx);
139 
142  size_t Get(const std::string &name, Bucket &bkt, Blob &user_blob);
143 
146  size_t Get(const std::string &name, Bucket &bkt, void *user_blob,
147  size_t blob_size, const Context &ctx);
148 
154  size_t Get(const std::string &name, Bucket *bkt, Blob &user_blob,
155  const Context &ctx);
156 
158  size_t Get(const std::string &name, Bucket *bkt, Blob &user_blob);
159 
163  size_t Get(const std::string &name, Bucket *bkt, void *user_blob,
164  size_t blob_size, const Context &ctx);
165 
168  std::vector<std::string> GetLinks(Context &ctx);
169 
179  Status Attach(Trait *trait);
180 
186  Status Attach(Trait *trait, Context &ctx);
187 
194  Status Detach(Trait *trait);
195 
201  Status Detach(Trait *trait, Context &ctx);
202 
212  template <class Predicate>
213  std::vector<TraitID> GetTraits(Predicate pred, Context &ctx);
214 
221  Trait *GetTrait(TraitType type);
222 
233  Status Release();
234 
239  Status Release(Context &ctx);
240 
250  Status Destroy();
251 
256  Status Destroy(Context &ctx);
257 }; // class VBucket
258 
259 } // namespace api
260 } // namespace hermes
261 
262 #endif // VBUCKET_H_
Definition: hermes_status.h:80
A container for Blobs.
Definition: bucket.h:37
Definition: vbucket.h:35
size_t Get(const std::string &name, Bucket *bkt, void *user_blob, size_t blob_size, const Context &ctx)
Retrieve a Blob into a user buffer.
size_t Get(const std::string &name, Bucket &bkt, Blob &user_blob, const Context &ctx)
Definition: vbucket.cc:169
std::shared_ptr< Hermes > hermes_
Definition: vbucket.h:44
void WaitForBackgroundFlush()
Definition: vbucket.cc:59
Status Destroy()
Destroy this VBucket.
Definition: vbucket.cc:339
Status Attach(Trait *trait)
Attach a Trait to this VBucket.
Definition: vbucket.cc:220
std::vector< std::string > GetLinks(Context &ctx)
Definition: vbucket.cc:205
Context ctx_
Definition: vbucket.h:46
Status Detach(Trait *trait)
Detach a trait from this VBucket.
Definition: vbucket.cc:254
std::string name_
Definition: vbucket.h:38
bool ContainsBlob(std::string blob_name, std::string bucket_name)
Definition: vbucket.cc:148
VBucketID id_
Definition: vbucket.h:40
size_t Get(const std::string &name, Bucket *bkt, Blob &user_blob, const Context &ctx)
VBucket(std::string initial_name, std::shared_ptr< Hermes > const &hermes, Context ctx=Context())
Create or open a VBucket.
Definition: vbucket.cc:26
Status Link(std::string blob_name, std::string bucket_name)
Definition: vbucket.cc:63
size_t Get(const std::string &name, Bucket *bkt, Blob &user_blob)
Status Release()
Release this vBucket.
Definition: vbucket.cc:321
std::vector< TraitID > GetTraits(Predicate pred, Context &ctx)
Retrieves the subset of attached traits satisfying the Predicate pred.
Definition: vbucket.cc:308
std::list< Trait * > attached_traits_
Definition: vbucket.h:42
Trait * GetTrait(TraitType type)
Get's an attached Trait that matches type.
Definition: vbucket.cc:295
~VBucket()
Close a VBucket.
Definition: vbucket.cc:45
Status Unlink(std::string blob_name, std::string bucket_name, Context &ctx)
Definition: vbucket.cc:109
std::string GetName() const
Return the name of this VBucket.
Definition: vbucket.cc:55
bool IsValid() const
Return bool{this VBucket is valid}.
Definition: vbucket.cc:51
std::vector< unsigned char > Blob
Definition: hermes_types.h:70
TraitType
Trait types.
Definition: hermes_types.h:428
Definition: adapter_utils.cc:35
Definition: hermes_types.h:137
Base class for Traits, which can attach functionality to VBuckets.
Definition: traits.h:52
Definition: hermes_types.h:388