[MOBY-guts] biomoby commit
Eddie Kawas
kawas at dev.open-bio.org
Wed Oct 18 22:27:56 UTC 2006
kawas
Wed Oct 18 18:27:56 EDT 2006
Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/utilities
In directory dev.open-bio.org:/tmp/cvs-serv27044/Java/src/main/org/biomoby/client/ui/graphical/servlet/utilities
Modified Files:
ServiceTester.java
Log Message:
moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/utilities ServiceTester.java,1.7,1.8
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/utilities/ServiceTester.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/utilities/ServiceTester.java 2006/10/17 14:14:43 1.7
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/utilities/ServiceTester.java 2006/10/18 22:27:56 1.8
@@ -1,5 +1,8 @@
package org.biomoby.client.ui.graphical.servlet.utilities;
+import java.io.BufferedWriter;
+import java.io.FileWriter;
+import java.io.IOException;
import java.text.DecimalFormat;
import java.util.Collections;
import java.util.HashMap;
@@ -7,11 +10,15 @@
import java.util.Map;
import java.util.TreeMap;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+
import org.apache.axis.AxisFault;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.log4j.Logger;
import org.biomoby.client.CentralImpl;
import org.biomoby.shared.Central;
import org.biomoby.shared.MobyException;
@@ -27,7 +34,7 @@
// default number of threads
private int numThreads = 6;
-
+
private String newline = System.getProperty("line.separator");
private Log log = LogFactory.getLog(this.getClass());
@@ -93,7 +100,8 @@
if (testers[j] != null)
continue;
- // avoid indexing errors (we checked the length before entering loop)
+ // avoid indexing errors (we checked the length before
+ // entering loop)
if (i >= services.length)
break;
MobyService service = services[i++];
@@ -155,15 +163,56 @@
log.info("getting results complete");
return sb.toString();
}
-
+
public String getStats() {
StringBuffer sb = new StringBuffer();
Map map = getResultMap();
int num_bad_authorities = 0;
int total_alive = 0;
int total_dead = 0;
-
- sb.append("There are " + map.keySet().size() + " service providers, with at least one registered service, registered with this registry." + newline);
+
+ sb
+ .append("There are "
+ + map.keySet().size()
+ + " service providers, with at least one registered service, registered with this registry."
+ + newline);
+ for (Iterator it = map.keySet().iterator(); it.hasNext();) {
+ String key = (String) it.next();
+ Map list = (Map) map.get(key);
+ boolean hasGoodService = false;
+ // dive into this authoritys' services
+ for (Iterator listIt = list.keySet().iterator(); listIt.hasNext();) {
+ String servicename = (String) listIt.next();
+ Boolean contents = (Boolean) list.get(servicename);
+ if (contents.booleanValue()) {
+ total_alive++;
+ hasGoodService = true;
+ } else {
+ total_dead++;
+ }
+ }
+ // increment authority counts
+ if (!hasGoodService)
+ num_bad_authorities++;
+ }
+ DecimalFormat df = new DecimalFormat("####.00");
+ sb.append("\tOf these service providers, there are " + num_bad_authorities
+ + " that don't have at least one working service." + newline);
+ sb.append("There are " + total_alive
+ + " services that are reachable in their current state." + newline);
+ sb.append("There are " + total_dead + " services that are not reachable." + newline);
+ sb.append(newline + "\tThat represents approximately "
+ + df.format(((float) total_alive / (float) (total_dead + total_alive)) * 100)
+ + "% in terms of alive services.");
+ return Utils.format(sb.toString(), 1);
+ }
+
+ public void logStats() {
+ StringBuffer sb = new StringBuffer();
+ Map map = getResultMap();
+ int num_bad_authorities = 0;
+ int total_alive = 0;
+ int total_dead = 0;
for (Iterator it = map.keySet().iterator(); it.hasNext();) {
String key = (String) it.next();
Map list = (Map) map.get(key);
@@ -182,13 +231,99 @@
// increment authority counts
if (!hasGoodService)
num_bad_authorities++;
- }
+ }
DecimalFormat df = new DecimalFormat("####.00");
- sb.append("\tOf these service providers, there are " + num_bad_authorities + " that don't have at least one working service."+newline);
- sb.append("There are "+total_alive+" services that are reachable in their current state."+newline);
- sb.append("There are "+total_dead+" services that are not reachable."+newline);
- sb.append(newline + "\tThat represents approximately " + df.format(((float)total_alive/(float)(total_dead+total_alive))*100) + "% in terms of alive services." );
- return Utils.format(sb.toString(), 4);
+
+ sb.append(total_dead + ",");
+ sb.append(total_alive + ",");
+ sb
+ .append(df.format(((float) total_alive / (float) (total_dead + total_alive)) * 100)
+ + "%");
+
+ // Temporary file output - would preferably write to a separate log
+ try {
+ if (DIRECTORY == null) {
+ try {
+ Context c = new InitialContext();
+ DIRECTORY = (String)c.lookup("java:comp/env/CACHE_PATH");
+ } catch (Exception e) {
+ // default to the the user directory
+ DIRECTORY = System.getProperty("user.dir");
+ }
+ }
+ BufferedWriter out = new BufferedWriter(new FileWriter(DIRECTORY +"/" + "CallableStatsLog.txt", true));
+ out.write(sb.toString()+newline);
+ out.close();
+ } catch (IOException e) {
+ }
+
+ // would like if this wrote to a different file
+ Logger.getLogger("CallableStats").info("###" + sb.toString() + "###");
+
+ }
+
+ private String DIRECTORY = null;
+ public String getDeadServicesByAuthority() {
+ StringBuffer sb = new StringBuffer();
+ sb.append("The following are services, sorted by Service Provider, have been identified"
+ + " as \"dead\" by the MOBY Service Testing agent."
+ + newline
+ + newline
+ + "A \"dead\" service is one that does not respond correctly to a MOBY "
+ + "\"ping\"; where a correct \"ping\" request/response is:"
+ + newline
+ + newline
+ + "REQUEST"
+ + newline
+ + newline
+ + " <MOBY>"
+ + newline
+ + " <mobyContent></mobyContent>"
+ + newline
+ + " </MOBY>"
+ + newline
+ + newline
+ + "RESPONSE"
+ + newline
+ + newline
+ + " <MOBY>"
+ + newline
+ + " <mobyContent></mobyContent>"
+ + newline
+ + " </MOBY>"
+ + newline
+ + newline
+ + "The status of all services is tested hourly, and is recorded in the "
+ + newline
+ + "LSID metadata for each service as a boolean value in the RDF tag"
+ + newline
+ + " \"isAlive\", which may be used by client software to filter-out"
+ + newline
+ + " non-functional services."
+ + newline);
+
+ Map map = getResultMap();
+
+ for (Iterator it = map.keySet().iterator(); it.hasNext();) {
+ String key = (String) it.next();
+ Map list = (Map) map.get(key);
+ // dive into this authoritys' services
+ boolean firstTime = true;
+ for (Iterator listIt = list.keySet().iterator(); listIt.hasNext();) {
+ String servicename = (String) listIt.next();
+ Boolean contents = (Boolean) list.get(servicename);
+ if (!contents.booleanValue()) {
+ // found a bad one
+ if (firstTime) {
+ firstTime = false;
+ sb.append(newline + newline + "\t" + key + newline + "\t\t" + servicename);
+ } else {
+ sb.append(newline + "\t\t" + servicename);
+ }
+ }
+ }
+ }
+ return Utils.format(sb.toString(), 2);
}
public String getServiceInformationByAuthority(String authority) {
@@ -315,8 +450,7 @@
try {
output = doCall(s.getName(),
new Object[] { "<moby:MOBY xmlns:moby=\"http://www.biomoby.org/moby\">"
- + "" + " <moby:mobyContent>" + ""
- + " </moby:mobyContent>" + ""
+ + "" + " <moby:mobyContent>" + "" + " </moby:mobyContent>" + ""
+ "</moby:MOBY>" + "" }, impl.getRegistryEndpoint());
// log.info(output);
} catch (MobyException e) {
@@ -356,4 +490,5 @@
public void setNumThreads(int numThreads) {
this.numThreads = numThreads;
}
+
}
More information about the MOBY-guts
mailing list