SWC-DB  v0.5.12 C++ documentations
SWC-DB© (Super Wide Column Database) - High Performance Scalable Database (https://github.com/kashirin-alex/swc-db)
FileSystem.cc
Go to the documentation of this file.
1 /*
2  * SWC-DB© Copyright since 2019 Alex Kashirin <kashirin.alex@gmail.com>
3  * License details at <https://github.com/kashirin-alex/swc-db/#license>
4  */
5 
7 
12 
51 
52 
53 namespace SWC { namespace FS {
54 
55 
57  config->settings->file_desc.add_options()
58  ("swc.fs.broker.cfg.dyn", Config::strs(),
59  "Dyn-config file")
60 
61  ("swc.fs.broker.host", Config::str(),
62  "FsBroker host (default by hostname)")
63  ("swc.fs.broker.port", Config::i16(14000),
64  "FsBroker port")
65 
66  ("swc.fs.broker.metrics.enabled", Config::boo(true),
67  "Enable or Disable Metrics Tracking")
68 
69  ("swc.fs.broker.concurrency.relative", Config::boo(true),
70  "Determined ratio by HW-Concurrency")
71  ("swc.fs.broker.handlers", Config::i32(6),
72  "Number or HW-Concurrency base of Handlers for broker tasks")
73 
74  ("swc.fs.broker.timeout", Config::g_i32(120000),
75  "Default request timeout in ms")
76  ("swc.fs.broker.timeout.bytes.ratio", Config::g_i32(1000),
77  "Timeout ratio to bytes, bytes/ratio=ms added to default timeout")
78 
79  ("swc.fs.broker.comm.encoder",
82  nullptr,
85  "The encoding to use in communication, options PLAIN/ZSTD/SNAPPY/ZLIB")
86 
87  ("swc.fs.broker.fds.max", Config::g_i32(256),
88  "Max Open Fds for opt. without closing")
89  ;
90  config->settings->parse_file(
91  config->settings->get_str("swc.fs.broker.cfg", ""),
92  "swc.fs.broker.cfg.dyn"
93  );
94 
95  config->cfg_fds_max = config->settings
96  ->get<Config::Property::Value_int32_g>("swc.fs.broker.fds.max");
97  config->stats_enabled = config->settings->get_bool(
98  "swc.fs.broker.metrics.enabled");
99  return config;
100 }
101 
102 
103 
106  std::string host = settings->get_str(
107  "swc.fs.broker.host", "");
108  if(host.empty()) {
109  char hostname[256];
110  if(gethostname(hostname, sizeof(hostname)) == -1)
111  SWC_THROW(errno, "gethostname");
112  host.append(hostname);
113  }
114 
115  Comm::Networks nets;
116  asio::error_code ec;
118  settings->get_strs("swc.comm.network.priority"), nets, ec);
119  if(ec)
121  "swc.comm.network.priority error(%s)",
122  ec.message().c_str());
123 
124  Config::Strings addr;
126  settings->get_i16("swc.fs.broker.port"),
127  addr, host, nets, true
128  );
129 }
130 
131 
132 
134  : FileSystem(apply_broker(config), ImplOptions(true)),
135  m_io(
136  Comm::IoContext::make(
137  "FsBroker",
138  settings->get_bool("swc.fs.broker.concurrency.relative"),
139  settings->get_i32("swc.fs.broker.handlers")
140  )
141  ),
142  m_service(
143  new Comm::client::Serialized(
144  *settings,
145  "FS-BROKER",
146  m_io,
147  client::FsBroker::AppContext::Ptr(
148  new client::FsBroker::AppContext(*settings))
149  )
150  ),
151  m_type_underlying(fs_type(
152  settings->get_str("swc.fs.broker.underlying"))),
153  m_endpoints(get_endpoints(settings)),
154  m_connections(),
155  cfg_timeout(
156  settings->get<Config::Property::Value_int32_g>(
157  "swc.fs.broker.timeout")),
158  cfg_timeout_ratio(
159  settings->get<Config::Property::Value_int32_g>(
160  "swc.fs.broker.timeout.bytes.ratio")) {
161 }
162 
164 
166  m_run.store(false);
167  m_service->stop();
168  for(Comm::ConnHandlerPtr conn; m_connections.pop(&conn); ) conn->do_close();
169  m_io->stop();
171 }
172 
174  return Type::BROKER;
175 }
176 
178  return m_type_underlying;
179 }
180 
181 std::string FileSystemBroker::to_string() const {
182  return format(
183  "(type=BROKER underlying-type=%s)",
185  );
186 }
187 
188 
192  while(m_run && (!m_connections.pop(&conn) || !conn->is_open()) &&
193  !(conn = m_service->get_connection(
194  m_endpoints, std::chrono::milliseconds(20000), 3)));
195  if(m_run) {
196  m_connections.push(conn);
197  return conn->send_request(hdlr->cbp, hdlr);
198  } else {
199  if(conn)
200  conn->do_close();
201  hdlr->handle(conn, Comm::Event::make(Error::SERVER_SHUTTING_DOWN));
202  }
203  return true;
204 }
205 
207 
208 bool FileSystemBroker::exists(int& err, const std::string& name) {
209  SWC_FS_EXISTS_START(name);
210 
213  statistics, cfg_timeout->get(), name)
214  );
215  while(!send_request(hdlr));
216  hdlr->wait();
217  err = hdlr->error;
218  return hdlr->state;
219 }
220 
222  const std::string& name) {
223  SWC_FS_EXISTS_START(name);
224 
227  statistics, cfg_timeout->get(), name, std::move(cb)));
228  while(!send_request(hdlr));
229 }
230 
231 void FileSystemBroker::remove(int& err, const std::string& name) {
232  SWC_FS_REMOVE_START(name);
233 
236  statistics, cfg_timeout->get(), name));
237  while(!send_request(hdlr));
238  hdlr->wait();
239  err = hdlr->error;
240 }
241 
243  const std::string& name) {
244  SWC_FS_REMOVE_START(name);
245 
248  statistics, cfg_timeout->get(), name, std::move(cb)));
249  while(!send_request(hdlr));
250 }
251 
252 size_t FileSystemBroker::length(int& err, const std::string& name) {
253  SWC_FS_LENGTH_START(name);
254 
257  statistics, cfg_timeout->get(), name));
258  while(!send_request(hdlr));
259  hdlr->wait();
260  err = hdlr->error;
261  return hdlr->length;
262 }
263 
265  const std::string& name) {
266  SWC_FS_LENGTH_START(name);
267 
270  statistics, cfg_timeout->get(), name, std::move(cb)));
271  while(!send_request(hdlr));
272 }
273 
274 void FileSystemBroker::mkdirs(int& err, const std::string& name) {
275  SWC_FS_MKDIRS_START(name);
276 
279  statistics, cfg_timeout->get(), name));
280  while(!send_request(hdlr));
281  hdlr->wait();
282  err = hdlr->error;
283 }
284 
286  const std::string& name) {
287  SWC_FS_MKDIRS_START(name);
288 
291  statistics, cfg_timeout->get(), name, std::move(cb)));
292  while(!send_request(hdlr));
293 }
294 
295 void FileSystemBroker::readdir(int& err, const std::string& name,
296  DirentList& results) {
297  SWC_FS_READDIR_START(name);
298 
301  statistics, cfg_timeout->get(), name, results));
302  while(!send_request(hdlr));
303  hdlr->wait();
304  err = hdlr->error;
305 }
306 
308  const std::string& name) {
309  SWC_FS_READDIR_START(name);
310 
313  statistics, cfg_timeout->get(), name, std::move(cb)));
314  while(!send_request(hdlr));
315 }
316 
317 void FileSystemBroker::rmdir(int& err, const std::string& name) {
318  SWC_FS_RMDIR_START(name);
319 
322  statistics, cfg_timeout->get(), name));
323  while(!send_request(hdlr));
324  hdlr->wait();
325  err = hdlr->error;
326 }
327 
329  const std::string& name) {
330  SWC_FS_RMDIR_START(name);
331 
334  statistics, cfg_timeout->get(), name, std::move(cb)));
335  while(!send_request(hdlr));
336 }
337 
338 void FileSystemBroker::rename(int& err, const std::string& from,
339  const std::string& to) {
341 
344  statistics, cfg_timeout->get(), from, to));
345  while(!send_request(hdlr));
346  hdlr->wait();
347  err = hdlr->error;
348 }
349 
351  const std::string& from,
352  const std::string& to) {
354 
357  statistics, cfg_timeout->get(), from, to, std::move(cb)));
358  while(!send_request(hdlr));
359 }
360 
362 
363 void FileSystemBroker::write(int& err, SmartFd::Ptr& smartfd,
364  uint8_t replication, StaticBuffer& buffer) {
365  SWC_FS_WRITE_START(smartfd, replication, buffer.size);
366 
369  statistics, cfg_timeout->get(), smartfd, replication, buffer));
370  while(!send_request(hdlr));
371  hdlr->wait();
372  err = hdlr->error;
373 }
374 
376  SmartFd::Ptr& smartfd,
377  uint8_t replication,
378  StaticBuffer&& buffer) {
379  SWC_FS_WRITE_START(smartfd, replication, buffer.size);
380 
383  statistics,
384  cfg_timeout->get(), smartfd, replication,
385  std::move(buffer), std::move(cb)));
386  while(!send_request(hdlr));
387 }
388 
389 void FileSystemBroker::read(int& err, const std::string& name,
390  StaticBuffer* dst) {
391  SWC_FS_READALL_START(name);
392 
395  statistics, cfg_timeout->get(), name, dst));
396  while(!send_request(hdlr));
397  hdlr->wait();
398  err = hdlr->error;
399 }
400 
402  const std::string& name) {
403  SWC_FS_READALL_START(name);
404 
407  statistics, cfg_timeout->get(), name, std::move(cb))
408  );
409  while(!send_request(hdlr));
410 }
411 
413  uint64_t offset, uint32_t amount,
414  StaticBuffer* dst) {
415  SWC_FS_COMBI_PREAD_START(smartfd, offset, amount);
416 
419  statistics,
420  cfg_timeout->get() + amount/cfg_timeout_ratio->get(),
421  smartfd, offset, amount, dst)
422  );
423  while(!send_request(hdlr));
424  hdlr->wait();
425  err = hdlr->error;
426 }
427 
429  SmartFd::Ptr& smartfd,
430  uint64_t offset, uint32_t amount) {
431  SWC_FS_COMBI_PREAD_START(smartfd, offset, amount);
432 
435  statistics,
436  cfg_timeout->get() + amount/cfg_timeout_ratio->get(),
437  smartfd, offset, amount, std::move(cb))
438  );
439  while(!send_request(hdlr));
440 }
441 
442 void FileSystemBroker::create(int& err, SmartFd::Ptr& smartfd,
443  uint8_t replication) {
444  SWC_FS_CREATE_START(smartfd, replication);
445 
448  shared_from_this(),
449  cfg_timeout->get(), smartfd, replication)
450  );
451  while(!send_request(hdlr));
452  hdlr->wait();
453  err = hdlr->error;
454 }
455 
457  SmartFd::Ptr& smartfd,
458  uint8_t replication) {
459  SWC_FS_CREATE_START(smartfd, replication);
460 
463  shared_from_this(),
464  cfg_timeout->get(), smartfd, replication, std::move(cb))
465  );
466  while(!send_request(hdlr));
467 }
468 
469 size_t FileSystemBroker::append(int& err, SmartFd::Ptr& smartfd,
470  StaticBuffer& buffer, Flags flags) {
471  SWC_FS_APPEND_START(smartfd, buffer.size, flags);
472 
475  statistics,
476  cfg_timeout->get() + buffer.size/cfg_timeout_ratio->get(),
477  smartfd, buffer, flags)
478  );
479  while(!send_request(hdlr));
480  hdlr->wait();
481  err = hdlr->error;
482  return hdlr->amount;
483 }
484 
486  SmartFd::Ptr& smartfd,
487  StaticBuffer& buffer, Flags flags) {
488  SWC_FS_APPEND_START(smartfd, buffer.size, flags);
489 
492  statistics,
493  cfg_timeout->get() + buffer.size/cfg_timeout_ratio->get(),
494  smartfd, buffer, flags, std::move(cb))
495  );
496  while(!send_request(hdlr));
497 }
498 
499 void FileSystemBroker::open(int& err, SmartFd::Ptr& smartfd) {
500  SWC_FS_OPEN_START(smartfd);
501 
504  shared_from_this(), cfg_timeout->get(), smartfd));
505  while(!send_request(hdlr));
506  hdlr->wait();
507  err = hdlr->error;
508 }
509 
511  SWC_FS_OPEN_START(smartfd);
512 
515  shared_from_this(), cfg_timeout->get(), smartfd, std::move(cb)));
516  while(!send_request(hdlr));
517 }
518 
519 size_t FileSystemBroker::read(int& err, SmartFd::Ptr& smartfd,
520  void* dst, size_t amount) {
521  SWC_FS_READ_START(smartfd, amount);
522 
525  statistics,
526  cfg_timeout->get() + amount/cfg_timeout_ratio->get(),
527  smartfd, dst, amount, true)
528  );
529  while(!send_request(hdlr));
530  hdlr->wait();
531  err = hdlr->error;
532  return hdlr->amount;
533 }
534 
535 size_t FileSystemBroker::read(int& err, SmartFd::Ptr& smartfd,
536  StaticBuffer* dst, size_t amount) {
537  SWC_FS_READ_START(smartfd, amount);
538 
541  statistics,
542  cfg_timeout->get() + amount/cfg_timeout_ratio->get(),
543  smartfd, static_cast<void*>(dst), amount, false)
544  );
545  while(!send_request(hdlr));
546  hdlr->wait();
547  err = hdlr->error;
548  return hdlr->amount;
549 }
550 
552  SmartFd::Ptr& smartfd, size_t amount) {
553  SWC_FS_READ_START(smartfd, amount);
554 
557  statistics,
558  cfg_timeout->get() + amount/cfg_timeout_ratio->get(),
559  smartfd, amount, std::move(cb))
560  );
561  while(!send_request(hdlr));
562 }
563 
564 size_t FileSystemBroker::pread(int& err, SmartFd::Ptr& smartfd,
565  uint64_t offset, void* dst,
566  size_t amount) {
567  SWC_FS_PREAD_START(smartfd, offset, amount);
568 
571  statistics,
572  cfg_timeout->get() + amount/cfg_timeout_ratio->get(),
573  smartfd, offset, dst, amount, true)
574  );
575  while(!send_request(hdlr));
576  hdlr->wait();
577  err = hdlr->error;
578  return hdlr->amount;
579 }
580 
581 size_t FileSystemBroker::pread(int& err, SmartFd::Ptr& smartfd,
582  uint64_t offset, StaticBuffer* dst,
583  size_t amount) {
584  SWC_FS_PREAD_START(smartfd, offset, amount);
585 
588  statistics,
589  cfg_timeout->get() + amount/cfg_timeout_ratio->get(),
590  smartfd, offset, static_cast<void*>(dst), amount, false)
591  );
592  while(!send_request(hdlr));
593  hdlr->wait();
594  err = hdlr->error;
595  return hdlr->amount;
596 }
597 
599  SmartFd::Ptr& smartfd,
600  uint64_t offset, size_t amount) {
601  SWC_FS_PREAD_START(smartfd, offset, amount);
602 
605  statistics,
606  cfg_timeout->get() + amount/cfg_timeout_ratio->get(),
607  smartfd, offset, amount, std::move(cb))
608  );
609  while(!send_request(hdlr));
610 }
611 
612 void FileSystemBroker::seek(int& err, SmartFd::Ptr& smartfd, size_t offset) {
613  SWC_FS_SEEK_START(smartfd, offset);
614 
617  statistics, cfg_timeout->get(), smartfd, offset));
618  while(!send_request(hdlr));
619  hdlr->wait();
620  err = hdlr->error;
621 }
622 
624  SmartFd::Ptr& smartfd,
625  size_t offset) {
626  SWC_FS_SEEK_START(smartfd, offset);
627 
630  statistics, cfg_timeout->get(), smartfd, offset, std::move(cb)));
631  while(!send_request(hdlr));
632 }
633 
634 void FileSystemBroker::flush(int& err, SmartFd::Ptr& smartfd) {
635  SWC_FS_FLUSH_START(smartfd);
636 
639  statistics, cfg_timeout->get(), smartfd));
640  while(!send_request(hdlr));
641  hdlr->wait();
642  err = hdlr->error;
643 }
644 
646  SmartFd::Ptr& smartfd) {
647  SWC_FS_FLUSH_START(smartfd);
648 
651  statistics, cfg_timeout->get(), smartfd, std::move(cb)));
652  while(!send_request(hdlr));
653 }
654 
655 void FileSystemBroker::sync(int& err, SmartFd::Ptr& smartfd) {
656  SWC_FS_SYNC_START(smartfd);
657 
660  statistics, cfg_timeout->get(), smartfd));
661  while(!send_request(hdlr));
662  hdlr->wait();
663  err = hdlr->error;
664 }
665 
667  SmartFd::Ptr& smartfd) {
668  SWC_FS_SYNC_START(smartfd);
669 
672  statistics, cfg_timeout->get(), smartfd, std::move(cb)));
673  while(!send_request(hdlr));
674 }
675 
676 void FileSystemBroker::close(int& err, SmartFd::Ptr& smartfd) {
677  SWC_FS_CLOSE_START(smartfd);
678 
681  shared_from_this(), cfg_timeout->get(), smartfd));
682  while(!send_request(hdlr));
683  hdlr->wait();
684  err = hdlr->error;
685 }
686 
688  SmartFd::Ptr& smartfd) {
689  SWC_FS_CLOSE_START(smartfd);
690 
693  shared_from_this(), cfg_timeout->get(), smartfd, std::move(cb)));
694  while(!send_request(hdlr));
695 }
696 
697 
698 }} // namespace SWC
699 
700 
701 
702 extern "C" {
704  return static_cast<SWC::FS::FileSystem*>(
705  new SWC::FS::FileSystemBroker(config));
706 }
707 }
SWC::Comm::Protocol::FsBroker::Req::Close
Definition: Close.h:17
SWC::Config::i32
Property::Value_int32::Ptr i32(const int32_t &v)
Definition: PropertiesParser.cc:33
SWC_FS_APPEND_START
#define SWC_FS_APPEND_START(_smartfd, _amount, _flags)
Definition: Logger.h:217
Append.h
SWC::Comm::Protocol::FsBroker::Req::Readdir::Ptr
std::shared_ptr< Readdir > Ptr
Definition: Readdir.h:19
SWC::FS::FileSystemBroker::rename
void rename(int &err, const std::string &from, const std::string &to) override
Definition: FileSystem.cc:338
ExistsSync.h
SWC::Comm::Protocol::FsBroker::Req::Rmdir::Ptr
std::shared_ptr< Rmdir > Ptr
Definition: Rmdir.h:19
SWC::Comm::Protocol::FsBroker::Req::ReaddirSync
Definition: ReaddirSync.h:17
SWC::FS::Callback::OpenCb_t
std::function< void(int)> OpenCb_t
Definition: Callbacks.h:34
SWC::FS::FileSystem::Ptr
std::shared_ptr< FileSystem > Ptr
Definition: FileSystem.h:104
SWC::Config::g_i32
Property::Value_int32_g::Ptr g_i32(const int32_t &v)
Definition: PropertiesParser.cc:77
SWC::FS::FileSystemBroker::write
void write(int &err, SmartFd::Ptr &smartfd, uint8_t replication, StaticBuffer &buffer) override
SmartFd actions.
Definition: FileSystem.cc:363
CombiPreadSync.h
SWC::FS::Callback::WriteCb_t
std::function< void(int, StaticBuffer &&)> WriteCb_t
Definition: Callbacks.h:29
Create.h
SWC::FS::fs_type
Type fs_type(const std::string &fs_name)
Definition: FileSystem.cc:19
SWC::FS::Callback::PreadCb_t
std::function< void(int, StaticBuffer &&)> PreadCb_t
Definition: Callbacks.h:36
SWC::FS::FileSystemBroker::FileSystemBroker
FileSystemBroker(Configurables *config)
Definition: FileSystem.cc:133
SWC::Comm::Protocol::FsBroker::Req::OpenSync
Definition: OpenSync.h:17
SWC::Config::g_enum
Property::Value_enum_g::Ptr g_enum(const int32_t &v, Property::Value_enum_g::OnChg_t &&cb, Property::Value_enum_g::FromString_t &&from_string, Property::Value_enum_g::Repr_t &&repr)
Definition: PropertiesParser.cc:89
Flush.h
FlushSync.h
ReaddirSync.h
SWC::Comm::Resolver::get_networks
void get_networks(const Config::Strings &networks, Networks &nets, asio::error_code &ec)
Definition: Resolver.cc:264
SWC::Error::SERVER_SHUTTING_DOWN
@ SERVER_SHUTTING_DOWN
Definition: Error.h:84
SWC::Comm::Protocol::FsBroker::Req::SyncSync
Definition: SyncSync.h:17
SWC::Config::Settings::Ptr
std::shared_ptr< Settings > Ptr
Definition: Settings.h:29
SWC::FS::FileSystemBroker::open
void open(int &err, SmartFd::Ptr &smartfd) override
Definition: FileSystem.cc:499
SWC::FS::Callback::CombiPreadCb_t
std::function< void(int, StaticBuffer &&)> CombiPreadCb_t
Definition: Callbacks.h:31
SWC::FS::Callback::ReadCb_t
std::function< void(int, StaticBuffer &&)> ReadCb_t
Definition: Callbacks.h:35
Pread.h
SWC::FS::FileSystemBroker::readdir
void readdir(int &err, const std::string &name, DirentList &results) override
Definition: FileSystem.cc:295
SWC::FS::apply_broker
Configurables * apply_broker(Configurables *config)
Definition: FileSystem.cc:56
SWC::FS::Type
Type
Definition: FileSystem.h:20
SWC::Comm::Protocol::FsBroker::Req::FlushSync
Definition: FlushSync.h:17
Length.h
SWC_FS_FLUSH_START
#define SWC_FS_FLUSH_START(_smartfd)
Definition: Logger.h:241
SWC::FS::FileSystemBroker::length
size_t length(int &err, const std::string &name) override
Definition: FileSystem.cc:252
SWC::Comm::Protocol::FsBroker::Req::PreadSync
Definition: PreadSync.h:17
SWC::Comm::Protocol::FsBroker::Req::Close::Ptr
std::shared_ptr< Close > Ptr
Definition: Close.h:19
SWC::Comm::Protocol::FsBroker::Req::Mkdirs
Definition: Mkdirs.h:17
SWC::FS::FileSystemBroker::cfg_timeout
const Config::Property::Value_int32_g::Ptr cfg_timeout
Definition: FileSystem.h:171
Exists.h
SWC::Comm::Protocol::FsBroker::Req::CreateSync::Ptr
std::shared_ptr< CreateSync > Ptr
Definition: CreateSync.h:20
SWC::Comm::Protocol::FsBroker::Req::Read::Ptr
std::shared_ptr< Read > Ptr
Definition: Read.h:19
SWC::FS::FileSystemBroker::sync
void sync(int &err, SmartFd::Ptr &smartfd) override
Definition: FileSystem.cc:655
SWC::Comm::Protocol::FsBroker::Req::CloseSync::Ptr
std::shared_ptr< CloseSync > Ptr
Definition: CloseSync.h:19
SWC::Comm::Protocol::FsBroker::Req::ExistsSync::Ptr
std::shared_ptr< ExistsSync > Ptr
Definition: ExistsSync.h:19
SWC_THROW
#define SWC_THROW(_code_, _msg_)
Definition: Exception.h:134
SWC::FS::Callback::LengthCb_t
std::function< void(int, size_t)> LengthCb_t
Definition: Callbacks.h:22
SWC::Comm::Protocol::FsBroker::Req::Append::Ptr
std::shared_ptr< Append > Ptr
Definition: Append.h:19
SWC::FS::Callback::SyncCb_t
std::function< void(int)> SyncCb_t
Definition: Callbacks.h:40
ConnHandler.h
SWC::Comm::Protocol::FsBroker::Req::MkdirsSync
Definition: MkdirsSync.h:17
SWC::FS::Flags
Flags
Definition: FileSystem.h:41
SWC::FS::FileSystemBroker::m_connections
Core::QueueSafe< Comm::ConnHandlerPtr > m_connections
Definition: FileSystem.h:169
Rmdir.h
SyncSync.h
SWC::FS::FileSystem
Definition: FileSystem.h:101
FileSystem.h
SWC::Core::Encoder::from_string_encoding
SWC_CAN_INLINE int from_string_encoding(const std::string &typ) noexcept
Definition: Encoder.h:47
ReadAll.h
SWC::Config::boo
Property::Value_bool::Ptr boo(const bool &v)
Definition: PropertiesParser.cc:21
SWC::FS::BROKER
@ BROKER
Definition: FileSystem.h:24
SWC::Comm::Protocol::FsBroker::Req::WriteSync
Definition: WriteSync.h:17
Base.h
ReadSync.h
SWC::Comm::Protocol::FsBroker::Req::Rename::Ptr
std::shared_ptr< Rename > Ptr
Definition: Rename.h:19
SWC::FS::Callback::ExistsCb_t
std::function< void(int, bool)> ExistsCb_t
Definition: Callbacks.h:20
SWC::Comm::Protocol::FsBroker::Req::ReaddirSync::Ptr
std::shared_ptr< ReaddirSync > Ptr
Definition: ReaddirSync.h:19
SWC::Config::Property::Value_int32_g::get
SWC_CAN_INLINE int32_t get() const noexcept
Definition: Property.h:610
Remove.h
CombiPread.h
SWC_FS_PREAD_START
#define SWC_FS_PREAD_START(_smartfd, _offset, _amount)
Definition: Logger.h:185
SWC::FS::FileSystemBroker
Definition: FileSystem.h:30
SWC::FS::FileSystemBroker::get_type_underlying
Type SWC_PURE_FUNC get_type_underlying() const noexcept override
Definition: FileSystem.cc:177
SWC::Comm::Protocol::FsBroker::Req::Rename
Definition: Rename.h:17
SWC::FS::Configurables
Definition: FileSystem.h:48
SWC_FS_COMBI_PREAD_START
#define SWC_FS_COMBI_PREAD_START(_smartfd, _offset, _amount)
Definition: Logger.h:201
SWC_DEFAULT_COMM_ENCODER
#define SWC_DEFAULT_COMM_ENCODER
Definition: Encoder.h:23
SWC::FS::Callback::CloseCb_t
std::function< void(int)> CloseCb_t
Definition: Callbacks.h:41
AppContext.h
PreadSync.h
SWC::Comm::Protocol::FsBroker::Req::Open::Ptr
std::shared_ptr< Open > Ptr
Definition: Open.h:19
Open.h
SWC::Config::i16
Property::Value_uint16::Ptr i16(const uint16_t &v)
Definition: PropertiesParser.cc:29
SWC::Comm::Protocol::FsBroker::Req::RmdirSync
Definition: RmdirSync.h:17
Mkdirs.h
SWC::Comm::Protocol::FsBroker::Req::Write
Definition: Write.h:17
SWC::FS::Callback::RenameCb_t
std::function< void(int)> RenameCb_t
Definition: Callbacks.h:27
SWC_FS_CLOSE_START
#define SWC_FS_CLOSE_START(_smartfd)
Definition: Logger.h:263
SWC::Comm::Protocol::FsBroker::Req::Readdir
Definition: Readdir.h:17
SWC::FS::ImplOptions
Definition: FileSystem.h:66
Sync.h
SWC::Core::QueueSafe::push
SWC_CAN_INLINE void push(const ItemT &item)
Definition: QueueSafe.h:42
SWC::FS::FileSystemBroker::m_service
Comm::client::Serialized::Ptr m_service
Definition: FileSystem.h:166
SWC::FS::FileSystemBroker::get_type
Type SWC_CONST_FUNC get_type() const noexcept override
Definition: FileSystem.cc:173
Write.h
SWC::Comm::Protocol::FsBroker::Req::SyncSync::Ptr
std::shared_ptr< SyncSync > Ptr
Definition: SyncSync.h:19
SWC::Comm::Protocol::FsBroker::Req::Remove
Definition: Remove.h:17
SWC::Comm::Protocol::FsBroker::Req::Read
Definition: Read.h:17
SWC::Comm::Protocol::FsBroker::Req::Append
Definition: Append.h:17
SWC::Comm::Protocol::FsBroker::Req::RemoveSync
Definition: RemoveSync.h:17
SWC::Core::AtomicBase::store
constexpr SWC_CAN_INLINE void store(T v) noexcept
Definition: Atomic.h:37
SWC::FS::FileSystemBroker::seek
void seek(int &err, SmartFd::Ptr &smartfd, size_t offset) override
Definition: FileSystem.cc:612
SWC::Comm::Protocol::FsBroker::Req::CombiPread
Definition: CombiPread.h:17
SWC_FS_RENAME_START
#define SWC_FS_RENAME_START(_from, _to)
Definition: Logger.h:103
SWC::Comm::Protocol::FsBroker::Req::RenameSync::Ptr
std::shared_ptr< RenameSync > Ptr
Definition: RenameSync.h:19
SWC::Comm::Protocol::FsBroker::Req::Remove::Ptr
std::shared_ptr< Remove > Ptr
Definition: Remove.h:19
OpenSync.h
SWC_FS_MKDIRS_START
#define SWC_FS_MKDIRS_START(_path)
Definition: Logger.h:67
SWC::Comm::Protocol::FsBroker::Req::AppendSync::Ptr
std::shared_ptr< AppendSync > Ptr
Definition: AppendSync.h:19
SWC::FS::FileSystemBroker::append
size_t append(int &err, SmartFd::Ptr &smartfd, StaticBuffer &buffer, Flags flags) override
Definition: FileSystem.cc:469
SWC::FS::FileSystemBroker::rmdir
void rmdir(int &err, const std::string &name) override
Definition: FileSystem.cc:317
SWC::Comm::Protocol::FsBroker::Req::ReadAllSync
Definition: ReadAllSync.h:16
SWC::Comm::Protocol::FsBroker::Req::Pread::Ptr
std::shared_ptr< Pread > Ptr
Definition: Pread.h:19
fs_make_new_broker
SWC::FS::FileSystem * fs_make_new_broker(SWC::FS::Configurables *config)
Definition: FileSystem.cc:703
WriteSync.h
SWC_FS_SYNC_START
#define SWC_FS_SYNC_START(_smartfd)
Definition: Logger.h:252
SWC::FS::FileSystemBroker::cfg_timeout_ratio
const Config::Property::Value_int32_g::Ptr cfg_timeout_ratio
Definition: FileSystem.h:172
SWC_FS_WRITE_START
#define SWC_FS_WRITE_START(_smartfd, _replication, _amount)
Definition: Logger.h:156
SWC::Comm::Protocol::FsBroker::Req::Pread
Definition: Pread.h:17
SWC
The SWC-DB C++ namespace 'SWC'.
Definition: main.cc:12
SWC::Comm::Protocol::FsBroker::Req::MkdirsSync::Ptr
std::shared_ptr< MkdirsSync > Ptr
Definition: MkdirsSync.h:19
SWC::FS::FileSystemBroker::m_io
Comm::IoContextPtr m_io
Definition: FileSystem.h:165
SWC::Comm::Protocol::FsBroker::Req::Base::Ptr
BasePtr Ptr
Definition: Base.h:20
SWC::Comm::Protocol::FsBroker::Req::Sync::Ptr
std::shared_ptr< Sync > Ptr
Definition: Sync.h:19
SWC::FS::Configurables::settings
Config::Settings::Ptr settings
Definition: FileSystem.h:49
SWC::Core::Buffer
Definition: Buffer.h:18
RemoveSync.h
SWC::Core::Buffer::size
size_t size
Definition: Buffer.h:130
LengthSync.h
SWC::FS::Callback::ReadAllCb_t
std::function< void(int, StaticBuffer &&)> ReadAllCb_t
Definition: Callbacks.h:30
SWC_FS_CREATE_START
#define SWC_FS_CREATE_START(_smartfd, _replication)
Definition: Logger.h:131
CloseSync.h
SWC::Config::strs
Property::Value_strings::Ptr strs(Strings &&v)
Definition: PropertiesParser.cc:49
RmdirSync.h
SWC_THROWF
#define SWC_THROWF(_code_, _fmt_,...)
Definition: Exception.h:136
SWC::FS::Configurables::cfg_fds_max
Config::Property::Value_int32_g::Ptr cfg_fds_max
Definition: FileSystem.h:50
SWC::Comm::Protocol::FsBroker::Req::FlushSync::Ptr
std::shared_ptr< FlushSync > Ptr
Definition: FlushSync.h:19
SWC_FS_OPEN_START
#define SWC_FS_OPEN_START(_smartfd)
Definition: Logger.h:144
SWC::Config::str
Property::Value_string::Ptr str(std::string &&v)
Definition: PropertiesParser.cc:45
SWC::Comm::Protocol::FsBroker::Req::RmdirSync::Ptr
std::shared_ptr< RmdirSync > Ptr
Definition: RmdirSync.h:19
SWC::FS::Callback::ReaddirCb_t
std::function< void(int, DirentList &&)> ReaddirCb_t
Definition: Callbacks.h:25
SWC::FS::Callback::RemoveCb_t
std::function< void(int)> RemoveCb_t
Definition: Callbacks.h:21
SWC::Comm::Protocol::FsBroker::Req::AppendSync
Definition: AppendSync.h:17
SWC::Comm::Protocol::FsBroker::Req::SeekSync
Definition: SeekSync.h:17
SWC::FS::FileSystemBroker::m_type_underlying
Type m_type_underlying
Definition: FileSystem.h:167
SWC::Comm::Protocol::FsBroker::Req::ReadAll::Ptr
std::shared_ptr< ReadAll > Ptr
Definition: ReadAll.h:19
SWC::FS::Callback::RmdirCb_t
std::function< void(int)> RmdirCb_t
Definition: Callbacks.h:26
SWC::Comm::Protocol::FsBroker::Req::ReadAllSync::Ptr
std::shared_ptr< ReadAllSync > Ptr
Definition: ReadAllSync.h:18
SWC::Comm::ConnHandlerPtr
std::shared_ptr< ConnHandler > ConnHandlerPtr
Definition: AppContext.h:17
SWC::Comm::Protocol::FsBroker::Req::ReadAll
Definition: ReadAll.h:17
SWC::Comm::Protocol::FsBroker::Req::Create
Definition: Create.h:18
RenameSync.h
SWC::Error::CONFIG_BAD_VALUE
@ CONFIG_BAD_VALUE
Definition: Error.h:81
SWC::FS::FileSystem::settings
const Config::Settings::Ptr settings
Definition: FileSystem.h:110
SWC::Comm::Protocol::FsBroker::Req::Flush::Ptr
std::shared_ptr< Flush > Ptr
Definition: Flush.h:19
Commands.h
SWC::format
std::string format(const char *fmt,...) __attribute__((format(printf
Definition: String.cc:17
SWC::FS::Callback::CreateCb_t
std::function< void(int)> CreateCb_t
Definition: Callbacks.h:33
SWC::Comm::Protocol::FsBroker::Req::Exists::Ptr
std::shared_ptr< Exists > Ptr
Definition: Exists.h:19
SWC::Core::Vector< EndPoint >
SWC::Comm::Protocol::FsBroker::Req::Create::Ptr
std::shared_ptr< Create > Ptr
Definition: Create.h:20
SWC::FS::FileSystemBroker::send_request
bool send_request(Comm::Protocol::FsBroker::Req::BasePtr hdlr)
Definition: FileSystem.cc:189
SWC::Comm::Protocol::FsBroker::Req::Sync
Definition: Sync.h:17
SWC::Condition::from
Comp from(const char **buf, uint32_t *remainp, uint8_t extended=0x00) noexcept
Definition: Comparators.cc:15
SWC::FS::SmartFd::Ptr
std::shared_ptr< SmartFd > Ptr
Definition: SmartFd.h:37
SWC_FS_READDIR_START
#define SWC_FS_READDIR_START(_path)
Definition: Logger.h:79
SeekSync.h
SWC::FS::Callback::FlushCb_t
std::function< void(int)> FlushCb_t
Definition: Callbacks.h:39
SWC::FS::FileSystem::m_run
Core::AtomicBool m_run
Definition: FileSystem.h:113
SWC::FS::FileSystem::stop
virtual void stop()
Definition: FileSystem.cc:115
Seek.h
SWC::FS::FileSystemBroker::combi_pread
void combi_pread(int &err, SmartFd::Ptr &smartfd, uint64_t offset, uint32_t amount, StaticBuffer *dst) override
Definition: FileSystem.cc:412
Rename.h
MkdirsSync.h
SWC::Comm::Protocol::FsBroker::Req::OpenSync::Ptr
std::shared_ptr< OpenSync > Ptr
Definition: OpenSync.h:19
SWC::FS::FileSystemBroker::to_string
std::string to_string() const override
Definition: FileSystem.cc:181
SWC::FS::Configurables::stats_enabled
bool stats_enabled
Definition: FileSystem.h:52
SWC::Comm::Protocol::FsBroker::Req::CloseSync
Definition: CloseSync.h:17
SWC::Comm::Event::make
static SWC_CAN_INLINE Ptr make(int error)
Definition: Event.h:36
SWC::Comm::Protocol::FsBroker::Req::Rmdir
Definition: Rmdir.h:17
Read.h
SWC_FS_READ_START
#define SWC_FS_READ_START(_smartfd, _amount)
Definition: Logger.h:170
SWC::FS::FileSystemBroker::mkdirs
void mkdirs(int &err, const std::string &name) override
Definition: FileSystem.cc:274
SWC::FS::FileSystemBroker::remove
void remove(int &err, const std::string &name) override
Definition: FileSystem.cc:231
SWC::Comm::Protocol::FsBroker::Req::SeekSync::Ptr
std::shared_ptr< SeekSync > Ptr
Definition: SeekSync.h:19
SWC::Comm::Protocol::FsBroker::Req::WriteSync::Ptr
std::shared_ptr< WriteSync > Ptr
Definition: WriteSync.h:19
SWC::FS::FileSystemBroker::exists
bool exists(int &err, const std::string &name) override
File/Dir name actions.
Definition: FileSystem.cc:208
SWC::FS::FileSystemBroker::flush
void flush(int &err, SmartFd::Ptr &smartfd) override
Definition: FileSystem.cc:634
SWC::FS::FileSystemBroker::stop
void stop() override
Definition: FileSystem.cc:165
SWC::Comm::Protocol::FsBroker::Req::Open
Definition: Open.h:17
SWC::Comm::Protocol::FsBroker::Req::CombiPreadSync::Ptr
std::shared_ptr< CombiPreadSync > Ptr
Definition: CombiPreadSync.h:18
SWC::FS::FileSystemBroker::get_endpoints
static Comm::EndPoints get_endpoints(const Config::Settings::Ptr &settings)
Definition: FileSystem.cc:105
SWC::Comm::Protocol::FsBroker::Req::Length
Definition: Length.h:17
SWC::Comm::Protocol::FsBroker::Req::Flush
Definition: Flush.h:17
SWC_FS_EXISTS_START
#define SWC_FS_EXISTS_START(_path)
Definition: Logger.h:31
SWC::Comm::Protocol::FsBroker::Req::Seek
Definition: Seek.h:17
SWC::Comm::Protocol::FsBroker::Req::Length::Ptr
std::shared_ptr< Length > Ptr
Definition: Length.h:19
SWC::Comm::Protocol::FsBroker::Req::ReadSync::Ptr
std::shared_ptr< ReadSync > Ptr
Definition: ReadSync.h:19
SWC::Comm::Protocol::FsBroker::Req::Write::Ptr
std::shared_ptr< Write > Ptr
Definition: Write.h:19
SWC::FS::Callback::SeekCb_t
std::function< void(int)> SeekCb_t
Definition: Callbacks.h:38
SWC::Core::Encoder::repr_encoding
SWC_CAN_INLINE std::string repr_encoding(int typ)
Definition: Encoder.h:42
SWC::Comm::Protocol::FsBroker::Req::LengthSync
Definition: LengthSync.h:17
SWC::Comm::Protocol::FsBroker::Req::ExistsSync
Definition: ExistsSync.h:17
SWC_FS_RMDIR_START
#define SWC_FS_RMDIR_START(_path)
Definition: Logger.h:91
flags
uint8_t flags
Flags.
Definition: Header.h:55
SWC::Comm::Protocol::FsBroker::Req::Mkdirs::Ptr
std::shared_ptr< Mkdirs > Ptr
Definition: Mkdirs.h:19
SWC::Comm::Protocol::FsBroker::Req::LengthSync::Ptr
std::shared_ptr< LengthSync > Ptr
Definition: LengthSync.h:19
SWC_FS_SEEK_START
#define SWC_FS_SEEK_START(_smartfd, _offset)
Definition: Logger.h:230
SWC::Comm::Protocol::FsBroker::Req::ReadSync
Definition: ReadSync.h:17
SWC_FS_LENGTH_START
#define SWC_FS_LENGTH_START(_path)
Definition: Logger.h:55
SWC::FS::FileSystemBroker::m_endpoints
const Comm::EndPoints m_endpoints
Definition: FileSystem.h:168
SWC::FS::FileSystemBroker::create
void create(int &err, SmartFd::Ptr &smartfd, uint8_t replication) override
Definition: FileSystem.cc:442
Close.h
SWC::Comm::Resolver::get_endpoints
EndPoints get_endpoints(uint16_t defaul_port, const Config::Strings &addrs, const std::string &host, const Networks &nets, bool srv=false)
Definition: Resolver.cc:152
SWC::FS::FileSystemBroker::read
void read(int &err, const std::string &name, StaticBuffer *dst) override
Definition: FileSystem.cc:389
SWC::Comm::Protocol::FsBroker::Req::CombiPreadSync
Definition: CombiPreadSync.h:16
ReadAllSync.h
SWC::FS::FileSystemBroker::close
void close(int &err, SmartFd::Ptr &smartfd) override
Definition: FileSystem.cc:676
SWC::FS::Callback::AppendCb_t
std::function< void(int, size_t)> AppendCb_t
Definition: Callbacks.h:37
SWC::Comm::Protocol::FsBroker::Req::CreateSync
Definition: CreateSync.h:18
SWC_FS_READALL_START
#define SWC_FS_READALL_START(_name)
Definition: Logger.h:115
SWC::Comm::Protocol::FsBroker::Req::PreadSync::Ptr
std::shared_ptr< PreadSync > Ptr
Definition: PreadSync.h:19
Readdir.h
SWC::Comm::Protocol::FsBroker::Req::RemoveSync::Ptr
std::shared_ptr< RemoveSync > Ptr
Definition: RemoveSync.h:19
SWC::FS::Callback::MkdirsCb_t
std::function< void(int)> MkdirsCb_t
Definition: Callbacks.h:24
SWC::FS::FileSystem::statistics
Statistics statistics
Definition: FileSystem.h:114
SWC::Comm::Protocol::FsBroker::Req::RenameSync
Definition: RenameSync.h:17
SWC_FS_REMOVE_START
#define SWC_FS_REMOVE_START(_path)
Definition: Logger.h:43
SWC::Config::Property::Value_int32_g
Definition: Property.h:586
SWC::Comm::Protocol::FsBroker::Req::CombiPread::Ptr
std::shared_ptr< CombiPread > Ptr
Definition: CombiPread.h:19
AppendSync.h
SWC::Comm::Protocol::FsBroker::Req::Exists
Definition: Exists.h:17
SWC::FS::to_string
const char *SWC_CONST_FUNC to_string(Type typ) noexcept
Definition: FileSystem.cc:47
SWC::FS::FileSystemBroker::pread
size_t pread(int &err, SmartFd::Ptr &smartfd, uint64_t offset, void *dst, size_t amount) override
Definition: FileSystem.cc:564
CreateSync.h
SWC::Comm::Protocol::FsBroker::Req::Seek::Ptr
std::shared_ptr< Seek > Ptr
Definition: Seek.h:19
SWC::Core::QueueSafe::pop
SWC_CAN_INLINE bool pop(ItemT *item)
Definition: QueueSafe.h:97
SWC::FS::FileSystemBroker::~FileSystemBroker
virtual ~FileSystemBroker() noexcept
Definition: FileSystem.cc:163