Package org.jboss.ha.framework.interfaces

Examples of org.jboss.ha.framework.interfaces.GenericClusteringException


               {
                  log.trace("Invocation returned exception: " + response);
               }
               if(response instanceof GenericClusteringException)
               {
                  GenericClusteringException gcex = (GenericClusteringException) response;
                  lastException = gcex;
                  // this is a generic clustering exception that contain the
                  // completion status: usefull to determine if we are authorized
                  // to re-issue a query to another node
                  //
                  if(gcex.getCompletionStatus() == GenericClusteringException.COMPLETED_NO)
                  {
                     // we don't want to remove the node from the list of failed
                     // node UNLESS there is a risk to indefinitively loop
                     //
                     if(totalNumberOfTargets() >= failoverCounter)
                     {
                        if(!gcex.isDefinitive())
                        {
                           definitivlyRemoveNodeOnFailure = false;
                        }
                     }
                     removeDeadTarget(getLocator());
                     if(!definitivlyRemoveNodeOnFailure)
                     {
                        resetView();
                     }
                     failoverAuthorized = txContextAllowsFailover(invocation);

                     failoverCounter++;
                     invocation.setValue("FAILOVER_COUNTER", new Integer(failoverCounter), PayloadKey.AS_IS);

                     if (trace)
                     {
                        log.trace("Received GenericClusteringException where request was not completed.  Will retry if transaction failover is authorised.");
                     }

                     continue;
                  }
                  else
                  {
                     invocationHasReachedAServer(invocation);
                     throw new ServerException("Clustering error", gcex);
                  }
               }
               else
               {
                  throw ((Exception) response);
               }
            }
            if(response instanceof MarshalledObject<?>)
            {
               haResponse = (HARMIResponse) ((MarshalledObject<?>) response).get();
            }
            else
            {
               haResponse = (HARMIResponse) response;
            }

            // check for clustered targets
            if(haResponse.newReplicants != null)
            {
               updateClusterInfo(haResponse.newReplicants, haResponse.currentViewId);
            }
           
            response = haResponse.response;
            invocationHasReachedAServer(invocation);
            return response;

         }
         catch(CannotConnectException cncEx)
         {
            if (trace)
            {
               log.trace("Invocation failed: CannotConnectException - " + cncEx, cncEx);
            }
           
            removeDeadTarget(getLocator());
            resetView();
            failoverAuthorized = txContextAllowsFailover(invocation);

            failoverCounter++;
            invocation.setValue("FAILOVER_COUNTER", new Integer(failoverCounter), PayloadKey.AS_IS);
         }
         catch(GenericClusteringException gcex)
         {
            lastException = gcex;
            // this is a generic clustering exception that contain the
            // completion status: usefull to determine if we are authorized
            // to re-issue a query to another node
            //
            if(gcex.getCompletionStatus() == GenericClusteringException.COMPLETED_NO)
            {
               // we don't want to remove the node from the list of failed
               // node UNLESS there is a risk to indefinitively loop
               //
               if(totalNumberOfTargets() >= failoverCounter)
               {
                  if(!gcex.isDefinitive())
                  {
                     definitivlyRemoveNodeOnFailure = false;
                  }
               }
               removeDeadTarget(getLocator());
View Full Code Here


         {
            // Handle application declared exceptions
            Throwable cause = e.getTargetException();
            if (cause instanceof GenericClusteringException)
            {
               GenericClusteringException gce = (GenericClusteringException) cause;
               definitivelyRemoveNodeOnFailure = handleGenericClusteringException(invocation, failoverCounter,
                     definitivelyRemoveNodeOnFailure, gce);
            }
            else
            {
View Full Code Here

         if (!this.allowRemoteInvocations && !isAppLocalCall)
            // it is a remote call and they are currently forbidden!
            //
         {
            if (isDebugEnabled) log.debug ("Refusing a remote home invocation. here= " + ejbModuleName + "; Origin= " + origin);
            throw new GenericClusteringException (GenericClusteringException.COMPLETED_NO,
                                                  "This application does not accept remote calls any more");
         }

         // we need to acquire the read lock. If we cannot directly, it means
         // that the stop/destroy call has gotten the write lock in the meantime
         //
         try
         {
            if (!isAppLocalCall) // we only consider remote calls => every local originates from a remote!
            {
               if (!rwLock.readLock().tryLock(readAcquireTimeMs, TimeUnit.MILLISECONDS))
                  throw new GenericClusteringException (GenericClusteringException.COMPLETED_NO,
                                                        "Container is shuting down on this node (timeout)");
            }
         }
         catch (java.lang.InterruptedException ie)
         {
            Thread.currentThread().interrupt();
            throw new GenericClusteringException (GenericClusteringException.COMPLETED_NO,
                                                  "Container is shuting down on this node");
         }

         runningHomeInvocations++;
         try
         {
            if (!isAppLocalCall)
               setOrigin (mi);
            return this.getNext ().invokeHome (mi);
         }
         catch (GenericClusteringException gce)
         {
            // a gce exception has be thrown somewhere else: we need to modify its flag
            // and forward it. We could add optimisations at this level by having some
            // "idempotent" flag at the container level
            //
            gce.setCompletionStatus (gce.COMPLETED_MAYBE);
            throw gce;
         }
         finally
         {
            if (!isAppLocalCall)
               revertOrigin (mi, origin);

            runningHomeInvocations--;
            if (!isAppLocalCall) // we only consider remote calls => every local originates from a remote!
               rwLock.readLock().unlock();
         }
      }
      else
         throw new GenericClusteringException (GenericClusteringException.COMPLETED_NO,
                                               "Container is not allowing invocations as it failed to start or is shutting down");
   }
View Full Code Here

         if (!this.allowRemoteInvocations && !isAppLocalCall)
            // it is a remote call and they are currently forbidden!
            //
         {
            if (isDebugEnabled) log.debug ("Refusing a remote invocation");
            throw new GenericClusteringException (GenericClusteringException.COMPLETED_NO,
                                                  "This application does not accept remote calls any more");
         }

         // we need to acquire the read lock. If we cannot directly, it means
         // that the stop/destroy call has gotten the write lock in the meantime
         //
         try
         {
            if (!isAppLocalCall) // we only consider remote calls => every local originates from a remote!
            {
               if (!rwLock.readLock ().tryLock(readAcquireTimeMs, TimeUnit.MILLISECONDS))
                  throw new GenericClusteringException (GenericClusteringException.COMPLETED_NO,
                                                        "Container is shuting down on this node (timeout)");
            }
         }
         catch (java.lang.InterruptedException ie)
         {
            Thread.currentThread().interrupt();
            throw new GenericClusteringException (GenericClusteringException.COMPLETED_NO,
                                                  "Container is shuting down on this node");
         }

         runningInvocations++;
         try
         {
            if (!isAppLocalCall)
               setOrigin (mi);
            return this.getNext ().invoke (mi);
         }
         catch (GenericClusteringException gce)
         {
            // a gce exception has be thrown somewhere else: we need to modify its flag
            // and forward it. We could add optimisations at this level by having some
            // "idempotent" flag at the container level
            //
            gce.setCompletionStatus (gce.COMPLETED_MAYBE);
            throw gce;
         }
         finally
         {
            if (!isAppLocalCall)
               revertOrigin (mi, origin);

            runningInvocations--;
            if (!isAppLocalCall) // we only consider remote calls => every local originates from a remote!
               rwLock.readLock().unlock();
         }
      }
      else
         throw new GenericClusteringException (GenericClusteringException.COMPLETED_NO,
                                               "Container is not allowing invocations as it failed to start or is shutting down");
   }
View Full Code Here

      {
         // Unwrap any JMX exceptions
         e = (Exception) JMXExceptionDecoder.decode(e);
         // Don't send JMX exception back to client to avoid needing jmx
         if( e instanceof JMException )
            e = new GenericClusteringException (GenericClusteringException.COMPLETED_NO, e.getMessage());

         // Only log errors if trace is enabled
         if( log.isTraceEnabled() )
            log.trace("operation failed", e);
         throw e;
View Full Code Here

            // Consequently, a client could own an up-to-date list of the replicants
            // (before the cluster has converged) and try to perform an invocation
            // on this node where the HATarget no more exist, thus receiving a
            // wrong exception and no failover is performed with an IllegalStateException
            //
            throw new GenericClusteringException(GenericClusteringException.COMPLETED_NO,
                                                 "target is not/no more registered on this node");           
         }
        
         if (!target.invocationsAllowed ())
            throw new GenericClusteringException(GenericClusteringException.COMPLETED_NO,
                                        "invocations are currently not allowed on this target");           

         // The cl on the thread should be set in another interceptor
         Object[] args = {invocation};
         String[] sig = {"org.jboss.invocation.Invocation"};
         Object rtn = super.getServer().invoke(mbean,
            "invoke", args, sig);

         // Update the targets list if the client view is out of date
         HARMIResponse rsp = new HARMIResponse();
         if (clientViewId != target.getCurrentViewId())
         {
            rsp.newReplicants = new ArrayList<Object>(target.getReplicantList());
            rsp.currentViewId = target.getCurrentViewId();
         }
         rsp.response = rtn;

         // Return the raw object and let the http layer marshall it
         return rsp;
      }
      catch (InstanceNotFoundException e)
      {
         throw new GenericClusteringException(GenericClusteringException.COMPLETED_NO, e);
      }
      catch (ReflectionException e)
      {
         throw new GenericClusteringException(GenericClusteringException.COMPLETED_NO, e);
      }     
      catch(Exception e)
      {
         JMXExceptionDecoder.rethrow(e);
View Full Code Here

            // Consequently, a client could own an up-to-date list of the replicants
            // (before the cluster has converged) and try to perform an invocation
            // on this node where the HATarget no more exist, thus receiving a
            // wrong exception and no failover is performed with an IllegalStateException
            //
            throw new GenericClusteringException(GenericClusteringException.COMPLETED_NO,
                                                 "target is not/no more registered on this node");
         }

         if(!target.invocationsAllowed())
         {
            throw new GenericClusteringException(GenericClusteringException.COMPLETED_NO,
                                                 "invocations are currently not allowed on this target");
         }
         /** End Clustering **/

         // The cl on the thread should be set in another interceptor
         Object obj = getServer().invoke(mbean,
                                         "invoke",
                                         new Object[]{invocation},
                                         Invocation.INVOKE_SIGNATURE);

         /** Clustering **/

         HARMIResponse haResponse = new HARMIResponse();

         if(clientViewId != target.getCurrentViewId())
         {
            haResponse.newReplicants = new ArrayList<Object>(target.getReplicantList());
            haResponse.currentViewId = target.getCurrentViewId();
         }
         haResponse.response = obj;

         /** End Clustering **/

         return new MarshalledObject<HARMIResponse>(haResponse);
      }
      catch (InstanceNotFoundException e)
      {
         throw new GenericClusteringException(GenericClusteringException.COMPLETED_NO, e);
      }
      catch (ReflectionException e)
      {
         throw new GenericClusteringException(GenericClusteringException.COMPLETED_NO, e);
      }     
      catch(Exception e)
      {
         JMXExceptionDecoder.rethrow(e);

View Full Code Here

         }
      }

      if (doFail)
      {
         GenericClusteringException e = new GenericClusteringException
         (GenericClusteringException.COMPLETED_NO, "Test failover from ejb interceptor", false);
        
         log.debug ("WE FAILOVER IN EJB INTERCEPTOR (explicit failover)!", e);

         throw e;
View Full Code Here

         }
      }

      if (doFail)
      {
         GenericClusteringException e = new GenericClusteringException
         (GenericClusteringException.COMPLETED_NO, "Test failover from ejb interceptor", false);
        
         log.debug ("WE FAILOVER IN EJB INTERCEPTOR (explicit failover)!", e);

         throw e;
View Full Code Here

            // Just in case this get wrapped in a Throwable. This can happen when
            // the exception is generated inside the container and it is wrapped in
            // a ForwardId exception.
            if(t.getCause() instanceof GenericClusteringException)
            {
               GenericClusteringException gce = (GenericClusteringException)t.getCause();
               lastException = gce;
               // this is a generic clustering exception that contain the
               // completion status: usefull to determine if we are authorized
               // to re-issue a query to another node
               //
               if (gce.getCompletionStatus() == GenericClusteringException.COMPLETED_NO)
               {
                  // we don't want to remove the node from the list of failed
                  // node UNLESS there is a risk to indefinitively loop
                  //
                  if (family.get().getTargets().size() >= failoverCounter)
                  {
                     if (!gce.isDefinitive())
                        definitivlyRemoveNodeOnFailure = false;
                  }
               }
               else
               {
View Full Code Here

TOP

Related Classes of org.jboss.ha.framework.interfaces.GenericClusteringException

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.