Package org.jboss.ha.hasessionstate.interfaces

Examples of org.jboss.ha.hasessionstate.interfaces.PackagedSession


      return this.localTakeOwnership(appName, keyId);
   }
  
   public PackagedSession localTakeOwnership(String appName, Object keyId) throws java.rmi.RemoteException
   {
      PackagedSession session = this.getAppMap(appName).get(keyId);
     
      // if the session is not yet available, we simply return null. The persistence manager
      // will have to take an action accordingly
      //
      if (session == null)
      {
         return null;
      }
     
      Lock lock = session.getLock();
     
      if (!lock.tryLock())
      {
         throw new java.rmi.RemoteException("Concurent calls on session object.");
      }
     
      try
      {
         if (!session.getOwner().equals(this.myNodeName))
         {
            Object[] args = { appName, keyId, this.myNodeName, new Long(session.getVersion()) };
            ArrayList<?> answers = null;
            try
            {
               answers = this.partition.callMethodOnCluster(this.sessionStateIdentifier, "_setOwnership", args, SET_OWNERSHIP_TYPES, true);
            }
            catch (Exception e)
            {
               this.log.error("operation failed", e);
            }
           
            if ((answers != null) && answers.contains(Boolean.FALSE))
            {
               throw new java.rmi.RemoteException("Concurent calls on session object.");
            }

            session.setOwner(this.myNodeName);
            return session;
         }

         return session;
      }
View Full Code Here


      }
   }
  
   public Boolean _setOwnership(String appName, Object keyId, String newOwner, Long remoteVersion)
   {
      PackagedSession session = this.getAppMap(appName).get(keyId);
     
      Lock lock = session.getLock();
     
      if (!lock.tryLock())
      {
         return Boolean.FALSE;
      }

      try
      {
         if (!session.getOwner().equals(this.myNodeName))
         {
            // this is not our business... we don't care
            // we do not update the owner of ps as another host may refuse the _setOwnership call
            // anyway, the update will be sent to us later if state is modified
            //
            return Boolean.TRUE;
         }
         else if (session.getVersion() > remoteVersion.longValue())
         {
            // we are concerned and our version is more recent than the one of the remote host!
            // it means that we have concurrent calls on the same state that has not yet been updated
            // this means we will need to raise a java.rmi.RemoteException
            //
            return Boolean.FALSE;
         }

         // the remote host has the same version as us (or more recent? possible?)
         // we need to update the ownership. We can do this because we know that no other
         // node can refuse the _setOwnership call
         session.setOwner(newOwner);

         this.ownedObjectExternallyModified(appName, keyId, session, session);
        
         return Boolean.TRUE;
      }
View Full Code Here

      }
   }
  
   public void _removeSession(String appName, Object keyId)
   {
      PackagedSession session = this.getAppMap(appName).remove(keyId);
     
      if ((session != null) && session.getOwner().equals(this.myNodeName))
      {
         this.ownedObjectExternallyModified(appName, keyId, session, session);
      }
   }
View Full Code Here

TOP

Related Classes of org.jboss.ha.hasessionstate.interfaces.PackagedSession

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.