vlclient: add -probe option
authorMichael Meffie <mmeffie@sinenomine.net>
Wed, 16 Jan 2013 17:10:02 +0000 (12:10 -0500)
committerDerrick Brashear <shadow@your-file-system.com>
Sat, 2 Feb 2013 13:21:58 +0000 (05:21 -0800)
Add a new option to the vlclient test program to call the
probe server RPC to ping the vlservers in a cell. Uses a multi
rx call to do the probes in parallel.

The existing -host option can be used to ping a single
vlserver.

Change-Id: I25666b7ff139ae43364ac04869b14997f3ed0d53
Reviewed-on: http://gerrit.openafs.org/8911
Reviewed-by: Chas Williams - CONTRACTOR <chas@cmf.nrl.navy.mil>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

src/vlserver/liboafs_vldb.la.sym
src/vlserver/vlclient.c

index 1730061..ea9c653 100644 (file)
@@ -28,3 +28,7 @@ ubik_VL_UpdateEntry
 ubik_VL_UpdateEntryByName
 xdr_bulkaddrs
 xdr_bulkentries
+VL_ProbeServer
+EndVL_ProbeServer
+StartVL_ProbeServer
+ubik_VL_ProbeServer
index 4167d6e..403e20c 100644 (file)
@@ -60,7 +60,7 @@ static char *opcode_names[VL_NUMBER_OPCODESX] = {
     "ListAttributes",
     "LinkedList",
     "GetStats",
-    "Probe",
+    "Probe",   /* RPC is ProbeServer */
     "GetAddrs",
     "ChangeAddr",
     "CreateEntryN",
@@ -202,7 +202,42 @@ handleit(struct cmd_syndesc *as, void *arock)
        exit(1);
     }
 
-    if (as->parms[5].items) {  /* -gstats */
+    if (as->parms[6].items) {  /* -probe */
+       int nconns = 0;
+       int status = 0;
+       int i;
+       char hoststr[16];
+       afs_uint32 addr;
+
+       for (i = 0; cstruct->conns[i]; i++, nconns++) {
+           rx_SetConnDeadTime(cstruct->conns[i], 6);
+           addr = rx_HostOf(rx_PeerOf(cstruct->conns[i]));
+           if (!nconns) {
+               printf("probing");
+           }
+           printf(" %s", afs_inet_ntoa_r(addr, hoststr));
+       }
+       if (nconns == 0) {
+           printf("no connections\n");
+           return 255;
+       }
+       printf("\n");
+       multi_Rx(cstruct->conns, nconns) {
+           multi_VL_ProbeServer();
+           addr = rx_HostOf(rx_PeerOf(cstruct->conns[multi_i]));
+           if (!multi_error) {
+               printf(" ok: %s\n", afs_inet_ntoa_r(addr, hoststr));
+           } else {
+               status = 255;
+               printf(" not ok (%d): %s\n", multi_error,
+                      afs_inet_ntoa_r(addr, hoststr));
+           }
+       }
+       multi_End;
+       return status;
+    }
+
+    if (as->parms[5].items) {  /* -getstats */
        vldstats stats;
        vital_vlheader vital_header;
        code = ubik_VL_GetStats(cstruct, 0, &stats, &vital_header);
@@ -1015,6 +1050,8 @@ main(int argc, char **argv)
                "cellname '-host' belongs to (required for auth conns)");
     cmd_AddParm(ts, "-getstats", CMD_FLAG, CMD_OPTIONAL,
                "print vldb statistics (non interactive)");
+    cmd_AddParm(ts, "-probe", CMD_FLAG, CMD_OPTIONAL,
+               "probe vldb servers, use with -host to probe only one. (non interactive)");
     code = cmd_Dispatch(argc, argv);
     exit(code);
 }