mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 01:25:21 +00:00
Remove Exception in getKeeperDispatcher
- to handle the nil case by caller
This commit is contained in:
parent
c18dd55400
commit
03a5ce542d
@ -8,7 +8,7 @@ namespace DB
|
||||
|
||||
namespace ErrorCodes
|
||||
{
|
||||
extern const int KEEPER_EXCEPTION;
|
||||
extern const int LOGICAL_ERROR;
|
||||
}
|
||||
|
||||
void TinyContext::setConfig(const ConfigurationPtr & config_)
|
||||
@ -31,7 +31,7 @@ void TinyContext::initializeKeeperDispatcher([[maybe_unused]] bool start_async)
|
||||
std::lock_guard lock(keeper_dispatcher_mutex);
|
||||
|
||||
if (keeper_dispatcher)
|
||||
throw Exception(ErrorCodes::KEEPER_EXCEPTION, "Trying to initialize Keeper multiple times");
|
||||
throw Exception(ErrorCodes::LOGICAL_ERROR, "Trying to initialize Keeper multiple times");
|
||||
|
||||
if (config_ref.has("keeper_server"))
|
||||
{
|
||||
@ -43,9 +43,6 @@ void TinyContext::initializeKeeperDispatcher([[maybe_unused]] bool start_async)
|
||||
std::shared_ptr<KeeperDispatcher> TinyContext::getKeeperDispatcher() const
|
||||
{
|
||||
std::lock_guard lock(keeper_dispatcher_mutex);
|
||||
if (!keeper_dispatcher)
|
||||
throw Exception(ErrorCodes::KEEPER_EXCEPTION, "Keeper must be initialized before requests");
|
||||
|
||||
return keeper_dispatcher;
|
||||
}
|
||||
|
||||
|
@ -1470,8 +1470,9 @@ void AsynchronousMetrics::update(std::chrono::system_clock::time_point update_ti
|
||||
}
|
||||
#if USE_NURAFT
|
||||
{
|
||||
try {
|
||||
auto keeper_dispatcher = getContext()->getKeeperDispatcher();
|
||||
auto keeper_dispatcher = getContext()->getKeeperDispatcher();
|
||||
if (keeper_dispatcher)
|
||||
{
|
||||
size_t is_leader = 0;
|
||||
size_t is_follower = 0;
|
||||
size_t is_observer = 0;
|
||||
@ -1492,13 +1493,13 @@ void AsynchronousMetrics::update(std::chrono::system_clock::time_point update_ti
|
||||
size_t snapshot_dir_size = 0;
|
||||
size_t log_dir_size = 0;
|
||||
|
||||
if (keeper_dispatcher && keeper_dispatcher->isServerActive())
|
||||
if (keeper_dispatcher->isServerActive())
|
||||
{
|
||||
auto keeper_4LW_info = keeper_dispatcher -> getKeeper4LWInfo();
|
||||
is_standalone = static_cast<size_t>(keeper_4LW_info.is_standalone;
|
||||
is_leader = static_cast<size_t>(keeper_4LW_info.is_leader;
|
||||
is_observer = static_cast<size_t>(keeper_4LW_info.is_observer;
|
||||
is_follower = static_cast<size_t>(keeper_4LW_info.is_follower;
|
||||
is_standalone = static_cast<size_t>(keeper_4LW_info.is_standalone);
|
||||
is_leader = static_cast<size_t>(keeper_4LW_info.is_leader);
|
||||
is_observer = static_cast<size_t>(keeper_4LW_info.is_observer);
|
||||
is_follower = static_cast<size_t>(keeper_4LW_info.is_follower);
|
||||
|
||||
zxid = keeper_4LW_info.last_zxid;
|
||||
const auto & state_machine = keeper_dispatcher->getStateMachine();
|
||||
@ -1549,10 +1550,6 @@ void AsynchronousMetrics::update(std::chrono::system_clock::time_point update_ti
|
||||
new_values["KeeperSnapshotDirSize"] = snapshot_dir_size;
|
||||
new_values["KeeperLogDirSize"] = log_dir_size;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
tryLogCurrentException(__PRETTY_FUNCTION__);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -135,7 +135,6 @@ namespace ErrorCodes
|
||||
extern const int INVALID_SETTING_VALUE;
|
||||
extern const int UNKNOWN_READ_METHOD;
|
||||
extern const int NOT_IMPLEMENTED;
|
||||
extern const int KEEPER_EXCEPTION;
|
||||
}
|
||||
|
||||
|
||||
@ -2069,7 +2068,7 @@ void Context::initializeKeeperDispatcher([[maybe_unused]] bool start_async) cons
|
||||
std::lock_guard lock(shared->keeper_dispatcher_mutex);
|
||||
|
||||
if (shared->keeper_dispatcher)
|
||||
throw Exception(ErrorCodes::KEEPER_EXCEPTION, "Trying to initialize Keeper multiple times");
|
||||
throw Exception(ErrorCodes::LOGICAL_ERROR, "Trying to initialize Keeper multiple times");
|
||||
|
||||
const auto & config = getConfigRef();
|
||||
if (config.has("keeper_server"))
|
||||
@ -2097,9 +2096,6 @@ void Context::initializeKeeperDispatcher([[maybe_unused]] bool start_async) cons
|
||||
std::shared_ptr<KeeperDispatcher> & Context::getKeeperDispatcher() const
|
||||
{
|
||||
std::lock_guard lock(shared->keeper_dispatcher_mutex);
|
||||
if (!shared->keeper_dispatcher)
|
||||
throw Exception(ErrorCodes::KEEPER_EXCEPTION, "Keeper must be initialized before requests");
|
||||
|
||||
return shared->keeper_dispatcher;
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user