From 483eb2f56657e8e7f419ab1a4fab8dce9ade8609 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 27 Apr 2024 20:24:20 +0200 Subject: Adding upstream version 14.2.21. Signed-off-by: Daniel Baumann --- src/client/hypertable/CephBroker.h | 117 +++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 src/client/hypertable/CephBroker.h (limited to 'src/client/hypertable/CephBroker.h') diff --git a/src/client/hypertable/CephBroker.h b/src/client/hypertable/CephBroker.h new file mode 100644 index 00000000..d2df3890 --- /dev/null +++ b/src/client/hypertable/CephBroker.h @@ -0,0 +1,117 @@ +/** -*- C++ -*- + * Copyright (C) 2009-2011 New Dream Network + * + * This file is part of Hypertable. + * + * Hypertable is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or any later version. + * + * Hypertable is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Hypertable. If not, see + * + * Authors: + * Gregory Farnum + * Colin McCabe + */ + +#ifndef HYPERTABLE_CEPHBROKER_H +#define HYPERTABLE_CEPHBROKER_H + +extern "C" { +#include +} +#include +#include "Common/String.h" +#include "Common/Properties.h" + +#include "DfsBroker/Lib/Broker.h" + +#include + +namespace Hypertable { + using namespace DfsBroker; + /** + * + */ + class OpenFileDataCeph : public OpenFileData { + public: + OpenFileDataCeph(struct ceph_mount_info *cmount_, const String& fname, + int _fd, int _flags); + virtual ~OpenFileDataCeph(); + struct ceph_mount_info *cmount; + int fd; + int flags; + String filename; + }; + + /** + * + */ + class OpenFileDataCephPtr : public OpenFileDataPtr { + public: + OpenFileDataCephPtr() : OpenFileDataPtr() { } + explicit OpenFileDataCephPtr(OpenFileDataCeph *ofdl) : OpenFileDataPtr(ofdl, true) { } + OpenFileDataCeph *operator->() const { return static_cast(get()); } + }; + + /** + * + */ + class CephBroker : public DfsBroker::Broker { + public: + explicit CephBroker(PropertiesPtr& cfg); + virtual ~CephBroker(); + + virtual void open(ResponseCallbackOpen *cb, const char *fname, + uint32_t flags, uint32_t bufsz); + virtual void + create(ResponseCallbackOpen *cb, const char *fname, uint32_t flags, + int32_t bufsz, int16_t replication, int64_t blksz); + virtual void close(ResponseCallback *cb, uint32_t fd); + virtual void read(ResponseCallbackRead *cb, uint32_t fd, uint32_t amount); + virtual void append(ResponseCallbackAppend *cb, uint32_t fd, + uint32_t amount, const void *data, bool sync); + virtual void seek(ResponseCallback *cb, uint32_t fd, uint64_t offset); + virtual void remove(ResponseCallback *cb, const char *fname); + virtual void length(ResponseCallbackLength *cb, const char *fname, bool); + virtual void pread(ResponseCallbackRead *cb, uint32_t fd, uint64_t offset, + uint32_t amount, bool); + virtual void mkdirs(ResponseCallback *cb, const char *dname); + virtual void rmdir(ResponseCallback *cb, const char *dname); + virtual void flush(ResponseCallback *cb, uint32_t fd); + virtual void status(ResponseCallback *cb); + virtual void shutdown(ResponseCallback *cb); + virtual void readdir(ResponseCallbackReaddir *cb, const char *dname); + virtual void exists(ResponseCallbackExists *cb, const char *fname); + virtual void rename(ResponseCallback *cb, const char *src, const char *dst); + virtual void debug(ResponseCallback *, int32_t command, + StaticBuffer &serialized_parameters); + + private: + struct ceph_mount_info *cmount; + static std::atomic ms_next_fd; + + virtual void report_error(ResponseCallback *cb, int error); + + void make_abs_path(const char *fname, String& abs) { + if (fname[0] == '/') + abs = fname; + else + abs = m_root_dir + "/" + fname; + } + + int rmdir_recursive(const char *directory); + + bool m_verbose; + String m_root_dir; + }; +} + +#endif //HYPERTABLE_CEPH_BROKER_H -- cgit v1.2.3