0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
CephBroker.h
Go to the documentation of this file.
1 /* -*- c++ -*-
2  * Copyright (C) 2007-2015 Hypertable, Inc.
3  *
4  * This file is part of Hypertable.
5  *
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 3
9  * of the License, or any later version.
10  *
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.
15  *
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/>
18  */
19 
20 #ifndef FsBroker_ceph_CephBroker_h
21 #define FsBroker_ceph_CephBroker_h
22 
23 #include <FsBroker/Lib/Broker.h>
24 
25 #include <Common/Properties.h>
26 #include <Common/Status.h>
27 #include <Common/String.h>
28 
29 #include <ceph/libceph.h>
30 
31 #include <atomic>
32 
33 extern "C" {
34 #include <unistd.h>
35 }
36 
37 namespace Hypertable {
38 namespace FsBroker {
39  using namespace Lib;
40 
41  class OpenFileDataCeph : public OpenFileData {
42  public:
43  OpenFileDataCeph(const String& fname, int _fd, int _flags) :
44  fd(_fd), flags(_flags), filename(fname) {}
45  virtual ~OpenFileDataCeph() { ceph_close(fd); }
46  int fd;
47  int flags;
49  };
50 
52  public:
55  OpenFileDataCeph *operator->() const { return (OpenFileDataCeph *)get(); }
56  };
57 
58  class CephBroker : public FsBroker::Broker {
59  public:
61  virtual ~CephBroker();
62 
63  virtual void open(Response::Callback::Open *cb, const char *fname,
64  uint32_t flags, uint32_t bufsz);
65  virtual void
66  create(Response::Callback::Open *cb, const char *fname, uint32_t flags,
67  int32_t bufsz, int16_t replication, int64_t blksz);
68  virtual void close(ResponseCallback *cb, uint32_t fd);
69  virtual void read(Response::Callback::Read *cb, uint32_t fd, uint32_t amount);
70  virtual void append(Response::Callback::Append *cb, uint32_t fd,
71  uint32_t amount, const void *data, Filesystem::Flags flags);
72  virtual void seek(ResponseCallback *cb, uint32_t fd, uint64_t offset);
73  virtual void remove(ResponseCallback *cb, const char *fname);
74  virtual void length(Response::Callback::Length *cb, const char *fname,
75  bool accurate = true);
76  virtual void pread(Response::Callback::Read *cb, uint32_t fd, uint64_t offset,
77  uint32_t amount, bool verify_checksum);
78  virtual void mkdirs(ResponseCallback *cb, const char *dname);
79  virtual void rmdir(ResponseCallback *cb, const char *dname);
80  virtual void flush(ResponseCallback *cb, uint32_t fd);
81  virtual void sync(ResponseCallback *cb, uint32_t fd);
82  virtual void status(Response::Callback::Status *cb);
83  virtual void shutdown(ResponseCallback *cb);
84  virtual void readdir(Response::Callback::Readdir *cb, const char *dname);
85  virtual void exists(Response::Callback::Exists *cb, const char *fname);
86  virtual void rename(ResponseCallback *cb, const char *src, const char *dst);
87  virtual void debug(ResponseCallback *, int32_t command,
88  StaticBuffer &serialized_parameters);
89 
90  private:
91  static atomic<int> ms_next_fd;
92 
93  virtual void report_error(ResponseCallback *cb, int error);
94 
95  void make_abs_path(const char *fname, String& abs) {
96  if (fname[0] == '/')
97  abs = fname;
98  else
99  abs = m_root_dir + "/" + fname;
100  }
101 
102  int rmdir_recursive(const char *directory);
103 
106 
107  bool m_verbose;
109  };
110 
111 }}
112 
113 #endif // FsBroker_ceph_CephBroker_h
A memory buffer of static size.
Definition: StaticBuffer.h:45
static String filename
Definition: Config.cc:48
Application handler for append function.
Definition: Append.h:45
Holds Nagios-style program status information.
Definition: Status.h:42
std::string String
A String is simply a typedef to std::string.
Definition: String.h:44
OpenFileDataCephPtr(OpenFileDataCeph *ofdl)
Definition: CephBroker.h:54
Declarations for Status.
Abstract class to be implemented by brokers.
Definition: Broker.h:51
std::shared_ptr< OpenFileData > OpenFileDataPtr
Definition: OpenFileMap.h:45
Flags
Enumeration type for append flags.
Definition: Filesystem.h:76
Application handler for exists function.
Definition: Exists.h:45
Program options handling.
static atomic< int > ms_next_fd
Definition: CephBroker.h:91
void make_abs_path(const char *fname, String &abs)
Definition: CephBroker.h:95
Application handler for length function.
Definition: Length.h:45
Directory container class.
Definition: directory.h:343
bool status(ContextPtr &context, Timer &timer, Status &status)
Runs a status check on the master.
Definition: Utility.cc:408
std::shared_ptr< Properties > PropertiesPtr
Definition: Properties.h:447
OpenFileDataCeph(const String &fname, int _fd, int _flags)
Definition: CephBroker.h:43
OpenFileDataCeph * operator->() const
Definition: CephBroker.h:55
This class is used to generate and deliver standard responses back to a client.
Application handler for readdir function.
Definition: Readdir.h:48
Hypertable definitions
Hypertable::Status m_status
Server status information.
Definition: CephBroker.h:105
Application handler for open function.
Definition: Open.h:45
Application handler for read function.
Definition: Read.h:47
Application handler for open function.
Definition: Status.h:50
A String class based on std::string.