geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jensde...@apache.org
Subject [03/17] incubator-geode git commit: GEODE-14: Initial integration of gemfire-modules subproject
Date Tue, 22 Dec 2015 21:08:15 GMT
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/63bc5f03/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/bootstrap/PeerToPeerCache.java
----------------------------------------------------------------------
diff --git a/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/bootstrap/PeerToPeerCache.java b/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/bootstrap/PeerToPeerCache.java
deleted file mode 100644
index b3d1b41..0000000
--- a/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/bootstrap/PeerToPeerCache.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*=========================================================================
- * Copyright (c) 2010-2014 Pivotal Software, Inc. All Rights Reserved.
- * This product is protected by U.S. and international copyright
- * and intellectual property laws. Pivotal products are covered by
- * one or more patents listed at http://www.pivotal.io/patents.
- *=========================================================================
- */
-package com.gemstone.gemfire.modules.session.bootstrap;
-
-import com.gemstone.gemfire.cache.CacheClosedException;
-import com.gemstone.gemfire.cache.CacheFactory;
-import com.gemstone.gemfire.cache.control.RebalanceResults;
-import com.gemstone.gemfire.modules.util.RegionHelper;
-
-/**
- * This is a singleton class which maintains configuration properties as well as
- * starting a Peer-To-Peer cache.
- */
-
-public class PeerToPeerCache extends AbstractCache {
-
-  protected static final String DEFAULT_CACHE_XML_FILE_NAME = "cache-peer.xml";
-
-  static {
-    instance = new PeerToPeerCache();
-  }
-
-  private PeerToPeerCache() {
-    // Singleton
-    super();
-  }
-
-  public static AbstractCache getInstance() {
-    return instance;
-  }
-
-  @Override
-  protected void createOrRetrieveCache() {
-    if (getLogger().isDebugEnabled()) {
-      getLogger().debug("Creating cache");
-    }
-    // Get the existing cache if any
-    try {
-      this.cache = CacheFactory.getAnyInstance();
-    } catch (CacheClosedException e) {
-    }
-
-    // If no cache exists, create one
-    String message = null;
-    if (this.cache == null) {
-      this.cache = new CacheFactory(
-          createDistributedSystemProperties()).create();
-      message = "Created ";
-    } else {
-      message = "Retrieved ";
-    }
-    getLogger().info(message + this.cache);
-  }
-
-  @Override
-  protected void rebalanceCache() {
-    try {
-      getLogger().info("Rebalancing: " + this.cache);
-      RebalanceResults results = RegionHelper.rebalanceCache(this.cache);
-      if (getLogger().isDebugEnabled()) {
-        getLogger().debug("Done rebalancing: " + this.cache);
-        getLogger().debug(RegionHelper.getRebalanceResultsMessage(results));
-      }
-    } catch (Exception e) {
-      getLogger().warn("Rebalance failed because of the following exception:",
-          e);
-    }
-  }
-
-  @Override
-  protected String getDefaultCacheXmlFileName() {
-    return DEFAULT_CACHE_XML_FILE_NAME;
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/63bc5f03/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/AbstractCacheLifecycleListener.java
----------------------------------------------------------------------
diff --git a/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/AbstractCacheLifecycleListener.java b/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/AbstractCacheLifecycleListener.java
deleted file mode 100644
index a6710b7..0000000
--- a/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/AbstractCacheLifecycleListener.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*=========================================================================
- * Copyright (c) 2010-2014 Pivotal Software, Inc. All Rights Reserved.
- * This product is protected by U.S. and international copyright
- * and intellectual property laws. Pivotal products are covered by
- * one or more patents listed at http://www.pivotal.io/patents.
- *=========================================================================
- */
-package com.gemstone.gemfire.modules.session.catalina;
-
-
-import com.gemstone.gemfire.modules.session.bootstrap.AbstractCache;
-import com.gemstone.gemfire.modules.session.bootstrap.LifecycleTypeAdapter;
-import org.apache.catalina.LifecycleEvent;
-import org.apache.catalina.LifecycleListener;
-
-
-public abstract class AbstractCacheLifecycleListener implements LifecycleListener {
-  protected AbstractCache cache;
-    
-  @Override
-  public void lifecycleEvent(LifecycleEvent le) {
-    cache.lifecycleEvent(LifecycleTypeAdapter.valueOf(le.getType().toUpperCase()));
-  }
-
-  /**
-   * This is called by Tomcat to set properties on the Listener.
-   */
-  public void setProperty(String name, String value) {
-    cache.setProperty(name, value);
-  }
-
-  /*
-   * These getters and setters are also called by Tomcat and just passed on to
-   * the cache.
-   */
-  public float getEvictionHeapPercentage() {
-    return cache.getEvictionHeapPercentage();
-  }
-
-  public void setEvictionHeapPercentage(String evictionHeapPercentage) {
-    cache.setEvictionHeapPercentage(evictionHeapPercentage);
-  }
-
-  public float getCriticalHeapPercentage() {
-    return cache.getCriticalHeapPercentage();
-  }
-
-  public void setCriticalHeapPercentage(String criticalHeapPercentage) {
-    cache.setCriticalHeapPercentage(criticalHeapPercentage);
-  }
-  
-  public void setRebalance(boolean rebalance) {
-    cache.setRebalance(rebalance);
-  }
-  
-  public boolean getRebalance() {
-    return cache.getRebalance();
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/63bc5f03/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/AbstractSessionCache.java
----------------------------------------------------------------------
diff --git a/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/AbstractSessionCache.java b/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/AbstractSessionCache.java
deleted file mode 100644
index 151eb0d..0000000
--- a/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/AbstractSessionCache.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*=========================================================================
- * Copyright (c) 2010-2014 Pivotal Software, Inc. All Rights Reserved.
- * This product is protected by U.S. and international copyright
- * and intellectual property laws. Pivotal products are covered by
- * one or more patents listed at http://www.pivotal.io/patents.
- *=========================================================================
- */
-package com.gemstone.gemfire.modules.session.catalina;
-
-import com.gemstone.gemfire.cache.EntryNotFoundException;
-import org.apache.catalina.Session;
-
-import com.gemstone.gemfire.cache.Region;
-import com.gemstone.gemfire.modules.session.catalina.internal.DeltaSessionStatistics;
-import com.gemstone.gemfire.modules.util.RegionConfiguration;
-import com.gemstone.gemfire.modules.util.SessionCustomExpiry;
-import javax.servlet.http.HttpSession;
-
-public abstract class AbstractSessionCache implements SessionCache {
-  
-  protected SessionManager sessionManager;
-  
-  /**
-   * The sessionRegion is the <code>Region</code> that actually stores and
-   * replicates the <code>Session</code>s.
-   */
-  protected Region<String,HttpSession> sessionRegion;
-
-  /**
-   * The operatingRegion is the <code>Region</code> used to do HTTP operations.
-   * if local cache is enabled, then this will be the local <code>Region</code>;
-   * otherwise, it will be the session <code>Region</code>.
-   */
-  protected Region<String,HttpSession> operatingRegion;
-
-  protected DeltaSessionStatistics statistics;
-  
-  public AbstractSessionCache(SessionManager sessionManager) {
-    this.sessionManager = sessionManager;
-  }
-  
-  @Override
-  public String getSessionRegionName() {
-    return getSessionRegion().getFullPath();
-  }
-  
-  @Override
-  public String getOperatingRegionName() {
-    return getOperatingRegion().getFullPath();
-  }
-  
-  @Override
-  public void putSession(Session session) {
-    getOperatingRegion().put(session.getId(), (HttpSession)session);
-  }
-
-  @Override
-  public HttpSession getSession(String sessionId) {
-    return getOperatingRegion().get(sessionId);
-  }
-  
-  @Override
-  public void destroySession(String sessionId) {
-    try {
-      getOperatingRegion().destroy(sessionId);
-    } catch (EntryNotFoundException enex) {
-      // Ignored
-    }
-  }
-  
-  @Override
-  public DeltaSessionStatistics getStatistics() {
-    return this.statistics;
-  }
-  
-  protected SessionManager getSessionManager() {
-    return this.sessionManager;
-  }
-
-  public Region<String,HttpSession> getSessionRegion() {
-    return this.sessionRegion;
-  }
-
-  public Region<String,HttpSession> getOperatingRegion() {
-    return this.operatingRegion;
-  }
-
-  protected void createStatistics() {
-    this.statistics = new DeltaSessionStatistics(getCache().getDistributedSystem(), getSessionManager().getStatisticsName());
-  }
-
-  protected RegionConfiguration createRegionConfiguration() {
-    RegionConfiguration configuration = new RegionConfiguration();
-    configuration.setRegionName(getSessionManager().getRegionName());
-    configuration.setRegionAttributesId(getSessionManager().getRegionAttributesId());
-    if (getSessionManager().getMaxInactiveInterval() != RegionConfiguration.DEFAULT_MAX_INACTIVE_INTERVAL) {
-      configuration.setMaxInactiveInterval(getSessionManager().getMaxInactiveInterval());
-      configuration.setCustomExpiry(new SessionCustomExpiry());
-    }
-    configuration.setEnableGatewayDeltaReplication(getSessionManager().getEnableGatewayDeltaReplication());
-    configuration.setEnableGatewayReplication(getSessionManager().getEnableGatewayReplication());
-    configuration.setEnableDebugListener(getSessionManager().getEnableDebugListener());
-    return configuration;
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/63bc5f03/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/ClientServerCacheLifecycleListener.java
----------------------------------------------------------------------
diff --git a/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/ClientServerCacheLifecycleListener.java b/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/ClientServerCacheLifecycleListener.java
deleted file mode 100644
index 5541b72..0000000
--- a/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/ClientServerCacheLifecycleListener.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package com.gemstone.gemfire.modules.session.catalina;
-
-import com.gemstone.gemfire.modules.session.bootstrap.ClientServerCache;
-
-public class ClientServerCacheLifecycleListener extends AbstractCacheLifecycleListener {
-
-  public ClientServerCacheLifecycleListener() {
-    cache = ClientServerCache.getInstance();
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/63bc5f03/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/ClientServerSessionCache.java
----------------------------------------------------------------------
diff --git a/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/ClientServerSessionCache.java b/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/ClientServerSessionCache.java
deleted file mode 100644
index fa23519..0000000
--- a/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/ClientServerSessionCache.java
+++ /dev/null
@@ -1,247 +0,0 @@
-/*=========================================================================
- * Copyright (c) 2010-2014 Pivotal Software, Inc. All Rights Reserved.
- * This product is protected by U.S. and international copyright
- * and intellectual property laws. Pivotal products are covered by
- * one or more patents listed at http://www.pivotal.io/patents.
- *=========================================================================
- */
-package com.gemstone.gemfire.modules.session.catalina;
-
-import java.lang.IllegalStateException;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import com.gemstone.gemfire.cache.InterestResultPolicy;
-import com.gemstone.gemfire.cache.client.PoolManager;
-import com.gemstone.gemfire.cache.client.internal.PoolImpl;
-
-import com.gemstone.gemfire.cache.GemFireCache;
-import com.gemstone.gemfire.cache.Region;
-import com.gemstone.gemfire.cache.RegionShortcut;
-import com.gemstone.gemfire.cache.client.ClientCache;
-import com.gemstone.gemfire.cache.client.ClientRegionFactory;
-import com.gemstone.gemfire.cache.client.ClientRegionShortcut;
-import com.gemstone.gemfire.cache.execute.Execution;
-import com.gemstone.gemfire.cache.execute.FunctionService;
-import com.gemstone.gemfire.cache.execute.ResultCollector;
-import com.gemstone.gemfire.modules.session.catalina.callback.SessionExpirationCacheListener;
-import com.gemstone.gemfire.modules.util.BootstrappingFunction;
-import com.gemstone.gemfire.modules.util.CreateRegionFunction;
-import com.gemstone.gemfire.modules.util.RegionConfiguration;
-import com.gemstone.gemfire.modules.util.RegionSizeFunction;
-import com.gemstone.gemfire.modules.util.RegionStatus;
-import com.gemstone.gemfire.modules.util.SessionCustomExpiry;
-import com.gemstone.gemfire.modules.util.TouchPartitionedRegionEntriesFunction;
-import com.gemstone.gemfire.modules.util.TouchReplicatedRegionEntriesFunction;
-
-import javax.servlet.http.HttpSession;
-
-public class ClientServerSessionCache extends AbstractSessionCache {
-
-  private ClientCache cache;
-  
-  protected static final String DEFAULT_REGION_ATTRIBUTES_ID = RegionShortcut.PARTITION_REDUNDANT.toString();
-
-  protected static final boolean DEFAULT_ENABLE_LOCAL_CACHE = true;
-
-  public ClientServerSessionCache(SessionManager sessionManager, ClientCache cache) {
-    super(sessionManager);
-    this.cache = cache;
-  }
-
-  @Override
-  public void initialize() {
-    // Bootstrap the servers
-    bootstrapServers();
-    
-    // Create or retrieve the region
-    try {
-      createOrRetrieveRegion();
-    } catch (Exception ex) {
-      sessionManager.getLogger().fatal("Unable to create or retrieve region", ex);
-      throw new IllegalStateException(ex);
-    }
-    
-    // Set the session region directly as the operating region since there is no difference
-    // between the local cache region and the session region.
-    this.operatingRegion = this.sessionRegion;
-
-    // Create or retrieve the statistics
-    createStatistics();
-  }
-  
-  @Override
-  public String getDefaultRegionAttributesId() {
-    return DEFAULT_REGION_ATTRIBUTES_ID;
-  }
-  
-  @Override
-  public boolean getDefaultEnableLocalCache() {
-    return DEFAULT_ENABLE_LOCAL_CACHE;
-  }
-
-  @Override
-  public void touchSessions(Set<String> sessionIds) {
-    // Get the region attributes id to determine the region type. This is
-    // problematic since the region attributes id doesn't really define the
-    // region type. Currently there is no way to know the type of region created
-    // on the server. Maybe the CreateRegionFunction should return it.
-    String regionAttributesID = getSessionManager().getRegionAttributesId().toLowerCase();
-
-    // Invoke the appropriate function depending on the type of region
-    if (regionAttributesID.startsWith("partition")) {
-      // Execute the partitioned touch function on the primary server(s)
-      Execution execution = FunctionService.onRegion(getSessionRegion()).withFilter(sessionIds);
-      try {
-        ResultCollector collector = execution.execute(TouchPartitionedRegionEntriesFunction.ID, true, false, true);
-        collector.getResult();
-      } catch (Exception e) {
-        // If an exception occurs in the function, log it.
-        getSessionManager().getLogger().warn("Caught unexpected exception:", e);
-      }
-    } else {
-      // Execute the member touch function on all the server(s)
-      Execution execution = FunctionService.onServers(getCache()).withArgs(
-          new Object[] {this.sessionRegion.getFullPath(), sessionIds});
-      try {
-        ResultCollector collector = execution.execute(TouchReplicatedRegionEntriesFunction.ID, true, false, false);
-        collector.getResult();
-      } catch (Exception e) {
-        // If an exception occurs in the function, log it.
-        getSessionManager().getLogger().warn("Caught unexpected exception:", e);
-      }
-    }
-  }
-  
-  @Override
-  public boolean isPeerToPeer() {
-    return false;
-  }
-  
-  @Override
-  public boolean isClientServer() {
-    return true;
-  }
-
-  @Override
-  public Set<String> keySet() {
-    return getSessionRegion().keySetOnServer();
-  }
-  
-  @Override
-  public int size() {
-  	// Add a single dummy key to force the function to go to one server
-    Set<String> filters = new HashSet<String>();
-    filters.add("test-key");
-    
-    // Execute the function on the session region
-    Execution execution = FunctionService.onRegion(getSessionRegion()).withFilter(filters);
-    ResultCollector collector = execution.execute(RegionSizeFunction.ID, true, true, true);
-    List<Integer> result = (List<Integer>) collector.getResult();
-    
-    // Return the first (and only) element
-    return result.get(0);
-  }
-
-  @Override
-  public boolean isBackingCacheAvailable() {
-    if (getSessionManager().isCommitValveFailfastEnabled()) {
-      PoolImpl pool = (PoolImpl) PoolManager.find(getOperatingRegionName());
-      return pool.isPrimaryUpdaterAlive();
-    }
-    return true;
-  }
-
-  public GemFireCache getCache() {
-    return this.cache;
-  }
-  
-  private void bootstrapServers() {
-    Execution execution = FunctionService.onServers(this.cache);
-    ResultCollector collector = execution.execute(new BootstrappingFunction());
-    // Get the result. Nothing is being done with it.
-    try {
-      collector.getResult();
-    } catch (Exception e) {
-      // If an exception occurs in the function, log it.
-      getSessionManager().getLogger().warn("Caught unexpected exception:", e);
-    }
-  }
-
-  protected void createOrRetrieveRegion() {
-    // Retrieve the local session region
-    this.sessionRegion = this.cache.getRegion(getSessionManager().getRegionName());
-
-    // If necessary, create the regions on the server and client
-    if (this.sessionRegion == null) {
-      // Create the PR on the servers
-      createSessionRegionOnServers();
-      
-      // Create the region on the client
-      this.sessionRegion = createLocalSessionRegion();
-      if (getSessionManager().getLogger().isDebugEnabled()) {
-        getSessionManager().getLogger().debug("Created session region: " + this.sessionRegion);
-      }
-    } else {
-      if (getSessionManager().getLogger().isDebugEnabled()) {
-        getSessionManager().getLogger().debug("Retrieved session region: " + this.sessionRegion);
-      }
-    }
-  }
-
-  private void createSessionRegionOnServers() {
-    // Create the RegionConfiguration
-    RegionConfiguration configuration = createRegionConfiguration();
-    
-    // Send it to the server tier
-    Execution execution = FunctionService.onServer(this.cache).withArgs(configuration);
-    ResultCollector collector = execution.execute(CreateRegionFunction.ID);
-    
-    // Verify the region was successfully created on the servers
-    List<RegionStatus> results = (List<RegionStatus>) collector.getResult();
-    for (RegionStatus status : results) {
-      if (status == RegionStatus.INVALID) {
-        StringBuilder builder = new StringBuilder();
-        builder
-          .append("An exception occurred on the server while attempting to create or validate region named ")
-          .append(getSessionManager().getRegionName())
-          .append(". See the server log for additional details.");
-        throw new IllegalStateException(builder.toString());
-      }
-    }
-  }
-  
-  private Region<String,HttpSession> createLocalSessionRegion() {
-    ClientRegionFactory<String,HttpSession> factory = null;
-    if (getSessionManager().getEnableLocalCache()) {
-      // Create the region factory with caching and heap LRU enabled
-      factory = this.cache.createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY_HEAP_LRU);
-  
-      // Set the expiration time, action and listener if necessary
-      int maxInactiveInterval = getSessionManager().getMaxInactiveInterval();
-      if (maxInactiveInterval != RegionConfiguration.DEFAULT_MAX_INACTIVE_INTERVAL) {
-        factory.setStatisticsEnabled(true);
-        factory.setCustomEntryIdleTimeout(new SessionCustomExpiry());
-        factory.addCacheListener(new SessionExpirationCacheListener());
-      }
-    } else {
-      // Create the region factory without caching enabled
-      factory = this.cache.createClientRegionFactory(ClientRegionShortcut.PROXY);
-      factory.addCacheListener(new SessionExpirationCacheListener());
-    }
-
-    // Create the region
-    Region region = factory.create(getSessionManager().getRegionName());
-
-    /*
-     * If we're using an empty client region, we register interest so that
-     * expired sessions are destroyed correctly.
-     */
-    if (! getSessionManager().getEnableLocalCache()) {
-      region.registerInterest("ALL_KEYS", InterestResultPolicy.KEYS);
-    }
-
-    return region;
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/63bc5f03/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/CommitSessionValve.java
----------------------------------------------------------------------
diff --git a/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/CommitSessionValve.java b/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/CommitSessionValve.java
deleted file mode 100644
index da5ca44..0000000
--- a/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/CommitSessionValve.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*=========================================================================
- * Copyright (c) 2010-2014 Pivotal Software, Inc. All Rights Reserved.
- * This product is protected by U.S. and international copyright
- * and intellectual property laws. Pivotal products are covered by
- * one or more patents listed at http://www.pivotal.io/patents.
- *=========================================================================
- */
-package com.gemstone.gemfire.modules.session.catalina;
-
-import java.io.IOException;
-
-import javax.servlet.ServletException;
-
-import org.apache.catalina.Manager;
-import org.apache.catalina.connector.Request;
-import org.apache.catalina.connector.Response;
-import org.apache.catalina.valves.ValveBase;
-import org.apache.juli.logging.Log;
-import org.apache.juli.logging.LogFactory;
-
-public class CommitSessionValve extends ValveBase {
-  
-  private static final Log log = LogFactory.getLog(CommitSessionValve.class);
-
-  protected static final String info = "com.gemstone.gemfire.modules.session.catalina.CommitSessionValve/1.0";
-
-  public CommitSessionValve() {
-    log.info("Initialized");
-  }
-
-  @Override
-  public void invoke(Request request, Response response) throws IOException,
-      ServletException {
-    // Get the Manager
-    Manager manager = request.getContext().getManager();
-    DeltaSessionFacade session = null;
-    
-    // Invoke the next Valve
-    try {
-      getNext().invoke(request, response);
-    } finally {
-      // Commit and if the correct Manager was found
-      if (manager instanceof DeltaSessionManager) {
-        session = (DeltaSessionFacade)request.getSession(false);
-        if (session != null) {
-          if (session.isValid()) {
-            ((DeltaSessionManager) manager).removeTouchedSession(session.getId());
-            session.commit();
-            if (manager.getContainer().getLogger().isDebugEnabled()) {
-              manager.getContainer().getLogger().debug(session + ": Committed.");
-            }
-          } else {
-            if (manager.getContainer().getLogger().isDebugEnabled()) {
-              manager.getContainer().getLogger().debug(
-                  session + ": Not valid so not committing.");
-            }
-          }
-        }
-      }
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/63bc5f03/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/DeltaSession.java
----------------------------------------------------------------------
diff --git a/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/DeltaSession.java b/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/DeltaSession.java
deleted file mode 100644
index 007ab95..0000000
--- a/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/DeltaSession.java
+++ /dev/null
@@ -1,597 +0,0 @@
-/*=========================================================================
- * Copyright (c) 2010-2014 Pivotal Software, Inc. All Rights Reserved.
- * This product is protected by U.S. and international copyright
- * and intellectual property laws. Pivotal products are covered by
- * one or more patents listed at http://www.pivotal.io/patents.
- *=========================================================================
- */
-package com.gemstone.gemfire.modules.session.catalina;
-
-import java.io.DataInput;
-import java.io.DataOutput;
-import java.io.IOException;
-import java.io.InputStream;
-import java.security.AccessController;
-import java.security.Principal;
-import java.security.PrivilegedAction;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import javax.servlet.http.HttpSession;
-
-import com.gemstone.gemfire.internal.cache.lru.Sizeable;
-import org.apache.catalina.Manager;
-import org.apache.catalina.ha.session.SerializablePrincipal;
-import org.apache.catalina.realm.GenericPrincipal;
-import org.apache.catalina.security.SecurityUtil;
-import org.apache.catalina.session.StandardSession;
-
-import com.gemstone.gemfire.DataSerializable;
-import com.gemstone.gemfire.DataSerializer;
-import com.gemstone.gemfire.Delta;
-import com.gemstone.gemfire.InvalidDeltaException;
-import com.gemstone.gemfire.cache.Region;
-import com.gemstone.gemfire.internal.util.BlobHelper;
-import com.gemstone.gemfire.modules.gatewaydelta.GatewayDelta;
-import com.gemstone.gemfire.modules.gatewaydelta.GatewayDeltaEvent;
-import com.gemstone.gemfire.modules.session.catalina.internal.DeltaSessionAttributeEvent;
-import com.gemstone.gemfire.modules.session.catalina.internal.DeltaSessionAttributeEventBatch;
-import com.gemstone.gemfire.modules.session.catalina.internal.DeltaSessionDestroyAttributeEvent;
-import com.gemstone.gemfire.modules.session.catalina.internal.DeltaSessionUpdateAttributeEvent;
-import org.apache.juli.logging.Log;
-import org.apache.juli.logging.LogFactory;
-
-@SuppressWarnings("serial")
-public class DeltaSession extends StandardSession implements DataSerializable, Delta, GatewayDelta, Sizeable {
-  
-  private transient Region<String,HttpSession> operatingRegion;
-  
-  private String sessionRegionName;
-
-  private String contextName;
-
-  private boolean hasDelta;
-  
-  private boolean applyRemotely;
-  
-  private boolean enableGatewayDeltaReplication;
-
-  private transient final Object changeLock = new Object();
-  
-  private final List<DeltaSessionAttributeEvent> eventQueue = new ArrayList<DeltaSessionAttributeEvent>();
-  
-  private transient GatewayDeltaEvent currentGatewayDeltaEvent;
-  
-  private transient boolean expired = false;
-
-  private transient boolean preferDeserializedForm = true;
-  
-  private byte[] serializedPrincipal;
-
-  private final Log LOG = LogFactory.getLog(DeltaSession.class.getName());
-  
-  /**
-   * The string manager for this package.
-   */
-//  protected static StringManager STRING_MANAGER =
-//    StringManager.getManager("com.gemstone.gemfire.modules.session.catalina");
-
-  /**
-   * Construct a new <code>Session</code> associated with no
-   * <code>Manager</code>. The <code>Manager</code> will be assigned later using
-   * {@link #setOwner(Object)}.
-   */
-  public DeltaSession() {
-    super(null);
-  }
-
-  /**
-   * Construct a new Session associated with the specified Manager.
-   * 
-   * @param manager
-   *          The manager with which this Session is associated
-   */
-  public DeltaSession(Manager manager) {
-    super(manager);
-    setOwner(manager);
-  }
-  
-  /**
-   * Return the <code>HttpSession</code> for which this object
-   * is the facade.
-   */
-  @SuppressWarnings("unchecked")
-  public HttpSession getSession() {
-    if (facade == null) {
-      if (SecurityUtil.isPackageProtectionEnabled()) {
-        final DeltaSession fsession = this;
-        facade = (DeltaSessionFacade) AccessController
-            .doPrivileged(new PrivilegedAction() {
-              public Object run() {
-                return new DeltaSessionFacade(fsession);
-              }
-            });
-      } else {
-        facade = new DeltaSessionFacade(this);
-      }
-    }
-    return (facade);
-  }
-  
-  public Principal getPrincipal() {
-    if (this.principal == null && this.serializedPrincipal != null) {
-      SerializablePrincipal sp = null;
-      try {
-        sp = (SerializablePrincipal) BlobHelper.deserializeBlob(this.serializedPrincipal);
-      } catch (Exception e) {
-        StringBuilder builder = new StringBuilder();
-        builder
-          .append(this)
-          .append(": Serialized principal contains a byte[] that cannot be deserialized due to the following exception");
-        ((DeltaSessionManager) getManager()).getLogger().warn(builder.toString(), e);
-        return null;
-      }
-      this.principal = sp.getPrincipal(this.manager.getContainer().getRealm());
-      if (getManager() != null) {
-        DeltaSessionManager mgr = (DeltaSessionManager) getManager();
-        if (mgr.getLogger().isDebugEnabled()) {
-          mgr.getLogger().debug(this + ": Deserialized principal: " + this.principal);
-          //mgr.logCurrentStack();
-        }
-      }
-    }
-    return this.principal;
-  }
-
-  public void setPrincipal(Principal principal) {
-    super.setPrincipal(principal);
-
-    // Put the session into the region to serialize the principal
-    if (getManager() != null) {
-      // TODO convert this to a delta
-      getManager().add(this);
-      DeltaSessionManager mgr = (DeltaSessionManager) getManager();
-      if (mgr.getLogger().isDebugEnabled()) {
-        mgr.getLogger().debug(this + ": Cached principal: " + principal);
-        //mgr.logCurrentStack();
-      }
-    }
-  }
-
-  private byte[] getSerializedPrincipal() {
-    if (this.serializedPrincipal == null) {
-      if (this.principal != null && this.principal instanceof GenericPrincipal) {
-        GenericPrincipal gp = (GenericPrincipal) this.principal;
-        SerializablePrincipal sp = SerializablePrincipal.createPrincipal(gp);
-        this.serializedPrincipal = serialize(sp);
-        if (manager != null) {
-          DeltaSessionManager mgr = (DeltaSessionManager) getManager();
-          if (mgr.getLogger().isDebugEnabled()) {
-            mgr.getLogger().debug(this + ": Serialized principal: " + sp);
-            //mgr.logCurrentStack();
-          }
-        }
-      }
-    }
-    return this.serializedPrincipal;
-  }
-  
-  protected Region<String,HttpSession> getOperatingRegion() {
-    // This region shouldn't be null when it is needed.
-    // It should have been set by the setOwner method.
-    return this.operatingRegion;
-  }
-
-  public boolean isCommitEnabled() {
-    DeltaSessionManager mgr = (DeltaSessionManager) getManager();
-    return mgr.isCommitValveEnabled();
-  }
-
-  public GatewayDeltaEvent getCurrentGatewayDeltaEvent() {
-    return this.currentGatewayDeltaEvent;
-  }
- 
-  public void setCurrentGatewayDeltaEvent(GatewayDeltaEvent currentGatewayDeltaEvent) {
-    this.currentGatewayDeltaEvent = currentGatewayDeltaEvent;
-  }
-
-  @SuppressWarnings("unchecked")
-  public void setOwner(Object manager) {
-    if (manager instanceof DeltaSessionManager) {
-      DeltaSessionManager sessionManager = (DeltaSessionManager) manager;
-      this.manager = sessionManager;
-      initializeRegion(sessionManager);
-      this.hasDelta = false;
-      this.applyRemotely = false;
-      this.enableGatewayDeltaReplication = sessionManager.getEnableGatewayDeltaReplication();
-      this.preferDeserializedForm = sessionManager.getPreferDeserializedForm();
-
-      // Initialize transient variables
-      if (this.listeners == null) {
-        this.listeners = new ArrayList();
-      }
-
-      if (this.notes == null) {
-        this.notes = new Hashtable();
-      }
-
-      contextName = ((DeltaSessionManager) manager).getContainer().getName();
-    } else {
-      throw new IllegalArgumentException(this + ": The Manager must be an AbstractManager");
-    }
-  }
-
-  private void checkBackingCacheAvailable() {
-    if (! ((SessionManager)getManager()).isBackingCacheAvailable()) {
-      throw new IllegalStateException("No backing cache server is available.");
-    }
-  }
-  
-  public void setAttribute(String name, Object value, boolean notify) {
-    checkBackingCacheAvailable();
-    synchronized (this.changeLock) {
-      // Serialize the value
-      byte[] serializedValue = serialize(value);
-
-      // Store the attribute locally
-      if (this.preferDeserializedForm) {
-        super.setAttribute(name, value, true);
-      } else {
-        super.setAttribute(name, serializedValue, true);
-      }
-
-      if (serializedValue == null) {
-        return;
-      }
-      
-      // Create the update attribute message
-      DeltaSessionAttributeEvent event = new DeltaSessionUpdateAttributeEvent(name, serializedValue);
-      queueAttributeEvent(event, true);
-      
-      // Distribute the update
-      if (! isCommitEnabled()) {
-        putInRegion(getOperatingRegion(), true, null);
-      }
-    }
-  }
-  
-  public void removeAttribute(String name, boolean notify) {
-    checkBackingCacheAvailable();
-    synchronized (this.changeLock) {
-      // Remove the attribute locally
-      super.removeAttribute(name, true);
-      
-      // Create the destroy attribute message
-      DeltaSessionAttributeEvent event = new DeltaSessionDestroyAttributeEvent(name);
-      queueAttributeEvent(event, true);
-      
-      // Distribute the update
-      if (! isCommitEnabled()) {
-        putInRegion(getOperatingRegion(), true, null);
-      }
-    }
-  }
-  
-  public Object getAttribute(String name) {
-    checkBackingCacheAvailable();
-    Object value = super.getAttribute(name);
-
-    // If the attribute is a byte[] (meaning it came from the server),
-    // deserialize it and add it to attributes map before returning it.
-    if (value instanceof byte[]) {
-      try {
-        value = BlobHelper.deserializeBlob((byte[]) value);
-      } catch (Exception e) {
-        StringBuilder builder = new StringBuilder();
-        builder
-          .append(this)
-          .append(": Attribute named ")
-          .append(name)
-          .append(" contains a byte[] that cannot be deserialized due to the following exception");
-        ((DeltaSessionManager) getManager()).getLogger().warn(builder.toString(), e);
-      }
-      if (this.preferDeserializedForm) {
-        localUpdateAttribute(name, value);
-      }
-    }
-    
-    // Touch the session region if necessary. This is an asynchronous operation
-    // that prevents the session region from prematurely expiring a session that
-    // is only getting attributes.
-    ((DeltaSessionManager) getManager()).addSessionToTouch(getId());
-    
-    return value;
-  }
-
-  public void invalidate() {
-    super.invalidate();
-    //getOperatingRegion().destroy(this.id, true); // already done in super (remove)
-    ((DeltaSessionManager) getManager()).getStatistics().incSessionsInvalidated();
-  }
-
-  public void processExpired() {
-    if (((DeltaSessionManager) getManager()).getLogger().isDebugEnabled()) {
-      ((DeltaSessionManager) getManager()).getLogger().debug(this + ": Expired");
-    }
-    // Set expired (so region.destroy is not called again)
-    setExpired(true);
-
-    // Do expire processing
-    expire();
-    
-    // Update statistics
-    DeltaSessionManager manager = (DeltaSessionManager) getManager();
-    if (manager != null) {
-      manager.getStatistics().incSessionsExpired();
-    }
-  }
-
-  public void setMaxInactiveInterval(int interval) {
-    super.setMaxInactiveInterval(interval);
-  }
-
-  public void localUpdateAttribute(String name, Object value) {
-    super.setAttribute(name, value, false); // don't do notification since this is a replication
-  }
-  
-  public void localDestroyAttribute(String name) {
-    super.removeAttribute(name, false); // don't do notification since this is a replication
-  }
-  
-  public void applyAttributeEvents(Region<String,DeltaSession> region, List<DeltaSessionAttributeEvent> events) {
-    for (DeltaSessionAttributeEvent event : events) {
-      event.apply(this);
-      queueAttributeEvent(event, false);
-    }
-    
-    putInRegion(region, false, true); 
-  }
-
-  private void initializeRegion(DeltaSessionManager sessionManager) {
-    // Get the session region name
-    this.sessionRegionName = sessionManager.getRegionName();
-
-    // Get the operating region.
-    // If a P2P manager is used, then this will be a local region fronting the
-    // session region if local cache is enabled; otherwise, it will be the
-    // session region itself.
-    // If a CS manager is used, it will be the session proxy region.
-    this.operatingRegion = sessionManager.getSessionCache().getOperatingRegion();
-    if (sessionManager.getLogger().isDebugEnabled()) {
-      sessionManager.getLogger().debug(this + ": Set operating region: " + this.operatingRegion);
-    }
-  }
-  
-  private void queueAttributeEvent(DeltaSessionAttributeEvent event, boolean checkAddToCurrentGatewayDelta) {
-    // Add to current gateway delta if necessary
-    if (checkAddToCurrentGatewayDelta) {
-      // If the manager has enabled gateway delta replication and is a P2P
-      // manager, the GatewayDeltaForwardCacheListener will be invoked in this
-      // VM. Add the event to the currentDelta.
-      DeltaSessionManager mgr = (DeltaSessionManager) this.manager;
-      if (this.enableGatewayDeltaReplication && mgr.isPeerToPeer()) {
-        // If commit is not enabled, add the event to the current batch; else,
-        // the current batch will be initialized to the events in the queue will
-        // be added at commit time.
-        if (! isCommitEnabled()) {
-          List<DeltaSessionAttributeEvent> events = new ArrayList<DeltaSessionAttributeEvent>();
-          events.add(event);
-          this.currentGatewayDeltaEvent = new DeltaSessionAttributeEventBatch(this.sessionRegionName, this.id, events);
-        }
-      }
-    }
-    this.eventQueue.add(event);
-  }
-
-  @SuppressWarnings("unchecked")
-  private void putInRegion(Region region, boolean applyRemotely, Object callbackArgument) {
-    this.hasDelta = true;
-    this.applyRemotely = applyRemotely;
-    region.put(this.id, this, callbackArgument);
-    this.eventQueue.clear();
-  }
-  
-  public void commit() {
-    if (!isValidInternal())
-      throw new IllegalStateException("commit: Session " + getId() +
-              " already invalidated");
-//          (STRING_MANAGER.getString("deltaSession.commit.ise", getId()));
-
-    synchronized (this.changeLock) {
-      // Jens - there used to be a check to only perform this if the queue is
-      // empty, but we want this to always run so that the lastAccessedTime
-      // will be updated even when no attributes have been changed.
-      DeltaSessionManager mgr = (DeltaSessionManager) this.manager;
-      if (this.enableGatewayDeltaReplication && mgr.isPeerToPeer()) {
-        setCurrentGatewayDeltaEvent(new DeltaSessionAttributeEventBatch(this.sessionRegionName, this.id, this.eventQueue));
-      }
-      this.hasDelta = true;
-      this.applyRemotely = true;
-      putInRegion(getOperatingRegion(), true, null);
-      this.eventQueue.clear();
-    }
-  }
-  
-  public void abort() {
-    synchronized (this.changeLock) {
-      this.eventQueue.clear();
-    }
-  }
-
-  private void setExpired(boolean expired) {
-    this.expired = expired;
-  }
-
-  protected boolean getExpired() {
-    return this.expired;
-  }
-
-  public String getContextName() {
-    return contextName;
-  }
-  
-  public boolean hasDelta() {
-    return this.hasDelta;
-  }
-
-  public void toDelta(DataOutput out) throws IOException {
-    // Write whether to apply the changes to another DS if necessary
-    out.writeBoolean(this.applyRemotely);
-
-    // Write the events
-    DataSerializer.writeArrayList((ArrayList) this.eventQueue, out);
-
-    out.writeLong(this.lastAccessedTime);
-    out.writeInt(this.maxInactiveInterval);
-  }
-  
-  public void fromDelta(DataInput in) throws IOException, InvalidDeltaException {
-    // Read whether to apply the changes to another DS if necessary
-    this.applyRemotely = in.readBoolean();
-
-    // Read the events
-    List<DeltaSessionAttributeEvent> events = null;
-    try {
-      events = DataSerializer.readArrayList(in);
-    } catch (ClassNotFoundException e) {
-      throw new InvalidDeltaException(e);
-    }
-
-    // This allows for backwards compatibility with 2.1 clients
-    if (((InputStream)in).available() > 0) {
-      this.lastAccessedTime = in.readLong();
-      this.maxInactiveInterval = in.readInt();
-    }
-
-    // Iterate and apply the events
-    for (DeltaSessionAttributeEvent event : events) {
-      event.apply(this);
-    }
-
-    // Add the events to the gateway delta region if necessary
-    if (this.enableGatewayDeltaReplication && this.applyRemotely) {
-      setCurrentGatewayDeltaEvent(new DeltaSessionAttributeEventBatch(this.sessionRegionName, this.id, events));
-    }
-
-    // Access it to set the last accessed time. End access it to set not new.
-    access();
-    endAccess();
-  }
-
-  @Override
-  public void toData(DataOutput out) throws IOException {
-    // Write the StandardSession state
-    DataSerializer.writeString(this.id, out);
-    out.writeLong(this.creationTime);
-    out.writeLong(this.lastAccessedTime);
-    out.writeLong(this.thisAccessedTime);
-    out.writeInt(this.maxInactiveInterval);
-    out.writeBoolean(this.isNew);
-    out.writeBoolean(this.isValid);
-    DataSerializer.writeObject(getSerializedAttributes(), out);
-    DataSerializer.writeByteArray(getSerializedPrincipal(), out);
-
-    // Write the DeltaSession state
-    out.writeBoolean(this.enableGatewayDeltaReplication);
-    DataSerializer.writeString(this.sessionRegionName, out);
-
-    DataSerializer.writeString(this.contextName, out);
-  }
-
-  @Override
-  public void fromData(DataInput in) throws IOException, ClassNotFoundException {
-    // Read the StandardSession state
-    this.id = DataSerializer.readString(in);
-    this.creationTime = in.readLong();
-    this.lastAccessedTime = in.readLong();
-    this.thisAccessedTime = in.readLong();
-    this.maxInactiveInterval = in.readInt();
-    this.isNew = in.readBoolean();
-    this.isValid = in.readBoolean();
-    this.attributes = DataSerializer.readObject(in);
-    this.serializedPrincipal = DataSerializer.readByteArray(in);
-
-    // Read the DeltaSession state
-    this.enableGatewayDeltaReplication = in.readBoolean();
-    this.sessionRegionName = DataSerializer.readString(in);
-
-    // This allows for backwards compatibility with 2.1 clients
-    if (((InputStream)in).available() > 0) {
-      this.contextName = DataSerializer.readString(in);
-    }
-
-    // Initialize the transients if necessary
-    if (this.listeners == null) {
-      this.listeners = new ArrayList();
-    }
-
-    if (this.notes == null) {
-      this.notes = new Hashtable();
-    }
-  }
-
-  @Override
-  public int getSizeInBytes() {
-    int size = 0;
-    for (Enumeration<String> e = getAttributeNames(); e.hasMoreElements(); ) {
-      // Don't use this.getAttribute() because we don't want to deserialize
-      // the value.
-      Object value = super.getAttribute(e.nextElement());
-      if (value instanceof byte[]) {
-        size += ((byte[]) value).length;
-      }
-    }
-
-    return size;
-  }
-
-  @SuppressWarnings({ "unchecked", "rawtypes" })
-  private Map<String,byte[]> getSerializedAttributes() {
-    // Iterate the values and serialize them if necessary before sending them to the server. This makes the application classes unnecessary on the server.
-    Map<String,byte[]> serializedAttributes = new ConcurrentHashMap<String,byte[]>();
-    for (Iterator i= this.attributes.entrySet().iterator(); i.hasNext();) {
-      Map.Entry<String,Object> entry = (Map.Entry<String,Object>) i.next();
-      Object value = entry.getValue();
-      byte[] serializedValue = value instanceof byte[] ? (byte[]) value : serialize(value);
-      serializedAttributes.put(entry.getKey(), serializedValue);
-    }
-    return serializedAttributes;
-  }
-  
-  private byte[] serialize(Object obj) {
-    byte[] serializedValue = null;
-    try {
-      serializedValue = BlobHelper.serializeToBlob(obj);
-    } catch (IOException e) {
-      StringBuilder builder = new StringBuilder();
-      builder
-        .append(this)
-        .append(": Object ")
-        .append(obj)
-        .append(" cannot be serialized due to the following exception");
-      ((DeltaSessionManager) getManager()).getLogger().warn(builder.toString(), e);
-    }
-    return serializedValue;
-  }
-  
-  @Override
-  public String toString() {
-    return new StringBuilder()
-      .append("DeltaSession[")
-      .append("id=")
-      .append(getId())
-      .append("; context=")
-      .append(this.contextName)
-      .append("; sessionRegionName=")
-      .append(this.sessionRegionName)
-      .append("; operatingRegionName=")
-      .append(getOperatingRegion() == null ? "unset" : getOperatingRegion().getFullPath())
-      .append("]")
-      .toString();
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/63bc5f03/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/DeltaSessionFacade.java
----------------------------------------------------------------------
diff --git a/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/DeltaSessionFacade.java b/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/DeltaSessionFacade.java
deleted file mode 100644
index dcb3433..0000000
--- a/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/DeltaSessionFacade.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*=========================================================================
- * Copyright (c) 2010-2014 Pivotal Software, Inc. All Rights Reserved.
- * This product is protected by U.S. and international copyright
- * and intellectual property laws. Pivotal products are covered by
- * one or more patents listed at http://www.pivotal.io/patents.
- *=========================================================================
- */
-package com.gemstone.gemfire.modules.session.catalina;
-
-import org.apache.catalina.session.StandardSessionFacade;
-
-import javax.servlet.http.HttpSession;
-
-public class DeltaSessionFacade extends StandardSessionFacade {
-  
-  private DeltaSession session;
-
-  /**
-   * Construct a new session facade.
-   */
-  public DeltaSessionFacade(DeltaSession session) {
-    super((HttpSession)session);
-    // Store session locally since the super session is private and provides no accessor.
-    this.session = session;
-  }
-
-  // ----------- DeltaSession Methods
-  
-  public void commit() {
-    this.session.commit();
-  }
-  
-  public void abort() {
-    this.session.abort();
-  }
-
-  boolean isValid() {
-    return this.session.isValid();
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/63bc5f03/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/DeltaSessionManager.java
----------------------------------------------------------------------
diff --git a/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/DeltaSessionManager.java b/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/DeltaSessionManager.java
deleted file mode 100644
index c5befb5..0000000
--- a/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/DeltaSessionManager.java
+++ /dev/null
@@ -1,1000 +0,0 @@
-/*=========================================================================
- * Copyright (c) 2010-2014 Pivotal Software, Inc. All Rights Reserved.
- * This product is protected by U.S. and international copyright
- * and intellectual property laws. Pivotal products are covered by
- * one or more patents listed at http://www.pivotal.io/patents.
- *=========================================================================
- */
-package com.gemstone.gemfire.modules.session.catalina;
-
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-import java.util.Timer;
-import java.util.TimerTask;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import com.gemstone.gemfire.cache.Region;
-import com.gemstone.gemfire.modules.util.ContextMapper;
-import org.apache.catalina.Container;
-import org.apache.catalina.Context;
-import org.apache.catalina.Lifecycle;
-import org.apache.catalina.LifecycleListener;
-import org.apache.catalina.Loader;
-import org.apache.catalina.Session;
-import org.apache.catalina.Valve;
-import org.apache.catalina.session.ManagerBase;
-import org.apache.catalina.session.StandardSession;
-import org.apache.catalina.util.CustomObjectInputStream;
-import org.apache.catalina.util.LifecycleSupport;
-import org.apache.juli.logging.Log;
-import org.apache.juli.logging.LogFactory;
-
-import com.gemstone.gemfire.cache.query.Query;
-import com.gemstone.gemfire.cache.query.QueryService;
-import com.gemstone.gemfire.cache.query.SelectResults;
-import com.gemstone.gemfire.cache.CacheFactory;
-import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
-import com.gemstone.gemfire.modules.session.catalina.internal.DeltaSessionStatistics;
-import com.gemstone.gemfire.modules.util.RegionConfiguration;
-import com.gemstone.gemfire.modules.util.RegionHelper;
-
-abstract public class DeltaSessionManager extends ManagerBase implements Lifecycle,
-    PropertyChangeListener, SessionManager {
-
-  /**
-   * The <code>LifecycleSupport</code> for this component.
-   */
-  protected LifecycleSupport lifecycle = new LifecycleSupport(this);
-  
-  /**
-   * The number of rejected sessions.
-   */
-  private AtomicInteger rejectedSessions;
-
-  /**
-   * The maximum number of active Sessions allowed, or -1 for no limit.
-   */
-  protected int maxActiveSessions = -1;
-
-  /**
-   * Has this <code>Manager</code> been started?
-   */
-  protected AtomicBoolean started = new AtomicBoolean(false);
-
-  /**
-   * The name of this <code>Manager</code>
-   */
-  protected String name;
-  
-  protected Valve jvmRouteBinderValve;
-
-  protected Valve commitSessionValve;
-
-  protected SessionCache sessionCache;
-  
-  protected static final String DEFAULT_REGION_NAME = RegionHelper.NAME + "_sessions";
-  
-  protected static final boolean DEFAULT_ENABLE_GATEWAY_DELTA_REPLICATION = false;
-  
-  protected static final boolean DEFAULT_ENABLE_GATEWAY_REPLICATION = false;
-  
-  protected static final boolean DEFAULT_ENABLE_DEBUG_LISTENER = false;
-
-  protected static final boolean DEFAULT_ENABLE_COMMIT_VALVE = true;
-
-  protected static final boolean DEFAULT_ENABLE_COMMIT_VALVE_FAILFAST = false;
-
-  protected static final boolean DEFAULT_PREFER_DESERIALIZED_FORM = true;
-
-  /*
-   * This *MUST* only be assigned during start/startInternal otherwise it will be associated
-   * with the incorrect context class loader.
-   */
-  protected Log LOGGER;
-
-  protected String regionName = DEFAULT_REGION_NAME;
-  
-  protected String regionAttributesId; // the default is different for client-server and peer-to-peer
-  
-  protected Boolean enableLocalCache; // the default is different for client-server and peer-to-peer
-
-  protected boolean enableCommitValve = DEFAULT_ENABLE_COMMIT_VALVE;
-
-  protected boolean enableCommitValveFailfast = DEFAULT_ENABLE_COMMIT_VALVE_FAILFAST;
-
-  protected boolean enableGatewayDeltaReplication = DEFAULT_ENABLE_GATEWAY_DELTA_REPLICATION;
-  
-  protected boolean enableGatewayReplication = DEFAULT_ENABLE_GATEWAY_REPLICATION;
-
-  protected boolean enableDebugListener = DEFAULT_ENABLE_DEBUG_LISTENER;
-
-  protected boolean preferDeserializedForm = DEFAULT_PREFER_DESERIALIZED_FORM;
-
-  private Timer timer;
-
-  private final Set<String> sessionsToTouch;
-
-  private static final long TIMER_TASK_PERIOD =
-    Long.getLong("gemfiremodules.sessionTimerTaskPeriod", 10000);
-
-  private static final long TIMER_TASK_DELAY =
-    Long.getLong("gemfiremodules.sessionTimerTaskDelay", 10000);
-
-  public DeltaSessionManager() {
-    // Create the set to store sessions to be touched after get attribute requests
-    this.sessionsToTouch =  Collections.newSetFromMap(
-        new ConcurrentHashMap<String, Boolean>());
-  }
-  
-  @Override
-  public String getRegionName() {
-    return this.regionName;
-  }
-  
-  public void setRegionName(String regionName) {
-    this.regionName = regionName;
-  }
-
-  @Override
-  public String getRegionAttributesId() {
-    // This property will be null if it hasn't been set in the context.xml file.
-    // Since its default is dependent on the session cache, get the default from
-    // the session cache.
-    if (this.regionAttributesId == null) {
-      this.regionAttributesId = getSessionCache().getDefaultRegionAttributesId();
-    }
-    return this.regionAttributesId;
-  }
-    
-  public void setRegionAttributesId(String regionType) {
-    this.regionAttributesId = regionType;
-  }
-  
-  @Override
-  public boolean getEnableLocalCache() {
-    // This property will be null if it hasn't been set in the context.xml file.
-    // Since its default is dependent on the session cache, get the default from
-    // the session cache.
-    if (this.enableLocalCache == null) {
-      this.enableLocalCache = getSessionCache().getDefaultEnableLocalCache();
-    }
-    return this.enableLocalCache;
-  }
-  
-  public void setEnableLocalCache(boolean enableLocalCache) {
-    this.enableLocalCache = enableLocalCache;
-  }
-
-  public int getMaxActiveSessions() {
-    return this.maxActiveSessions;
-  }
-
-  public void setMaxActiveSessions(int maxActiveSessions) {
-    int oldMaxActiveSessions = this.maxActiveSessions;
-    this.maxActiveSessions = maxActiveSessions;
-    support.firePropertyChange("maxActiveSessions",
-      new Integer(oldMaxActiveSessions), new Integer(this.maxActiveSessions));
-  }
-
-  @Override
-  public boolean getEnableGatewayDeltaReplication() {
-    //return this.enableGatewayDeltaReplication;
-    return false; // disabled
-  }
-
-  public void setEnableGatewayDeltaReplication(boolean enableGatewayDeltaReplication) {
-    this.enableGatewayDeltaReplication = enableGatewayDeltaReplication;
-  }
-  
-  @Override
-  public boolean getEnableGatewayReplication() {
-    return this.enableGatewayReplication;
-  }
-
-  public void setEnableGatewayReplication(boolean enableGatewayReplication) {
-    this.enableGatewayReplication = enableGatewayReplication;
-  }
-
-  @Override
-  public boolean getEnableDebugListener() {
-    return this.enableDebugListener;
-  }
-
-  public void setEnableDebugListener(boolean enableDebugListener) {
-    this.enableDebugListener = enableDebugListener;
-  }
-
-  @Override
-  public boolean isCommitValveEnabled() {
-    return this.enableCommitValve;
-  }
-
-  public void setEnableCommitValve(boolean enable) {
-    this.enableCommitValve = enable;
-  }
-
-  @Override
-  public boolean isCommitValveFailfastEnabled() {
-    return this.enableCommitValveFailfast;
-  }
-  
-  public void setEnableCommitValveFailfast(boolean enable) {
-    this.enableCommitValveFailfast = enable;
-  }
-
-  @Override
-  public boolean isBackingCacheAvailable() {
-    return sessionCache.isBackingCacheAvailable();
-  }
-
-  public void setPreferDeserializedForm(boolean enable) {
-    this.preferDeserializedForm = enable;
-  }
-
-  @Override
-  public boolean getPreferDeserializedForm() {
-    return this.preferDeserializedForm;
-  }
-
-  @Override
-  public String getStatisticsName() {
-    return getContainer().getName().replace("/", "");
-  }
-  
-  @Override
-  public Log getLogger() {
-    if (LOGGER == null) {
-      LOGGER = LogFactory.getLog(DeltaSessionManager.class);
-    }
-    return LOGGER;
-  }
-  
-  public SessionCache getSessionCache() {
-    return this.sessionCache;
-  }
-  
-  public DeltaSessionStatistics getStatistics() {
-    return getSessionCache().getStatistics();
-  }
-  
-  public boolean isPeerToPeer() {
-    return getSessionCache().isPeerToPeer();
-  }
-  
-  public boolean isClientServer() {
-    return getSessionCache().isClientServer();
-  }
-
-  /**
-   * This method was taken from StandardManager to set the default
-   * maxInactiveInterval based on the container (to 30 minutes).
-   * 
-   * Set the Container with which this Manager has been associated. If it is a
-   * Context (the usual case), listen for changes to the session timeout
-   * property.
-   * 
-   * @param container
-   *          The associated Container
-   */
-  @Override
-  public void setContainer(Container container) {
-    // De-register from the old Container (if any)
-    if ((this.container != null) && (this.container instanceof Context)) {
-      ((Context) this.container).removePropertyChangeListener(this);
-    }
-
-    // Default processing provided by our superclass
-    super.setContainer(container);
-
-    // Register with the new Container (if any)
-    if ((this.container != null) && (this.container instanceof Context)) {
-      // Overwrite the max inactive interval with the context's session timeout.
-      setMaxInactiveInterval(((Context) this.container).getSessionTimeout() * 60);
-      ((Context) this.container).addPropertyChangeListener(this);
-    }
-  }
-
-  @Override
-  public Session findSession(String id) throws IOException {
-    if (id == null) {
-      return null;
-    }
-    if (getLogger().isDebugEnabled()) {
-      getLogger().debug(this + ": Finding session " + id + " in " + getSessionCache().getOperatingRegionName());
-    }
-    DeltaSession session = (DeltaSession) getSessionCache().getSession(id);
-    /*
-     * Check that the context name for this session is the same as this manager's.
-     * This comes into play when multiple versions of a webapp are deployed and
-     * active at the same time; the context name will contain an embedded
-     * version number; something like /test###2.
-     */
-    if (session != null &&
-        ! session.getContextName().isEmpty() &&
-        ! getContainer().getName().equals(session.getContextName())) {
-      getLogger().info(this + ": Session " + id +
-          " rejected as container name and context do not match: " +
-          getContainer().getName() + " != " + session.getContextName());
-      session = null;
-    }
-
-    if (session == null) {
-      if (getLogger().isDebugEnabled()) {
-        getLogger().debug(this + ": Did not find session " + id + " in " + getSessionCache().getOperatingRegionName());
-      }
-    } else {
-      if (getLogger().isDebugEnabled()) {
-        getLogger().debug(this + ": Found session " + id + " in " + getSessionCache().getOperatingRegionName() + ": " + session);
-      }
-      // The session was previously stored. Set new to false.
-      session.setNew(false);
-      
-      // Check the manager.
-      // If the manager is null, the session was replicated and this is a
-      // failover situation. Reset the manager and activate the session.
-      if (session.getManager() == null) {
-        DeltaSession ds = (DeltaSession) session;
-        ds.setOwner(this);
-        ds.activate();
-      }
-    }
-    return session;
-  }
-
-  protected void initializeSessionCache() {
-    // Retrieve the cache
-    GemFireCacheImpl cache = (GemFireCacheImpl) CacheFactory.getAnyInstance();
-    if (cache == null) {
-      throw new IllegalStateException("No cache exists. Please configure either a PeerToPeerCacheLifecycleListener or ClientServerCacheLifecycleListener in the server.xml file.");
-    }
-    
-    // Create the appropriate session cache
-    this.sessionCache = cache.isClient()
-      ? new ClientServerSessionCache(this, cache)
-      : new PeerToPeerSessionCache(this, cache);
-
-    // Initialize the session cache
-    this.sessionCache.initialize();
-  }
-
-  @Override
-  protected StandardSession getNewSession() {
-    return new DeltaSession(this);
-  }
-
-  @Override
-  public void remove(Session session) {
-    remove(session, false);
-  }
-
-  public void remove(Session session, boolean update) {
-    //super.remove(session);
-    // Remove the session from the region if necessary.
-    // It will have already been removed if it expired implicitly.
-    DeltaSession ds = (DeltaSession) session;
-    if (ds.getExpired()) {
-      if (getLogger().isDebugEnabled()) {
-        getLogger().debug(this + ": Expired session " + session.getId() + " from " + getSessionCache().getOperatingRegionName());
-      }
-    } else {
-      if (getLogger().isDebugEnabled()) {
-        getLogger().debug(this + ": Destroying session " + session.getId() + " from " + getSessionCache().getOperatingRegionName());
-      }
-      getSessionCache().destroySession(session.getId());
-      if (getLogger().isDebugEnabled()) {
-        getLogger().debug(this + ": Destroyed session " + session.getId() + " from " + getSessionCache().getOperatingRegionName());
-      }
-    }
-  }
-
-  @Override
-  public void add(Session session) {
-    //super.add(session);
-    if (getLogger().isDebugEnabled()) {
-      getLogger().debug(this + ": Storing session " + session.getId() + " into " + getSessionCache().getOperatingRegionName());
-    }
-    getSessionCache().putSession(session);
-    if (getLogger().isDebugEnabled()) {
-      getLogger().debug(this + ": Stored session " + session.getId() + " into " + getSessionCache().getOperatingRegionName());
-    }
-    getSessionCache().getStatistics().incSessionsCreated();
-  }
-
-  @Override
-  public int getRejectedSessions() {
-    return this.rejectedSessions.get();
-  }
-
-  public void setRejectedSessions(int rejectedSessions) {
-    this.rejectedSessions.set(rejectedSessions);
-  }
-
-  private void incrementRejectedSessions() {
-    this.rejectedSessions.incrementAndGet();
-  }
-
-  /** 
-   * Returns the number of active sessions
-   *
-   * @return number of sessions active
-   */
-  @Override
-  public int getActiveSessions() {
-    return getSessionCache().size();
-  }
-
-  /** 
-   * For debugging: return a list of all session ids currently active
-   *
-   */
-  @Override
-  public String listSessionIds() {
-    StringBuilder builder = new StringBuilder();
-    Iterator<String> sessionIds = getSessionCache().keySet().iterator();
-    while (sessionIds.hasNext()) {
-    	builder.append(sessionIds.next());
-      if (sessionIds.hasNext()) {
-      	builder.append(" ");
-      }
-    }
-    return builder.toString();
-  }
-
-  /*
-   * If local caching is enabled, add the session to the set of sessions to be
-   * touched. A timer task will be periodically invoked to get the session in
-   * the session region to update its last accessed time. This prevents the
-   * session from expiring in the case where the application is only getting
-   * attributes from the session and never putting attributes into the
-   * session. If local caching is disabled. the session's last accessed time
-   * would already have been updated properly in the sessions region.
-   *
-   * Note: Due to issues in GemFire expiry, sessions are always asynchronously
-   * touched using a function regardless whether or not local caching is
-   * enabled. This prevents premature expiration.
-   */
-  protected void addSessionToTouch(String sessionId) {
-    this.sessionsToTouch.add(sessionId);
-  }
-
-  protected Set<String> getSessionsToTouch() {
-    return this.sessionsToTouch;
-  }
-
-  protected boolean removeTouchedSession(String sessionId) {
-    return this.sessionsToTouch.remove(sessionId);
-  }
-
-  protected void scheduleTimerTasks() {
-    // Create the timer
-    this.timer = new Timer("Timer for " + toString(), true);
-
-    // Schedule the task to handle sessions to be touched
-    scheduleTouchSessionsTask();
-	  
-    // Schedule the task to maintain the maxActive sessions
-    scheduleDetermineMaxActiveSessionsTask();
-  }
-
-  private void scheduleTouchSessionsTask() {
-    TimerTask task = new TimerTask() {
-      @Override
-      public void run() {
-        // Get the sessionIds to touch and clear the set inside synchronization
-        Set<String> sessionIds = null;
-        sessionIds = new HashSet<String>(getSessionsToTouch());
-        getSessionsToTouch().clear();
-
-        // Touch the sessions we currently have
-        if (sessionIds != null && (!sessionIds.isEmpty())) {
-          getSessionCache().touchSessions(sessionIds);
-          if (getLogger().isDebugEnabled()) {
-            getLogger().debug(DeltaSessionManager.this + ": Touched sessions: " + sessionIds);
-          }
-        }
-      }
-    };
-    this.timer.schedule(task, TIMER_TASK_DELAY, TIMER_TASK_PERIOD);
-  }
-
-  protected void cancelTimer() {
-    if (timer != null) {
-      this.timer.cancel();
-    }
-  }
-  
-  private void scheduleDetermineMaxActiveSessionsTask() {
-    TimerTask task = new TimerTask() {
-      @Override
-      public void run() {
-      	int currentActiveSessions = getSessionCache().size();
-      	if (currentActiveSessions > getMaxActive()) {
-      		setMaxActive(currentActiveSessions);
-          if (getLogger().isDebugEnabled()) {
-            getLogger().debug(DeltaSessionManager.this + ": Set max active sessions: " + currentActiveSessions);
-          }
-      	}
-      }
-    };
-    this.timer.schedule(task, TIMER_TASK_DELAY, TIMER_TASK_PERIOD);
-  }
-
-  @Override
-  public void load() throws ClassNotFoundException, IOException {
-    doLoad();
-    ContextMapper.addContext(getContainer().getName(), this);
-  }
-
-  @Override
-  public void unload() throws IOException {
-    doUnload();
-    ContextMapper.removeContext(getContainer().getName());
-  }
-
-  protected void registerJvmRouteBinderValve() {
-    if (getLogger().isDebugEnabled()) {
-      getLogger().debug(this + ": Registering JVM route binder valve");
-    }
-    jvmRouteBinderValve = new JvmRouteBinderValve();
-    getContainer().getPipeline().addValve(jvmRouteBinderValve);
-  }
-
-  protected void unregisterJvmRouteBinderValve() {
-    if (getLogger().isDebugEnabled()) {
-      getLogger().debug(this + ": Unregistering JVM route binder valve");
-    }
-    if (jvmRouteBinderValve != null) {
-      getContainer().getPipeline().removeValve(jvmRouteBinderValve);
-    }
-  }
-
-  protected void registerCommitSessionValve() {
-    if (getLogger().isDebugEnabled()) {
-      getLogger().debug(this + ": Registering CommitSessionValve");
-    }
-    commitSessionValve = new CommitSessionValve();
-    getContainer().getPipeline().addValve(commitSessionValve);
-  }
-  
-  protected void unregisterCommitSessionValve() {
-    if (getLogger().isDebugEnabled()) {
-      getLogger().debug(this + ": Unregistering CommitSessionValve");
-    }
-    if (commitSessionValve != null) {
-      getContainer().getPipeline().removeValve(commitSessionValve);
-    }
-  }
-  
-  // ------------------------------ Lifecycle Methods
-  
-  /**
-   * Add a lifecycle event listener to this component.
-   *
-   * @param listener The listener to add
-   */
-  @Override
-  public void addLifecycleListener(LifecycleListener listener) {
-    this.lifecycle.addLifecycleListener(listener);
-  }
-
-  /**
-   * Get the lifecycle listeners associated with this lifecycle. If this
-   * Lifecycle has no listeners registered, a zero-length array is returned.
-   */
-  @Override
-  public LifecycleListener[] findLifecycleListeners() {
-    return this.lifecycle.findLifecycleListeners();
-  }
-
-  /**
-   * Remove a lifecycle event listener from this component.
-   *
-   * @param listener The listener to remove
-   */
-  @Override
-  public void removeLifecycleListener(LifecycleListener listener) {
-    this.lifecycle.removeLifecycleListener(listener);
-  }
-  
-  /**
-   * Process property change events from our associated Context.
-   * 
-   * Part of this method implementation was taken from StandardManager. The
-   * sessionTimeout can be changed in the web.xml which is processed after the
-   * context.xml. The context (and the default session timeout) would already
-   * have been set in this Manager. This is the way to get the new session
-   * timeout value specified in the web.xml.
-   * 
-   * The precedence order for setting the session timeout value is:
-   * 
-   * <ol>
-   * <li>the max inactive interval is set based on the Manager defined in the
-   * context.xml
-   * <li>the max inactive interval is then overwritten by the value of the
-   * Context's session timeout when setContainer is called
-   * <li>the max inactive interval is then overwritten by the value of the
-   * session-timeout specified in the web.xml (if any)
-   * </ol>
-   * 
-   * @param event
-   *          The property change event that has occurred
-   */
-  @Override
-  public void propertyChange(PropertyChangeEvent event) {
-
-    // Validate the source of this event
-    if (!(event.getSource() instanceof Context)) {
-      return;
-    }
-    Context context = (Context) event.getSource();
-
-    // Process a relevant property change
-    if (event.getPropertyName().equals("sessionTimeout")) {
-      try {
-      	int interval = ((Integer) event.getNewValue()).intValue();
-      	if (interval < RegionConfiguration.DEFAULT_MAX_INACTIVE_INTERVAL) {
-      		getLogger().warn("The configured session timeout of " + interval + " minutes is invalid. Using the original value of " + event.getOldValue() + " minutes.");
-      		interval = ((Integer) event.getOldValue()).intValue();;
-      	}
-				// StandardContext.setSessionTimeout passes -1 if the configured timeout
-				// is 0; otherwise it passes the value set in web.xml. If the interval
-				// parameter equals the default, set the max inactive interval to the
-				// default (no expiration); otherwise set it in seconds.
-				setMaxInactiveInterval(interval == RegionConfiguration.DEFAULT_MAX_INACTIVE_INTERVAL
-          ? RegionConfiguration.DEFAULT_MAX_INACTIVE_INTERVAL
-          : interval * 60);
-      } catch (NumberFormatException e) {
-        getLogger().error(sm.getString("standardManager.sessionTimeout", event
-                .getNewValue().toString()));
-      }
-    }
-  }
-
-  /**
-   * Save any currently active sessions in the appropriate persistence
-   * mechanism, if any.  If persistence is not supported, this method
-   * returns without doing anything.
-   *
-   * @exception IOException if an input/output error occurs
-   */
-  protected void doUnload() throws IOException {
-    QueryService querySvc = sessionCache.getCache().getQueryService();
-    Context context;
-    if (getContainer() instanceof Context) {
-      context = (Context) getContainer();
-    } else {
-      getLogger().error("Unable to unload sessions - container is of type " +
-          getContainer().getClass().getName() + " instead of StandardContext");
-      return;
-    }
-    String regionName;
-    if (getRegionName().startsWith("/")) {
-      regionName = getRegionName();
-    } else {
-      regionName = "/" + getRegionName();
-    }
-    Query query = querySvc.newQuery("select s.id from " + regionName +
-        " as s where s.contextName = '" + context.getPath() + "'");
-    getLogger().debug("Query: " + query.getQueryString());
-
-    SelectResults results;
-    try {
-      results = (SelectResults) query.execute();
-    } catch (Exception ex) {
-      getLogger().error("Unable to perform query during doUnload", ex);
-      return;
-    }
-
-    if (results.isEmpty()) {
-      getLogger().debug("No sessions to unload for context " + context.getPath());
-      return; // nothing to do
-    }
-
-    // Open an output stream to the specified pathname, if any
-    File store = sessionStore(context.getPath());
-    if (store == null) {
-      return;
-    }
-    if (getLogger().isDebugEnabled()) {
-      getLogger().debug("Unloading sessions to " + store.getAbsolutePath());
-    }
-    FileOutputStream fos = null;
-    BufferedOutputStream bos = null;
-    ObjectOutputStream oos = null;
-    boolean error = false;
-    try {
-      fos = new FileOutputStream(store.getAbsolutePath());
-      bos = new BufferedOutputStream(fos);
-      oos = new ObjectOutputStream(bos);
-    } catch (IOException e) {
-      error = true;
-      getLogger().error("Exception unloading sessions", e);
-      throw e;
-    } finally {
-      if (error) {
-        if (oos != null) {
-          try {
-            oos.close();
-          } catch (IOException ioe) {
-            // Ignore
-          }
-        }
-        if (bos != null) {
-          try {
-            bos.close();
-          } catch (IOException ioe) {
-            // Ignore
-          }
-        }
-        if (fos != null) {
-          try {
-            fos.close();
-          } catch (IOException ioe) {
-            // Ignore
-          }
-        }
-      }
-    }
-
-    ArrayList<StandardSession> list = new ArrayList<StandardSession>();
-    Iterator<String> elements = results.iterator();
-    while (elements.hasNext()) {
-      String id = elements.next();
-      DeltaSession session = (DeltaSession) findSession(id);
-      if (session != null) {
-        list.add(session);
-      }
-    }
-
-    // Write the number of active sessions, followed by the details
-    if (getLogger().isDebugEnabled())
-      getLogger().debug("Unloading " + list.size() + " sessions");
-    try {
-      oos.writeObject(new Integer(list.size()));
-      for (StandardSession session : list) {
-        session.passivate();
-        session.writeObjectData(oos);
-      }
-    } catch (IOException e) {
-      getLogger().error("Exception unloading sessions", e);
-      try {
-        oos.close();
-      } catch (IOException f) {
-        // Ignore
-      }
-      throw e;
-    }
-
-    // Flush and close the output stream
-    try {
-      oos.flush();
-    } finally {
-      try {
-        oos.close();
-      } catch (IOException f) {
-        // Ignore
-      }
-    }
-
-    // Locally destroy the sessions we just wrote
-    if (getSessionCache().isClientServer()) {
-      for (StandardSession session : list) {
-        if (getLogger().isDebugEnabled()) {
-          getLogger().debug("Locally destroying session " + session.getId());
-        }
-        getSessionCache().getOperatingRegion().localDestroy(session.getId());
-      }
-    }
-
-//    // Expire all the sessions we just wrote
-//    if (getLogger().isDebugEnabled()) {
-//      getLogger().debug("Expiring " + list.size() + " persisted sessions");
-//    }
-//    Iterator<StandardSession> expires = list.iterator();
-//    while (expires.hasNext()) {
-//      StandardSession session = expires.next();
-//      try {
-//        session.expire(false);
-//      } catch (Throwable t) {
-////        ExceptionUtils.handleThrowable(t);
-//      } finally {
-//        session.recycle();
-//      }
-//    }
-
-    if (getLogger().isDebugEnabled()) {
-      getLogger().debug("Unloading complete");
-    }
-  }
-
-  /**
-   * Load any currently active sessions that were previously unloaded
-   * to the appropriate persistence mechanism, if any.  If persistence is not
-   * supported, this method returns without doing anything.
-   *
-   * @exception ClassNotFoundException if a serialized class cannot be
-   *  found during the reload
-   * @exception IOException if an input/output error occurs
-   */
-  protected void doLoad() throws ClassNotFoundException, IOException {
-    Context context;
-    if (getContainer() instanceof Context) {
-      context = (Context) getContainer();
-    } else {
-      getLogger().error("Unable to unload sessions - container is of type " +
-          getContainer().getClass().getName() + " instead of StandardContext");
-      return;
-    }
-
-    // Open an input stream to the specified pathname, if any
-    File store = sessionStore(context.getPath());
-    if (store == null) {
-      getLogger().debug("No session store file found");
-      return;
-    }
-    if (getLogger().isDebugEnabled()) {
-      getLogger().debug("Loading sessions from " + store.getAbsolutePath());
-    }
-    FileInputStream fis = null;
-    BufferedInputStream bis = null;
-    ObjectInputStream ois = null;
-    Loader loader = null;
-    ClassLoader classLoader = null;
-    try {
-      fis = new FileInputStream(store.getAbsolutePath());
-      bis = new BufferedInputStream(fis);
-      if (container != null) {
-        loader = container.getLoader();
-      }
-      if (loader != null) {
-        classLoader = loader.getClassLoader();
-      }
-      if (classLoader != null) {
-        if (getLogger().isDebugEnabled()) {
-          getLogger().debug("Creating custom object input stream for class loader");
-        }
-        ois = new CustomObjectInputStream(bis, classLoader);
-      } else {
-        if (getLogger().isDebugEnabled()) {
-          getLogger().debug("Creating standard object input stream");
-        }
-        ois = new ObjectInputStream(bis);
-      }
-    } catch (FileNotFoundException e) {
-      if (getLogger().isDebugEnabled()) {
-        getLogger().debug("No persisted data file found");
-      }
-      return;
-    } catch (IOException e) {
-      getLogger().error("Exception loading sessions", e);
-      if (fis != null) {
-        try {
-          fis.close();
-        } catch (IOException f) {
-          // Ignore
-        }
-      }
-      if (bis != null) {
-        try {
-          bis.close();
-        } catch (IOException f) {
-          // Ignore
-        }
-      }
-      throw e;
-    }
-
-    // Load the previously unloaded active sessions
-    try {
-      Integer count = (Integer) ois.readObject();
-      int n = count.intValue();
-      if (getLogger().isDebugEnabled()) {
-        getLogger().debug("Loading " + n + " persisted sessions");
-      }
-      for (int i = 0; i < n; i++) {
-        StandardSession session = getNewSession();
-        session.readObjectData(ois);
-        session.setManager(this);
-
-        Region region = getSessionCache().getOperatingRegion();
-        DeltaSession existingSession = (DeltaSession) region.get(session.getId());
-        // Check whether the existing session is newer
-        if (existingSession != null &&
-            existingSession.getLastAccessedTime() > session.getLastAccessedTime()) {
-          if (getLogger().isDebugEnabled()) {
-            getLogger().debug("Loaded session " + session.getId() + " is older than cached copy");
-          }
-          continue;
-        }
-
-        // Check whether the new session has already expired
-        if (! session.isValid()) {
-          if (getLogger().isDebugEnabled()) {
-            getLogger().debug("Loaded session " + session.getId() + " is invalid");
-          }
-          continue;
-        }
-
-        getLogger().debug("Loading session " + session.getId());
-        session.activate();
-        add(session);
-      }
-    } catch (ClassNotFoundException e) {
-      getLogger().error(e);
-      try {
-        ois.close();
-      } catch (IOException f) {
-        // Ignore
-      }
-      throw e;
-    } catch (IOException e) {
-      getLogger().error(e);
-      try {
-        ois.close();
-      } catch (IOException f) {
-        // Ignore
-      }
-      throw e;
-    } finally {
-      // Close the input stream
-      try {
-        ois.close();
-      } catch (IOException f) {
-        // ignored
-      }
-
-      // Delete the persistent storage file
-      if (store.exists()) {
-        store.delete();
-      }
-    }
-  }
-
-  /**
-   * Return a File object representing the pathname to our
-   * persistence file, if any.
-   */
-  private File sessionStore(String ctxPath) {
-    String storeDir = System.getProperty("catalina.base");
-    if (storeDir == null || storeDir.isEmpty()) {
-      storeDir = System.getProperty("java.io.tmpdir");
-    } else {
-      storeDir += System.getProperty("file.separator") + "temp";
-    }
-    File file = new File(storeDir,
-        ctxPath.replaceAll("/", "_") + ".sessions.ser");
-
-    return (file);
-  }
-
-  @Override
-  public String toString() {
-    return new StringBuilder()
-      .append(getClass().getSimpleName())
-      .append("[")
-      .append("container=")
-      .append(getContainer())
-      .append("; regionName=")
-      .append(this.regionName)
-      .append("; regionAttributesId=")
-      .append(this.regionAttributesId)
-      .append("]")
-      .toString();
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/63bc5f03/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/JvmRouteBinderValve.java
----------------------------------------------------------------------
diff --git a/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/JvmRouteBinderValve.java b/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/JvmRouteBinderValve.java
deleted file mode 100644
index 42e25cc..0000000
--- a/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/JvmRouteBinderValve.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*=========================================================================
- * Copyright (c) 2010-2014 Pivotal Software, Inc. All Rights Reserved.
- * This product is protected by U.S. and international copyright
- * and intellectual property laws. Pivotal products are covered by
- * one or more patents listed at http://www.pivotal.io/patents.
- *=========================================================================
- */
-package com.gemstone.gemfire.modules.session.catalina;
-
-import java.io.IOException;
-
-import javax.servlet.ServletException;
-
-import org.apache.catalina.Manager;
-import org.apache.catalina.Session;
-import org.apache.catalina.connector.Request;
-import org.apache.catalina.connector.Response;
-import org.apache.catalina.valves.ValveBase;
-
-public class JvmRouteBinderValve extends ValveBase {
-  
-  protected static final String info = "com.gemstone.gemfire.modules.session.JvmRouteBinderValve/1.0";
-
-  @Override
-  public void invoke(Request request, Response response) throws IOException,
-      ServletException {
-    
-    // Get the Manager
-    Manager manager = request.getContext().getManager();
-
-    // If it is an AbstractManager, handle possible failover
-    if (manager instanceof DeltaSessionManager) {
-      DeltaSessionManager absMgr = (DeltaSessionManager) manager;
-      String localJvmRoute = absMgr.getJvmRoute();
-        if (localJvmRoute != null) {
-          handlePossibleFailover(request, absMgr,localJvmRoute);
-        }
-    }
-
-    // Invoke the next Valve
-    getNext().invoke(request, response);
-  }
-  
-  private void handlePossibleFailover(Request request, DeltaSessionManager manager, String localJvmRoute) {
-    String sessionId = request.getRequestedSessionId();
-    if (sessionId != null) {
-      // Get request JVM route
-      String requestJvmRoute = null;
-      int index = sessionId.indexOf(".");
-      if (index > 0) {
-        requestJvmRoute = sessionId.substring(index + 1, sessionId.length());
-      }
-
-      // If the requested JVM route doesn't equal the session's JVM route, handle failover
-      if (requestJvmRoute != null && !requestJvmRoute.equals(localJvmRoute)) {
-        if (manager.getLogger().isDebugEnabled()) {
-          StringBuilder builder = new StringBuilder();
-          builder
-            .append(this)
-            .append(": Handling failover of session ")
-            .append(sessionId)
-            .append(" from ")
-            .append(requestJvmRoute)
-            .append(" to ")
-            .append(localJvmRoute);
-          manager.getLogger().debug(builder.toString());
-        }
-        // Get the original session
-        Session session = null;
-        try {
-          session = manager.findSession(sessionId);
-        } catch (IOException e) {
-          StringBuilder builder = new StringBuilder();
-          builder
-            .append(this)
-            .append(": Caught exception attempting to find session ")
-            .append(sessionId)
-            .append(" in ")
-            .append(manager);
-          manager.getLogger().warn(builder.toString(), e);
-        }
-        
-        if (session == null) {
-          StringBuilder builder = new StringBuilder();
-          builder
-            .append(this)
-            .append(": Did not find session ")
-            .append(sessionId)
-            .append(" to failover in ")
-            .append(manager);
-          manager.getLogger().warn(builder.toString());
-        } else {
-          // Change its session id. This removes the previous session and creates the new one.
-          String baseSessionId = sessionId.substring(0, index);
-          String newSessionId = baseSessionId + "." + localJvmRoute;
-          session.setId(newSessionId);
-  
-          // Change the request's session id
-          request.changeSessionId(newSessionId);
-        }
-      }
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/63bc5f03/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/LocalStrings.properties
----------------------------------------------------------------------
diff --git a/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/LocalStrings.properties b/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/LocalStrings.properties
deleted file mode 100644
index 5abddf7..0000000
--- a/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/LocalStrings.properties
+++ /dev/null
@@ -1 +0,0 @@
-deltaSession.commit.ise=commit: Session {0} already invalidated

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/63bc5f03/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/PeerToPeerCacheLifecycleListener.java
----------------------------------------------------------------------
diff --git a/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/PeerToPeerCacheLifecycleListener.java b/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/PeerToPeerCacheLifecycleListener.java
deleted file mode 100644
index 30da3bc..0000000
--- a/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/PeerToPeerCacheLifecycleListener.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package com.gemstone.gemfire.modules.session.catalina;
-
-import com.gemstone.gemfire.modules.session.bootstrap.PeerToPeerCache;
-
-/**
- * This is a thin wrapper around a peer-to-peer cache.
- */
-public class PeerToPeerCacheLifecycleListener 
-    extends AbstractCacheLifecycleListener {
-
-  public PeerToPeerCacheLifecycleListener() {
-    cache = PeerToPeerCache.getInstance();
-  }
-}



Mime
View raw message