static const unsigned SIMD_ALIGN;
vector<int> chunk_mapping;
+ ErasureCodeProfile _profile;
virtual ~ErasureCode() {}
+ virtual int init(ErasureCodeProfile &profile, ostream *ss) {
+ _profile = profile;
+ return 0;
+ }
+
+ virtual const ErasureCodeProfile &get_profile() const {
+ return _profile;
+ }
+
virtual unsigned int get_coding_chunk_count() const {
return get_chunk_count() - get_data_chunk_count();
}
namespace ceph {
typedef map<std::string,std::string> ErasureCodeProfile;
+
+ inline ostream& operator<<(ostream& out, const ErasureCodeProfile& profile) {
+ out << "{";
+ for (ErasureCodeProfile::const_iterator it = profile.begin();
+ it != profile.end();
+ ++it) {
+ if (it != profile.begin()) out << ",";
+ out << it->first << "=" << it->second;
+ }
+ out << "}";
+ return out;
+ }
+
+
class ErasureCodeInterface {
public:
virtual ~ErasureCodeInterface() {}
if (err)
return err;
prepare();
+ ErasureCode::init(profile, ss);
return err;
}
if (err)
return err;
prepare();
+ ErasureCode::init(profile, ss);
return err;
}
profile.erase("mapping");
profile.erase("layers");
}
+ ErasureCode::init(profile, ss);
return 0;
}
if (err)
return err;
prepare();
+ ErasureCode::init(profile, ss);
return err;
}
public:
virtual ~ErasureCodeExample() {}
- virtual int init(ErasureCodeProfile &profile, ostream *ss) {
- return 0;
- }
-
virtual int create_ruleset(const string &name,
CrushWrapper &crush,
ostream *ss) const {
ostream *ss)
{
*erasure_code = ErasureCodeInterfaceRef(new ErasureCodeExample());
+ (*erasure_code)->init(profile, ss);
return 0;
}
};
endif
bin_DEBUGPROGRAMS += ceph_erasure_code
-libec_example_la_SOURCES = test/erasure-code/ErasureCodePluginExample.cc
+libec_example_la_SOURCES = \
+ erasure-code/ErasureCode.cc \
+ test/erasure-code/ErasureCodePluginExample.cc
test/erasure-code/ErasureCodePluginExample.cc: ./ceph_ver.h
libec_example_la_CFLAGS = ${AM_CFLAGS}
libec_example_la_CXXFLAGS= ${AM_CXXFLAGS}