[Opensrf-commits] r976 - trunk/src/router

svn at svn.open-ils.org svn at svn.open-ils.org
Mon Jun 25 16:50:48 EDT 2007


Author: miker
Date: 2007-06-25 16:48:18 -0400 (Mon, 25 Jun 2007)
New Revision: 976

Modified:
   trunk/src/router/osrf_router.c
Log:
adding yet more router commands to gather some stats about request counts

Modified: trunk/src/router/osrf_router.c
===================================================================
--- trunk/src/router/osrf_router.c	2007-06-25 20:22:34 UTC (rev 975)
+++ trunk/src/router/osrf_router.c	2007-06-25 20:48:18 UTC (rev 976)
@@ -6,8 +6,10 @@
 
 
 #define ROUTER_REQUEST_CLASS_LIST "opensrf.router.info.class.list"
-#define ROUTER_REQUEST_FULL_STATS "opensrf.router.info.stats.class.node.all"
-#define ROUTER_REQUEST_CLASS_STATS "opensrf.router.info.stats.class.all"
+#define ROUTER_REQUEST_STATS_NODE_FULL "opensrf.router.info.stats.class.node.all"
+#define ROUTER_REQUEST_STATS_CLASS_FULL "opensrf.router.info.stats.class.all"
+#define ROUTER_REQUEST_STATS_CLASS "opensrf.router.info.stats.class"
+#define ROUTER_REQUEST_STATS_CLASS_SUMMARY "opensrf.router.info.stats.class.summary"
 
 osrfRouter* osrfNewRouter( 
 		char* domain, char* name, 
@@ -557,12 +559,57 @@
 		osrfStringArrayFree(keys);
 
 
-	} else if(!strcmp( omsg->method_name, ROUTER_REQUEST_FULL_STATS )) {
+	} else if(!strcmp( omsg->method_name, ROUTER_REQUEST_STATS_CLASS_SUMMARY )) {
 
 		osrfRouterClass* class;
 		osrfRouterNode* node;
+		int count = 0;
+
+		char* classname = jsonObjectToSimpleString( jsonObjectGetIndex( omsg->_params, 0 ) );
+
+		if (!classname) {
+			free(classname);
+			return -1;
+		}
+
+		class = osrfHashGet(router->classes, classname);
+
+		osrfHashIterator* node_itr = osrfNewHashIterator(class->nodes);
+		while( (node = osrfHashIteratorNext(node_itr)) ) {
+			count += node->count;
+			//jsonObjectSetKey( class_res, node->remoteId, jsonNewNumberObject( (double) node->count ) );
+		}
+		osrfHashIteratorFree(node_itr);
+
+		jresponse = jsonNewNumberObject( (double) count );
+
+	} else if(!strcmp( omsg->method_name, ROUTER_REQUEST_STATS_CLASS )) {
+
+		osrfRouterClass* class;
+		osrfRouterNode* node;
+
+		char* classname = jsonObjectToSimpleString( jsonObjectGetIndex( omsg->_params, 0 ) );
+
+		if (!classname) {
+			free(classname);
+			return -1;
+		}
+
 		jresponse = jsonParseString("{}");
+		class = osrfHashGet(router->classes, classname);
 
+		osrfHashIterator* node_itr = osrfNewHashIterator(class->nodes);
+		while( (node = osrfHashIteratorNext(node_itr)) ) {
+			jsonObjectSetKey( jresponse, node->remoteId, jsonNewNumberObject( (double) node->count ) );
+		}
+		osrfHashIteratorFree(node_itr);
+
+	} else if(!strcmp( omsg->method_name, ROUTER_REQUEST_STATS_CLASS_FULL )) {
+
+		osrfRouterClass* class;
+		osrfRouterNode* node;
+		jresponse = jsonParseString("{}");
+
 		osrfHashIterator* class_itr = osrfNewHashIterator(router->classes);
 		while( (class = osrfHashIteratorNext(class_itr)) ) {
 
@@ -580,7 +627,7 @@
 
 		osrfHashIteratorFree(class_itr);
 
-	} else if(!strcmp( omsg->method_name, ROUTER_REQUEST_CLASS_STATS )) {
+	} else if(!strcmp( omsg->method_name, ROUTER_REQUEST_STATS_NODE_FULL )) {
 
 		osrfRouterClass* class;
 		osrfRouterNode* node;



More information about the opensrf-commits mailing list