diff options
author | David Zafman <dzafman@redhat.com> | 2014-09-25 07:43:05 +0200 |
---|---|---|
committer | David Zafman <dzafman@redhat.com> | 2014-10-20 19:47:50 +0200 |
commit | a03f85a8e7fab296ea2df70a929a1c5e4aa0f7fb (patch) | |
tree | 0c31947fa08adbf78a89ef20820affc2e6bdd9d2 /src/librados/ListObjectImpl.h | |
parent | rados: Fix ObjectIterator instantiation to specify correct value_type (diff) | |
download | ceph-a03f85a8e7fab296ea2df70a929a1c5e4aa0f7fb.tar.xz ceph-a03f85a8e7fab296ea2df70a929a1c5e4aa0f7fb.zip |
osd, osdc, librados, tools, rgw: Implement pgls of all namespaces
Add release note
New librados interface
New pg_nls_response_t over the wire protocol
Ignore internal namespace (.ceph_internal)
Enhance ObjListCtx to keep independent IoCtxImpl so nspace won't change out from under listing code
Add ListObject with private implementation ListObjectImpl to return from iterator
Add EINVAL error for old librados interface when LIBRADOS_ALL_NSPACES set
Add throw to old librados c++ interface when all_nspaces set
Fixes: #9031
Signed-off-by: David Zafman <dzafman@redhat.com>
Diffstat (limited to 'src/librados/ListObjectImpl.h')
-rw-r--r-- | src/librados/ListObjectImpl.h | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/src/librados/ListObjectImpl.h b/src/librados/ListObjectImpl.h new file mode 100644 index 00000000000..08754dfad0b --- /dev/null +++ b/src/librados/ListObjectImpl.h @@ -0,0 +1,78 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab +/* + * Ceph - scalable distributed file system + * + * Copyright (C) 2014 David Zafman <dzafman@redhat.com> + * + * This is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software + * Foundation. See file COPYING. + * + */ +#include <string> + +#ifndef CEPH_LIBRADOS_LISTOBJECTIMPL_H +#define CEPH_LIBRADOS_LISTOBJECTIMPL_H + +#include <include/rados/librados.hpp> + +namespace librados { +struct ListObjectImpl { + std::string nspace; + std::string oid; + std::string locator; + + ListObjectImpl() {} + ListObjectImpl(std::string n, std::string o, std::string l): + nspace(n), oid(o), locator(l) {} + + const std::string& get_nspace() { return nspace; } + const std::string& get_oid() { return oid; } + const std::string& get_locator() { return locator; } +}; +WRITE_EQ_OPERATORS_3(ListObjectImpl, nspace, oid, locator) +WRITE_CMP_OPERATORS_3(ListObjectImpl, nspace, oid, locator) +inline std::ostream& operator<<(std::ostream& out, const struct ListObjectImpl& lop) { + out << (lop.nspace.size() ? lop.nspace + "/" : "") << lop.oid + << (lop.locator.size() ? "@" + lop.locator : ""); + return out; +} + +class ObjListCtx; + +struct NObjectIteratorImpl { + public: + NObjectIteratorImpl() {} + ~NObjectIteratorImpl(); + NObjectIteratorImpl(const NObjectIteratorImpl &rhs); + NObjectIteratorImpl& operator=(const NObjectIteratorImpl& rhs); + + bool operator==(const NObjectIteratorImpl& rhs) const; + bool operator!=(const NObjectIteratorImpl& rhs) const; + const ListObject& operator*() const; + const ListObject* operator->() const; + NObjectIteratorImpl &operator++(); // Preincrement + NObjectIteratorImpl operator++(int); // Postincrement + const ListObject *get_listobjectp() { return &cur_obj; } + friend class IoCtx; + friend class ListObjectImpl; + //friend class ListObject; + friend class NObjectIterator; + + /// get current hash position of the iterator, rounded to the current pg + uint32_t get_pg_hash_position() const; + + /// move the iterator to a given hash position. this may (will!) be rounded to the nearest pg. + uint32_t seek(uint32_t pos); + + private: + NObjectIteratorImpl(ObjListCtx *ctx_); + void get_next(); + ceph::shared_ptr < ObjListCtx > ctx; + ListObject cur_obj; +}; + +} +#endif |