SWC-DB  v0.5.12 C++ documentations
SWC-DB© (Super Wide Column Database) - High Performance Scalable Database (https://github.com/kashirin-alex/swc-db)
MngrRole.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 
8 
9 namespace SWC { namespace Manager {
10 
11 
13  const Comm::EndPoints& endpoints)
14  : m_local_endpoints(endpoints),
15  m_local_token(Comm::endpoints_hash(m_local_endpoints)),
16  m_mutex(), m_states(), m_checkin(), m_local_groups(),
17  m_local_active_role(DB::Types::MngrRole::NONE),
18  m_major_updates(false), m_mngrs_client_srv(),
19  m_mutex_timer(),
20  m_check_timer(asio::high_resolution_timer(app_io->executor())),
21  m_run(true),
22  m_mngr_inchain(new Comm::client::ConnQueue(app_io)),
23  cfg_conn_probes(
24  Env::Config::settings()->get<Config::Property::Value_uint16_g>(
25  "swc.mngr.role.connection.probes")),
26  cfg_conn_timeout(
27  Env::Config::settings()->get<Config::Property::Value_int32_g>(
28  "swc.mngr.role.connection.timeout")),
29  cfg_conn_fb_failures(
30  Env::Config::settings()->get<Config::Property::Value_int32_g>(
31  "swc.mngr.role.connection.fallback.failures")),
32  cfg_req_timeout(
33  Env::Config::settings()->get<Config::Property::Value_int32_g>(
34  "swc.mngr.role.request.timeout")),
35  cfg_delay_updated(
36  Env::Config::settings()->get<Config::Property::Value_int32_g>(
37  "swc.mngr.role.check.delay.updated")),
38  cfg_check_interval(
39  Env::Config::settings()->get<Config::Property::Value_int32_g>(
40  "swc.mngr.role.check.interval")),
41  cfg_delay_fallback(
42  Env::Config::settings()->get<Config::Property::Value_int32_g>(
43  "swc.mngr.role.check.delay.fallback")) {
44  schedule_checkin(3000);
45 }
46 
47 void MngrRole::schedule_checkin(uint32_t t_ms) {
49  if(!m_run)
50  return;
51 
52  auto set_in = std::chrono::milliseconds(t_ms);
53  auto set_on = m_check_timer.expiry();
54  auto now = asio::high_resolution_timer::clock_type::now();
55  if(set_on > now && set_on < now + set_in)
56  return;
57 
58  m_check_timer.expires_after(set_in);
59  struct TimerTask {
60  MngrRole* ptr;
62  TimerTask(MngrRole* a_ptr) noexcept : ptr(a_ptr) { }
63  void operator()(const asio::error_code& ec) {
64  if(ec != asio::error::operation_aborted)
65  ptr->managers_checkin();
66  }
67  };
68  m_check_timer.async_wait(TimerTask(this));
69 
70  SWC_LOGF(LOG_DEBUG, "MngrRole managers_checkin scheduled in ms=%u", t_ms);
71 }
72 
75  auto host = active_mngr(cid);
76  return host && Comm::has_endpoint(host->endpoints, m_local_endpoints);
77 }
78 
80 bool MngrRole::is_active_role(uint8_t role) {
81  return m_local_active_role & role;
82 }
83 
87  for(auto& host : m_states) {
88  if(host->state == DB::Types::MngrState::ACTIVE &&
89  host->role & DB::Types::MngrRole::COLUMNS &&
90  host->cid_begin <= cid &&
91  (!host->cid_end || host->cid_end >= cid))
92  return host;
93  }
94  return nullptr;
95 }
96 
100  for(auto& host : m_states) {
101  if(host->state == DB::Types::MngrState::ACTIVE &&
102  host->role & role)
103  return host;
104  }
105  return nullptr;
106 }
107 
109  for(auto& g : groups) {
110  bool found = false;
112  for(auto& host : m_states) {
113  if(host->state == DB::Types::MngrState::ACTIVE &&
114  g->role == host->role &&
115  g->cid_begin == host->cid_begin && g->cid_end == host->cid_end) {
116  found = true;
117  break;
118  }
119  }
120  if(!found)
121  return false;
122  }
123  return true;
124 }
125 
128  states.assign(m_states.cbegin(), m_states.cend());
129 }
130 
133  return m_mngr_inchain->get_endpoint_remote();
134 }
135 
139  m_mngr_inchain->put(req);
140 }
141 
142 void MngrRole::fill_states(const MngrsStatus& states, uint64_t token,
143  const Comm::ResponseCallback::Ptr& cb) {
144  bool new_recs = false;
145  bool turn_around = token == m_local_token;
146 
147  for(auto& host : states) {
148 
149  bool local = Comm::has_endpoint(host->endpoints, m_local_endpoints);
150 
151  if(local && !token &&
152  uint8_t(host->state.load()) < uint8_t(DB::Types::MngrState::STANDBY)) {
153  update_state(host->endpoints, DB::Types::MngrState::STANDBY);
154  continue;
155  }
156 
157  MngrStatus::Ptr host_set = get_host(host->endpoints);
158  if(!host_set)
159  continue;
160 
161  if(host_set->state == DB::Types::MngrState::OFF
162  && host->state > DB::Types::MngrState::OFF) {
163  //m_major_updates = true;
164  schedule_checkin(500);
165  }
166 
167  if(uint8_t(host->state.load()) < uint8_t(DB::Types::MngrState::STANDBY)) {
168  if(host->state != host_set->state) {
169  update_state(host->endpoints,
170  host->state != DB::Types::MngrState::NOTSET?
171  host->state : host_set->state);
172  new_recs = true;
173  }
174  continue;
175  }
176 
177  MngrStatus::Ptr high_set = get_highest_state_host(host);
178  if(!high_set)
179  continue;
180 
181  if(high_set->state == DB::Types::MngrState::ACTIVE) {
182  if(host->state != host_set->state
183  && host_set->priority != high_set->priority) {
184  update_state(host->endpoints, DB::Types::MngrState::STANDBY);
185  new_recs = true;
186  }
187  continue;
188  }
189  if(host->state == DB::Types::MngrState::ACTIVE) {
190  update_state(host->endpoints, host->state);
191  new_recs = true;
192  // m_major_updates = true;
193  continue;
194  }
195 
196 
197  if(host->priority > high_set->priority) {
198  if(uint8_t(host->state.load())
199  > uint8_t(DB::Types::MngrState::STANDBY)) {
200  update_state(
201  host->endpoints,
202  DB::Types::MngrState(uint8_t(host->state.load()) - 1)
203  );
204  new_recs = true;
205  }
206  } else {
207  if(uint8_t(host->state.load())
208  < uint8_t(DB::Types::MngrState::ACTIVE)) {
209  update_state(
210  host->endpoints,
211  DB::Types::MngrState(uint8_t(host->state.load()) + 1)
212  );
213  new_recs = true;
214  }
215  }
216  }
217 
218  for(auto& host : states) {
219  if(!is_group_off(host))
220  continue;
221  auto hosts_pr_group =
222  Env::Clients::get()->managers.groups->get_endpoints(
223  host->role, host->cid_begin, host->cid_end);
224  for(auto& h : hosts_pr_group) {
225  if(Comm::has_endpoint(h, host->endpoints)
227  continue;
228 
230  MngrStatus::Ptr l_high = get_highest_state_host(l_host);
231  if(!l_high || l_high->state < DB::Types::MngrState::WANT) {
232  update_state(m_local_endpoints, DB::Types::MngrState::WANT);
233  new_recs = true;
234  }
235  break;
236  }
237  }
238 
239  {
241  if(!token || !turn_around) {
242  if(!token)
243  token = m_local_token;
244 
247  cb, m_states, token, m_local_endpoints[0],
249  + cfg_req_timeout->get()) * m_states.size()
250  )
251  ));
252  // schedule_checkin(3000);
253  return;
254  }
255  }
256 
257  if(cb)
258  cb->response_ok();
259 
261  new_recs ? cfg_delay_updated->get() : cfg_check_interval->get());
262 
265 }
266 
267 void MngrRole::update_manager_addr(uint64_t hash,
268  const Comm::EndPoint& mngr_host) {
269  bool major_updates;
270  {
272 
273  bool new_srv = m_mngrs_client_srv.emplace(hash, mngr_host).second;
274  if(new_srv) {
275  //m_major_updates = true;
276  schedule_checkin(500);
277  }
278  major_updates = m_major_updates;
279  m_major_updates = false;
280  }
281  if(major_updates)
283 }
284 
285 void MngrRole::disconnection(const Comm::EndPoint& endpoint_server,
286  const Comm::EndPoint& endpoint_client,
287  bool srv) {
288  if(!m_run)
289  return;
290  Comm::EndPoints endpoints;
291  {
293 
294  auto it = m_mngrs_client_srv.find(Comm::endpoint_hash(endpoint_server));
295  if(it != m_mngrs_client_srv.cend()) {
296  endpoints.push_back(it->second);
297  m_mngrs_client_srv.erase(it);
298  } else
299  endpoints.push_back(endpoint_server);
300  }
301  MngrStatus::Ptr host_set = get_host(endpoints);
302  if(!host_set)
303  return;
304 
306  host_set->state == DB::Types::MngrState::ACTIVE ?
308 
310  SWC_LOG_OSTREAM << "disconnection, srv=" << srv
311  << " server=" << endpoint_server
312  << " client=" << endpoint_client;
313  );
314  if(host_set->state != DB::Types::MngrState::ACTIVE)
315  update_state(endpoint_server, DB::Types::MngrState::OFF);
316  // m_major_updates = true;
317 }
318 
322  SWC_LOG(LOG_INFO, "Stopping MngrRole");
323 
324  m_run.store(false);
325  {
327  m_check_timer.cancel();
328  }
329 
330  m_mngr_inchain->stop();
331 
332  for(MngrStatus::Ptr h;;) {
333  {
335  if(m_states.empty())
336  break;
337  h = m_states.front();
339  }
340  if(h->conn && h->conn->is_open())
341  h->conn->do_close();
342  }
344 }
345 
346 void MngrRole::print(std::ostream& out) {
347  out << "Mngrs Role:";
348  for(auto& h : m_states)
349  h->print(out << "\n ");
350 
351  m_mngr_inchain->print(out << "\nMngrInchain ");
352 
353  out << "\nLocal-Endpoints: [";
354  for(auto& endpoint : m_local_endpoints)
355  out << endpoint << ',';
356  out << ']';
357 }
358 
360  auto groups = Env::Clients::get()->managers.groups->get_groups();
361  for(auto& g : groups) {
362  // SWC_LOG(LOG_DEBUG, g->to_string().c_str());
363  uint32_t pr = 0;
364  for(auto& endpoints : g->get_hosts()) {
365  ++pr;
366  bool found = false;
367  for(auto& host : m_states) {
368  if((found = Comm::has_endpoint(endpoints, host->endpoints))) {
369  host->priority.store(pr);
370  break;
371  }
372  }
373  if(found)
374  continue;
375 
377  new MngrStatus(
378  g->role, g->cid_begin, g->cid_end, endpoints, nullptr, pr));
379  }
380  }
381  for(auto it=m_states.cbegin(); it != m_states.cend(); ) {
382  bool found = false;
383  for(auto& g : groups) {
384  for(auto& endpoints : g->get_hosts()) {
385  if(Comm::has_endpoint((*it)->endpoints, endpoints)) {
386  found = true;
387  break;
388  }
389  }
390  if(found)
391  break;
392  }
393  if(found)
394  ++it;
395  else
396  m_states.erase(it);
397  }
398 
399  m_local_groups = Env::Clients::get()->managers.groups->get_groups(
401 }
402 
404  if(m_checkin.running())
405  return;
406 
407  //SWC_LOG(LOG_DEBUG, "managers_checkin");
408  uint32_t sz = 0;
409  bool has_role;
410  {
412  _apply_cfg();
413  for(auto& h : m_states) {
414  if(h->state != DB::Types::MngrState::OFF)
415  ++sz;
416  }
417  has_role = !m_local_groups.empty();
418  }
419  if(has_role)
420  return managers_checker(0, sz, false);
421 
423  std::string s;
424  for(auto& endpoint : m_local_endpoints) {
425  s.append(
426  endpoint.address().to_string() + "|" +
427  std::to_string(endpoint.port())+ ",");
428  }
429 
430  if(!m_mngrs_client_srv.empty()) {
431  SWC_LOGF(LOG_DEBUG, "Manager(%s) decommissioned", s.c_str());
432  std::raise(SIGINT);
433  return;
434  }
435 
436  SWC_LOGF(LOG_DEBUG, "Manager(%s) without role", s.c_str());
437  m_checkin.stop();
439 }
440 
442  MngrsStatus states;
443  {
445  states.assign(m_states.cbegin(), m_states.cend());
446  }
447  fill_states(states, 0, nullptr);
448 }
449 
450 void MngrRole::managers_checker(uint32_t next, uint32_t total, bool flw) {
451  // set manager followed(in-chain) local manager, incl. last's is first
452  if(!m_run)
453  return;
454  if(!total) {
455  m_checkin.stop();
457  }
458 
459  MngrStatus::Ptr host_chk;
460  {
462  if(next == m_states.size())
463  next = 0;
464  host_chk = m_states[next];
465  ++next;
466  }
467 
468  if(Comm::has_endpoint(host_chk->endpoints, m_local_endpoints) && total >= 1) {
469  if(flw) {
470  m_checkin.stop();
472  }
473  flw = true;
474  if(total > 1)
475  return managers_checker(next, total, flw);
476  }
477 
478  if(!flw)
479  return managers_checker(next, total, flw);
480 
481  if(host_chk->conn && host_chk->conn->is_open())
482  return set_mngr_inchain(host_chk->conn);
483 
484  struct Callback {
485  MngrRole* ptr;
486  MngrStatus::Ptr host_chk;
487  uint32_t next;
488  uint32_t total;
489  bool flw;
491  Callback(MngrRole* a_ptr, const MngrStatus::Ptr& a_host_chk,
492  uint32_t a_next, uint32_t a_total, bool a_flw) noexcept
493  : ptr(a_ptr), host_chk(a_host_chk),
494  next(a_next), total(a_total), flw(a_flw) { }
495  Callback(Callback&& other) noexcept
496  : ptr(other.ptr), host_chk(std::move(other.host_chk)),
497  next(other.next), total(other.total), flw(other.flw) { }
498  Callback(const Callback&) = delete;
499  Callback& operator=(Callback&&) = delete;
500  Callback& operator=(const Callback&) = delete;
501  ~Callback() noexcept { }
502  void operator()(const Comm::ConnHandlerPtr& conn) noexcept {
503  ptr->manager_checker(host_chk, next, total, flw, conn);
504  }
505  };
506  Env::Clients::get()->managers.queues->service->get_connection<Callback>(
507  host_chk->endpoints,
508  std::chrono::milliseconds(cfg_conn_timeout->get()),
509  cfg_conn_probes->get(),
510  this, host_chk, next, total, flw
511  );
512 }
513 
515  uint32_t next, uint32_t total, bool flw,
516  const Comm::ConnHandlerPtr& conn) {
517  if(!conn || !conn->is_open()) {
518  if(host->state == DB::Types::MngrState::ACTIVE
519  && ++host->failures <= cfg_conn_fb_failures->get()) {
520  m_checkin.stop();
521  SWC_LOGF(LOG_DEBUG, "Allowed conn Failure=%d before fallback",
522  host->failures);
524  }
525  host->state.store(DB::Types::MngrState::OFF);
526  return managers_checker(next, total-1, flw);
527  }
528  host->conn = conn;
529  host->failures = 0;
530  m_major_updates = true;
531  set_mngr_inchain(host->conn);
532 }
533 
535  DB::Types::MngrState state) {
537 
538  for(auto& host : m_states) {
539  if(Comm::has_endpoint(endpoint, host->endpoints)) {
540  host->state.store(state);
541  }
542  }
543 }
544 
546  DB::Types::MngrState state) {
548 
549  for(auto& host : m_states) {
550  if(Comm::has_endpoint(endpoints, host->endpoints)) {
551  host->state.store(state);
552  }
553  }
554 }
555 
558 
559  for(auto& host : m_states) {
560  if(Comm::has_endpoint(endpoints, host->endpoints))
561  return host;
562  }
563  return nullptr;
564 }
565 
568 
569  MngrStatus::Ptr h = nullptr;
570  for(auto& host : m_states) {
571  if(host->eq_grouping(*other.get()) &&
572  (!h || h->state < host->state))
573  h = host;
574  }
575  return h;
576 }
577 
580 
581  bool offline = true;
582  for(auto& host : m_states) {
583  if(host->eq_grouping(*other.get()) &&
584  host->state != DB::Types::MngrState::OFF)
585  offline = false;
586  }
587  return offline;
588 }
589 
591  MngrStatus::Ptr host_local;
592  uint8_t role_old, role_new;
593  bool has_cols = false;
594  cid_t cid_begin = DB::Schema::NO_CID;
595  cid_t cid_end = DB::Schema::NO_CID;
596  {
598  role_old = m_local_active_role;
599 
600  for(auto& host : m_states) {
601  if(Comm::has_endpoint(host->endpoints, m_local_endpoints)) {
602  host_local = host;
603  break;
604  }
605  }
606  if(host_local && host_local->state == DB::Types::MngrState::ACTIVE) {
607  m_local_active_role.store(host_local->role);
609  cid_begin = host_local->cid_begin;
610  cid_end = host_local->cid_end;
611  }
612  } else {
614  }
615  role_new = m_local_active_role;
616  }
617 
618  Env::Mngr::mngd_columns()->change_active(cid_begin, cid_end, has_cols);
619 
620  if(role_old == role_new)
621  return;
622 
623  if(role_new & DB::Types::MngrRole::RANGERS) {
624  if(!(role_old & DB::Types::MngrRole::RANGERS))
626 
627  } else if(role_old & DB::Types::MngrRole::RANGERS) {
628  SWC_LOG(LOG_INFO, "Manager(RANGERS) role has been decommissioned");
629  }
630 
631  if(role_new & DB::Types::MngrRole::SCHEMAS) {
632  if(!(role_old & DB::Types::MngrRole::SCHEMAS))
634 
635  } else if(role_old & DB::Types::MngrRole::SCHEMAS &&
636  !(role_new & DB::Types::MngrRole::SCHEMAS)) {
638  SWC_LOG(LOG_INFO, "Manager(SCHEMAS) role has been decommissioned");
639  }
640 
641  if(role_old & DB::Types::MngrRole::COLUMNS &&
642  (role_new & DB::Types::MngrRole::NO_COLUMNS || !has_cols)) {
643  SWC_LOG(LOG_INFO, "Manager(COLUMNS) role has been decommissioned");
644  }
645 
646  if(!(role_new & DB::Types::MngrRole::RANGERS) &&
647  (role_new & DB::Types::MngrRole::NO_COLUMNS || !has_cols)) {
648  Env::Mngr::rangers()->stop(false);
649  }
650 
651 }
652 
654  m_mngr_inchain->set(mngr);
655 
656  fill_states();
657  m_checkin.stop();
659 }
660 
661 
662 } // namespace Manager
663 
664 
665 }
666 
667 
SWC::Core::Vector::erase
SWC_CAN_INLINE iterator erase(size_type offset) noexcept(_NoExceptMoveAssign &&_NoExceptDestructor)
Definition: Vector.h:464
SWC::Manager::MngdColumns::initialize
bool initialize()
Definition: MngdColumns.cc:504
SWC::Manager::MngdColumns::require_sync
void require_sync()
Definition: MngdColumns.cc:229
SWC::Core::Vector::front
constexpr SWC_CAN_INLINE reference front() noexcept
Definition: Vector.h:243
SWC::Core::StateRunning::stop
constexpr SWC_CAN_INLINE void stop() noexcept
Definition: StateRunning.h:32
SWC::DB::Types::MngrRole::NONE
const uint8_t NONE
Definition: MngrRole.h:13
ClientContextManager.cc
SWC_LOG_OSTREAM
#define SWC_LOG_OSTREAM
Definition: Logger.h:44
SWC::Manager::MngrRole::fill_states
void fill_states()
Definition: MngrRole.cc:441
SWC::Manager::MngrRole::managers_checker
void managers_checker(uint32_t next, uint32_t total, bool flw)
Definition: MngrRole.cc:450
SWC::Manager::MngrRole::m_local_endpoints
const Comm::EndPoints m_local_endpoints
Definition: MngrRole.h:98
MngrRole.h
SWC::Manager::MngrRole::update_manager_addr
void update_manager_addr(uint64_t hash, const Comm::EndPoint &mngr_host)
Definition: MngrRole.cc:267
MngrState.cc
SWC::DB::SchemaPrimitives::NO_CID
static constexpr const cid_t NO_CID
Definition: Schema.h:25
SWC::Env::Clients::get
static SWC_CAN_INLINE client::Clients::Ptr & get() noexcept
Definition: Clients.h:299
SWC_LOGF
#define SWC_LOGF(priority, fmt,...)
Definition: Logger.h:188
SWC::Config::Property::Value_uint16_g::get
SWC_CAN_INLINE uint16_t get() const noexcept
Definition: Property.h:572
SWC::Manager::MngrRole::m_check_timer
asio::high_resolution_timer m_check_timer
Definition: MngrRole.h:110
SWC_LOG_OUT
#define SWC_LOG_OUT(pr, _code_)
Definition: Logger.h:178
SWC::Manager::MngrRole::get_inchain_endpoint
Comm::EndPoint get_inchain_endpoint() const
Definition: MngrRole.cc:132
SWC::DB::Types::MngrColumn::NOTSET
@ NOTSET
Definition: MngrColumnState.h:17
SWC::Manager::MngrRole::update_state
void update_state(const Comm::EndPoint &endpoint, DB::Types::MngrState state)
Definition: MngrRole.cc:534
SWC::Core::ScopedLock
Definition: MutexLock.h:41
SWC::Manager::MngdColumns::change_active
void change_active(const cid_t cid_begin, const cid_t cid_end, bool has_cols)
Definition: MngdColumns.cc:193
SWC::Manager::MngrRole::apply_role_changes
void apply_role_changes()
Definition: MngrRole.cc:590
SWC::Manager::MngrRole::cfg_conn_fb_failures
const Config::Property::Value_int32_g::Ptr cfg_conn_fb_failures
Definition: MngrRole.h:118
SWC::Comm::EndPoint
asio::ip::tcp::endpoint EndPoint
Definition: Resolver.h:19
SWC::DB::Types::MngrState::NOTSET
@ NOTSET
SWC::DB::Types::MngrRole::NO_COLUMNS
const uint8_t NO_COLUMNS
Definition: MngrRole.h:17
SWC::Core::SharedLock
Definition: MutexLock.h:19
SWC::Manager::MngrStatus::Ptr
std::shared_ptr< MngrStatus > Ptr
Definition: MngrStatus.h:21
SWC::Manager::MngrRole::get_states
void get_states(MngrsStatus &states)
Definition: MngrRole.cc:126
SWC::LOG_INFO
@ LOG_INFO
Definition: Logger.h:35
SWC::Comm::IoContextPtr
std::shared_ptr< IoContext > IoContextPtr
Definition: IoContext.h:16
SWC::Manager::MngrRole::operator=
MngrRole & operator=(const MngrRole &)=delete
SWC::Manager::MngrRole::m_run
Core::AtomicBool m_run
Definition: MngrRole.h:111
SWC::Comm::Protocol::Mngr::Req::MngrState::Ptr
std::shared_ptr< MngrState > Ptr
Definition: MngrState.h:17
SWC::Manager::MngrRole::m_mutex_timer
Core::MutexAtomic m_mutex_timer
Definition: MngrRole.h:109
SWC::Config::Property::Value_int32_g::get
SWC_CAN_INLINE int32_t get() const noexcept
Definition: Property.h:610
SWC::Comm::has_endpoint
bool SWC_PURE_FUNC has_endpoint(const EndPoint &e1, const EndPoints &endpoints_in) noexcept
Definition: Resolver.cc:93
SWC::Comm::endpoints_hash
size_t endpoints_hash(const EndPoints &endpoints)
Definition: Resolver.cc:120
SWC::Core::MutexAtomic::scope
Definition: MutexAtomic.h:77
SWC::DB::Types::MngrRole::SCHEMAS
const uint8_t SCHEMAS
Definition: MngrRole.h:15
SWC::Manager::MngrRole::cfg_delay_fallback
const Config::Property::Value_int32_g::Ptr cfg_delay_fallback
Definition: MngrRole.h:123
SWC::Manager::MngrRole::stop
void stop()
Definition: MngrRole.cc:319
SWC::Core::AtomicBase::store
constexpr SWC_CAN_INLINE void store(T v) noexcept
Definition: Atomic.h:37
SWC::Core::Vector::empty
constexpr SWC_CAN_INLINE bool empty() const noexcept
Definition: Vector.h:168
SWC::Manager::MngrRole::active_mngr
MngrStatus::Ptr active_mngr(cid_t cid)
Definition: MngrRole.cc:85
SWC_CAN_INLINE
#define SWC_CAN_INLINE
Definition: Compat.h:102
SWC::LOG_DEBUG
@ LOG_DEBUG
Definition: Logger.h:36
SWC::Manager::MngrRole::get_host
MngrStatus::Ptr get_host(const Comm::EndPoints &endpoints)
Definition: MngrRole.cc:556
SWC::Manager::MngrRole::schedule_checkin
void schedule_checkin(uint32_t t_ms=10000)
Definition: MngrRole.cc:47
SWC_LOG
#define SWC_LOG(priority, message)
Definition: Logger.h:191
SWC::Manager::MngrRole::m_local_token
const uint64_t m_local_token
Definition: MngrRole.h:99
SWC::Manager::MngrRole::manager_checker
void manager_checker(MngrStatus::Ptr host, uint32_t next, uint32_t total, bool flw, const Comm::ConnHandlerPtr &conn)
Definition: MngrRole.cc:514
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::Manager::MngrRole::cfg_conn_probes
const Config::Property::Value_uint16_g::Ptr cfg_conn_probes
Definition: MngrRole.h:116
SWC::Manager::MngrRole::m_mngr_inchain
Comm::client::ConnQueuePtr m_mngr_inchain
Definition: MngrRole.h:113
SWC::Manager::MngdColumns::reset
void reset(bool schemas_mngr)
Definition: MngdColumns.cc:98
SWC::Manager::MngrRole::cfg_conn_timeout
const Config::Property::Value_int32_g::Ptr cfg_conn_timeout
Definition: MngrRole.h:117
SWC::Comm::Protocol::Mngr::Req::MngrState
Definition: MngrState.h:15
SWC::Comm::ResponseCallback::Ptr
std::shared_ptr< ResponseCallback > Ptr
Definition: ResponseCallback.h:18
SWC::Manager::Rangers::stop
void stop(bool shuttingdown=true)
Definition: Rangers.cc:55
SWC::Manager::MngrRole::is_active_role
bool is_active_role(uint8_t role)
Definition: MngrRole.cc:80
SWC::Core::StateRunning::running
constexpr SWC_CAN_INLINE bool running() noexcept
Definition: StateRunning.h:37
SWC::Condition::NONE
@ NONE
Definition: Comparators.h:28
SWC::Manager::MngrRole::are_all_active
bool are_all_active(const client::Mngr::Groups::Vec &groups)
Definition: MngrRole.cc:108
SWC::cid_t
uint64_t cid_t
Definition: Identifiers.h:16
SWC::Comm::ConnHandlerPtr
std::shared_ptr< ConnHandler > ConnHandlerPtr
Definition: AppContext.h:17
SWC::Manager::MngrRole::m_mngrs_client_srv
std::unordered_map< uint64_t, Comm::EndPoint > m_mngrs_client_srv
Definition: MngrRole.h:107
SWC::Manager::MngrRole::MngrRole
MngrRole(const Comm::IoContextPtr &app_io, const Comm::EndPoints &endpoints)
Definition: MngrRole.cc:12
SWC::Manager::MngrRole::disconnection
void disconnection(const Comm::EndPoint &endpoint_server, const Comm::EndPoint &endpoint_client, bool srv=false)
Definition: MngrRole.cc:285
SWC::Core::Vector< EndPoint >
SWC::Manager::MngrRole::cfg_delay_updated
const Config::Property::Value_int32_g::Ptr cfg_delay_updated
Definition: MngrRole.h:121
SWC::Manager::MngrStatus
Definition: MngrStatus.h:18
SWC::Manager::MngdColumns::create_schemas_store
void create_schemas_store()
Definition: MngdColumns.cc:80
SWC::Manager::Rangers::schedule_check
void schedule_check(uint32_t t_ms=10000)
Definition: Rangers.cc:90
SWC::Manager::MngrRole::m_major_updates
bool m_major_updates
Definition: MngrRole.h:106
SWC::Manager::MngrRole::active_mngr_role
MngrStatus::Ptr active_mngr_role(uint8_t role)
Definition: MngrRole.cc:98
SWC::Core::Vector::cend
constexpr SWC_CAN_INLINE const_iterator cend() const noexcept
Definition: Vector.h:232
SWC::Manager::MngrRole::print
void print(std::ostream &out)
Definition: MngrRole.cc:346
SWC::DB::Types::MngrState
MngrState
Definition: MngrState.h:14
SWC::Manager::MngdColumns::stop
void stop()
Definition: MngdColumns.cc:48
SWC::Manager::MngrRole::is_active
bool is_active(cid_t cid)
Definition: MngrRole.cc:74
SWC::Manager::MngrRole::m_local_active_role
Core::Atomic< uint8_t > m_local_active_role
Definition: MngrRole.h:105
SWC::Manager::MngrRole
Definition: MngrRole.h:16
SWC::Manager::MngrRole::req_mngr_inchain
void req_mngr_inchain(const Comm::client::ConnQueue::ReqBase::Ptr &req)
Definition: MngrRole.cc:137
SWC::Manager::MngrRole::is_group_off
bool is_group_off(const MngrStatus::Ptr &other)
Definition: MngrRole.cc:578
SWC::Manager::MngrRole::m_states
MngrsStatus m_states
Definition: MngrRole.h:102
SWC::Manager::MngrRole::cfg_req_timeout
const Config::Property::Value_int32_g::Ptr cfg_req_timeout
Definition: MngrRole.h:120
SWC::Manager::MngrRole::m_local_groups
client::Mngr::Groups::Vec m_local_groups
Definition: MngrRole.h:104
SWC::Manager::MngrRole::m_mutex
std::shared_mutex m_mutex
Definition: MngrRole.h:101
SWC::Manager::MngrRole::managers_checkin
void managers_checkin()
Definition: MngrRole.cc:403
SWC::Manager::MngrRole::get_highest_state_host
MngrStatus::Ptr get_highest_state_host(const MngrStatus::Ptr &other)
Definition: MngrRole.cc:566
SWC::Comm::endpoint_hash
size_t SWC_PURE_FUNC endpoint_hash(const EndPoint &endpoint) noexcept
Definition: Resolver.cc:133
SWC::Comm::client::ConnQueueReqBase::Ptr
std::shared_ptr< ConnQueueReqBase > Ptr
Definition: ClientConnQueue.h:25
SWC::Core::Vector::assign
SWC_CAN_INLINE void assign(IteratorT first, IteratorT last)
Definition: Vector.h:452
SWC::Manager::MngrRole::m_checkin
Core::StateRunning m_checkin
Definition: MngrRole.h:103
SWC::Manager::MngrRole::set_mngr_inchain
void set_mngr_inchain(const Comm::ConnHandlerPtr &mngr)
Definition: MngrRole.cc:653
SWC::DB::Types::MngrRole::RANGERS
const uint8_t RANGERS
Definition: MngrRole.h:16
SWC::Core::Vector::push_back
SWC_CAN_INLINE void push_back(ArgsT &&... args)
Definition: Vector.h:331
SWC::Core::Vector::cbegin
constexpr SWC_CAN_INLINE const_iterator cbegin() const noexcept
Definition: Vector.h:216
SWC::Core::to_string
SWC_CAN_INLINE std::string to_string(const BitFieldInt< T, SZ > &v)
Definition: BitFieldInt.h:263
SWC::Manager::MngrRole::cfg_check_interval
const Config::Property::Value_int32_g::Ptr cfg_check_interval
Definition: MngrRole.h:122
SWC::Core::Vector::size
constexpr SWC_CAN_INLINE size_type size() const noexcept
Definition: Vector.h:189
SWC::Manager::MngrRole::_apply_cfg
void _apply_cfg()
Definition: MngrRole.cc:359
SWC::Core::Vector::emplace_back
SWC_CAN_INLINE reference emplace_back(ArgsT &&... args)
Definition: Vector.h:349
SWC::DB::Types::MngrRole::COLUMNS
const uint8_t COLUMNS
Definition: MngrRole.h:14
SWC::Env::Mngr::rangers
static SWC_CAN_INLINE Manager::Rangers * rangers() noexcept
Definition: MngrEnv.h:69