Examples of DistributableSessionMetadata


Examples of org.jboss.web.tomcat.service.session.distributedcache.spi.DistributableSessionMetadata

     
      testee.clear();
     
      int existing = testee.getSize();
     
      DistributableSessionMetadata md = new DistributableSessionMetadata();
      String id = nextId();
      md.setId(id + ".full");
      md.setCreationTime(System.currentTimeMillis());
      md.setNew(true);
      md.setValid(true);
      md.setMaxInactiveInterval(2);
      Long ts = Long.valueOf(md.getCreationTime() + 1);
      Map<String, Object> attrs = new HashMap<String, Object>();
      attrs.put("key", "value");
      OutgoingSessionGranularitySessionData sessionData = new MockOutgoingSessionData(id, 0, ts, md, attrs);
      testee.storeSessionData(sessionData);
     
View Full Code Here

Examples of org.jboss.web.tomcat.service.session.distributedcache.spi.DistributableSessionMetadata

               if (getLogger().isTraceEnabled())
               {
                  getLogger().trace("Loading session " + maskId(realId));
               }

               DistributableSessionMetadata metadata = new DistributableSessionMetadata();

               metadata.setId(rst.getString(1));
               metadata.setCreationTime(rst.getLong(2));
               String isNew = rst.getString(3);
               metadata.setNew("1".equals(isNew));
               metadata.setMaxInactiveInterval(rst.getInt(4));
               String valid = rst.getString(7);
               metadata.setValid("1".equals(valid));
//               metadata.setValid(true);

               Integer version = Integer.valueOf(rst.getInt(5));
               Long timestamp = Long.valueOf(rst.getLong(6));
View Full Code Here

Examples of org.jboss.web.tomcat.service.session.distributedcache.spi.DistributableSessionMetadata

         try
         {
            byte[] obs = writeSessionAttributes(sessionData);

            DistributableSessionMetadata metadata = sessionData.getMetadata();
            if (metadata != null && metadata.isNew())
            {
               try
               {
                  executeInsert(sessionData, obs, _conn);
               }
View Full Code Here

Examples of org.jboss.web.tomcat.service.session.distributedcache.spi.DistributableSessionMetadata

      if (obs == null)
      {
         obs = this.emptyAttributes;
      }

      DistributableSessionMetadata metadata = session.getMetadata();
      if (metadata == null)
      {
         throw new IllegalStateException("Cannot insert session " + maskId(session) + " as session metadata is missing");
      }

      int size = obs.length;
      ByteArrayInputStream bis = new ByteArrayInputStream(obs);
      InputStream in = new BufferedInputStream(bis, size);

      try
      {
         PreparedStatement preparedInsertSql = prepareStatement(conn, getInsertSql());
         preparedInsertSql.setString(1, getName());
         preparedInsertSql.setString(2, session.getRealId());
         preparedInsertSql.setString(3, metadata.getId());
         preparedInsertSql.setLong(4, metadata.getCreationTime());
         preparedInsertSql.setString(5, metadata.isNew() ? "1" : "0");
         preparedInsertSql.setInt(6, metadata.getMaxInactiveInterval());
         preparedInsertSql.setInt(7, session.getVersion());
         preparedInsertSql.setLong(8, session.getTimestamp());
         preparedInsertSql.setString(9, metadata.isValid() ? "1" : "0");
         preparedInsertSql.setBinaryStream(10, in, size);
         preparedInsertSql.execute();
      }
      finally
      {
View Full Code Here

Examples of org.jboss.web.tomcat.service.session.distributedcache.spi.DistributableSessionMetadata

   }

   private int executeReInsert(OutgoingSessionGranularitySessionData session, byte[] obs, Connection conn)
         throws SQLException, IOException
   {
      DistributableSessionMetadata metadata = session.getMetadata();
      int size = obs.length;
      InputStream in = null;
      if (obs != null)
      {
         ByteArrayInputStream bis = new ByteArrayInputStream(obs);
         in = new BufferedInputStream(bis, size);
      }

      try
      {
         PreparedStatement preparedUpdateSql = prepareStatement(conn, getReInsertSql());
         preparedUpdateSql.setInt(1, session.getVersion());
         preparedUpdateSql.setLong(2, session.getTimestamp());
         preparedUpdateSql.setString(3, metadata.getId());
         preparedUpdateSql.setString(4, metadata.isNew() ? "1" : "0");
         preparedUpdateSql.setInt(5, metadata.getMaxInactiveInterval());
         preparedUpdateSql.setString(6, metadata.isValid() ? "1" : "0");
         preparedUpdateSql.setBinaryStream(7, in, size);
         preparedUpdateSql.setLong(8, metadata.getCreationTime());

         // Add in the WHERE clause params
         preparedUpdateSql.setString(9, session.getRealId());
         preparedUpdateSql.setString(10, getName());
         int count = preparedUpdateSql.executeUpdate();
View Full Code Here

Examples of org.jboss.web.tomcat.service.session.distributedcache.spi.DistributableSessionMetadata

   }

   private int executeUpdate(OutgoingSessionGranularitySessionData session, byte[] obs, Connection conn)
         throws SQLException, IOException
   {
      DistributableSessionMetadata metadata = session.getMetadata();
      int size = obs == null ? -1 : obs.length;
      InputStream in = null;
      if (obs != null)
      {
         ByteArrayInputStream bis = new ByteArrayInputStream(obs);
         in = new BufferedInputStream(bis, size);
      }

      try
      {
         PreparedStatement preparedUpdateSql = null;
         int idParam = -1; // first parameter in the WHERE clause
         if (metadata != null)
         {
            if (obs != null)
            {
               preparedUpdateSql = prepareStatement(conn, getFullUpdateSql());
               preparedUpdateSql.setBinaryStream(7, in, size);
               idParam = 8;
            }
            else
            {
               preparedUpdateSql = prepareStatement(conn, getMetadataUpdateSql());
               idParam = 7;
            }

            preparedUpdateSql.setString(3, metadata.getId());
            preparedUpdateSql.setString(4, metadata.isNew() ? "1" : "0");
            preparedUpdateSql.setInt(5, metadata.getMaxInactiveInterval());
            preparedUpdateSql.setString(6, metadata.isValid() ? "1" : "0");
         }
         else if (obs != null)
         {
            preparedUpdateSql = prepareStatement(conn, getAttributeUpdateSql());
            preparedUpdateSql.setBinaryStream(3, in, size);
View Full Code Here

Examples of org.jboss.web.tomcat.service.session.distributedcache.spi.DistributableSessionMetadata

         {
            String realId = entry.getKey();
            String owner = entry.getValue();

            long ts = -1;
            DistributableSessionMetadata md = null;
            try
            {
               IncomingDistributableSessionData sessionData = proxy_.getSessionData(realId, owner, false);
               if (sessionData == null)
               {
                  log_.debug("Metadata unavailable for unloaded session " + realId);
                  continue;
               }
               ts = sessionData.getTimestamp();
               md = sessionData.getMetadata();
            }
            catch (Exception e)
            {
               // most likely a lock conflict if the session is being updated remotely;
               // ignore it and use default values for timstamp and maxInactive
               log_.debug("Problem reading metadata for session " + realId + " -- " + e.toString(), e);              
            }
           
            long lastMod = ts == -1 ? System.currentTimeMillis() : ts;
            int maxLife = md == null ? getMaxInactiveInterval() : md.getMaxInactiveInterval();
           
            OwnedSessionUpdate osu = new OwnedSessionUpdate(owner, lastMod, maxLife, false);
            unloadedSessions_.put(realId, osu);
         }
        
View Full Code Here

Examples of org.jboss.web.tomcat.service.session.distributedcache.spi.DistributableSessionMetadata

   @Override
   protected OutgoingSessionGranularitySessionData getOutgoingSessionData()
   {
      Map<String, Object> attrs = isSessionAttributeMapDirty() ? getSessionAttributeMap() : null;
      DistributableSessionMetadata metadata = isSessionMetadataDirty() ? getSessionMetadata() : null;
      Long timestamp = attrs != null || metadata != null || getMustReplicateTimestamp() ? Long.valueOf(getSessionTimestamp()) : null;
      return new OutgoingData(getRealId(), getVersion(), timestamp, metadata, attrs);
   }
View Full Code Here

Examples of org.jboss.web.tomcat.service.session.distributedcache.spi.DistributableSessionMetadata

   {
      testee.start();
     
      int existing = testee.getSize();
     
      DistributableSessionMetadata md = new DistributableSessionMetadata();
      String id = nextId();
      md.setId(id + ".full");
      md.setCreationTime(System.currentTimeMillis());
      md.setNew(true);
      md.setValid(true);
      md.setMaxInactiveInterval(30000);
      Long ts = Long.valueOf(md.getCreationTime() + 1);
      Map<String, Object> attrs = new HashMap<String, Object>();
      attrs.put("key", "value");
      OutgoingSessionGranularitySessionData sessionData = new MockOutgoingSessionData(id, 0, ts, md, attrs);
      testee.storeSessionData(sessionData);
     
      assertEquals(Integer.valueOf(0), testee.getSessionVersion(id));
     
      md = new DistributableSessionMetadata();
      String id2 = nextId();
      md.setId(id2 + ".full");
      md.setCreationTime(System.currentTimeMillis());
      md.setNew(true);
      md.setValid(true);
      md.setMaxInactiveInterval(30000);
      ts = Long.valueOf(md.getCreationTime() + 1);
      attrs = new HashMap<String, Object>();
      attrs.put("key", "value");
      sessionData = new MockOutgoingSessionData(id2, 0, ts, md, attrs);
      testee.storeSessionData(sessionData);
     
View Full Code Here

Examples of org.jboss.web.tomcat.service.session.distributedcache.spi.DistributableSessionMetadata

    * Test method for {@link org.jboss.web.tomcat.service.session.persistent.RDBMSStoreBase#getSessionIds()}.
    */
   public void testGetSessionIds()
   {
      testee.start();
      DistributableSessionMetadata md = new DistributableSessionMetadata();
      String id = nextId();
      md.setId(id + ".full");
      md.setCreationTime(System.currentTimeMillis());
      md.setNew(true);
      md.setValid(true);
      md.setMaxInactiveInterval(30000);
      Long ts = Long.valueOf(md.getCreationTime() + 1);
      Map<String, Object> attrs = new HashMap<String, Object>();
      attrs.put("key", "value");
      OutgoingSessionGranularitySessionData sessionData = new MockOutgoingSessionData(id, 0, ts, md, attrs);
      testee.storeSessionData(sessionData);
     
      md = new DistributableSessionMetadata();
      String id2 = nextId();
      md.setId(id2 + ".full");
      md.setCreationTime(System.currentTimeMillis());
      md.setNew(true);
      md.setValid(true);
      md.setMaxInactiveInterval(30000);
      ts = Long.valueOf(md.getCreationTime() + 1);
      attrs = new HashMap<String, Object>();
      attrs.put("key", "value");
      sessionData = new MockOutgoingSessionData(id2, 0, ts, md, attrs);
      testee.storeSessionData(sessionData);
     
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.