Expose locally collected rx peer statistics
authorJacob Thebault-Spieker <summatusmentis@gmail.com>
Wed, 22 Jul 2009 21:56:32 +0000 (17:56 -0400)
committerDerrick Brashear <shadow@dementia.org>
Thu, 23 Jul 2009 16:00:41 +0000 (09:00 -0700)
This implements rx_GetLocalPeers(), which exposes peer statistics
that are currently collected to the cache manager. This function
will later be used to rank both the file server and vldb server
lists using the statistics exposed by rx_GetLocalPeers().

Reviewed-on: http://gerrit.openafs.org/http://gerrit.openafs.org/186
Reviewed-by: Jeffrey Altman <jaltman@openafs.org>
Tested-by: Jeffrey Altman <jaltman@openafs.org>
Tested-by: Derrick Brashear <shadow@dementia.org>
Reviewed-by: Derrick Brashear <shadow@dementia.org>

src/libafsrpc/afsrpc.def [changed mode: 0644->0755]
src/libafsrpc/afsrpc.exp [changed mode: 0644->0755]
src/rx/rx.c [changed mode: 0644->0755]
src/rx/rx_prototypes.h [changed mode: 0644->0755]
src/shlibafsrpc/libafsrpc.exp [changed mode: 0644->0755]
src/shlibafsrpc/libafsrpc.map [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index e727d04..0fe1c64
@@ -247,6 +247,7 @@ EXPORTS
         xdr_free                                @252
         RXAFS_FsCmd                             @253
         rxi_CallError                           @254
+        rx_GetLocalPeers                       @255
 
 ; for performance testing
         rx_TSFPQGlobSize                        @2001 DATA
old mode 100644 (file)
new mode 100755 (executable)
index 97e3bb5..0b19b05
@@ -166,3 +166,4 @@ RXAFS_FlushCPS
 RXAFS_DFSSymlink
 RXAFSCB_function_names
 RXAFS_FsCmd
+rx_GetLocalPeers
old mode 100644 (file)
new mode 100755 (executable)
index f91c6cf..df2349b
@@ -6959,6 +6959,60 @@ rx_GetServerPeers(osi_socket socket, afs_uint32 remoteAddr,
     return rc;
 }
 
+afs_int32 
+rx_GetLocalPeers(afs_uint32 peerHost, afs_uint16 peerPort,
+               struct rx_debugPeer * peerStats)
+{
+       struct rx_peer *tp;
+       afs_int32 error = 1; /* default to "did not succeed" */
+       afs_uint32 hashValue = PEER_HASH(peerHost, peerPort);
+
+       MUTEX_ENTER(&rx_peerHashTable_lock);
+       for(tp = rx_peerHashTable[hashValue]; 
+             tp != NULL; tp = tp->next) {
+               if (tp->host == peerHost)
+                       break;
+       }
+
+       if (tp) {
+               error = 0;
+
+               peerStats->host = tp->host;
+               peerStats->port = tp->port;
+               peerStats->ifMTU = tp->ifMTU;
+               peerStats->idleWhen = tp->idleWhen;
+               peerStats->refCount = tp->refCount;
+               peerStats->burstSize = tp->burstSize;
+               peerStats->burst = tp->burst;
+               peerStats->burstWait.sec = tp->burstWait.sec;
+               peerStats->burstWait.usec = tp->burstWait.usec;
+               peerStats->rtt = tp->rtt;
+               peerStats->rtt_dev = tp->rtt_dev;
+               peerStats->timeout.sec = tp->timeout.sec;
+               peerStats->timeout.usec = tp->timeout.usec;
+               peerStats->nSent = tp->nSent;
+               peerStats->reSends = tp->reSends;
+               peerStats->inPacketSkew = tp->inPacketSkew;
+               peerStats->outPacketSkew = tp->outPacketSkew;
+               peerStats->rateFlag = tp->rateFlag;
+               peerStats->natMTU = tp->natMTU;
+               peerStats->maxMTU = tp->maxMTU;
+               peerStats->maxDgramPackets = tp->maxDgramPackets;
+               peerStats->ifDgramPackets = tp->ifDgramPackets;
+               peerStats->MTU = tp->MTU;
+               peerStats->cwind = tp->cwind;
+               peerStats->nDgramPackets = tp->nDgramPackets;
+               peerStats->congestSeq = tp->congestSeq;
+               peerStats->bytesSent.high = tp->bytesSent.high;
+               peerStats->bytesSent.low = tp->bytesSent.low;
+               peerStats->bytesReceived.high = tp->bytesReceived.high;
+               peerStats->bytesReceived.low = tp->bytesReceived.low;
+       }
+       MUTEX_EXIT(&rx_peerHashTable_lock);
+
+       return error;
+}
+
 void
 shutdown_rx(void)
 {
old mode 100644 (file)
new mode 100755 (executable)
index 307e75d..b7415ac
@@ -217,6 +217,8 @@ extern afs_int32 rx_GetServerPeers(osi_socket socket, afs_uint32 remoteAddr,
                                   afs_uint32 debugSupportedValues,
                                   struct rx_debugPeer *peer,
                                   afs_uint32 * supportedValues);
+extern afs_int32 rx_GetLocalPeers(afs_uint32 peerHost, afs_uint16 peerPort,
+                                     struct rx_debugPeer * peerStats);
 extern void shutdown_rx(void);
 #ifndef osirx_AssertMine
 extern void osirx_AssertMine(afs_kmutex_t * lockaddr, char *msg);
old mode 100644 (file)
new mode 100755 (executable)
index 06f1af9..c73bb63
@@ -165,3 +165,4 @@ RXAFS_Lookup
 RXAFS_FlushCPS
 RXAFS_DFSSymlink
 RXAFSCB_function_names
+rx_GetLocalPeers
old mode 100644 (file)
new mode 100755 (executable)
index b29b98f..d816cb0
        ucstring;
        lcstring;
        AssertionFailed;
+       rx_GetLocalPeers
 
     local:
        *;