1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2011 New Dream Network
8 * This is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License version 2.1, as published by the Free Software
11 * Foundation. See file COPYING.
15 #include "cross_process_sem.h"
16 #include "include/rados/librados.h"
17 #include "st_rados_notify.h"
18 #include "systest_runnable.h"
20 StRadosNotify::StRadosNotify(int argc, const char **argv,
21 CrossProcessSem *setup_sem,
22 CrossProcessSem *notify_sem,
23 CrossProcessSem *notified_sem,
25 const std::string &pool_name,
26 const std::string &obj_name)
27 : SysTestRunnable(argc, argv),
28 m_setup_sem(setup_sem),
29 m_notify_sem(notify_sem),
30 m_notified_sem(notified_sem),
31 m_notify_retcode(notify_retcode),
32 m_pool_name(pool_name),
37 StRadosNotify::~StRadosNotify()
41 #pragma GCC diagnostic ignored "-Wpragmas"
42 #pragma GCC diagnostic push
43 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
45 int StRadosNotify::run()
48 RETURN1_IF_NONZERO(rados_create(&cl, NULL));
49 rados_conf_parse_argv(cl, m_argc, m_argv);
50 RETURN1_IF_NONZERO(rados_conf_read_file(cl, NULL));
51 rados_conf_parse_env(cl, NULL);
59 RETURN1_IF_NONZERO(rados_connect(cl));
60 RETURN1_IF_NONZERO(rados_ioctx_create(cl, m_pool_name.c_str(), &io_ctx));
67 printf("%s: notifying object %s\n", get_id_str(), m_obj_name.c_str());
68 RETURN1_IF_NOT_VAL(m_notify_retcode,
69 rados_notify(io_ctx, m_obj_name.c_str(), 0, NULL, 0));
71 m_notified_sem->post();
74 rados_ioctx_destroy(io_ctx);
80 #pragma GCC diagnostic pop
81 #pragma GCC diagnostic warning "-Wpragmas"