add interface GetConfig()/SetConfig() (#877)

* #665 add interface GetConfig()/SetConfig()

* #665 remove test code
pull/882/head
Cai Yudong 2019-12-31 10:47:52 +08:00 committed by Jin Hai
parent 1e72267a65
commit a8756559c4
5 changed files with 68 additions and 3 deletions

View File

@ -456,4 +456,24 @@ ClientProxy::DropPartition(const PartitionParam& partition_param) {
}
}
Status
ClientProxy::GetConfig(const std::string& node_name, std::string& value) const {
try {
return client_ptr_->Cmd(value, "get_config " + node_name);
} catch (std::exception& ex) {
return Status(StatusCode::UnknownError, "Fail to get config: " + node_name);
}
}
Status
ClientProxy::SetConfig(const std::string& node_name, const std::string& value) const {
try {
std::string dummy;
return client_ptr_->Cmd(dummy, "set_config " + node_name + " " + value);
} catch (std::exception& ex) {
return Status(StatusCode::UnknownError, "Fail to set config: " + node_name);
}
}
} // namespace milvus

View File

@ -104,10 +104,14 @@ class ClientProxy : public Connection {
Status
DropPartition(const PartitionParam& partition_param) override;
private:
std::shared_ptr<::grpc::Channel> channel_;
Status
GetConfig(const std::string& node_name, std::string& value) const override;
Status
SetConfig(const std::string& node_name, const std::string& value) const override;
private:
std::shared_ptr<::grpc::Channel> channel_;
std::shared_ptr<GrpcClient> client_ptr_;
bool connected_ = false;
};

View File

@ -444,6 +444,32 @@ class Connection {
*/
virtual Status
DropPartition(const PartitionParam& param) = 0;
/**
* @brief Get config method
*
* This method is used to set config.
*
* @param node_name, config node name.
* @param value, config value.
*
* @return Indicate if this operation is successful.
*/
virtual Status
GetConfig(const std::string& node_name, std::string& value) const = 0;
/**
* @brief Set config method
*
* This method is used to set config.
*
* @param node_name, config node name.
* @param value, config value.
*
* @return Indicate if this operation is successful.
*/
virtual Status
SetConfig(const std::string& node_name, const std::string& value) const = 0;
};
} // namespace milvus

View File

@ -161,4 +161,13 @@ ConnectionImpl::DropPartition(const PartitionParam& param) {
return client_proxy_->DropPartition(param);
}
Status
ConnectionImpl::GetConfig(const std::string& node_name, std::string& value) const {
return client_proxy_->GetConfig(node_name, value);
}
Status
ConnectionImpl::SetConfig(const std::string& node_name, const std::string& value) const {
return client_proxy_->SetConfig(node_name, value);
}
} // namespace milvus

View File

@ -106,7 +106,13 @@ class ConnectionImpl : public Connection {
Status
DropPartition(const PartitionParam& param) override;
private:
Status
GetConfig(const std::string& node_name, std::string& value) const override;
Status
SetConfig(const std::string& node_name, const std::string& value) const override;
private:
std::shared_ptr<ClientProxy> client_proxy_;
};