Skip to content

Commit

Permalink
created extent_client_cache as a simple proxy for extent_client
Browse files Browse the repository at this point in the history
  • Loading branch information
phlalx committed May 21, 2017
1 parent 2221c8d commit fbe18d3
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 7 deletions.
4 changes: 2 additions & 2 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ hfiles1=rpc/fifo.h rpc/connection.h rpc/rpc.h rpc/marshall.h rpc/method_thread.h
rpc/thr_pool.h rpc/pollmgr.h rpc/jsl_log.h rpc/slock.h rpc/rpctest.cc\
lock_protocol.h lock_server.h lock_client.h gettime.h gettime.cc lang/verify.h \
lang/algorithm.h
hfiles2=yfs_client.h extent_client.h extent_protocol.h extent_server.h
hfiles2=yfs_client.h extent_client.h extent_protocol.h extent_server.h extent_client_cache.h
hfiles3=lock_client_cache.h lock_server_cache.h handle.h tprintf.h
hfiles4=log.h rsm.h rsm_protocol.h config.h paxos.h paxos_protocol.h rsm_state_transfer.h rsmtest_client.h tprintf.h
hfiles5=rsm_state_transfer.h rsm_client.h
Expand Down Expand Up @@ -86,7 +86,7 @@ endif

lock_server : $(patsubst %.cc,%.o,$(lock_server)) rpc/librpc.a

yfs_client=yfs_client.cc extent_client.cc fuse.cc
yfs_client=yfs_client.cc extent_client_cache.cc fuse.cc extent_client.cc
ifeq ($(LAB3GE),1)
yfs_client += lock_client.cc
endif
Expand Down
43 changes: 43 additions & 0 deletions extent_client_cache.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// RPC stubs for clients to talk to extent_server

#include "extent_client_cache.h"
#include "extent_client.h"
#include <sstream>
#include <iostream>
#include <stdio.h>
#include <unistd.h>
#include <time.h>

// The calls assume that the caller holds a lock on the extent

extent_client_cache::extent_client_cache(std::string dst)
{
ec = new extent_client(dst);
}

extent_protocol::status
extent_client_cache::get(extent_protocol::extentid_t eid, std::string &buf)
{
return ec->get(eid, buf);
}

extent_protocol::status
extent_client_cache::getattr(extent_protocol::extentid_t eid,
extent_protocol::attr &attr)
{
return ec->getattr(eid, attr);
}

extent_protocol::status
extent_client_cache::put(extent_protocol::extentid_t eid, std::string buf)
{
return ec->put(eid, buf);
}

extent_protocol::status
extent_client_cache::remove(extent_protocol::extentid_t eid)
{
return ec->remove(eid);
}


28 changes: 28 additions & 0 deletions extent_client_cache.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// extent client interface.

#ifndef extent_client_cache_h
#define extent_client_cache_h

#include <string>
#include "extent_protocol.h"
#include "extent_client.h"
#include "rpc.h"

class extent_client_cache {

private:
extent_client *ec;

public:
extent_client_cache(std::string dst);

extent_protocol::status get(extent_protocol::extentid_t eid,
std::string &buf);
extent_protocol::status getattr(extent_protocol::extentid_t eid,
extent_protocol::attr &a);
extent_protocol::status put(extent_protocol::extentid_t eid, std::string buf);
extent_protocol::status remove(extent_protocol::extentid_t eid);
};

#endif

4 changes: 2 additions & 2 deletions yfs_client.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// yfs client. implements FS operations using extent and lock server
#include "yfs_client.h"
#include "extent_client.h"
#include "extent_client_cache.h"
#include "lock_client_cache.h"
#include <sstream>
#include <iostream>
Expand Down Expand Up @@ -28,7 +28,7 @@ void yfs_client::releaseLock(inum i) {
}

yfs_client::yfs_client(std::string extent_dst, std::string lock_dst) {
ec = new extent_client(extent_dst);
ec = new extent_client_cache(extent_dst);
lc = new lock_client_cache(lock_dst);
srand (time(NULL)); // TODO déjà fait dans fuse ??

Expand Down
5 changes: 2 additions & 3 deletions yfs_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@
#define yfs_client_h

#include <string>
//#include "yfs_protocol.h"
#include "extent_client.h"
#include "extent_client_cache.h"
#include <vector>
#include "lock_protocol.h"
#include "lock_client.h"
#include "jsl_log.h"

class yfs_client {

extent_client *ec;
extent_client_cache *ec;
lock_client *lc = NULL;

public:
Expand Down

0 comments on commit fbe18d3

Please sign in to comment.