@@ -2177,7 +2177,7 @@ void NameServerImpl::MakeSnapshotNS(RpcController* controller, const MakeSnapsho
21772177 request->name ().c_str (), request->pid ());
21782178}
21792179
2180- int NameServerImpl::SetPartitionInfo (TableInfo& table_info) {
2180+ base::Status NameServerImpl::SetPartitionInfo (TableInfo& table_info) {
21812181 uint32_t partition_num = FLAGS_partition_num;
21822182 if (table_info.has_partition_num () && table_info.partition_num () > 0 ) {
21832183 partition_num = table_info.partition_num ();
@@ -2204,11 +2204,11 @@ int NameServerImpl::SetPartitionInfo(TableInfo& table_info) {
22042204 if (endpoint_pid_bucked.size () < replica_num) {
22052205 PDLOG (WARNING, " healthy endpoint num[%u] is less than replica_num[%u]" , endpoint_pid_bucked.size (),
22062206 replica_num);
2207- return - 1 ;
2207+ return base::Status (base:: kError , " healthy endpoint num is less than replica num " ) ;
22082208 }
22092209 if (replica_num < 1 ) {
2210- PDLOG (WARNING, " replica_num less than 1 that is illegal, replica_num[%u]" , replica_num);
2211- return - 1 ;
2210+ PDLOG (WARNING, " replica_num cannot be less than 1. replica_num[%u]" , replica_num);
2211+ return base::Status (base:: kError , " replica_num cannot be less than 1 " ) ;
22122212 }
22132213 std::map<std::string, uint64_t > endpoint_leader = endpoint_pid_bucked;
22142214 {
@@ -2274,7 +2274,7 @@ int NameServerImpl::SetPartitionInfo(TableInfo& table_info) {
22742274 }
22752275 PDLOG (INFO, " set table partition ok. name[%s] partition_num[%u] replica_num[%u]" , table_info.name ().c_str (),
22762276 partition_num, replica_num);
2277- return 0 ;
2277+ return {} ;
22782278}
22792279
22802280base::Status NameServerImpl::CreateTableOnTablet (const std::shared_ptr<::openmldb::nameserver::TableInfo>& table_info,
@@ -3559,9 +3559,10 @@ void NameServerImpl::CreateTableInfoSimply(RpcController* controller, const Crea
35593559 return ;
35603560 }
35613561 } else {
3562- if (SetPartitionInfo (*table_info) < 0 ) {
3562+ auto status = SetPartitionInfo (*table_info);
3563+ if (!status.OK ()) {
35633564 response->set_code (::openmldb::base::ReturnCode::kSetPartitionInfoFailed );
3564- response->set_msg (" set partition info failed " );
3565+ response->set_msg (status. GetMsg () );
35653566 PDLOG (WARNING, " set partition info failed" );
35663567 return ;
35673568 }
@@ -3655,9 +3656,10 @@ void NameServerImpl::CreateTableInfo(RpcController* controller, const CreateTabl
36553656 return ;
36563657 }
36573658 } else {
3658- if (SetPartitionInfo (*table_info) < 0 ) {
3659+ auto status = SetPartitionInfo (*table_info);
3660+ if (!status.OK ()) {
36593661 response->set_code (::openmldb::base::ReturnCode::kSetPartitionInfoFailed );
3660- response->set_msg (" set partition info failed " );
3662+ response->set_msg (status. GetMsg () );
36613663 PDLOG (WARNING, " set partition info failed" );
36623664 return ;
36633665 }
@@ -3843,9 +3845,9 @@ void NameServerImpl::CreateTable(RpcController* controller, const CreateTableReq
38433845 return ;
38443846 }
38453847 } else {
3846- if ( SetPartitionInfo (*table_info) < 0 ) {
3847- base::SetResponseStatus (base::ReturnCode:: kSetPartitionInfoFailed , " set partition info failed " ,
3848- response);
3848+ auto status = SetPartitionInfo (*table_info);
3849+ if (!status. OK ()) {
3850+ base::SetResponseStatus (base::ReturnCode:: kSetPartitionInfoFailed , status. GetMsg (), response);
38493851 PDLOG (WARNING, " set partition info failed" );
38503852 return ;
38513853 }
@@ -9919,9 +9921,10 @@ base::Status NameServerImpl::CreateSystemTable(SystemTableType table_type) {
99199921 return {base::ReturnCode::kError , " allocate tid failed" };
99209922 }
99219923 table_info->set_tid (tid);
9922- if (SetPartitionInfo (*table_info) < 0 ) {
9924+ auto status = SetPartitionInfo (*table_info);
9925+ if (!status.OK ()) {
99239926 LOG (WARNING) << " set partition info failed. name is " << GetSystemTableName (table_type);
9924- return {base::ReturnCode:: kError , " set partition info failed " } ;
9927+ return status ;
99259928 }
99269929 uint64_t cur_term = GetTerm ();
99279930 GeneralResponse response;
0 commit comments