summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoic Dachary <loic@dachary.org>2013-08-28 15:46:34 +0200
committerLoic Dachary <loic@dachary.org>2013-09-09 23:28:37 +0200
commitb61369c80317738a4fd066ff45d11e7054ddc914 (patch)
treed49b30c4beeaa1b095c9934622ffc85a082c80d0
parent640f2f213f345bd35d57b38f14fbe5a9b38c11cf (diff)
downloadceph-b61369c80317738a4fd066ff45d11e7054ddc914.tar.gz
ErasureCodePlugin: plugin interface
When dynamically loaded, a plugin is expected to define int __erasure_code_init(char *plugin_name); When called, it is responsible for registering an ErasureCodePlugin derived object that provides a factory method from which the concrete implementation of the ErasureCodeInterface object can be generated: virtual int factory(const map<std::string,std::string> &parameters, ErasureCodeInterfaceRef *erasure_code) { *erasure_code = ErasureCodeInterfaceRef(new ErasureCodeExample(parameters)); return 0; } The plugin instance contains the library data member which is used to store the handle of the shared library. It is opaque to the plugin. http://tracker.ceph.com/issues/5878 refs #5878 Signed-off-by: Loic Dachary <loic@dachary.org>
-rw-r--r--src/osd/ErasureCodePlugin.h42
-rw-r--r--src/osd/Makefile.am1
2 files changed, 43 insertions, 0 deletions
diff --git a/src/osd/ErasureCodePlugin.h b/src/osd/ErasureCodePlugin.h
new file mode 100644
index 00000000000..4c210d698d1
--- /dev/null
+++ b/src/osd/ErasureCodePlugin.h
@@ -0,0 +1,42 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+/*
+ * Ceph - scalable distributed file system
+ *
+ * Copyright (C) 2013 Cloudwatt <libre.licensing@cloudwatt.com>
+ *
+ * Author: Loic Dachary <loic@dachary.org>
+ *
+ * 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_H
+#define CEPH_ERASURE_CODE_PLUGIN_H
+
+#include "ErasureCodeInterface.h"
+
+extern "C" {
+ int __erasure_code_init(char *plugin_name);
+}
+
+namespace ceph {
+
+ class ErasureCodePlugin {
+ public:
+ void *library;
+
+ ErasureCodePlugin() :
+ library(0) {}
+ virtual ~ErasureCodePlugin() {}
+
+ virtual int factory(const map<std::string,std::string> &parameters,
+ ErasureCodeInterfaceRef *erasure_code) = 0;
+ };
+
+}
+
+#endif
diff --git a/src/osd/Makefile.am b/src/osd/Makefile.am
index 6aaf8466670..382085f5f16 100644
--- a/src/osd/Makefile.am
+++ b/src/osd/Makefile.am
@@ -18,6 +18,7 @@ noinst_HEADERS += \
osd/Ager.h \
osd/ClassHandler.h \
osd/ErasureCodeInterface.h \
+ osd/ErasureCodePlugin.h \
osd/OSD.h \
osd/OSDCap.h \
osd/OSDMap.h \