[jboss-cvs] JBoss Messaging SVN: r3739 - projects/jaio/trunk/jaio/java/tests/org/jboss/jaio/libaioimpl/test.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Feb 19 23:04:47 EST 2008


Author: clebert.suconic at jboss.com
Date: 2008-02-19 23:04:46 -0500 (Tue, 19 Feb 2008)
New Revision: 3739

Modified:
   projects/jaio/trunk/jaio/java/tests/org/jboss/jaio/libaioimpl/test/TestController.java
Log:
Added async test

Modified: projects/jaio/trunk/jaio/java/tests/org/jboss/jaio/libaioimpl/test/TestController.java
===================================================================
--- projects/jaio/trunk/jaio/java/tests/org/jboss/jaio/libaioimpl/test/TestController.java	2008-02-20 02:08:12 UTC (rev 3738)
+++ projects/jaio/trunk/jaio/java/tests/org/jboss/jaio/libaioimpl/test/TestController.java	2008-02-20 04:04:46 UTC (rev 3739)
@@ -23,8 +23,8 @@
     {
         super.setUp();
         LocalAIO.staticDone = 0;
-        //File file = new File(FILE_NAME);
-        //file.delete();
+        File file = new File(FILE_NAME);
+        file.delete();
     }
 
     public void aatestOpen()throws Exception
@@ -54,7 +54,7 @@
         
     }
     
-    public void testDirectDataNoPage() throws Exception
+    public void testAddAsyncData() throws Exception
     {
         try
         {
@@ -90,11 +90,11 @@
             int counter = 0;
             for (LocalAIO tmp: list)
             {
-                if (SIZE > 1024*1024) System.out.println("adding"); System.out.flush(); // deleteme
+                if (SIZE > 1024*1024) System.out.println("adding"); System.out.flush();
                 controller.append(tmp);
                 if (++counter % 500 == 0)
                 {
-                    System.out.println(500*1000/(System.currentTimeMillis()-lastTime) + " rec/sec");
+                    System.out.println(500*1000/(System.currentTimeMillis()-lastTime) + " rec/sec (Async)");
                     lastTime = System.currentTimeMillis();
                 }
                 
@@ -110,13 +110,13 @@
     
             long timeTotal = System.currentTimeMillis() - valueInitial;
             System.out.println("Flushed " + timeTotal);
-            System.out.println("time = " + timeTotal + " for " + NUMBER_LINES + " registers " + " size each line = " + SIZE  + " Records/Sec=" + (NUMBER_LINES*1000/timeTotal));
+            System.out.println("time = " + timeTotal + " for " + NUMBER_LINES + " registers " + " size each line = " + SIZE  + " Records/Sec=" + (NUMBER_LINES*1000/timeTotal) + " (Assynchronous)");
     
             for (LocalAIO tmp: list)
             {
                 assertEquals(1, tmp.timesDoneCalled);
-                //assertTrue(tmp.encodeCalled);
-                //assertTrue(tmp.encodeSizeCalled);
+                assertTrue(tmp.encodeCalled);
+                assertTrue(tmp.encodeSizeCalled);
                 assertTrue(tmp.doneCalled);
             }
             
@@ -130,6 +130,66 @@
         
     }
     
+    public void testDirectSynchronous() throws Exception
+    {
+        try
+        {
+            System.out.println("++testDirectDataNoPage"); System.out.flush();
+            final int NUMBER_LINES = 100000; 
+            final int SIZE = 1024;
+            //final int SIZE = 512;
+            
+            final LibAIOController controller = new LibAIOController();
+            controller.open(FILE_NAME);
+            
+            long startPreAllocate = System.currentTimeMillis();
+            controller.preAllocate(1, NUMBER_LINES * SIZE);
+            long endPreAllocate = System.currentTimeMillis() - startPreAllocate;
+            if (endPreAllocate != 0) System.out.println("PreAllocated the file in " + endPreAllocate + " seconds, What means " + ((100 * 1024*1024)/endPreAllocate) + " bytes per millisecond");
+
+            long valueInitial = System.currentTimeMillis();
+            int counterFile=0;
+    
+            System.out.println("Adding data");
+            
+            long lastTime = System.currentTimeMillis();
+            int counter = 0;
+            
+            for (int i=0; i<NUMBER_LINES; i++)
+            {
+                CountDownLatch latchDone = new CountDownLatch(1);
+                LocalAIO aioBlock = new LocalAIO(SIZE, latchDone);
+                controller.append(aioBlock);
+                latchDone.await();
+                assertTrue(aioBlock.doneCalled);
+                assertTrue(aioBlock.encodeCalled);
+                if (++counter % 500 == 0)
+                {
+                    System.out.println(500*1000/(System.currentTimeMillis()-lastTime) + " rec/sec (Synchronous)");
+                    lastTime = System.currentTimeMillis();
+                }
+            }
+
+            System.out.println("Data added " + (System.currentTimeMillis() - valueInitial));
+            
+            
+            System.out.println("Finished append " + (System.currentTimeMillis() - valueInitial) + " received = " + LocalAIO.staticDone);
+            System.out.println("Flush now");
+            System.out.println("Received " + LocalAIO.staticDone);
+    
+            long timeTotal = System.currentTimeMillis() - valueInitial;
+            System.out.println("Flushed " + timeTotal);
+            System.out.println("time = " + timeTotal + " for " + NUMBER_LINES + " registers " + " size each line = " + SIZE  + " Records/Sec=" + (NUMBER_LINES*1000/timeTotal) + " Synchronous");
+    
+            controller.close();
+        }
+        catch (Exception e)
+        {
+            System.out.println("Received " + LocalAIO.staticDone + " before it failed");
+        }
+        
+    }
+    
     public void aatestPage() throws Exception
     {
         LibAIOController controller = new LibAIOController();
@@ -179,13 +239,13 @@
         public void done()
         {
             //System.out.println("Received Done"); System.out.flush();
+            doneCalled = true;
+            timesDoneCalled++;
+            staticDone++;
             if (latch != null) 
             {
                 latch.countDown();
             }
-            doneCalled = true;
-            timesDoneCalled++;
-            staticDone++;
             
         }
 




More information about the jboss-cvs-commits mailing list