Package org.jboss.ha.hasessionstate.interfaces

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


      this._createSession(appName, keyId);
   }
  
   public PackagedSession _createSession(String appName, Object keyId)
   {
      PackagedSession session = this.createSession(keyId);
     
      this.getAppMap(appName).put(keyId, session);
     
      return session;
   }
View Full Code Here


   }
  
   public void setState(String appName, Object keyId, byte[] state)
      throws java.rmi.RemoteException
   {
      PackagedSession session = this.createSession(keyId);
      PackagedSession existing = this.getAppMap(appName).putIfAbsent(keyId, session);
     
      if (existing != null)
      {
         session = existing;
      }
View Full Code Here

      }
   }
  
   public void _setState(String appName, PackagedSession session)
   {
      PackagedSession existing = this.getAppMap(appName).putIfAbsent(session.getKey(), session);
     
      if (existing != null)
      {
         Lock lock = existing.getLock();
        
         try
         {
            lock.lockInterruptibly();
         }
         catch (InterruptedException ie)
         {
            Thread.currentThread().interrupt();
            this.log.info(ie);
            return;
         }
        
         try
         {
            if (existing.getOwner().equals(this.myNodeName))
            {
               // a modification has occured externally while we were the owner
               //
               this.ownedObjectExternallyModified(appName, session.getKey(), existing, session);
            }
           
            existing.update(session);
         }
         finally
         {
            lock.unlock();
         }
View Full Code Here

      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()) };
            List<?> 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

      try
      {
         ObjectInputStream in;

         // Load state
         PackagedSession state = this.sessionState.getStateWithOwnership (this.appName, ctx.getId ());

         if (state == null)
            throw new EJBException ("Could not activate; failed to recover session (session has been probably removed by session-timeout)");

         in = new SessionObjectInputStream (ctx, new ByteArrayInputStream (state.getState ()));;

         ctx.setInstance ( in.readObject () );

         in.close ();
View Full Code Here

      this._createSession(appName, keyId);
   }
  
   public PackagedSession _createSession(String appName, Object keyId)
   {
      PackagedSession session = this.createSession(keyId);
     
      this.getAppMap(appName).put(keyId, session);
     
      return session;
   }
View Full Code Here

   }
  
   public void setState(String appName, Object keyId, byte[] state)
      throws java.rmi.RemoteException
   {
      PackagedSession session = this.createSession(keyId);
      PackagedSession existing = this.getAppMap(appName).putIfAbsent(keyId, session);
     
      if (existing != null)
      {
         session = existing;
      }
View Full Code Here

      }
   }
  
   public void _setState(String appName, PackagedSession session)
   {
      PackagedSession existing = this.getAppMap(appName).putIfAbsent(session.getKey(), session);
     
      if (existing != null)
      {
         Lock lock = existing.getLock();
        
         try
         {
            lock.lockInterruptibly();
         }
         catch (InterruptedException ie)
         {
            this.log.info(ie);
            return;
         }
        
         try
         {
            if (existing.getOwner().equals(this.myNodeName))
            {
               // a modification has occured externally while we were the owner
               //
               this.ownedObjectExternallyModified(appName, session.getKey(), existing, session);
            }
           
            existing.update(session);
         }
         finally
         {
            lock.unlock();
         }
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.