You can not get hold of HttpSession object in your portlet. To get hold of HttpSession object, either you write your custom interceptor or a filter. What you have is access to PortletSession object through getPortletSession method of request object where request could be a RenderRequest or ActionRequest. Unfortunately, there is no session.getSize() method which would tell you how big exactly your portlet session is. You would have to enumerate through attributes in session in both PORTLET_SCOPE and APPLICATION_SCOPE, get their values then obtain their size as follow:
Enumeration portletAttribs = session.getAttributeNames();
Enumeration applicationAttribs = session.getAttributeNames(PortletSession.APPLICATION_SCOPE);
ByteArrayOutputStream bs = new ByteArrayOutputStream();
ObjectOutputStream os = new ObjectOutputStream(bs);
while(portletAttribs.hasMoreElements())
{
Object obj = session.getAttribute(portletAttribs.nextElement());
os.writeObject(obj);
}
Similarly you enumerate through attributes in applicationAttribs and add write them to ObjectOuputStream. Then you get the size using:
System.out.println("PortletSession Size is " + bs.size());
The value you get is a close approximation to how big your portlet session is. HttpSession size will be bigger because portal needs to store the navigational state of your portlet/s as well.
Now, let's talk about how much data is getting replicated across your portal cluster. We will find this using JGroups MBean and JConsole which is the Java Monitoring and Management Console graphical tool shipped in J2SE JDK 5.0 and up.
First we need to prep up JBoss so that mbeans are available to JConsole. You can find the details at
JBoss-JConsole wiki. In a nutshell, you need to modiify $JBOSS_HOME/bin/run.conf. Your JAVA_OPTS should look more or less like
JAVA_OPTS="-Xms128m -Xmx512m -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Dcom.sun.management.jmxremote -Djavax.management.builder.initial=org.jboss.system.server.jmx.MBeanSe
rverBuilderImpl -Djboss.platform.mbeanserver"
Start JBoss Portal + JBoss AS bundle. In a separate terminal launch jconsole. You should automatically pick up PID of JBoss instance as shown here. Click Connect.
Now under MBeans tag, select Tree->jboss.jgroups -> protocol->Tomcat-Cluster->UDP as shown below. Here you will see total number of bytes sent and received by a node in cluster.
These Bytes Sent and Received value are for data related to session replication. To see replication data related to the second level cache used by Hibernate in Portal, you need to select
Tree->jboss.jgroups -> protocol->portal.hibernate->UDP
With those tools, you can now make sure that your sessions are not getting too large for the costly session replication on a cluster. You can use and abuse.
1 comment:
Hi, I m having problem that i can not view to chose version of portlet specification in configuration tab while creating dynamic web project also I am not able to view jboss a redheart produt while serner selection although viewing redheart community..I m using jbosss portal server as bundel 2.7.2 ,eclipse galileo and JBossTools-Update-3.1.1.v201006011046R-H111-GA(3).zip
,can anyone please help me to fix this.
Post a Comment