diff options
author | Ji Chen <insomnia@139.com> | 2015-10-21 04:10:39 +0200 |
---|---|---|
committer | Ji Chen <insomnia@139.com> | 2015-12-08 04:22:26 +0100 |
commit | 7d48f62f5c86913d8f00b44d46a04a52d338907c (patch) | |
tree | d1e58cfde73ed5e186f496ba031c5e918b8a15b3 /src/cls/rgw/cls_rgw_client.cc | |
parent | deb,rpm: package buffer_fwd.h (diff) | |
download | ceph-7d48f62f5c86913d8f00b44d46a04a52d338907c.tar.xz ceph-7d48f62f5c86913d8f00b44d46a04a52d338907c.zip |
LifeCycle feature
As same as amazon S3 interface,"PUT Bucket lifecycle" and
"DELETE Bucket lifecycle" have been implemented,
"GET Bucket lifecycle" not realized yet as S3cmd has not
realize it also.
The feature`s main point is to remove expire file per day.
Files transfer from hot layer to cold layer is not supported.
ToDo:Maybe to transfer from replicate pool to EC pool or
from ssd to sata pool will be valuable.
Now put all buckets which should do lifecycle into shard
objects in .rgw.lc pool.
lifecycle config file format:
<LifecycleConfiguration>
<Rule>
<ID>sample-rule</ID>
<Prefix></Prefix>
<Status>enable</Status>
<Expiration>
<Days>1</Days>
</Expiration>
</Rule>
</LifecycleConfiguration>
Signed-off-by: Ji Chen <insomnia@139.com>
Diffstat (limited to 'src/cls/rgw/cls_rgw_client.cc')
-rw-r--r-- | src/cls/rgw/cls_rgw_client.cc | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/src/cls/rgw/cls_rgw_client.cc b/src/cls/rgw/cls_rgw_client.cc index e6ac56b822c..8fcbe4db262 100644 --- a/src/cls/rgw/cls_rgw_client.cc +++ b/src/cls/rgw/cls_rgw_client.cc @@ -627,3 +627,93 @@ void cls_rgw_gc_remove(librados::ObjectWriteOperation& op, const list<string>& t ::encode(call, in); op.exec("rgw", "gc_remove", in); } + +int cls_rgw_lc_get_head(IoCtx& io_ctx, string& oid, cls_rgw_lc_obj_head& head) +{ + bufferlist in, out; + int r = io_ctx.exec(oid, "rgw", "lc_get_head", in, out); + if (r < 0) + return r; + + cls_rgw_lc_get_head_ret ret; + try { + bufferlist::iterator iter = out.begin(); + ::decode(ret, iter); + } catch (buffer::error& err) { + return -EIO; + } + head = ret.head; + + return r; +} + +int cls_rgw_lc_put_head(IoCtx& io_ctx, string& oid, cls_rgw_lc_obj_head& head) +{ + bufferlist in, out; + cls_rgw_lc_put_head_op call; + call.head = head; + ::encode(call, in); + int r = io_ctx.exec(oid, "rgw", "lc_put_head", in, out); + return r; +} + +int cls_rgw_lc_get_entry(IoCtx& io_ctx, string& oid, string& marker, pair<string, int>& entry) +{ + bufferlist in, out; + cls_rgw_lc_get_entry_op call; + call.marker = marker; + ::encode(call, in); + int r = io_ctx.exec(oid, "rgw", "lc_get_entry", in, out); + if (r < 0) + return r; + + cls_rgw_lc_get_entry_ret ret; + try { + bufferlist::iterator iter = out.begin(); + ::decode(ret, iter); + } catch (buffer::error& err) { + return -EIO; + } + entry = ret.entry; + + return r; +} + +int cls_rgw_lc_rm_entry(IoCtx& io_ctx, string& oid, pair<string, int>& entry) +{ + bufferlist in, out; + cls_rgw_lc_rm_entry_op call; + call.entry = entry; + ::encode(call, in); + int r = io_ctx.exec(oid, "rgw", "lc_rm_entry", in, out); + return r; +} + +int cls_rgw_lc_set_entry(IoCtx& io_ctx, string& oid, pair<string, int>& entry) +{ + bufferlist in, out; + cls_rgw_lc_rm_entry_op call; + call.entry = entry; + ::encode(call, in); + int r = io_ctx.exec(oid, "rgw", "lc_set_entry", in, out); + return r; +} + +int cls_rgw_lc_list(IoCtx& io_ctx, string& oid, map<string, int>& entries) +{ + bufferlist in, out; + int r = io_ctx.exec(oid, "rgw", "lc_list_entry", in, out); + if (r < 0) + return r; + + cls_rgw_lc_list_entry_ret ret; + try { + bufferlist::iterator iter = out.begin(); + ::decode(ret, iter); + } catch (buffer::error& err) { + return -EIO; + } + entries.insert(ret.entries.begin(),ret.entries.end()); + + return r; +} |