persistent session storage

46
MONTREAL JUNE 30, JULY 1ST AND 2ND 2012 Persistent Session Storage Henceforth referred to as PSS :) - Ramsey Gurley

Upload: wo-community

Post on 19-May-2015

694 views

Category:

Documents


0 download

DESCRIPTION

Learn how you can serialize your objects to use persistent session storage that can be restored even after a instance shutdown.

TRANSCRIPT

Page 1: Persistent Session Storage

MONTREAL JUNE 30, JULY 1ST AND 2ND 2012

MONTREAL JUNE 30, JULY 1ST AND 2ND 2012

Persistent Session StorageHenceforth referred to as PSS :)

- Ramsey Gurley

Page 2: Persistent Session Storage

Demo

Page 3: Persistent Session Storage

MONTREAL JUNE 30, JULY 1ST AND 2ND 2012

MONTREAL JUNE 30, JULY 1ST AND 2ND 2012

Robust, scalable, front end apps using component actions.

What does this mean?

Page 4: Persistent Session Storage

Advantages of PSS

• Memory consumption

• Long sessions

• Distribution

Page 5: Persistent Session Storage

Memory Consumption

• Sessions storage handled by EOF

• Session memory freed after each request

• Drastically improves stateful performance under load

Page 6: Persistent Session Storage

Long Sessions

• WOSessionTimeOut=0

• Bookmarkable component actions

Page 7: Persistent Session Storage

Distribution

• WOSession’s setDistributionEnabled()

• Restart instances anytime

• Improved scaling

Page 8: Persistent Session Storage

How do I enable PSS?

Page 9: Persistent Session Storage

Demo

Page 10: Persistent Session Storage

Steps to enable PSS

• Add ERPersistentSessionStorage framework

• Set up the connection dictionary for the model

• Generate the schema from the model (Enable migrations)

Page 11: Persistent Session Storage

MONTREAL JUNE 30, JULY 1ST AND 2ND 2012

MONTREAL JUNE 30, JULY 1ST AND 2ND 2012

How now brown cow?Why has no one done this before now?

Page 12: Persistent Session Storage

Serialization Bug

Page 13: Persistent Session Storage

EOGenericRecord

• Serialize EO

• Serializes EC

• Deserialize EO

• Deserialize EC

• Populate EO

EO EC

Page 14: Persistent Session Storage

Workaround?

• Serialize EC first!

• Fails :(

Page 15: Persistent Session Storage

EOGenericRecord

• Serialize EO

• Serializes related

• Deserialize EO

• Deserialize related

• Populate EO

EO EO

Page 16: Persistent Session Storage

What happens?

• EOCustomObject classDescription

• EOGenericRecord serializes classDescription

• Deserialize EOCustomObject sets values

• Dictionary not created until EOGenericRecord sets classDescription

• NullPointerException

Page 17: Persistent Session Storage

Serialization Bug Fix

• Re-implement core classes

• EOCustomObject

• EOGenericRecord

Page 18: Persistent Session Storage

Other WO Serialization Erros

• WODisplayGroup

• D2WPage

Page 19: Persistent Session Storage

Serialization

• Classpath order - ERD2W & ERPSS

• General rule - Wonder first

Page 20: Persistent Session Storage

PSS Requirements

Page 21: Persistent Session Storage

PSS Requirements

• Serializable components and classes

• Serializable session

• No memory leaks

Page 22: Persistent Session Storage

Serializable Classes

Page 23: Persistent Session Storage

serialVersionUID/**

* Do I need to update serialVersionUID? See section 5.6 <cite>Type Changes * Affecting Serialization</cite> on page 51 of the <a * href="http://java.sun.com/j2se/1.4/pdf/serial-spec.pdf">Java Object * Serialization Spec</a> */ private static final long serialVersionUID = 1L;

Page 24: Persistent Session Storage

Update serialVersionUID?

• Change class hierarchy

• Delete fields

• Make non-static into static

• Make non-transient into transient

• Change type of a primitive field

Page 25: Persistent Session Storage

Serializable Session

Page 26: Persistent Session Storage

Serializable Session

• Serializable instance variables

• Serializable object store contents

Page 27: Persistent Session Storage

No Memory Leaks

Page 28: Persistent Session Storage

Helpful Tools

• FindBugs

• jvisualvm

• jMeter

Page 29: Persistent Session Storage

Find Serialization Errors

Page 30: Persistent Session Storage

FindBugshttp://findbugs.cs.umd.edu/eclipse/

Page 31: Persistent Session Storage

FindBugs

Page 32: Persistent Session Storage

Serialization Debug Propertysun.io.serialization.extendedDebugInfo=true

Page 33: Persistent Session Storage

Serialization Debug PropertyCaused by: java.io.NotSerializableException: er.extensions.localization.ERXLocalizer

- field (class "er.modern.directtoweb.components.ERMDBatchSizeControl", name: "_localizer", ... - object (class "er.modern.directtoweb.components.ERMDBatchSizeControl",... - element of array (index: 5) - array (class "[Ljava.lang.Object;", size: 7) - field (class "com.webobjects.foundation.NSDictionary", name: "objects", type: "class [Ljava.lang.Object;") - custom writeObject data (class "com.webobjects.foundation.NSDictionary") - object (class "com.webobjects.foundation.NSMutableDictionary", ... - custom writeObject data (class "com.webobjects.appserver.WOComponent") - object (class "er.modern.look.pages.ERMODListPage", ... - field (class "com.webobjects.appserver._private.WOTransactionRecord", name: ... - object (class "com.webobjects.appserver._private.WOTransactionRecord", ... - element of array (index: 1) - array (class "[Ljava.lang.Object;", size: 2) - field (class "com.webobjects.foundation.NSDictionary", name: "objects", type: "class [Ljava.lang.Object;") - custom writeObject data (class "com.webobjects.foundation.NSDictionary") - object (class "com.webobjects.foundation.NSMutableDictionary", - field (class "com.webobjects.appserver.WOSession", name: "_contextRecords", ... - root object (class "wowodc.modernpss.Session", ...

Page 34: Persistent Session Storage

Other Serialization Issues

Page 35: Persistent Session Storage

D2WContext

• D2WContext is not serializable

• ERD2WContext is serializable

• Use ERD2WContext factory

Page 36: Persistent Session Storage

ERD2WContext

• Does not serialize entire context

• frame

• task

• entity

• propertyKey

• pageConfiguration

• object

Page 37: Persistent Session Storage

ERXEC

• calls dispose() during writeObject()

Page 38: Persistent Session Storage

Find Memory Leaks

Page 39: Persistent Session Storage

jvisualvm

• Installed with Java 1.6+

• Just type ‘jvisualvm’ into Terminal.app to launch

• View CPU and memory usage

Page 40: Persistent Session Storage

No Memory Leak

Page 41: Persistent Session Storage

Memory Leak

Page 42: Persistent Session Storage

Analyzing Memory

• Heap Dump

• Object Query Language (OQL)

• http://visualvm.java.net/oqlhelp.html

Page 43: Persistent Session Storage

Load Testing With JMeter

Page 44: Persistent Session Storage

JMeter

• http://jmeter.apache.org/

Page 45: Persistent Session Storage

Finding a Memory Leak Demo

Page 46: Persistent Session Storage

Q & A