Cleanup CacheClientUpdater

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

Branch: refs/heads/feature/GEODE-2632-16
Commit: f13ceee61416cf16821f51b02ed2af8dc7cb109b
Parents: 971ab8b
Author: Kirk Lund <kl...@apache.org>
Authored: Mon May 22 14:49:21 2017 -0700
Committer: Kirk Lund <kl...@apache.org>
Committed: Mon May 22 14:49:21 2017 -0700

----------------------------------------------------------------------
 .../java/org/apache/geode/Instantiator.java     |  99 ++-
 .../internal/cache/tier/CachedRegionHelper.java |  18 +-
 .../cache/tier/sockets/CacheClientUpdater.java  | 850 ++++++++++---------
 .../cache/tier/sockets/ChunkedMessage.java      |   6 +-
 .../internal/cache/tier/sockets/Message.java    |  61 +-
 .../cache/tier/sockets/ServerConnection.java    |   5 +-
 ...arallelGatewaySenderOperationsDUnitTest.java |   3 +-
 7 files changed, 528 insertions(+), 514 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/f13ceee6/geode-core/src/main/java/org/apache/geode/Instantiator.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/Instantiator.java 
b/geode-core/src/main/java/org/apache/geode/Instantiator.java
index c727e5b..ea42057 100644
--- a/geode-core/src/main/java/org/apache/geode/Instantiator.java
+++ b/geode-core/src/main/java/org/apache/geode/Instantiator.java
@@ -20,16 +20,16 @@ import 
org.apache.geode.internal.cache.tier.sockets.ClientProxyMembershipID;
 import org.apache.geode.internal.i18n.LocalizedStrings;
 
 /**
- * {@code Instantiator} allows classes that implement {@link DataSerializable} 
to be registered
- * with the data serialization framework. Knowledge of {@code 
DataSerializable} classes allows
- * the framework to optimize how instances of those classes are data 
serialized.
+ * {@code Instantiator} allows classes that implement {@link DataSerializable} 
to be registered with
+ * the data serialization framework. Knowledge of {@code DataSerializable} 
classes allows the
+ * framework to optimize how instances of those classes are data serialized.
  *
  * <P>
  *
  * Ordinarily, when a {@code DataSerializable} object is written using
  * {@link DataSerializer#writeObject(Object, java.io.DataOutput)}, a special 
marker class id is
- * written to the stream followed by the class name of the {@code 
DataSerializable} object.
- * After the marker class id is read by {@link DataSerializer#readObject} it 
performs the following
+ * written to the stream followed by the class name of the {@code 
DataSerializable} object. After
+ * the marker class id is read by {@link DataSerializer#readObject} it 
performs the following
  * operations,
  *
  * <OL>
@@ -44,20 +44,20 @@ import org.apache.geode.internal.i18n.LocalizedStrings;
  *
  * </OL>
  *
- * However, if a {@code DataSerializable} class is {@linkplain 
#register(Instantiator)
- * registered} with the data serialization framework and assigned a unique 
class id, an important
- * optimization can be performed that avoid the expense of using reflection to 
instantiate the
+ * However, if a {@code DataSerializable} class is {@linkplain 
#register(Instantiator) registered}
+ * with the data serialization framework and assigned a unique class id, an 
important optimization
+ * can be performed that avoid the expense of using reflection to instantiate 
the
  * {@code DataSerializable} class. When the object is written using
  * {@link DataSerializer#writeObject(Object, java.io.DataOutput)}, the 
object's registered class id
  * is written to the stream. Consequently, when the data is read from the 
stream, the
- * {@link #newInstance} method of the appropriate {@code Instantiator} 
instance is invoked to
- * create an "empty" instance of the {@code DataSerializable} instead of using 
reflection to
- * create the new instance.
+ * {@link #newInstance} method of the appropriate {@code Instantiator} 
instance is invoked to create
+ * an "empty" instance of the {@code DataSerializable} instead of using 
reflection to create the new
+ * instance.
  *
  * <P>
  *
- * Commonly, a {@code DataSerializable} class will register itself with the
- * {@code Instantiator} in a static initializer as shown in the below example 
code.
+ * Commonly, a {@code DataSerializable} class will register itself with the 
{@code Instantiator} in
+ * a static initializer as shown in the below example code.
  *
  * <PRE>
 public class User implements DataSerializable {
@@ -98,20 +98,19 @@ public class User implements DataSerializable {
 }
  * </PRE>
  *
- * {@code Instantiator}s may be distributed to other members of the 
distributed system when
- * they are registered. Consider the following scenario in which VM1 and VM2 
are members of the same
+ * {@code Instantiator}s may be distributed to other members of the 
distributed system when they are
+ * registered. Consider the following scenario in which VM1 and VM2 are 
members of the same
  * distributed system. Both VMs define the sameRegion and VM2's region 
replicates the contents of
- * VM1's using replication. VM1 puts an instance of the above {@code User} 
class into the
- * region. The act of instantiating {@code User} will load the {@code User} 
class and
- * invoke its static initializer, thus registering the {@code Instantiator} 
with the data
- * serialization framework. Because the region is a replicate, the {@code 
User} will be data
- * serialized and sent to VM2. However, when VM2 attempts to data deserialize 
the {@code User},
- * its {@code Instantiator} will not necessarily be registered because {@code 
User}'s
- * static initializer may not have been invoked yet. As a result, an exception 
would be logged while
- * deserializing the {@code User} and the replicate would not appear to have 
the new value. So,
- * in order to ensure that the {@code Instantiator} is registered in VM2, the 
data
- * serialization framework distributes a message to each member when an {@code 
Instantiator} is
- * {@linkplain #register(Instantiator) registered}.
+ * VM1's using replication. VM1 puts an instance of the above {@code User} 
class into the region.
+ * The act of instantiating {@code User} will load the {@code User} class and 
invoke its static
+ * initializer, thus registering the {@code Instantiator} with the data 
serialization framework.
+ * Because the region is a replicate, the {@code User} will be data serialized 
and sent to VM2.
+ * However, when VM2 attempts to data deserialize the {@code User}, its {@code 
Instantiator} will
+ * not necessarily be registered because {@code User}'s static initializer may 
not have been invoked
+ * yet. As a result, an exception would be logged while deserializing the 
{@code User} and the
+ * replicate would not appear to have the new value. So, in order to ensure 
that the
+ * {@code Instantiator} is registered in VM2, the data serialization framework 
distributes a message
+ * to each member when an {@code Instantiator} is {@linkplain 
#register(Instantiator) registered}.
  * <p>
  * Note that the framework does not require that an {@code Instantiator} be
  * {@link java.io.Serializable}, but it does require that it provide a
@@ -140,15 +139,15 @@ public abstract class Instantiator {
   private ClientProxyMembershipID context;
 
   /**
-   * Registers a {@code DataSerializable} class with the data serialization 
framework. This
-   * method is usually invoked from the static initializer of a class that 
implements
+   * Registers a {@code DataSerializable} class with the data serialization 
framework. This method
+   * is usually invoked from the static initializer of a class that implements
    * {@code DataSerializable}.
    *
-   * @param instantiator An {@code Instantiator} whose {@link #newInstance} 
method is invoked
-   *        when an object is data deserialized.
+   * @param instantiator An {@code Instantiator} whose {@link #newInstance} 
method is invoked when
+   *        an object is data deserialized.
    *
-   * @throws IllegalStateException If class {@code c} is already registered 
with a different
-   *         class id, or another class has already been registered with id 
{@code classId}
+   * @throws IllegalStateException If class {@code c} is already registered 
with a different class
+   *         id, or another class has already been registered with id {@code 
classId}
    * @throws NullPointerException If {@code instantiator} is {@code null}.
    */
   public static synchronized void register(Instantiator instantiator) {
@@ -156,16 +155,16 @@ public abstract class Instantiator {
   }
 
   /**
-   * Registers a {@code DataSerializable} class with the data serialization 
framework. This
-   * method is usually invoked from the static initializer of a class that 
implements
+   * Registers a {@code DataSerializable} class with the data serialization 
framework. This method
+   * is usually invoked from the static initializer of a class that implements
    * {@code DataSerializable}.
    *
-   * @param instantiator An {@code Instantiator} whose {@link #newInstance} 
method is invoked
-   *        when an object is data deserialized.
+   * @param instantiator An {@code Instantiator} whose {@link #newInstance} 
method is invoked when
+   *        an object is data deserialized.
    *
-   * @param distribute True if the registered {@code Instantiator} has to be 
distributed to
-   *        other members of the distributed system. Note that if distribute 
is set to false it may
-   *        still be distributed in some cases.
+   * @param distribute True if the registered {@code Instantiator} has to be 
distributed to other
+   *        members of the distributed system. Note that if distribute is set 
to false it may still
+   *        be distributed in some cases.
    *
    * @throws IllegalArgumentException If class {@code c} is already registered 
with a different
    *         class id, or another class has already been registered with id 
{@code classId}
@@ -182,11 +181,11 @@ public abstract class Instantiator {
    *
    * @param c The {@code DataSerializable} class to register. This class must 
have a static
    *        initializer that registers this {@code Instantiator}.
-   * @param classId A unique id for class {@code c}. The {@code classId} must 
not be zero.
-   *        This has been an {@code int} since dsPhase1.
+   * @param classId A unique id for class {@code c}. The {@code classId} must 
not be zero. This has
+   *        been an {@code int} since dsPhase1.
    *
-   * @throws IllegalArgumentException If {@code c} does not implement
-   *         {@code DataSerializable}, {@code classId} is less than or equal 
to zero.
+   * @throws IllegalArgumentException If {@code c} does not implement {@code 
DataSerializable},
+   *         {@code classId} is less than or equal to zero.
    * @throws NullPointerException If {@code c} is {@code null}
    */
   public Instantiator(Class<? extends DataSerializable> c, int classId) {
@@ -202,8 +201,8 @@ public abstract class Instantiator {
     }
 
     if (classId == 0) {
-      throw new 
IllegalArgumentException(LocalizedStrings.Instantiator_CLASS_ID_0_MUST_NOT_BE_0
-          .toLocalizedString(classId));
+      throw new IllegalArgumentException(
+          
LocalizedStrings.Instantiator_CLASS_ID_0_MUST_NOT_BE_0.toLocalizedString(classId));
     }
 
     this.clazz = c;
@@ -211,16 +210,15 @@ public abstract class Instantiator {
   }
 
   /**
-   * Creates a new "empty" instance of a {@code DataSerializable} class whose 
state will be
-   * filled in by invoking its {@link DataSerializable#fromData fromData} 
method.
+   * Creates a new "empty" instance of a {@code DataSerializable} class whose 
state will be filled
+   * in by invoking its {@link DataSerializable#fromData fromData} method.
    *
    * @see DataSerializer#readObject
    */
   public abstract DataSerializable newInstance();
 
   /**
-   * Returns the {@code DataSerializable} class that is instantiated by this
-   * {@code Instantiator}.
+   * Returns the {@code DataSerializable} class that is instantiated by this 
{@code Instantiator}.
    */
   public Class<? extends DataSerializable> getInstantiatedClass() {
     return this.clazz;
@@ -241,8 +239,7 @@ public abstract class Instantiator {
   }
 
   /**
-   * Returns the unique {@code eventId} of this {@code Instantiator}. For 
internal use
-   * only.
+   * Returns the unique {@code eventId} of this {@code Instantiator}. For 
internal use only.
    */
   public Object/* EventID */ getEventId() {
     return this.eventId;

http://git-wip-us.apache.org/repos/asf/geode/blob/f13ceee6/geode-core/src/main/java/org/apache/geode/internal/cache/tier/CachedRegionHelper.java
----------------------------------------------------------------------
diff --git 
a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/CachedRegionHelper.java
 
b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/CachedRegionHelper.java
index a82a804..940da95 100644
--- 
a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/CachedRegionHelper.java
+++ 
b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/CachedRegionHelper.java
@@ -27,21 +27,19 @@ import org.apache.geode.internal.cache.InternalCache;
 public class CachedRegionHelper {
 
   private final InternalCache cache;
+
   private volatile boolean shutdown = false;
-  // private Map regions;
-  private volatile int slowEmulationSleep = 0;
 
-  public CachedRegionHelper(InternalCache c) {
-    this.cache = c;
-    // this.regions = new WeakHashMap();
+  public CachedRegionHelper(InternalCache cache) {
+    this.cache = cache;
   }
 
   public void checkCancelInProgress(Throwable e) throws CancelException {
-    cache.getCancelCriterion().checkCancelInProgress(e);
+    this.cache.getCancelCriterion().checkCancelInProgress(e);
   }
 
   public Region getRegion(String name) {
-    return cache.getRegion(name);
+    return this.cache.getRegion(name);
   }
 
   public InternalCache getCache() {
@@ -53,12 +51,14 @@ public class CachedRegionHelper {
   }
 
   public boolean isShutdown() {
-    return shutdown || cache.getCancelCriterion().isCancelInProgress();
+    return this.shutdown || 
this.cache.getCancelCriterion().isCancelInProgress();
   }
 
+  /**
+   * CachedRegionHelper#close() does nothing
+   */
   public void close() {
     // cache = null;
-    // regions = null;
   }
 
   /**

Reply via email to