0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
LocalBroker.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_local_LocalBroker_h
23 #define FsBroker_local_LocalBroker_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 Hypertable {
40 namespace FsBroker {
41 
42  using namespace Lib;
43 
45  public:
46  OpenFileDataLocal(const String &fname, int _fd, int _flags) : fd(_fd), flags(_flags), filename(fname) { }
47  virtual ~OpenFileDataLocal() {
48  close(fd);
49  }
50  int fd;
51  int flags;
53  };
54 
56  public:
59  : OpenFileDataPtr(ofdl) { }
61  return (OpenFileDataLocal *)get();
62  }
63  };
64 
65  class LocalBroker : public Lib::Broker {
66  public:
67  LocalBroker(PropertiesPtr &props);
68  virtual ~LocalBroker();
69 
70  virtual void open(Response::Callback::Open *cb, const char *fname,
71  uint32_t flags, uint32_t bufsz);
72  virtual void create(Response::Callback::Open *cb, const char *fname, uint32_t flags,
73  int32_t bufsz, int16_t replication, int64_t blksz);
74  virtual void close(ResponseCallback *cb, uint32_t fd);
75  virtual void read(Response::Callback::Read *cb, uint32_t fd, uint32_t amount);
76  virtual void append(Response::Callback::Append *cb, uint32_t fd,
77  uint32_t amount, const void *data, Filesystem::Flags flags);
78  virtual void seek(ResponseCallback *cb, uint32_t fd, uint64_t offset);
79  virtual void remove(ResponseCallback *cb, const char *fname);
80  virtual void length(Response::Callback::Length *cb, const char *fname,
81  bool accurate = true);
82  virtual void pread(Response::Callback::Read *cb, uint32_t fd, uint64_t offset,
83  uint32_t amount, bool verify_checksum);
84  virtual void mkdirs(ResponseCallback *cb, const char *dname);
85  virtual void rmdir(ResponseCallback *cb, const char *dname);
86  virtual void readdir(Response::Callback::Readdir *cb, const char *dname);
87  virtual void flush(ResponseCallback *cb, uint32_t fd);
88  virtual void sync(ResponseCallback *cb, uint32_t fd);
89  virtual void status(Response::Callback::Status *cb);
90  virtual void shutdown(ResponseCallback *cb);
91  virtual void exists(Response::Callback::Exists *cb, const char *fname);
92  virtual void rename(ResponseCallback *cb, const char *src, const char *dst);
93  virtual void debug(ResponseCallback *, int32_t command,
94  StaticBuffer &serialized_parameters);
95 
96  private:
97 
98  static atomic<int> ms_next_fd;
99 
100  virtual void report_error(ResponseCallback *cb);
101 
104 
107 
109  bool m_verbose;
112  };
113 
114 }}
115 
116 #endif // FsBroker_local_LocalBroker_h
StatusManager m_status_manager
Server status manager.
Definition: LocalBroker.h:106
A memory buffer of static size.
Definition: StaticBuffer.h:45
static atomic< int > ms_next_fd
Definition: LocalBroker.h:98
static String filename
Definition: Config.cc:48
Application handler for append function.
Definition: Append.h:45
std::string String
A String is simply a typedef to std::string.
Definition: String.h:44
OpenFileDataLocal * operator->() const
Definition: LocalBroker.h:60
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.
MetricsHandlerPtr m_metrics_handler
Metrics collection handler.
Definition: LocalBroker.h:103
Application handler for length function.
Definition: Length.h:45
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
Manages file system broker status.
Definition: StatusManager.h:44
OpenFileDataLocal(const String &fname, int _fd, int _flags)
Definition: LocalBroker.h:46
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
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.
OpenFileDataLocalPtr(OpenFileDataLocal *ofdl)
Definition: LocalBroker.h:58
Declarations for StatusManager.
std::shared_ptr< MetricsHandler > MetricsHandlerPtr
Smart pointer to MetricsHandler.