SWC-DB  v0.5.12 C++ documentations
SWC-DB© (Super Wide Column Database) - High Performance Scalable Database (https://github.com/kashirin-alex/swc-db)
RangeUnloaded.h
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 
6 
7 #ifndef swcdb_manager_Protocol_handlers_RangeUnloaded_h
8 #define swcdb_manager_Protocol_handlers_RangeUnloaded_h
9 
11 
12 
13 namespace SWC { namespace Comm { namespace Protocol {
14 namespace Mngr { namespace Handler {
15 
16 
17 void range_unloaded(const ConnHandlerPtr& conn, const Event::Ptr& ev) {
18  Params::RangeUnloadedRsp rsp_params;
19  try {
20  const uint8_t *ptr = ev->data.base;
21  size_t remain = ev->data.size;
22 
24  params.decode(&ptr, &remain);
25  SWC_PRINT << "RangeUnloaded: " << params.to_string() << SWC_PRINT_CLOSE;
26 
27  auto col = Env::Mngr::mngd_columns()->get_column(
28  rsp_params.err, params.cid);
29  if(rsp_params.err) {
30  if(rsp_params.err == Error::COLUMN_MARKED_REMOVED ||
31  rsp_params.err == Error::MNGR_NOT_ACTIVE ||
32  rsp_params.err == Error::COLUMN_NOT_EXISTS)
33  goto send_response;
34  rsp_params.err = Error::OK;
35  }
36 
37  auto range = col->get_range(params.rid);
38  if(!range) {
39  rsp_params.err = Error::RANGE_NOT_FOUND;
40  goto send_response;
41  }
42 
43  range->set_state_none();
45 
46  } catch(...) {
49  rsp_params.err = e.code();
50  }
51 
52  send_response:
53  SWC_PRINT << "RangeUnloaded(RSP): " << rsp_params.to_string()
54  << SWC_PRINT_CLOSE;
55  conn->send_response(Buffers::make(ev, rsp_params));
56 
57 }
58 
59 
60 }}}}}
61 
62 #endif // swcdb_manager_Protocol_handlers_RangeUnloaded_h
SWC::Manager::MngdColumns::get_column
Column::Ptr get_column(int &err, cid_t cid)
Definition: MngdColumns.cc:174
SWC::Error::Exception::code
constexpr SWC_CAN_INLINE int code() const noexcept
Definition: Exception.h:51
SWC_LOG_OSTREAM
#define SWC_LOG_OSTREAM
Definition: Logger.h:44
SWC::Comm::Protocol::Mngr::Params::RangeUnloadedRsp::err
int err
Definition: RangeUnloaded.h:78
SWC_LOG_OUT
#define SWC_LOG_OUT(pr, _code_)
Definition: Logger.h:178
SWC::Comm::Protocol::Mngr::Params::RangeUnloadedReq::cid
cid_t cid
Definition: RangeUnloaded.h:26
SWC_PRINT
#define SWC_PRINT
Definition: Logger.h:167
SWC::Comm::Protocol::Mngr::Params::RangeUnloadedRsp::to_string
std::string to_string() const
Definition: RangeUnloaded.h:80
SWC_PRINT_CLOSE
#define SWC_PRINT_CLOSE
Definition: Logger.h:171
SWC::Error::OK
@ OK
Definition: Error.h:45
SWC::Comm::Protocol::Mngr::Params::RangeUnloadedReq
Definition: RangeUnloaded.h:16
SWC_CURRENT_EXCEPTION
#define SWC_CURRENT_EXCEPTION(_msg_)
Definition: Exception.h:119
SWC::Comm::Protocol::Mngr::Params::RangeUnloadedReq::to_string
std::string to_string() const
Definition: RangeUnloaded.h:29
SWC
The SWC-DB C++ namespace 'SWC'.
Definition: main.cc:12
SWC::Env::Mngr::mngd_columns
static SWC_CAN_INLINE Manager::MngdColumns * mngd_columns() noexcept
Definition: MngrEnv.h:74
SWC::Comm::Protocol::Mngr::Params::RangeUnloadedReq::rid
rid_t rid
Definition: RangeUnloaded.h:27
SWC::LOG_ERROR
@ LOG_ERROR
Definition: Logger.h:32
SWC::Comm::Protocol::Mngr::Handler::range_unloaded
void range_unloaded(const ConnHandlerPtr &conn, const Event::Ptr &ev)
Definition: RangeUnloaded.h:17
SWC::Comm::ConnHandlerPtr
std::shared_ptr< ConnHandler > ConnHandlerPtr
Definition: AppContext.h:17
SWC::Error::COLUMN_NOT_EXISTS
@ COLUMN_NOT_EXISTS
Definition: Error.h:100
SWC::Comm::Protocol::Mngr::Params::RangeUnloadedRsp
Definition: RangeUnloaded.h:59
SWC::Comm::Buffers::make
static SWC_CAN_INLINE Ptr make(uint32_t reserve=0)
Definition: Buffers.h:27
RangeUnloaded.h
SWC::Manager::Rangers::assign_ranges
void assign_ranges()
Definition: Rangers.cc:544
SWC::Error::RANGE_NOT_FOUND
@ RANGE_NOT_FOUND
Definition: Error.h:116
SWC::Error::COLUMN_MARKED_REMOVED
@ COLUMN_MARKED_REMOVED
Definition: Error.h:102
SWC::Comm::Serializable::decode
void decode(const uint8_t **bufp, size_t *remainp)
Definition: Serializable.h:59
SWC::Comm::Event::Ptr
std::shared_ptr< Event > Ptr
Definition: Event.h:33
SWC::Error::MNGR_NOT_ACTIVE
@ MNGR_NOT_ACTIVE
Definition: Error.h:87
SWC::Error::Exception
Definition: Exception.h:21
SWC::Env::Mngr::rangers
static SWC_CAN_INLINE Manager::Rangers * rangers() noexcept
Definition: MngrEnv.h:69