Package org.hornetq.core.persistence

Examples of org.hornetq.core.persistence.OperationContext


   private void sendReplicatePacket(final Packet packet, boolean lineUp)
   {
      boolean runItNow = false;

      OperationContext repliToken = OperationContextImpl.getContext(executorFactory);
      if (lineUp)
      {
         repliToken.replicationLineUp();
      }

      synchronized (replicationLock)
      {
         if (!enabled)
         {
            // Already replicating channel failed, so just play the action now

            runItNow = true;
         }
         else
         {
            pendingTokens.add(repliToken);

            replicatingChannel.send(packet);
         }
      }

      // Execute outside lock

      if (runItNow)
      {
         repliToken.replicationDone();
      }
   }
View Full Code Here


      }
   }

   private void replicated()
   {
      OperationContext ctx = pendingTokens.poll();

      if (ctx == null)
      {
         throw new IllegalStateException("Missing replication token on the queue.");
      }

      ctx.replicationDone();
   }
View Full Code Here

   /**
    *
    */
   protected void asyncAppendCommit()
   {
      final OperationContext ctx = storageManager.getContext();
      storageManager.afterCompleteOperations(new IOAsyncTask()
      {
         public void onError(int errorCode, String errorMessage)
         {
         }
        
         public void done()
         {
            OperationContext originalCtx = storageManager.getContext();
            try
            {
               storageManager.setContext(ctx);
               storageManager.commit(id, false);
            }
View Full Code Here

         server.createQueue(PagingTest.ADDRESS, PagingTest.ADDRESS, null, true, false);

         final CountDownLatch pageUp = new CountDownLatch(0);
         final CountDownLatch pageDone = new CountDownLatch(1);

         OperationContext ctx = new OperationContext()
         {

            public void onError(int errorCode, String errorMessage)
            {
            }
View Full Code Here

         server.createQueue(PagingTest.ADDRESS, PagingTest.ADDRESS, null, true, false);

         final CountDownLatch pageUp = new CountDownLatch(0);
         final CountDownLatch pageDone = new CountDownLatch(1);

         OperationContext ctx = new OperationContext()
         {

            public void onError(int errorCode, String errorMessage)
            {
            }
View Full Code Here

      if (securityStore != null)
      {
         securityStore.authenticate(username, password);
      }
      final OperationContext context = storageManager.newContext(getExecutorFactory().getExecutor());
      final ServerSessionImpl session = internalCreateSession(name, username, password, minLargeMessageSize, connection, autoCommitSends, autoCommitAcks, preAcknowledge, xa, defaultAddress, callback, context);

      sessions.put(name, session);

      return session;
View Full Code Here

      }
   }

   public void testExceptionSettingActionBefore() throws Exception
   {
      OperationContext ctx = OperationContextImpl.getContext(factory);

      ctx.storeLineUp();

      String msg = "I'm an exception";

      ctx.onError(5, msg);

      final AtomicInteger lastError = new AtomicInteger(0);

      final List<String> msgsResult = new ArrayList<String>();

      final CountDownLatch latch = new CountDownLatch(1);

      ctx.executeOnCompletion(new IOAsyncTask()
      {
         public void onError(final int errorCode, final String errorMessage)
         {
            lastError.set(errorCode);
            msgsResult.add(errorMessage);
            latch.countDown();
         }

         public void done()
         {
         }
      });

      Assert.assertTrue(latch.await(5, TimeUnit.SECONDS));

      Assert.assertEquals(5, lastError.get());

      Assert.assertEquals(1, msgsResult.size());

      Assert.assertEquals(msg, msgsResult.get(0));

      final CountDownLatch latch2 = new CountDownLatch(1);

      // Adding the Task after the exception should still throw an exception
      ctx.executeOnCompletion(new IOAsyncTask()
      {
         public void onError(final int errorCode, final String errorMessage)
         {
            lastError.set(errorCode);
            msgsResult.add(errorMessage);
            latch2.countDown();
         }

         public void done()
         {
         }
      });

      Assert.assertTrue(latch2.await(5, TimeUnit.SECONDS));

      Assert.assertEquals(2, msgsResult.size());

      Assert.assertEquals(msg, msgsResult.get(0));

      Assert.assertEquals(msg, msgsResult.get(1));

      final CountDownLatch latch3 = new CountDownLatch(1);

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

         int numberOfAdds = 200;

         final CountDownLatch latch = new CountDownLatch(numberOfAdds);

         OperationContext ctx = storage.getContext();

         for (int i = 0; i < numberOfAdds; i++)
         {
            final int nAdd = i;

            if (i % 2 == 0)
            {
               replicatedJournal.appendPrepareRecord(i, new FakeData(), false);
            }

            ctx.executeOnCompletion(new IOAsyncTask()
            {

               public void onError(final int errorCode, final String errorMessage)
               {
               }
View Full Code Here

      return name;
   }

   public Response propose(final Proposal proposal) throws Exception
   {
      OperationContext originalCtx = storageManager.getContext();

      try
      {
         // the waitCompletion cannot be done inside an ordered executor or we would starve when the thread pool is full
         storageManager.setContext(storageManager.newSingleThreadContext());
View Full Code Here

      // since sendLiveIsStoping my issue a close back from the channel
      // and we want to ensure a stop here just in case
      ReplicationManager replicatorInUse = replicator;
      if (replicatorInUse != null)
      {
         final OperationContext token = replicator.sendLiveIsStopping(LiveStopping.FAIL_OVER);
         if (token != null)
         {
            try
            {
               token.waitCompletion(5000);
            }
            catch (Exception e)
            {
               // ignore it
            }
View Full Code Here

TOP

Related Classes of org.hornetq.core.persistence.OperationContext

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.