You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by je...@apache.org on 2015/12/22 22:08:25 UTC
[13/17] incubator-geode git commit: GEODE-14: Formatting changes
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8af9dfd7/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/DeltaSessionManager.java
----------------------------------------------------------------------
diff --git a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/DeltaSessionManager.java b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/DeltaSessionManager.java
index c5befb5..832d04b 100644
--- a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/DeltaSessionManager.java
+++ b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/DeltaSessionManager.java
@@ -7,6 +7,30 @@
*/
package com.gemstone.gemfire.modules.session.catalina;
+import com.gemstone.gemfire.cache.CacheFactory;
+import com.gemstone.gemfire.cache.Region;
+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.internal.cache.GemFireCacheImpl;
+import com.gemstone.gemfire.modules.session.catalina.internal.DeltaSessionStatistics;
+import com.gemstone.gemfire.modules.util.ContextMapper;
+import com.gemstone.gemfire.modules.util.RegionConfiguration;
+import com.gemstone.gemfire.modules.util.RegionHelper;
+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 java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.BufferedInputStream;
@@ -29,39 +53,13 @@ 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 {
+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.
*/
@@ -81,19 +79,19 @@ abstract public class DeltaSessionManager extends ManagerBase implements Lifecyc
* 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;
@@ -109,9 +107,9 @@ abstract public class DeltaSessionManager extends ManagerBase implements Lifecyc
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;
@@ -119,7 +117,7 @@ abstract public class DeltaSessionManager extends ManagerBase implements Lifecyc
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;
@@ -130,23 +128,20 @@ abstract public class DeltaSessionManager extends ManagerBase implements Lifecyc
private final Set<String> sessionsToTouch;
- private static final long TIMER_TASK_PERIOD =
- Long.getLong("gemfiremodules.sessionTimerTaskPeriod", 10000);
+ private static final long TIMER_TASK_PERIOD = Long.getLong("gemfiremodules.sessionTimerTaskPeriod", 10000);
- private static final long TIMER_TASK_DELAY =
- Long.getLong("gemfiremodules.sessionTimerTaskDelay", 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>());
+ this.sessionsToTouch = Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>());
}
-
+
@Override
public String getRegionName() {
return this.regionName;
}
-
+
public void setRegionName(String regionName) {
this.regionName = regionName;
}
@@ -161,11 +156,11 @@ abstract public class DeltaSessionManager extends ManagerBase implements Lifecyc
}
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.
@@ -176,7 +171,7 @@ abstract public class DeltaSessionManager extends ManagerBase implements Lifecyc
}
return this.enableLocalCache;
}
-
+
public void setEnableLocalCache(boolean enableLocalCache) {
this.enableLocalCache = enableLocalCache;
}
@@ -188,8 +183,8 @@ abstract public class DeltaSessionManager extends ManagerBase implements Lifecyc
public void setMaxActiveSessions(int maxActiveSessions) {
int oldMaxActiveSessions = this.maxActiveSessions;
this.maxActiveSessions = maxActiveSessions;
- support.firePropertyChange("maxActiveSessions",
- new Integer(oldMaxActiveSessions), new Integer(this.maxActiveSessions));
+ support.firePropertyChange("maxActiveSessions", new Integer(oldMaxActiveSessions),
+ new Integer(this.maxActiveSessions));
}
@Override
@@ -201,7 +196,7 @@ abstract public class DeltaSessionManager extends ManagerBase implements Lifecyc
public void setEnableGatewayDeltaReplication(boolean enableGatewayDeltaReplication) {
this.enableGatewayDeltaReplication = enableGatewayDeltaReplication;
}
-
+
@Override
public boolean getEnableGatewayReplication() {
return this.enableGatewayReplication;
@@ -233,7 +228,7 @@ abstract public class DeltaSessionManager extends ManagerBase implements Lifecyc
public boolean isCommitValveFailfastEnabled() {
return this.enableCommitValveFailfast;
}
-
+
public void setEnableCommitValveFailfast(boolean enable) {
this.enableCommitValveFailfast = enable;
}
@@ -256,7 +251,7 @@ abstract public class DeltaSessionManager extends ManagerBase implements Lifecyc
public String getStatisticsName() {
return getContainer().getName().replace("/", "");
}
-
+
@Override
public Log getLogger() {
if (LOGGER == null) {
@@ -264,33 +259,31 @@ abstract public class DeltaSessionManager extends ManagerBase implements Lifecyc
}
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
+ * This method was taken from StandardManager to set the default maxInactiveInterval based on the container (to 30
+ * minutes).
+ * <p>
+ * 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) {
@@ -326,8 +319,8 @@ abstract public class DeltaSessionManager extends ManagerBase implements Lifecyc
* version number; something like /test###2.
*/
if (session != null &&
- ! session.getContextName().isEmpty() &&
- ! getContainer().getName().equals(session.getContextName())) {
+ !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());
@@ -340,11 +333,12 @@ abstract public class DeltaSessionManager extends ManagerBase implements Lifecyc
}
} else {
if (getLogger().isDebugEnabled()) {
- getLogger().debug(this + ": Found session " + id + " in " + getSessionCache().getOperatingRegionName() + ": " + session);
+ 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.
@@ -361,13 +355,13 @@ abstract public class DeltaSessionManager extends ManagerBase implements Lifecyc
// 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.");
+ 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);
+ this.sessionCache = cache.isClient() ? new ClientServerSessionCache(this, cache) : new PeerToPeerSessionCache(this,
+ cache);
// Initialize the session cache
this.sessionCache.initialize();
@@ -390,15 +384,18 @@ abstract public class DeltaSessionManager extends ManagerBase implements Lifecyc
DeltaSession ds = (DeltaSession) session;
if (ds.getExpired()) {
if (getLogger().isDebugEnabled()) {
- getLogger().debug(this + ": Expired session " + session.getId() + " from " + getSessionCache().getOperatingRegionName());
+ getLogger().debug(
+ this + ": Expired session " + session.getId() + " from " + getSessionCache().getOperatingRegionName());
}
} else {
if (getLogger().isDebugEnabled()) {
- getLogger().debug(this + ": Destroying session " + session.getId() + " from " + getSessionCache().getOperatingRegionName());
+ 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());
+ getLogger().debug(
+ this + ": Destroyed session " + session.getId() + " from " + getSessionCache().getOperatingRegionName());
}
}
}
@@ -407,11 +404,13 @@ abstract public class DeltaSessionManager extends ManagerBase implements Lifecyc
public void add(Session session) {
//super.add(session);
if (getLogger().isDebugEnabled()) {
- getLogger().debug(this + ": Storing session " + session.getId() + " into " + getSessionCache().getOperatingRegionName());
+ 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());
+ getLogger().debug(
+ this + ": Stored session " + session.getId() + " into " + getSessionCache().getOperatingRegionName());
}
getSessionCache().getStatistics().incSessionsCreated();
}
@@ -429,7 +428,7 @@ abstract public class DeltaSessionManager extends ManagerBase implements Lifecyc
this.rejectedSessions.incrementAndGet();
}
- /**
+ /**
* Returns the number of active sessions
*
* @return number of sessions active
@@ -439,18 +438,17 @@ abstract public class DeltaSessionManager extends ManagerBase implements Lifecyc
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());
+ builder.append(sessionIds.next());
if (sessionIds.hasNext()) {
- builder.append(" ");
+ builder.append(" ");
}
}
return builder.toString();
@@ -487,7 +485,7 @@ abstract public class DeltaSessionManager extends ManagerBase implements Lifecyc
// Schedule the task to handle sessions to be touched
scheduleTouchSessionsTask();
-
+
// Schedule the task to maintain the maxActive sessions
scheduleDetermineMaxActiveSessionsTask();
}
@@ -518,18 +516,18 @@ abstract public class DeltaSessionManager extends ManagerBase implements Lifecyc
this.timer.cancel();
}
}
-
+
private void scheduleDetermineMaxActiveSessionsTask() {
TimerTask task = new TimerTask() {
@Override
public void run() {
- int currentActiveSessions = getSessionCache().size();
- if (currentActiveSessions > getMaxActive()) {
- setMaxActive(currentActiveSessions);
+ 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);
@@ -571,7 +569,7 @@ abstract public class DeltaSessionManager extends ManagerBase implements Lifecyc
commitSessionValve = new CommitSessionValve();
getContainer().getPipeline().addValve(commitSessionValve);
}
-
+
protected void unregisterCommitSessionValve() {
if (getLogger().isDebugEnabled()) {
getLogger().debug(this + ": Unregistering CommitSessionValve");
@@ -580,9 +578,9 @@ abstract public class DeltaSessionManager extends ManagerBase implements Lifecyc
getContainer().getPipeline().removeValve(commitSessionValve);
}
}
-
+
// ------------------------------ Lifecycle Methods
-
+
/**
* Add a lifecycle event listener to this component.
*
@@ -594,8 +592,8 @@ abstract public class DeltaSessionManager extends ManagerBase implements Lifecyc
}
/**
- * Get the lifecycle listeners associated with this lifecycle. If this
- * Lifecycle has no listeners registered, a zero-length array is returned.
+ * 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() {
@@ -611,29 +609,21 @@ abstract public class DeltaSessionManager extends ManagerBase implements Lifecyc
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.
- *
+ * <p>
+ * 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.
+ * <p>
* 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
+ * <p>
+ * <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) {
@@ -647,31 +637,31 @@ abstract public class DeltaSessionManager extends ManagerBase implements Lifecyc
// 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);
+ 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()));
+ 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.
+ * 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
+ * @throws IOException if an input/output error occurs
*/
protected void doUnload() throws IOException {
QueryService querySvc = sessionCache.getCache().getQueryService();
@@ -763,8 +753,7 @@ abstract public class DeltaSessionManager extends ManagerBase implements Lifecyc
}
// Write the number of active sessions, followed by the details
- if (getLogger().isDebugEnabled())
- getLogger().debug("Unloading " + list.size() + " sessions");
+ if (getLogger().isDebugEnabled()) getLogger().debug("Unloading " + list.size() + " sessions");
try {
oos.writeObject(new Integer(list.size()));
for (StandardSession session : list) {
@@ -824,13 +813,11 @@ abstract public class DeltaSessionManager extends ManagerBase implements Lifecyc
}
/**
- * 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.
+ * 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
+ * @throws ClassNotFoundException if a serialized class cannot be found during the reload
+ * @throws IOException if an input/output error occurs
*/
protected void doLoad() throws ClassNotFoundException, IOException {
Context context;
@@ -915,8 +902,7 @@ abstract public class DeltaSessionManager extends ManagerBase implements Lifecyc
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 (existingSession != null && existingSession.getLastAccessedTime() > session.getLastAccessedTime()) {
if (getLogger().isDebugEnabled()) {
getLogger().debug("Loaded session " + session.getId() + " is older than cached copy");
}
@@ -924,7 +910,7 @@ abstract public class DeltaSessionManager extends ManagerBase implements Lifecyc
}
// Check whether the new session has already expired
- if (! session.isValid()) {
+ if (!session.isValid()) {
if (getLogger().isDebugEnabled()) {
getLogger().debug("Loaded session " + session.getId() + " is invalid");
}
@@ -967,8 +953,7 @@ abstract public class DeltaSessionManager extends ManagerBase implements Lifecyc
}
/**
- * Return a File object representing the pathname to our
- * persistence file, if any.
+ * Return a File object representing the pathname to our persistence file, if any.
*/
private File sessionStore(String ctxPath) {
String storeDir = System.getProperty("catalina.base");
@@ -977,24 +962,22 @@ abstract public class DeltaSessionManager extends ManagerBase implements Lifecyc
} else {
storeDir += System.getProperty("file.separator") + "temp";
}
- File file = new File(storeDir,
- ctxPath.replaceAll("/", "_") + ".sessions.ser");
+ 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();
+ 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/8af9dfd7/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/JvmRouteBinderValve.java
----------------------------------------------------------------------
diff --git a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/JvmRouteBinderValve.java b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/JvmRouteBinderValve.java
index 42e25cc..0519425 100644
--- a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/JvmRouteBinderValve.java
+++ b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/JvmRouteBinderValve.java
@@ -7,24 +7,22 @@
*/
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;
+import javax.servlet.ServletException;
+import java.io.IOException;
+
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 {
-
+ public void invoke(Request request, Response response) throws IOException, ServletException {
+
// Get the Manager
Manager manager = request.getContext().getManager();
@@ -32,15 +30,15 @@ public class JvmRouteBinderValve extends ValveBase {
if (manager instanceof DeltaSessionManager) {
DeltaSessionManager absMgr = (DeltaSessionManager) manager;
String localJvmRoute = absMgr.getJvmRoute();
- if (localJvmRoute != null) {
- handlePossibleFailover(request, absMgr,localJvmRoute);
- }
+ 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) {
@@ -55,14 +53,13 @@ public class JvmRouteBinderValve extends ValveBase {
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);
+ 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
@@ -71,30 +68,28 @@ public class JvmRouteBinderValve extends ValveBase {
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);
+ 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);
+ 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/8af9dfd7/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/PeerToPeerCacheLifecycleListener.java
----------------------------------------------------------------------
diff --git a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/PeerToPeerCacheLifecycleListener.java b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/PeerToPeerCacheLifecycleListener.java
index 30da3bc..8c40fc5 100644
--- a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/PeerToPeerCacheLifecycleListener.java
+++ b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/PeerToPeerCacheLifecycleListener.java
@@ -5,8 +5,7 @@ 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 class PeerToPeerCacheLifecycleListener extends AbstractCacheLifecycleListener {
public PeerToPeerCacheLifecycleListener() {
cache = PeerToPeerCache.getInstance();
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8af9dfd7/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/PeerToPeerSessionCache.java
----------------------------------------------------------------------
diff --git a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/PeerToPeerSessionCache.java b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/PeerToPeerSessionCache.java
index df9c152..b2b8dfa 100644
--- a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/PeerToPeerSessionCache.java
+++ b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/PeerToPeerSessionCache.java
@@ -7,9 +7,6 @@
*/
package com.gemstone.gemfire.modules.session.catalina;
-import java.util.Set;
-
-
import com.gemstone.gemfire.cache.Cache;
import com.gemstone.gemfire.cache.GemFireCache;
import com.gemstone.gemfire.cache.Region;
@@ -26,12 +23,14 @@ import com.gemstone.gemfire.modules.util.RegionHelper;
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;
+import java.util.Set;
public class PeerToPeerSessionCache extends AbstractSessionCache {
private Cache cache;
-
+
protected static final String DEFAULT_REGION_ATTRIBUTES_ID = RegionShortcut.REPLICATE.toString();
protected static final boolean DEFAULT_ENABLE_LOCAL_CACHE = false;
@@ -40,31 +39,29 @@ public class PeerToPeerSessionCache extends AbstractSessionCache {
super(sessionManager);
this.cache = cache;
}
-
+
@Override
public void initialize() {
// Register Functions
registerFunctions();
-
+
// Create or retrieve the region
createOrRetrieveRegion();
// If local cache is enabled, create the local region fronting the session region
// and set it as the operating region; otherwise, use the session region directly
// as the operating region.
- this.operatingRegion = getSessionManager().getEnableLocalCache()
- ? createOrRetrieveLocalRegion()
- : this.sessionRegion;
-
+ this.operatingRegion = getSessionManager().getEnableLocalCache() ? createOrRetrieveLocalRegion() : 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;
@@ -76,7 +73,7 @@ public class PeerToPeerSessionCache extends AbstractSessionCache {
// problematic since the region attributes id doesn't really define the
// region type. This should look at the actual session region.
String regionAttributesID = getSessionManager().getRegionAttributesId().toLowerCase();
-
+
// Invoke the appropriate function depending on the type of region
ResultCollector collector = null;
if (regionAttributesID.startsWith("partition")) {
@@ -85,12 +82,11 @@ public class PeerToPeerSessionCache extends AbstractSessionCache {
collector = execution.execute(TouchPartitionedRegionEntriesFunction.ID, true, false, true);
} else {
// Execute the member touch function on all the server(s)
- Execution execution = FunctionService.onMembers(
- getCache().getDistributedSystem()).withArgs(
- new Object[] { this.sessionRegion.getFullPath(), sessionIds });
+ Execution execution = FunctionService.onMembers(getCache().getDistributedSystem())
+ .withArgs(new Object[]{this.sessionRegion.getFullPath(), sessionIds});
collector = execution.execute(TouchReplicatedRegionEntriesFunction.ID, true, false, false);
}
-
+
// Get the result
try {
collector.getResult();
@@ -99,25 +95,25 @@ public class PeerToPeerSessionCache extends AbstractSessionCache {
getSessionManager().getLogger().warn("Caught unexpected exception:", e);
}
}
-
+
@Override
public boolean isPeerToPeer() {
return true;
}
-
+
@Override
public boolean isClientServer() {
return false;
}
-
+
@Override
public Set<String> keySet() {
- return getSessionRegion().keySet();
+ return getSessionRegion().keySet();
}
@Override
public int size() {
- return getSessionRegion().size();
+ return getSessionRegion().size();
}
@Override
@@ -127,6 +123,7 @@ public class PeerToPeerSessionCache extends AbstractSessionCache {
/**
* For peer-to-peer the backing cache *is* what's embedded in tomcat so it's always available
+ *
* @return
*/
@Override
@@ -139,7 +136,7 @@ public class PeerToPeerSessionCache extends AbstractSessionCache {
if (!FunctionService.isRegistered(TouchPartitionedRegionEntriesFunction.ID)) {
FunctionService.registerFunction(new TouchPartitionedRegionEntriesFunction());
}
-
+
// Register the touch replicated region entries function if it is not already registered
if (!FunctionService.isRegistered(TouchReplicatedRegionEntriesFunction.ID)) {
FunctionService.registerFunction(new TouchReplicatedRegionEntriesFunction());
@@ -173,19 +170,19 @@ public class PeerToPeerSessionCache extends AbstractSessionCache {
// Set the session region
this.sessionRegion = region;
}
-
+
private Region<String, HttpSession> createOrRetrieveLocalRegion() {
// Attempt to retrieve the fronting region
String frontingRegionName = this.sessionRegion.getName() + "_local";
Region<String, HttpSession> frontingRegion = this.cache.getRegion(frontingRegionName);
if (frontingRegion == null) {
// Create the region factory
- RegionFactory<String,HttpSession> factory = this.cache.createRegionFactory(RegionShortcut.LOCAL_HEAP_LRU);
-
+ RegionFactory<String, HttpSession> factory = this.cache.createRegionFactory(RegionShortcut.LOCAL_HEAP_LRU);
+
// Add the cache loader and writer
factory.setCacheLoader(new LocalSessionCacheLoader(this.sessionRegion));
factory.setCacheWriter(new LocalSessionCacheWriter(this.sessionRegion));
-
+
// Set the expiration time, action and listener if necessary
int maxInactiveInterval = getSessionManager().getMaxInactiveInterval();
if (maxInactiveInterval != RegionConfiguration.DEFAULT_MAX_INACTIVE_INTERVAL) {
@@ -193,7 +190,7 @@ public class PeerToPeerSessionCache extends AbstractSessionCache {
factory.setCustomEntryIdleTimeout(new SessionCustomExpiry());
factory.addCacheListener(new SessionExpirationCacheListener());
}
-
+
// Create the region
frontingRegion = factory.create(frontingRegionName);
if (getSessionManager().getLogger().isDebugEnabled()) {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8af9dfd7/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/SessionCache.java
----------------------------------------------------------------------
diff --git a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/SessionCache.java b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/SessionCache.java
index a14ee8b..fe88d41 100644
--- a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/SessionCache.java
+++ b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/SessionCache.java
@@ -7,48 +7,48 @@
*/
package com.gemstone.gemfire.modules.session.catalina;
-import java.util.Set;
-
import com.gemstone.gemfire.cache.GemFireCache;
import com.gemstone.gemfire.cache.Region;
import com.gemstone.gemfire.modules.session.catalina.internal.DeltaSessionStatistics;
-import javax.servlet.http.HttpSession;
import org.apache.catalina.Session;
+import javax.servlet.http.HttpSession;
+import java.util.Set;
+
public interface SessionCache {
-
+
public void initialize();
-
+
public String getDefaultRegionAttributesId();
public boolean getDefaultEnableLocalCache();
-
+
public String getSessionRegionName();
-
+
public String getOperatingRegionName();
public void putSession(Session session);
-
+
public HttpSession getSession(String sessionId);
-
+
public void destroySession(String sessionId);
-
+
public void touchSessions(Set<String> sessionIds);
-
+
public DeltaSessionStatistics getStatistics();
-
+
public GemFireCache getCache();
-
- public Region<String,HttpSession> getSessionRegion();
-
- public Region<String,HttpSession> getOperatingRegion();
-
+
+ public Region<String, HttpSession> getSessionRegion();
+
+ public Region<String, HttpSession> getOperatingRegion();
+
public boolean isPeerToPeer();
-
+
public boolean isClientServer();
-
+
public Set<String> keySet();
-
+
public int size();
public boolean isBackingCacheAvailable();
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8af9dfd7/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/SessionManager.java
----------------------------------------------------------------------
diff --git a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/SessionManager.java b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/SessionManager.java
index 1df8aab..fe66d41 100644
--- a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/SessionManager.java
+++ b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/SessionManager.java
@@ -12,15 +12,15 @@ import org.apache.juli.logging.Log;
public interface SessionManager {
public String getRegionName();
-
+
public String getRegionAttributesId();
-
+
public int getMaxInactiveInterval();
-
+
public boolean getEnableGatewayReplication();
-
+
public boolean getEnableGatewayDeltaReplication();
-
+
public boolean getEnableDebugListener();
public boolean getEnableLocalCache();
@@ -34,6 +34,6 @@ public interface SessionManager {
public boolean getPreferDeserializedForm();
public String getStatisticsName();
-
+
public Log getLogger();
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8af9dfd7/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/Tomcat6DeltaSessionManager.java
----------------------------------------------------------------------
diff --git a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/Tomcat6DeltaSessionManager.java b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/Tomcat6DeltaSessionManager.java
index 17b03ec..8a68a06 100644
--- a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/Tomcat6DeltaSessionManager.java
+++ b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/Tomcat6DeltaSessionManager.java
@@ -12,13 +12,11 @@ import org.apache.catalina.LifecycleException;
public class Tomcat6DeltaSessionManager extends DeltaSessionManager {
/**
- * Prepare for the beginning of active use of the public methods of this
- * component. This method should be called after <code>configure()</code>,
- * and before any of the public methods of the component are utilized.
+ * Prepare for the beginning of active use of the public methods of this component. This method should be called
+ * after <code>configure()</code>, and before any of the public methods of the component are utilized.
*
- * @exception LifecycleException if this component detects a fatal error
- * that prevents this component from being used
- */
+ * @throws LifecycleException if this component detects a fatal error that prevents this component from being used
+ */
@Override
public void start() throws LifecycleException {
if (getLogger().isDebugEnabled()) {
@@ -33,14 +31,14 @@ public class Tomcat6DeltaSessionManager extends DeltaSessionManager {
} catch (Throwable t) {
getLogger().error(t.getMessage(), t);
}
-
+
// Register our various valves
registerJvmRouteBinderValve();
if (isCommitValveEnabled()) {
registerCommitSessionValve();
}
-
+
// Initialize the appropriate session cache interface
initializeSessionCache();
@@ -51,12 +49,10 @@ public class Tomcat6DeltaSessionManager extends DeltaSessionManager {
}
/**
- * Gracefully terminate the active use of the public methods of this
- * component. This method should be the last one called on a given
- * instance of this component.
+ * Gracefully terminate the active use of the public methods of this component. This method should be the last one
+ * called on a given instance of this component.
*
- * @exception LifecycleException if this component detects a fatal error
- * that needs to be reported
+ * @throws LifecycleException if this component detects a fatal error that needs to be reported
*/
@Override
public void stop() throws LifecycleException {
@@ -68,7 +64,7 @@ public class Tomcat6DeltaSessionManager extends DeltaSessionManager {
// StandardManager expires all Sessions here.
// All Sessions are not known by this Manager.
-
+
// Require a new random number generator if we are restarted
this.random = null;
@@ -76,13 +72,13 @@ public class Tomcat6DeltaSessionManager extends DeltaSessionManager {
if (this.initialized) {
destroy();
}
-
+
// Clear any sessions to be touched
getSessionsToTouch().clear();
-
+
// Cancel the timer
cancelTimer();
-
+
// Unregister the JVM route valve
unregisterJvmRouteBinderValve();
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8af9dfd7/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/callback/LocalSessionCacheLoader.java
----------------------------------------------------------------------
diff --git a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/callback/LocalSessionCacheLoader.java b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/callback/LocalSessionCacheLoader.java
index ff1ab0b..9247627 100644
--- a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/callback/LocalSessionCacheLoader.java
+++ b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/callback/LocalSessionCacheLoader.java
@@ -1,35 +1,36 @@
-/*=========================================================================
- * 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.
- *=========================================================================
- */
+/*=========================================================================
+ * 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.callback;
-import java.util.Properties;
-
import com.gemstone.gemfire.cache.CacheLoader;
import com.gemstone.gemfire.cache.CacheLoaderException;
import com.gemstone.gemfire.cache.Declarable;
import com.gemstone.gemfire.cache.LoaderHelper;
import com.gemstone.gemfire.cache.Region;
+
import javax.servlet.http.HttpSession;
+import java.util.Properties;
-public class LocalSessionCacheLoader implements CacheLoader<String, HttpSession>,
- Declarable {
+public class LocalSessionCacheLoader implements CacheLoader<String, HttpSession>, Declarable {
- private final Region<String,HttpSession> backingRegion;
-
- public LocalSessionCacheLoader(Region<String,HttpSession> backingRegion) {
+ private final Region<String, HttpSession> backingRegion;
+
+ public LocalSessionCacheLoader(Region<String, HttpSession> backingRegion) {
this.backingRegion = backingRegion;
}
-
- public HttpSession load(LoaderHelper<String,HttpSession> helper) throws CacheLoaderException {
+
+ public HttpSession load(LoaderHelper<String, HttpSession> helper) throws CacheLoaderException {
return this.backingRegion.get(helper.getKey());
}
- public void close() {}
+ public void close() {
+ }
- public void init(Properties p) {}
+ public void init(Properties p) {
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8af9dfd7/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/callback/LocalSessionCacheWriter.java
----------------------------------------------------------------------
diff --git a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/callback/LocalSessionCacheWriter.java b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/callback/LocalSessionCacheWriter.java
index 458c8e8..990d53b 100644
--- a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/callback/LocalSessionCacheWriter.java
+++ b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/callback/LocalSessionCacheWriter.java
@@ -1,42 +1,39 @@
-/*=========================================================================
- * 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.
- *=========================================================================
- */
+/*=========================================================================
+ * 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.callback;
-import java.util.Properties;
-
-import org.apache.catalina.Session;
-
import com.gemstone.gemfire.cache.CacheWriterException;
import com.gemstone.gemfire.cache.Declarable;
import com.gemstone.gemfire.cache.EntryEvent;
import com.gemstone.gemfire.cache.EntryNotFoundException;
import com.gemstone.gemfire.cache.Region;
import com.gemstone.gemfire.cache.util.CacheWriterAdapter;
+
import javax.servlet.http.HttpSession;
+import java.util.Properties;
+
+public class LocalSessionCacheWriter extends CacheWriterAdapter<String, HttpSession> implements Declarable {
-public class LocalSessionCacheWriter extends
- CacheWriterAdapter<String, HttpSession> implements Declarable {
+ private final Region<String, HttpSession> backingRegion;
- private final Region<String,HttpSession> backingRegion;
-
- public LocalSessionCacheWriter(Region<String,HttpSession> backingRegion) {
+ public LocalSessionCacheWriter(Region<String, HttpSession> backingRegion) {
this.backingRegion = backingRegion;
}
- public void beforeCreate(EntryEvent<String,HttpSession> event) throws CacheWriterException {
+ public void beforeCreate(EntryEvent<String, HttpSession> event) throws CacheWriterException {
this.backingRegion.put(event.getKey(), event.getNewValue(), event.getCallbackArgument());
}
- public void beforeUpdate(EntryEvent<String,HttpSession> event) throws CacheWriterException {
+ public void beforeUpdate(EntryEvent<String, HttpSession> event) throws CacheWriterException {
this.backingRegion.put(event.getKey(), event.getNewValue(), event.getCallbackArgument());
}
- public void beforeDestroy(EntryEvent<String,HttpSession> event) throws CacheWriterException {
+ public void beforeDestroy(EntryEvent<String, HttpSession> event) throws CacheWriterException {
try {
this.backingRegion.destroy(event.getKey(), event.getCallbackArgument());
} catch (EntryNotFoundException e) {
@@ -45,7 +42,9 @@ public class LocalSessionCacheWriter extends
}
}
- public void close() {}
+ public void close() {
+ }
- public void init(Properties p) {}
+ public void init(Properties p) {
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8af9dfd7/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/callback/SessionExpirationCacheListener.java
----------------------------------------------------------------------
diff --git a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/callback/SessionExpirationCacheListener.java b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/callback/SessionExpirationCacheListener.java
index d5f9bf5..2841f28 100644
--- a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/callback/SessionExpirationCacheListener.java
+++ b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/callback/SessionExpirationCacheListener.java
@@ -10,19 +10,17 @@ package com.gemstone.gemfire.modules.session.catalina.callback;
import com.gemstone.gemfire.cache.Declarable;
import com.gemstone.gemfire.cache.EntryEvent;
import com.gemstone.gemfire.cache.Operation;
-
import com.gemstone.gemfire.cache.util.CacheListenerAdapter;
import com.gemstone.gemfire.modules.session.catalina.DeltaSession;
import com.gemstone.gemfire.modules.session.catalina.DeltaSessionManager;
import com.gemstone.gemfire.modules.util.ContextMapper;
-import java.util.Properties;
-
import javax.servlet.http.HttpSession;
+import java.util.Properties;
-public class SessionExpirationCacheListener extends CacheListenerAdapter<String,HttpSession> implements Declarable {
+public class SessionExpirationCacheListener extends CacheListenerAdapter<String, HttpSession> implements Declarable {
- public void afterDestroy(EntryEvent<String,HttpSession> event) {
+ public void afterDestroy(EntryEvent<String, HttpSession> event) {
// A Session expired. If it was destroyed by GemFire expiration, process it.
// If it was destroyed via Session.invalidate, ignore it since it has
// already been processed.
@@ -40,8 +38,7 @@ public class SessionExpirationCacheListener extends CacheListenerAdapter<String,
Object callback = event.getCallbackArgument();
if (callback != null && callback instanceof DeltaSession) {
session = (DeltaSession) callback;
- DeltaSessionManager m = ContextMapper.getContext(
- session.getContextName());
+ DeltaSessionManager m = ContextMapper.getContext(session.getContextName());
if (m != null) {
session.setOwner(m);
}
@@ -52,7 +49,8 @@ public class SessionExpirationCacheListener extends CacheListenerAdapter<String,
}
}
- public void init(Properties p) {}
+ public void init(Properties p) {
+ }
public boolean equals(Object obj) {
// This method is only implemented so that RegionAttributesCreation.sameAs
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8af9dfd7/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/internal/DeltaSessionAttributeEventBatch.java
----------------------------------------------------------------------
diff --git a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/internal/DeltaSessionAttributeEventBatch.java b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/internal/DeltaSessionAttributeEventBatch.java
index b0d8681..190863a 100644
--- a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/internal/DeltaSessionAttributeEventBatch.java
+++ b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/internal/DeltaSessionAttributeEventBatch.java
@@ -7,53 +7,48 @@
*/
package com.gemstone.gemfire.modules.session.catalina.internal;
-import java.io.DataInput;
-import java.io.DataOutput;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
import com.gemstone.gemfire.DataSerializer;
import com.gemstone.gemfire.cache.Cache;
import com.gemstone.gemfire.cache.Region;
import com.gemstone.gemfire.modules.gatewaydelta.AbstractGatewayDeltaEvent;
import com.gemstone.gemfire.modules.session.catalina.DeltaSession;
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
@SuppressWarnings("serial")
public class DeltaSessionAttributeEventBatch extends AbstractGatewayDeltaEvent {
private List<DeltaSessionAttributeEvent> eventQueue;
-
+
public DeltaSessionAttributeEventBatch() {
}
- public DeltaSessionAttributeEventBatch(String regionName, String sessionId, List<DeltaSessionAttributeEvent> eventQueue) {
+ public DeltaSessionAttributeEventBatch(String regionName, String sessionId,
+ List<DeltaSessionAttributeEvent> eventQueue) {
super(regionName, sessionId);
this.eventQueue = eventQueue;
}
-
+
public List<DeltaSessionAttributeEvent> getEventQueue() {
return this.eventQueue;
}
public void apply(Cache cache) {
- Region<String,DeltaSession> region = getRegion(cache);
+ Region<String, DeltaSession> region = getRegion(cache);
DeltaSession session = region.get(this.key);
if (session == null) {
StringBuilder builder = new StringBuilder();
- builder
- .append("Session ")
- .append(this.key)
- .append(" was not found while attempting to apply ")
- .append(this);
+ builder.append("Session ").append(this.key).append(" was not found while attempting to apply ").append(this);
cache.getLogger().warning(builder.toString());
} else {
session.applyAttributeEvents(region, this.eventQueue);
if (cache.getLogger().fineEnabled()) {
StringBuilder builder = new StringBuilder();
- builder
- .append("Applied ")
- .append(this);
+ builder.append("Applied ").append(this);
cache.getLogger().fine(builder.toString());
}
}
@@ -70,16 +65,15 @@ public class DeltaSessionAttributeEventBatch extends AbstractGatewayDeltaEvent {
}
public String toString() {
- return new StringBuilder()
- .append("DeltaSessionAttributeEventBatch[")
- .append("regionName=")
- .append(this.regionName)
- .append("; sessionId=")
- .append(this.key)
- .append("; numberOfEvents=")
- .append(this.eventQueue.size())
- .append("]")
- .toString();
+ return new StringBuilder().append("DeltaSessionAttributeEventBatch[")
+ .append("regionName=")
+ .append(this.regionName)
+ .append("; sessionId=")
+ .append(this.key)
+ .append("; numberOfEvents=")
+ .append(this.eventQueue.size())
+ .append("]")
+ .toString();
}
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8af9dfd7/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/internal/DeltaSessionDestroyAttributeEvent.java
----------------------------------------------------------------------
diff --git a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/internal/DeltaSessionDestroyAttributeEvent.java b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/internal/DeltaSessionDestroyAttributeEvent.java
index a8ee4fa..555caad 100644
--- a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/internal/DeltaSessionDestroyAttributeEvent.java
+++ b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/internal/DeltaSessionDestroyAttributeEvent.java
@@ -7,28 +7,28 @@
*/
package com.gemstone.gemfire.modules.session.catalina.internal;
-import java.io.DataInput;
-import java.io.DataOutput;
-import java.io.IOException;
-
import com.gemstone.gemfire.DataSerializable;
import com.gemstone.gemfire.DataSerializer;
import com.gemstone.gemfire.Instantiator;
import com.gemstone.gemfire.modules.session.catalina.DeltaSession;
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+
@SuppressWarnings("serial")
public class DeltaSessionDestroyAttributeEvent implements DeltaSessionAttributeEvent {
private String attributeName;
-
+
public DeltaSessionDestroyAttributeEvent() {
}
public DeltaSessionDestroyAttributeEvent(String attributeName) {
this.attributeName = attributeName;
}
-
+
public String getAttributeName() {
return this.attributeName;
}
@@ -44,7 +44,7 @@ public class DeltaSessionDestroyAttributeEvent implements DeltaSessionAttributeE
public void toData(DataOutput out) throws IOException {
DataSerializer.writeString(this.attributeName, out);
}
-
+
public static void registerInstantiator(int id) {
Instantiator.register(new Instantiator(DeltaSessionDestroyAttributeEvent.class, id) {
public DataSerializable newInstance() {
@@ -52,14 +52,13 @@ public class DeltaSessionDestroyAttributeEvent implements DeltaSessionAttributeE
}
});
}
-
+
public String toString() {
- return new StringBuilder()
- .append("DeltaSessionDestroyAttributeEvent[")
- .append("attributeName=")
- .append(this.attributeName)
- .append("]")
- .toString();
+ return new StringBuilder().append("DeltaSessionDestroyAttributeEvent[")
+ .append("attributeName=")
+ .append(this.attributeName)
+ .append("]")
+ .toString();
}
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8af9dfd7/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/internal/DeltaSessionStatistics.java
----------------------------------------------------------------------
diff --git a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/internal/DeltaSessionStatistics.java b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/internal/DeltaSessionStatistics.java
index 43c8df5..8341565 100644
--- a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/internal/DeltaSessionStatistics.java
+++ b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/internal/DeltaSessionStatistics.java
@@ -21,8 +21,8 @@ public class DeltaSessionStatistics {
private static final StatisticsType type;
private static final String SESSIONS_CREATED = "sessionsCreated";
- private static final String SESSIONS_INVALIDATED= "sessionsInvalidated";
- private static final String SESSIONS_EXPIRED= "sessionsExpired";
+ private static final String SESSIONS_INVALIDATED = "sessionsInvalidated";
+ private static final String SESSIONS_EXPIRED = "sessionsExpired";
private static final int sessionsCreatedId;
private static final int sessionsInvalidatedId;
@@ -32,12 +32,10 @@ public class DeltaSessionStatistics {
// Initialize type
StatisticsTypeFactory f = StatisticsTypeFactoryImpl.singleton();
type = f.createType(typeName, typeName,
- new StatisticDescriptor[] {
- f.createIntCounter(SESSIONS_CREATED, "The number of sessions created", "operations"),
- f.createIntCounter(SESSIONS_INVALIDATED, "The number of sessions invalidated by invoking invalidate", "operations"),
- f.createIntCounter(SESSIONS_EXPIRED, "The number of sessions invalidated by timeout", "operations"),
- }
- );
+ new StatisticDescriptor[]{f.createIntCounter(SESSIONS_CREATED, "The number of sessions created",
+ "operations"), f.createIntCounter(SESSIONS_INVALIDATED,
+ "The number of sessions invalidated by invoking invalidate", "operations"), f.createIntCounter(
+ SESSIONS_EXPIRED, "The number of sessions invalidated by timeout", "operations"),});
// Initialize id fields
sessionsCreatedId = type.nameToId(SESSIONS_CREATED);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8af9dfd7/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/internal/DeltaSessionUpdateAttributeEvent.java
----------------------------------------------------------------------
diff --git a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/internal/DeltaSessionUpdateAttributeEvent.java b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/internal/DeltaSessionUpdateAttributeEvent.java
index 93fdac4..ac28154 100644
--- a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/internal/DeltaSessionUpdateAttributeEvent.java
+++ b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/internal/DeltaSessionUpdateAttributeEvent.java
@@ -7,22 +7,22 @@
*/
package com.gemstone.gemfire.modules.session.catalina.internal;
-import java.io.DataInput;
-import java.io.DataOutput;
-import java.io.IOException;
-
import com.gemstone.gemfire.DataSerializable;
import com.gemstone.gemfire.DataSerializer;
import com.gemstone.gemfire.Instantiator;
import com.gemstone.gemfire.modules.session.catalina.DeltaSession;
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+
@SuppressWarnings("serial")
public class DeltaSessionUpdateAttributeEvent implements DeltaSessionAttributeEvent {
private String attributeName;
private Object attributeValue;
-
+
public DeltaSessionUpdateAttributeEvent() {
}
@@ -30,7 +30,7 @@ public class DeltaSessionUpdateAttributeEvent implements DeltaSessionAttributeEv
this.attributeName = attributeName;
this.attributeValue = attributeValue;
}
-
+
public String getAttributeName() {
return this.attributeName;
}
@@ -52,7 +52,7 @@ public class DeltaSessionUpdateAttributeEvent implements DeltaSessionAttributeEv
DataSerializer.writeString(this.attributeName, out);
DataSerializer.writeObject(this.attributeValue, out);
}
-
+
public static void registerInstantiator(int id) {
Instantiator.register(new Instantiator(DeltaSessionUpdateAttributeEvent.class, id) {
public DataSerializable newInstance() {
@@ -60,16 +60,15 @@ public class DeltaSessionUpdateAttributeEvent implements DeltaSessionAttributeEv
}
});
}
-
+
public String toString() {
- return new StringBuilder()
- .append("DeltaSessionUpdateAttributeEvent[")
- .append("attributeName=")
- .append(this.attributeName)
- .append("; attributeValue=")
- .append(this.attributeValue)
- .append("]")
- .toString();
+ return new StringBuilder().append("DeltaSessionUpdateAttributeEvent[")
+ .append("attributeName=")
+ .append(this.attributeName)
+ .append("; attributeValue=")
+ .append(this.attributeValue)
+ .append("]")
+ .toString();
}
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8af9dfd7/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/util/Banner.java
----------------------------------------------------------------------
diff --git a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/util/Banner.java b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/util/Banner.java
index 9e3332d..ff9ae35 100644
--- a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/util/Banner.java
+++ b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/util/Banner.java
@@ -7,14 +7,14 @@
*/
package com.gemstone.gemfire.modules.util;
+import com.gemstone.gemfire.internal.GemFireVersion;
+
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Properties;
-import com.gemstone.gemfire.internal.GemFireVersion;
-
public class Banner {
private static String VERSION = "unknown";
@@ -29,7 +29,7 @@ public class Banner {
} catch (IOException e) {
}
}
-
+
public static String getString() {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
@@ -37,13 +37,14 @@ public class Banner {
pw.close();
return sw.toString();
}
-
+
private static void print(PrintWriter pw) {
pw.println("GemFire Modules");
pw.print("Modules version: ");
pw.println(VERSION);
GemFireVersion.print(pw);
}
-
- private Banner() {}
+
+ private Banner() {
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8af9dfd7/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/util/BootstrappingFunction.java
----------------------------------------------------------------------
diff --git a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/util/BootstrappingFunction.java b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/util/BootstrappingFunction.java
index 0a68ae6..d26b048 100644
--- a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/util/BootstrappingFunction.java
+++ b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/util/BootstrappingFunction.java
@@ -25,28 +25,28 @@ import java.util.Set;
public class BootstrappingFunction implements Function, MembershipListener {
private static final long serialVersionUID = 1856043174458190605L;
-
+
public static final String ID = "bootstrapping-function";
-
+
private static final int TIME_TO_WAIT_FOR_CACHE = Integer.getInteger("gemfiremodules.timeToWaitForCache", 30000);
-
+
@Override
public void execute(FunctionContext context) {
// Verify that the cache exists before continuing.
// When this function is executed by a remote membership listener, it is
// being invoked before the cache is started.
Cache cache = verifyCacheExists();
-
+
// Register as membership listener
registerAsMembershipListener(cache);
// Register functions
registerFunctions();
-
+
// Return status
context.getResultSender().lastResult(Boolean.TRUE);
}
-
+
private Cache verifyCacheExists() {
int timeToWait = 0;
Cache cache = null;
@@ -65,11 +65,11 @@ public class BootstrappingFunction implements Function, MembershipListener {
}
timeToWait += 250;
}
-
+
if (cache == null) {
cache = new CacheFactory().create();
}
-
+
return cache;
}
@@ -86,20 +86,20 @@ public class BootstrappingFunction implements Function, MembershipListener {
if (!FunctionService.isRegistered(CreateRegionFunction.ID)) {
FunctionService.registerFunction(new CreateRegionFunction());
}
-
+
// Register the touch partitioned region entries function if it is not already registered
if (!FunctionService.isRegistered(TouchPartitionedRegionEntriesFunction.ID)) {
FunctionService.registerFunction(new TouchPartitionedRegionEntriesFunction());
}
-
+
// Register the touch replicated region entries function if it is not already registered
if (!FunctionService.isRegistered(TouchReplicatedRegionEntriesFunction.ID)) {
FunctionService.registerFunction(new TouchReplicatedRegionEntriesFunction());
}
-
+
// Register the region size function if it is not already registered
if (!FunctionService.isRegistered(RegionSizeFunction.ID)) {
- FunctionService.registerFunction(new RegionSizeFunction());
+ FunctionService.registerFunction(new RegionSizeFunction());
}
}
}
@@ -138,13 +138,13 @@ public class BootstrappingFunction implements Function, MembershipListener {
public boolean optimizeForWrite() {
return false;
}
-
+
public int hashCode() {
// This method is only implemented so that multiple instances of this class
// don't get added as membership listeners.
return ID.hashCode();
}
-
+
public boolean equals(Object obj) {
// This method is only implemented so that multiple instances of this class
// don't get added as membership listeners.
@@ -155,7 +155,7 @@ public class BootstrappingFunction implements Function, MembershipListener {
if (obj == null || !(obj instanceof BootstrappingFunction)) {
return false;
}
-
+
return true;
}
@@ -169,8 +169,7 @@ public class BootstrappingFunction implements Function, MembershipListener {
}
@Override
- public void memberSuspect(InternalDistributedMember id,
- InternalDistributedMember whoSuspected, String reason) {
+ public void memberSuspect(InternalDistributedMember id, InternalDistributedMember whoSuspected, String reason) {
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8af9dfd7/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/util/ClassLoaderObjectInputStream.java
----------------------------------------------------------------------
diff --git a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/util/ClassLoaderObjectInputStream.java b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/util/ClassLoaderObjectInputStream.java
index 6dc991a..f4b96db 100644
--- a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/util/ClassLoaderObjectInputStream.java
+++ b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/util/ClassLoaderObjectInputStream.java
@@ -13,22 +13,19 @@ import java.io.ObjectInputStream;
import java.io.ObjectStreamClass;
/**
- * This class is used when session attributes need to be reconstructed with a
- * new classloader.
+ * This class is used when session attributes need to be reconstructed with a new classloader.
*/
public class ClassLoaderObjectInputStream extends ObjectInputStream {
private final ClassLoader loader;
- public ClassLoaderObjectInputStream(InputStream in,
- ClassLoader loader) throws IOException {
+ public ClassLoaderObjectInputStream(InputStream in, ClassLoader loader) throws IOException {
super(in);
this.loader = loader;
}
@Override
- public Class<?> resolveClass(
- ObjectStreamClass desc) throws ClassNotFoundException {
+ public Class<?> resolveClass(ObjectStreamClass desc) throws ClassNotFoundException {
return Class.forName(desc.getName(), false, loader);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8af9dfd7/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/util/ContextMapper.java
----------------------------------------------------------------------
diff --git a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/util/ContextMapper.java b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/util/ContextMapper.java
index d1a5404..787c9e8 100644
--- a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/util/ContextMapper.java
+++ b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/util/ContextMapper.java
@@ -7,21 +7,17 @@ import java.util.Map;
/**
* This basic singleton class maps context paths to manager instances.
- *
- * This class exists for a particular corner case described here. Consider a
- * client-server environment with empty client regions *and* the need to fire
- * HttpSessionListener destroy events. When a session expires, in this scenario,
- * the Gemfire destroy events originate on the server and, with some Gemfire
- * hackery, the destroyed object ends up as the event's callback argument. At
- * the point that the CacheListener then gets the event, the re-constituted
- * session object has no manager associated and so we need to re-attach a
- * manager to it so that events can be fired correctly.
+ * <p>
+ * This class exists for a particular corner case described here. Consider a client-server environment with empty client
+ * regions *and* the need to fire HttpSessionListener destroy events. When a session expires, in this scenario, the
+ * Gemfire destroy events originate on the server and, with some Gemfire hackery, the destroyed object ends up as the
+ * event's callback argument. At the point that the CacheListener then gets the event, the re-constituted session object
+ * has no manager associated and so we need to re-attach a manager to it so that events can be fired correctly.
*/
public class ContextMapper {
- private static Map<String, DeltaSessionManager> managers =
- new HashMap<String, DeltaSessionManager>();
+ private static Map<String, DeltaSessionManager> managers = new HashMap<String, DeltaSessionManager>();
private ContextMapper() {
// This is a singleton
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8af9dfd7/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/util/CreateRegionFunction.java
----------------------------------------------------------------------
diff --git a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/util/CreateRegionFunction.java b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/util/CreateRegionFunction.java
index 65c2c51..a116c03 100644
--- a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/util/CreateRegionFunction.java
+++ b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/util/CreateRegionFunction.java
@@ -7,18 +7,19 @@
*/
package com.gemstone.gemfire.modules.util;
-import com.gemstone.gemfire.cache.*;
-
+import com.gemstone.gemfire.cache.Cache;
+import com.gemstone.gemfire.cache.CacheFactory;
+import com.gemstone.gemfire.cache.Declarable;
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.cache.RegionFactory;
+import com.gemstone.gemfire.cache.RegionShortcut;
import com.gemstone.gemfire.cache.client.ClientCache;
-import com.gemstone.gemfire.cache.execute.*;
+import com.gemstone.gemfire.cache.execute.Function;
+import com.gemstone.gemfire.cache.execute.FunctionContext;
import com.gemstone.gemfire.cache.partition.PartitionRegionHelper;
-
import com.gemstone.gemfire.distributed.DistributedLockService;
-
import com.gemstone.gemfire.distributed.internal.locks.DistributedMemberLock;
-
import com.gemstone.gemfire.internal.cache.PartitionedRegion;
-
import com.gemstone.gemfire.internal.cache.xmlcache.CacheXmlGenerator;
import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
@@ -26,7 +27,6 @@ import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
-
import java.util.Properties;
public class CreateRegionFunction implements Function, Declarable {
@@ -34,25 +34,24 @@ public class CreateRegionFunction implements Function, Declarable {
private static final long serialVersionUID = -9210226844302128969L;
private final Cache cache;
-
- private final Region<String,RegionConfiguration> regionConfigurationsRegion;
-
+
+ private final Region<String, RegionConfiguration> regionConfigurationsRegion;
+
public static final String ID = "create-region-function";
-
- private static final boolean DUMP_SESSION_CACHE_XML =
- Boolean.getBoolean("gemfiremodules.dumpSessionCacheXml");
+
+ private static final boolean DUMP_SESSION_CACHE_XML = Boolean.getBoolean("gemfiremodules.dumpSessionCacheXml");
private static final String REGION_CONFIGURATION_METADATA_REGION = "__regionConfigurationMetadata";
-
+
public CreateRegionFunction() {
this(CacheFactory.getAnyInstance());
}
-
+
public CreateRegionFunction(Cache cache) {
this.cache = cache;
this.regionConfigurationsRegion = createRegionConfigurationMetadataRegion();
}
-
+
public CreateRegionFunction(ClientCache cache) {
this.cache = null;
this.regionConfigurationsRegion = null;
@@ -62,17 +61,13 @@ public class CreateRegionFunction implements Function, Declarable {
RegionConfiguration configuration = (RegionConfiguration) context.getArguments();
if (this.cache.getLogger().fineEnabled()) {
StringBuilder builder = new StringBuilder();
- builder
- .append("Function ")
- .append(ID)
- .append(" received request: ")
- .append(configuration);
+ builder.append("Function ").append(ID).append(" received request: ").append(configuration);
this.cache.getLogger().fine(builder.toString());
}
// Create or retrieve region
RegionStatus status = createOrRetrieveRegion(configuration);
-
+
// Dump XML
if (DUMP_SESSION_CACHE_XML) {
writeCacheXml();
@@ -80,7 +75,7 @@ public class CreateRegionFunction implements Function, Declarable {
// Return status
context.getResultSender().lastResult(status);
}
-
+
private RegionStatus createOrRetrieveRegion(RegionConfiguration configuration) {
RegionStatus status = null;
String regionName = configuration.getRegionName();
@@ -96,9 +91,7 @@ public class CreateRegionFunction implements Function, Declarable {
RegionHelper.validateRegion(this.cache, configuration, region);
} catch (Exception e) {
if (!e.getMessage()
- .equals(
- LocalizedStrings.RegionAttributesCreation_CACHELISTENERS_ARE_NOT_THE_SAME
- .toLocalizedString())) {
+ .equals(LocalizedStrings.RegionAttributesCreation_CACHELISTENERS_ARE_NOT_THE_SAME.toLocalizedString())) {
this.cache.getLogger().warning(e);
}
status = RegionStatus.INVALID;
@@ -125,14 +118,14 @@ public class CreateRegionFunction implements Function, Declarable {
public void init(Properties properties) {
}
-
+
private RegionStatus createRegion(RegionConfiguration configuration) {
// Get a distributed lock
DistributedMemberLock dml = getDistributedLock();
if (this.cache.getLogger().fineEnabled()) {
this.cache.getLogger().fine(this + ": Attempting to lock " + dml);
}
- long start=0, end=0;
+ long start = 0, end = 0;
RegionStatus status = null;
try {
if (this.cache.getLogger().fineEnabled()) {
@@ -142,25 +135,25 @@ public class CreateRegionFunction implements Function, Declarable {
dml.lockInterruptibly();
if (this.cache.getLogger().fineEnabled()) {
end = System.currentTimeMillis();
- this.cache.getLogger().fine(this + ": Obtained lock on " + dml + " in " + (end-start) + " ms");
+ this.cache.getLogger().fine(this + ": Obtained lock on " + dml + " in " + (end - start) + " ms");
}
-
+
// Attempt to get the region again after the lock has been obtained
String regionName = configuration.getRegionName();
Region region = this.cache.getRegion(regionName);
-
+
// If it exists now, validate it.
// Else put an entry into the sessionRegionConfigurationsRegion
// while holding the lock. This will create the region in all VMs.
if (region == null) {
this.regionConfigurationsRegion.put(regionName, configuration);
-
+
// Retrieve the region after creating it
region = this.cache.getRegion(regionName);
// If the region is null now, it wasn't created for some reason
// (e.g. the region attributes id were invalid)
if (region == null) {
- status = RegionStatus.INVALID;
+ status = RegionStatus.INVALID;
} else {
// Create the PR buckets if necessary)
if (region instanceof PartitionedRegion) {
@@ -175,59 +168,54 @@ public class CreateRegionFunction implements Function, Declarable {
RegionHelper.validateRegion(this.cache, configuration, region);
} catch (Exception e) {
if (!e.getMessage()
- .equals(
- LocalizedStrings.RegionAttributesCreation_CACHELISTENERS_ARE_NOT_THE_SAME
- .toLocalizedString())) {
+ .equals(LocalizedStrings.RegionAttributesCreation_CACHELISTENERS_ARE_NOT_THE_SAME.toLocalizedString())) {
this.cache.getLogger().warning(e);
}
status = RegionStatus.INVALID;
}
}
- } catch(Exception e) {
+ } catch (Exception e) {
StringBuilder builder = new StringBuilder();
- builder
- .append(this)
- .append(": Caught Exception attempting to create region named ")
- .append(configuration.getRegionName())
- .append(":");
+ builder.append(this)
+ .append(": Caught Exception attempting to create region named ")
+ .append(configuration.getRegionName())
+ .append(":");
this.cache.getLogger().warning(builder.toString(), e);
status = RegionStatus.INVALID;
- }
- finally {
+ } finally {
// Unlock the distributed lock
try {
dml.unlock();
+ } catch (Exception e) {
}
- catch (Exception e) {}
}
return status;
}
-
+
private void createBuckets(PartitionedRegion region) {
PartitionRegionHelper.assignBucketsToPartitions(region);
}
-
- private Region<String,RegionConfiguration> createRegionConfigurationMetadataRegion() {
+
+ private Region<String, RegionConfiguration> createRegionConfigurationMetadataRegion() {
// a sessionFactory in hibernate could have been re-started
// so, it is possible that this region exists already
- Region<String, RegionConfiguration> r = this.cache
- .getRegion(REGION_CONFIGURATION_METADATA_REGION);
+ Region<String, RegionConfiguration> r = this.cache.getRegion(REGION_CONFIGURATION_METADATA_REGION);
if (r != null) {
return r;
}
- RegionFactory<String, RegionConfiguration> factory = this.cache
- .createRegionFactory(RegionShortcut.REPLICATE);
+ RegionFactory<String, RegionConfiguration> factory = this.cache.createRegionFactory(RegionShortcut.REPLICATE);
factory.addCacheListener(new RegionConfigurationCacheListener());
return factory.create(REGION_CONFIGURATION_METADATA_REGION);
}
-
+
private void writeCacheXml() {
File file = new File("cache-" + System.currentTimeMillis() + ".xml");
try {
PrintWriter pw = new PrintWriter(new FileWriter(file), true);
CacheXmlGenerator.generate(this.cache, pw);
pw.close();
- } catch (IOException e) {}
+ } catch (IOException e) {
+ }
}
private DistributedMemberLock getDistributedLock() {