Package org.jboss.cache.RPCManagerImpl

Examples of org.jboss.cache.RPCManagerImpl.FlushTracker


   }

   protected Object executeCommand(ReplicableCommand cmd, Message req) throws Throwable
   {
      boolean unlock = false;
      FlushTracker flushTracker = rpcManager.getFlushTracker();

      try
      {
         if (cmd == null) throw new NullPointerException("Unable to execute a null command!  Message was " + req);
         if (trace) log.trace("Executing command: " + cmd + " [sender=" + req.getSrc() + "]");

         boolean replayIgnored = false;


         if (configuration.isNonBlockingStateTransfer() && !(cmd instanceof StateTransferControlCommand))
         {
            int flushCount  = flushTracker.getFlushCompletionCount();
            flushTracker.lockProcessingLock();
            unlock = true;

            flushTracker.waitForFlushCompletion(configuration.getStateRetrievalTimeout());

            // If this thread blocked during a NBST flush, then inform the sender
            // it needs to replay ignored messages
            replayIgnored = flushTracker.getFlushCompletionCount() != flushCount;
         }

         Object ret;

         if (cmd instanceof VisitableCommand)
         {
            InvocationContext ctx = invocationContextContainer.get();
            ctx.setOriginLocal(false);
            if (!componentRegistry.invocationsAllowed(false))
            {
               return new RequestIgnoredResponse();
            }
            ret = interceptorChain.invoke(ctx, (VisitableCommand) cmd);
         }
         else
         {
            if (trace) log.trace("This is a non-visitable command - so performing directly and not via the invoker.");

            // need to check cache status for all except buddy replication commands.
            if (requiresRunningCache(cmd) && !componentRegistry.invocationsAllowed(false))
            {
               return new RequestIgnoredResponse();
            }
            ret = cmd.perform(null);
         }

         if (replayIgnored)
         {
            ExtendedResponse extended = new ExtendedResponse(ret);
            extended.setReplayIgnoredRequests(true);
            ret = extended;
         }

         return ret;
      }
      finally
      {
         if (replicationObserver != null)
            replicationObserver.afterExecutingCommand(cmd);

         if (unlock)
            flushTracker.unlockProcessingLock();
      }
   }
View Full Code Here


      if (trace) log.trace("persistent state succesfully written");
   }

   private void writeTxLog(ObjectOutputStream out) throws Exception
   {
      FlushTracker flushTracker = rpcManager.getFlushTracker();

      try
      {
         if (trace) log.trace("Transaction log size is " + txLog.size());
         for (int nonProgress = 0, size = txLog.size(); size > 0;)
         {
            if (trace) log.trace("Tx Log remaining entries = " + size);
            txLog.writeCommitLog(cache.getMarshaller(), out);
            int newSize = txLog.size();

            // If size did not decrease then we did not make progress, and could be wasting
            // our time. Limit this to the specified max.
            if (newSize >= size && ++nonProgress >= maxNonProgressingLogWrites)
               break;

            size = newSize;
         }

         // Wait on incoming and outgoing threads to line-up in front of
         // the flush gate.
         flushTracker.lockSuspendProcessingLock();

         // Signal to sender that we need a flush to get a consistent view
         // of the remaining transactions.
         delimitStream(out);
         out.flush();
         if (trace) log.trace("Waiting for a FLUSH");
         flushTracker.waitForFlushStart(flushTimeout);
         if (trace) log.trace("FLUSH received, proceeding with writing commit log");
         // Write remaining transactions
         txLog.writeCommitLog(cache.getMarshaller(), out);
         delimitStream(out);

         // Write all non-completed prepares
         txLog.writePendingPrepares(cache.getMarshaller(), out);
         delimitStream(out);
         out.flush();
      }
      finally
      {
         flushTracker.unlockSuspendProcessingLock();
      }
   }
View Full Code Here

   }

   protected Object executeCommand(ReplicableCommand cmd, Message req) throws Throwable
   {
      boolean unlock = false;
      FlushTracker flushTracker = rpcManager.getFlushTracker();

      try
      {
         if (cmd == null) throw new NullPointerException("Unable to execute a null command!  Message was " + req);
         if (trace) log.trace("Executing command: " + cmd + " [sender=" + req.getSrc() + "]");

         boolean replayIgnored = false;


         if (configuration.isNonBlockingStateTransfer() && !(cmd instanceof StateTransferControlCommand))
         {
            int flushCount  = flushTracker.getFlushCompletionCount();
            flushTracker.lockProcessingLock();
            unlock = true;

            flushTracker.waitForFlushCompletion(configuration.getStateRetrievalTimeout());

            // If this thread blocked during a NBST flush, then inform the sender
            // it needs to replay ignored messages
            replayIgnored = flushTracker.getFlushCompletionCount() != flushCount;
         }

         Object ret;

         if (cmd instanceof VisitableCommand)
         {
            InvocationContext ctx = invocationContextContainer.get();
            ctx.setOriginLocal(false);
            if (!componentRegistry.invocationsAllowed(false))
            {
               return new RequestIgnoredResponse();
            }
            try
            {
               ret = interceptorChain.invoke(ctx, (VisitableCommand) cmd);
            }
            catch (CacheNotReadyException cnre)
            {
               // this could happen, even though we check the state earlier on.  There is still a window
               // for the cache to be shut down in the meanwhile.
               if (log.isDebugEnabled()) log.debug("Cache not in a state to respond!", cnre);
               return new RequestIgnoredResponse();
            }
         }
         else
         {
            if (trace) log.trace("This is a non-visitable command - so performing directly and not via the invoker.");

            // need to check cache status for all except buddy replication commands.
            if (requiresRunningCache(cmd) && !componentRegistry.invocationsAllowed(false))
            {
               return new RequestIgnoredResponse();
            }
            ret = cmd.perform(null);
         }

         if (replayIgnored)
         {
            ExtendedResponse extended = new ExtendedResponse(ret);
            extended.setReplayIgnoredRequests(true);
            ret = extended;
         }

         return ret;
      }
      finally
      {
         if (replicationObserver != null)
            replicationObserver.afterExecutingCommand(cmd);

         if (unlock)
            flushTracker.unlockProcessingLock();
      }
   }
View Full Code Here

   }

   protected Object executeCommand(ReplicableCommand cmd, Message req) throws Throwable
   {
      boolean unlock = false;
      FlushTracker flushTracker = rpcManager.getFlushTracker();

      try
      {
         if (cmd == null) throw new NullPointerException("Unable to execute a null command!  Message was " + req);
         if (trace) log.trace("Executing command: " + cmd + " [sender=" + req.getSrc() + "]");

         boolean replayIgnored = false;


         if (configuration.isNonBlockingStateTransfer() && !(cmd instanceof StateTransferControlCommand))
         {
            int flushCount  = flushTracker.getFlushCompletionCount();
            flushTracker.lockProcessingLock();
            unlock = true;

            flushTracker.waitForFlushCompletion(configuration.getStateRetrievalTimeout());

            // If this thread blocked during a NBST flush, then inform the sender
            // it needs to replay ignored messages
            replayIgnored = flushTracker.getFlushCompletionCount() != flushCount;
         }

         Object ret;

         if (cmd instanceof VisitableCommand)
         {
            InvocationContext ctx = invocationContextContainer.get();
            ctx.setOriginLocal(false);
            if (!componentRegistry.invocationsAllowed(false))
            {
               return new RequestIgnoredResponse();
            }
            try
            {
               ret = interceptorChain.invoke(ctx, (VisitableCommand) cmd);
            }
            catch (CacheNotReadyException cnre)
            {
               // this could happen, even though we check the state earlier on.  There is still a window
               // for the cache to be shut down in the meanwhile.
               if (log.isDebugEnabled()) log.debug("Cache not in a state to respond!", cnre);
               return new RequestIgnoredResponse();
            }
         }
         else
         {
            if (trace) log.trace("This is a non-visitable command - so performing directly and not via the invoker.");

            // need to check cache status for all except buddy replication commands.
            if (requiresRunningCache(cmd) && !componentRegistry.invocationsAllowed(false))
            {
               return new RequestIgnoredResponse();
            }
            ret = cmd.perform(null);
         }

         if (replayIgnored)
         {
            ExtendedResponse extended = new ExtendedResponse(ret);
            extended.setReplayIgnoredRequests(true);
            ret = extended;
         }

         return ret;
      }
      finally
      {
         if (replicationObserver != null)
            replicationObserver.afterExecutingCommand(cmd);

         if (unlock)
            flushTracker.unlockProcessingLock();
      }
   }
View Full Code Here

TOP

Related Classes of org.jboss.cache.RPCManagerImpl.FlushTracker

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.