JAVA_LIBDIR = .lib
JAVAC=javac -J-Xmx256m
JAVA=java -Xmx256m
-JAVA_LIBS = .:$(JAVA_LIBDIR):ext/json-jdk1.5-2007-05-01.jar:ext/wstx-asl-3.2.1.jar:ext/stax-api-1.0.1.jar:ext/java_memcached-release_1.5.1.jar
+JAVA_LIBS = .:$(JAVA_LIBDIR):ext/json-jdk1.5-2007-05-01.jar:ext/wstx-lgpl-3.2.1.jar:ext/stax-api-1.0.1.jar:ext/java_memcached-release_1.5.1.jar
JAVA_SRC = \
org/opensrf/net/xmpp/*.java \
org/opensrf/util/*.java \
"<iq id='123' type='set'><query xmlns='jabber:iq:auth'>" +
"<username>%s</username><password>%s</password><resource>%s</resource></query></iq>";
+ public static final String JABBER_DISCONNECT = "</stream:stream>";
+
/** jabber domain */
private String host;
/** jabber port */
PrintWriter writer;
/** Raw socket output stream */
OutputStream outStream;
+ /** The raw socket */
+ Socket socket;
/** The process-wide session. All communication occurs
* accross this single connection */
this.password = password;
this.resource = resource;
- Socket socket;
-
try {
/* open the socket and associated streams */
socket = new Socket(host, port);
return null;
}
+
+
+ /**
+ * Disconnects from the jabber server and closes the socket
+ */
+ public void disconnect() {
+ try {
+ outStream.write(JABBER_DISCONNECT.getBytes());
+ socket.close();
+ } catch(Exception e) {}
+ }
}
--- /dev/null
+package org.opensrf.test;
+import org.opensrf.*;
+import org.opensrf.util.*;
+import java.util.Date;
+import java.util.List;
+import java.util.ArrayList;
+import java.io.PrintStream;
+
+
+public class MathBench {
+
+ public static void main(String args[]) throws Exception {
+
+ PrintStream out = System.out;
+ if(args.length < 2) {
+ out.println("usage: java org.opensrf.test.MathBench <osrfConfig> <numIterations>");
+ return;
+ }
+
+ Sys.bootstrapClient(args[0], "/config/opensrf");
+ int count = Integer.parseInt(args[1]);
+
+ ClientSession session = new ClientSession("opensrf.math");
+ List<Object> params = new ArrayList<Object>();
+ params.add(new Integer(1));
+ params.add(new Integer(2));
+
+ Request request;
+ Result result;
+ long start;
+ double total = 0;
+
+ for(int i = 0; i < count; i++) {
+
+ start = new Date().getTime();
+ request = session.request("add", params);
+ result = request.recv(5000);
+ total += new Date().getTime() - start;
+
+ if(result.getStatusCode() == Status.OK) {
+ out.print("+");
+ } else {
+ out.println("\nrequest failed");
+ out.println("status = " + result.getStatus());
+ out.println("status code = " + result.getStatusCode());
+ }
+
+ request.cleanup();
+
+ if((i+1) % 100 == 0) /* print 100 per line */
+ out.println("");
+ }
+
+ out.println("\nAverage request time is " + (total/count) + " ms");
+ Sys.shutdown();
+ }
+}
+
+
+