mirror of
https://github.com/ceph/ceph
synced 2025-02-21 01:47:25 +00:00
erasure-code: implement get_profile for every plugins
The ErasureCode::init function is implemented to store the profile and is called by the init method of each plugin. The ErasureCode::get_profile function is implemented to return the profile that was stored. A specialized ostream<< function is implemented to facilitate the display of the profile. Signed-off-by: Loic Dachary <ldachary@redhat.com>
This commit is contained in:
parent
0f2c556796
commit
77e5330da1
@ -33,9 +33,19 @@ namespace ceph {
|
||||
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();
|
||||
}
|
||||
|
@ -153,6 +153,20 @@ using namespace std;
|
||||
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() {}
|
||||
|
@ -80,6 +80,7 @@ ErasureCodeIsa::init(ErasureCodeProfile &profile, ostream *ss)
|
||||
if (err)
|
||||
return err;
|
||||
prepare();
|
||||
ErasureCode::init(profile, ss);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
@ -67,6 +67,7 @@ int ErasureCodeJerasure::init(ErasureCodeProfile& profile, ostream *ss)
|
||||
if (err)
|
||||
return err;
|
||||
prepare();
|
||||
ErasureCode::init(profile, ss);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
@ -534,6 +534,7 @@ int ErasureCodeLrc::init(ErasureCodeProfile &profile,
|
||||
profile.erase("mapping");
|
||||
profile.erase("layers");
|
||||
}
|
||||
ErasureCode::init(profile, ss);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -68,6 +68,7 @@ int ErasureCodeShec::init(ErasureCodeProfile &profile,
|
||||
if (err)
|
||||
return err;
|
||||
prepare();
|
||||
ErasureCode::init(profile, ss);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
@ -39,10 +39,6 @@ class ErasureCodeExample : public ErasureCode {
|
||||
public:
|
||||
virtual ~ErasureCodeExample() {}
|
||||
|
||||
virtual int init(ErasureCodeProfile &profile, ostream *ss) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual int create_ruleset(const string &name,
|
||||
CrushWrapper &crush,
|
||||
ostream *ss) const {
|
||||
|
@ -28,6 +28,7 @@ public:
|
||||
ostream *ss)
|
||||
{
|
||||
*erasure_code = ErasureCodeInterfaceRef(new ErasureCodeExample());
|
||||
(*erasure_code)->init(profile, ss);
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
@ -35,7 +35,9 @@ ceph_erasure_code_LDADD += -ldl
|
||||
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}
|
||||
|
Loading…
Reference in New Issue
Block a user