diff --git a/GNUmakefile b/GNUmakefile index 77a2d77..5817d85 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -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 @@ -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 diff --git a/extent_client_cache.cc b/extent_client_cache.cc new file mode 100644 index 0000000..0caae53 --- /dev/null +++ b/extent_client_cache.cc @@ -0,0 +1,43 @@ +// RPC stubs for clients to talk to extent_server + +#include "extent_client_cache.h" +#include "extent_client.h" +#include +#include +#include +#include +#include + +// 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); +} + + diff --git a/extent_client_cache.h b/extent_client_cache.h new file mode 100644 index 0000000..40d900b --- /dev/null +++ b/extent_client_cache.h @@ -0,0 +1,28 @@ +// extent client interface. + +#ifndef extent_client_cache_h +#define extent_client_cache_h + +#include +#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 + diff --git a/yfs_client.cc b/yfs_client.cc index fd9d0a9..2694416 100644 --- a/yfs_client.cc +++ b/yfs_client.cc @@ -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 #include @@ -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 ?? diff --git a/yfs_client.h b/yfs_client.h index 08527b5..23461f3 100644 --- a/yfs_client.h +++ b/yfs_client.h @@ -2,8 +2,7 @@ #define yfs_client_h #include -//#include "yfs_protocol.h" -#include "extent_client.h" +#include "extent_client_cache.h" #include #include "lock_protocol.h" #include "lock_client.h" @@ -11,7 +10,7 @@ class yfs_client { - extent_client *ec; + extent_client_cache *ec; lock_client *lc = NULL; public: