-
Notifications
You must be signed in to change notification settings - Fork 0
/
extent_client.h
56 lines (42 loc) · 1.62 KB
/
extent_client.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// extent client interface.
#ifndef extent_client_h
#define extent_client_h
#include <string>
#include "extent_protocol.h"
#include "rpc.h"
class extent_client {
private:
rpcc *cl;
struct extent_t {
std::string buffer;
extent_protocol::attr attrs;
bool isRemote;
bool isDirty;
bool existLocally;
bool isRemoved;
pthread_mutex_t mutex;
extent_t():
isRemote(false),
isDirty(false),
existLocally(false),
isRemoved(false)
{
pthread_mutex_init(&mutex, NULL);
}
};
std::map<extent_protocol::extentid_t, extent_t> localExtents; // data blocks
extent_protocol::status fetch(extent_protocol::extentid_t id);
void reallocateString(std::string &str, unsigned newSize);
public:
extent_client(std::string dst);
extent_protocol::status create(extent_protocol::extentid_t id);
extent_protocol::status update(extent_protocol::extentid_t id, std::string buf, int offset, int size, int & bytesWritten);
extent_protocol::status updateAll(extent_protocol::extentid_t id, std::string buf);
extent_protocol::status retrieve(extent_protocol::extentid_t id, int offset, int size, std::string &buf);
extent_protocol::status retrieveAll(extent_protocol::extentid_t id, std::string &buf);
extent_protocol::status getattr(extent_protocol::extentid_t id, extent_protocol::attr &a);
extent_protocol::status setattr(extent_protocol::extentid_t id, extent_protocol::attr a);
extent_protocol::status remove(extent_protocol::extentid_t id);
extent_protocol::status flush(extent_protocol::extentid_t id);
};
#endif