Permalink
Browse files

Added movement of files betn nodes

  • Loading branch information...
1 parent c55184e commit e9133aa870cf50576b8df483cda1358614b745fc @sghike committed with Wonho Choi Apr 29, 2012
Showing with 17 additions and 0 deletions.
  1. +17 −0 mp2/Node_server.cpp
View
@@ -352,6 +352,23 @@ class NodeHandler : virtual public NodeIf {
if (me->predecessor != n) {
me->predecessor = n;
cout << "node= " << me->id << ": updated predecessor= " << n.id << endl;
+ map<int, _FILE> offload;
+ map<int, _FILE>::iterator it;
+ for (it = me->keys_table.begin(); it != me->keys_table.end(); it++) {
+ if (it->first <= me->predecessor.id) {
+ offload.insert(*it);
+ }
+ }
+ boost::shared_ptr<TSocket> socket(new TSocket("localhost", me->predecessor.port));
+ boost::shared_ptr<TTransport> transport(new TBufferedTransport(socket));
+ boost::shared_ptr<TProtocol> protocol(new TBinaryProtocol(transport));
+ NodeClient client(protocol);
+ transport->open();
+ bool ret = client.accept_files(offload);
+ transport->close();
+ if (!ret) {
+ cout << "Transfer of files between nodes " << me->id << " and " << me->predecessor.id << " failed." << endl;
+ }
}
}
if (me->predecessor.id != -1) {

0 comments on commit e9133aa

Please sign in to comment.