-
Notifications
You must be signed in to change notification settings - Fork 0
/
extent_server.h
60 lines (36 loc) · 1.38 KB
/
extent_server.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
// this is the extent server
#ifndef extent_server_h
#define extent_server_h
#include <string>
#include <map>
#include "extent_protocol.h"
struct extent_t {
std::string data;
extent_protocol::attr attrs;
};
class extent_server {
std::map<extent_protocol::extentid_t, extent_t> m_dataBlocks; // data blocks
public:
extent_server();
// create an extent
int create(extent_protocol::extentid_t id, int &);
// update extent content
int update(extent_protocol::extentid_t id, std::string buf, unsigned offset, unsigned size, int & bytesWritten);
// update full extent content (with resize)
int updateAll(extent_protocol::extentid_t id, std::string buf, int &);
// get extent content
int retrieve(extent_protocol::extentid_t id, unsigned offset, unsigned size, std::string &buf);
// get full extent content
int retrieveAll(extent_protocol::extentid_t id, std::string &buf);
// get extent attributes
int getattr(extent_protocol::extentid_t id, extent_protocol::attr &);
// set extent attributes
int setattr(extent_protocol::extentid_t id, extent_protocol::attr, int &);
// remove an extent
int remove(extent_protocol::extentid_t id, int &);
// put extent with attrs to server
int put(extent_protocol::extentid_t id, std::string buf, extent_protocol::attr a, int &);
private:
void reallocateString(std::string &str, unsigned newSize);
};
#endif