Package org.hornetq.core.persistence.impl.journal

Examples of org.hornetq.core.persistence.impl.journal.OperationContextImpl


               while (running.get())
               {
                  final long[] values = new long[100];
                  long tx = seqGenerator.incrementAndGet();

                  OperationContextImpl ctx = new OperationContextImpl(executor);
                  storage.setContext(ctx);

                  for (int i = 0; i < 100; i++)
                  {
                     long id = seqGenerator.incrementAndGet();
                     values[i] = id;

                     ServerMessageImpl message = new ServerMessageImpl(id, 100);

                     message.getBodyBuffer().writeBytes(new byte[1024]);

                     storage.storeMessageTransactional(tx, message);
                  }
                  ServerMessageImpl message = new ServerMessageImpl(seqGenerator.incrementAndGet(), 100);
                 
                  survivingMsgs.add(message.getMessageID());
                 
                  // This one will stay here forever
                  storage.storeMessage(message);

                  storage.commit(tx);

                  ctx.executeOnCompletion(new IOAsyncTask()
                  {
                     public void onError(int errorCode, String errorMessage)
                     {
                     }
View Full Code Here


      ExecutorService executor = Executors.newSingleThreadExecutor();
      executor.shutdown();

      final CountDownLatch latch = new CountDownLatch(1);

      final OperationContextImpl impl = new OperationContextImpl(executor)
      {
         @Override
         public void complete()
         {
            super.complete();
            latch.countDown();
         }

      };

      impl.storeLineUp();

      final AtomicInteger numberOfFailures = new AtomicInteger(0);

      Thread t = new Thread()
      {
         @Override
         public void run()
         {
            try
            {
               impl.waitCompletion(5000);
            }
            catch (Throwable e)
            {
               e.printStackTrace();
               numberOfFailures.incrementAndGet();
            }
         }
      };

      t.start();

      // Need to wait complete to be called first or the test would be invalid.
      // We use a latch instead of forcing a sleep here
      Assert.assertTrue(latch.await(5, TimeUnit.SECONDS));

      impl.done();

      t.join();

      Assert.assertEquals(1, numberOfFailures.get());
   }
View Full Code Here

   {
      ExecutorService executor = Executors.newSingleThreadExecutor();

      final CountDownLatch latch = new CountDownLatch(1);

      final OperationContextImpl context = new OperationContextImpl(executor)
      {
         @Override
         public void complete()
         {
            super.complete();
            latch.countDown();
         }

      };

      context.storeLineUp();

      final AtomicInteger failures = new AtomicInteger(0);

      Thread t = new Thread()
      {
         @Override
         public void run()
         {
            try
            {
               context.waitCompletion(5000);
            }
            catch (Throwable e)
            {
               e.printStackTrace();
               failures.incrementAndGet();
            }
         }
      };

      t.start();

      // Need to wait complete to be called first or the test would be invalid.
      // We use a latch instead of forcing a sleep here
      Assert.assertTrue(latch.await(5, TimeUnit.SECONDS));

      context.onError(1, "Poop happens!");

      t.join();

      Assert.assertEquals(1, failures.get());

      failures.set(0);

      final AtomicInteger operations = new AtomicInteger(0);

      // We should be up to date with lineUps and executions. this should now just finish processing
      context.executeOnCompletion(new IOAsyncTask()
      {

         public void done()
         {
            operations.incrementAndGet();
View Full Code Here

               while (running.get())
               {
                  final long[] values = new long[100];
                  long tx = seqGenerator.incrementAndGet();

                  OperationContextImpl ctx = new OperationContextImpl(executor);
                  storage.setContext(ctx);

                  for (int i = 0; i < 100; i++)
                  {
                     long id = seqGenerator.incrementAndGet();
                     values[i] = id;

                     ServerMessageImpl message = new ServerMessageImpl(id, 100);

                     message.getBodyBuffer().writeBytes(new byte[1024]);

                     storage.storeMessageTransactional(tx, message);
                  }
                  ServerMessageImpl message = new ServerMessageImpl(seqGenerator.incrementAndGet(), 100);
                 
                  survivingMsgs.add(message.getMessageID());
                 
                  // This one will stay here forever
                  storage.storeMessage(message);

                  storage.commit(tx);

                  ctx.executeOnCompletion(new IOAsyncTask()
                  {
                     public void onError(int errorCode, String errorMessage)
                     {
                     }
View Full Code Here

   public void testCompleteTaskAfterPaging() throws Exception
   {
      ExecutorService executor = Executors.newSingleThreadExecutor();
      try
      {
         OperationContextImpl impl = new OperationContextImpl(executor);
         final CountDownLatch latch1 = new CountDownLatch(1);
         final CountDownLatch latch2 = new CountDownLatch(1);
        
         impl.executeOnCompletion(new IOAsyncTask()
         {
           
            public void onError(int errorCode, String errorMessage)
            {
            }
           
            public void done()
            {
               latch1.countDown();
            }
         });
        
         assertTrue(latch1.await(10, TimeUnit.SECONDS));
        
         for (int i = 0 ; i < 10; i++) impl.storeLineUp();
         for (int i = 0 ; i < 3; i++) impl.pageSyncLineUp();

         impl.executeOnCompletion(new IOAsyncTask()
         {
           
            public void onError(int errorCode, String errorMessage)
            {
            }
           
            public void done()
            {
               latch2.countDown();
            }
         });
        
        
         assertFalse(latch2.await(1, TimeUnit.MILLISECONDS));
        
         for (int i = 0 ; i < 9; i++) impl.done();
         for (int i = 0 ; i < 2; i++) impl.pageSyncDone();
        
        
         assertFalse(latch2.await(1, TimeUnit.MILLISECONDS));
        
         impl.done();
         impl.pageSyncDone();
        
         assertTrue(latch2.await(10, TimeUnit.SECONDS));
        
      }
      finally
View Full Code Here

      ExecutorService executor = Executors.newSingleThreadExecutor();
      executor.shutdown();

      final CountDownLatch latch = new CountDownLatch(1);

      final OperationContextImpl impl = new OperationContextImpl(executor)
      {
         @Override
         public void complete()
         {
            super.complete();
            latch.countDown();
         }

      };

      impl.storeLineUp();

      final AtomicInteger numberOfFailures = new AtomicInteger(0);

      Thread t = new Thread()
      {
         @Override
         public void run()
         {
            try
            {
               impl.waitCompletion(5000);
            }
            catch (Throwable e)
            {
               e.printStackTrace();
               numberOfFailures.incrementAndGet();
            }
         }
      };

      t.start();

      // Need to wait complete to be called first or the test would be invalid.
      // We use a latch instead of forcing a sleep here
      Assert.assertTrue(latch.await(5, TimeUnit.SECONDS));

      impl.done();

      t.join();

      Assert.assertEquals(1, numberOfFailures.get());
   }
View Full Code Here

   {
      ExecutorService executor = Executors.newSingleThreadExecutor();

      final CountDownLatch latch = new CountDownLatch(1);

      final OperationContextImpl context = new OperationContextImpl(executor)
      {
         @Override
         public void complete()
         {
            super.complete();
            latch.countDown();
         }

      };

      context.storeLineUp();

      final AtomicInteger failures = new AtomicInteger(0);

      Thread t = new Thread()
      {
         @Override
         public void run()
         {
            try
            {
               context.waitCompletion(5000);
            }
            catch (Throwable e)
            {
               e.printStackTrace();
               failures.incrementAndGet();
            }
         }
      };

      t.start();

      // Need to wait complete to be called first or the test would be invalid.
      // We use a latch instead of forcing a sleep here
      Assert.assertTrue(latch.await(5, TimeUnit.SECONDS));

      context.onError(1, "Poop happens!");

      t.join();

      Assert.assertEquals(1, failures.get());

      failures.set(0);

      final AtomicInteger operations = new AtomicInteger(0);

      // We should be up to date with lineUps and executions. this should now just finish processing
      context.executeOnCompletion(new IOAsyncTask()
      {

         public void done()
         {
            operations.incrementAndGet();
View Full Code Here

   public void testCompleteTaskAfterPaging() throws Exception
   {
      ExecutorService executor = Executors.newSingleThreadExecutor();
      try
      {
         OperationContextImpl impl = new OperationContextImpl(executor);
         final CountDownLatch latch1 = new CountDownLatch(1);
         final CountDownLatch latch2 = new CountDownLatch(1);

         impl.executeOnCompletion(new IOAsyncTask()
         {

            public void onError(int errorCode, String errorMessage)
            {
            }

            public void done()
            {
               latch1.countDown();
            }
         });

         assertTrue(latch1.await(10, TimeUnit.SECONDS));

         for (int i = 0 ; i < 10; i++) impl.storeLineUp();
         for (int i = 0 ; i < 3; i++) impl.pageSyncLineUp();

         impl.executeOnCompletion(new IOAsyncTask()
         {

            public void onError(int errorCode, String errorMessage)
            {
            }

            public void done()
            {
               latch2.countDown();
            }
         });


         assertFalse(latch2.await(1, TimeUnit.MILLISECONDS));

         for (int i = 0 ; i < 9; i++) impl.done();
         for (int i = 0 ; i < 2; i++) impl.pageSyncDone();


         assertFalse(latch2.await(1, TimeUnit.MILLISECONDS));

         impl.done();
         impl.pageSyncDone();

         assertTrue(latch2.await(10, TimeUnit.SECONDS));

      }
      finally
View Full Code Here

      ExecutorService executor = Executors.newSingleThreadExecutor();
      executor.shutdown();

      final CountDownLatch latch = new CountDownLatch(1);

      final OperationContextImpl impl = new OperationContextImpl(executor)
      {
         @Override
         public void complete()
         {
            super.complete();
            latch.countDown();
         }

      };

      impl.storeLineUp();

      final AtomicInteger numberOfFailures = new AtomicInteger(0);

      Thread t = new Thread()
      {
         @Override
         public void run()
         {
            try
            {
               impl.waitCompletion(5000);
            }
            catch (Throwable e)
            {
               e.printStackTrace();
               numberOfFailures.incrementAndGet();
            }
         }
      };

      t.start();

      // Need to wait complete to be called first or the test would be invalid.
      // We use a latch instead of forcing a sleep here
      Assert.assertTrue(latch.await(5, TimeUnit.SECONDS));

      impl.done();

      t.join();

      Assert.assertEquals(1, numberOfFailures.get());
   }
View Full Code Here

   {
      ExecutorService executor = Executors.newSingleThreadExecutor();

      final CountDownLatch latch = new CountDownLatch(1);

      final OperationContextImpl context = new OperationContextImpl(executor)
      {
         @Override
         public void complete()
         {
            super.complete();
            latch.countDown();
         }

      };

      context.storeLineUp();

      final AtomicInteger failures = new AtomicInteger(0);

      Thread t = new Thread()
      {
         @Override
         public void run()
         {
            try
            {
               context.waitCompletion(5000);
            }
            catch (Throwable e)
            {
               e.printStackTrace();
               failures.incrementAndGet();
            }
         }
      };

      t.start();

      // Need to wait complete to be called first or the test would be invalid.
      // We use a latch instead of forcing a sleep here
      Assert.assertTrue(latch.await(5, TimeUnit.SECONDS));

      context.onError(1, "Poop happens!");

      t.join();

      Assert.assertEquals(1, failures.get());

      failures.set(0);

      final AtomicInteger operations = new AtomicInteger(0);

      // We should be up to date with lineUps and executions. this should now just finish processing
      context.executeOnCompletion(new IOAsyncTask()
      {

         public void done()
         {
            operations.incrementAndGet();
View Full Code Here

TOP

Related Classes of org.hornetq.core.persistence.impl.journal.OperationContextImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.