| 3087 | } |
| 3088 | |
| 3089 | void HandleNSClientUpdateTableAlive(const std::vector<std::string>& parts, |
| 3090 | ::fedb::client::NsClient* client) { |
| 3091 | if (parts.size() < 5) { |
| 3092 | std::cout << "Bad format" << std::endl; |
| 3093 | return; |
| 3094 | } |
| 3095 | std::string name = parts[1]; |
| 3096 | std::string endpoint = parts[3]; |
| 3097 | bool is_alive = false; |
| 3098 | if (parts[4] == "yes") { |
| 3099 | is_alive = true; |
| 3100 | } else if (parts[4] == "no") { |
| 3101 | is_alive = false; |
| 3102 | } else { |
| 3103 | std::cout << "is_alive should be yes or no" << std::endl; |
| 3104 | return; |
| 3105 | } |
| 3106 | uint32_t pid = UINT32_MAX; |
| 3107 | if (parts[2] != "*") { |
| 3108 | try { |
| 3109 | int pid_tmp = boost::lexical_cast<int32_t>(parts[2]); |
| 3110 | if (pid_tmp < 0) { |
| 3111 | std::cout << "Invalid args. pid should be uint32_t" |
| 3112 | << std::endl; |
| 3113 | return; |
| 3114 | } |
| 3115 | pid = pid_tmp; |
| 3116 | } catch (std::exception const& e) { |
| 3117 | std::cout << "Invalid args. pid should be uint32_t" << std::endl; |
| 3118 | return; |
| 3119 | } |
| 3120 | } |
| 3121 | std::string msg; |
| 3122 | if (!client->UpdateTableAliveStatus(endpoint, name, pid, is_alive, msg)) { |
| 3123 | std::cout << "Fail to update table alive. error msg: " << msg |
| 3124 | << std::endl; |
| 3125 | return; |
| 3126 | } |
| 3127 | std::cout << "update ok" << std::endl; |
| 3128 | } |
| 3129 | |
| 3130 | void HandleNSShowOPStatus(const std::vector<std::string>& parts, |
| 3131 | ::fedb::client::NsClient* client) { |
no test coverage detected