o.back()->addr = ea;
}
+// -- chunk_info_t --
+
+void chunk_info_t::encode(bufferlist& bl) const
+{
+ ENCODE_START(1, 1, bl);
+ ::encode(offset, bl);
+ ::encode(length, bl);
+ ::encode(oid, bl);
+ ::encode(flags, bl);
+ ENCODE_FINISH(bl);
+}
+
+void chunk_info_t::decode(bufferlist::iterator& bl)
+{
+ DECODE_START(1, bl);
+ ::decode(offset, bl);
+ ::decode(length, bl);
+ ::decode(oid, bl);
+ ::decode(flags, bl);
+ DECODE_FINISH(bl);
+}
+
+void chunk_info_t::dump(Formatter *f) const
+{
+ f->dump_unsigned("length", length);
+ f->open_object_section("oid");
+ oid.dump(f);
+ f->close_section();
+ f->dump_unsigned("flags", flags);
+}
+
+ostream& operator<<(ostream& out, const chunk_info_t& ci)
+{
+ return out << "(len: " << ci.length << " oid: " << ci.oid
+ << " offset: " << ci.offset
+ << " flags: " << ci.get_flag_string(ci.flags) << ")";
+}
+
// -- object_manifest_t --
void object_manifest_t::encode(bufferlist& bl) const
case TYPE_REDIRECT:
::encode(redirect_target, bl);
break;
+ case TYPE_CHUNKED:
+ ::encode(chunk_map, bl);
+ break;
default:
ceph_abort();
}
case TYPE_REDIRECT:
::decode(redirect_target, bl);
break;
+ case TYPE_CHUNKED:
+ ::decode(chunk_map, bl);
+ break;
default:
ceph_abort();
}
void object_manifest_t::dump(Formatter *f) const
{
f->dump_unsigned("type", type);
- f->open_object_section("redirect_target");
- redirect_target.dump(f);
- f->close_section();
+ if (type == TYPE_REDIRECT) {
+ f->open_object_section("redirect_target");
+ redirect_target.dump(f);
+ f->close_section();
+ } else if (type == TYPE_CHUNKED) {
+ f->open_array_section("chunk_map");
+ for (auto& p : chunk_map) {
+ f->open_object_section("chunk");
+ f->dump_unsigned("offset", p.first);
+ p.second.dump(f);
+ f->close_section();
+ }
+ f->close_section();
+ }
}
void object_manifest_t::generate_test_instances(list<object_manifest_t*>& o)
ostream& operator<<(ostream& out, const object_manifest_t& om)
{
- return out << "type:" << om.type << " redirect_target:" << om.redirect_target;
+ out << "manifest(" << om.get_type_name();
+ if (om.is_redirect()) {
+ out << " " << om.redirect_target;
+ } else if (om.is_chunked()) {
+ out << " " << om.chunk_map;
+ }
+ out << ")";
+ return out;
}
// -- object_info_t --
<< " " << n.timeout << "s)";
}
+struct chunk_info_t {
+ enum {
+ FLAG_DIRTY = 1,
+ FLAG_MISSING = 2,
+ };
+ uint32_t offset;
+ uint32_t length;
+ hobject_t oid;
+ uint32_t flags; // FLAG_*
+
+ chunk_info_t() : length(0), flags(0) { }
+
+ static string get_flag_string(uint64_t flags) {
+ string r;
+ if (flags & FLAG_DIRTY) {
+ r += "|dirty";
+ }
+ if (flags & FLAG_MISSING) {
+ r += "|missing";
+ }
+ if (r.length())
+ return r.substr(1);
+ return r;
+ }
+ void encode(bufferlist &bl) const;
+ void decode(bufferlist::iterator &bl);
+ void dump(Formatter *f) const;
+ friend ostream& operator<<(ostream& out, const chunk_info_t& ci);
+};
+WRITE_CLASS_ENCODER(chunk_info_t)
+ostream& operator<<(ostream& out, const chunk_info_t& ci);
+
struct object_info_t;
struct object_manifest_t {
enum {
TYPE_NONE = 0,
- TYPE_REDIRECT = 1, // start with this
- TYPE_CHUNKED = 2, // do this later
+ TYPE_REDIRECT = 1,
+ TYPE_CHUNKED = 2,
};
uint8_t type; // redirect, chunked, ...
hobject_t redirect_target;
+ map <uint64_t, chunk_info_t> chunk_map;
object_manifest_t() : type(0) { }
object_manifest_t(uint8_t type, const hobject_t& redirect_target)
const char *get_type_name() const {
return get_type_name(type);
}
+ void clear() {
+ type = 0;
+ redirect_target = hobject_t();
+ chunk_map.clear();
+ }
static void generate_test_instances(list<object_manifest_t*>& o);
void encode(bufferlist &bl) const;
void decode(bufferlist::iterator &bl);