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_delete_objs.h"
18 #include "systest_runnable.h"
19 #include "systest_settings.h"
23 StRadosDeleteObjs::StRadosDeleteObjs(int argc, const char **argv,
24 CrossProcessSem *setup_sem,
25 CrossProcessSem *deleted_sem,
27 const std::string &pool_name,
28 const std::string &suffix)
29 : SysTestRunnable(argc, argv),
30 m_setup_sem(setup_sem),
31 m_deleted_sem(deleted_sem),
33 m_pool_name(pool_name),
38 StRadosDeleteObjs::~StRadosDeleteObjs()
42 int StRadosDeleteObjs::run()
45 RETURN1_IF_NONZERO(rados_create(&cl, NULL));
46 rados_conf_parse_argv(cl, m_argc, m_argv);
47 RETURN1_IF_NONZERO(rados_conf_read_file(cl, NULL));
48 rados_conf_parse_env(cl, NULL);
49 RETURN1_IF_NONZERO(rados_connect(cl));
54 rados_pool_create(cl, m_pool_name.c_str());
55 RETURN1_IF_NONZERO(rados_ioctx_create(cl, m_pool_name.c_str(), &io_ctx));
57 for (int i = 0; i < m_num_objs; ++i) {
59 snprintf(oid, sizeof(oid), "%d%s", i, m_suffix.c_str());
60 RETURN1_IF_NONZERO(rados_remove(io_ctx, oid));
61 if (((i % 25) == 0) || (i == m_num_objs - 1)) {
62 printf("%s: deleted object %d...\n", get_id_str(), i);
66 rados_ioctx_destroy(io_ctx);
68 m_deleted_sem->post();