MCPcopy Create free account
hub / github.com/apple/foundationdb / printStatus

Function printStatus

fdbcli/StatusCommand.actor.cpp:203–1221  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

201namespace fdb_cli {
202
203void printStatus(StatusObjectReader statusObj,
204 StatusClient::StatusLevel level,
205 bool displayDatabaseAvailable,
206 bool hideErrorMessages) {
207 if (FlowTransport::transport().incompatibleOutgoingConnectionsPresent()) {
208 fprintf(
209 stderr,
210 "WARNING: One or more of the processes in the cluster is incompatible with this version of fdbcli.\n\n");
211 }
212
213 try {
214 bool printedCoordinators = false;
215
216 // status or status details
217 if (level == StatusClient::NORMAL || level == StatusClient::DETAILED) {
218
219 StatusObjectReader statusObjClient;
220 statusObj.get("client", statusObjClient);
221
222 // The way the output string is assembled is to add new line character before addition to the string rather
223 // than after
224 std::string outputString = "";
225 std::string clusterFilePath;
226 if (statusObjClient.get("cluster_file.path", clusterFilePath))
227 outputString = format("Using cluster file `%s'.\n", clusterFilePath.c_str());
228 else
229 outputString = "Using unknown cluster file.\n";
230
231 StatusObjectReader statusObjCoordinators;
232 StatusArray coordinatorsArr;
233
234 if (statusObjClient.get("coordinators", statusObjCoordinators)) {
235 // Look for a second "coordinators", under the first one.
236 if (statusObjCoordinators.has("coordinators"))
237 coordinatorsArr = statusObjCoordinators.last().get_array();
238 }
239
240 // Check if any coordination servers are unreachable
241 bool quorum_reachable;
242 if (statusObjCoordinators.get("quorum_reachable", quorum_reachable) && !quorum_reachable) {
243 outputString += "\nCould not communicate with a quorum of coordination servers:";
244 outputString += getCoordinatorsInfoString(statusObj);
245
246 printf("%s\n", outputString.c_str());
247 return;
248 } else {
249 for (StatusObjectReader coor : coordinatorsArr) {
250 bool reachable;
251 if (coor.get("reachable", reachable) && !reachable) {
252 outputString += "\nCould not communicate with all of the coordination servers."
253 "\n The database will remain operational as long as we"
254 "\n can connect to a quorum of servers, however the fault"
255 "\n tolerance of the system is reduced as long as the"
256 "\n servers remain disconnected.\n";
257 outputString += getCoordinatorsInfoString(statusObj);
258 outputString += "\n";
259 printedCoordinators = true;
260 break;

Callers 3

printStatusFromJSONFunction · 0.85
Future<Void> checkStatusFunction · 0.85

Calls 15

fprintfFunction · 0.85
printfFunction · 0.85
lineWrapFunction · 0.85
getDateInfoStringFunction · 0.85
getWorkloadRatesFunction · 0.85
getBackupDRTagsFunction · 0.85
logBackupDRFunction · 0.85
write_stringFunction · 0.85

Tested by

no test coverage detected