diff --git a/src/client/ns_client.cc b/src/client/ns_client.cc index adbe3e59579..2c0659c9704 100644 --- a/src/client/ns_client.cc +++ b/src/client/ns_client.cc @@ -475,8 +475,8 @@ bool NsClient::OfflineEndpoint(const std::string& endpoint, uint32_t concurrency return false; } -base::Status NsClient::Migrate(const std::string& src_endpoint, const std::string& name, const std::set& pid_set, - const std::string& des_endpoint) { +base::Status NsClient::Migrate(const std::string& src_endpoint, const std::string& name, + const std::set& pid_set, const std::string& des_endpoint) { ::openmldb::nameserver::MigrateRequest request; ::openmldb::nameserver::GeneralResponse response; request.set_src_endpoint(src_endpoint); @@ -584,7 +584,8 @@ bool NsClient::GetTablePartition(const std::string& name, uint32_t pid, return false; } -base::Status NsClient::UpdateTableAliveStatus(const std::string& endpoint, const std::string& name, uint32_t pid, bool is_alive) { +base::Status NsClient::UpdateTableAliveStatus(const std::string& endpoint, const std::string& name, uint32_t pid, + bool is_alive) { ::openmldb::nameserver::UpdateTableAliveRequest request; ::openmldb::nameserver::GeneralResponse response; request.set_endpoint(endpoint); @@ -594,8 +595,8 @@ base::Status NsClient::UpdateTableAliveStatus(const std::string& endpoint, const if (pid < UINT32_MAX) { request.set_pid(pid); } - auto st = client_.SendRequestSt(&::openmldb::nameserver::NameServer_Stub::UpdateTableAliveStatus, &request, &response, - FLAGS_request_timeout_ms, 1); + auto st = client_.SendRequestSt(&::openmldb::nameserver::NameServer_Stub::UpdateTableAliveStatus, &request, + &response, FLAGS_request_timeout_ms, 1); if (st.OK()) { return {response.code(), response.msg()}; } diff --git a/src/client/tablet_client.cc b/src/client/tablet_client.cc index 923d14a384b..a71aa6ed801 100644 --- a/src/client/tablet_client.cc +++ b/src/client/tablet_client.cc @@ -681,12 +681,13 @@ base::Status TabletClient::GetTableFollower(uint32_t tid, uint32_t pid, uint64_t request.set_tid(tid); request.set_pid(pid); auto st = client_.SendRequestSt(&::openmldb::api::TabletServer_Stub::GetTableFollower, &request, &response, - FLAGS_request_timeout_ms, 1); + FLAGS_request_timeout_ms, 1); if (st.OK()) { - if(response.code() == 0) { + if (response.code() == 0) { offset = response.offset(); for (int idx = 0; idx < response.follower_info_size(); idx++) { - info_map.insert(std::make_pair(response.follower_info(idx).endpoint(), response.follower_info(idx).offset())); + info_map.insert( + std::make_pair(response.follower_info(idx).endpoint(), response.follower_info(idx).offset())); } return {}; } else { diff --git a/src/client/tablet_client.h b/src/client/tablet_client.h index 7d2c948d7a9..447e58cbb6e 100644 --- a/src/client/tablet_client.h +++ b/src/client/tablet_client.h @@ -39,7 +39,6 @@ namespace sdk { class SQLRequestRowBatch; } // namespace sdk - namespace client { using ::openmldb::api::TaskInfo; const uint32_t INVALID_REMOTE_TID = UINT32_MAX; @@ -78,7 +77,8 @@ class TabletClient : public Client { bool Get(uint32_t tid, uint32_t pid, const std::string& pk, uint64_t time, std::string& value, // NOLINT uint64_t& ts, // NOLINT - std::string& msg); ; // NOLINT + std::string& msg); + ; // NOLINT bool Get(uint32_t tid, uint32_t pid, const std::string& pk, uint64_t time, const std::string& idx_name, std::string& value, // NOLINT @@ -89,21 +89,20 @@ class TabletClient : public Client { std::string& msg); // NOLINT base::Status Delete(uint32_t tid, uint32_t pid, const std::map& index_val, - const std::string& ts_name, const std::optional start_ts, const std::optional& end_ts); + const std::string& ts_name, const std::optional start_ts, + const std::optional& end_ts); bool Count(uint32_t tid, uint32_t pid, const std::string& pk, const std::string& idx_name, bool filter_expired_data, uint64_t& value, std::string& msg); // NOLINT + std::shared_ptr Scan(uint32_t tid, uint32_t pid, const std::string& pk, + const std::string& idx_name, uint64_t stime, uint64_t etime, + uint32_t limit, uint32_t skip_record_num, + std::string& msg); // NOLINT - std::shared_ptr Scan(uint32_t tid, uint32_t pid, - const std::string& pk, const std::string& idx_name, - uint64_t stime, uint64_t etime, - uint32_t limit, uint32_t skip_record_num, std::string& msg); // NOLINT - - std::shared_ptr Scan(uint32_t tid, uint32_t pid, - const std::string& pk, const std::string& idx_name, - uint64_t stime, uint64_t etime, - uint32_t limit, std::string& msg); // NOLINT + std::shared_ptr Scan(uint32_t tid, uint32_t pid, const std::string& pk, + const std::string& idx_name, uint64_t stime, uint64_t etime, + uint32_t limit, std::string& msg); // NOLINT bool Scan(const ::openmldb::api::ScanRequest& request, brpc::Controller* cntl, ::openmldb::api::ScanResponse* response); @@ -137,8 +136,8 @@ class TabletClient : public Client { base::Status LoadTable(const std::string& name, uint32_t id, uint32_t pid, uint64_t ttl, uint32_t seg_cnt); - base::Status LoadTable(const std::string& name, uint32_t id, uint32_t pid, uint64_t ttl, bool leader, uint32_t seg_cnt, - std::shared_ptr task_info = std::shared_ptr()); + base::Status LoadTable(const std::string& name, uint32_t id, uint32_t pid, uint64_t ttl, bool leader, + uint32_t seg_cnt, std::shared_ptr task_info = std::shared_ptr()); // for ns WrapTaskFun, must return bool bool LoadTable(const ::openmldb::api::TableMeta& table_meta, std::shared_ptr task_info); @@ -159,25 +158,25 @@ class TabletClient : public Client { bool GetTermPair(uint32_t tid, uint32_t pid, ::openmldb::common::StorageMode storage_mode, // NOLINT - uint64_t& term, // NOLINT - uint64_t& offset, bool& has_table, // NOLINT - bool& is_leader); // NOLINT + uint64_t& term, // NOLINT + uint64_t& offset, bool& has_table, // NOLINT + bool& is_leader); // NOLINT bool GetManifest(uint32_t tid, uint32_t pid, ::openmldb::common::StorageMode storage_mode, - ::openmldb::api::Manifest& manifest); // NOLINT + ::openmldb::api::Manifest& manifest); // NOLINT base::Status GetTableStatus(::openmldb::api::GetTableStatusResponse& response); // NOLINT base::Status GetTableStatus(uint32_t tid, uint32_t pid, - ::openmldb::api::TableStatus& table_status); // NOLINT + ::openmldb::api::TableStatus& table_status); // NOLINT base::Status GetTableStatus(uint32_t tid, uint32_t pid, bool need_schema, - ::openmldb::api::TableStatus& table_status); // NOLINT + ::openmldb::api::TableStatus& table_status); // NOLINT bool FollowOfNoOne(uint32_t tid, uint32_t pid, uint64_t term, uint64_t& offset); // NOLINT base::Status GetTableFollower(uint32_t tid, uint32_t pid, - uint64_t& offset, // NOLINT - std::map& info_map); // NOLINT + uint64_t& offset, // NOLINT + std::map& info_map); // NOLINT bool GetAllSnapshotOffset(std::map>& tid_pid_offset); // NOLINT @@ -186,8 +185,9 @@ class TabletClient : public Client { bool DisConnectZK(); std::shared_ptr Traverse(uint32_t tid, uint32_t pid, - const std::string& idx_name, const std::string& pk, uint64_t ts, - uint32_t limit, bool skip_current_pk, uint32_t ts_pos, uint32_t& count); // NOLINT + const std::string& idx_name, const std::string& pk, + uint64_t ts, uint32_t limit, bool skip_current_pk, + uint32_t ts_pos, uint32_t& count); // NOLINT bool SetMode(bool mode); @@ -196,9 +196,8 @@ class TabletClient : public Client { bool AddIndex(uint32_t tid, uint32_t pid, const ::openmldb::common::ColumnKey& column_key, std::shared_ptr task_info); - bool AddMultiIndex(uint32_t tid, uint32_t pid, - const std::vector<::openmldb::common::ColumnKey>& column_keys, - std::shared_ptr task_info); + bool AddMultiIndex(uint32_t tid, uint32_t pid, const std::vector<::openmldb::common::ColumnKey>& column_keys, + std::shared_ptr task_info); bool GetCatalog(uint64_t* version); @@ -208,8 +207,7 @@ class TabletClient : public Client { bool LoadIndexData(uint32_t tid, uint32_t pid, uint32_t partition_num, std::shared_ptr task_info); bool ExtractIndexData(uint32_t tid, uint32_t pid, uint32_t partition_num, - const std::vector<::openmldb::common::ColumnKey>& column_key, - uint64_t offset, bool dump_data, + const std::vector<::openmldb::common::ColumnKey>& column_key, uint64_t offset, bool dump_data, std::shared_ptr task_info); bool CancelOP(const uint64_t op_id); @@ -228,9 +226,9 @@ class TabletClient : public Client { uint64_t timeout_ms); base::Status CallSQLBatchRequestProcedure(const std::string& db, const std::string& sp_name, - const base::Slice& meta, const base::Slice& data, - bool is_debug, uint64_t timeout_ms, - brpc::Controller* cntl, openmldb::api::SQLBatchRequestQueryResponse* response); + const base::Slice& meta, const base::Slice& data, bool is_debug, + uint64_t timeout_ms, brpc::Controller* cntl, + openmldb::api::SQLBatchRequestQueryResponse* response); bool DropProcedure(const std::string& db_name, const std::string& sp_name); @@ -254,14 +252,13 @@ class TabletClient : public Client { uint64_t timeout_ms, openmldb::RpcCallback* callback); - base::Status CallSQLBatchRequestProcedure(const std::string& db, const std::string& sp_name, - const base::Slice& meta, const base::Slice& data, - bool is_debug, uint64_t timeout_ms, - openmldb::RpcCallback* callback); + base::Status CallSQLBatchRequestProcedure( + const std::string& db, const std::string& sp_name, const base::Slice& meta, const base::Slice& data, + bool is_debug, uint64_t timeout_ms, + openmldb::RpcCallback* callback); - bool CreateAggregator(const ::openmldb::api::TableMeta& base_table_meta, - uint32_t aggr_tid, uint32_t aggr_pid, uint32_t index_pos, - const ::openmldb::base::LongWindowInfo& window_info); + bool CreateAggregator(const ::openmldb::api::TableMeta& base_table_meta, uint32_t aggr_tid, uint32_t aggr_pid, + uint32_t index_pos, const ::openmldb::base::LongWindowInfo& window_info); bool GetAndFlushDeployStats(::openmldb::api::DeployStatsResponse* res); diff --git a/src/cmd/openmldb.cc b/src/cmd/openmldb.cc index fe1875c901f..053ff033c24 100644 --- a/src/cmd/openmldb.cc +++ b/src/cmd/openmldb.cc @@ -480,7 +480,8 @@ void HandleNSClientSetTTL(const std::vector& parts, ::openmldb::cli bool ok = client->UpdateTTL(parts[1], type, abs_ttl, lat_ttl, index_name, err); if (ok) { std::cout << "Set ttl ok ! Note that, " - "it will take effect after two garbage collection intervals (i.e. gc_interval)." << std::endl; + "it will take effect after two garbage collection intervals (i.e. gc_interval)." + << std::endl; } else { std::cout << "Set ttl failed! " << err << std::endl; } @@ -907,8 +908,8 @@ void HandleNSClientChangeLeader(const std::vector& parts, ::openmld std::cout << "Invalid args. pid should be uint32_t" << std::endl; return; } - std::cout << "change leader ok. " - "If there are writing operations while changing a leader, it may cause data loss." << std::endl; + std::cout << "change leader ok. If there are writing operations while changing a leader, it may cause data loss." + << std::endl; } void HandleNSClientOfflineEndpoint(const std::vector& parts, ::openmldb::client::NsClient* client) { @@ -2694,7 +2695,7 @@ void HandleNSClientUpdateTableAlive(const std::vector& parts, ::ope } } - if (auto st = client->UpdateTableAliveStatus(endpoint, name, pid, is_alive);!st.OK()) { + if (auto st = client->UpdateTableAliveStatus(endpoint, name, pid, is_alive); !st.OK()) { std::cout << "Fail to update table alive. error msg: " << st.GetMsg() << std::endl; return; } @@ -3107,8 +3108,9 @@ void HandleClientGetTableStatus(const std::vector parts, ::openmldb if (parts.size() == 3) { ::openmldb::api::TableStatus table_status; try { - if (auto st = client->GetTableStatus(boost::lexical_cast(parts[1]), boost::lexical_cast(parts[2]), - table_status); st.OK()) { + if (auto st = client->GetTableStatus(boost::lexical_cast(parts[1]), + boost::lexical_cast(parts[2]), table_status); + st.OK()) { status_vec.push_back(table_status); } else { std::cout << "gettablestatus failed, error msg: " << st.GetMsg() << std::endl; @@ -3676,8 +3678,8 @@ void StartNsClient() { } std::shared_ptr<::openmldb::zk::ZkClient> zk_client; if (!FLAGS_zk_cluster.empty()) { - zk_client = std::make_shared<::openmldb::zk::ZkClient>(FLAGS_zk_cluster, "", - FLAGS_zk_session_timeout, "", FLAGS_zk_root_path); + zk_client = std::make_shared<::openmldb::zk::ZkClient>(FLAGS_zk_cluster, "", FLAGS_zk_session_timeout, "", + FLAGS_zk_root_path); if (!zk_client->Init()) { std::cout << "zk client init failed" << std::endl; return; diff --git a/src/replica/snapshot_replica_test.cc b/src/replica/snapshot_replica_test.cc index a9302050142..05e9a9d01da 100644 --- a/src/replica/snapshot_replica_test.cc +++ b/src/replica/snapshot_replica_test.cc @@ -93,7 +93,8 @@ TEST_P(SnapshotReplicaTest, AddReplicate) { sleep(1); ::openmldb::api::TableStatus table_status; - ASSERT_TRUE(client.GetTableStatus(tid, pid, table_status)); + auto st = client.GetTableStatus(tid, pid, table_status); + ASSERT_TRUE(st.OK()) << st.ToString(); ASSERT_EQ(::openmldb::api::kTableNormal, table_status.state()); ret = client.DelReplica(tid, pid, end_point);