dumpjournal_LDADD = libosdc.a libcrush.a libcommon.a
# osd
-cosd_SOURCES = cosd.cc msg/SimpleMessenger.cc
+cosd_SOURCES = cosd.cc msg/SimpleMessenger.cc objclass/class_debug.cc \
+ objclass/class_api.cc
cosd_LDADD = libosd.a libos.a libcrush.a libcommon.a -ldl
dupstore_SOURCES = dupstore.cc
dupstore_LDADD = libos.a libcommon.a
osd/ReplicatedPG.cc \
osd/Ager.cc \
osd/OSD.cc \
- common/ClassHandler.cc \
- objclass/class_debug.cc \
- objclass/class_api.cc
+ common/ClassHandler.cc
# osd/RAID4PG.cc
libosdc_a_SOURCES = \
void ClassMonitor::create_initial(bufferlist& bl)
{
dout(10) << "create_initial -- creating initial map" << dendl;
+ ClassImpl i;
+ ClassInfo l;
+ l.name = "test";
+ l.version = 12;
+ i.seq = 0;
+ i.stamp = g_clock.now();
+ bufferptr ptr(1024);
+ memset(ptr.c_str(), 0x13, 1024);
+ i.binary.append(ptr);
+ ClassLibraryIncremental inc;
+ ::encode(i, inc.impl);
+ ::encode(l, inc.info);
+ inc.add = true;
+ pending_class.insert(pair<utime_t,ClassLibraryIncremental>(i.stamp, inc));
}
bool ClassMonitor::store_impl(ClassInfo& info, ClassImpl& impl)
#include "common/ClassHandler.h"
-extern OSD *osd;
+static OSD *osd;
void cls_initialize(OSD *_osd)
{
}
-extern "C" void *cls_alloc(size_t size)
+void *cls_alloc(size_t size)
{
return malloc(size);
}
-extern "C" void cls_free(void *p)
+void cls_free(void *p)
{
free(p);
}
+
int cls_register(const char *name, cls_handle_t *handle)
{
ClassHandler::ClassData *cd;
return (cd != NULL);
}
+
int cls_unregister(cls_handle_t handle)
{
ClassHandler::ClassData *cd;
cd = (ClassHandler::ClassData *)handle;
osd->class_handler->unregister_class(cd);
+ return 1;
}
int cls_register_method(cls_handle_t hclass, const char *method,
int cls_unregister_method(cls_method_handle_t handle)
{
- ClassHandler::ClassMethod *method;
+ ClassHandler::ClassMethod *method = (ClassHandler::ClassMethod *)handle;
method->unregister();
return 1;
#include <stdlib.h>
#include <stdarg.h>
-extern "C" int cls_log(const char *format, ...)
+#include <iostream>
+
+int cls_log(const char *format, ...)
{
int size = 256, n;
va_list ap;
va_end(ap);
#define MAX_SIZE 8196
if ((n > -1 && n < size) || size > MAX_SIZE) {
- dout(0) << buf << dendl;
+ *_dout << buf << std::endl;
return n;
}
size *= 2;
extern int cls_register(const char *name, cls_handle_t *handle);
extern int cls_unregister(cls_handle_t);
-extern int cls_register_method(const char *method,
+extern int cls_register_method(cls_handle_t hclass, const char *method,
cls_method_call_t class_call, cls_method_handle_t *handle);
extern int cls_unregister_method(cls_method_handle_t handle);
extern int cls_link(cls_method_handle_t handle, int priority, cls_trigger_t trigger);
extern int cls_unlink(cls_method_handle_t handle);
+
+/* should be defined by the class implementation
+ defined here inorder to get it compiled without C++ mangling */
+extern void class_init(void);
+extern void class_fini(void);
+
#ifdef __cplusplus
}
#endif
#include "common/Timer.h"
#include "common/LogClient.h"
-#include "common/ClassHandler.h"
+#include "osd/ClassHandler.h"
#include <iostream>
#include <errno.h>
#include <sys/mount.h>
#endif // DARWIN
+#include "objclass/objclass.h"
#include "config.h"
}
}
+void cls_initialize(OSD *_osd);
+
int OSD::init()
{
Mutex::Locker lock(osd_lock);
class_handler = new ClassHandler(this);
assert(class_handler);
+ cls_initialize(this);
// load up "current" osdmap
assert_warn(!osdmap);