-
Notifications
You must be signed in to change notification settings - Fork 0
/
testdrive_migrate.cc
90 lines (80 loc) · 2.46 KB
/
testdrive_migrate.cc
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
85
86
87
88
89
90
#include "testdrive_migrate.h"
#include <unistd.h>
#include <thread>
#include <sstream>
#include "ib.h"
#include "ib_container.h"
#include "modify_qp.h"
#include "debug.h"
#include "mig.h"
#include "allocator.h"
#include "control.h"
#include "json.hpp"
using json = nlohmann::json;
void testdrive_migrate(typename
slope::control::RdmaControlPlane<td_mig_type>::ptr control_plane) {
if(control_plane->self_name() == control_plane->cluster_nodes().front()) {
debout("start testdrive_migrate");
slope::mig_ptr<td_mig_type> ptr;
debout("finished creating a vector of int of size 0");
{
debout("acquiring a context for adding elements to the vector");
auto lock = ptr.create_context();
ptr.get()->resize(10);
// for (int i = 0; i < 10; i++) {
// ptr.get()->push_back(i);
// }
}
std::iota(ptr.get()->begin(), ptr.get()->end(), 0);
deb(*ptr.get());
for (auto it : ptr.get_chunks()) {
std::stringstream out;
out << std::showbase << std::internal << std::setfill('0')
<< " @" << std::hex << std::setw(16) << it.first;
out << " " << it.second;
debout(out.str());
}
debout("vector contents:");
deb(*ptr.get());
debout("start the migration");
deb(control_plane->cluster_nodes());
// control_plane->simple_send();
auto operation =
control_plane->init_migration(control_plane->cluster_nodes()[1], ptr);
// use ptr without alloc/dealloc
while (true) {
for (unsigned int i = 1; i < 1e6; i++) {
(*ptr.get())[0] = 10;
}
// std::cout << "will try commit" << std::endl;
// TODO: fix try_commit
// if (operation->try_commit()) {
// break;
// }
}
operation->collect();
} else {
// control_plane->simple_recv();
while(true) {
auto migrated_ptr = control_plane->poll_migrate();
debout("null");
if (migrated_ptr.get() != nullptr) {
debout("returned");
// deb((*migrated_ptr.get()));
for (auto it : migrated_ptr.get_chunks()) {
std::stringstream out;
out << std::showbase << std::internal << std::setfill('0')
<< " @" << std::hex << std::setw(16) << it.first;
out << " " << it.second;
debout(out.str());
}
debout("vector contents:");
deb(*migrated_ptr.get());
deb((*migrated_ptr.get()).size());
migrated_ptr.collect_pages();
break;
}
}
debout("done");
}
}