-
Notifications
You must be signed in to change notification settings - Fork 95
/
Copy pathdhash_store.h
84 lines (69 loc) · 1.88 KB
/
dhash_store.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#ifndef __DHASH_STORE__H_
#define __DHASH_STORE__H_
#include <dhash_prot.h>
#include <dhash_common.h>
#include <dhash.h>
#include <route.h>
#include <chord.h>
typedef callback<void, dhash_stat, chordID, bool>::ref cbclistore_t;
//store a block/fragment by sending RPCs smaller than the MTU
class dhash_store {
public:
static void execute (ptr<vnode> clntnode, ptr<location> dest,
blockID bid,
str data,
u_int32_t exp,
cbclistore_t cb,
store_status store_type = DHASH_STORE,
int nonce = 0)
{
vNew dhash_store (clntnode, dest, bid, data, exp, store_type, nonce, cb);
}
protected:
uint npending;
bool error;
dhash_stat status;
ptr<location> dest;
str data;
u_int32_t expiration;
blockID bid;
cbclistore_t cb;
dhash_ctype ctype;
int procno;
u_int nonce;
store_status store_type;
ptr<vnode> clntnode;
int num_retries;
timecb_t *dcb;
bool present;
ptr<bool> deleted;
dhash_store (ptr<vnode> clntnode, ptr<location> dest, blockID bid,
str _block, u_int32_t exp,
store_status store_type, int nonce,
cbclistore_t cb)
: npending (0),
error (false),
status (DHASH_OK),
dest (dest), data (_block), expiration (exp), bid (bid), cb (cb),
ctype (bid.ctype),
procno ((nonce > 0) ? DHASHPROC_FETCHCOMPLETE : DHASHPROC_STORE),
nonce (nonce),
store_type (store_type),
clntnode (clntnode), num_retries (0),
dcb (NULL),
present (false),
deleted (New refcounted<bool> (false))
{
start (deleted);
}
~dhash_store ()
{
if (dcb) timecb_remove (dcb);
}
void done (bool present);
void timed_out (ptr<bool> deleted);
void start (ptr<bool> deleted);
void finish (ptr<bool> deleted, ptr<dhash_storeres> res, int num, clnt_stat err);
void store (char *buf, size_t len, size_t off, int num);
};
#endif