]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
compressor/zstd: add zstd to embedded ceph 13159/head
authorBassam Tabbara <bassam.tabbara@quantum.com>
Fri, 27 Jan 2017 20:42:28 +0000 (12:42 -0800)
committerBassam Tabbara <bassam.tabbara@quantum.com>
Fri, 27 Jan 2017 20:42:28 +0000 (12:42 -0800)
Signed-off-by: Bassam Tabbara <bassam.tabbara@quantum.com>
src/compressor/zstd/CompressionPluginZstd.cc
src/compressor/zstd/CompressionPluginZstd.h [new file with mode: 0644]
src/libcephd/libcephd.cc
src/test/libcephd/CMakeLists.txt

index 2170dbd7e6caa7fa808a0876a67cc0b40991f845..321b3dd96f62be6d9c2e5d5832f00208d74bf664 100644 (file)
  *
  */
 
-#include <ostream>
-
-// -----------------------------------------------------------------------------
+#include "acconfig.h"
 #include "ceph_ver.h"
-#include "compressor/CompressionPlugin.h"
-#include "ZstdCompressor.h"
-// -----------------------------------------------------------------------------
-
-class CompressionPluginZstd : public CompressionPlugin {
+#include "CompressionPluginZstd.h"
 
-public:
-
-  explicit CompressionPluginZstd(CephContext* cct) : CompressionPlugin(cct)
-  {}
-
-  virtual int factory(CompressorRef *cs,
-                      std::ostream *ss)
-  {
-    if (compressor == 0) {
-      ZstdCompressor *interface = new ZstdCompressor();
-      compressor = CompressorRef(interface);
-    }
-    *cs = compressor;
-    return 0;
-  }
-};
+#ifndef BUILDING_FOR_EMBEDDED
 
 // -----------------------------------------------------------------------------
 
@@ -56,3 +35,5 @@ int __ceph_plugin_init(CephContext *cct,
 
   return instance->add(type, name, new CompressionPluginZstd(cct));
 }
+
+#endif // !BUILDING_FOR_EMBEDDED
diff --git a/src/compressor/zstd/CompressionPluginZstd.h b/src/compressor/zstd/CompressionPluginZstd.h
new file mode 100644 (file)
index 0000000..59c52cf
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Ceph - scalable distributed file system
+ *
+ * Copyright (C) 2015 Mirantis, Inc.
+ *
+ * Author: Alyona Kiseleva <akiselyova@mirantis.com>
+ *
+ *  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_COMPRESSION_PLUGIN_ZSTD_H
+#define CEPH_COMPRESSION_PLUGIN_ZSTD_H
+
+// -----------------------------------------------------------------------------
+#include "ceph_ver.h"
+#include "compressor/CompressionPlugin.h"
+#include "ZstdCompressor.h"
+// -----------------------------------------------------------------------------
+
+class CompressionPluginZstd : public CompressionPlugin {
+
+public:
+
+  explicit CompressionPluginZstd(CephContext* cct) : CompressionPlugin(cct)
+  {}
+
+  virtual int factory(CompressorRef *cs,
+                      std::ostream *ss)
+  {
+    if (compressor == 0) {
+      ZstdCompressor *interface = new ZstdCompressor();
+      compressor = CompressorRef(interface);
+    }
+    *cs = compressor;
+    return 0;
+  }
+};
+
+#endif
index c653879d6c910c09eb330955d0aa797057110d58..71b0767f03c53a7d234ebaf18e4cef44b6b18ee2 100644 (file)
@@ -7,6 +7,7 @@
 #include "common/PluginRegistry.h"
 #include "compressor/snappy/CompressionPluginSnappy.h"
 #include "compressor/zlib/CompressionPluginZlib.h"
+#include "compressor/zstd/CompressionPluginZstd.h"
 #include "erasure-code/ErasureCodePlugin.h"
 #if __x86_64__ && defined(HAVE_BETTER_YASM_ELF64)
 #include "erasure-code/isa/ErasureCodePluginIsa.h"
@@ -168,6 +169,13 @@ void cephd_preload_embedded_plugins()
       delete plugin;
     }
     assert(r == 0);
+
+    plugin = new CompressionPluginZstd(g_ceph_context);
+    r = reg->add("compressor", "zstd", plugin);
+    if (r == -EEXIST) {
+      delete plugin;
+    }
+    assert(r == 0);
   }
 }
 
index 60a28cbb81286461512ab88720bc7f06a3481a7c..8aa253562c4b8b0b2ff8e1df2038c8ec2c1b767e 100644 (file)
@@ -16,7 +16,7 @@ add_executable(ceph_test_cephd_api_misc
 set_target_properties(ceph_test_cephd_api_misc PROPERTIES COMPILE_FLAGS
   ${UNITTEST_CXX_FLAGS})
 target_link_libraries(ceph_test_cephd_api_misc
-  cephd global ${UNITTEST_LIBS} cephdtest z snappy)
+  cephd global ${UNITTEST_LIBS} cephdtest z snappy ceph_zstd)
 
 install(TARGETS
   ceph_test_cephd_api_misc