From: Bassam Tabbara Date: Mon, 19 Sep 2016 18:19:37 +0000 (-0700) Subject: erasure-code: Move the EC factory code into separate header files X-Git-Tag: v11.0.1~44^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2e333bdbc4a8119391124e52a2fb4931aef8e479;p=ceph.git erasure-code: Move the EC factory code into separate header files This helps the EC factories be invokable directly for testing and other uses. Signed-off-by: Bassam Tabbara --- diff --git a/src/erasure-code/isa/ErasureCodePluginIsa.cc b/src/erasure-code/isa/ErasureCodePluginIsa.cc index 611d76b07706..c4c37b1bf1d0 100644 --- a/src/erasure-code/isa/ErasureCodePluginIsa.cc +++ b/src/erasure-code/isa/ErasureCodePluginIsa.cc @@ -26,20 +26,15 @@ // ----------------------------------------------------------------------------- #include "ceph_ver.h" #include "common/debug.h" -#include "erasure-code/ErasureCodePlugin.h" -#include "ErasureCodeIsaTableCache.h" +#include "ErasureCodePluginIsa.h" #include "ErasureCodeIsa.h" // ----------------------------------------------------------------------------- -class ErasureCodePluginIsa : public ErasureCodePlugin { -public: - ErasureCodeIsaTableCache tcache; - - virtual int factory(const std::string &directory, +int ErasureCodePluginIsa::factory(const std::string &directory, ErasureCodeProfile &profile, ErasureCodeInterfaceRef *erasure_code, ostream *ss) - { +{ ErasureCodeIsa *interface; std::string t; if (profile.find("technique") == profile.end()) @@ -68,8 +63,7 @@ public: } *erasure_code = ErasureCodeInterfaceRef(interface); return 0; - } -}; +} // ----------------------------------------------------------------------------- diff --git a/src/erasure-code/isa/ErasureCodePluginIsa.h b/src/erasure-code/isa/ErasureCodePluginIsa.h new file mode 100644 index 000000000000..7ed5aed6645a --- /dev/null +++ b/src/erasure-code/isa/ErasureCodePluginIsa.h @@ -0,0 +1,34 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab +/* + * Ceph distributed storage system + * + * Copyright (C) 2014 Cloudwatt + * Copyright (C) 2014 Red Hat + * + * Author: Loic Dachary + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + */ + +#ifndef CEPH_ERASURE_CODE_PLUGIN_ISA_H +#define CEPH_ERASURE_CODE_PLUGIN_ISA_H + +#include "erasure-code/ErasureCodePlugin.h" +#include "ErasureCodeIsaTableCache.h" + +class ErasureCodePluginIsa : public ErasureCodePlugin { +public: + ErasureCodeIsaTableCache tcache; + + virtual int factory(const std::string &directory, + ErasureCodeProfile &profile, + ErasureCodeInterfaceRef *erasure_code, + ostream *ss); +}; + +#endif diff --git a/src/erasure-code/jerasure/ErasureCodePluginJerasure.cc b/src/erasure-code/jerasure/ErasureCodePluginJerasure.cc index 3ae4366635b5..6029eef4ea9d 100644 --- a/src/erasure-code/jerasure/ErasureCodePluginJerasure.cc +++ b/src/erasure-code/jerasure/ErasureCodePluginJerasure.cc @@ -17,8 +17,8 @@ #include "ceph_ver.h" #include "common/debug.h" -#include "erasure-code/ErasureCodePlugin.h" #include "ErasureCodeJerasure.h" +#include "ErasureCodePluginJerasure.h" #include "jerasure_init.h" #define dout_subsys ceph_subsys_osd @@ -30,9 +30,7 @@ static ostream& _prefix(std::ostream* _dout) return *_dout << "ErasureCodePluginJerasure: "; } -class ErasureCodePluginJerasure : public ErasureCodePlugin { -public: - virtual int factory(const std::string& directory, +int ErasureCodePluginJerasure::factory(const std::string& directory, ErasureCodeProfile &profile, ErasureCodeInterfaceRef *erasure_code, ostream *ss) { @@ -70,8 +68,7 @@ public: } *erasure_code = ErasureCodeInterfaceRef(interface); return 0; - } -}; +} const char *__erasure_code_version() { return CEPH_GIT_NICE_VER; } diff --git a/src/erasure-code/jerasure/ErasureCodePluginJerasure.h b/src/erasure-code/jerasure/ErasureCodePluginJerasure.h new file mode 100644 index 000000000000..b52da8b5b273 --- /dev/null +++ b/src/erasure-code/jerasure/ErasureCodePluginJerasure.h @@ -0,0 +1,31 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab +/* + * Ceph distributed storage system + * + * Copyright (C) 2014 Cloudwatt + * Copyright (C) 2014 Red Hat + * + * Author: Loic Dachary + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + */ + +#ifndef CEPH_ERASURE_CODE_PLUGIN_JERASURE_H +#define CEPH_ERASURE_CODE_PLUGIN_JERASURE_H + +#include "erasure-code/ErasureCodePlugin.h" + +class ErasureCodePluginJerasure : public ErasureCodePlugin { +public: + virtual int factory(const std::string& directory, + ErasureCodeProfile &profile, + ErasureCodeInterfaceRef *erasure_code, + ostream *ss); +}; + +#endif diff --git a/src/erasure-code/lrc/ErasureCodePluginLrc.cc b/src/erasure-code/lrc/ErasureCodePluginLrc.cc index 5f22cc6bf907..003b3dc19dde 100644 --- a/src/erasure-code/lrc/ErasureCodePluginLrc.cc +++ b/src/erasure-code/lrc/ErasureCodePluginLrc.cc @@ -17,7 +17,7 @@ #include "ceph_ver.h" #include "common/debug.h" -#include "erasure-code/ErasureCodePlugin.h" +#include "ErasureCodePluginLrc.h" #include "ErasureCodeLrc.h" // re-include our assert @@ -27,9 +27,7 @@ #undef dout_prefix #define dout_prefix _prefix(_dout) -class ErasureCodePluginLrc : public ErasureCodePlugin { -public: - virtual int factory(const std::string &directory, +int ErasureCodePluginLrc::factory(const std::string &directory, ErasureCodeProfile &profile, ErasureCodeInterfaceRef *erasure_code, ostream *ss) { @@ -42,7 +40,6 @@ public: } *erasure_code = ErasureCodeInterfaceRef(interface); return 0; - } }; const char *__erasure_code_version() { return CEPH_GIT_NICE_VER; } diff --git a/src/erasure-code/lrc/ErasureCodePluginLrc.h b/src/erasure-code/lrc/ErasureCodePluginLrc.h new file mode 100644 index 000000000000..a0dbe74e9daf --- /dev/null +++ b/src/erasure-code/lrc/ErasureCodePluginLrc.h @@ -0,0 +1,31 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab +/* + * Ceph distributed storage system + * + * Copyright (C) 2014 Cloudwatt + * Copyright (C) 2014 Red Hat + * + * Author: Loic Dachary + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + */ + +#ifndef CEPH_ERASURE_CODE_PLUGIN_LRC_H +#define CEPH_ERASURE_CODE_PLUGIN_LRC_H + +#include "erasure-code/ErasureCodePlugin.h" + +class ErasureCodePluginLrc : public ErasureCodePlugin { +public: + virtual int factory(const std::string &directory, + ErasureCodeProfile &profile, + ErasureCodeInterfaceRef *erasure_code, + ostream *ss); +}; + +#endif diff --git a/src/erasure-code/shec/ErasureCodePluginShec.cc b/src/erasure-code/shec/ErasureCodePluginShec.cc index 7d242b4f7e01..d31777e50d63 100644 --- a/src/erasure-code/shec/ErasureCodePluginShec.cc +++ b/src/erasure-code/shec/ErasureCodePluginShec.cc @@ -20,7 +20,7 @@ #include "ceph_ver.h" #include "common/debug.h" -#include "erasure-code/ErasureCodePlugin.h" +#include "ErasureCodePluginShec.h" #include "ErasureCodeShecTableCache.h" #include "ErasureCodeShec.h" #include "jerasure_init.h" @@ -34,11 +34,7 @@ static ostream& _prefix(std::ostream* _dout) return *_dout << "ErasureCodePluginShec: "; } -class ErasureCodePluginShec : public ErasureCodePlugin { -public: - ErasureCodeShecTableCache tcache; - - virtual int factory(const std::string &directory, +int ErasureCodePluginShec::factory(const std::string &directory, ErasureCodeProfile &profile, ErasureCodeInterfaceRef *erasure_code, ostream *ss) { @@ -68,8 +64,7 @@ public: dout(10) << "ErasureCodePluginShec: factory() completed" << dendl; return 0; - } -}; +} const char *__erasure_code_version() { return CEPH_GIT_NICE_VER; } diff --git a/src/erasure-code/shec/ErasureCodePluginShec.h b/src/erasure-code/shec/ErasureCodePluginShec.h new file mode 100644 index 000000000000..fa642974ea0f --- /dev/null +++ b/src/erasure-code/shec/ErasureCodePluginShec.h @@ -0,0 +1,34 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab +/* + * Ceph distributed storage system + * + * Copyright (C) 2014 Cloudwatt + * Copyright (C) 2014 Red Hat + * + * Author: Loic Dachary + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + */ + +#ifndef CEPH_ERASURE_CODE_PLUGIN_SHEC_H +#define CEPH_ERASURE_CODE_PLUGIN_SHEC_H + +#include "ErasureCodeShecTableCache.h" +#include "erasure-code/ErasureCodePlugin.h" + +class ErasureCodePluginShec : public ErasureCodePlugin { +public: + ErasureCodeShecTableCache tcache; + + virtual int factory(const std::string &directory, + ErasureCodeProfile &profile, + ErasureCodeInterfaceRef *erasure_code, + ostream *ss); +}; + +#endif