Configuring session management websphere
Below function can be used to configure the session manager for the session management websphere #--------------------------------------------------------------------------------- #-- Configuring session manager for Web container #--------------------------------------------------------------------------------- proc webcontainer_sessionsetall {} { puts "************************************************************************" puts "---- Configuring session manager for Web container ----" puts "************************************************************************" if { $Dep_Type == "doall" } { #---------------------------------------------------------------- set servernumber [llength $serverNames] puts "deploy: -- webserver number found: $servernumber" set servernodenumber [llength $nodeNames] puts "deploy: -- webservernode number found:$servernodenumber" puts "deploy: -- start looping ..." for {set i 0} {$i < $servernumber} {incr i} { puts "deploy: -- Server number set to:I=$i" set serverName [lindex $serverNames $i] puts "deploy: -- serverName:$serverName" set nodeName [lindex $nodeNames $i] puts "deploy: -- servernodeName:$nodeName" if { [llength $serverName] && [llength $nodeName] } { puts "----------------------------------------------------------------------------------" puts "serverconfig: -- Setting up Session Manager for $serverName on node $nodeName..." puts "----------------------------------------------------------------------------------" #------------------------------------------------------------------ set SerializedSessionAccess "false" set CookieValue "true" set myDomain "" set myCookieName "JSESSIONID" set sessionPersistenceModeName "DATA_REPLICATION" #------------------------------------------------------------------ set aServer [$AdminConfig getid /Node:$nodeName/Server:$serverName/] if { [llength $aServer] == 0 } { puts "Server $serverName do not exists." exit 0 } else { puts "Server $serverName exists" } set aSessionMgr [$AdminConfig list SessionManager $aServer] puts "Configure session serialization access" set serialAccessAttr [list allowSerializedSessionAccess $SerializedSessionAccess] set waitTimeAttr [list maxWaitTime 30] set timeoutAttr [list accessSessionOnTimeout true] set attrs [list $serialAccessAttr $waitTimeAttr $timeoutAttr] $AdminConfig modify $aSessionMgr $attrs puts "Configure to track session with cookies" set cookieAttr [list enableCookies $CookieValue] set protocolAttr [list enableProtocolSwitchRewriting false] set urlAttr [list enableUrlRewriting false] set sslAttr [list enableSSLTracking false] # valid session persistence mode values are NONE, DATABASE, and DATA_REPLICATION] set sessionPersistenceAttr [list sessionPersistenceMode DATA_REPLICATION] #lappend sessionPersistenceAttr {Cluster cluster1} #set sessionPersistenceAttr [list sessionPersistenceMode DATABASE] set attrs [list $cookieAttr $urlAttr $sslAttr $protocolAttr] $AdminConfig modify $aSessionMgr $attrs # setting up Cookie attributes set domainAttr [list domain $myDomain] # set cookie maximum age to use current browser session set maxAgeAttr [list maximumAge -1] set nameAttr [list name $myCookieName] set pathAttr [list path "/"] set secureAttr [list secure false] set cookieAttrs [list $domainAttr $maxAgeAttr $nameAttr $pathAttr $secureAttr] # get the cookie config object name for the above SessionManager set cookie [$AdminConfig showAttribute $aSessionMgr defaultCookieSettings] # check if there is existing cookie properties if {[llength $cookie] != 0} { # modifying existing cookie puts "Modify existing cookie" $AdminConfig modify $cookie $cookieAttrs puts [$AdminConfig showall $cookie] } else { # create a cookie puts "Create a cookie" set cookie [$AdminConfig create Cookie $aSessionMgr $cookieAttrs] puts [$AdminConfig showall $cookie] } # setting up database session persistence if { $sessionPersistenceModeName == "DATABASE" } { puts "Configure for database session persistence" set dsJndiAttr [list datasourceJNDIName jdbc/mySession] set userAttr [list userId myUser] set pwdAttr [list password myPassword] set sessionDbPersAttrs [list $dsJndiAttr $userAttr $pwdAttr] # get session database persistence config object name set aSessionDbPers [$AdminConfig showAttribute $aSessionMgr sessionDatabasePersistence] if {[llength $aSessionDbPers] != 0} { puts "Modify existing session database persistence" $AdminConfig modify $aSessionDbPers $sessionDbPersAttrs puts [$AdminConfig showall $aSessionDbPers] } else { puts "Create a session database persistence object" set aSessionDbPers [$AdminConfig create SessionDatabasePersistence $aSessionMgr $sessionDbPersAttrs] puts [$AdminConfig showall $aSessionDbPers] } } if { $sessionPersistenceModeName == "DATA_REPLICATION" } { puts "Found replication mode as Memory to Memory Replication" set deployments [$AdminConfig getid /Server:$serverName/] set smgr [$AdminConfig list SessionManager $deployments] set attrs [list [list sessionPersistenceMode DATA_REPLICATION]] lappend attrs {enable true} $AdminConfig modify $smgr $attrs } # setting up attributes for TuningParams set aofAttr [list allowOverflow true] set isAttr [list invalidationSchedule [list [list firstHour 2] [list secondHour 5]]] set itAttr [list invalidationTimeout 30] set mimscAttr [list maxInMemorySessionCount 1000] set siAttr [list scheduleInvalidation true] set umrsAttr [list usingMultiRowSchema true] set wcAttr [list writeContents ONLY_UPDATED_ATTRIBUTES] set wfAttr [list writeFrequency END_OF_SERVLET_SERVICE] set wiAttr [list writeInterval 5] set tuningParamAttrs [list $aofAttr $isAttr $itAttr $mimscAttr $siAttr $umrsAttr $wcAttr $wfAttr $wiAttr] # get tuning params config object name set tp [$AdminConfig showAttribute $aSessionMgr tuningParams] # check if there is existing tuning params if {[llength $tp] != 0} { # modifying TuningParams attributes puts "Modify existing tuning params" $AdminConfig modify $tp $tuningParamAttrs puts [$AdminConfig showall $tp] } else { # create a turning params object puts "Create a tuning params object" set tp [$AdminConfig create TuningParams $aSessionMgr $tuningParamAttrs] puts [$AdminConfig showall $tp] } puts "saving configuration." $AdminConfig save break }}} else { puts "Skipping loop as DepType choosen other than doall" puts "----------------------------------------------------------------------------------" puts "serverconfig: -- Setting up Session Manager for $serverName on node $nodeName..." puts "----------------------------------------------------------------------------------" #------------------------------------------------------------------ set SerializedSessionAccess "false" set CookieValue "true" set myDomain "" set myCookieName "JSESSIONID" set sessionPersistenceModeName "DATA_REPLICATION" #------------------------------------------------------------------ set aServer [$AdminConfig getid /Node:$nodeName/Server:$serverName/] if { [llength $aServer] == 0 } { puts "Server $serverName do not exists." exit 0 } else { puts "Server $serverName exists" } set aSessionMgr [$AdminConfig list SessionManager $aServer] puts "Configure session serialization access" set serialAccessAttr [list allowSerializedSessionAccess $SerializedSessionAccess] set waitTimeAttr [list maxWaitTime 30] set timeoutAttr [list accessSessionOnTimeout true] set attrs [list $serialAccessAttr $waitTimeAttr $timeoutAttr] $AdminConfig modify $aSessionMgr $attrs puts "Configure to track session with cookies" set cookieAttr [list enableCookies $CookieValue] set protocolAttr [list enableProtocolSwitchRewriting false] set urlAttr [list enableUrlRewriting false] set sslAttr [list enableSSLTracking false] # valid session persistence mode values are NONE, DATABASE, and DATA_REPLICATION] set sessionPersistenceAttr [list sessionPersistenceMode DATA_REPLICATION] #lappend sessionPersistenceAttr {Cluster cluster1} puts "sessionPersistenceAttr $sessionPersistenceAttr" #set sessionPersistenceAttr [list sessionPersistenceMode DATABASE] set attrs [list $cookieAttr $urlAttr $sslAttr $protocolAttr] $AdminConfig modify $aSessionMgr $attrs # setting up Cookie attributes set domainAttr [list domain $myDomain] # set cookie maximum age to use current browser session set maxAgeAttr [list maximumAge -1] set nameAttr [list name $myCookieName] set pathAttr [list path "/"] set secureAttr [list secure false] set cookieAttrs [list $domainAttr $maxAgeAttr $nameAttr $pathAttr $secureAttr] # get the cookie config object name for the above SessionManager set cookie [$AdminConfig showAttribute $aSessionMgr defaultCookieSettings] # check if there is existing cookie properties if {[llength $cookie] != 0} { # modifying existing cookie puts "Modify existing cookie" $AdminConfig modify $cookie $cookieAttrs puts [$AdminConfig showall $cookie] } else { # create a cookie puts "Create a cookie" set cookie [$AdminConfig create Cookie $aSessionMgr $cookieAttrs] puts [$AdminConfig showall $cookie] } # setting up database session persistence if { $sessionPersistenceModeName == "DATABASE" } { puts "Configure for database session persistence" set dsJndiAttr [list datasourceJNDIName jdbc/mySession] set userAttr [list userId myUser] set pwdAttr [list password myPassword] set sessionDbPersAttrs [list $dsJndiAttr $userAttr $pwdAttr] # get session database persistence config object name set aSessionDbPers [$AdminConfig showAttribute $aSessionMgr sessionDatabasePersistence] if {[llength $aSessionDbPers] != 0} { puts "Modify existing session database persistence" $AdminConfig modify $aSessionDbPers $sessionDbPersAttrs puts [$AdminConfig showall $aSessionDbPers] } else { puts "Create a session database persistence object" set aSessionDbPers [$AdminConfig create SessionDatabasePersistence $aSessionMgr $sessionDbPersAttrs] puts [$AdminConfig showall $aSessionDbPers] } } if { $sessionPersistenceModeName == "DATA_REPLICATION" } { puts "Found replication mode as Memory to Memory Replication" set deployments [$AdminConfig getid /Server:$serverName/] set smgr [$AdminConfig list SessionManager $deployments] set attrs [list [list sessionPersistenceMode DATA_REPLICATION]] lappend attrs {enable true} $AdminConfig modify $smgr $attrs } # setting up attributes for TuningParams set aofAttr [list allowOverflow true] set isAttr [list invalidationSchedule [list [list firstHour 2] [list secondHour 5]]] set itAttr [list invalidationTimeout 30] set mimscAttr [list maxInMemorySessionCount 1000] set siAttr [list scheduleInvalidation true] set umrsAttr [list usingMultiRowSchema true] set wcAttr [list writeContents ONLY_UPDATED_ATTRIBUTES] set wfAttr [list writeFrequency END_OF_SERVLET_SERVICE] set wiAttr [list writeInterval 5] set tuningParamAttrs [list $aofAttr $isAttr $itAttr $mimscAttr $siAttr $umrsAttr $wcAttr $wfAttr $wiAttr] # get tuning params config object name set tp [$AdminConfig showAttribute $aSessionMgr tuningParams] # check if there is existing tuning params if {[llength $tp] != 0} { # modifying TuningParams attributes puts "Modify existing tuning params" $AdminConfig modify $tp $tuningParamAttrs puts [$AdminConfig showall $tp] } else { # create a turning params object puts "Create a tuning params object" set tp [$AdminConfig create TuningParams $aSessionMgr $tuningParamAttrs] puts [$AdminConfig showall $tp] } puts "saving configuration." $AdminConfig save }} #---------------------------------------------------------------------------------------- < \pre>
In case of any ©Copyright or missing credits issue please check CopyRights page for faster resolutions.