Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added movement of files betn nodes

  • Loading branch information...
commit e9133aa870cf50576b8df483cda1358614b745fc 1 parent c55184e
@sghike authored Wonho Choi committed
Showing with 17 additions and 0 deletions.
  1. +17 −0 mp2/Node_server.cpp
View
17 mp2/Node_server.cpp
@@ -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) {
Please sign in to comment.
Something went wrong with that request. Please try again.