geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From upthewatersp...@apache.org
Subject [1/2] geode git commit: GEODE-2018: Added instantiators to SessionCachingFilter init method
Date Thu, 29 Jun 2017 21:20:00 GMT
Repository: geode
Updated Branches:
  refs/heads/develop 422778608 -> b5eeba30e


GEODE-2018: Added instantiators to SessionCachingFilter init method

Also removed unused registerInstantiator methods from GatewayDeltaCreateEvent,
GatewayDeltaDestroyEvent, and DeltaSessionDestroyAttrbiuteEvent classes.

This closes #587


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/b5eeba30
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/b5eeba30
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/b5eeba30

Branch: refs/heads/develop
Commit: b5eeba30e52f4b65b549229448a7e11ce14cd650
Parents: d82a548
Author: David Anuta <david.r.anuta@gmail.com>
Authored: Fri Jun 16 10:44:05 2017 -0700
Committer: Dan Smith <upthewaterspout@apache.org>
Committed: Thu Jun 29 14:04:36 2017 -0700

----------------------------------------------------------------------
 .../session/internal/common/CacheProperty.java  |  3 +-
 .../internal/filter/GemfireHttpSession.java     |  4 ++
 .../internal/filter/GemfireSessionManager.java  |  8 +--
 .../DeltaQueuedSessionAttributes.java           |  4 ++
 .../attributes/DeltaSessionAttributes.java      |  4 ++
 .../attributes/ImmediateSessionAttributes.java  | 64 --------------------
 .../attributes/QueuedSessionAttributes.java     | 61 -------------------
 .../session/filter/SessionCachingFilter.java    | 42 ++++++++++---
 .../gatewaydelta/GatewayDeltaCreateEvent.java   |  8 ---
 .../gatewaydelta/GatewayDeltaDestroyEvent.java  |  8 ---
 .../DeltaSessionDestroyAttributeEvent.java      |  8 ---
 11 files changed, 48 insertions(+), 166 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/b5eeba30/extensions/geode-modules-session-internal/src/main/java/org/apache/geode/modules/session/internal/common/CacheProperty.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-session-internal/src/main/java/org/apache/geode/modules/session/internal/common/CacheProperty.java
b/extensions/geode-modules-session-internal/src/main/java/org/apache/geode/modules/session/internal/common/CacheProperty.java
index fe16fc3..00240d9 100644
--- a/extensions/geode-modules-session-internal/src/main/java/org/apache/geode/modules/session/internal/common/CacheProperty.java
+++ b/extensions/geode-modules-session-internal/src/main/java/org/apache/geode/modules/session/internal/common/CacheProperty.java
@@ -38,8 +38,7 @@ public enum CacheProperty {
    * This parameter can take the following values which match the respective attribute container
    * classes
    * <p/>
-   * delta_queued : QueuedDeltaSessionAttributes delta_immediate : DeltaSessionAttributes
immediate
-   * : ImmediateSessionAttributes queued : QueuedSessionAttributes
+   * delta_queued : QueuedDeltaSessionAttributes delta_immediate : DeltaSessionAttributes
    */
   SESSION_DELTA_POLICY(String.class),
 

http://git-wip-us.apache.org/repos/asf/geode/blob/b5eeba30/extensions/geode-modules-session-internal/src/main/java/org/apache/geode/modules/session/internal/filter/GemfireHttpSession.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-session-internal/src/main/java/org/apache/geode/modules/session/internal/filter/GemfireHttpSession.java
b/extensions/geode-modules-session-internal/src/main/java/org/apache/geode/modules/session/internal/filter/GemfireHttpSession.java
index 90edc6a..88b20d6 100644
--- a/extensions/geode-modules-session-internal/src/main/java/org/apache/geode/modules/session/internal/filter/GemfireHttpSession.java
+++ b/extensions/geode-modules-session-internal/src/main/java/org/apache/geode/modules/session/internal/filter/GemfireHttpSession.java
@@ -88,6 +88,10 @@ public class GemfireHttpSession implements HttpSession, DataSerializable,
Delta
    * Register ourselves for de-serialization
    */
   static {
+    registerInstantiator();
+  }
+
+  public static void registerInstantiator() {
     Instantiator.register(new Instantiator(GemfireHttpSession.class, 27315) {
       @Override
       public DataSerializable newInstance() {

http://git-wip-us.apache.org/repos/asf/geode/blob/b5eeba30/extensions/geode-modules-session-internal/src/main/java/org/apache/geode/modules/session/internal/filter/GemfireSessionManager.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-session-internal/src/main/java/org/apache/geode/modules/session/internal/filter/GemfireSessionManager.java
b/extensions/geode-modules-session-internal/src/main/java/org/apache/geode/modules/session/internal/filter/GemfireSessionManager.java
index 20cfeca..c7466d6 100644
--- a/extensions/geode-modules-session-internal/src/main/java/org/apache/geode/modules/session/internal/filter/GemfireSessionManager.java
+++ b/extensions/geode-modules-session-internal/src/main/java/org/apache/geode/modules/session/internal/filter/GemfireSessionManager.java
@@ -32,7 +32,6 @@ import org.apache.geode.modules.session.internal.common.SessionCache;
 import org.apache.geode.modules.session.internal.filter.attributes.AbstractSessionAttributes;
 import org.apache.geode.modules.session.internal.filter.attributes.DeltaQueuedSessionAttributes;
 import org.apache.geode.modules.session.internal.filter.attributes.DeltaSessionAttributes;
-import org.apache.geode.modules.session.internal.filter.attributes.ImmediateSessionAttributes;
 import org.apache.geode.modules.session.internal.filter.util.TypeAwareMap;
 import org.apache.geode.modules.session.internal.jmx.SessionStatistics;
 import org.apache.geode.modules.util.RegionHelper;
@@ -219,15 +218,14 @@ public class GemfireSessionManager implements SessionManager {
     /**
      * Set up the attribute container depending on how things are configured
      */
+    Object sessionPolicy = properties.get(CacheProperty.SESSION_DELTA_POLICY);
     AbstractSessionAttributes attributes;
-    if ("delta_queued".equals(properties.get(CacheProperty.SESSION_DELTA_POLICY))) {
+    if ("delta_queued".equals(sessionPolicy) || "queued".equals(sessionPolicy)) {
       attributes = new DeltaQueuedSessionAttributes();
       ((DeltaQueuedSessionAttributes) attributes)
           .setReplicationTrigger((String) properties.get(CacheProperty.REPLICATION_TRIGGER));
-    } else if ("delta_immediate".equals(properties.get(CacheProperty.SESSION_DELTA_POLICY)))
{
+    } else if ("delta_immediate".equals(sessionPolicy) || "immediate".equals(sessionPolicy))
{
       attributes = new DeltaSessionAttributes();
-    } else if ("immediate".equals(properties.get(CacheProperty.SESSION_DELTA_POLICY))) {
-      attributes = new ImmediateSessionAttributes();
     } else {
       attributes = new DeltaSessionAttributes();
       LOG.warn("No session delta policy specified - using default of 'delta_immediate'");

http://git-wip-us.apache.org/repos/asf/geode/blob/b5eeba30/extensions/geode-modules-session-internal/src/main/java/org/apache/geode/modules/session/internal/filter/attributes/DeltaQueuedSessionAttributes.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-session-internal/src/main/java/org/apache/geode/modules/session/internal/filter/attributes/DeltaQueuedSessionAttributes.java
b/extensions/geode-modules-session-internal/src/main/java/org/apache/geode/modules/session/internal/filter/attributes/DeltaQueuedSessionAttributes.java
index a806515..87b9ca3 100644
--- a/extensions/geode-modules-session-internal/src/main/java/org/apache/geode/modules/session/internal/filter/attributes/DeltaQueuedSessionAttributes.java
+++ b/extensions/geode-modules-session-internal/src/main/java/org/apache/geode/modules/session/internal/filter/attributes/DeltaQueuedSessionAttributes.java
@@ -39,6 +39,10 @@ public class DeltaQueuedSessionAttributes extends AbstractDeltaSessionAttributes
    * Register ourselves for de-serialization
    */
   static {
+    registerInstantiator();
+  }
+
+  public static void registerInstantiator() {
     Instantiator.register(new Instantiator(DeltaQueuedSessionAttributes.class, 3479) {
       @Override
       public DataSerializable newInstance() {

http://git-wip-us.apache.org/repos/asf/geode/blob/b5eeba30/extensions/geode-modules-session-internal/src/main/java/org/apache/geode/modules/session/internal/filter/attributes/DeltaSessionAttributes.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-session-internal/src/main/java/org/apache/geode/modules/session/internal/filter/attributes/DeltaSessionAttributes.java
b/extensions/geode-modules-session-internal/src/main/java/org/apache/geode/modules/session/internal/filter/attributes/DeltaSessionAttributes.java
index 010d4e3..5928b71 100644
--- a/extensions/geode-modules-session-internal/src/main/java/org/apache/geode/modules/session/internal/filter/attributes/DeltaSessionAttributes.java
+++ b/extensions/geode-modules-session-internal/src/main/java/org/apache/geode/modules/session/internal/filter/attributes/DeltaSessionAttributes.java
@@ -32,6 +32,10 @@ public class DeltaSessionAttributes extends AbstractDeltaSessionAttributes
{
    * Register ourselves for de-serialization
    */
   static {
+    registerInstantiator();
+  }
+
+  public static void registerInstantiator() {
     Instantiator.register(new Instantiator(DeltaSessionAttributes.class, 347) {
       @Override
       public DataSerializable newInstance() {

http://git-wip-us.apache.org/repos/asf/geode/blob/b5eeba30/extensions/geode-modules-session-internal/src/main/java/org/apache/geode/modules/session/internal/filter/attributes/ImmediateSessionAttributes.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-session-internal/src/main/java/org/apache/geode/modules/session/internal/filter/attributes/ImmediateSessionAttributes.java
b/extensions/geode-modules-session-internal/src/main/java/org/apache/geode/modules/session/internal/filter/attributes/ImmediateSessionAttributes.java
deleted file mode 100644
index 084be45..0000000
--- a/extensions/geode-modules-session-internal/src/main/java/org/apache/geode/modules/session/internal/filter/attributes/ImmediateSessionAttributes.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for additional information
regarding
- * copyright ownership. The ASF licenses this file to You under the Apache License, Version
2.0 (the
- * "License"); you may not use this file except in compliance with the License. You may obtain
a
- * copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under
the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express
- * or implied. See the License for the specific language governing permissions and limitations
under
- * the License.
- */
-
-package org.apache.geode.modules.session.internal.filter.attributes;
-
-import org.apache.geode.DataSerializable;
-import org.apache.geode.Instantiator;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * This class implements immediately transmitted attributes. All attributes are transmitted
for
- * every attribute update. This is bound to be a performance hit in some cases but ensures
much
- * higher data availability.
- */
-public class ImmediateSessionAttributes extends AbstractSessionAttributes {
-
-  private static final Logger LOG =
-      LoggerFactory.getLogger(ImmediateSessionAttributes.class.getName());
-
-  /**
-   * Register ourselves for de-serialization
-   */
-  static {
-    Instantiator.register(new Instantiator(ImmediateSessionAttributes.class, 347) {
-      @Override
-      public DataSerializable newInstance() {
-        return new ImmediateSessionAttributes();
-      }
-    });
-  }
-
-  /**
-   * Default constructor
-   */
-  public ImmediateSessionAttributes() {}
-
-  @Override
-  public Object putAttribute(String attr, Object value) {
-    Object obj = attributes.put(attr, value);
-    flush();
-    return obj;
-  }
-
-  @Override
-  public Object removeAttribute(String attr) {
-    Object obj = attributes.remove(attr);
-    flush();
-    return obj;
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/b5eeba30/extensions/geode-modules-session-internal/src/main/java/org/apache/geode/modules/session/internal/filter/attributes/QueuedSessionAttributes.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-session-internal/src/main/java/org/apache/geode/modules/session/internal/filter/attributes/QueuedSessionAttributes.java
b/extensions/geode-modules-session-internal/src/main/java/org/apache/geode/modules/session/internal/filter/attributes/QueuedSessionAttributes.java
deleted file mode 100644
index 374e81e..0000000
--- a/extensions/geode-modules-session-internal/src/main/java/org/apache/geode/modules/session/internal/filter/attributes/QueuedSessionAttributes.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for additional information
regarding
- * copyright ownership. The ASF licenses this file to You under the Apache License, Version
2.0 (the
- * "License"); you may not use this file except in compliance with the License. You may obtain
a
- * copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under
the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express
- * or implied. See the License for the specific language governing permissions and limitations
under
- * the License.
- */
-
-package org.apache.geode.modules.session.internal.filter.attributes;
-
-import org.apache.geode.DataSerializable;
-import org.apache.geode.Instantiator;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * This class implements an attribute container which delays sending updates until the session
goes
- * out of scope. All attributes are transmitted during the update.
- */
-public class QueuedSessionAttributes extends AbstractSessionAttributes {
-
-  private static final Logger LOG =
-      LoggerFactory.getLogger(QueuedSessionAttributes.class.getName());
-
-  /**
-   * Register ourselves for de-serialization
-   */
-  static {
-    Instantiator.register(new Instantiator(QueuedSessionAttributes.class, 347) {
-      @Override
-      public DataSerializable newInstance() {
-        return new QueuedSessionAttributes();
-      }
-    });
-  }
-
-  /**
-   * Default constructor
-   */
-  public QueuedSessionAttributes() {}
-
-  @Override
-  public Object putAttribute(String attr, Object value) {
-    Object obj = attributes.put(attr, value);
-    return obj;
-  }
-
-  @Override
-  public Object removeAttribute(String attr) {
-    Object obj = attributes.remove(attr);
-    return obj;
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/b5eeba30/extensions/geode-modules-session/src/main/java/org/apache/geode/modules/session/filter/SessionCachingFilter.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-session/src/main/java/org/apache/geode/modules/session/filter/SessionCachingFilter.java
b/extensions/geode-modules-session/src/main/java/org/apache/geode/modules/session/filter/SessionCachingFilter.java
index 702415e..bf58e22 100644
--- a/extensions/geode-modules-session/src/main/java/org/apache/geode/modules/session/filter/SessionCachingFilter.java
+++ b/extensions/geode-modules-session/src/main/java/org/apache/geode/modules/session/filter/SessionCachingFilter.java
@@ -15,16 +15,6 @@
 
 package org.apache.geode.modules.session.filter;
 
-import org.apache.geode.distributed.internal.DistributionConfig;
-import org.apache.geode.modules.session.internal.filter.GemfireHttpSession;
-import org.apache.geode.modules.session.internal.filter.GemfireSessionManager;
-import org.apache.geode.modules.session.internal.filter.SessionManager;
-import org.apache.geode.modules.session.internal.filter.util.ThreadLocalSession;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.servlet.*;
-import javax.servlet.http.*;
 import java.io.IOException;
 import java.io.PrintStream;
 import java.io.PrintWriter;
@@ -33,6 +23,31 @@ import java.security.Principal;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.atomic.AtomicInteger;
 
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletRequestWrapper;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpServletResponseWrapper;
+import javax.servlet.http.HttpSession;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.geode.distributed.internal.DistributionConfig;
+import org.apache.geode.modules.session.internal.filter.GemfireHttpSession;
+import org.apache.geode.modules.session.internal.filter.GemfireSessionManager;
+import org.apache.geode.modules.session.internal.filter.SessionManager;
+import org.apache.geode.modules.session.internal.filter.attributes.DeltaQueuedSessionAttributes;
+import org.apache.geode.modules.session.internal.filter.attributes.DeltaSessionAttributes;
+import org.apache.geode.modules.session.internal.filter.util.ThreadLocalSession;
+
 /**
  * Primary class which orchestrates everything. This is the class which gets configured in
the
  * web.xml.
@@ -494,6 +509,7 @@ public class SessionCachingFilter implements Filter {
   @Override
   public void init(final FilterConfig config) {
     LOG.info("Starting Session Filter initialization");
+    registerInstantiators();
     this.filterConfig = config;
 
     if (started.getAndDecrement() > 0) {
@@ -528,6 +544,12 @@ public class SessionCachingFilter implements Filter {
     LOG.debug("Filter class loader {}", this.getClass().getClassLoader());
   }
 
+  private void registerInstantiators() {
+    GemfireHttpSession.registerInstantiator();
+    DeltaQueuedSessionAttributes.registerInstantiator();
+    DeltaSessionAttributes.registerInstantiator();
+  }
+
   /**
    * Return a String representation of this object.
    */

http://git-wip-us.apache.org/repos/asf/geode/blob/b5eeba30/extensions/geode-modules/src/main/java/org/apache/geode/modules/gatewaydelta/GatewayDeltaCreateEvent.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules/src/main/java/org/apache/geode/modules/gatewaydelta/GatewayDeltaCreateEvent.java
b/extensions/geode-modules/src/main/java/org/apache/geode/modules/gatewaydelta/GatewayDeltaCreateEvent.java
index ba9ba3f..f26f860 100644
--- a/extensions/geode-modules/src/main/java/org/apache/geode/modules/gatewaydelta/GatewayDeltaCreateEvent.java
+++ b/extensions/geode-modules/src/main/java/org/apache/geode/modules/gatewaydelta/GatewayDeltaCreateEvent.java
@@ -62,14 +62,6 @@ public class GatewayDeltaCreateEvent extends AbstractGatewayDeltaEvent
{
     DataSerializer.writeByteArray(this.gatewayDelta, out);
   }
 
-  public static void registerInstantiator(int id) {
-    Instantiator.register(new Instantiator(GatewayDeltaCreateEvent.class, id) {
-      public DataSerializable newInstance() {
-        return new GatewayDeltaCreateEvent();
-      }
-    });
-  }
-
   public String toString() {
     return new StringBuilder().append("GatewayDeltaCreateEvent[").append("regionName=")
         .append(this.regionName).append("; key=").append(this.key).append("; gatewayDelta=")

http://git-wip-us.apache.org/repos/asf/geode/blob/b5eeba30/extensions/geode-modules/src/main/java/org/apache/geode/modules/gatewaydelta/GatewayDeltaDestroyEvent.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules/src/main/java/org/apache/geode/modules/gatewaydelta/GatewayDeltaDestroyEvent.java
b/extensions/geode-modules/src/main/java/org/apache/geode/modules/gatewaydelta/GatewayDeltaDestroyEvent.java
index 5b8d823..cf713bb 100644
--- a/extensions/geode-modules/src/main/java/org/apache/geode/modules/gatewaydelta/GatewayDeltaDestroyEvent.java
+++ b/extensions/geode-modules/src/main/java/org/apache/geode/modules/gatewaydelta/GatewayDeltaDestroyEvent.java
@@ -58,14 +58,6 @@ public class GatewayDeltaDestroyEvent extends AbstractGatewayDeltaEvent
{
     super.toData(out);
   }
 
-  public static void registerInstantiator(int id) {
-    Instantiator.register(new Instantiator(GatewayDeltaDestroyEvent.class, id) {
-      public DataSerializable newInstance() {
-        return new GatewayDeltaDestroyEvent();
-      }
-    });
-  }
-
   public String toString() {
     return new StringBuilder().append("GatewayDeltaDestroyEvent[").append("regionName=")
         .append(this.regionName).append("; key=").append(this.key).append("]").toString();

http://git-wip-us.apache.org/repos/asf/geode/blob/b5eeba30/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/internal/DeltaSessionDestroyAttributeEvent.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/internal/DeltaSessionDestroyAttributeEvent.java
b/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/internal/DeltaSessionDestroyAttributeEvent.java
index 7ab59a5..5baf059 100644
--- a/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/internal/DeltaSessionDestroyAttributeEvent.java
+++ b/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/internal/DeltaSessionDestroyAttributeEvent.java
@@ -52,14 +52,6 @@ public class DeltaSessionDestroyAttributeEvent implements DeltaSessionAttributeE
     DataSerializer.writeString(this.attributeName, out);
   }
 
-  public static void registerInstantiator(int id) {
-    Instantiator.register(new Instantiator(DeltaSessionDestroyAttributeEvent.class, id) {
-      public DataSerializable newInstance() {
-        return new DeltaSessionDestroyAttributeEvent();
-      }
-    });
-  }
-
   public String toString() {
     return new StringBuilder().append("DeltaSessionDestroyAttributeEvent[").append("attributeName=")
         .append(this.attributeName).append("]").toString();


Mime
View raw message