SWC-DB  v0.5.12 C++ documentations
SWC-DB© (Super Wide Column Database) - High Performance Scalable Database (https://github.com/kashirin-alex/swc-db)
BrokerScanner.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 
6 
9 
10 
11 namespace SWC { namespace client { namespace Query { namespace Select {
12 
13 
14 
15 #define SWC_SCANNER_REQ_DEBUG(msg) \
16  SWC_LOG_OUT(LOG_DEBUG, params.print(SWC_LOG_OSTREAM << msg << ' '); );
17 
18 #define SWC_SCANNER_RSP_DEBUG(msg) \
19  SWC_LOG_OUT(LOG_DEBUG, \
20  print(SWC_LOG_OSTREAM << msg << ' '); \
21  rsp.print(SWC_LOG_OSTREAM << ' '); \
22  );
23 
24 
26 
27 void BrokerScanner::print(std::ostream& out) {
28  out << "BrokerScanner(cid=" << cid << ' ';
29  interval.print(out);
30  out << " completion=" << selector->completion.count()
31  << ')';
32 }
33 
36  SWC_SCANNER_REQ_DEBUG("bkr_select");
37  struct ReqData {
38  Ptr scanner;
41  ReqData(const Ptr& a_scanner) noexcept
42  : scanner(a_scanner),
43  profile(scanner->selector->profile.bkr()) {
44  }
46  ~ReqData() noexcept { }
48  client::Clients::Ptr& get_clients() noexcept {
49  return scanner->selector->clients;
50  }
52  bool valid() {
53  return scanner->selector->valid();
54  }
56  void callback(const ReqBase::Ptr& req,
58  profile.add(rsp.err);
59  scanner->selected(req, rsp);
60  }
61  };
63  ::request(params, selector->timeout, shared_from_this());
64 }
65 
68  switch(rsp.err) {
69  case Error::OK: {
70  SWC_SCANNER_RSP_DEBUG("bkr_selected");
73 
74  if(!rsp.data.size ||
75  selector->add_cells(cid, rsp.data, rsp.more, interval)) {
76  if(rsp.more && selector->valid())
77  return select();
78  }
79  break;
80  }
84  SWC_SCANNER_RSP_DEBUG("bkr_selected QUIT");
85  selector->clients->schemas.remove(cid);
86  selector->error(rsp.err); // rsp.err = Error::CONSIST_ERRORS;
87  selector->error(cid, rsp.err);
88  break;
89  }
91  SWC_SCANNER_RSP_DEBUG("bkr_selected STOPPED");
92  selector->error(rsp.err);
93  break;
94  }
95  default: {
96  if(selector->valid()) {
97  SWC_SCANNER_RSP_DEBUG("bkr_selected RETRYING");
98  return req->request_again();
99  }
100  }
101  }
102  if(selector->completion.is_last())
103  selector->response(rsp.err);
104 }
105 
106 
107 #undef SWC_SCANNER_REQ_DEBUG
108 #undef SWC_SCANNER_RSP_DEBUG
109 
110 }}}}
SWC::client::Query::Select::BrokerScanner::~BrokerScanner
~BrokerScanner() noexcept
Definition: BrokerScanner.cc:25
SWC::Error::COLUMN_SCHEMA_NAME_NOT_EXISTS
@ COLUMN_SCHEMA_NAME_NOT_EXISTS
Definition: Error.h:105
SWC::Comm::Protocol::Bkr::Params::CellsSelectRsp::offset
uint64_t offset
Definition: CellsSelect.h:95
SWC::client::Query::Select::BrokerScanner::selected
void selected(const ReqBase::Ptr &req, Comm::Protocol::Bkr::Params::CellsSelectRsp &rsp)
Definition: BrokerScanner.cc:66
SWC::client::Clients::Ptr
ClientsPtr Ptr
Definition: Clients.h:58
SWC::client::Query::Select::BrokerScanner::Ptr
std::shared_ptr< BrokerScanner > Ptr
Definition: BrokerScanner.h:34
SWC::DB::Specs::Flags::offset
uint64_t offset
Definition: SpecsFlags.h:142
SWC::DB::Specs::Interval::print
void print(std::ostream &out) const
Definition: SpecsInterval.cc:322
SWC::client::Query::Select::BrokerScanner::selector
Handlers::Base::Ptr selector
Definition: BrokerScanner.h:35
SWC::Comm::Protocol::Bkr::Params::CellsSelectReqRef
Definition: CellsSelect.h:48
SWC::client::Query::Select::BrokerScanner::print
void print(std::ostream &out)
Definition: BrokerScanner.cc:27
CellsSelect.h
SWC::Error::OK
@ OK
Definition: Error.h:45
SWC_CAN_INLINE
#define SWC_CAN_INLINE
Definition: Compat.h:102
SWC
The SWC-DB C++ namespace 'SWC'.
Definition: main.cc:12
SWC::Comm::Protocol::Bkr::Req::CellsSelect::request
static SWC_CAN_INLINE void request(const Params::CellsSelectReqRef &params, const uint32_t timeout, DataArgsT &&... args)
Definition: CellsSelect.h:37
SWC::Comm::Protocol::Bkr::Params::CellsSelectRsp::more
bool more
Definition: CellsSelect.h:94
SWC::client::Query::Select::BrokerScanner::cid
const cid_t cid
Definition: BrokerScanner.h:37
SWC::Core::Buffer::size
size_t size
Definition: Buffer.h:130
BrokerScanner.h
SWC_SCANNER_RSP_DEBUG
#define SWC_SCANNER_RSP_DEBUG(msg)
Definition: BrokerScanner.cc:18
SWC::Error::CLIENT_STOPPING
@ CLIENT_STOPPING
Definition: Error.h:127
SWC::DB::Specs::Interval::flags
Flags flags
Definition: SpecsInterval.h:242
SWC::Error::COLUMN_NOT_EXISTS
@ COLUMN_NOT_EXISTS
Definition: Error.h:100
SWC::Comm::Protocol::Bkr::Params::CellsSelectRsp::err
int32_t err
Definition: CellsSelect.h:93
SWC::Error::COLUMN_MARKED_REMOVED
@ COLUMN_MARKED_REMOVED
Definition: Error.h:102
SWC_SCANNER_REQ_DEBUG
#define SWC_SCANNER_REQ_DEBUG(msg)
Definition: BrokerScanner.cc:15
SWC::Comm::Protocol::Bkr::Params::CellsSelectRsp
Definition: CellsSelect.h:77
SWC::client::Query::Profiling::Component::Start
Definition: Profiling.h:56
SWC::client::Query::Select::BrokerScanner::interval
DB::Specs::Interval interval
Definition: BrokerScanner.h:36
SWC::Comm::client::ConnQueueReqBase::Ptr
std::shared_ptr< ConnQueueReqBase > Ptr
Definition: ClientConnQueue.h:25
SWC::client::Query::Select::BrokerScanner::select
void select()
Definition: BrokerScanner.cc:34
SWC::Comm::Protocol::Bkr::Params::CellsSelectRsp::data
StaticBuffer data
Definition: CellsSelect.h:96
SWC::client::Query::Profiling::Component::Start::add
SWC_CAN_INLINE void add(bool err) const noexcept
Definition: Profiling.h:66