mirror of
https://github.com/ceph/ceph
synced 2025-02-28 05:22:19 +00:00
*** empty log message ***
git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@22 29311d96-e01e-0410-9327-a35deaab8ce9
This commit is contained in:
parent
fc7e45c772
commit
5345042e7e
@ -37,6 +37,15 @@ class ClNode : public LRUObject {
|
||||
}
|
||||
}
|
||||
|
||||
void full_path(string& p) {
|
||||
if (parent)
|
||||
parent->full_path(p);
|
||||
if (p.length()) {
|
||||
p.append("/");
|
||||
}
|
||||
p.append(ref_name);
|
||||
}
|
||||
|
||||
void link(string name, ClNode* node) {
|
||||
if (children.size() == 0)
|
||||
get();
|
||||
|
@ -11,6 +11,8 @@
|
||||
#include "../messages/MClientRequest.h"
|
||||
#include "../messages/MClientReply.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
Client::Client(int id, Messenger *m)
|
||||
{
|
||||
whoami = id;
|
||||
@ -49,7 +51,7 @@ void Client::dispatch(Message *m)
|
||||
assim_reply((MClientReply*)m);
|
||||
delete m;
|
||||
|
||||
//issue_request();
|
||||
issue_request();
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -81,16 +83,81 @@ void Client::assim_reply(MClientReply *r)
|
||||
cur->ino = r->trace_ino[i];
|
||||
cur->dist = r->trace_dist[i];
|
||||
}
|
||||
|
||||
cwd = cur;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Client::issue_request()
|
||||
{
|
||||
if (!cwd) cwd = root;
|
||||
string p = "";
|
||||
if (cwd) {
|
||||
|
||||
if (rand() % 10 > 5) {
|
||||
// descend
|
||||
p = "/CVS/Root";
|
||||
} else {
|
||||
// ascend
|
||||
if (cwd->parent)
|
||||
cwd = cwd->parent;
|
||||
cwd->full_path(p);
|
||||
}
|
||||
}
|
||||
|
||||
send_request(p); // root, if !cwd
|
||||
}
|
||||
|
||||
void Client::send_request(string& p)
|
||||
{
|
||||
|
||||
MClientRequest *req = new MClientRequest(tid++, MDS_OP_STAT);
|
||||
req->ino = 1;
|
||||
req->path = "/CVS/Root";
|
||||
req->path = p;
|
||||
|
||||
// direct it
|
||||
int mds = 0;
|
||||
|
||||
if (root) {
|
||||
int off = 0;
|
||||
ClNode *cur = root;
|
||||
while (off < req->path.length()) {
|
||||
int nextslash = req->path.find('/', off);
|
||||
if (nextslash == off) {
|
||||
off++;
|
||||
continue;
|
||||
}
|
||||
if (nextslash < 0)
|
||||
nextslash = req->path.length(); // no more slashes
|
||||
|
||||
string dname = req->path.substr(off,nextslash-off);
|
||||
cout << "//path segment is " << dname << endl;
|
||||
|
||||
ClNode *n = cur->lookup(dname);
|
||||
if (n) {
|
||||
cur = n;
|
||||
off = nextslash+1;
|
||||
} else {
|
||||
cout << " don't have it. " << endl;
|
||||
int b = cur->dist.size();
|
||||
//cout << " b is " << b << endl;
|
||||
for (int i=0; i<b; i++) {
|
||||
if (cur->dist[i]) {
|
||||
mds = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// we need the root inode
|
||||
mds = 0;
|
||||
}
|
||||
|
||||
cout << "client" << whoami << " sending req to mds " << mds << " for " << req->path << endl;
|
||||
messenger->send_message(req,
|
||||
MSG_ADDR_MDS(0), MDS_PORT_SERVER,
|
||||
MSG_ADDR_MDS(mds), MDS_PORT_SERVER,
|
||||
0);
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ class Client : public Dispatcher {
|
||||
virtual void assim_reply(MClientReply*);
|
||||
virtual void issue_request();
|
||||
|
||||
virtual void send_request(string& p);
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user