Package org.jboss.cache.marshall

Examples of org.jboss.cache.marshall.JBCMethodCall


        txTable = cache.getTransactionTable();
    }

    public Object invoke(MethodCall call) throws Throwable
    {
        JBCMethodCall m = (JBCMethodCall) call;
        if (log.isTraceEnabled())
        {
            log.trace("("+cache.getLocalAddress()+") call on method [" + m + "]");
        }
        // bypass for buddy group org metod calls.
        if (isBuddyGroupOrganisationMethod(m)) return super.invoke(m);

        InvocationContext ctx = getInvocationContext();

        final Transaction suspendedTransaction;
        boolean scrubTxsOnExit = false;
        final boolean resumeSuspended;
        Option optionOverride = ctx.getOptionOverrides();
       setTransactionInContext(ctx, txManager);

        if (optionOverride!= null && optionOverride.isFailSilently() && ctx.getTransaction() != null)
        {
           // make sure we remove the tx and global tx from the transaction table, since we don't care about this transaction
           // and will just suspend it.  - JBCACHE-1246
           GlobalTransaction gtx = txTable.remove(ctx.getTransaction());
           if (gtx != null) txTable.remove(gtx);

           suspendedTransaction = txManager.suspend();
           // set the tx in the invocation context to null now! - JBCACHE-785
           ctx.setTransaction(null);
           ctx.setGlobalTransaction(null);
            resumeSuspended = true;
        } else {
            suspendedTransaction = null;
            resumeSuspended = false;
        }

        Object result = null;

        try
        {
            // first of all deal with tx methods - these are only going to be
            // prepare/commit/rollback called by a remote cache, since calling
            // such methods on TreeCache directly would fail.

            if (isTransactionLifecycleMethod(m))
            {
                // this is a prepare, commit, or rollback.
                // start by setting transactional details into InvocationContext.
                ctx.setGlobalTransaction( findGlobalTransaction(m.getArgs()) );

                if (log.isDebugEnabled()) log.debug("Got gtx from method call " + ctx.getGlobalTransaction());
                ctx.getGlobalTransaction().setRemote( isRemoteGlobalTx(ctx.getGlobalTransaction()) );

                //replaceGtx(m, gtxFromMethodCall);
                if (ctx.getGlobalTransaction().isRemote()) remoteTransactions.put(ctx.getGlobalTransaction(),NULL);

                switch (m.getMethodId())
                {
                   case MethodDeclarations.optimisticPrepareMethod_id:
                   case MethodDeclarations.prepareMethod_id:
                      if (ctx.getGlobalTransaction().isRemote())
                      {
View Full Code Here


        if (modifications != null)
        {
            for (Iterator it = modifications.iterator(); it.hasNext();)
            {
                JBCMethodCall method_call = (JBCMethodCall) it.next();
                try
                {
                   if (injectDataVersions && !MethodDeclarations.isDataGravitationMethod(method_call.getMethodId()))
                   {
                      Object[] origArgs = method_call.getArgs();
                      // there may be instances (e.g., data gravitation calls) where a data version is not passed in or not even relevant.
                      // make sure we are aware of this.
                      injectDataVersion(origArgs[origArgs.length - 1]);
                      // modify the call to the non-dataversioned counterpart since we've popped out the data version
                      Object[] args = new Object[origArgs.length - 1];
                      System.arraycopy(origArgs, 0, args, 0, args.length);

                      retval = super.invoke(MethodCallFactory.create(MethodDeclarations.getUnversionedMethod(method_call.getMethodId()), args));
                   }
                   else
                   {
                      retval = super.invoke(method_call);
                   }
View Full Code Here

    public void testFqnManipulation()
    {
        Fqn fqn1 = Fqn.fromString("/hello/world");

        JBCMethodCall call1 = MethodCallFactory.create(MethodDeclarations.putKeyValMethodLocal, new Object[]{fqn1, "key", "value"});
        JBCMethodCall call2 = MethodCallFactory.create(MethodDeclarations.replicateMethod, new Object[]{call1});

        BuddyManager bm = createBasicBuddyManager();

        JBCMethodCall newReplicatedCall = bm.transformFqns(call2);
        JBCMethodCall newPutCall = (JBCMethodCall) newReplicatedCall.getArgs()[0];

        // should use object refs to transform the original MethodCall.
        String expected = "/" + BuddyManager.BUDDY_BACKUP_SUBTREE + "/" + null + "/hello/world";
        assertEquals(expected, newPutCall.getArgs()[0].toString());

    }
View Full Code Here

    public void testRootFqnManipulation()
    {
        Fqn fqn1 = Fqn.ROOT;

        JBCMethodCall call1 = MethodCallFactory.create(MethodDeclarations.putKeyValMethodLocal, new Object[]{fqn1, "key", "value"});
        JBCMethodCall call2 = MethodCallFactory.create(MethodDeclarations.replicateMethod, new Object[]{call1});

        BuddyManager bm = createBasicBuddyManager();

        JBCMethodCall newReplicatedCall = bm.transformFqns(call2);
        JBCMethodCall newPutCall = (JBCMethodCall) newReplicatedCall.getArgs()[0];

        // should use object refs to transform the original MethodCall.
        String expected = "/" + BuddyManager.BUDDY_BACKUP_SUBTREE + "/" + null;
        assertEquals(expected, newPutCall.getArgs()[0].toString());
    }
View Full Code Here

        Fqn fqn1 = Fqn.ROOT;
        Fqn fqn2 = Fqn.fromString("/hello/world");
        Fqn fqn3 = Fqn.fromString("/hello/again");
        Fqn fqn4 = Fqn.fromString("/buddy/replication");

        JBCMethodCall call1 = MethodCallFactory.create(MethodDeclarations.putKeyValMethodLocal, new Object[]{fqn1, "key", "value"});
        JBCMethodCall call2 = MethodCallFactory.create(MethodDeclarations.putKeyValMethodLocal, new Object[]{fqn2, "key", "value"});
        JBCMethodCall call3 = MethodCallFactory.create(MethodDeclarations.putKeyValMethodLocal, new Object[]{fqn3, "key", "value"});
        JBCMethodCall call4 = MethodCallFactory.create(MethodDeclarations.putKeyValMethodLocal, new Object[]{fqn4, "key", "value"});
        List list = new ArrayList();
        list.add(call1);
        list.add(call2);
        list.add(call3);
        list.add(call4);

        JBCMethodCall call5 = MethodCallFactory.create(MethodDeclarations.replicateAllMethod, new Object[]{list});

        BuddyManager bm = createBasicBuddyManager();

        JBCMethodCall newReplicatedCall = bm.transformFqns(call5);
        List l  = (List) newReplicatedCall.getArgs()[0];

        // should use object refs to transform the original MethodCall.
        String expected = "/" + BuddyManager.BUDDY_BACKUP_SUBTREE + "/null";

        int i=0;
View Full Code Here

      Set blocked = new HashSet();
      Object monitor = new Object();
     
      public Object invoke(MethodCall m) throws Throwable
      {        
         JBCMethodCall call = (JBCMethodCall) m;
         if (call.getMethodId() == MethodDeclarations.getNodeMethodLocal_id)
         {
            try
            {
               Object[] args = call.getArgs();
               Fqn fqn = (Fqn) args[0];
               synchronized (monitor)
               {
                  monitor.wait(2000);
               }     
View Full Code Here

    * @param m
    * @return
    * @throws Throwable
    */
   public Object invoke(MethodCall call) throws Throwable {
      JBCMethodCall m = (JBCMethodCall) call;
      Method meth=m.getMethod();
      Fqn fqn;
      boolean isPut=putMethods.contains(meth),
            isRemove=m.getMethodId() == MethodDeclarations.removeNodeMethodLocal_id,
            isEvict=m.getMethodId() == MethodDeclarations.evictNodeMethodLocal_id;

      if(isPut || isRemove || isEvict) {  // we need to sync put(), remove() and evict() calls
         Object[] args=m.getArgs();
         fqn=(Fqn)(args != null? (isEvict? args[0] : args[1]) : null);
         if(fqn == null)
            throw new CacheException("failed extracting FQN from method " + m);

         if(isPut) { // lock needs to be held across puts()
View Full Code Here

      syncCommunications = cache.getCacheModeInternal() == TreeCache.REPL_SYNC;
   }

   public Object invoke(MethodCall call) throws Throwable
   {
      JBCMethodCall m = (JBCMethodCall) call;
      InvocationContext ctx = getInvocationContext();

      if (((ctx.getOptionOverrides() != null) && ctx.getOptionOverrides().isSkipDataGravitation()))
      {
         return super.invoke(call);
      }

      if (log.isTraceEnabled()) log.trace("Invoked with method call " + m);

      // Transactional lifecycle methods should be handled regardless of whether data gravitation is enabled or not.
      if (!isTransactionLifecycleMethod(m))
      {
         if (isGravitationEnabled(ctx) && MethodDeclarations.isGetMethod(m.getMethodId()))
         {
            // test that the Fqn being requested exists locally in the cache.
            Fqn fqn = extractFqn(m.getMethodId(), m.getArgs());
            if (log.isTraceEnabled()) log.trace("Checking local existence of fqn " + fqn);
            if (BuddyManager.isBackupFqn(fqn))
            {
               log.info("Is call for a backup Fqn, not performing any gravitation.  Direct calls on internal backup nodes are *not* supported.");
            }
            else
            {
               if (!cache.exists(fqn))
               {
                  // perform a data gravitation
                  log.trace("Gravitating from local backup tree");
                  BackupData data = localBackupGet(fqn);
                 
                  if (data == null)
                  {
                     log.trace("Gravitating from remote backup tree");
                     // gravitate remotely.
                     data = remoteBackupGet(fqn);
                  }

                  if (data != null)
                  {
                     // create node locally so I don't gravitate again
                     // when I do the put() call to the cluster!
                     createNode(true, data.backupData);
                     // Make sure I replicate to my buddies.
                     log.trace("Passing the put call locally to make sure state is persisted and ownership is correctly established.");
                     createNode(false, data.backupData);

                     // now obtain locks -
                     lock(data.primaryFqn);

                     // Clean up the other nodes
                     cleanBackupData(data);
                  }
               }
            }
         }
         else
         {
            if (log.isTraceEnabled())
               log.trace("Suppressing data gravitation for this call.");
         }
      }
      else
      {

         try
         {
            switch (m.getMethodId())
            {
               case MethodDeclarations.prepareMethod_id:
               case MethodDeclarations.optimisticPrepareMethod_id:
                  Object o = super.invoke(m);
                  doPrepare(ctx.getGlobalTransaction());
View Full Code Here

   {
      MethodCall cleanup = (MethodCall) transactionMods.get(gtx);
      if (log.isTraceEnabled()) log.trace("Broadcasting prepare for cleanup ops " + cleanup);
      if (cleanup != null)
      {
         JBCMethodCall prepare;
         List mods = new ArrayList(1);
         mods.add(cleanup);
         if (cache.isNodeLockingOptimistic())
         {
            prepare = MethodCallFactory.create(MethodDeclarations.optimisticPrepareMethod, new Object[]{gtx, mods, null, cache.getLocalAddress(), Boolean.FALSE});
View Full Code Here

//       {
//           primaryDataCleanup = MethodCallFactory.create(MethodDeclarations.evictNodeMethodLocal, new Object[]{backup.primaryFqn});
//           backupDataCleanup = MethodCallFactory.create(MethodDeclarations.evictNodeMethodLocal, new Object[]{backup.backupFqn});
//       }

      JBCMethodCall cleanup = MethodCallFactory.create(MethodDeclarations.dataGravitationCleanupMethod, new Object[]{getInvocationContext().getGlobalTransaction(), backup.primaryFqn, backup.backupFqn});


      if (log.isTraceEnabled()) log.trace("Performing cleanup on [" + backup.primaryFqn + "]");
      GlobalTransaction gtx = getInvocationContext().getGlobalTransaction();
      if (gtx == null)
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.