Skip to content

Instantly share code, notes, and snippets.

@MahatiC
Last active July 1, 2020 05:33
Show Gist options
  • Save MahatiC/c3d6d95b75e18e3df69f5a30bfe081bf to your computer and use it in GitHub Desktop.
Save MahatiC/c3d6d95b75e18e3df69f5a30bfe081bf to your computer and use it in GitHub Desktop.
template <typename ImageCtxT>
class ParentWriteLog {
//will contain all the common code between SSDWriteLog and ReplicatedWriteLog classes
};
template <typename ImageCtxT>
class SSDWriteLog : public ParentWriteLog<ImageCtxT> {
public:
//SSD specific code
};
template <typename ImageCtxT>
class ReplicatedWriteLog : public ParentWriteLog<ImageCtxT> {
public:
//RWL or AEP specific code
};
template <typename ImageCtxT>
class WriteLogCache : public ImageCache<ImageCtxT> {
WriteLogCache::WriteLogCache() {
ParentWriteLog *obj = new ReplicatedWriteLog (OR) new SSDWriteLog //depending on build or config options
}
public:
//will give access to client AIO methods like:
void aio_read(Extents&& image_extents, ceph::bufferlist *bl,
int fadvise_flags, Context *on_finish) override;
}
//existing classes like Request (librbd/cache/rwl/Request) will be able to work with ParentWriteLog type
//as the class is templated like below and where necessary we can do template specialization
template <typename T>
class C_BlockIORequest : public Context {
public:
T &rwl; // This T currently is used with ReplicatedWriteLog
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment