MCPcopy Create free account
hub / github.com/ceph/ceph / gather_socket_output

Method gather_socket_output

src/test/admin_socket_output.cc:126–195  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

124}
125
126bool AdminSocketOutput::gather_socket_output() {
127
128 std::cout << "Gathering socket output" << std::endl;
129 for (const auto& socket : sockets) {
130 std::string response;
131 AdminSocketClient client(socket.second);
132 std::cout << std::endl
133 << "Sending request to " << socket << std::endl
134 << std::endl;
135 std::string err = client.do_request("{\"prefix\":\"help\"}", &response);
136 if (!err.empty()) {
137 std::cerr << __func__ << " AdminSocketClient::do_request errored with: "
138 << err << std::endl;
139 return false;
140 }
141 std::cout << response << '\n';
142
143 JSONParser parser;
144 bool ret = parser.parse(response.c_str(), response.size());
145 if (!ret) {
146 cerr << "parse error" << std::endl;
147 return false;
148 }
149
150 socket_results sresults;
151 JSONObjIter iter = parser.find_first();
152 const auto postponed_iter = postponed_commands.find(socket.first);
153 std::vector<std::string> postponed;
154 if (postponed_iter != postponed_commands.end()) {
155 postponed = postponed_iter->second;
156 }
157 std::cout << "Sending commands to " << socket.first << " socket"
158 << std::endl;
159 for (; !iter.end(); ++iter) {
160 if (std::find(postponed.begin(), postponed.end(), (*iter)->get_name())
161 != std::end(postponed)) {
162 std::cout << "Command \"" << (*iter)->get_name() << "\" postponed"
163 << std::endl;
164 continue;
165 }
166 sresults.insert(run_command(client, (*iter)->get_name()));
167 }
168
169 if (sresults.empty()) {
170 return false;
171 }
172
173 // Custom commands
174 const auto seek = custom_commands.find(socket.first);
175 if (seek != custom_commands.end()) {
176 std::cout << std::endl << "Sending custom commands:" << std::endl;
177 for (const auto& raw_command : seek->second) {
178 sresults.insert(run_command(client, raw_command, true));
179 }
180 }
181
182 // Postponed commands
183 if (!postponed.empty())

Callers

nothing calls this directly

Calls 14

findFunction · 0.85
endFunction · 0.50
run_commandFunction · 0.50
do_requestMethod · 0.45
emptyMethod · 0.45
parseMethod · 0.45
c_strMethod · 0.45
sizeMethod · 0.45
find_firstMethod · 0.45
findMethod · 0.45
endMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected