]>
git.proxmox.com Git - ceph.git/blob - ceph/src/client/hypertable/CephBroker.h
2 * Copyright (C) 2009-2011 New Dream Network
4 * This file is part of Hypertable.
6 * Hypertable is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or any later version.
11 * Hypertable is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with Hypertable. If not, see <http://www.gnu.org/licenses/>
20 * Gregory Farnum <gfarnum@gmail.com>
21 * Colin McCabe <cmccabe@alumni.cmu.edu>
24 #ifndef HYPERTABLE_CEPHBROKER_H
25 #define HYPERTABLE_CEPHBROKER_H
31 #include "Common/String.h"
32 #include "Common/Properties.h"
34 #include "DfsBroker/Lib/Broker.h"
36 #include <cephfs/libcephfs.h>
38 namespace Hypertable
{
39 using namespace DfsBroker
;
43 class OpenFileDataCeph
: public OpenFileData
{
45 OpenFileDataCeph(struct ceph_mount_info
*cmount_
, const String
& fname
,
47 virtual ~OpenFileDataCeph();
48 struct ceph_mount_info
*cmount
;
57 class OpenFileDataCephPtr
: public OpenFileDataPtr
{
59 OpenFileDataCephPtr() : OpenFileDataPtr() { }
60 explicit OpenFileDataCephPtr(OpenFileDataCeph
*ofdl
) : OpenFileDataPtr(ofdl
, true) { }
61 OpenFileDataCeph
*operator->() const { return static_cast<OpenFileDataCeph
*>(get()); }
67 class CephBroker
: public DfsBroker::Broker
{
69 explicit CephBroker(PropertiesPtr
& cfg
);
70 virtual ~CephBroker();
72 virtual void open(ResponseCallbackOpen
*cb
, const char *fname
,
73 uint32_t flags
, uint32_t bufsz
);
75 create(ResponseCallbackOpen
*cb
, const char *fname
, uint32_t flags
,
76 int32_t bufsz
, int16_t replication
, int64_t blksz
);
77 virtual void close(ResponseCallback
*cb
, uint32_t fd
);
78 virtual void read(ResponseCallbackRead
*cb
, uint32_t fd
, uint32_t amount
);
79 virtual void append(ResponseCallbackAppend
*cb
, uint32_t fd
,
80 uint32_t amount
, const void *data
, bool sync
);
81 virtual void seek(ResponseCallback
*cb
, uint32_t fd
, uint64_t offset
);
82 virtual void remove(ResponseCallback
*cb
, const char *fname
);
83 virtual void length(ResponseCallbackLength
*cb
, const char *fname
, bool);
84 virtual void pread(ResponseCallbackRead
*cb
, uint32_t fd
, uint64_t offset
,
85 uint32_t amount
, bool);
86 virtual void mkdirs(ResponseCallback
*cb
, const char *dname
);
87 virtual void rmdir(ResponseCallback
*cb
, const char *dname
);
88 virtual void flush(ResponseCallback
*cb
, uint32_t fd
);
89 virtual void status(ResponseCallback
*cb
);
90 virtual void shutdown(ResponseCallback
*cb
);
91 virtual void readdir(ResponseCallbackReaddir
*cb
, const char *dname
);
92 virtual void exists(ResponseCallbackExists
*cb
, const char *fname
);
93 virtual void rename(ResponseCallback
*cb
, const char *src
, const char *dst
);
94 virtual void debug(ResponseCallback
*, int32_t command
,
95 StaticBuffer
&serialized_parameters
);
98 struct ceph_mount_info
*cmount
;
99 static std::atomic
<int> ms_next_fd
;
101 virtual void report_error(ResponseCallback
*cb
, int error
);
103 void make_abs_path(const char *fname
, String
& abs
) {
107 abs
= m_root_dir
+ "/" + fname
;
110 int rmdir_recursive(const char *directory
);
117 #endif //HYPERTABLE_CEPH_BROKER_H