commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hamm...@apache.org
Subject cvs commit: jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/test SocketClientTest.java SocketServerTest.java TestClient.java
Date Thu, 17 Jan 2002 17:48:46 GMT
hammant     02/01/17 09:48:46

  Modified:    altrmi/src/java/org/apache/commons/altrmi/client/impl
                        ClientCustomStreamReadWriter.java
                        ClientObjectStreamReadWriter.java
                        ClientStreamReadWriter.java
                        StreamInvocationHandler.java
               altrmi/src/java/org/apache/commons/altrmi/client/impl/socket
                        AbstractSocketStreamInvocationHandler.java
               altrmi/src/java/org/apache/commons/altrmi/server/impl
                        AbstractServer.java
                        ServerCustomStreamReadWriter.java
                        ServerObjectStreamReadWriter.java
                        ServerStreamReadWriter.java
                        StreamServerConnection.java
               altrmi/src/java/org/apache/commons/altrmi/test
                        SocketClientTest.java SocketServerTest.java
                        TestClient.java
  Log:
  custom transport now working
  
  Revision  Changes    Path
  1.3       +23 -19    jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/impl/ClientCustomStreamReadWriter.java
  
  Index: ClientCustomStreamReadWriter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/impl/ClientCustomStreamReadWriter.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ClientCustomStreamReadWriter.java	17 Jan 2002 12:14:28 -0000	1.2
  +++ ClientCustomStreamReadWriter.java	17 Jan 2002 17:48:45 -0000	1.3
  @@ -29,12 +29,10 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.2 $
  + * @version $Revision: 1.3 $
    */
   public class ClientCustomStreamReadWriter extends ClientStreamReadWriter {
   
  -    private ByteArrayOutputStream mBAOS = new ByteArrayOutputStream();
  -    private ObjectOutputStream mObjectOutputStream;
       private DataInputStream mDataInputStream;
       private DataOutputStream mDataOutputStream;
   
  @@ -50,34 +48,40 @@
        */
       public ClientCustomStreamReadWriter(InputStream inputStream, OutputStream outputStream)
               throws IOException {
  -
           mDataOutputStream = new DataOutputStream(outputStream);
           mDataInputStream = new DataInputStream(inputStream);
  -        mObjectOutputStream = new ObjectOutputStream(mBAOS);
       }
   
  -    protected void writeRequest(AltrmiRequest altrmiRequest) throws IOException {
  +    protected synchronized AltrmiReply postRequest(AltrmiRequest altrmiRequest)
  +            throws IOException, ClassNotFoundException {
  +
  +        writeRequest(altrmiRequest);
  +
  +        return readReply();
  +    }
  +
  +    private void writeRequest(AltrmiRequest altrmiRequest) throws IOException {
   
  -        mObjectOutputStream.writeObject(altrmiRequest);
  -        mObjectOutputStream.flush();
  +        ByteArrayOutputStream bAOS = new ByteArrayOutputStream();
  +        ObjectOutputStream objectOutputStream;
   
  -        byte[] aBytes = mBAOS.toByteArray();
  +        objectOutputStream = new ObjectOutputStream(bAOS);
   
  -        mObjectOutputStream.reset();
  -        System.out.println("CLT Writing " + aBytes.length);
  -        System.out.flush();
  -        mDataOutputStream.write(aBytes.length);
  +        objectOutputStream.writeObject(altrmiRequest);
  +        objectOutputStream.flush();
  +
  +        byte[] aBytes = bAOS.toByteArray();
  +
  +        objectOutputStream.close();
  +        bAOS.close();
  +        mDataOutputStream.writeInt(aBytes.length);
           mDataOutputStream.write(aBytes);
           mDataOutputStream.flush();
       }
   
  -    protected AltrmiReply readReply() throws IOException, ClassNotFoundException {
  -
  -        int byteArraySize = mDataInputStream.readInt();
  -
  -        System.out.println("CLT Reading " + byteArraySize);
  -        System.out.flush();
  +    private AltrmiReply readReply() throws IOException, ClassNotFoundException {
   
  +        int byteArraySize = (int) mDataInputStream.readInt();
           byte[] byteArray = new byte[byteArraySize];
   
           mDataInputStream.read(byteArray);
  
  
  
  1.3       +10 -4     jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/impl/ClientObjectStreamReadWriter.java
  
  Index: ClientObjectStreamReadWriter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/impl/ClientObjectStreamReadWriter.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ClientObjectStreamReadWriter.java	17 Jan 2002 12:14:28 -0000	1.2
  +++ ClientObjectStreamReadWriter.java	17 Jan 2002 17:48:45 -0000	1.3
  @@ -25,7 +25,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.2 $
  + * @version $Revision: 1.3 $
    */
   public class ClientObjectStreamReadWriter extends ClientStreamReadWriter {
   
  @@ -44,13 +44,19 @@
        */
       public ClientObjectStreamReadWriter(InputStream inputStream, OutputStream outputStream)
               throws IOException {
  -
           mObjectOutputStream = new ObjectOutputStream(outputStream);
           mObjectInputStream = new ObjectInputStream(inputStream);
  +    }
  +
  +    protected synchronized AltrmiReply postRequest(AltrmiRequest altrmiRequest)
  +            throws IOException, ClassNotFoundException {
  +
  +        writeRequest(altrmiRequest);
   
  +        return readReply();
       }
   
  -    protected void writeRequest(AltrmiRequest altrmiRequest) throws IOException {
  +    private void writeRequest(AltrmiRequest altrmiRequest) throws IOException {
   
           mObjectOutputStream.writeObject(altrmiRequest);
           mObjectOutputStream.flush();
  @@ -58,7 +64,7 @@
           //mObjectOutputStream.reset();
       }
   
  -    protected AltrmiReply readReply() throws IOException, ClassNotFoundException {
  +    private AltrmiReply readReply() throws IOException, ClassNotFoundException {
           return (AltrmiReply) mObjectInputStream.readObject();
       }
   }
  
  
  
  1.2       +3 -5      jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/impl/ClientStreamReadWriter.java
  
  Index: ClientStreamReadWriter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/impl/ClientStreamReadWriter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ClientStreamReadWriter.java	17 Jan 2002 12:14:28 -0000	1.1
  +++ ClientStreamReadWriter.java	17 Jan 2002 17:48:45 -0000	1.2
  @@ -23,11 +23,9 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
    */
   public abstract class ClientStreamReadWriter {
  -
  -    protected abstract void writeRequest(AltrmiRequest altrmiRequest) throws IOException;
  -
  -    protected abstract AltrmiReply readReply() throws IOException, ClassNotFoundException;
  +    protected abstract AltrmiReply postRequest(AltrmiRequest altrmiRequest)
  +        throws IOException, ClassNotFoundException;
   }
  
  
  
  1.3       +2 -4      jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/impl/StreamInvocationHandler.java
  
  Index: StreamInvocationHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/impl/StreamInvocationHandler.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- StreamInvocationHandler.java	17 Jan 2002 12:14:28 -0000	1.2
  +++ StreamInvocationHandler.java	17 Jan 2002 17:48:45 -0000	1.3
  @@ -36,7 +36,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.2 $
  + * @version $Revision: 1.3 $
    */
   public abstract class StreamInvocationHandler extends AltrmiClientInvocationHandler {
   
  @@ -93,9 +93,7 @@
                       try {
                           long t1 = System.currentTimeMillis();
   
  -                        mObjectReadWriter.writeRequest(request);
  -
  -                        reply = (AltrmiReply) mObjectReadWriter.readReply();
  +                        reply = (AltrmiReply) mObjectReadWriter.postRequest(request);
   
                           long t2 = System.currentTimeMillis();
   
  
  
  
  1.3       +1 -3      jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/impl/socket/AbstractSocketStreamInvocationHandler.java
  
  Index: AbstractSocketStreamInvocationHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/impl/socket/AbstractSocketStreamInvocationHandler.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AbstractSocketStreamInvocationHandler.java	17 Jan 2002 12:14:29 -0000	1.2
  +++ AbstractSocketStreamInvocationHandler.java	17 Jan 2002 17:48:46 -0000	1.3
  @@ -30,7 +30,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.2 $
  + * @version $Revision: 1.3 $
    */
   public abstract class AbstractSocketStreamInvocationHandler extends StreamInvocationHandler
{
   
  @@ -75,8 +75,6 @@
   
           try {
               Socket socket = new Socket(mHost, mPort);
  -            ObjectOutputStream oOS = new ObjectOutputStream(socket.getOutputStream());
  -            ObjectInputStream oIS = new ObjectInputStream(socket.getInputStream());
   
               setObjectReadWriter(new ClientObjectStreamReadWriter(socket.getInputStream(),
                                                                    socket.getOutputStream()));
  
  
  
  1.7       +1 -5      jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/AbstractServer.java
  
  Index: AbstractServer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/AbstractServer.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- AbstractServer.java	17 Jan 2002 12:14:29 -0000	1.6
  +++ AbstractServer.java	17 Jan 2002 17:48:46 -0000	1.7
  @@ -53,7 +53,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.6 $
  + * @version $Revision: 1.7 $
    */
   public abstract class AbstractServer extends AbstractMethodHandler implements AltrmiServer
{
   
  @@ -282,8 +282,6 @@
               String publishedThing = mr.getPublishedServiceName() + "_" + mr.getObjectName();
   
               if (!mPublishedObjects.containsKey(publishedThing)) {
  -                System.out.flush();
  -
                   return new NotPublishedReply();
               }
   
  @@ -296,8 +294,6 @@
               String publishedThing = mr.getPublishedServiceName() + "_" + mr.getObjectName();
   
               if (!mPublishedObjects.containsKey(publishedThing)) {
  -                System.out.flush();
  -
                   return new NotPublishedReply();
               }
   
  
  
  
  1.3       +24 -23    jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/ServerCustomStreamReadWriter.java
  
  Index: ServerCustomStreamReadWriter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/ServerCustomStreamReadWriter.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ServerCustomStreamReadWriter.java	17 Jan 2002 12:14:29 -0000	1.2
  +++ ServerCustomStreamReadWriter.java	17 Jan 2002 17:48:46 -0000	1.3
  @@ -29,55 +29,56 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.2 $
  + * @version $Revision: 1.3 $
    */
   public class ServerCustomStreamReadWriter extends ServerStreamReadWriter {
   
  -    private ByteArrayOutputStream mBAOS = new ByteArrayOutputStream();
  -    private ObjectOutputStream mObjectOutputStream;
       private DataInputStream mDataInputStream;
       private DataOutputStream mDataOutputStream;
   
       protected void initialize() throws IOException {
  -
           mDataInputStream = new DataInputStream(mInputStream);
           mDataOutputStream = new DataOutputStream(mOutputStream);
  -        mObjectOutputStream = new ObjectOutputStream(mBAOS);
       }
   
  -    protected void writeReply(AltrmiReply altrmiReply) throws IOException {
  -
  -        mObjectOutputStream.writeObject(altrmiReply);
  -        mObjectOutputStream.flush();
  +    protected synchronized AltrmiRequest writeReplyAndGetRequest(AltrmiReply altrmiReply)
  +            throws IOException, ClassNotFoundException {
   
  -        byte[] aBytes = mBAOS.toByteArray();
  +        if (altrmiReply != null) {
  +            writeReply(altrmiReply);
  +        }
   
  -        mObjectOutputStream.reset();
  -        System.out.println("SVR Writing " + aBytes.length);
  -        System.out.flush();
  -        mDataOutputStream.write(aBytes.length);
  -        mDataOutputStream.write(aBytes);
  -        mDataOutputStream.flush();
  +        return readRequest();
       }
   
  -    protected AltrmiRequest readRequest() throws IOException, ClassNotFoundException {
  +    private void writeReply(AltrmiReply altrmiReply) throws IOException {
   
  -        int byteArraySize = mDataInputStream.readInt();
  +        ByteArrayOutputStream bAOS = new ByteArrayOutputStream();
  +        ObjectOutputStream objectOutputStream;
   
  -        System.out.println("SVR Reading1 " + byteArraySize);
  +        objectOutputStream = new ObjectOutputStream(bAOS);
   
  -        int byteArraySize2 = mDataInputStream.readInt();
  +        objectOutputStream.writeObject(altrmiReply);
  +        objectOutputStream.flush();
   
  -        System.out.println("SVR Reading2 " + byteArraySize2);
  -        System.out.flush();
  +        byte[] aBytes = bAOS.toByteArray();
   
  +        mDataOutputStream.writeInt(aBytes.length);
  +        mDataOutputStream.write(aBytes);
  +        mDataOutputStream.flush();
  +    }
  +
  +    private AltrmiRequest readRequest() throws IOException, ClassNotFoundException {
  +
  +        int byteArraySize = mDataInputStream.readInt();
           byte[] byteArray = new byte[byteArraySize];
   
           mDataInputStream.read(byteArray);
   
           ByteArrayInputStream bAIS = new ByteArrayInputStream(byteArray);
           ObjectInputStream oOs = new ObjectInputStream(bAIS);
  +        AltrmiRequest ar = (AltrmiRequest) oOs.readObject();
   
  -        return (AltrmiRequest) oOs.readObject();
  +        return ar;
       }
   }
  
  
  
  1.3       +10 -3     jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/ServerObjectStreamReadWriter.java
  
  Index: ServerObjectStreamReadWriter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/ServerObjectStreamReadWriter.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ServerObjectStreamReadWriter.java	17 Jan 2002 12:14:29 -0000	1.2
  +++ ServerObjectStreamReadWriter.java	17 Jan 2002 17:48:46 -0000	1.3
  @@ -25,7 +25,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.2 $
  + * @version $Revision: 1.3 $
    */
   public class ServerObjectStreamReadWriter extends ServerStreamReadWriter {
   
  @@ -37,7 +37,14 @@
           mObjectOutputStream = new ObjectOutputStream(mOutputStream);
       }
   
  -    protected void writeReply(AltrmiReply altrmiReply) throws IOException {
  +    protected synchronized AltrmiRequest writeReplyAndGetRequest(AltrmiReply altrmiReply)
throws IOException, ClassNotFoundException {
  +        if (altrmiReply != null) {
  +            writeReply(altrmiReply);
  +        }
  +        return readRequest();
  +    }
  +
  +    private void writeReply(AltrmiReply altrmiReply) throws IOException {
   
           mObjectOutputStream.writeObject(altrmiReply);
           mObjectOutputStream.flush();
  @@ -45,7 +52,7 @@
           //mObjectOutputStream.reset();
       }
   
  -    protected AltrmiRequest readRequest() throws IOException, ClassNotFoundException {
  +    private AltrmiRequest readRequest() throws IOException, ClassNotFoundException {
           return (AltrmiRequest) mObjectInputStream.readObject();
       }
   }
  
  
  
  1.2       +6 -6      jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/ServerStreamReadWriter.java
  
  Index: ServerStreamReadWriter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/ServerStreamReadWriter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ServerStreamReadWriter.java	17 Jan 2002 12:14:29 -0000	1.1
  +++ ServerStreamReadWriter.java	17 Jan 2002 17:48:46 -0000	1.2
  @@ -25,7 +25,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
    */
   public abstract class ServerStreamReadWriter {
   
  @@ -39,19 +39,19 @@
        * @param inputStream
        * @param outputStream
        *
  +     *
  +     * @throws ClassCastException
        * @throws IOException
        *
        */
       public final void setStreams(InputStream inputStream, OutputStream outputStream)
  -            throws IOException {
  -
  +            throws IOException, ClassCastException {
           mInputStream = inputStream;
           mOutputStream = outputStream;
       }
   
       protected abstract void initialize() throws IOException;
   
  -    protected abstract void writeReply(AltrmiReply altrmiReply) throws IOException;
  -
  -    protected abstract AltrmiRequest readRequest() throws IOException, ClassNotFoundException;
  +    protected abstract AltrmiRequest writeReplyAndGetRequest(AltrmiReply altrmiReply)
  +        throws IOException, ClassNotFoundException;
   }
  
  
  
  1.3       +8 -6      jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/StreamServerConnection.java
  
  Index: StreamServerConnection.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/StreamServerConnection.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- StreamServerConnection.java	17 Jan 2002 12:14:29 -0000	1.2
  +++ StreamServerConnection.java	17 Jan 2002 17:48:46 -0000	1.3
  @@ -30,7 +30,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.2 $
  + * @version $Revision: 1.3 $
    */
   public abstract class StreamServerConnection implements Runnable, AltrmiServerConnection
{
   
  @@ -65,20 +65,22 @@
               mReadWriter.initialize();
   
               boolean more = true;
  +            AltrmiRequest request = null;
  +            AltrmiReply reply = null;
   
               while (more) {
                   try {
  -                    AltrmiRequest request = mReadWriter.readRequest();
  -                    AltrmiReply reply = mAbstractServer.processRequest(request);
  +                    if (request != null) {
  +                        reply = mAbstractServer.processRequest(request);
  +                    }
   
  -                    mReadWriter.writeReply(reply);
  +                    request = mReadWriter.writeReplyAndGetRequest(reply);
   
                       // http://developer.java.sun.com/developer/bugParade/bugs/4499841.html
                       // halves the performance though.
                       //oOS.reset();
                       if (mEndConnection) {
  -                        mReadWriter.writeReply(new EndConnectionReply());
  -
  +                        reply = new EndConnectionReply();
                           more = false;
                       }
                   } catch (IOException ioe) {
  
  
  
  1.5       +7 -2      jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/test/SocketClientTest.java
  
  Index: SocketClientTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/test/SocketClientTest.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- SocketClientTest.java	17 Jan 2002 12:14:30 -0000	1.4
  +++ SocketClientTest.java	17 Jan 2002 17:48:46 -0000	1.5
  @@ -1,3 +1,4 @@
  +
   /*
    * Copyright (C) The Apache Software Foundation. All rights reserved.
    *
  @@ -25,7 +26,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.4 $
  + * @version $Revision: 1.5 $
    */
   public class SocketClientTest {
   
  @@ -43,13 +44,17 @@
           System.out.println("Stream over Socket Client");
   
           AltrmiHostContext arhc;
  +
           if (args[1].equals("ObjectStream")) {
               System.out.println("(Object Stream)");
  +
               arhc = new SocketObjectStreamHostContext("127.0.0.1", 1234);
           } else {
               System.out.println("(Custom Stream)");
  -            arhc = new SocketCustomStreamHostContext("127.0.0.1", 1234);
  +
  +            arhc = new SocketCustomStreamHostContext("127.0.0.1", 1235);
           }
  +
           AltrmiFactory af = null;
   
           if (args[0].equals("S")) {
  
  
  
  1.5       +8 -2      jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/test/SocketServerTest.java
  
  Index: SocketServerTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/test/SocketServerTest.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- SocketServerTest.java	17 Jan 2002 12:14:30 -0000	1.4
  +++ SocketServerTest.java	17 Jan 2002 17:48:46 -0000	1.5
  @@ -1,3 +1,4 @@
  +
   /*
    * Copyright (C) The Apache Software Foundation. All rights reserved.
    *
  @@ -22,7 +23,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.4 $
  + * @version $Revision: 1.5 $
    */
   public class SocketServerTest {
   
  @@ -43,15 +44,20 @@
   
           if (args[1].equals("ObjectStream")) {
               System.out.println("(Object Stream)");
  +
               as = new CompleteSocketObjectStreamServer(1234);
           } else {
  +
               // CustomStream
               System.out.println("(Custom Stream)");
  -            as = new CompleteSocketCustomStreamServer(1234);
  +
  +            as = new CompleteSocketCustomStreamServer(1235);
           }
  +
           if (args[0].equals("S")) {
               as.setClassRetriever(new BaseMobileClassRetriever());
           }
  +
           TestInterfaceImpl ti = new TestInterfaceImpl();
   
           as.publish(ti, "Hello", TestInterface.class, TestInterface2.class);
  
  
  
  1.4       +14 -13    jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/test/TestClient.java
  
  Index: TestClient.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/test/TestClient.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TestClient.java	16 Jan 2002 11:32:20 -0000	1.3
  +++ TestClient.java	17 Jan 2002 17:48:46 -0000	1.4
  @@ -23,7 +23,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.3 $
  + * @version $Revision: 1.4 $
    */
   public class TestClient {
   
  @@ -100,32 +100,33 @@
   
           }
   
  -
  -        System.out.println("CLT: Two timings about to start, please stand by...");
  +        System.out.println("CLT: Two timings about to start, please stand by... (10 seconds
each)");
           ti.testSpeed();    // to ignore for timing
   
           long start = System.currentTimeMillis();
  +        long projectedEnd = start + (10 * 1000);
  +
  +        // delays due to timing is negligible
   
  -        for (int i = 0; i < 100000; i++) {
  +        int ct = 0;
  +        while (System.currentTimeMillis() < projectedEnd) {
  +            ct ++;
               ti.testSpeed();
           }
   
  -        long end = System.currentTimeMillis();
  -
  -        System.out.println("CLT: Total time take for 100,000 simple calls (millis) = "
  -                           + (end - start));
  +        System.out.println("CLT: Number of simple calls in 10 seconds = " + ct);
   
           String rv = ti.testSpeed2("toIgnoreForTiming");
   
           start = System.currentTimeMillis();
  +        projectedEnd = start + (10 * 1000);
   
  -        for (int i = 0; i < 100000; i++) {
  +        ct = 0;
  +        while (System.currentTimeMillis() < projectedEnd) {
  +            ct ++;
               rv = ti.testSpeed2("qwerty");
           }
   
  -        end = System.currentTimeMillis();
  -
  -        System.out.println("CLT: Total time take for 100,000 retval/param calls (millis)
= "
  -                           + (end - start));
  +        System.out.println("CLT: Number of complex calls in 10 seconds = " + ct);
       }
   }
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message