[MOBY-guts] biomoby commit

Eddie Kawas kawas at dev.open-bio.org
Wed Oct 25 19:32:54 UTC 2006


kawas
Wed Oct 25 15:32:54 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-serv14113/Java/src/main/org/biomoby/client/ui/graphical/servlet/utilities

Modified Files:
	ServiceTester.java 
Added Files:
	ServiceTesterRunner.java RegistryContextListener.java 
Log Message:
made service testing code more modular and fixed a thread (cleanup) issue
moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/utilities ServiceTesterRunner.java,NONE,1.1 RegistryContextListener.java,NONE,1.1 ServiceTester.java,1.8,1.9
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/utilities/ServiceTester.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- /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
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/utilities/ServiceTester.java	2006/10/25 19:32:54	1.9
@@ -5,6 +5,7 @@
 import java.io.IOException;
 import java.text.DecimalFormat;
 import java.util.Collections;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
@@ -28,7 +29,9 @@
 
 public class ServiceTester {
 
-	private Central central = null;
+	private String url = null;
+
+	private String uri = null;
 
 	private Map results = null;
 
@@ -40,13 +43,19 @@
 	private Log log = LogFactory.getLog(this.getClass());
 
 	public ServiceTester() throws MobyException {
-		central = new CentralImpl();
+		// default here
+		this.url = CentralImpl.DEFAULT_ENDPOINT;
+		this.uri = CentralImpl.DEFAULT_NAMESPACE;
+
 		results = new TreeMap();
 	}
 
 	@SuppressWarnings("unchecked")
 	public ServiceTester(String url, String uri) throws MobyException {
-		central = new CentralImpl(url, uri);
+		// use default if necessary
+		this.url = url == null || url.trim().equals("") ? CentralImpl.DEFAULT_ENDPOINT : url;
+		this.uri = uri == null || uri.trim().equals("") ? CentralImpl.DEFAULT_NAMESPACE : uri;
+
 		results = Collections.synchronizedMap(new TreeMap());
 	}
 
@@ -55,9 +64,10 @@
 		MobyService template = new MobyService();
 
 		try {
+			Central central = new CentralImpl(url, uri);
 			services = central.findService(template);
 		} catch (MobyException e) {
-
+			log.error("Couldn't query Moby Central ..." + newline + Utils.format(e, 3));
 		}
 		if (services == null)
 			return new MobyService[] {};
@@ -245,63 +255,41 @@
 			if (DIRECTORY == null) {
 				try {
 					Context c = new InitialContext();
-					DIRECTORY = (String)c.lookup("java:comp/env/CACHE_PATH");
+					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
+			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
+				+ " 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);
-		
+				+ "\"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();) {
@@ -353,6 +341,7 @@
 				MobyService s = new MobyService(servicename);
 				s.setAuthority(authority);
 				try {
+					Central central = new CentralImpl(url, uri);
 					if (central.findService(s).length > 0)
 						return true;
 				} catch (MobyException e) {
@@ -365,6 +354,7 @@
 			MobyService s = new MobyService(servicename);
 			s.setAuthority(authority);
 			try {
+				Central central = new CentralImpl(url, uri);
 				if (central.findService(s).length > 0)
 					return true;
 			} catch (MobyException e) {
@@ -491,4 +481,19 @@
 		this.numThreads = numThreads;
 	}
 
+	public String toString() {
+		return "ServiceTester(" 
+				+ newline 
+				+ "\t\t" 
+				+ url 
+				+ "," 
+				+ newline 
+				+ "\t\t" 
+				+ uri 
+				+ ")"
+				+ newline 
+				+ " @ " 
+				+ new Date().toString();
+	}
+
 }




More information about the MOBY-guts mailing list