2 * Ceph - scalable distributed file system
4 * Copyright (C) 2014 CERN (Switzerland)
6 * Author: Andreas-Joachim Peters <Andreas.Joachim.Peters@cern.ch>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
17 * @file ErasureCodePluginIsa.cc
19 * @brief Erasure Code Plug-in class wrapping the INTEL ISA-L library
21 * The factory plug-in class allows to call individual encoding techniques.
22 * The INTEL ISA-L library provides two pre-defined encoding matrices
23 * (cauchy, reed_sol_van = default).
26 // -----------------------------------------------------------------------------
28 #include "common/debug.h"
29 #include "ErasureCodePluginIsa.h"
30 #include "ErasureCodeIsa.h"
31 // -----------------------------------------------------------------------------
33 int ErasureCodePluginIsa::factory(const std::string
&directory
,
34 ErasureCodeProfile
&profile
,
35 ErasureCodeInterfaceRef
*erasure_code
,
38 ErasureCodeIsa
*interface
;
40 if (profile
.find("technique") == profile
.end())
41 profile
["technique"] = "reed_sol_van";
42 t
= profile
.find("technique")->second
;
43 if ((t
== "reed_sol_van")) {
44 interface
= new ErasureCodeIsaDefault(tcache
,
45 ErasureCodeIsaDefault::kVandermonde
);
47 if ((t
== "cauchy")) {
48 interface
= new ErasureCodeIsaDefault(tcache
,
49 ErasureCodeIsaDefault::kCauchy
);
51 *ss
<< "technique=" << t
<< " is not a valid coding technique. "
52 << " Choose one of the following: "
54 << "cauchy" << std::endl
;
59 int r
= interface
->init(profile
, ss
);
64 *erasure_code
= ErasureCodeInterfaceRef(interface
);
68 #ifndef BUILDING_FOR_EMBEDDED
70 // -----------------------------------------------------------------------------
72 const char *__erasure_code_version()
74 return CEPH_GIT_NICE_VER
;
77 // -----------------------------------------------------------------------------
79 int __erasure_code_init(char *plugin_name
, char *directory
)
81 ErasureCodePluginRegistry
&instance
= ErasureCodePluginRegistry::instance();
83 return instance
.add(plugin_name
, new ErasureCodePluginIsa());