Package org.jboss.cache.marshall

Examples of org.jboss.cache.marshall.JBCMethodCall


    * @return
    * @throws Throwable
    */
   public Object invoke(MethodCall call) throws Throwable {

      JBCMethodCall m = (JBCMethodCall) call;

      // if this is a shared cache loader and the call is of remote origin, pass up the chain. - Manik
      // see http://www.jboss.com/index.html?module=bb&op=viewtopic&t=76090

      if (!getInvocationContext().isOriginLocal() && loaderConfig.isShared()) {
          log.trace("Passing up method call and bypassing this interceptor since the cache loader is shared and this call originated remotely.");
          return super.invoke(m);
      }

      Fqn          fqn;
      Map          attributes;
      Object       key, value;
      Method       meth=m.getMethod();
      Object[]     args=m.getArgs();
      Object       retval, tmp_retval=null;
      boolean      use_tmp_retval=false;


       if (log.isTraceEnabled()) {
           log.trace("CacheStoreInterceptor called with meth " + m);
       }

       if (tx_mgr != null && tx_mgr.getTransaction() != null) {
           // we have a tx running.
           log.trace("transactional so don't put stuff in the cloader yet.");
           GlobalTransaction gtx = getInvocationContext().getGlobalTransaction();
           switch (m.getMethodId())
           {
              case MethodDeclarations.commitMethod_id:
                 if (getInvocationContext().isTxHasMods()) {
                    // this is a commit call.
                    if (log.isTraceEnabled()) log.trace("Calling loader.commit() for gtx " + gtx);
                    // sync call (a write) on the loader
                    List fqnsModified = getFqnsFromModificationList(tx_table.get(gtx).getCacheLoaderModifications());
                    try
                    {
                         loader.commit(gtx);
                    }
                    finally
                    {
                        preparingTxs.remove(gtx);
                    }
                    if (cache.getUseInterceptorMbeans()&& statsEnabled) {
                       Integer puts = (Integer)m_txStores.get(gtx);
                       if (puts != null)
                          m_cacheStores = m_cacheStores + puts.intValue();
                       m_txStores.remove(gtx);
                    }
                 }
                 else {
                    log.trace("Commit called with no modifications; ignoring.");
                 }
                 break;
              case MethodDeclarations.rollbackMethod_id:
                 if (getInvocationContext().isTxHasMods()) {
                    // this is a rollback method
                    if (preparingTxs.containsKey(gtx))
                    {
                        preparingTxs.remove(gtx);
                        loader.rollback(gtx);
                    }
                    if (cache.getUseInterceptorMbeans()&& statsEnabled)
                       m_txStores.remove(gtx);
                 }
                 else {
                    log.trace("Rollback called with no modifications; ignoring.");
                 }
                 break;
              case MethodDeclarations.optimisticPrepareMethod_id:
              case MethodDeclarations.prepareMethod_id:
                 prepareCacheLoader(gtx, isOnePhaseCommitPrepareMehod(m));
                 break;
           }

           // pass up the chain
           return super.invoke(m);
       }

      // if we're here we don't run in a transaction

      // remove() methods need to be applied to the CacheLoader before passing up the call: a listener might
      // access an element just removed, causing the CacheLoader to *load* the element before *removing* it.
//      synchronized(this) {
       switch (m.getMethodId())
       {
          case MethodDeclarations.removeNodeMethodLocal_id:
             fqn=(Fqn)args[1];
             loader.remove(fqn);
             break;
          case MethodDeclarations.removeKeyMethodLocal_id:
             fqn=(Fqn)args[1];
             key=args[2];
             tmp_retval=loader.remove(fqn, key);
             use_tmp_retval=true;
             break;
          case MethodDeclarations.removeDataMethodLocal_id:
             fqn=(Fqn)args[1];
             loader.removeData(fqn);
             break;
       }
//      }

      retval=super.invoke(m);

      // put() methods need to be applied *after* the call
//      synchronized(this) {
      switch (m.getMethodId())
      {
         case MethodDeclarations.putDataMethodLocal_id:
         case MethodDeclarations.putDataEraseMethodLocal_id:
            Modification mod = convertMethodCallToModification(m);
            log.debug(mod);
View Full Code Here


    * @see Region#getMethodCallQueue
    */
   public void _enqueueMethodCall(String subtree, MethodCall call)
           throws Throwable
   {
      JBCMethodCall jbcCall = (JBCMethodCall) call;
      Fqn fqn = Fqn.fromString(subtree);
      Region region = regionManager_.getRegion(fqn);
      // JBCACHE-1225 -- handle buddy region fqns
      if (region == null && BuddyManager.isBackupFqn(fqn))
      {
         // Strip out the buddy group portion
         fqn = fqn.getFqnChild(2, fqn.size());
         region = regionManager_.getRegion(fqn);
      }
      if (region == null)
         throw new IllegalStateException("No region found for " + subtree);

      List queue = region.getMethodCallQueue();
      synchronized (queue)
      {
         // Confirm we're not active yet; if we are just invoke the method
         switch (region.getStatus())
         {
            case(Region.STATUS_ACTIVE):
               if (log.isTraceEnabled())
                  log.trace("_enqueueMethodCall(): Invoking " + call.getName() +
                          " on subtree " + subtree);
               call.invoke(this);
               break;

            case(Region.STATUS_QUEUEING):

               // Don't bother queueing a getState call

               if (jbcCall.getMethodId() == MethodDeclarations.replicateMethod_id)
               {
                  JBCMethodCall mc = (JBCMethodCall) call.getArgs()[0];
                  if (mc.getMethodId() == MethodDeclarations.getPartialStateMethod_id)
                     return;
               }
               if (log.isTraceEnabled())
                  log.trace("_enqueueMethodCall(): Enqueuing " + call.getName() +
                          " " + call.getArgs() + " on subtree " + subtree);
View Full Code Here

   }

   private void processQueuedMethodCalls(List queue) throws Throwable
   {
      Map gtxMap = new HashMap();
      JBCMethodCall call = null;
      JBCMethodCall wrapped = null;
      for (Iterator iter = queue.iterator(); iter.hasNext();)
      {
         call = (JBCMethodCall) iter.next();
         boolean forgive = false;
         if (call.getMethodId() == MethodDeclarations.replicateMethod_id)
         {
            Object[] args = call.getArgs();
            wrapped = (JBCMethodCall) args[0];
            switch (wrapped.getMethodId())
            {
               case MethodDeclarations.prepareMethod_id:
                  args = wrapped.getArgs();
                  gtxMap.put(args[0], NULL);
                  break;
               case MethodDeclarations.commitMethod_id:
               case MethodDeclarations.rollbackMethod_id:
                  args = wrapped.getArgs();
                  // If we didn't see the prepare earlier, we'll forgive
                  // any error when we invoke the commit/rollback
                  // TODO maybe just skip the commit/rollback?
//                  forgive = (gtxMap.remove(args[0]) == null);
                  if (gtxMap.remove(args[0]) == null)
View Full Code Here

    * be moved entirely into the ReplicationInterceptor.
    */
   public Object _replicate(MethodCall method_call) throws Throwable
   {
      if (log.isTraceEnabled()) log.trace(getLocalAddress() + " received call " + method_call);
      JBCMethodCall jbcCall = (JBCMethodCall) method_call;
      try
      {
         getInvocationContext().setOriginLocal(false);

         Object result = invokeMethod(method_call);

         // Patch from Owen Taylor - JBCACHE-766
         // We replicating, we don't need to return the return value of the put-key-value
         // methods and the return values will cause marshalling problems, so we
         // omit them.
         if (jbcCall.getMethodId() == MethodDeclarations.putKeyValMethodLocal_id ||
                 jbcCall.getMethodId() == MethodDeclarations.putFailFastKeyValueMethodLocal_id ||
                 jbcCall.getMethodId() == MethodDeclarations.removeKeyMethodLocal_id)
            return null;
         else
            return result;
      }
      catch (Exception ex)
      {
         // patch from Owen Taylor (otaylor@redhat.com) to fix JBCACHE-786
         // The point of putFailFast() is to allow the caller to catch and ignore timeouts;
         // but they don't get a chance to do that for the (always async) replicated version,
         // so we just ignore timeout exceptions for putFailFast here.

         if (jbcCall.getMethodId() == MethodDeclarations.putFailFastKeyValueMethodLocal_id && ex instanceof TimeoutException)
         {
            log.debug("ignoring timeout exception when replicating putFailFast");
            return null;
         }

View Full Code Here

    * @return a List containing 2 elements: (Boolean.TRUE or Boolean.FALSE) and a value (Object).  If buddy replication
    *         is used one further element is added - an Fqn of the backup subtree in which this node may be found.
    */
   public List _clusteredGet(MethodCall methodCall, Boolean searchBackupSubtrees)
   {
      JBCMethodCall call = (JBCMethodCall) methodCall;
      if (log.isTraceEnabled()) log.trace("Clustered Get called with params: " + call + ", " + searchBackupSubtrees);
      Method m = call.getMethod();
      Object[] args = call.getArgs();

      Object callResults = null;

      try
      {
View Full Code Here

    */
   public Object invoke(MethodCall call) throws Throwable
   {
      //Fqn fqn;
      Map attributes;
      JBCMethodCall m = (JBCMethodCall) call;
      //Object key;
      //Object value;
      Method meth = m.getMethod();
      Object[]args = m.getArgs();
      Object retval = null;


      // if statistics not enabled, execute the method and return
      if (!statsEnabled)
         return super.invoke(m);
     
      long t1, t2;
      switch (m.getMethodId())
      {
         case MethodDeclarations.getKeyValueMethodLocal_id:
            //fqn = (Fqn) args[0];
            //key = args[1];
            t1 = System.currentTimeMillis();
View Full Code Here

{

    public Object invoke(MethodCall call) throws Throwable
    {

        JBCMethodCall m = (JBCMethodCall) call;
        InvocationContext ctx = getInvocationContext();
        GlobalTransaction gtx = ctx.getGlobalTransaction();

       // bypass for buddy group org metod calls.
       if (isBuddyGroupOrganisationMethod(m)) return super.invoke(m);
      

        boolean isLocalCommitOrRollback = gtx != null && !gtx.isRemote() && (m.getMethodId() == MethodDeclarations.commitMethod_id || m.getMethodId() == MethodDeclarations.rollbackMethod_id);


        // pass up the chain if not a local commit or rollback (in which case replicate first)
        Object o = isLocalCommitOrRollback ? null : super.invoke(m);

        Option optionOverride = ctx.getOptionOverrides();

        if (optionOverride != null && optionOverride.isCacheModeLocal() && ctx.getTransaction() == null)
        {
            log.trace("skip replication");
            return isLocalCommitOrRollback ? super.invoke(m) : o;
        }

        Method method = m.getMethod();

        // could be potentially TRANSACTIONAL. If so, we register for transaction completion callbacks (if we
        // have not yet done so
        if (ctx.getTransaction() != null)
        {
            if (gtx != null && !gtx.isRemote())
            {
                // lets see what sort of method we've got.
               switch(m.getMethodId())
               {
                  case MethodDeclarations.commitMethod_id:
                     // REPL_ASYNC will result in only a prepare() method - 1 phase commit.
                     if (containsModifications(m)) replicateCall(m, cache.getSyncCommitPhase());
                     // now pass up the chain
View Full Code Here

    * @return
    * @throws Throwable
    */
   public Object invoke(MethodCall call) throws Throwable {
     
      JBCMethodCall m = (JBCMethodCall) call;
     
      // hmesha- We don't need to handle transaction during passivation since
      // passivation happens local to a node and never replicated

      // evict() method need to be applied to the CacheLoader before passing up the call
      if (m.getMethodId() == MethodDeclarations.evictNodeMethodLocal_id) {
         Object[]     args=m.getArgs();
         Fqn fqn = (Fqn)args[0];
         try
         {
            synchronized (this) {
               // evict method local doesn't hold attributes
View Full Code Here

   public JBCMethodCall transformFqns(JBCMethodCall call, boolean transformForCurrentCall)
   {
      if (call != null && call.getArgs() != null)
      {
         JBCMethodCall call2 = new JBCMethodCall(call.getMethod(), (Object[]) call.getArgs().clone(), call.getMethodId());
         handleArgs(call2.getArgs(), transformForCurrentCall);
         return call2;
      }
      else
      {
         return call;
View Full Code Here

   {
      for (int i = 0; i < args.length; i++)
      {
         if (args[i] instanceof JBCMethodCall)
         {
            JBCMethodCall call = (JBCMethodCall) args[i];
            boolean transformFqns = true;
            if (call.getMethodId() == MethodDeclarations.dataGravitationCleanupMethod_id)
            {
               transformFqns = false;
            }

            args[i] = transformFqns((JBCMethodCall) args[i], transformFqns);
View Full Code Here

TOP

Related Classes of org.jboss.cache.marshall.JBCMethodCall

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.