0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
QfsBroker.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 this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  * 02110-1301, USA.
20  */
21 
22 #ifndef FsBroker_qfs_QfsBroker_h
23 #define FsBroker_qfs_QfsBroker_h
24 
25 #include <FsBroker/Lib/Broker.h>
28 
29 #include <Common/Properties.h>
30 #include <Common/String.h>
31 
32 #include <atomic>
33 #include <string>
34 
35 extern "C" {
36 #include <unistd.h>
37 }
38 
39 namespace KFS {
40  class KfsClient;
41 }
42 
43 namespace Hypertable {
44 namespace FsBroker {
45  using namespace Lib;
46 
47 
48  class OpenFileDataQfs: public OpenFileData {
49  public:
50  OpenFileDataQfs(const std::string &fname, int fd, KFS::KfsClient *client)
51  : fname(fname), fd(fd), m_client(client) {};
52  virtual ~OpenFileDataQfs();
53  std::string fname;
54  int fd;
55  private:
56  KFS::KfsClient *const m_client;
57  };
58 
59 
61  public:
65  return (OpenFileDataQfs*) get();
66  }
67  };
68 
69  class QfsBroker : public FsBroker::Broker {
70  public:
72  virtual ~QfsBroker();
73 
74  virtual void open(Response::Callback::Open *cb, const char *fname, uint32_t flags, uint32_t bufsz);
75  virtual void close(ResponseCallback *cb, uint32_t fd);
76 
77  virtual void create(Response::Callback::Open *cb, const char *fname, uint32_t flags, int32_t bufsz, int16_t replication, int64_t blksz);
78  virtual void read(Response::Callback::Read *cb, uint32_t fd, uint32_t amount);
79  virtual void append(Response::Callback::Append *, uint32_t fd, uint32_t amount, const void *data, Filesystem::Flags flags);
80  virtual void seek(ResponseCallback *cb, uint32_t fd, uint64_t offset);
81  virtual void remove(ResponseCallback *cb, const char *fname);
82  virtual void length(Response::Callback::Length *cb, const char *fname,
83  bool accurate = true);
84  virtual void pread(Response::Callback::Read *cb, uint32_t fd, uint64_t offset,
85  uint32_t amount, bool verify_checksum);
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 sync(ResponseCallback *cb, uint32_t fd);
90  virtual void status(Response::Callback::Status *cb);
91  virtual void shutdown(ResponseCallback *cb);
92  virtual void readdir(Response::Callback::Readdir *cb, const char *dname);
93  virtual void exists(Response::Callback::Exists *cb, const char *fname);
94  virtual void rename(ResponseCallback *cb, const char *src, const char *dst);
95  virtual void debug(ResponseCallback *cb, int32_t command,
96  StaticBuffer &serialized_parameters);
97  private:
98 
100  static std::atomic<int> ms_next_fd;
101 
104 
107 
108  std::string m_host;
109  int m_port;
110  void report_error(ResponseCallback *cb, int error);
111  KFS::KfsClient* const m_client;
112  };
113 }}
114 
115 #endif // FsBroker_qfs_QfsBroker_h
A memory buffer of static size.
Definition: StaticBuffer.h:45
Application handler for append function.
Definition: Append.h:45
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.
OpenFileDataQfs * operator->() const
Definition: QfsBroker.h:64
Application handler for length function.
Definition: Length.h:45
MetricsHandlerPtr m_metrics_handler
Metrics collection handler.
Definition: QfsBroker.h:103
KFS::KfsClient *const m_client
Definition: QfsBroker.h:56
bool status(ContextPtr &context, Timer &timer, Status &status)
Runs a status check on the master.
Definition: Utility.cc:408
Definition: main.cc:53
std::shared_ptr< Properties > PropertiesPtr
Definition: Properties.h:447
Manages file system broker status.
Definition: StatusManager.h:44
static std::atomic< int > ms_next_fd
Atomic counter for file descriptor assignment.
Definition: QfsBroker.h:100
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
OpenFileDataQfsPtr(OpenFileDataQfs *ofdq)
Definition: QfsBroker.h:63
Application handler for open function.
Definition: Open.h:45
Declarations for MetricsHandler.
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.
Declarations for StatusManager.
OpenFileDataQfs(const std::string &fname, int fd, KFS::KfsClient *client)
Definition: QfsBroker.h:50
KFS::KfsClient *const m_client
Definition: QfsBroker.h:111
std::shared_ptr< MetricsHandler > MetricsHandlerPtr
Smart pointer to MetricsHandler.
StatusManager m_status_manager
Server status manager.
Definition: QfsBroker.h:106