ceph 通过自定义操作的方式来提供丰富的业务逻辑, 例如radosgw的业务逻辑
首先先通过下面方法注册到OSD中
72/* class registration api */
73extern int cls_register(const char *name, cls_handle_t *handle);
74extern int cls_unregister(cls_handle_t);
75
76-extern int cls_register_method(cls_handle_t hclass, const char *method, int flags,
77 cls_method_call_t class_call, cls_method_handle_t *handle);
78extern int cls_unregister_method(cls_method_handle_t handle);
79extern void cls_unregister_filter(cls_filter_handle_t handle);
...
137-extern int cls_register_cxx_method(cls_handle_t hclass, const char *method, int flags,
138 cls_method_cxx_call_t class_call, cls_method_handle_t *handle);
显然一个是用来注册c++ 方法的, 一个是注册c方法的
其中
hclass 是方法组
method 是方法名
flags 是这个方法会请求的锁类型
class_call 是定义的处理函数
handle 作为返回的句柄
客户端需要调用这些方法时
通过调用ObjectOperation::exec 输入方法组,方法名,参数
288 -class CEPH_RADOS_API ObjectOperation
289 {
290 public:
291 ObjectOperation();
292 virtual ~ObjectOperation();
293
294 size_t size();
295

Ceph系统允许通过自定义操作扩展其功能,如在radosgw中的应用。注册过程涉及C++和C方法,使用指定的处理函数。客户端通过ObjectOperation::exec调用方法。在线程中,OSD根据消息类型找到对应处理函数。锁机制包括读锁(CLS_METHOD_RD)和写锁(CLS_METHOD_WR),以保证对象操作的互斥性。ObjectContext::RWState实现了一种多读多写但读写互斥的锁行为,防止饥饿并管理等待队列,确保操作顺序,尤其是在高并发读写场景下。这种自定义操作和锁管理机制构成了Ceph众多业务的基础,如radosgw等。
最低0.47元/天 解锁文章
5052

被折叠的 条评论
为什么被折叠?



