0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
MaprBroker.cc
Go to the documentation of this file.
1 /*
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 #include <Common/Compat.h>
23 
24 #include "MaprBroker.h"
25 
27 
28 #include <Common/FileUtils.h>
29 #include <Common/Filesystem.h>
30 #include <Common/Path.h>
31 #include <Common/ScopeGuard.h>
32 #include <Common/String.h>
33 #include <Common/System.h>
34 #include <Common/SystemInfo.h>
35 
36 #include <boost/algorithm/string.hpp>
37 
38 #include <cerrno>
39 #include <chrono>
40 #include <cstdio>
41 #include <cstring>
42 #include <string>
43 #include <thread>
44 #include <vector>
45 
46 extern "C" {
47 #include <dirent.h>
48 #include <fcntl.h>
49 #include <limits.h>
50 #include <sys/types.h>
51 #if defined(__sun__)
52 #include <sys/fcntl.h>
53 #endif
54 #include <sys/uio.h>
55 #include <unistd.h>
56 }
57 
58 using namespace Hypertable;
59 using namespace Hypertable::FsBroker;
60 using namespace std;
61 
62 atomic<int> MaprBroker::ms_next_fd {0};
63 
65  m_verbose = cfg->get_bool("verbose");
66  m_aggregate_writes = cfg->get_bool("DfsBroker.Mapr.aggregate.writes", true);
67  m_readbuffering = cfg->get_bool("DfsBroker.Mapr.readbuffering", true);
68  m_namenode_host = cfg->get_str("DfsBroker.Hdfs.NameNode.Host");
69  m_namenode_port = cfg->get_i16("DfsBroker.Hdfs.NameNode.Port");
70 
71  m_metrics_handler = std::make_shared<MetricsHandler>(cfg, "mapr");
72  m_metrics_handler->start_collecting();
73 
74  m_filesystem = hdfsConnectNewInstance(m_namenode_host.c_str(), m_namenode_port);
75 
76 }
77 
78 
79 
81  m_metrics_handler->stop_collecting();
82  hdfsDisconnect(m_filesystem);
83 }
84 
85 
86 void
88  uint32_t flags, uint32_t bufsz) {
89  hdfsFile file;
90  int fd;
91 
92  if (bufsz == (uint32_t)-1)
93  bufsz = 0;
94 
95  HT_DEBUGF("open file='%s' flags=%u bufsz=%d", fname, flags, bufsz);
96 
97  fd = ++ms_next_fd;
98 
99  int oflags = O_RDONLY;
100 
101  if ((file = hdfsOpenFile(m_filesystem, fname, oflags, bufsz, 0, 0)) == 0) {
102  report_error(cb);
103  HT_ERRORF("open failed: file='%s' - %s", fname, strerror(errno));
104  return;
105  }
106 
107  HT_INFOF("open(%s) = %d", fname, (int)fd);
108 
109  {
110  struct sockaddr_in addr;
111  OpenFileDataMaprPtr fdata(new OpenFileDataMapr(m_filesystem, fname, file, O_RDONLY));
112 
113  cb->get_address(addr);
114 
115  m_open_file_map.create(fd, addr, fdata);
116 
117  cb->response(fd);
118  }
119 }
120 
121 
122 void
123 MaprBroker::create(Response::Callback::Open *cb, const char *fname, uint32_t flags,
124  int32_t bufsz, int16_t replication, int64_t blksz) {
125  hdfsFile file;
126  int fd;
127  int oflags = O_WRONLY;
128 
129  if (bufsz == -1)
130  bufsz = 0;
131  if (replication == -1)
132  replication = 0;
133  if (blksz == -1)
134  blksz = 0;
135 
136  HT_DEBUGF("create file='%s' flags=%u bufsz=%d replication=%d blksz=%lld",
137  fname, flags, bufsz, (int)replication, (Lld)blksz);
138 
139  fd = ++ms_next_fd;
140 
141  if ((flags & Filesystem::OPEN_FLAG_OVERWRITE) == 0)
142  oflags |= O_APPEND;
143 
144  if ((file = hdfsOpenFile(m_filesystem, fname, oflags, bufsz, replication, blksz)) == 0) {
145  report_error(cb);
146  HT_ERRORF("create failed: file='%s' - %s", fname, strerror(errno));
147  return;
148  }
149 
150  //HT_DEBUGF("created file='%s' fd=%d mapr_fd=%d", fname, fd, mapr_fd);
151 
152  HT_INFOF("create(%s) = %d", fname, (int)fd);
153 
154  {
155  struct sockaddr_in addr;
156  OpenFileDataMaprPtr fdata(new OpenFileDataMapr(m_filesystem, fname, file, oflags));
157 
158  cb->get_address(addr);
159 
160  m_open_file_map.create(fd, addr, fdata);
161 
162  cb->response(fd);
163  }
164 }
165 
166 
167 void MaprBroker::close(ResponseCallback *cb, uint32_t fd) {
168  int error;
169  HT_DEBUGF("close fd=%d", fd);
170  m_open_file_map.remove(fd);
171  if ((error = cb->response_ok()) != Error::OK)
172  HT_ERRORF("Problem sending response for close(%u) - %s", (unsigned)fd, Error::get_text(error));
173 }
174 
175 
176 void MaprBroker::read(Response::Callback::Read *cb, uint32_t fd, uint32_t amount) {
177  OpenFileDataMaprPtr fdata;
178  tSize nread;
179  int64_t offset;
180  uint8_t *readbuf;
181  int error;
182 
183 #if defined(__linux__)
184  void *vptr = 0;
185  HT_ASSERT(posix_memalign(&vptr, HT_DIRECT_IO_ALIGNMENT, amount) == 0);
186  readbuf = (uint8_t *)vptr;
187 #else
188  readbuf = new uint8_t [amount];
189 #endif
190 
191  StaticBuffer buf(readbuf, amount);
192 
193  HT_DEBUGF("read fd=%d amount=%d", fd, amount);
194 
195  if (!m_open_file_map.get(fd, fdata)) {
196  char errbuf[32];
197  sprintf(errbuf, "%d", fd);
199  HT_ERRORF("bad file handle: %d", fd);
200  m_metrics_handler->increment_error_count();
201  return;
202  }
203 
204  if ((offset = hdfsTell(m_filesystem, fdata->file)) == -1) {
205  report_error(cb);
206  HT_ERRORF("lseek failed: fd=%d offset=0 SEEK_CUR - %s", fd,
207  strerror(errno));
208  return;
209  }
210 
211  if ((nread = hdfsRead(m_filesystem, fdata->file, buf.base, (tSize)amount)) == -1) {
212  report_error(cb);
213  HT_ERRORF("read failed: fd=%d offset=%llu amount=%d - %s",
214  fd, (Llu)offset, amount, strerror(errno));
215  return;
216  }
217 
218  buf.size = nread;
219 
220  m_metrics_handler->add_bytes_read(nread);
221 
222  if ((error = cb->response(offset, buf)) != Error::OK)
223  HT_ERRORF("Problem sending response for read(%u, %u) - %s",
224  (unsigned)fd, (unsigned)amount, Error::get_text(error));
225 
226 }
227 
228 
230  uint32_t amount, const void *data, Filesystem::Flags flags) {
231  OpenFileDataMaprPtr fdata;
232  tSize nwritten;
233  int64_t offset;
234  int error;
235 
236  HT_DEBUG_OUT << "append fd=" << fd << " amount=" << amount << " data='"
237  << format_bytes(20, data, amount) << " flags="
238  << static_cast<int>(flags) << HT_END;
239 
240  if (!m_open_file_map.get(fd, fdata)) {
241  char errbuf[32];
242  sprintf(errbuf, "%d", fd);
244  m_metrics_handler->increment_error_count();
245  return;
246  }
247 
248  if ((offset = hdfsTell(m_filesystem, fdata->file)) == -1) {
249  report_error(cb);
250  HT_ERRORF("lseek failed: fd=%d offset=0 SEEK_CUR - %s", fd,
251  strerror(errno));
252  return;
253  }
254 
255  if ((nwritten = hdfsWrite(m_filesystem, fdata->file, data, (tSize)amount)) == -1) {
256  report_error(cb);
257  HT_ERRORF("write failed: fd=%d offset=%llu amount=%d data=%p- %s",
258  fd, (Llu)offset, amount, data, strerror(errno));
259  return;
260  }
261 
262  if (flags == Filesystem::Flags::FLUSH || flags == Filesystem::Flags::SYNC) {
263  int64_t start_time = get_ts64();
264  if (hdfsFlush(m_filesystem, fdata->file)) {
265  report_error(cb);
266  HT_ERRORF("flush failed: fd=%d - %s", fd, strerror(errno));
267  return;
268  }
269  m_metrics_handler->add_sync(get_ts64() - start_time);
270  }
271 
272  m_metrics_handler->add_bytes_written(nwritten);
273 
274  if ((error = cb->response(offset, nwritten)) != Error::OK)
275  HT_ERRORF("Problem sending response for append(%u, %u) - %s",
276  (unsigned)fd, (unsigned)amount, Error::get_text(error));
277 
278 }
279 
280 
281 void MaprBroker::seek(ResponseCallback *cb, uint32_t fd, uint64_t offset) {
282  OpenFileDataMaprPtr fdata;
283  int error;
284 
285  HT_DEBUGF("seek fd=%lu offset=%llu", (Lu)fd, (Llu)offset);
286 
287  if (!m_open_file_map.get(fd, fdata)) {
288  char errbuf[32];
289  sprintf(errbuf, "%d", fd);
291  m_metrics_handler->increment_error_count();
292  return;
293  }
294 
295  if ((offset = hdfsSeek(m_filesystem, fdata->file, (tOffset)offset)) == (uint64_t)-1) {
296  report_error(cb);
297  HT_ERRORF("lseek failed: fd=%d offset=%llu - %s", fd, (Llu)offset,
298  strerror(errno));
299  return;
300  }
301 
302  if ((error = cb->response_ok()) != Error::OK)
303  HT_ERRORF("Problem sending response for seek(%u, %llu) - %s",
304  (unsigned)fd, (Llu)offset, Error::get_text(error));
305 
306 }
307 
308 
309 void MaprBroker::remove(ResponseCallback *cb, const char *fname) {
310  int error;
311 
312  HT_DEBUGF("remove file='%s'", fname);
313 
314  if (hdfsDelete(m_filesystem, fname) == -1) {
315  report_error(cb);
316  HT_ERRORF("unlink failed: file='%s' - %s", fname,
317  strerror(errno));
318  return;
319  }
320 
321  if ((error = cb->response_ok()) != Error::OK)
322  HT_ERRORF("Problem sending response for remove(%s) - %s",
323  fname, Error::get_text(error));
324 }
325 
326 
327 void MaprBroker::length(Response::Callback::Length *cb, const char *fname,
328  bool accurate) {
329  hdfsFileInfo *fileInfo;
330  int error;
331 
332  (void)accurate;
333 
334  if ((fileInfo = hdfsGetPathInfo(m_filesystem, fname)) == 0) {
335  report_error(cb);
336  HT_ERRORF("length (stat) failed: file='%s' - %s", fname,
337  strerror(errno));
338  return;
339  }
340 
341  HT_DEBUGF("length('%s') = %lu", fname, (unsigned long)fileInfo->mSize);
342 
343  if ((error = cb->response(fileInfo->mSize)) != Error::OK)
344  HT_ERRORF("Problem sending response (%llu) for length(%s) - %s",
345  (Llu)fileInfo->mSize, fname, Error::get_text(error));
346 
347  hdfsFreeFileInfo(fileInfo, 1);
348 }
349 
350 
351 void
352 MaprBroker::pread(Response::Callback::Read *cb, uint32_t fd, uint64_t offset,
353  uint32_t amount, bool) {
354  OpenFileDataMaprPtr fdata;
355  ssize_t nread;
356  uint8_t *readbuf;
357  int error;
358 
359  HT_DEBUGF("pread fd=%d offset=%llu amount=%d", fd, (Llu)offset, amount);
360 
361 #if defined(__linux__)
362  void *vptr = 0;
363  HT_ASSERT(posix_memalign(&vptr, HT_DIRECT_IO_ALIGNMENT, amount) == 0);
364  readbuf = (uint8_t *)vptr;
365 #else
366  readbuf = new uint8_t [amount];
367 #endif
368 
369  StaticBuffer buf(readbuf, amount);
370 
371  if (!m_open_file_map.get(fd, fdata)) {
372  char errbuf[32];
373  sprintf(errbuf, "%d", fd);
375  m_metrics_handler->increment_error_count();
376  return;
377  }
378 
379  if ((nread = hdfsPread(m_filesystem, fdata->file, (tOffset)offset, buf.base, (tSize)amount)) == -1) {
380  report_error(cb);
381  HT_ERRORF("pread failed: fd=%d amount=%d offset=%llu - %s", fd,
382  amount, (Llu)offset, strerror(errno));
383  return;
384  }
385 
386  buf.size = nread;
387 
388  m_metrics_handler->add_bytes_read(nread);
389 
390  if ((error = cb->response(offset, buf)) != Error::OK)
391  HT_ERRORF("Problem sending response for pread(%u, %llu, %u) - %s",
392  (unsigned)fd, (Llu)offset, (unsigned)amount, Error::get_text(error));
393 
394 }
395 
396 
397 void MaprBroker::mkdirs(ResponseCallback *cb, const char *dname) {
398  int error;
399 
400  HT_DEBUGF("mkdirs dir='%s'", dname);
401 
402  String make_dir = dname;
403 
404  boost::trim_right_if(make_dir, boost::is_any_of("/"));
405 
406  if (hdfsCreateDirectory(m_filesystem, make_dir.c_str()) == -1) {
407  report_error(cb);
408  HT_ERRORF("mkdirs failed: dname='%s' - %s", dname,
409  strerror(errno));
410  return;
411  }
412 
413  if ((error = cb->response_ok()) != Error::OK)
414  HT_ERRORF("Problem sending response for mkdirs(%s) - %s",
415  dname, Error::get_text(error));
416 }
417 
418 namespace {
419 
420  void free_file_info(hdfsFileInfo *fileInfo, int numEntries) {
421  if (numEntries != 0)
422  hdfsFreeFileInfo(fileInfo, numEntries);
423  }
424 
425 
426  void rmdir_recursive(hdfsFS fs, const String &dname) {
427  hdfsFileInfo *fileInfo = 0;
428  int numEntries = 0;
429 
430  HT_ON_SCOPE_EXIT(&free_file_info, fileInfo, numEntries);
431 
432  if ((fileInfo = hdfsListDirectory(fs, dname.c_str(), &numEntries)) == 0) {
433  if (errno == ENOENT)
434  return;
435  HT_THROWF(Error::FSBROKER_IO_ERROR, "Problem listing directory '%s' - %s",
436  dname.c_str(), strerror(errno));
437  }
438 
439  for (int i=0; i<numEntries; i++) {
440  String child = fileInfo[i].mName;
441  if (fileInfo[i].mKind == kObjectKindDirectory)
442  rmdir_recursive(fs, child);
443  else if (fileInfo[i].mKind == kObjectKindFile) {
444  if (hdfsDelete(fs, child.c_str()) == -1) {
445  if (errno != 0) {
446  HT_THROWF(Error::FSBROKER_IO_ERROR, "Problem deleting file '%s' - %s",
447  child.c_str(), strerror(errno));
448  }
449  }
450  }
451  }
452 
453  if (hdfsDelete(fs, dname.c_str()) == -1) {
454  HT_THROWF(Error::FSBROKER_IO_ERROR, "Problem removing directory '%s' - %s",
455  dname.c_str(), strerror(errno));
456  }
457  }
458 
459 }
460 
461 void MaprBroker::rmdir(ResponseCallback *cb, const char *dname) {
462  int error;
463  String removal_dir = String(dname);
464 
465  boost::trim_right_if(removal_dir, boost::is_any_of("/"));
466 
467  if (m_verbose)
468  HT_DEBUGF("rmdir dir='%s'", dname);
469 
470  try {
471  rmdir_recursive(m_filesystem, removal_dir);
472  }
473  catch (Hypertable::Exception &e) {
474  if ((error = cb->error(e.code(), e.what())) != Error::OK)
475  HT_ERRORF("Problem sending error response for rmdir(%s) - %s",
476  dname, Error::get_text(error));
477  HT_ERROR_OUT << e << HT_END;
478  }
479 
480  if ((error = cb->response_ok()) != Error::OK)
481  HT_ERRORF("Problem sending response for mkdirs(%s) - %s",
482  dname, Error::get_text(error));
483 }
484 
485 
486 void MaprBroker::readdir(Response::Callback::Readdir *cb, const char *dname) {
487  std::vector<Filesystem::Dirent> listing;
488  hdfsFileInfo *fileInfo;
489  int numEntries;
490 
491  HT_DEBUGF("Readdir dir='%s'", dname);
492 
493  if ((fileInfo = hdfsListDirectory(m_filesystem, dname, &numEntries)) == 0) {
494  report_error(cb);
495  HT_ERRORF("readdir('%s') failed - %s", dname, strerror(errno));
496  return;
497  }
498 
499  Filesystem::Dirent entry;
500  for (int i=0; i<numEntries; i++) {
501  const char *ptr;
502  if (fileInfo[i].mName[0] != '.' && fileInfo[i].mName[0] != 0) {
503  if ((ptr = strrchr(fileInfo[i].mName, '/')))
504  entry.name = (String)(ptr+1);
505  else
506  entry.name = (String)fileInfo[i].mName;
507  entry.length = fileInfo[i].mSize;
508  entry.last_modification_time = fileInfo[i].mLastMod;
509  entry.is_dir = fileInfo[i].mKind == kObjectKindDirectory;
510  listing.push_back(entry);
511  }
512  }
513  hdfsFreeFileInfo(fileInfo, numEntries);
514 
515  HT_DEBUGF("Sending back %d listings", (int)listing.size());
516 
517  cb->response(listing);
518 }
519 
520 
521 void MaprBroker::flush(ResponseCallback *cb, uint32_t fd) {
522  this->sync(cb, fd);
523 }
524 
525 void MaprBroker::sync(ResponseCallback *cb, uint32_t fd) {
526  OpenFileDataMaprPtr fdata;
527 
528  HT_DEBUGF("sync fd=%d", fd);
529 
530  if (!m_open_file_map.get(fd, fdata)) {
531  char errbuf[32];
532  sprintf(errbuf, "%d", fd);
534  m_metrics_handler->increment_error_count();
535  return;
536  }
537 
538  HT_DEBUGF("sync fd=%d filename=%s", fd, fdata->filename.c_str());
539 
540  int64_t start_time = get_ts64();
541  if (hdfsFlush(m_filesystem, fdata->file) == -1) {
542  report_error(cb);
543  HT_ERRORF("sync failed: fd=%d - %s", fd, strerror(errno));
544  return;
545  }
546  m_metrics_handler->add_sync(get_ts64() - start_time);
547 
548  cb->response_ok();
549 }
550 
551 
553  cb->response(m_status);
554 }
555 
556 
558  m_open_file_map.remove_all();
559  cb->response_ok();
560  this_thread::sleep_for(chrono::milliseconds(2000));
561 }
562 
563 
564 void MaprBroker::exists(Response::Callback::Exists *cb, const char *fname) {
565  String abspath;
566 
567  HT_DEBUGF("exists file='%s'", fname);
568 
569  if (hdfsExists(m_filesystem, fname) == -1) {
570  cb->response(false);
571  return;
572  }
573 
574  cb->response(true);
575 }
576 
577 
578 void
579 MaprBroker::rename(ResponseCallback *cb, const char *src, const char *dst) {
580 
581  HT_DEBUGF("rename %s -> %s", src, dst);
582 
583  if (hdfsRename(m_filesystem, src, dst) == -1) {
584  report_error(cb);
585  return;
586  }
587  cb->response_ok();
588 }
589 
590 void
591 MaprBroker::debug(ResponseCallback *cb, int32_t command,
592  StaticBuffer &serialized_parameters) {
593  HT_ERRORF("debug command %d not implemented.", command);
594  cb->error(Error::NOT_IMPLEMENTED, format("Unsupported debug command - %d",
595  command));
596 }
597 
598 
599 
601  char errbuf[128];
602  errbuf[0] = 0;
603 
604  m_metrics_handler->increment_error_count();
605 
606  strerror_r(errno, errbuf, 128);
607 
608  if (errno == ENOTDIR || errno == ENAMETOOLONG || errno == ENOENT)
609  cb->error(Error::FSBROKER_BAD_FILENAME, errbuf);
610  else if (errno == EACCES || errno == EPERM)
612  else if (errno == EBADF)
614  else if (errno == EINVAL)
616  else
617  cb->error(Error::FSBROKER_IO_ERROR, errbuf);
618 }
A memory buffer of static size.
Definition: StaticBuffer.h:45
Retrieves system information (hardware, installation directory, etc)
int response(bool exists)
Sends response parameters back to client.
Definition: Exists.cc:40
virtual void remove(ResponseCallback *cb, const char *fname)
Remove a file or directory.
Definition: MaprBroker.cc:309
virtual void append(Response::Callback::Append *cb, uint32_t fd, uint32_t amount, const void *data, Filesystem::Flags flags)
Append data to open file.
Definition: MaprBroker.cc:229
virtual void flush(ResponseCallback *cb, uint32_t fd)
Flush data that has been written.
Definition: MaprBroker.cc:521
void get_address(struct sockaddr_in &addr)
Gets the remote address of the requesting client.
Application handler for append function.
Definition: Append.h:45
Abstract base class for a filesystem.
std::string String
A String is simply a typedef to std::string.
Definition: String.h:44
Compatibility class for boost::filesystem::path.
virtual void rmdir(ResponseCallback *cb, const char *dname)
Remove a directory.
Definition: MaprBroker.cc:461
String format(const char *fmt,...)
Returns a String using printf like format facilities Vanilla snprintf is about 1.5x faster than this...
Definition: String.cc:37
virtual int response_ok()
Sends a a simple success response back to the client which is just the 4-byte error code Error::OK...
int response(int32_t fd)
Sends response parameters back to client.
Definition: Open.cc:40
Flags
Enumeration type for append flags.
Definition: Filesystem.h:76
long long unsigned int Llu
Shortcut for printf formats.
Definition: String.h:50
Application handler for exists function.
Definition: Exists.h:45
virtual void status(Response::Callback::Status *cb)
Check status of FSBroker.
Definition: MaprBroker.cc:552
File system broker definitions.
Definition: CephBroker.h:38
virtual void mkdirs(ResponseCallback *cb, const char *dname)
Make a directory hierarcy, If the parent dirs are not, present, they are also created.
Definition: MaprBroker.cc:397
STL namespace.
time_t last_modification_time
Last modification time.
Definition: Filesystem.h:100
#define HT_ON_SCOPE_EXIT(...)
Definition: ScopeGuard.h:301
virtual void readdir(Response::Callback::Readdir *cb, const char *dname)
Read a directory's contents.
Definition: MaprBroker.cc:486
virtual void open(Response::Callback::Open *cb, const char *fname, uint32_t flags, uint32_t bufsz)
Open a file and pass the fd to the callback on success.
Definition: MaprBroker.cc:87
String format_bytes(size_t n, const void *buf, size_t len, const char *trailer)
Return first n bytes of buffer with an optional trailer if the size of the buffer exceeds n...
Definition: String.cc:103
virtual void create(Response::Callback::Open *cb, const char *fname, uint32_t flags, int32_t bufsz, int16_t replication, int64_t blksz)
Open a file, and create it if it doesn't exist, optionally overwriting the contents.
Definition: MaprBroker.cc:123
virtual void shutdown(ResponseCallback *cb)
Gracefully shutdown broker, closeing open files.
Definition: MaprBroker.cc:557
virtual void sync(ResponseCallback *cb, uint32_t fd)
Sync out data that has been written.
Definition: MaprBroker.cc:525
uint64_t length
Length of file.
Definition: Filesystem.h:98
#define HT_ASSERT(_e_)
Definition: Logger.h:396
bool is_dir
Flag indicating if entry id a directory.
Definition: Filesystem.h:102
Application handler for length function.
Definition: Length.h:45
File system utility functions.
virtual void rename(ResponseCallback *cb, const char *src, const char *dst)
Rename a file from src to dst.
Definition: MaprBroker.cc:579
const char * get_text(int error)
Returns a descriptive error message.
Definition: Error.cc:330
virtual void length(Response::Callback::Length *cb, const char *fname, bool accurate=true)
Get length of file.
Definition: MaprBroker.cc:327
std::shared_ptr< Properties > PropertiesPtr
Definition: Properties.h:447
Compatibility Macros for C/C++.
virtual void report_error(ResponseCallback *cb)
Definition: MaprBroker.cc:600
#define HT_END
Definition: Logger.h:220
int response(uint64_t offset, StaticBuffer &buffer)
Sends response parameters back to client.
Definition: Read.cc:40
virtual void pread(Response::Callback::Read *cb, uint32_t fd, uint64_t offset, uint32_t amount, bool verify_checksum)
Read from file at position.
Definition: MaprBroker.cc:352
virtual void close(ResponseCallback *cb, uint32_t fd)
Close open file.
Definition: MaprBroker.cc:167
#define HT_ERROR_OUT
Definition: Logger.h:301
virtual void seek(ResponseCallback *cb, uint32_t fd, uint64_t offset)
Seek open file.
Definition: MaprBroker.cc:281
This class is used to generate and deliver standard responses back to a client.
int response(std::vector< Filesystem::Dirent > &listing)
Sends response parameters back to client.
Definition: Readdir.cc:41
Application handler for readdir function.
Definition: Readdir.h:48
Hypertable definitions
#define HT_DEBUGF(msg,...)
Definition: Logger.h:260
long long int Lld
Shortcut for printf formats.
Definition: String.h:53
Application handler for open function.
Definition: Open.h:45
Application handler for read function.
Definition: Read.h:47
virtual int error(int error, const String &msg)
Sends a standard error response back to the client.
virtual void debug(ResponseCallback *, int32_t command, StaticBuffer &serialized_parameters)
Debug command.
Definition: MaprBroker.cc:591
#define HT_INFOF(msg,...)
Definition: Logger.h:272
String name
File or directory name.
Definition: Filesystem.h:96
#define HT_THROWF(_code_, _fmt_,...)
Definition: Error.h:490
MaprBroker(PropertiesPtr &props)
Definition: MaprBroker.cc:64
Declarations for ReactorFactory.
This is a generic exception class for Hypertable.
Definition: Error.h:314
Application handler for open function.
Definition: Status.h:50
int response(Hypertable::Status &status)
Sends response parameters back to client.
Definition: Status.cc:40
A String class based on std::string.
long unsigned int Lu
Shortcut for printf formats.
Definition: String.h:47
#define HT_ERRORF(msg,...)
Definition: Logger.h:300
int response(uint64_t offset, uint32_t amount)
Sends response parameters back to client.
Definition: Append.cc:40
virtual void read(Response::Callback::Read *cb, uint32_t fd, uint32_t amount)
Read data from an open file.
Definition: MaprBroker.cc:176
static atomic< int > ms_next_fd
Definition: MaprBroker.h:105
System information and statistics based on libsigar.
virtual void exists(Response::Callback::Exists *cb, const char *fname)
Check for the existence of a file.
Definition: MaprBroker.cc:564
int response(uint64_t length)
Sends response parameters back to client.
Definition: Length.cc:40
#define HT_DEBUG_OUT
Definition: Logger.h:261
int64_t get_ts64()
Returns the current time in nanoseconds as a 64bit number.
Definition: Time.cc:40
#define HT_DIRECT_IO_ALIGNMENT
Definition: Filesystem.h:49
int code() const
Returns the error code.
Definition: Error.h:391
Executes user-defined functions when leaving the current scope.