admin@glassfish.java.net

[Fwd: Review Issue no :1053]

From: Irfan Ahmed <irfan_at_sun.com>
Date: Wed, 15 Oct 2008 15:49:18 +0530

Hi Anissa and Ken,

We are trying to add Sip Application to the call flow charting data in
SailFin in addition to the Web Application data.

There are a few formatting functions that are static private which we
need to use to get the correct formatting for the displayed chart.
Swetha has been working on the same and she has done the code changes
for this.

Can you please review the GlassFish code changes needed for this.

Thanks and Warm Rgds,
Irfan.
-- 
Irfan Ahmed Sun Microsystems Inc., Bangalore, India. (0) 9180-66927726, 
email: irfan_at_sun.com

attached mail follows:



Hi Irfan,

I have attached the GUI diffs for the fix 1053.
I have also attached the screen shot's of the GUI for a WebApp and a
SipApp.
Can you please review the changes and let me know of any further
modifications?

*Issue no :1053*
Problem: Admin GUI Callflow details page treats sip applications as web
applications.
Fix : It required a fix in the back end code as well as a gui fix.

Thanks and Regards,
Swetha.


? admin-gui.log
? admin-gui.txt
? admin_gui_fix.txt
? build
? fix.txt
? hs_err_pid7869.log
? src/java/com/sun/extensions/comms/SipUtilities.java_bak1
? src/java/com/sun/extensions/comms/SipUtilities.java_bak2
Index: src/docroot/appServer/callFlowDetail.jsf
===================================================================
RCS file: /cvs/glassfish/admin-gui/src/docroot/appServer/callFlowDetail.jsf,v
retrieving revision 1.13.2.1
diff -u -r1.13.2.1 callFlowDetail.jsf
--- src/docroot/appServer/callFlowDetail.jsf 11 Jan 2008 01:07:16 -0000 1.13.2.1
+++ src/docroot/appServer/callFlowDetail.jsf 23 Sep 2008 05:54:36 -0000
@@ -81,8 +81,19 @@
             callFlowStackMap=>$attribute{listOfRows}
             hasCallFlowChart=>$attribute{hasCallFlowChart}
         );
- setPageSessionAttribute(key="xLabels" value="#{detailInfo.xLabels}");
+
+ if(#{SipConfigBean.enabled}) {
+ updateCallFlowDetail(instanceName="$pageSession{instanceName}",
+ requestId="$pageSession{requestId}",
+ demo="false"
+ doCharting="$pageSession{doCharting}"
+ infoMap="#{detailInfo}"
+ detailInfo=>$page{detailInfo}
+ hasCallFlowChart=>$attribute{hasCallFlowChart});
+ }
+
         setPageSessionAttribute(key="valueList" value="#{detailInfo.valueList}");
+ setPageSessionAttribute(key="xLabels" value="#{detailInfo.xLabels}");
 />
 
 <sun:page id="page1">
@@ -165,6 +176,12 @@
                <sun:property id="webCProp" rendered="#{detailInfo.hasWebContainer}" labelAlign="left" noWrap="#{true}" overlapLabel="#{false}" label="$resource{i18n.callFlowDetail.webContainer}" >
                     <sun:staticText id="webc" text="#{detailInfo.webContainer}"/>
                </sun:property>
+
+ if(#{SipConfigBean.enabled}) {
+ <sun:property id="sipAppProp" rendered="#{detailInfo.hasSipApp}" labelAlign="left" noWrap="#{true}" overlapLabel="#{false}" label="$resource{i18n.callFlowDetail.sipApp}" >
+ <sun:staticText id="sipApp" text="#{detailInfo.sipApp}"/>
+ </sun:property>
+ }
                
                 <sun:property id="webAppProp" rendered="#{detailInfo.hasWebApp}" labelAlign="left" noWrap="#{true}" overlapLabel="#{false}" label="$resource{i18n.callFlowDetail.webApp}" >
                     <sun:staticText id="webApp" text="#{detailInfo.webApp}"/>
Index: src/java/com/sun/enterprise/tools/admingui/handlers/CallFlowHandlers.java
===================================================================
RCS file: /cvs/glassfish/admin-gui/src/java/com/sun/enterprise/tools/admingui/handlers/CallFlowHandlers.java,v
retrieving revision 1.11
diff -u -r1.11 CallFlowHandlers.java
--- src/java/com/sun/enterprise/tools/admingui/handlers/CallFlowHandlers.java 6 Jun 2007 03:00:34 -0000 1.11
+++ src/java/com/sun/enterprise/tools/admingui/handlers/CallFlowHandlers.java 23 Sep 2008 05:54:37 -0000
@@ -516,7 +516,7 @@
     }
     
     
- static private List convertToDetailStackList(List listOfMap) {
+ static public List convertToDetailStackList(List listOfMap) {
         
         DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, GuiUtil.getLocale());
        
@@ -591,7 +591,7 @@
          String percentStr = "";
          
          List labelList = new ArrayList();
-
+
          if (timeSpendMap.containsKey("WEB_APPLICATION")){
              infoMap.put("hasWebApp", true);
              ms = timeSpendMap.get("WEB_APPLICATION");
@@ -685,7 +685,7 @@
      }
      
      
- private static Map emptyMap(String key){
+ public static Map emptyMap(String key){
          Map aMap = new HashMap();
          aMap.put("title", "0%");
          aMap.put("label", GuiUtil.getMessage(key));
@@ -693,7 +693,7 @@
          return aMap;
      }
      
- private static Map chartLabelMap(String key, float percent, String percentStr, String ms ){
+ public static Map chartLabelMap(String key, float percent, String percentStr, String ms ){
         Map aMap = new HashMap();
         aMap.put("label", GuiUtil.getMessage(key));
         aMap.put("title", formatStr(key+"DD", percentStr, ms));
@@ -701,13 +701,13 @@
         return aMap;
      }
 
- private static String formatStr(String key, String percent, String ms){
+ public static String formatStr(String key, String percent, String ms){
          
          return GuiUtil.getMessage(key, new Object[]{percent, convertNanoToMs(ms)});
      }
      
     
- static CallFlowMonitor getCallFlowMonitor(String instanceName){
+ public static CallFlowMonitor getCallFlowMonitor(String instanceName){
         ServerRootMonitor serverRootMonitor = AMXUtil.getServerRootMonitor(instanceName);
         if (serverRootMonitor == null)
             return null;
@@ -865,7 +865,7 @@
     
     static int democount = 0;
 
- static private Map getDemoTimeSpendMap(String id){
+ static public Map getDemoTimeSpendMap(String id){
         
         HashMap hashMap = new HashMap();
         
@@ -1093,7 +1093,7 @@
     /*
         Compare Time Spent Maps (for sorting).
      */
- private final static class TimeSpentComparator implements java.util.Comparator
+ public final static class TimeSpentComparator implements java.util.Comparator
     {
         public int compare( Object o1, Object o2 )
         {
Index: src/java/com/sun/enterprise/tools/admingui/resources/Strings.properties
===================================================================
RCS file: /cvs/glassfish/admin-gui/src/java/com/sun/enterprise/tools/admingui/resources/Strings.properties,v
retrieving revision 1.132.2.14
diff -u -r1.132.2.14 Strings.properties
--- src/java/com/sun/enterprise/tools/admingui/resources/Strings.properties 1 Sep 2008 15:42:39 -0000 1.132.2.14
+++ src/java/com/sun/enterprise/tools/admingui/resources/Strings.properties 23 Sep 2008 05:54:37 -0000
@@ -1774,6 +1774,7 @@
 callFlowDetail.Component=Component
 callFlowDetail.Method=Method
 callFlowDetail.RequestTimeSection=Request Time Distribution
+callFlowDetail.sipApp= Sip Application:
 callFlowDetail.webContainer=Web Container:
 callFlowDetail.webApp=Web Application:
 callFlowDetail.ejbContainer=EJB Container:
@@ -1781,6 +1782,8 @@
 callFlowDetail.orbContainer=ORB Container:
 callFlowDetail.percentMs={0}% <br>{1} ms
 
+callFlowDetail.chart.sipApp=Sip App.
+callFlowDetail.chart.sipAppDD=Sip Application ({0}%, {1} ms)
 callFlowDetail.chart.webApp=Web App.
 callFlowDetail.chart.webAppDD=Web Application ({0}%, {1} ms)
 callFlowDetail.chart.webCont=Web Cont.
Index: src/java/com/sun/extensions/comms/SipUtilities.java
===================================================================
RCS file: /cvs/glassfish/admin-gui/src/java/com/sun/extensions/comms/Attic/SipUtilities.java,v
retrieving revision 1.1.2.8
diff -u -r1.1.2.8 SipUtilities.java
--- src/java/com/sun/extensions/comms/SipUtilities.java 25 Jun 2008 10:14:02 -0000 1.1.2.8
+++ src/java/com/sun/extensions/comms/SipUtilities.java 23 Sep 2008 05:54:37 -0000
@@ -40,8 +40,10 @@
 import com.sun.appserv.management.config.ClusterConfig;
 import com.sun.appserv.management.config.DeployedItemRefConfig;
 import com.sun.appserv.management.config.StandaloneServerConfig;
+import com.sun.appserv.management.monitor.CallFlowMonitor;
 import com.sun.enterprise.tools.admingui.util.AMXUtil;
 import com.sun.enterprise.tools.admingui.util.GuiUtil;
+import com.sun.enterprise.tools.admingui.handlers.CallFlowHandlers;
 import com.sun.jsftemplating.annotation.Handler;
 import com.sun.jsftemplating.annotation.HandlerInput;
 import com.sun.jsftemplating.annotation.HandlerOutput;
@@ -50,9 +52,13 @@
 import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
+import java.util.Iterator;
+import java.text.NumberFormat;
 import javax.el.ELContext;
 import javax.el.ExpressionFactory;
 import javax.el.ValueExpression;
@@ -290,6 +296,106 @@
         handlerContext.setOutputValue("labels", labels);
         handlerContext.setOutputValue("values", values);
     }
+
+ /**
+ * <p> This handler returns all the info necessary to display the call flow detailpage
+ * @param context The HandlerContext.
+ *
+ */
+ @Handler(id="updateCallFlowDetail",
+ input={
+ @HandlerInput(name="instanceName", type=String.class, required=true),
+ @HandlerInput(name="requestId", type=String.class, required=true),
+ @HandlerInput(name="infoMap", type=java.util.Map.class),
+ @HandlerInput(name="demo", type=Boolean.class),
+ @HandlerInput(name="doCharting", type=Boolean.class, required=false)},
+ output={
+ @HandlerOutput(name="detailInfo", type=java.util.Map.class),
+ @HandlerOutput(name="hasCallFlowChart", type=Boolean.class)}
+ )
+ public static void updateCallFlowDetail(HandlerContext handlerCtx) {
+
+ HashMap infoMap = new HashMap((Map)handlerCtx.getInputValue("infoMap"));
+ Boolean demo = (Boolean) handlerCtx.getInputValue("demo");
+ String requestId = (String) handlerCtx.getInputValue("requestId");
+ Boolean doCharting = (Boolean )handlerCtx.getInputValue("doCharting");
+ String instanceName = (String) handlerCtx.getInputValue("instanceName");
+
+ CallFlowMonitor cfm = CallFlowHandlers.getCallFlowMonitor(instanceName);
+ Map timeSpendMap = null;
+ if (demo != null && demo ){
+ timeSpendMap = CallFlowHandlers.getDemoTimeSpendMap(requestId);
+ }else{
+ timeSpendMap = (Map<String,String>) cfm.queryPieInformation(requestId);
+ }
+
+ boolean hasChartData = updateTimeSpendInfo(infoMap, timeSpendMap, doCharting);
+
+ handlerCtx.setOutputValue("detailInfo", infoMap);
+ handlerCtx.setOutputValue("hasCallFlowChart", hasChartData);
+
+ }
+
+ static private boolean updateTimeSpendInfo(Map infoMap, Map<String,String> timeSpendMap, Boolean doCharting) {
+
+ float total = 0;
+ for(String key : timeSpendMap.keySet()){
+ total += Float.parseFloat(timeSpendMap.get(key));
+ }
+
+ NumberFormat nf = NumberFormat.getInstance(GuiUtil.getLocale());
+ nf.setMinimumFractionDigits(1);
+
+ String ms = null;
+ float percent = 0;
+ String percentStr = "";
+
+ List valueList = new ArrayList();
+ List labels = new ArrayList();
+ Set set = infoMap.keySet();
+ Iterator iter = set.iterator();
+ while(iter.hasNext())
+ {
+ if(iter.next().equals("xLabels"))
+ {
+ labels = (ArrayList) infoMap.get("xLabels");
+ }
+ }
+
+ if (timeSpendMap.containsKey("SIP_APPLICATION")){
+ infoMap.put("hasSipApp", true);
+ ms = timeSpendMap.get("SIP_APPLICATION");
+ percent = Float.parseFloat(ms)/total * 100;
+ percentStr = nf.format(percent);
+ infoMap.put("sipApp", CallFlowHandlers.formatStr("callFlowDetail.percentMs", percentStr, ms));
+ labels.add(CallFlowHandlers.chartLabelMap("callFlowDetail.chart.sipApp", percent, percentStr, ms));
+ }else{
+ infoMap.put("hasSipApp", false);
+ labels.add(CallFlowHandlers.emptyMap("callFlowDetail.chart.sipApp"));
+ }
+
+ Collections.sort(labels, new CallFlowHandlers.TimeSpentComparator());
+
+ infoMap.put("xLabels", labels);
+ for(int i=0; i < labels.size() ; i++){
+ Float ff = (Float) ((Map)labels.get(i)).get("compValue");
+ valueList.add( Math.round(ff));
+ }
+
+ Map vMap = new HashMap();
+ vMap.put("color", "green");
+ vMap.put("values", valueList);
+
+ List vList = new ArrayList();
+ vList.add(vMap);
+ infoMap.put("valueList", vList);
+
+ if (doCharting != null && !doCharting){
+ return false;
+ }
+
+ return doCharting;
+ }
     
     /** The function is used to set SIP Monitoring Objects for runtime monitoring information
      */
@@ -312,3 +418,4 @@
         handlerContext.setOutputValue("MonitorObjects", objects);
     }
 }
+





WebApp.jpg
(image/jpeg attachment: WebApp.jpg)

SipApp.jpg
(image/jpeg attachment: SipApp.jpg)