mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-02 12:32:04 +00:00
initial add keeper az info in /keeper/availabilty-zone
Signed-off-by: Jianfei Hu <hujianfei258@gmail.com>
This commit is contained in:
parent
8c63d56cbb
commit
0b301f73c1
@ -9,6 +9,13 @@
|
||||
#include <Coordination/KeeperFeatureFlags.h>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
#if USE_AWS_S3
|
||||
|
||||
#include <IO/S3/Credentials.h>
|
||||
#include <aws/core/auth/AWSCredentials.h>
|
||||
#include <aws/core/client/ClientConfiguration.h>
|
||||
#endif
|
||||
|
||||
namespace DB
|
||||
{
|
||||
|
||||
@ -30,6 +37,11 @@ KeeperContext::KeeperContext(bool standalone_keeper_)
|
||||
|
||||
/// for older clients, the default is equivalent to WITH_MULTI_READ version
|
||||
system_nodes_with_data[keeper_api_version_path] = toString(static_cast<uint8_t>(KeeperApiVersion::WITH_MULTI_READ));
|
||||
|
||||
#if USE_AWS_S3
|
||||
auto metadata_client = S3::InitEC2MetadataClient(Aws::Client::ClientConfiguration{});
|
||||
running_availability_zone = metadata_client->getCurrentAvailabilityZone();
|
||||
#endif
|
||||
}
|
||||
|
||||
void KeeperContext::initialize(const Poco::Util::AbstractConfiguration & config, KeeperDispatcher * dispatcher_)
|
||||
@ -204,6 +216,11 @@ void KeeperContext::setStateFileDisk(DiskPtr disk)
|
||||
state_file_storage = std::move(disk);
|
||||
}
|
||||
|
||||
std::string KeeperContext::getRunningAvailabilityZone() const
|
||||
{
|
||||
return running_availability_zone;
|
||||
}
|
||||
|
||||
const std::unordered_map<std::string, std::string> & KeeperContext::getSystemNodesWithData() const
|
||||
{
|
||||
return system_nodes_with_data;
|
||||
|
@ -3,7 +3,6 @@
|
||||
#include <Disks/DiskSelector.h>
|
||||
#include <IO/WriteBufferFromString.h>
|
||||
#include <Poco/Util/AbstractConfiguration.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
|
||||
@ -54,6 +53,8 @@ public:
|
||||
|
||||
constexpr KeeperDispatcher * getDispatcher() const { return dispatcher; }
|
||||
|
||||
std::string getRunningAvailabilityZone() const;
|
||||
|
||||
private:
|
||||
/// local disk defined using path or disk name
|
||||
using Storage = std::variant<DiskPtr, std::string>;
|
||||
@ -89,6 +90,8 @@ private:
|
||||
|
||||
KeeperFeatureFlags feature_flags;
|
||||
KeeperDispatcher * dispatcher{nullptr};
|
||||
|
||||
std::string running_availability_zone;
|
||||
};
|
||||
|
||||
using KeeperContextPtr = std::shared_ptr<KeeperContext>;
|
||||
|
@ -1097,6 +1097,14 @@ struct KeeperStorageGetRequestProcessor final : public KeeperStorageRequestProce
|
||||
Coordination::ZooKeeperGetResponse & response = dynamic_cast<Coordination::ZooKeeperGetResponse &>(*response_ptr);
|
||||
Coordination::ZooKeeperGetRequest & request = dynamic_cast<Coordination::ZooKeeperGetRequest &>(*zk_request);
|
||||
|
||||
/// AZ node information is a special case not persisted in the storage, so we handle it first.
|
||||
if (request.path == "/keeper/availbility-zone")
|
||||
{
|
||||
response.data = storage.keeper_context->getRunningAvailabilityZone();
|
||||
response.error = Coordination::Error::ZOK;
|
||||
return response_ptr;
|
||||
}
|
||||
|
||||
if constexpr (!local)
|
||||
{
|
||||
if (const auto result = storage.commit(zxid); result != Coordination::Error::ZOK)
|
||||
|
@ -704,6 +704,7 @@ S3CredentialsProviderChain::S3CredentialsProviderChain(
|
||||
|
||||
aws_client_configuration.retryStrategy = std::make_shared<Aws::Client::DefaultRetryStrategy>(1, 1000);
|
||||
|
||||
// Code that we want to copy.
|
||||
auto ec2_metadata_client = InitEC2MetadataClient(aws_client_configuration);
|
||||
auto config_loader = std::make_shared<AWSEC2InstanceProfileConfigLoader>(ec2_metadata_client, !credentials_configuration.use_insecure_imds_request);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user