0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Broker.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_Lib_Broker_h
23 #define FsBroker_Lib_Broker_h
24 
25 #include "OpenFileMap.h"
26 #include "Response/Callback/Open.h"
27 #include "Response/Callback/Read.h"
31 #include "Response/Callback/Status.h"
33 
34 #include <Common/StaticBuffer.h>
35 
36 #include <memory>
37 
38 namespace Hypertable {
39 
41 namespace FsBroker {
42 
44 namespace Lib {
45 
48 
51  class Broker {
52  public:
53  virtual ~Broker() { return; }
62  virtual void open(Response::Callback::Open *cb, const char *fname,
63  uint32_t flags, uint32_t bufsz) = 0;
64 
76  virtual void create(Response::Callback::Open *cb, const char *fname,
77  uint32_t flags, int32_t bufsz,
78  int16_t replication, int64_t blksz) = 0;
79 
86  virtual void close(ResponseCallback *cb, uint32_t fd) = 0;
87 
94  virtual void read(Response::Callback::Read *cb, uint32_t fd,
95  uint32_t amount) = 0;
96 
105  virtual void append(Response::Callback::Append *cb, uint32_t fd,
106  uint32_t amount, const void *data, Filesystem::Flags flags) = 0;
107 
114  virtual void seek(ResponseCallback *cb, uint32_t fd, uint64_t offset) = 0;
115 
121  virtual void remove(ResponseCallback *cb, const char *fname) = 0;
122 
129  virtual void length(Response::Callback::Length *cb, const char *fname,
130  bool accurate = true) = 0;
131 
140  virtual void pread(Response::Callback::Read *cb, uint32_t fd, uint64_t offset,
141  uint32_t amount, bool verify_checksum) = 0;
142 
143 
151  virtual void mkdirs(ResponseCallback *cb, const char *dname) = 0;
152 
159  virtual void rmdir(ResponseCallback *cb, const char *dname) = 0;
160 
167  virtual void readdir(Response::Callback::Readdir *cb, const char *dname) = 0;
168 
169 
176  virtual void flush(ResponseCallback *cb, uint32_t fd) = 0;
177 
184  virtual void sync(ResponseCallback *cb, uint32_t fd) = 0;
185 
190  virtual void status(Response::Callback::Status *cb) = 0;
191 
196  virtual void shutdown(ResponseCallback *cb) = 0;
197 
204  virtual void exists(Response::Callback::Exists *cb, const char *fname) = 0;
205 
213  virtual void rename(ResponseCallback *cb, const char *src,
214  const char *dst) = 0;
215 
222  virtual void debug(ResponseCallback *cb, int32_t command,
223  StaticBuffer &serialized_parameters) = 0;
224 
225 
230 
231  protected:
238  };
239 
241  typedef std::shared_ptr<Broker> BrokerPtr;
242 
244 
245 }}}
246 
247 #endif // FsBroker_Lib_Broker_h
Declarations for Exists response callback.
virtual void flush(ResponseCallback *cb, uint32_t fd)=0
Flush data that has been written.
A memory buffer of static size.
Definition: StaticBuffer.h:45
virtual void open(Response::Callback::Open *cb, const char *fname, uint32_t flags, uint32_t bufsz)=0
Open a file and pass the fd to the callback on success.
virtual void readdir(Response::Callback::Readdir *cb, const char *dname)=0
Read a directory's contents.
Declarations for Open response callback.
virtual void exists(Response::Callback::Exists *cb, const char *fname)=0
Check for the existence of a file.
Application handler for append function.
Definition: Append.h:45
Abstract class to be implemented by brokers.
Definition: Broker.h:51
virtual void sync(ResponseCallback *cb, uint32_t fd)=0
Sync out data that has been written.
virtual void status(Response::Callback::Status *cb)=0
Check status of FSBroker.
Flags
Enumeration type for append flags.
Definition: Filesystem.h:76
Application handler for exists function.
Definition: Exists.h:45
virtual void debug(ResponseCallback *cb, int32_t command, StaticBuffer &serialized_parameters)=0
Debug command.
Declarations for Length response callback.
virtual void append(Response::Callback::Append *cb, uint32_t fd, uint32_t amount, const void *data, Filesystem::Flags flags)=0
Append data to open file.
Declarations for Read response callback.
Application handler for length function.
Definition: Length.h:45
OpenFileMap & get_open_file_map()
Definition: Broker.h:229
virtual void mkdirs(ResponseCallback *cb, const char *dname)=0
Make a directory hierarcy, If the parent dirs are not, present, they are also created.
virtual void rmdir(ResponseCallback *cb, const char *dname)=0
Remove a directory.
virtual void create(Response::Callback::Open *cb, const char *fname, uint32_t flags, int32_t bufsz, int16_t replication, int64_t blksz)=0
Open a file, and create it if it doesn't exist, optionally overwriting the contents.
virtual void shutdown(ResponseCallback *cb)=0
Gracefully shutdown broker, closeing open files.
A memory buffer of static size.
std::shared_ptr< Broker > BrokerPtr
Smart pointer to Broker.
Definition: Broker.h:241
virtual void pread(Response::Callback::Read *cb, uint32_t fd, uint64_t offset, uint32_t amount, bool verify_checksum)=0
Read from file at position.
OpenFileMap m_open_file_map
A map of open files.
Definition: Broker.h:237
Declarations for Append response callback.
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
Application handler for open function.
Definition: Open.h:45
Application handler for read function.
Definition: Read.h:47
virtual void rename(ResponseCallback *cb, const char *src, const char *dst)=0
Rename a file from src to dst.
Declarations for Readdir response callback.
virtual void read(Response::Callback::Read *cb, uint32_t fd, uint32_t amount)=0
Read data from an open file.
Application handler for open function.
Definition: Status.h:50
virtual void seek(ResponseCallback *cb, uint32_t fd, uint64_t offset)=0
Seek open file.
virtual void length(Response::Callback::Length *cb, const char *fname, bool accurate=true)=0
Get length of file.
virtual void close(ResponseCallback *cb, uint32_t fd)=0
Close open file.