I get what appears to me to be incorrect session handling when the Apache
Wicket session size of my application approaches my self-imposed limit of
900kB (which itself is near the Google App Engine (GAE) limit of 1MB).

I see flash messages set during the composition of a web response using

  org.apache.wicket.Session#info(Serializable message)

occur again after the subsequent web response, even though no flash message
was set subsequently.

I believe that this effect might be due to the large session size and
either:

  ·  the Wicket app's interplay of:
     ·  IStoreSettings#setMaxSizePerSession(...)
     ·  DefaultPageManagerProvider
     ·  MemorySizeEvictionStrategy

  or

  ·  GAE's session handling

causing incorrect operation.

Has anyone else encountered this problem or does anyone have any suggestion
as to what I can do?



*My code*
public class MyApplication extends WebApplication
{

  ...

  // GAE has a maximum session size of 1MB
  private static final Bytes G_BY_MAXIMUM_SIZE_SESSION_PAGE_INSTANCES =
   Bytes.kilobytes(900);

  @Override
  protected void init()
  {
    super.init();

    ...

    IStoreSettings ssStoreSettings = getStoreSettings();
    ssStoreSettings.setMaxSizePerSession(
     G_BY_MAXIMUM_SIZE_SESSION_PAGE_INSTANCES);

    // This prevents use of a new AsynchronousDataStore instance,
    // which attempts to start a new thread. This is forbidden by GAE.
    ssStoreSettings.setAsynchronous(false);

    IPageManagerContext pmcPageManagerContext = getPageManagerContext();
    DataStoreEvictionStrategy dsevEvictionStrategy =
     new
MemorySizeEvictionStrategy(G_BY_MAXIMUM_SIZE_SESSION_PAGE_INSTANCES);
    GaePageManagerProvider pmpPageManagerProvider = new
GaePageManagerProvider(
     this, pmcPageManagerContext, dsevEvictionStrategy);
    setPageManagerProvider(pmpPageManagerProvider);

    ...
  }

  ...
}


...


/**
 * This class extends <code>DefaultPageManagerProvider</code> as required to
 * conform to Google App Engine restrictions.
 */
public class GaePageManagerProvider extends DefaultPageManagerProvider
{
  private static final Logger m_logger = Logger.getLogger(
   GaePageManagerProvider.class.getName());

  private IPageManagerContext m_pmcPageManagerContext = null;
  private DataStoreEvictionStrategy m_dsevEvictionStrategy = null;

  /**
   * The constructor.
   * @param app
   *   The instance of the application.
   *   This must not be <code>null</code>.
   * @param pmcPageManagerContext
   *   The application's page manager context.
   * @param dsevEvictionStrategy
   *   The data store eviction strategy to be used.
   */
  public GaePageManagerProvider(Application app,
   IPageManagerContext pmcPageManagerContext,
   DataStoreEvictionStrategy dsevEvictionStrategy)
  {
    super(app);
    m_pmcPageManagerContext = pmcPageManagerContext;
    m_dsevEvictionStrategy = dsevEvictionStrategy;
  }

  @Override
  protected IDataStore newDataStore()
  {
    IDataStore dsResult = null;

    dsResult = new HttpSessionDataStore(m_pmcPageManagerContext,
     m_dsevEvictionStrategy)
    {
      // This method override is for logging purposes only
      @Override
      public void storeData(String sessionId, int pageId,
       byte[] pageAsBytes)
      {
        int nPageSize = -1;
        if (pageAsBytes != null)
          nPageSize = pageAsBytes.length;

        final int N_SIZE_FINE    = 100000;
        final int N_SIZE_INFO    = 500000;
        final int N_SIZE_WARNING = 800000;
        if (nPageSize >= N_SIZE_FINE)
        {
          Level lvl;
          if (nPageSize >= N_SIZE_WARNING)
            lvl = Level.WARNING;
          else if (nPageSize >= N_SIZE_INFO)
            lvl = Level.INFO;
          else
            lvl = Level.FINE;

          m_logger.log(lvl, String.format("Storing a page in the"
           + " application's DefaultPageManagerProvider's"
           + " HttpSessionDataStore with parameters:"
           + "\n sessionId          = %s,"
           + "\n pageId             = %d,"
           + "\n pageAsBytes.length = %d", sessionId, pageId, nPageSize));
        }

        super.storeData(sessionId, pageId, pageAsBytes);
      }
    };

    return dsResult;
  }
}



*My development environment*
Java:             1.6.0_35; Java HotSpot(TM) Client VM 20.10-b01
GAE/J SDK:        1.7.2
Web framework:    Apache Wicket 1.5.8
Web browser:      Mozilla Firefox 15.0.1
Operating system: Windows XP version 5.1 running on x86; Cp1252; en_GB (nb)
IDE:              NetBeans 7.2 (build 201207171143)




--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Incorrect-session-handling-in-a-GAE-environment-tp4652636.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to