]>
git.proxmox.com Git - ceph.git/blob - ceph/src/test/system/st_rados_watch.cc
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_watch.h"
18 #include "systest_runnable.h"
20 void notify_cb(uint8_t opcode
, uint64_t ver
, void *arg
)
22 int *notifies
= reinterpret_cast<int*>(arg
);
26 StRadosWatch::StRadosWatch(int argc
, const char **argv
,
27 CrossProcessSem
*setup_sem
,
28 CrossProcessSem
*watch_sem
,
29 CrossProcessSem
*notify_sem
,
32 const std::string
&pool_name
,
33 const std::string
&obj_name
)
34 : SysTestRunnable(argc
, argv
),
35 m_setup_sem(setup_sem
),
36 m_watch_sem(watch_sem
),
37 m_notify_sem(notify_sem
),
38 m_num_notifies(num_notifies
),
39 m_watch_retcode(watch_retcode
),
40 m_pool_name(pool_name
),
50 #pragma GCC diagnostic ignored "-Wpragmas"
51 #pragma GCC diagnostic push
52 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
58 RETURN1_IF_NONZERO(rados_create(&cl
, NULL
));
59 rados_conf_parse_argv(cl
, m_argc
, m_argv
);
60 RETURN1_IF_NONZERO(rados_conf_read_file(cl
, NULL
));
61 rados_conf_parse_env(cl
, NULL
);
71 RETURN1_IF_NONZERO(rados_connect(cl
));
72 RETURN1_IF_NONZERO(rados_ioctx_create(cl
, m_pool_name
.c_str(), &io_ctx
));
73 printf("%s: watching object %s\n", get_id_str(), m_obj_name
.c_str());
75 RETURN1_IF_NOT_VAL(m_watch_retcode
,
76 rados_watch(io_ctx
, m_obj_name
.c_str(), 0, &handle
,
77 reinterpret_cast<rados_watchcb_t
>(notify_cb
),
78 reinterpret_cast<void*>(&num_notifies
))
88 if (num_notifies
< m_num_notifies
) {
89 printf("Received fewer notifies than expected: %d < %d\n",
90 num_notifies
, m_num_notifies
);
94 if (m_watch_retcode
== 0)
95 rados_unwatch(io_ctx
, m_obj_name
.c_str(), handle
);
96 rados_ioctx_destroy(io_ctx
);
102 #pragma GCC diagnostic pop
103 #pragma GCC diagnostic warning "-Wpragmas"