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:26 UTC
[14/17] incubator-geode git commit: GEODE-14: Formatting changes
GEODE-14: Formatting changes
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/8af9dfd7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/8af9dfd7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/8af9dfd7
Branch: refs/heads/feature/GEODE-14
Commit: 8af9dfd7c33fcb641b81b534a778940377879dc7
Parents: 95349b2
Author: Jens Deppe <jd...@pivotal.io>
Authored: Tue Dec 22 08:29:52 2015 -0800
Committer: Jens Deppe <jd...@pivotal.io>
Committed: Tue Dec 22 08:29:52 2015 -0800
----------------------------------------------------------------------
.../catalina/Tomcat7DeltaSessionManager.java | 16 +-
.../gatewaydelta/AbstractGatewayDeltaEvent.java | 13 +-
.../modules/gatewaydelta/GatewayDelta.java | 4 +-
.../gatewaydelta/GatewayDeltaCreateEvent.java | 43 +-
.../gatewaydelta/GatewayDeltaDestroyEvent.java | 39 +-
.../modules/gatewaydelta/GatewayDeltaEvent.java | 2 +-
...tewayDeltaEventApplicationCacheListener.java | 30 +-
.../GatewayDeltaForwarderCacheListener.java | 127 ++-
.../session/bootstrap/AbstractCache.java | 182 ++--
.../session/bootstrap/ClientServerCache.java | 18 +-
.../session/bootstrap/PeerToPeerCache.java | 6 +-
.../AbstractCacheLifecycleListener.java | 6 +-
.../session/catalina/AbstractSessionCache.java | 43 +-
.../catalina/ClientServerSessionCache.java | 66 +-
.../session/catalina/CommitSessionValve.java | 19 +-
.../modules/session/catalina/DeltaSession.java | 221 +++--
.../session/catalina/DeltaSessionFacade.java | 8 +-
.../session/catalina/DeltaSessionManager.java | 301 ++++---
.../session/catalina/JvmRouteBinderValve.java | 63 +-
.../PeerToPeerCacheLifecycleListener.java | 3 +-
.../catalina/PeerToPeerSessionCache.java | 53 +-
.../modules/session/catalina/SessionCache.java | 40 +-
.../session/catalina/SessionManager.java | 12 +-
.../catalina/Tomcat6DeltaSessionManager.java | 30 +-
.../callback/LocalSessionCacheLoader.java | 37 +-
.../callback/LocalSessionCacheWriter.java | 41 +-
.../SessionExpirationCacheListener.java | 14 +-
.../DeltaSessionAttributeEventBatch.java | 50 +-
.../DeltaSessionDestroyAttributeEvent.java | 27 +-
.../internal/DeltaSessionStatistics.java | 14 +-
.../DeltaSessionUpdateAttributeEvent.java | 31 +-
.../gemstone/gemfire/modules/util/Banner.java | 13 +-
.../modules/util/BootstrappingFunction.java | 33 +-
.../util/ClassLoaderObjectInputStream.java | 9 +-
.../gemfire/modules/util/ContextMapper.java | 18 +-
.../modules/util/CreateRegionFunction.java | 98 +--
.../modules/util/DebugCacheListener.java | 28 +-
.../gemfire/modules/util/ModuleStatistics.java | 22 +-
.../modules/util/RegionConfiguration.java | 153 ++--
.../util/RegionConfigurationCacheListener.java | 77 +-
.../gemfire/modules/util/RegionHelper.java | 152 ++--
.../modules/util/RegionSizeFunction.java | 38 +-
.../modules/util/ResourceManagerValidator.java | 95 ++-
.../modules/util/SessionCustomExpiry.java | 18 +-
.../TouchPartitionedRegionEntriesFunction.java | 44 +-
.../TouchReplicatedRegionEntriesFunction.java | 42 +-
.../gemfire/modules/session/Callback.java | 11 +-
.../gemfire/modules/session/CommandServlet.java | 99 +--
.../gemfire/modules/session/DualCacheTest.java | 59 +-
.../gemfire/modules/session/EmbeddedTomcat.java | 272 +++---
.../gemfire/modules/session/QueryCommand.java | 12 +-
.../modules/session/TestSessionsBase.java | 830 +++++++++----------
52 files changed, 1768 insertions(+), 1914 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8af9dfd7/extensions/gemfire-modules-tomcat7/src/main/java/com/gemstone/gemfire/modules/session/catalina/Tomcat7DeltaSessionManager.java
----------------------------------------------------------------------
diff --git a/extensions/gemfire-modules-tomcat7/src/main/java/com/gemstone/gemfire/modules/session/catalina/Tomcat7DeltaSessionManager.java b/extensions/gemfire-modules-tomcat7/src/main/java/com/gemstone/gemfire/modules/session/catalina/Tomcat7DeltaSessionManager.java
index 0dab9e1..e062c3c 100644
--- a/extensions/gemfire-modules-tomcat7/src/main/java/com/gemstone/gemfire/modules/session/catalina/Tomcat7DeltaSessionManager.java
+++ b/extensions/gemfire-modules-tomcat7/src/main/java/com/gemstone/gemfire/modules/session/catalina/Tomcat7DeltaSessionManager.java
@@ -15,12 +15,10 @@ import java.io.IOException;
public class Tomcat7DeltaSessionManager 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.
*
- * @throws 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 startInternal() throws LifecycleException {
@@ -60,12 +58,10 @@ public class Tomcat7DeltaSessionManager 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.
*
- * @throws 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 stopInternal() throws LifecycleException {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8af9dfd7/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/gatewaydelta/AbstractGatewayDeltaEvent.java
----------------------------------------------------------------------
diff --git a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/gatewaydelta/AbstractGatewayDeltaEvent.java b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/gatewaydelta/AbstractGatewayDeltaEvent.java
index e382174..68b2304 100644
--- a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/gatewaydelta/AbstractGatewayDeltaEvent.java
+++ b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/gatewaydelta/AbstractGatewayDeltaEvent.java
@@ -7,16 +7,15 @@
*/
package com.gemstone.gemfire.modules.gatewaydelta;
-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.cache.Cache;
import com.gemstone.gemfire.cache.Region;
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+
@SuppressWarnings("serial")
public abstract class AbstractGatewayDeltaEvent implements GatewayDeltaEvent, DataSerializable {
@@ -30,7 +29,7 @@ public abstract class AbstractGatewayDeltaEvent implements GatewayDeltaEvent, Da
this.regionName = regionName;
this.key = key;
}
-
+
public String getRegionName() {
return this.regionName;
}
@@ -38,7 +37,7 @@ public abstract class AbstractGatewayDeltaEvent implements GatewayDeltaEvent, Da
public String getKey() {
return this.key;
}
-
+
@SuppressWarnings("unchecked")
public Region getRegion(Cache cache) {
return cache.getRegion(this.regionName);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8af9dfd7/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/gatewaydelta/GatewayDelta.java
----------------------------------------------------------------------
diff --git a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/gatewaydelta/GatewayDelta.java b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/gatewaydelta/GatewayDelta.java
index 7c37983..633b6c4 100644
--- a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/gatewaydelta/GatewayDelta.java
+++ b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/gatewaydelta/GatewayDelta.java
@@ -3,8 +3,8 @@ package com.gemstone.gemfire.modules.gatewaydelta;
public interface GatewayDelta {
public static final String GATEWAY_DELTA_REGION_NAME = "__gatewayDelta";
-
+
public GatewayDeltaEvent getCurrentGatewayDeltaEvent();
-
+
public void setCurrentGatewayDeltaEvent(GatewayDeltaEvent currentGatewayDeltaEvent);
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8af9dfd7/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/gatewaydelta/GatewayDeltaCreateEvent.java
----------------------------------------------------------------------
diff --git a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/gatewaydelta/GatewayDeltaCreateEvent.java b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/gatewaydelta/GatewayDeltaCreateEvent.java
index ff597da..f1991ca 100644
--- a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/gatewaydelta/GatewayDeltaCreateEvent.java
+++ b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/gatewaydelta/GatewayDeltaCreateEvent.java
@@ -7,25 +7,23 @@
*/
package com.gemstone.gemfire.modules.gatewaydelta;
-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.cache.Cache;
import com.gemstone.gemfire.cache.Region;
-
import com.gemstone.gemfire.internal.cache.CachedDeserializable;
import com.gemstone.gemfire.internal.cache.CachedDeserializableFactory;
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+
@SuppressWarnings("serial")
public class GatewayDeltaCreateEvent extends AbstractGatewayDeltaEvent {
private byte[] gatewayDelta;
-
+
public GatewayDeltaCreateEvent() {
}
@@ -37,15 +35,13 @@ public class GatewayDeltaCreateEvent extends AbstractGatewayDeltaEvent {
public byte[] getGatewayDelta() {
return this.gatewayDelta;
}
-
+
public void apply(Cache cache) {
- Region<String,CachedDeserializable> region = getRegion(cache);
+ Region<String, CachedDeserializable> region = getRegion(cache);
region.put(this.key, CachedDeserializableFactory.create(this.gatewayDelta), true);
if (cache.getLogger().fineEnabled()) {
StringBuilder builder = new StringBuilder();
- builder
- .append("Applied ")
- .append(this);
+ builder.append("Applied ").append(this);
cache.getLogger().fine(builder.toString());
}
}
@@ -59,7 +55,7 @@ public class GatewayDeltaCreateEvent extends AbstractGatewayDeltaEvent {
super.toData(out);
DataSerializer.writeByteArray(this.gatewayDelta, out);
}
-
+
public static void registerInstantiator(int id) {
Instantiator.register(new Instantiator(GatewayDeltaCreateEvent.class, id) {
public DataSerializable newInstance() {
@@ -67,18 +63,17 @@ public class GatewayDeltaCreateEvent extends AbstractGatewayDeltaEvent {
}
});
}
-
+
public String toString() {
- return new StringBuilder()
- .append("GatewayDeltaCreateEvent[")
- .append("regionName=")
- .append(this.regionName)
- .append("; key=")
- .append(this.key)
- .append("; gatewayDelta=")
- .append(this.gatewayDelta)
- .append("]")
- .toString();
+ return new StringBuilder().append("GatewayDeltaCreateEvent[")
+ .append("regionName=")
+ .append(this.regionName)
+ .append("; key=")
+ .append(this.key)
+ .append("; gatewayDelta=")
+ .append(this.gatewayDelta)
+ .append("]")
+ .toString();
}
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8af9dfd7/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/gatewaydelta/GatewayDeltaDestroyEvent.java
----------------------------------------------------------------------
diff --git a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/gatewaydelta/GatewayDeltaDestroyEvent.java b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/gatewaydelta/GatewayDeltaDestroyEvent.java
index cf6160c..e3119f0 100644
--- a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/gatewaydelta/GatewayDeltaDestroyEvent.java
+++ b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/gatewaydelta/GatewayDeltaDestroyEvent.java
@@ -7,10 +7,6 @@
*/
package com.gemstone.gemfire.modules.gatewaydelta;
-import java.io.DataInput;
-import java.io.DataOutput;
-import java.io.IOException;
-
import com.gemstone.gemfire.DataSerializable;
import com.gemstone.gemfire.Instantiator;
import com.gemstone.gemfire.cache.Cache;
@@ -18,6 +14,10 @@ import com.gemstone.gemfire.cache.EntryNotFoundException;
import com.gemstone.gemfire.cache.Region;
import com.gemstone.gemfire.modules.session.catalina.DeltaSession;
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+
@SuppressWarnings("serial")
public class GatewayDeltaDestroyEvent extends AbstractGatewayDeltaEvent {
@@ -29,23 +29,17 @@ public class GatewayDeltaDestroyEvent extends AbstractGatewayDeltaEvent {
}
public void apply(Cache cache) {
- Region<String,DeltaSession> region = getRegion(cache);
+ Region<String, DeltaSession> region = getRegion(cache);
try {
region.destroy(this.key);
if (cache.getLogger().fineEnabled()) {
StringBuilder builder = new StringBuilder();
- builder
- .append("Applied ")
- .append(this);
+ builder.append("Applied ").append(this);
cache.getLogger().fine(builder.toString());
}
} catch (EntryNotFoundException e) {
StringBuilder builder = new StringBuilder();
- builder
- .append(this)
- .append(": Session ")
- .append(this.key)
- .append(" was not found");
+ builder.append(this).append(": Session ").append(this.key).append(" was not found");
cache.getLogger().warning(builder.toString());
}
}
@@ -57,7 +51,7 @@ public class GatewayDeltaDestroyEvent extends AbstractGatewayDeltaEvent {
public void toData(DataOutput out) throws IOException {
super.toData(out);
}
-
+
public static void registerInstantiator(int id) {
Instantiator.register(new Instantiator(GatewayDeltaDestroyEvent.class, id) {
public DataSerializable newInstance() {
@@ -65,16 +59,15 @@ public class GatewayDeltaDestroyEvent extends AbstractGatewayDeltaEvent {
}
});
}
-
+
public String toString() {
- return new StringBuilder()
- .append("GatewayDeltaDestroyEvent[")
- .append("regionName=")
- .append(this.regionName)
- .append("; key=")
- .append(this.key)
- .append("]")
- .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/incubator-geode/blob/8af9dfd7/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/gatewaydelta/GatewayDeltaEvent.java
----------------------------------------------------------------------
diff --git a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/gatewaydelta/GatewayDeltaEvent.java b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/gatewaydelta/GatewayDeltaEvent.java
index c784e66..ca14aff 100644
--- a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/gatewaydelta/GatewayDeltaEvent.java
+++ b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/gatewaydelta/GatewayDeltaEvent.java
@@ -3,6 +3,6 @@ package com.gemstone.gemfire.modules.gatewaydelta;
import com.gemstone.gemfire.cache.Cache;
public interface GatewayDeltaEvent {
-
+
public void apply(Cache cache);
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8af9dfd7/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/gatewaydelta/GatewayDeltaEventApplicationCacheListener.java
----------------------------------------------------------------------
diff --git a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/gatewaydelta/GatewayDeltaEventApplicationCacheListener.java b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/gatewaydelta/GatewayDeltaEventApplicationCacheListener.java
index 2887bb8..f4137a9 100644
--- a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/gatewaydelta/GatewayDeltaEventApplicationCacheListener.java
+++ b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/gatewaydelta/GatewayDeltaEventApplicationCacheListener.java
@@ -7,8 +7,6 @@
*/
package com.gemstone.gemfire.modules.gatewaydelta;
-import java.util.Properties;
-
import com.gemstone.gemfire.cache.Cache;
import com.gemstone.gemfire.cache.CacheFactory;
import com.gemstone.gemfire.cache.Declarable;
@@ -17,25 +15,26 @@ import com.gemstone.gemfire.cache.util.CacheListenerAdapter;
import com.gemstone.gemfire.internal.cache.EntryEventImpl;
import com.gemstone.gemfire.internal.cache.wan.GatewaySenderEventCallbackArgument;
-public class GatewayDeltaEventApplicationCacheListener extends CacheListenerAdapter<String,GatewayDeltaEvent> implements Declarable {
+import java.util.Properties;
+
+public class GatewayDeltaEventApplicationCacheListener extends CacheListenerAdapter<String, GatewayDeltaEvent> implements Declarable {
private final Cache cache;
-
+
public GatewayDeltaEventApplicationCacheListener() {
this.cache = CacheFactory.getAnyInstance();
}
-
- public void afterCreate(EntryEvent<String,GatewayDeltaEvent> event) {
+
+ public void afterCreate(EntryEvent<String, GatewayDeltaEvent> event) {
System.out.println("GatewayDeltaApplierCacheListener event: " + event);
EntryEventImpl eventImpl = (EntryEventImpl) event;
if (this.cache.getLogger().fineEnabled()) {
StringBuilder builder = new StringBuilder();
- builder
- .append("GatewayDeltaApplierCacheListener: Received event for ")
- .append(event.getKey())
- .append("->")
- .append(event.getNewValue())
- .append(".");
+ builder.append("GatewayDeltaApplierCacheListener: Received event for ")
+ .append(event.getKey())
+ .append("->")
+ .append(event.getNewValue())
+ .append(".");
this.cache.getLogger().fine(builder.toString());
}
@@ -48,13 +47,12 @@ public class GatewayDeltaEventApplicationCacheListener extends CacheListenerAdap
System.out.println("Applied " + delta);
if (this.cache.getLogger().fineEnabled()) {
StringBuilder builder = new StringBuilder();
- builder
- .append("GatewayDeltaApplierCacheListener: Applied ")
- .append(delta);
+ builder.append("GatewayDeltaApplierCacheListener: Applied ").append(delta);
this.cache.getLogger().fine(builder.toString());
}
}
}
- 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/gatewaydelta/GatewayDeltaForwarderCacheListener.java
----------------------------------------------------------------------
diff --git a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/gatewaydelta/GatewayDeltaForwarderCacheListener.java b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/gatewaydelta/GatewayDeltaForwarderCacheListener.java
index 5f8a1ec..c8808e4 100644
--- a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/gatewaydelta/GatewayDeltaForwarderCacheListener.java
+++ b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/gatewaydelta/GatewayDeltaForwarderCacheListener.java
@@ -7,8 +7,6 @@
*/
package com.gemstone.gemfire.modules.gatewaydelta;
-import java.util.Properties;
-
import com.gemstone.gemfire.cache.Cache;
import com.gemstone.gemfire.cache.CacheFactory;
import com.gemstone.gemfire.cache.DataPolicy;
@@ -24,121 +22,121 @@ import com.gemstone.gemfire.cache.util.CacheListenerAdapter;
import com.gemstone.gemfire.internal.cache.EntryEventImpl;
import com.gemstone.gemfire.internal.cache.LocalRegion;
-public class GatewayDeltaForwarderCacheListener extends CacheListenerAdapter<String,GatewayDelta> implements Declarable {
+import java.util.Properties;
+
+public class GatewayDeltaForwarderCacheListener extends CacheListenerAdapter<String, GatewayDelta> implements Declarable {
private final Cache cache;
-
+
private LocalRegion gatewayDeltaRegion;
-
+
public GatewayDeltaForwarderCacheListener() {
this(CacheFactory.getAnyInstance());
}
-
+
public GatewayDeltaForwarderCacheListener(Cache cache) {
this.cache = cache;
}
-
+
@SuppressWarnings("unchecked")
- public void afterCreate(EntryEvent<String,GatewayDelta> event) {
+ public void afterCreate(EntryEvent<String, GatewayDelta> event) {
// If the event is from the local site, create a 'create' event and send it to the
// gateway delta region
if (event.getCallbackArgument() == null) {
if (this.cache.getLogger().fineEnabled()) {
StringBuilder builder = new StringBuilder();
- builder
- .append("GatewayDeltaForwarderCacheListener: Received create event for ")
- .append(event.getKey())
- .append("->")
- .append(event.getNewValue())
- .append(" that originated in the local site. Sending it to the remote site.");
+ builder.append("GatewayDeltaForwarderCacheListener: Received create event for ")
+ .append(event.getKey())
+ .append("->")
+ .append(event.getNewValue())
+ .append(" that originated in the local site. Sending it to the remote site.");
this.cache.getLogger().fine(builder.toString());
}
-
+
// Distribute the create event to the gateway hub(s)
String regionName = event.getRegion().getFullPath();
String sessionId = event.getKey();
SerializedCacheValue scv = event.getSerializedNewValue();
if (scv == null) {
- getGatewayDeltaRegion().put(sessionId, new GatewayDeltaCreateEvent(regionName, sessionId, EntryEventImpl.serialize(event.getNewValue())));
+ getGatewayDeltaRegion().put(sessionId,
+ new GatewayDeltaCreateEvent(regionName, sessionId, EntryEventImpl.serialize(event.getNewValue())));
} else {
- System.out.println("GatewayDeltaForwarderCacheListener event.getSerializedNewValue().getSerializedValue(): " + event.getSerializedNewValue().getSerializedValue());
- getGatewayDeltaRegion().put(sessionId, new GatewayDeltaCreateEvent(regionName, sessionId, scv.getSerializedValue()));
+ System.out.println(
+ "GatewayDeltaForwarderCacheListener event.getSerializedNewValue().getSerializedValue(): " + event.getSerializedNewValue()
+ .getSerializedValue());
+ getGatewayDeltaRegion().put(sessionId,
+ new GatewayDeltaCreateEvent(regionName, sessionId, scv.getSerializedValue()));
}
} else {
if (this.cache.getLogger().fineEnabled()) {
StringBuilder builder = new StringBuilder();
- builder
- .append("GatewayDeltaForwarderCacheListener: Received create event for ")
- .append(event.getKey())
- .append("->")
- .append(event.getNewValue())
- .append(" that originated in the remote site.");
+ builder.append("GatewayDeltaForwarderCacheListener: Received create event for ")
+ .append(event.getKey())
+ .append("->")
+ .append(event.getNewValue())
+ .append(" that originated in the remote site.");
this.cache.getLogger().fine(builder.toString());
}
}
}
-
- public void afterUpdate(EntryEvent<String,GatewayDelta> event) {
+
+ public void afterUpdate(EntryEvent<String, GatewayDelta> event) {
//System.out.println("GatewayDeltaForwarderCacheListener.afterUpdate: " + event);
// If the event is from the local site, create an 'update' event and send it to the
// gateway delta region
if (event.getCallbackArgument() == null) {
if (this.cache.getLogger().fineEnabled()) {
StringBuilder builder = new StringBuilder();
- builder
- .append("GatewayDeltaForwarderCacheListener: Received update event for ")
- .append(event.getKey())
- .append("->")
- .append(event.getNewValue())
- .append(" that originated in the local site. Sending it to the remote site.");
+ builder.append("GatewayDeltaForwarderCacheListener: Received update event for ")
+ .append(event.getKey())
+ .append("->")
+ .append(event.getNewValue())
+ .append(" that originated in the local site. Sending it to the remote site.");
this.cache.getLogger().fine(builder.toString());
}
-
+
// Distribute the update event to the gateway hub(s)
GatewayDelta session = event.getNewValue();
getGatewayDeltaRegion().put(event.getKey(), session.getCurrentGatewayDeltaEvent());
-
+
// Reset the current delta
session.setCurrentGatewayDeltaEvent(null);
} else {
if (this.cache.getLogger().fineEnabled()) {
StringBuilder builder = new StringBuilder();
- builder
- .append("GatewayDeltaForwarderCacheListener: Received update event for ")
- .append(event.getKey())
- .append("->")
- .append(event.getNewValue())
- .append(" that originated in the remote site.");
+ builder.append("GatewayDeltaForwarderCacheListener: Received update event for ")
+ .append(event.getKey())
+ .append("->")
+ .append(event.getNewValue())
+ .append(" that originated in the remote site.");
this.cache.getLogger().fine(builder.toString());
}
}
}
-
- public void afterDestroy(EntryEvent<String,GatewayDelta> event) {
+
+ public void afterDestroy(EntryEvent<String, GatewayDelta> event) {
// If the event is from the local site, create a 'destroy' event and send it to the
// gateway delta region
if (event.getCallbackArgument() != null) {
if (this.cache.getLogger().fineEnabled()) {
StringBuilder builder = new StringBuilder();
- builder
- .append("GatewayDeltaForwarderCacheListener: Received destroy event for ")
- .append(event.getKey())
- .append("->")
- .append(event.getNewValue())
- .append(" that originated in the local site. Sending it to the remote site.");
+ builder.append("GatewayDeltaForwarderCacheListener: Received destroy event for ")
+ .append(event.getKey())
+ .append("->")
+ .append(event.getNewValue())
+ .append(" that originated in the local site. Sending it to the remote site.");
this.cache.getLogger().fine(builder.toString());
}
-
+
// Distribute the destroy event to the gateway hub(s)
String sessionId = event.getKey();
getGatewayDeltaRegion().put(sessionId, new GatewayDeltaDestroyEvent(event.getRegion().getFullPath(), sessionId));
} else {
if (this.cache.getLogger().fineEnabled()) {
StringBuilder builder = new StringBuilder();
- builder
- .append("GatewayDeltaForwarderCacheListener: Received destroy event for session ")
- .append(event.getKey())
- .append(" that either expired or originated in the remote site.");
+ builder.append("GatewayDeltaForwarderCacheListener: Received destroy event for session ")
+ .append(event.getKey())
+ .append(" that either expired or originated in the remote site.");
this.cache.getLogger().fine(builder.toString());
}
}
@@ -146,37 +144,34 @@ public class GatewayDeltaForwarderCacheListener extends CacheListenerAdapter<Str
public void init(Properties p) {
}
-
+
private LocalRegion getGatewayDeltaRegion() {
if (this.gatewayDeltaRegion == null) {
this.gatewayDeltaRegion = createOrRetrieveGatewayDeltaRegion();
}
return this.gatewayDeltaRegion;
}
-
+
@SuppressWarnings("unchecked")
private LocalRegion createOrRetrieveGatewayDeltaRegion() {
Region region = this.cache.getRegion(GatewayDelta.GATEWAY_DELTA_REGION_NAME);
if (region == null) {
- region = new RegionFactory()
- .setScope(Scope.LOCAL)
- .setDataPolicy(DataPolicy.EMPTY)
- .setSubscriptionAttributes(new SubscriptionAttributes(InterestPolicy.ALL))
+ region = new RegionFactory().setScope(Scope.LOCAL)
+ .setDataPolicy(DataPolicy.EMPTY)
+ .setSubscriptionAttributes(new SubscriptionAttributes(InterestPolicy.ALL))
// TODO: Disabled for WAN
// .setEnableGateway(true)
- .addCacheListener(new GatewayDeltaEventApplicationCacheListener())
- .create(GatewayDelta.GATEWAY_DELTA_REGION_NAME);
+ .addCacheListener(new GatewayDeltaEventApplicationCacheListener())
+ .create(GatewayDelta.GATEWAY_DELTA_REGION_NAME);
}
if (this.cache.getLogger().fineEnabled()) {
StringBuilder builder = new StringBuilder();
- builder
- .append("GatewayDeltaForwarderCacheListener: Created gateway delta region: ")
- .append(region);
+ builder.append("GatewayDeltaForwarderCacheListener: Created gateway delta region: ").append(region);
this.cache.getLogger().fine(builder.toString());
}
return (LocalRegion) region;
}
-
+
public boolean equals(Object obj) {
// This method is only implemented so that RegionCreator.validateRegion works properly.
// The CacheListener comparison fails because two of these instances are not equal.
@@ -187,7 +182,7 @@ public class GatewayDeltaForwarderCacheListener extends CacheListenerAdapter<Str
if (obj == null || !(obj instanceof GatewayDeltaForwarderCacheListener)) {
return false;
}
-
+
return true;
}
}
\ 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/bootstrap/AbstractCache.java
----------------------------------------------------------------------
diff --git a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/bootstrap/AbstractCache.java b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/bootstrap/AbstractCache.java
index 5e2e4fd..c0ebe13 100644
--- a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/bootstrap/AbstractCache.java
+++ b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/bootstrap/AbstractCache.java
@@ -7,14 +7,6 @@
*/
package com.gemstone.gemfire.modules.session.bootstrap;
-import java.io.File;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Map;
-import java.util.Properties;
-import java.util.concurrent.ConcurrentHashMap;
-
import com.gemstone.gemfire.cache.GemFireCache;
import com.gemstone.gemfire.cache.control.ResourceManager;
import com.gemstone.gemfire.distributed.internal.AbstractDistributionConfig;
@@ -23,44 +15,51 @@ import com.gemstone.gemfire.internal.cache.LocalRegion;
import com.gemstone.gemfire.modules.util.Banner;
import com.gemstone.gemfire.modules.util.RegionHelper;
import com.gemstone.gemfire.modules.util.ResourceManagerValidator;
-import java.util.concurrent.atomic.AtomicBoolean;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.io.File;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicBoolean;
+
public abstract class AbstractCache {
-
+
protected GemFireCache cache;
-
+
private static final DateFormat FORMAT = new SimpleDateFormat("yyyy-MM-dd");
-
+
protected static final String DEFAULT_LOG_FILE_NAME = RegionHelper.NAME + "." + FORMAT.format(new Date()) + ".log";
-
+
protected static final String DEFAULT_STATISTIC_ARCHIVE_FILE_NAME = RegionHelper.NAME + ".gfs";
-
+
protected static final float DEFAULT_EVICTION_HEAP_PERCENTAGE = LocalRegion.DEFAULT_HEAPLRU_EVICTION_HEAP_PERCENTAGE;
-
+
protected static final float DEFAULT_CRITICAL_HEAP_PERCENTAGE = ResourceManager.DEFAULT_CRITICAL_PERCENTAGE;
-
+
protected static final Logger LOGGER = LoggerFactory.getLogger(AbstractCache.class);
-
+
protected float evictionHeapPercentage = DEFAULT_EVICTION_HEAP_PERCENTAGE;
-
+
protected float criticalHeapPercentage = DEFAULT_CRITICAL_HEAP_PERCENTAGE;
-
+
protected boolean rebalance = false;
- protected final Map<String,String> gemfireProperties;
+ protected final Map<String, String> gemfireProperties;
private final AtomicBoolean started = new AtomicBoolean(false);
/**
- * Instance reference which is set in static initialization blocks of any
- * subclasses.
+ * Instance reference which is set in static initialization blocks of any subclasses.
*/
protected static AbstractCache instance = null;
public AbstractCache() {
- this.gemfireProperties = new ConcurrentHashMap<String,String>();
+ this.gemfireProperties = new ConcurrentHashMap<String, String>();
}
public void lifecycleEvent(LifecycleTypeAdapter eventType) {
@@ -68,8 +67,7 @@ public abstract class AbstractCache {
getLogger().debug("Received " + eventType + " event");
}
- if (eventType.equals(LifecycleTypeAdapter.START) &&
- started.compareAndSet(false, true)) {
+ if (eventType.equals(LifecycleTypeAdapter.START) && started.compareAndSet(false, true)) {
// Create or retrieve the cache
getLogger().info("Initializing " + Banner.getString());
createOrRetrieveCache();
@@ -93,7 +91,7 @@ public abstract class AbstractCache {
public void close() {
getCache().close();
- while (! getCache().isClosed()) {
+ while (!getCache().isClosed()) {
}
started.set(false);
@@ -102,7 +100,7 @@ public abstract class AbstractCache {
public GemFireCache getCache() {
return this.cache;
}
-
+
public String getLogFileName() {
String logFileName = getGemFireProperties().get(DistributionConfig.LOG_FILE_NAME);
if (logFileName == null) {
@@ -110,7 +108,7 @@ public abstract class AbstractCache {
}
return logFileName;
}
-
+
public String getStatisticArchiveFileName() {
String statisticsArchiveFileName = getGemFireProperties().get(DistributionConfig.STATISTIC_ARCHIVE_FILE_NAME);
if (statisticsArchiveFileName == null) {
@@ -154,25 +152,25 @@ public abstract class AbstractCache {
public void setCriticalHeapPercentage(String criticalHeapPercentage) {
this.criticalHeapPercentage = Float.valueOf(criticalHeapPercentage);
}
-
+
public void setRebalance(boolean rebalance) {
this.rebalance = rebalance;
}
-
+
public boolean getRebalance() {
return this.rebalance;
}
- public Map<String,String> getGemFireProperties() {
+ public Map<String, String> getGemFireProperties() {
return this.gemfireProperties;
}
-
+
public void setProperty(String name, String value) {
//TODO Look at fake attributes
if (name.equals("className")) {
return;
}
-
+
// Determine the validity of the input property
boolean validProperty = false;
for (String gemfireProperty : AbstractDistributionConfig._getAttNames()) {
@@ -181,7 +179,7 @@ public abstract class AbstractCache {
break;
}
}
-
+
// If it is a valid GemFire property, add it to the the GemFire properties.
// Otherwise, log a warning.
if (validProperty) {
@@ -190,19 +188,19 @@ public abstract class AbstractCache {
getLogger().warn("The input property named " + name + " is not a valid GemFire property. It is being ignored.");
}
}
-
+
public Logger getLogger() {
return LOGGER;
}
-
+
protected Properties createDistributedSystemProperties() {
Properties properties = new Properties();
-
+
// Add any additional gemfire properties
- for (Map.Entry<String,String> entry : this.gemfireProperties.entrySet()) {
+ for (Map.Entry<String, String> entry : this.gemfireProperties.entrySet()) {
properties.put(entry.getKey(), entry.getValue());
}
-
+
// Replace the cache xml file in the properties
File cacheXmlFile = getCacheXmlFile();
String absoluteCacheXmlFileName = cacheXmlFile.getAbsolutePath();
@@ -216,13 +214,13 @@ public abstract class AbstractCache {
// Replace the log file in the properties
properties.put(DistributionConfig.LOG_FILE_NAME, getLogFile().getAbsolutePath());
-
+
// Replace the statistics archive file in the properties
File statisticArchiveFile = getStatisticArchiveFile();
if (statisticArchiveFile == null) {
- // Remove the statistics archive file name since statistic sampling is disabled
- properties.remove(DistributionConfig.STATISTIC_ARCHIVE_FILE_NAME);
- properties.remove(DistributionConfig.STATISTIC_SAMPLING_ENABLED_NAME);
+ // Remove the statistics archive file name since statistic sampling is disabled
+ properties.remove(DistributionConfig.STATISTIC_ARCHIVE_FILE_NAME);
+ properties.remove(DistributionConfig.STATISTIC_SAMPLING_ENABLED_NAME);
} else {
properties.put(DistributionConfig.STATISTIC_ARCHIVE_FILE_NAME, statisticArchiveFile.getAbsolutePath());
}
@@ -230,7 +228,7 @@ public abstract class AbstractCache {
return properties;
}
-
+
protected void closeCache() {
if (getLogger().isDebugEnabled()) {
getLogger().debug("Closing " + this.cache);
@@ -240,26 +238,26 @@ public abstract class AbstractCache {
}
getLogger().info("Closed " + this.cache);
}
-
+
protected File getLogFile() {
String logFileName = getLogFileName();
File logFile = new File(logFileName);
// If the log file is not absolute, point it at the logs directory.
if (!logFile.isAbsolute()) {
if (System.getProperty("catalina.base") != null) {
- logFile = new File(System.getProperty("catalina.base") + "/logs/", logFileName);
+ logFile = new File(System.getProperty("catalina.base") + "/logs/", logFileName);
} else if (System.getProperty("weblogic.Name") != null) {
String weblogicName = System.getProperty("weblogic.Name");
String separator = System.getProperty("file.separator");
- logFile = new File("servers" + separator + weblogicName + separator +
- "logs" + separator + logFileName);
+ logFile = new File("servers" + separator + weblogicName + separator +
+ "logs" + separator + logFileName);
} else {
logFile = new File(System.getProperty("gemfire.logdir"), logFileName);
}
}
return logFile;
}
-
+
protected File getStatisticArchiveFile() {
File statisticsArchiveFile = null;
String statisticSamplingEnabled = getGemFireProperties().get(DistributionConfig.STATISTIC_SAMPLING_ENABLED_NAME);
@@ -269,16 +267,14 @@ public abstract class AbstractCache {
// If the statistics archive file is not absolute, point it at the logs directory.
if (!statisticsArchiveFile.isAbsolute()) {
if (System.getProperty("catalina.base") != null) {
- statisticsArchiveFile = new File(System.getProperty("catalina.base") +
- "/logs/", statisticsArchiveFileName);
+ statisticsArchiveFile = new File(System.getProperty("catalina.base") + "/logs/", statisticsArchiveFileName);
} else if (System.getProperty("weblogic.Name") != null) {
String weblogicName = System.getProperty("weblogic.Name");
String separator = System.getProperty("file.separator");
- statisticsArchiveFile = new File("servers" + separator + weblogicName + separator +
+ statisticsArchiveFile = new File("servers" + separator + weblogicName + separator +
"logs" + separator + statisticsArchiveFileName);
} else {
- statisticsArchiveFile = new File(System.getProperty("gemfire.statisticsdir"),
- statisticsArchiveFileName);
+ statisticsArchiveFile = new File(System.getProperty("gemfire.statisticsdir"), statisticsArchiveFileName);
}
}
}
@@ -290,24 +286,21 @@ public abstract class AbstractCache {
ResourceManager rm = getCache().getResourceManager();
float currentEvictionHeapPercentage = rm.getEvictionHeapPercentage();
float currentCriticalHeapPercentage = rm.getCriticalHeapPercentage();
-
+
// Set new eviction and critical heap percentages if necessary
- if (getEvictionHeapPercentage() != currentEvictionHeapPercentage
- || getCriticalHeapPercentage() != currentCriticalHeapPercentage) {
+ if (getEvictionHeapPercentage() != currentEvictionHeapPercentage || getCriticalHeapPercentage() != currentCriticalHeapPercentage) {
if (getLogger().isDebugEnabled()) {
StringBuilder builder = new StringBuilder();
- builder
- .append("Previous eviction heap percentage=")
- .append(currentEvictionHeapPercentage)
- .append("; critical heap percentage=")
- .append(currentCriticalHeapPercentage);
+ builder.append("Previous eviction heap percentage=")
+ .append(currentEvictionHeapPercentage)
+ .append("; critical heap percentage=")
+ .append(currentCriticalHeapPercentage);
getLogger().debug(builder.toString());
builder.setLength(0);
- builder
- .append("Requested eviction heap percentage=")
- .append(getEvictionHeapPercentage())
- .append("; critical heap percentage=")
- .append(getCriticalHeapPercentage());
+ builder.append("Requested eviction heap percentage=")
+ .append(getEvictionHeapPercentage())
+ .append("; critical heap percentage=")
+ .append(getCriticalHeapPercentage());
getLogger().debug(builder.toString());
}
if (currentCriticalHeapPercentage == 0.0f) {
@@ -349,51 +342,48 @@ public abstract class AbstractCache {
}
if (getLogger().isDebugEnabled()) {
StringBuilder builder = new StringBuilder();
- builder
- .append("Actual eviction heap percentage=")
- .append(rm.getEvictionHeapPercentage())
- .append("; critical heap percentage=")
- .append(rm.getCriticalHeapPercentage());
+ builder.append("Actual eviction heap percentage=")
+ .append(rm.getEvictionHeapPercentage())
+ .append("; critical heap percentage=")
+ .append(rm.getCriticalHeapPercentage());
getLogger().debug(builder.toString());
}
}
-
+
// Validate java startup parameters (done after setting the eviction and
// critical heap percentages so that the CMSInitiatingOccupancyFraction can
// be compared against them.
ResourceManagerValidator.validateJavaStartupParameters(getCache());
}
-
- private void handleResourceManagerException(IllegalArgumentException e,
- float currentEvictionHeapPercentage, float currentCriticalHeapPercentage) {
+
+ private void handleResourceManagerException(IllegalArgumentException e, float currentEvictionHeapPercentage,
+ float currentCriticalHeapPercentage) {
StringBuilder builder = new StringBuilder();
- builder
- .append("Caught exception attempting to set eviction heap percentage=")
- .append(getEvictionHeapPercentage())
- .append(" and critical heap percentage=")
- .append(getCriticalHeapPercentage())
- .append(". The percentages will be set back to their previous values (eviction heap percentage=")
- .append(currentEvictionHeapPercentage)
- .append(" and critical heap percentage=")
- .append(currentCriticalHeapPercentage)
- .append(").");
- getLogger().warn(builder.toString(), e);
+ builder.append("Caught exception attempting to set eviction heap percentage=")
+ .append(getEvictionHeapPercentage())
+ .append(" and critical heap percentage=")
+ .append(getCriticalHeapPercentage())
+ .append(". The percentages will be set back to their previous values (eviction heap percentage=")
+ .append(currentEvictionHeapPercentage)
+ .append(" and critical heap percentage=")
+ .append(currentCriticalHeapPercentage)
+ .append(").");
+ getLogger().warn(builder.toString(), e);
}
@Override
public String toString() {
- return new StringBuilder()
- .append(getClass().getSimpleName())
- .append("[")
- .append("cache=")
- .append(this.cache)
- .append("]")
- .toString();
+ return new StringBuilder().append(getClass().getSimpleName())
+ .append("[")
+ .append("cache=")
+ .append(this.cache)
+ .append("]")
+ .toString();
}
protected abstract void createOrRetrieveCache();
-
+
protected abstract void rebalanceCache();
-
+
protected abstract String getDefaultCacheXmlFileName();
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8af9dfd7/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/bootstrap/ClientServerCache.java
----------------------------------------------------------------------
diff --git a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/bootstrap/ClientServerCache.java b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/bootstrap/ClientServerCache.java
index f49fac4..51be228 100644
--- a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/bootstrap/ClientServerCache.java
+++ b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/bootstrap/ClientServerCache.java
@@ -11,8 +11,7 @@ import com.gemstone.gemfire.cache.CacheClosedException;
import com.gemstone.gemfire.cache.client.ClientCacheFactory;
/**
- * This is a singleton class which maintains configuration properties as well
- * as starting a Client-Server cache.
+ * This is a singleton class which maintains configuration properties as well as starting a Client-Server cache.
*/
public class ClientServerCache extends AbstractCache {
@@ -23,12 +22,12 @@ public class ClientServerCache extends AbstractCache {
}
private ClientServerCache() {
- // Singleton
- super();
+ // Singleton
+ super();
}
public static AbstractCache getInstance() {
- return instance;
+ return instance;
}
@Override
@@ -39,8 +38,9 @@ public class ClientServerCache extends AbstractCache {
// Get the existing cache if any
try {
this.cache = ClientCacheFactory.getAnyInstance();
- } catch (CacheClosedException e) {}
-
+ } catch (CacheClosedException e) {
+ }
+
// If no cache exists, create one
String message = null;
if (this.cache == null) {
@@ -52,12 +52,12 @@ public class ClientServerCache extends AbstractCache {
}
getLogger().info(message + this.cache);
}
-
+
@Override
protected void rebalanceCache() {
getLogger().warn("The client cannot rebalance the server's cache.");
}
-
+
@Override
protected String getDefaultCacheXmlFileName() {
return DEFAULT_CACHE_XML_FILE_NAME;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8af9dfd7/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/bootstrap/PeerToPeerCache.java
----------------------------------------------------------------------
diff --git a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/bootstrap/PeerToPeerCache.java b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/bootstrap/PeerToPeerCache.java
index a088b5f..ffa2714 100644
--- a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/bootstrap/PeerToPeerCache.java
+++ b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/bootstrap/PeerToPeerCache.java
@@ -13,8 +13,7 @@ import com.gemstone.gemfire.cache.control.RebalanceResults;
import com.gemstone.gemfire.modules.util.RegionHelper;
/**
- * This is a singleton class which maintains configuration properties as well as
- * starting a Peer-To-Peer cache.
+ * This is a singleton class which maintains configuration properties as well as starting a Peer-To-Peer cache.
*/
public class PeerToPeerCache extends AbstractCache {
@@ -66,8 +65,7 @@ public class PeerToPeerCache extends AbstractCache {
getLogger().debug(RegionHelper.getRebalanceResultsMessage(results));
}
} catch (Exception e) {
- getLogger().warn("Rebalance failed because of the following exception:",
- e);
+ getLogger().warn("Rebalance failed because of the following exception:", e);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8af9dfd7/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/AbstractCacheLifecycleListener.java
----------------------------------------------------------------------
diff --git a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/AbstractCacheLifecycleListener.java b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/AbstractCacheLifecycleListener.java
index a6710b7..e7d7e10 100644
--- a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/AbstractCacheLifecycleListener.java
+++ b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/AbstractCacheLifecycleListener.java
@@ -16,7 +16,7 @@ import org.apache.catalina.LifecycleListener;
public abstract class AbstractCacheLifecycleListener implements LifecycleListener {
protected AbstractCache cache;
-
+
@Override
public void lifecycleEvent(LifecycleEvent le) {
cache.lifecycleEvent(LifecycleTypeAdapter.valueOf(le.getType().toUpperCase()));
@@ -48,11 +48,11 @@ public abstract class AbstractCacheLifecycleListener implements LifecycleListene
public void setCriticalHeapPercentage(String criticalHeapPercentage) {
cache.setCriticalHeapPercentage(criticalHeapPercentage);
}
-
+
public void setRebalance(boolean rebalance) {
cache.setRebalance(rebalance);
}
-
+
public boolean getRebalance() {
return cache.getRebalance();
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8af9dfd7/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/AbstractSessionCache.java
----------------------------------------------------------------------
diff --git a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/AbstractSessionCache.java b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/AbstractSessionCache.java
index 151eb0d..2fbb1df 100644
--- a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/AbstractSessionCache.java
+++ b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/AbstractSessionCache.java
@@ -8,57 +8,55 @@
package com.gemstone.gemfire.modules.session.catalina;
import com.gemstone.gemfire.cache.EntryNotFoundException;
-import org.apache.catalina.Session;
-
import com.gemstone.gemfire.cache.Region;
import com.gemstone.gemfire.modules.session.catalina.internal.DeltaSessionStatistics;
import com.gemstone.gemfire.modules.util.RegionConfiguration;
import com.gemstone.gemfire.modules.util.SessionCustomExpiry;
+import org.apache.catalina.Session;
+
import javax.servlet.http.HttpSession;
public abstract class AbstractSessionCache implements SessionCache {
-
+
protected SessionManager sessionManager;
-
+
/**
- * The sessionRegion is the <code>Region</code> that actually stores and
- * replicates the <code>Session</code>s.
+ * The sessionRegion is the <code>Region</code> that actually stores and replicates the <code>Session</code>s.
*/
- protected Region<String,HttpSession> sessionRegion;
+ protected Region<String, HttpSession> sessionRegion;
/**
- * The operatingRegion is the <code>Region</code> used to do HTTP operations.
- * if local cache is enabled, then this will be the local <code>Region</code>;
- * otherwise, it will be the session <code>Region</code>.
+ * The operatingRegion is the <code>Region</code> used to do HTTP operations. if local cache is enabled, then this
+ * will be the local <code>Region</code>; otherwise, it will be the session <code>Region</code>.
*/
- protected Region<String,HttpSession> operatingRegion;
+ protected Region<String, HttpSession> operatingRegion;
protected DeltaSessionStatistics statistics;
-
+
public AbstractSessionCache(SessionManager sessionManager) {
this.sessionManager = sessionManager;
}
-
+
@Override
public String getSessionRegionName() {
return getSessionRegion().getFullPath();
}
-
+
@Override
public String getOperatingRegionName() {
return getOperatingRegion().getFullPath();
}
-
+
@Override
public void putSession(Session session) {
- getOperatingRegion().put(session.getId(), (HttpSession)session);
+ getOperatingRegion().put(session.getId(), (HttpSession) session);
}
@Override
public HttpSession getSession(String sessionId) {
return getOperatingRegion().get(sessionId);
}
-
+
@Override
public void destroySession(String sessionId) {
try {
@@ -67,26 +65,27 @@ public abstract class AbstractSessionCache implements SessionCache {
// Ignored
}
}
-
+
@Override
public DeltaSessionStatistics getStatistics() {
return this.statistics;
}
-
+
protected SessionManager getSessionManager() {
return this.sessionManager;
}
- public Region<String,HttpSession> getSessionRegion() {
+ public Region<String, HttpSession> getSessionRegion() {
return this.sessionRegion;
}
- public Region<String,HttpSession> getOperatingRegion() {
+ public Region<String, HttpSession> getOperatingRegion() {
return this.operatingRegion;
}
protected void createStatistics() {
- this.statistics = new DeltaSessionStatistics(getCache().getDistributedSystem(), getSessionManager().getStatisticsName());
+ this.statistics = new DeltaSessionStatistics(getCache().getDistributedSystem(),
+ getSessionManager().getStatisticsName());
}
protected RegionConfiguration createRegionConfiguration() {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8af9dfd7/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/ClientServerSessionCache.java
----------------------------------------------------------------------
diff --git a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/ClientServerSessionCache.java b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/ClientServerSessionCache.java
index fa23519..0b21e3a 100644
--- a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/ClientServerSessionCache.java
+++ b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/ClientServerSessionCache.java
@@ -7,21 +7,15 @@
*/
package com.gemstone.gemfire.modules.session.catalina;
-import java.lang.IllegalStateException;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import com.gemstone.gemfire.cache.InterestResultPolicy;
-import com.gemstone.gemfire.cache.client.PoolManager;
-import com.gemstone.gemfire.cache.client.internal.PoolImpl;
-
import com.gemstone.gemfire.cache.GemFireCache;
+import com.gemstone.gemfire.cache.InterestResultPolicy;
import com.gemstone.gemfire.cache.Region;
import com.gemstone.gemfire.cache.RegionShortcut;
import com.gemstone.gemfire.cache.client.ClientCache;
import com.gemstone.gemfire.cache.client.ClientRegionFactory;
import com.gemstone.gemfire.cache.client.ClientRegionShortcut;
+import com.gemstone.gemfire.cache.client.PoolManager;
+import com.gemstone.gemfire.cache.client.internal.PoolImpl;
import com.gemstone.gemfire.cache.execute.Execution;
import com.gemstone.gemfire.cache.execute.FunctionService;
import com.gemstone.gemfire.cache.execute.ResultCollector;
@@ -36,11 +30,14 @@ import com.gemstone.gemfire.modules.util.TouchPartitionedRegionEntriesFunction;
import com.gemstone.gemfire.modules.util.TouchReplicatedRegionEntriesFunction;
import javax.servlet.http.HttpSession;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
public class ClientServerSessionCache extends AbstractSessionCache {
private ClientCache cache;
-
+
protected static final String DEFAULT_REGION_ATTRIBUTES_ID = RegionShortcut.PARTITION_REDUNDANT.toString();
protected static final boolean DEFAULT_ENABLE_LOCAL_CACHE = true;
@@ -54,7 +51,7 @@ public class ClientServerSessionCache extends AbstractSessionCache {
public void initialize() {
// Bootstrap the servers
bootstrapServers();
-
+
// Create or retrieve the region
try {
createOrRetrieveRegion();
@@ -62,7 +59,7 @@ public class ClientServerSessionCache extends AbstractSessionCache {
sessionManager.getLogger().fatal("Unable to create or retrieve region", ex);
throw new IllegalStateException(ex);
}
-
+
// Set the session region directly as the operating region since there is no difference
// between the local cache region and the session region.
this.operatingRegion = this.sessionRegion;
@@ -70,12 +67,12 @@ public class ClientServerSessionCache extends AbstractSessionCache {
// Create or retrieve the statistics
createStatistics();
}
-
+
@Override
public String getDefaultRegionAttributesId() {
return DEFAULT_REGION_ATTRIBUTES_ID;
}
-
+
@Override
public boolean getDefaultEnableLocalCache() {
return DEFAULT_ENABLE_LOCAL_CACHE;
@@ -102,8 +99,8 @@ public class ClientServerSessionCache extends AbstractSessionCache {
}
} else {
// Execute the member touch function on all the server(s)
- Execution execution = FunctionService.onServers(getCache()).withArgs(
- new Object[] {this.sessionRegion.getFullPath(), sessionIds});
+ Execution execution = FunctionService.onServers(getCache())
+ .withArgs(new Object[]{this.sessionRegion.getFullPath(), sessionIds});
try {
ResultCollector collector = execution.execute(TouchReplicatedRegionEntriesFunction.ID, true, false, false);
collector.getResult();
@@ -113,12 +110,12 @@ public class ClientServerSessionCache extends AbstractSessionCache {
}
}
}
-
+
@Override
public boolean isPeerToPeer() {
return false;
}
-
+
@Override
public boolean isClientServer() {
return true;
@@ -128,18 +125,18 @@ public class ClientServerSessionCache extends AbstractSessionCache {
public Set<String> keySet() {
return getSessionRegion().keySetOnServer();
}
-
+
@Override
public int size() {
- // Add a single dummy key to force the function to go to one server
+ // Add a single dummy key to force the function to go to one server
Set<String> filters = new HashSet<String>();
filters.add("test-key");
-
+
// Execute the function on the session region
Execution execution = FunctionService.onRegion(getSessionRegion()).withFilter(filters);
ResultCollector collector = execution.execute(RegionSizeFunction.ID, true, true, true);
List<Integer> result = (List<Integer>) collector.getResult();
-
+
// Return the first (and only) element
return result.get(0);
}
@@ -156,7 +153,7 @@ public class ClientServerSessionCache extends AbstractSessionCache {
public GemFireCache getCache() {
return this.cache;
}
-
+
private void bootstrapServers() {
Execution execution = FunctionService.onServers(this.cache);
ResultCollector collector = execution.execute(new BootstrappingFunction());
@@ -177,7 +174,7 @@ public class ClientServerSessionCache extends AbstractSessionCache {
if (this.sessionRegion == null) {
// Create the PR on the servers
createSessionRegionOnServers();
-
+
// Create the region on the client
this.sessionRegion = createLocalSessionRegion();
if (getSessionManager().getLogger().isDebugEnabled()) {
@@ -193,31 +190,30 @@ public class ClientServerSessionCache extends AbstractSessionCache {
private void createSessionRegionOnServers() {
// Create the RegionConfiguration
RegionConfiguration configuration = createRegionConfiguration();
-
+
// Send it to the server tier
Execution execution = FunctionService.onServer(this.cache).withArgs(configuration);
ResultCollector collector = execution.execute(CreateRegionFunction.ID);
-
+
// Verify the region was successfully created on the servers
List<RegionStatus> results = (List<RegionStatus>) collector.getResult();
for (RegionStatus status : results) {
if (status == RegionStatus.INVALID) {
StringBuilder builder = new StringBuilder();
- builder
- .append("An exception occurred on the server while attempting to create or validate region named ")
- .append(getSessionManager().getRegionName())
- .append(". See the server log for additional details.");
+ builder.append("An exception occurred on the server while attempting to create or validate region named ")
+ .append(getSessionManager().getRegionName())
+ .append(". See the server log for additional details.");
throw new IllegalStateException(builder.toString());
}
}
}
-
- private Region<String,HttpSession> createLocalSessionRegion() {
- ClientRegionFactory<String,HttpSession> factory = null;
+
+ private Region<String, HttpSession> createLocalSessionRegion() {
+ ClientRegionFactory<String, HttpSession> factory = null;
if (getSessionManager().getEnableLocalCache()) {
// Create the region factory with caching and heap LRU enabled
factory = this.cache.createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY_HEAP_LRU);
-
+
// Set the expiration time, action and listener if necessary
int maxInactiveInterval = getSessionManager().getMaxInactiveInterval();
if (maxInactiveInterval != RegionConfiguration.DEFAULT_MAX_INACTIVE_INTERVAL) {
@@ -238,7 +234,7 @@ public class ClientServerSessionCache extends AbstractSessionCache {
* If we're using an empty client region, we register interest so that
* expired sessions are destroyed correctly.
*/
- if (! getSessionManager().getEnableLocalCache()) {
+ if (!getSessionManager().getEnableLocalCache()) {
region.registerInterest("ALL_KEYS", InterestResultPolicy.KEYS);
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8af9dfd7/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/CommitSessionValve.java
----------------------------------------------------------------------
diff --git a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/CommitSessionValve.java b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/CommitSessionValve.java
index da5ca44..16a16b7 100644
--- a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/CommitSessionValve.java
+++ b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/CommitSessionValve.java
@@ -7,10 +7,6 @@
*/
package com.gemstone.gemfire.modules.session.catalina;
-import java.io.IOException;
-
-import javax.servlet.ServletException;
-
import org.apache.catalina.Manager;
import org.apache.catalina.connector.Request;
import org.apache.catalina.connector.Response;
@@ -18,8 +14,11 @@ import org.apache.catalina.valves.ValveBase;
import org.apache.juli.logging.Log;
import org.apache.juli.logging.LogFactory;
+import javax.servlet.ServletException;
+import java.io.IOException;
+
public class CommitSessionValve extends ValveBase {
-
+
private static final Log log = LogFactory.getLog(CommitSessionValve.class);
protected static final String info = "com.gemstone.gemfire.modules.session.catalina.CommitSessionValve/1.0";
@@ -29,19 +28,18 @@ public class CommitSessionValve extends ValveBase {
}
@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();
DeltaSessionFacade session = null;
-
+
// Invoke the next Valve
try {
getNext().invoke(request, response);
} finally {
// Commit and if the correct Manager was found
if (manager instanceof DeltaSessionManager) {
- session = (DeltaSessionFacade)request.getSession(false);
+ session = (DeltaSessionFacade) request.getSession(false);
if (session != null) {
if (session.isValid()) {
((DeltaSessionManager) manager).removeTouchedSession(session.getId());
@@ -51,8 +49,7 @@ public class CommitSessionValve extends ValveBase {
}
} else {
if (manager.getContainer().getLogger().isDebugEnabled()) {
- manager.getContainer().getLogger().debug(
- session + ": Not valid so not committing.");
+ manager.getContainer().getLogger().debug(session + ": Not valid so not committing.");
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8af9dfd7/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/DeltaSession.java
----------------------------------------------------------------------
diff --git a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/DeltaSession.java b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/DeltaSession.java
index 007ab95..4181eb3 100644
--- a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/DeltaSession.java
+++ b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/DeltaSession.java
@@ -7,35 +7,12 @@
*/
package com.gemstone.gemfire.modules.session.catalina;
-import java.io.DataInput;
-import java.io.DataOutput;
-import java.io.IOException;
-import java.io.InputStream;
-import java.security.AccessController;
-import java.security.Principal;
-import java.security.PrivilegedAction;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import javax.servlet.http.HttpSession;
-
-import com.gemstone.gemfire.internal.cache.lru.Sizeable;
-import org.apache.catalina.Manager;
-import org.apache.catalina.ha.session.SerializablePrincipal;
-import org.apache.catalina.realm.GenericPrincipal;
-import org.apache.catalina.security.SecurityUtil;
-import org.apache.catalina.session.StandardSession;
-
import com.gemstone.gemfire.DataSerializable;
import com.gemstone.gemfire.DataSerializer;
import com.gemstone.gemfire.Delta;
import com.gemstone.gemfire.InvalidDeltaException;
import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.internal.cache.lru.Sizeable;
import com.gemstone.gemfire.internal.util.BlobHelper;
import com.gemstone.gemfire.modules.gatewaydelta.GatewayDelta;
import com.gemstone.gemfire.modules.gatewaydelta.GatewayDeltaEvent;
@@ -43,38 +20,59 @@ import com.gemstone.gemfire.modules.session.catalina.internal.DeltaSessionAttrib
import com.gemstone.gemfire.modules.session.catalina.internal.DeltaSessionAttributeEventBatch;
import com.gemstone.gemfire.modules.session.catalina.internal.DeltaSessionDestroyAttributeEvent;
import com.gemstone.gemfire.modules.session.catalina.internal.DeltaSessionUpdateAttributeEvent;
+import org.apache.catalina.Manager;
+import org.apache.catalina.ha.session.SerializablePrincipal;
+import org.apache.catalina.realm.GenericPrincipal;
+import org.apache.catalina.security.SecurityUtil;
+import org.apache.catalina.session.StandardSession;
import org.apache.juli.logging.Log;
import org.apache.juli.logging.LogFactory;
+import javax.servlet.http.HttpSession;
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+import java.io.InputStream;
+import java.security.AccessController;
+import java.security.Principal;
+import java.security.PrivilegedAction;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
@SuppressWarnings("serial")
public class DeltaSession extends StandardSession implements DataSerializable, Delta, GatewayDelta, Sizeable {
-
- private transient Region<String,HttpSession> operatingRegion;
-
+
+ private transient Region<String, HttpSession> operatingRegion;
+
private String sessionRegionName;
private String contextName;
private boolean hasDelta;
-
+
private boolean applyRemotely;
-
+
private boolean enableGatewayDeltaReplication;
private transient final Object changeLock = new Object();
-
+
private final List<DeltaSessionAttributeEvent> eventQueue = new ArrayList<DeltaSessionAttributeEvent>();
-
+
private transient GatewayDeltaEvent currentGatewayDeltaEvent;
-
+
private transient boolean expired = false;
private transient boolean preferDeserializedForm = true;
-
+
private byte[] serializedPrincipal;
private final Log LOG = LogFactory.getLog(DeltaSession.class.getName());
-
+
/**
* The string manager for this package.
*/
@@ -82,9 +80,8 @@ public class DeltaSession extends StandardSession implements DataSerializable, D
// StringManager.getManager("com.gemstone.gemfire.modules.session.catalina");
/**
- * Construct a new <code>Session</code> associated with no
- * <code>Manager</code>. The <code>Manager</code> will be assigned later using
- * {@link #setOwner(Object)}.
+ * Construct a new <code>Session</code> associated with no <code>Manager</code>. The <code>Manager</code> will be
+ * assigned later using {@link #setOwner(Object)}.
*/
public DeltaSession() {
super(null);
@@ -92,37 +89,34 @@ public class DeltaSession extends StandardSession implements DataSerializable, D
/**
* Construct a new Session associated with the specified Manager.
- *
- * @param manager
- * The manager with which this Session is associated
+ *
+ * @param manager The manager with which this Session is associated
*/
public DeltaSession(Manager manager) {
super(manager);
setOwner(manager);
}
-
+
/**
- * Return the <code>HttpSession</code> for which this object
- * is the facade.
+ * Return the <code>HttpSession</code> for which this object is the facade.
*/
@SuppressWarnings("unchecked")
public HttpSession getSession() {
if (facade == null) {
if (SecurityUtil.isPackageProtectionEnabled()) {
final DeltaSession fsession = this;
- facade = (DeltaSessionFacade) AccessController
- .doPrivileged(new PrivilegedAction() {
- public Object run() {
- return new DeltaSessionFacade(fsession);
- }
- });
+ facade = (DeltaSessionFacade) AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return new DeltaSessionFacade(fsession);
+ }
+ });
} else {
facade = new DeltaSessionFacade(this);
}
}
return (facade);
}
-
+
public Principal getPrincipal() {
if (this.principal == null && this.serializedPrincipal != null) {
SerializablePrincipal sp = null;
@@ -130,9 +124,9 @@ public class DeltaSession extends StandardSession implements DataSerializable, D
sp = (SerializablePrincipal) BlobHelper.deserializeBlob(this.serializedPrincipal);
} catch (Exception e) {
StringBuilder builder = new StringBuilder();
- builder
- .append(this)
- .append(": Serialized principal contains a byte[] that cannot be deserialized due to the following exception");
+ builder.append(this)
+ .append(
+ ": Serialized principal contains a byte[] that cannot be deserialized due to the following exception");
((DeltaSessionManager) getManager()).getLogger().warn(builder.toString(), e);
return null;
}
@@ -180,8 +174,8 @@ public class DeltaSession extends StandardSession implements DataSerializable, D
}
return this.serializedPrincipal;
}
-
- protected Region<String,HttpSession> getOperatingRegion() {
+
+ protected Region<String, HttpSession> getOperatingRegion() {
// This region shouldn't be null when it is needed.
// It should have been set by the setOwner method.
return this.operatingRegion;
@@ -195,7 +189,7 @@ public class DeltaSession extends StandardSession implements DataSerializable, D
public GatewayDeltaEvent getCurrentGatewayDeltaEvent() {
return this.currentGatewayDeltaEvent;
}
-
+
public void setCurrentGatewayDeltaEvent(GatewayDeltaEvent currentGatewayDeltaEvent) {
this.currentGatewayDeltaEvent = currentGatewayDeltaEvent;
}
@@ -227,11 +221,11 @@ public class DeltaSession extends StandardSession implements DataSerializable, D
}
private void checkBackingCacheAvailable() {
- if (! ((SessionManager)getManager()).isBackingCacheAvailable()) {
+ if (!((SessionManager) getManager()).isBackingCacheAvailable()) {
throw new IllegalStateException("No backing cache server is available.");
}
}
-
+
public void setAttribute(String name, Object value, boolean notify) {
checkBackingCacheAvailable();
synchronized (this.changeLock) {
@@ -248,35 +242,35 @@ public class DeltaSession extends StandardSession implements DataSerializable, D
if (serializedValue == null) {
return;
}
-
+
// Create the update attribute message
DeltaSessionAttributeEvent event = new DeltaSessionUpdateAttributeEvent(name, serializedValue);
queueAttributeEvent(event, true);
-
+
// Distribute the update
- if (! isCommitEnabled()) {
+ if (!isCommitEnabled()) {
putInRegion(getOperatingRegion(), true, null);
}
}
}
-
+
public void removeAttribute(String name, boolean notify) {
checkBackingCacheAvailable();
synchronized (this.changeLock) {
// Remove the attribute locally
super.removeAttribute(name, true);
-
+
// Create the destroy attribute message
DeltaSessionAttributeEvent event = new DeltaSessionDestroyAttributeEvent(name);
queueAttributeEvent(event, true);
-
+
// Distribute the update
- if (! isCommitEnabled()) {
+ if (!isCommitEnabled()) {
putInRegion(getOperatingRegion(), true, null);
}
}
}
-
+
public Object getAttribute(String name) {
checkBackingCacheAvailable();
Object value = super.getAttribute(name);
@@ -288,23 +282,22 @@ public class DeltaSession extends StandardSession implements DataSerializable, D
value = BlobHelper.deserializeBlob((byte[]) value);
} catch (Exception e) {
StringBuilder builder = new StringBuilder();
- builder
- .append(this)
- .append(": Attribute named ")
- .append(name)
- .append(" contains a byte[] that cannot be deserialized due to the following exception");
+ builder.append(this)
+ .append(": Attribute named ")
+ .append(name)
+ .append(" contains a byte[] that cannot be deserialized due to the following exception");
((DeltaSessionManager) getManager()).getLogger().warn(builder.toString(), e);
}
if (this.preferDeserializedForm) {
localUpdateAttribute(name, value);
}
}
-
+
// Touch the session region if necessary. This is an asynchronous operation
// that prevents the session region from prematurely expiring a session that
// is only getting attributes.
((DeltaSessionManager) getManager()).addSessionToTouch(getId());
-
+
return value;
}
@@ -323,7 +316,7 @@ public class DeltaSession extends StandardSession implements DataSerializable, D
// Do expire processing
expire();
-
+
// Update statistics
DeltaSessionManager manager = (DeltaSessionManager) getManager();
if (manager != null) {
@@ -338,18 +331,18 @@ public class DeltaSession extends StandardSession implements DataSerializable, D
public void localUpdateAttribute(String name, Object value) {
super.setAttribute(name, value, false); // don't do notification since this is a replication
}
-
+
public void localDestroyAttribute(String name) {
super.removeAttribute(name, false); // don't do notification since this is a replication
}
-
- public void applyAttributeEvents(Region<String,DeltaSession> region, List<DeltaSessionAttributeEvent> events) {
+
+ public void applyAttributeEvents(Region<String, DeltaSession> region, List<DeltaSessionAttributeEvent> events) {
for (DeltaSessionAttributeEvent event : events) {
event.apply(this);
queueAttributeEvent(event, false);
}
-
- putInRegion(region, false, true);
+
+ putInRegion(region, false, true);
}
private void initializeRegion(DeltaSessionManager sessionManager) {
@@ -366,7 +359,7 @@ public class DeltaSession extends StandardSession implements DataSerializable, D
sessionManager.getLogger().debug(this + ": Set operating region: " + this.operatingRegion);
}
}
-
+
private void queueAttributeEvent(DeltaSessionAttributeEvent event, boolean checkAddToCurrentGatewayDelta) {
// Add to current gateway delta if necessary
if (checkAddToCurrentGatewayDelta) {
@@ -378,7 +371,7 @@ public class DeltaSession extends StandardSession implements DataSerializable, D
// If commit is not enabled, add the event to the current batch; else,
// the current batch will be initialized to the events in the queue will
// be added at commit time.
- if (! isCommitEnabled()) {
+ if (!isCommitEnabled()) {
List<DeltaSessionAttributeEvent> events = new ArrayList<DeltaSessionAttributeEvent>();
events.add(event);
this.currentGatewayDeltaEvent = new DeltaSessionAttributeEventBatch(this.sessionRegionName, this.id, events);
@@ -395,11 +388,10 @@ public class DeltaSession extends StandardSession implements DataSerializable, D
region.put(this.id, this, callbackArgument);
this.eventQueue.clear();
}
-
+
public void commit() {
- if (!isValidInternal())
- throw new IllegalStateException("commit: Session " + getId() +
- " already invalidated");
+ if (!isValidInternal()) throw new IllegalStateException("commit: Session " + getId() +
+ " already invalidated");
// (STRING_MANAGER.getString("deltaSession.commit.ise", getId()));
synchronized (this.changeLock) {
@@ -408,7 +400,8 @@ public class DeltaSession extends StandardSession implements DataSerializable, D
// will be updated even when no attributes have been changed.
DeltaSessionManager mgr = (DeltaSessionManager) this.manager;
if (this.enableGatewayDeltaReplication && mgr.isPeerToPeer()) {
- setCurrentGatewayDeltaEvent(new DeltaSessionAttributeEventBatch(this.sessionRegionName, this.id, this.eventQueue));
+ setCurrentGatewayDeltaEvent(
+ new DeltaSessionAttributeEventBatch(this.sessionRegionName, this.id, this.eventQueue));
}
this.hasDelta = true;
this.applyRemotely = true;
@@ -416,7 +409,7 @@ public class DeltaSession extends StandardSession implements DataSerializable, D
this.eventQueue.clear();
}
}
-
+
public void abort() {
synchronized (this.changeLock) {
this.eventQueue.clear();
@@ -434,7 +427,7 @@ public class DeltaSession extends StandardSession implements DataSerializable, D
public String getContextName() {
return contextName;
}
-
+
public boolean hasDelta() {
return this.hasDelta;
}
@@ -449,7 +442,7 @@ public class DeltaSession extends StandardSession implements DataSerializable, D
out.writeLong(this.lastAccessedTime);
out.writeInt(this.maxInactiveInterval);
}
-
+
public void fromDelta(DataInput in) throws IOException, InvalidDeltaException {
// Read whether to apply the changes to another DS if necessary
this.applyRemotely = in.readBoolean();
@@ -463,7 +456,7 @@ public class DeltaSession extends StandardSession implements DataSerializable, D
}
// This allows for backwards compatibility with 2.1 clients
- if (((InputStream)in).available() > 0) {
+ if (((InputStream) in).available() > 0) {
this.lastAccessedTime = in.readLong();
this.maxInactiveInterval = in.readInt();
}
@@ -521,7 +514,7 @@ public class DeltaSession extends StandardSession implements DataSerializable, D
this.sessionRegionName = DataSerializer.readString(in);
// This allows for backwards compatibility with 2.1 clients
- if (((InputStream)in).available() > 0) {
+ if (((InputStream) in).available() > 0) {
this.contextName = DataSerializer.readString(in);
}
@@ -550,48 +543,46 @@ public class DeltaSession extends StandardSession implements DataSerializable, D
return size;
}
- @SuppressWarnings({ "unchecked", "rawtypes" })
- private Map<String,byte[]> getSerializedAttributes() {
+ @SuppressWarnings({"unchecked", "rawtypes"})
+ private Map<String, byte[]> getSerializedAttributes() {
// Iterate the values and serialize them if necessary before sending them to the server. This makes the application classes unnecessary on the server.
- Map<String,byte[]> serializedAttributes = new ConcurrentHashMap<String,byte[]>();
- for (Iterator i= this.attributes.entrySet().iterator(); i.hasNext();) {
- Map.Entry<String,Object> entry = (Map.Entry<String,Object>) i.next();
+ Map<String, byte[]> serializedAttributes = new ConcurrentHashMap<String, byte[]>();
+ for (Iterator i = this.attributes.entrySet().iterator(); i.hasNext(); ) {
+ Map.Entry<String, Object> entry = (Map.Entry<String, Object>) i.next();
Object value = entry.getValue();
byte[] serializedValue = value instanceof byte[] ? (byte[]) value : serialize(value);
serializedAttributes.put(entry.getKey(), serializedValue);
}
return serializedAttributes;
}
-
+
private byte[] serialize(Object obj) {
byte[] serializedValue = null;
try {
serializedValue = BlobHelper.serializeToBlob(obj);
} catch (IOException e) {
StringBuilder builder = new StringBuilder();
- builder
- .append(this)
- .append(": Object ")
- .append(obj)
- .append(" cannot be serialized due to the following exception");
+ builder.append(this)
+ .append(": Object ")
+ .append(obj)
+ .append(" cannot be serialized due to the following exception");
((DeltaSessionManager) getManager()).getLogger().warn(builder.toString(), e);
}
return serializedValue;
}
-
+
@Override
public String toString() {
- return new StringBuilder()
- .append("DeltaSession[")
- .append("id=")
- .append(getId())
- .append("; context=")
- .append(this.contextName)
- .append("; sessionRegionName=")
- .append(this.sessionRegionName)
- .append("; operatingRegionName=")
- .append(getOperatingRegion() == null ? "unset" : getOperatingRegion().getFullPath())
- .append("]")
- .toString();
+ return new StringBuilder().append("DeltaSession[")
+ .append("id=")
+ .append(getId())
+ .append("; context=")
+ .append(this.contextName)
+ .append("; sessionRegionName=")
+ .append(this.sessionRegionName)
+ .append("; operatingRegionName=")
+ .append(getOperatingRegion() == null ? "unset" : getOperatingRegion().getFullPath())
+ .append("]")
+ .toString();
}
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8af9dfd7/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/DeltaSessionFacade.java
----------------------------------------------------------------------
diff --git a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/DeltaSessionFacade.java b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/DeltaSessionFacade.java
index dcb3433..e035813 100644
--- a/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/DeltaSessionFacade.java
+++ b/extensions/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/DeltaSessionFacade.java
@@ -12,24 +12,24 @@ import org.apache.catalina.session.StandardSessionFacade;
import javax.servlet.http.HttpSession;
public class DeltaSessionFacade extends StandardSessionFacade {
-
+
private DeltaSession session;
/**
* Construct a new session facade.
*/
public DeltaSessionFacade(DeltaSession session) {
- super((HttpSession)session);
+ super((HttpSession) session);
// Store session locally since the super session is private and provides no accessor.
this.session = session;
}
// ----------- DeltaSession Methods
-
+
public void commit() {
this.session.commit();
}
-
+
public void abort() {
this.session.abort();
}