#include <swcdb/manager/MngdColumns.h>
Classes | |
struct | ColumnReq |
Public Member Functions | |
MngdColumns () | |
MngdColumns (const MngdColumns &)=delete | |
MngdColumns (MngdColumns &&)=delete | |
MngdColumns & | operator= (const MngdColumns &)=delete |
MngdColumns & | operator= (MngdColumns &&)=delete |
~MngdColumns () noexcept | |
SWC_CAN_INLINE bool | running () const noexcept |
void | stop () |
void | create_schemas_store () |
void | reset (bool schemas_mngr) |
bool | is_schemas_mngr (int &err) |
bool | has_active () noexcept |
bool | is_active (cid_t cid) noexcept |
bool | active (cid_t &cid_begin, cid_t &cid_end) noexcept |
bool | expected_ready () noexcept |
void | columns_ready (int &err) |
Column::Ptr | get_column (int &err, cid_t cid) |
void | change_active (const cid_t cid_begin, const cid_t cid_end, bool has_cols) |
void | require_sync () |
void | action (const ColumnReq::Ptr &req) |
void | set_expect (cid_t cid_begin, cid_t cid_end, uint64_t total, cids_t &&columns, bool initial) |
void | update_status (Comm::Protocol::Mngr::Params::ColumnMng::Function func, const DB::Schema::Ptr &schema, int err, uint64_t req_id, bool initial=false) |
void | update (Comm::Protocol::Mngr::Params::ColumnMng::Function func, const DB::Schema::Ptr &schema, int err, uint64_t req_id) |
void | remove (const DB::Schema::Ptr &schema, rgrid_t rgrid, uint64_t req_id) |
void | print (std::ostream &out) |
bool | initialize () |
Private Member Functions | |
bool | columns_load () |
cid_t | get_next_cid () |
void | create (int &err, DB::Schema::Ptr &schema) |
void | update (int &err, DB::Schema::Ptr &schema, const DB::Schema::Ptr &old) |
void | update_status_ack (Comm::Protocol::Mngr::Params::ColumnMng::Function func, const DB::Schema::Ptr &schema, int err, uint64_t req_id) |
void | run_actions () |
Private Attributes | |
Core::AtomicBool | m_run |
Core::StateRunning | m_columns_load |
Core::MutexSptd | m_mutex_schemas |
Core::AtomicBool | m_schemas_set |
Core::MutexSptd | m_mutex_active |
bool | m_cid_active |
cid_t | m_cid_begin |
cid_t | m_cid_end |
uint64_t | m_expected_remain |
Core::Atomic< cid_t > | m_last_used_cid |
std::forward_list< cid_t > | m_expected_load |
Core::MutexSptd | m_mutex_actions |
Core::QueueSafe< ColumnReq::Ptr > | m_actions |
std::unordered_map< uint64_t, ColumnReq::Ptr > | m_actions_pending |
Static Private Attributes | |
constexpr static uint64_t | STATE_COLUMNS_NOT_INITIALIZED = UINT64_MAX |
Definition at line 15 of file MngdColumns.h.
SWC::Manager::MngdColumns::MngdColumns | ( | ) |
Definition at line 22 of file MngdColumns.cc.
|
delete |
|
delete |
|
inlinenoexcept |
Definition at line 44 of file MngdColumns.h.
SWC_CAN_INLINE void SWC::Manager::MngdColumns::action | ( | const ColumnReq::Ptr & | req | ) |
Definition at line 238 of file MngdColumns.cc.
References m_actions, SWC::Env::Mngr::post(), SWC::Core::QueueSafe< ItemT >::push_and_is_1st(), run_actions(), and SWC_CAN_INLINE.
Referenced by SWC::Comm::Protocol::Mngr::Handler::column_mng().
Definition at line 146 of file MngdColumns.cc.
Referenced by set_expect(), and SWC::Manager::Rangers::update_status().
void SWC::Manager::MngdColumns::change_active | ( | const cid_t | cid_begin, |
const cid_t | cid_end, | ||
bool | has_cols | ||
) |
Definition at line 193 of file MngdColumns.cc.
References cfg_delay_cols_init, SWC::Env::Mngr::columns(), SWC::Config::Property::Value_int32_g::get(), m_cid_active, m_cid_begin, m_cid_end, m_expected_remain, m_mutex_active, m_mutex_schemas, m_run, SWC::Env::Mngr::rangers(), SWC::DB::Schemas::reset(), SWC::Manager::Columns::reset(), SWC::Env::Mngr::role(), SWC::Manager::Rangers::schedule_check(), SWC::DB::Types::MngrRole::SCHEMAS, SWC::Env::Mngr::schemas(), and STATE_COLUMNS_NOT_INITIALIZED.
Referenced by SWC::Manager::MngrRole::apply_role_changes().
|
private |
Definition at line 605 of file MngdColumns.cc.
References SWC::DB::Schemas::all(), SWC::Core::Vector< T, SizeT, GROW_SZ >::begin(), SWC::Core::Vector< T, SizeT, GROW_SZ >::cbegin(), SWC::Core::Vector< T, SizeT, GROW_SZ >::cend(), SWC::Core::Vector< T, SizeT, GROW_SZ >::clear(), SWC::DB::Types::MngrRole::COLUMNS, SWC::Core::Vector< T, SizeT, GROW_SZ >::empty(), SWC::Core::Vector< T, SizeT, GROW_SZ >::end(), SWC::Env::Clients::get(), is_schemas_mngr(), SWC::LOG_DEBUG, SWC::LOG_WARN, m_columns_load, m_run, SWC::Error::OK, SWC::Core::Vector< T, SizeT, GROW_SZ >::push_back(), SWC::Core::Vector< T, SizeT, GROW_SZ >::reserve(), SWC::Env::Mngr::role(), SWC::Core::StateRunning::running(), SWC::Env::Mngr::schemas(), set_expect(), SWC::Core::Vector< T, SizeT, GROW_SZ >::size(), SWC::Comm::Resolver::sort(), STATE_COLUMNS_NOT_INITIALIZED, SWC::Core::StateRunning::stop(), SWC_FMT_LD, SWC_FMT_LU, SWC_LOG, SWC_LOGF, and update_status().
Referenced by require_sync(), and update_status_ack().
void SWC::Manager::MngdColumns::columns_ready | ( | int & | err | ) |
Definition at line 161 of file MngdColumns.cc.
References SWC::Env::Mngr::columns(), m_cid_active, m_expected_remain, m_mutex_active, SWC::Error::MNGR_NOT_INITIALIZED, and SWC::Manager::Columns::state().
Referenced by SWC::Comm::Protocol::Mngr::Handler::Report::operator()().
|
private |
Definition at line 722 of file MngdColumns.cc.
References SWC::DB::Schemas::add(), cfg_schema_replication, SWC::Error::COLUMN_REACHED_ID_LIMIT, SWC::Manager::Column::create(), SWC::Config::Property::Value_uint8_g::get(), SWC::DB::Schemas::get(), get_next_cid(), SWC::Error::INVALID_ARGUMENT, SWC::DB::Types::is_counter(), m_last_used_cid, SWC::DB::Schema::make(), SWC::DB::SchemaPrimitives::NO_CID, SWC::Time::now_ns(), SWC::Manager::Column::remove(), SWC::Common::Files::Schema::save_with_validation(), SWC::Env::Mngr::schemas(), SWC::Core::AtomicBase< T, OrderT >::store(), and SWC::DB::Cell::Serial::Value::UNKNOWN.
Referenced by run_actions().
void SWC::Manager::MngdColumns::create_schemas_store | ( | ) |
Definition at line 80 of file MngdColumns.cc.
References cfg_schema_replication, cfg_schemas_store_blksz, cfg_schemas_store_cap, cfg_schemas_store_encoder, SWC::Config::Property::Value_uint8_g::get(), SWC::Config::Property::Value_int32_g::get(), SWC::Config::Property::Value_uint64_g::get(), SWC::Config::Property::Value_enum_g::get(), is_schemas_mngr(), SWC::LOG_INFO, SWC::Error::OK, SWC::Error::print(), SWC::Env::Mngr::schemas(), SWC::Error::SERVER_SHUTTING_DOWN, size, SWC::Manager::Schemas::store_create(), SWC_LOG_OSTREAM, and SWC_LOG_OUT.
Referenced by SWC::Manager::MngrRole::stop().
|
noexcept |
Definition at line 156 of file MngdColumns.cc.
References m_expected_remain, and m_mutex_active.
Referenced by get_column().
Column::Ptr SWC::Manager::MngdColumns::get_column | ( | int & | err, |
cid_t | cid | ||
) |
Definition at line 174 of file MngdColumns.cc.
References SWC::Error::COLUMN_NOT_EXISTS, SWC::Env::Mngr::columns(), expected_ready(), is_active(), is_schemas_mngr(), SWC::Error::MNGR_NOT_ACTIVE, and SWC::Error::MNGR_NOT_INITIALIZED.
Referenced by SWC::Comm::Protocol::Mngr::Handler::column_compact(), SWC::Comm::Protocol::Mngr::Handler::RangeCreate::operator()(), SWC::Comm::Protocol::Mngr::Handler::RangeRemove::operator()(), SWC::Comm::Protocol::Mngr::Handler::Report::operator()(), SWC::Comm::Protocol::Mngr::Handler::range_unloaded(), SWC::Comm::Protocol::Mngr::Handler::rgr_get(), and update_status().
|
private |
Definition at line 708 of file MngdColumns.cc.
References SWC::Core::Atomic< T, OrderT >::add_rslt(), m_last_used_cid, SWC::Env::Mngr::schemas(), SWC::Core::AtomicBase< T, OrderT >::store(), and SWC::DB::Types::SystemColumn::SYS_CID_END.
Referenced by create().
|
noexcept |
Definition at line 133 of file MngdColumns.cc.
References m_cid_active, and m_mutex_active.
bool SWC::Manager::MngdColumns::initialize | ( | ) |
Definition at line 504 of file MngdColumns.cc.
References SWC::Core::Semaphore::acquire(), SWC::DB::Schemas::add(), SWC::Core::Semaphore::available(), SWC::Core::Vector< T, SizeT, GROW_SZ >::cbegin(), SWC::Core::Vector< T, SizeT, GROW_SZ >::cend(), cfg_schema_replication, SWC::Manager::Columns::columns_by_fs(), SWC::System::Resources::concurrency(), SWC::Manager::Column::create(), SWC::Config::Property::Value_uint8_g::get(), SWC::Error::get_text(), SWC::Common::Files::Schema::load(), SWC::LOG_DEBUG, SWC::LOG_ERROR, SWC::LOG_INFO, SWC::LOG_WARN, m_mutex_schemas, m_run, m_schemas_set, SWC::Error::OK, SWC::Env::Mngr::post(), SWC::Error::print(), SWC::Core::Vector< T, SizeT, GROW_SZ >::push_back(), SWC::Core::Semaphore::release(), SWC::Env::Mngr::res(), SWC::DB::Schemas::reset(), SWC::Env::Mngr::schemas(), size, SWC::Core::Vector< T, SizeT, GROW_SZ >::size(), SWC::Core::AtomicBase< T, OrderT >::store(), SWC_CAN_INLINE, SWC_FMT_LU, SWC_LOG, SWC_LOG_CURRENT_EXCEPTION, SWC_LOG_OSTREAM, SWC_LOG_OUT, SWC_LOGF, SWC::DB::Types::SystemColumn::SYS_CID_END, and SWC::Core::Semaphore::wait_all().
Referenced by SWC::Manager::MngrRole::apply_role_changes().
|
noexcept |
Definition at line 139 of file MngdColumns.cc.
Referenced by get_column(), SWC::Comm::Protocol::Mngr::Handler::MngrColumnGet::handle(), and update_status().
SWC_CAN_INLINE bool SWC::Manager::MngdColumns::is_schemas_mngr | ( | int & | err | ) |
Definition at line 116 of file MngdColumns.cc.
References m_mutex_schemas, m_run, m_schemas_set, SWC::Error::MNGR_NOT_INITIALIZED, SWC::Env::Mngr::role(), SWC::DB::Types::MngrRole::SCHEMAS, and SWC::Error::SERVER_SHUTTING_DOWN.
Referenced by columns_load(), create_schemas_store(), get_column(), and run_actions().
|
delete |
|
delete |
void SWC::Manager::MngdColumns::print | ( | std::ostream & | out | ) |
Definition at line 500 of file MngdColumns.cc.
References SWC::Env::Mngr::columns(), and SWC::Manager::Columns::print().
void SWC::Manager::MngdColumns::remove | ( | const DB::Schema::Ptr & | schema, |
rgrid_t | rgrid, | ||
uint64_t | req_id | ||
) |
Definition at line 407 of file MngdColumns.cc.
References SWC::Env::Mngr::columns(), SWC::Condition::EQ, SWC::Condition::FIP, SWC::Env::Clients::get(), SWC::Manager::Columns::get_column(), SWC::DB::Types::SystemColumn::get_range_type(), SWC::DB::Types::SystemColumn::get_sys_cid(), SWC::Error::get_text(), SWC::Env::Mngr::io(), SWC::DB::Types::SystemColumn::is_master(), SWC::DB::Types::SystemColumn::is_rgr_data_on_fs(), SWC::LOG_INFO, SWC::LOG_WARN, SWC::client::Query::Select::Handlers::Common::make(), SWC::Error::OK, SWC::DB::Cells::Result::print(), SWC::Env::Mngr::rangers(), SWC::DB::Schemas::remove(), SWC::Manager::Columns::remove(), SWC::Env::Mngr::role(), SWC::DB::Types::MngrRole::SCHEMAS, SWC::Env::Mngr::schemas(), SWC::DB::Types::SERIAL, SWC_FMT_LU, SWC_LOG_OSTREAM, SWC_LOG_OUT, SWC_LOGF, SWC::DB::Types::SystemColumn::SYS_RGR_DATA, SWC::Core::to_string(), update(), and SWC::Manager::Rangers::wait_health_check().
Referenced by SWC::Comm::Protocol::Rgr::Req::ColumnDelete::remove(), and update_status().
void SWC::Manager::MngdColumns::require_sync | ( | ) |
Definition at line 229 of file MngdColumns.cc.
References columns_load(), SWC::DB::Schema::make(), SWC::Error::OK, SWC::Env::Mngr::rangers(), SWC::Manager::Rangers::sync(), and update().
Referenced by SWC::Manager::MngrRole::update_manager_addr().
void SWC::Manager::MngdColumns::reset | ( | bool | schemas_mngr | ) |
Definition at line 98 of file MngdColumns.cc.
References m_cid_active, m_mutex_active, m_mutex_schemas, m_schemas_set, SWC::DB::Schemas::reset(), SWC::Env::Mngr::schemas(), and SWC::Core::AtomicBase< T, OrderT >::store().
Referenced by SWC::Manager::MngrRole::apply_role_changes().
|
private |
Definition at line 901 of file MngdColumns.cc.
References SWC::Error::COLUMN_SCHEMA_ID_EXISTS, SWC::Error::COLUMN_SCHEMA_IS_SYSTEM, SWC::Error::COLUMN_SCHEMA_NAME_EMPTY, SWC::Error::COLUMN_SCHEMA_NAME_EXISTS, SWC::Error::COLUMN_SCHEMA_NAME_NOT_CORRES, SWC::Error::COLUMN_SCHEMA_NAME_NOT_EXISTS, create(), SWC::Core::QueueSafe< ItemT >::front(), SWC::DB::Schemas::get(), is_schemas_mngr(), SWC::LOG_DEBUG, m_actions, m_actions_pending, m_mutex_actions, m_mutex_schemas, m_run, m_schemas_set, SWC::Error::MNGR_NOT_ACTIVE, SWC::DB::SchemaPrimitives::NO_CID, SWC::Error::NOT_IMPLEMENTED, SWC::Time::now_ns(), SWC::Error::OK, SWC::Core::QueueSafe< ItemT >::pop_and_more(), SWC::Error::REQUEST_TIMEOUT, SWC::Env::Mngr::schemas(), SWC::Error::SERVER_SHUTTING_DOWN, SWC::Condition::str_eq(), SWC_LOG_OSTREAM, SWC_LOG_OUT, SWC::DB::Types::SystemColumn::SYS_CID_END, update(), and update_status().
Referenced by action().
|
inlinenoexcept |
Definition at line 47 of file MngdColumns.h.
References m_run.
Referenced by SWC::Comm::Protocol::Mngr::Handler::MngrColumnGet::valid().
void SWC::Manager::MngdColumns::set_expect | ( | cid_t | cid_begin, |
cid_t | cid_end, | ||
uint64_t | total, | ||
cids_t && | columns, | ||
bool | initial | ||
) |
Definition at line 249 of file MngdColumns.cc.
References active(), SWC::Env::Mngr::columns(), SWC::LOG_DEBUG, m_cid_active, m_cid_begin, m_cid_end, m_expected_load, m_expected_remain, m_mutex_active, m_run, SWC::Error::OK, SWC::Manager::MngrRole::req_mngr_inchain(), SWC::Env::Mngr::role(), SWC::DB::Types::MngrRole::SCHEMAS, STATE_COLUMNS_NOT_INITIALIZED, SWC_FMT_LU, and SWC_LOGF.
Referenced by columns_load(), and SWC::Comm::Protocol::Mngr::Handler::ColumnUpdate::operator()().
void SWC::Manager::MngdColumns::stop | ( | ) |
Definition at line 48 of file MngdColumns.cc.
References SWC::Core::QueueSafe< ItemT >::empty(), SWC::LOG_DEBUG, SWC::LOG_INFO, m_actions, m_actions_pending, m_columns_load, m_expected_load, m_expected_remain, m_mutex_actions, m_mutex_active, m_run, SWC::Core::QueueSafe< ItemT >::size(), STATE_COLUMNS_NOT_INITIALIZED, SWC::Core::AtomicBase< T, OrderT >::store(), SWC_FMT_LU, SWC_LOG, and SWC_LOGF.
Referenced by SWC::Manager::MngrRole::stop().
SWC_CAN_INLINE void SWC::Manager::MngdColumns::update | ( | Comm::Protocol::Mngr::Params::ColumnMng::Function | func, |
const DB::Schema::Ptr & | schema, | ||
int | err, | ||
uint64_t | req_id | ||
) |
Definition at line 808 of file MngdColumns.cc.
References SWC::Manager::MngrRole::req_mngr_inchain(), and SWC::Env::Mngr::role().
Referenced by remove(), require_sync(), run_actions(), update_status(), and SWC::Comm::Protocol::Rgr::Req::ColumnUpdate::updated().
|
private |
Definition at line 766 of file MngdColumns.cc.
References cfg_schema_replication, SWC::Error::COLUMN_CHANGE_INCOMPATIBLE, SWC::Error::COLUMN_SCHEMA_ID_EMPTY, SWC::Error::COLUMN_SCHEMA_NOT_DIFFERENT, SWC::Config::Property::Value_uint8_g::get(), SWC::DB::Schemas::get(), SWC::DB::Types::is_counter(), SWC::DB::Schema::make(), SWC::DB::SchemaPrimitives::NO_CID, SWC::Time::now_ns(), SWC::DB::Schemas::replace(), SWC::Common::Files::Schema::save_with_validation(), SWC::Env::Mngr::schemas(), SWC::Condition::str_eq(), and SWC::DB::Types::SystemColumn::SYS_CID_END.
void SWC::Manager::MngdColumns::update_status | ( | Comm::Protocol::Mngr::Params::ColumnMng::Function | func, |
const DB::Schema::Ptr & | schema, | ||
int | err, | ||
uint64_t | req_id, | ||
bool | initial = false |
||
) |
Definition at line 304 of file MngdColumns.cc.
References SWC::Manager::Rangers::assign_ranges(), SWC::Manager::Rangers::column_delete(), SWC::Error::COLUMN_NOT_EXISTS, SWC::Error::COLUMN_NOT_READY, SWC::Env::Mngr::columns(), SWC::Core::Vector< T, SizeT, GROW_SZ >::empty(), SWC::DB::Schemas::get(), get_column(), SWC::Manager::Columns::get_column(), is_active(), SWC::Manager::MngrRole::is_active_role(), SWC::Manager::Columns::is_an_initialization(), SWC::LOG_DEBUG, m_expected_load, m_expected_remain, m_mutex_active, m_run, SWC::Error::OK, SWC::Env::Mngr::rangers(), remove(), SWC::DB::Schemas::replace(), SWC::Env::Mngr::role(), SWC::DB::Types::MngrRole::SCHEMAS, SWC::Env::Mngr::schemas(), STATE_COLUMNS_NOT_INITIALIZED, SWC_FMT_LU, SWC_LOG_OSTREAM, SWC_LOG_OUT, SWC_LOGF, update(), SWC::Manager::Rangers::update(), and update_status_ack().
Referenced by columns_load(), SWC::Comm::Protocol::Mngr::Handler::ColumnUpdate::operator()(), run_actions(), and update_status_ack().
|
private |
Definition at line 818 of file MngdColumns.cc.
References SWC::Error::COLUMN_SCHEMA_NAME_NOT_EXISTS, columns_load(), SWC::DB::Schemas::get(), SWC::LOG_DEBUG, SWC::LOG_WARN, m_actions_pending, m_last_used_cid, m_mutex_actions, m_mutex_schemas, m_run, m_schemas_set, SWC::Error::MNGR_NOT_ACTIVE, SWC::Error::OK, SWC::Error::print(), SWC::DB::Schemas::remove(), SWC::Manager::Column::remove(), SWC::Env::Mngr::schemas(), SWC::Error::SERVER_SHUTTING_DOWN, SWC::Core::AtomicBase< T, OrderT >::store(), SWC_LOG_OSTREAM, SWC_LOG_OUT, and update_status().
Referenced by update_status().
const Config::Property::Value_int32_g::Ptr SWC::Manager::MngdColumns::cfg_delay_cols_init |
Definition at line 34 of file MngdColumns.h.
Referenced by change_active().
const Config::Property::Value_uint8_g::Ptr SWC::Manager::MngdColumns::cfg_schema_replication |
Definition at line 30 of file MngdColumns.h.
Referenced by create(), create_schemas_store(), initialize(), and update().
const Config::Property::Value_int32_g::Ptr SWC::Manager::MngdColumns::cfg_schemas_store_blksz |
Definition at line 32 of file MngdColumns.h.
Referenced by create_schemas_store().
const Config::Property::Value_uint64_g::Ptr SWC::Manager::MngdColumns::cfg_schemas_store_cap |
Definition at line 31 of file MngdColumns.h.
Referenced by create_schemas_store().
const Config::Property::Value_enum_g::Ptr SWC::Manager::MngdColumns::cfg_schemas_store_encoder |
Definition at line 33 of file MngdColumns.h.
Referenced by create_schemas_store().
|
private |
Definition at line 130 of file MngdColumns.h.
Referenced by action(), run_actions(), and stop().
|
private |
Definition at line 131 of file MngdColumns.h.
Referenced by run_actions(), stop(), and update_status_ack().
|
private |
Definition at line 122 of file MngdColumns.h.
Referenced by change_active(), columns_ready(), has_active(), reset(), and set_expect().
|
private |
Definition at line 123 of file MngdColumns.h.
Referenced by change_active(), and set_expect().
|
private |
Definition at line 124 of file MngdColumns.h.
Referenced by change_active(), and set_expect().
|
private |
Definition at line 116 of file MngdColumns.h.
Referenced by columns_load(), and stop().
|
private |
Definition at line 127 of file MngdColumns.h.
Referenced by set_expect(), stop(), and update_status().
|
private |
Definition at line 125 of file MngdColumns.h.
Referenced by change_active(), columns_ready(), expected_ready(), set_expect(), stop(), and update_status().
|
private |
Definition at line 126 of file MngdColumns.h.
Referenced by create(), get_next_cid(), and update_status_ack().
|
private |
Definition at line 129 of file MngdColumns.h.
Referenced by run_actions(), stop(), and update_status_ack().
|
private |
Definition at line 121 of file MngdColumns.h.
Referenced by change_active(), columns_ready(), expected_ready(), has_active(), reset(), set_expect(), stop(), and update_status().
|
private |
Definition at line 118 of file MngdColumns.h.
Referenced by change_active(), initialize(), is_schemas_mngr(), reset(), run_actions(), and update_status_ack().
|
private |
Definition at line 114 of file MngdColumns.h.
Referenced by change_active(), columns_load(), initialize(), is_schemas_mngr(), run_actions(), running(), set_expect(), stop(), update_status(), and update_status_ack().
|
private |
Definition at line 119 of file MngdColumns.h.
Referenced by initialize(), is_schemas_mngr(), reset(), run_actions(), and update_status_ack().
|
staticconstexprprivate |
Definition at line 133 of file MngdColumns.h.
Referenced by change_active(), columns_load(), set_expect(), stop(), and update_status().