[jboss-cvs] jboss-profiler/java/src/expansion/org/jboss/profiler/exp/view/servlet ...

Takuro Okada t2-okada at nri.co.jp
Mon Nov 6 02:36:59 EST 2006


  User: tokada  
  Date: 06/11/06 02:36:59

  Modified:    java/src/expansion/org/jboss/profiler/exp/view/servlet      
                        Tag: JBossProfiler_Expansion ExecutionStack.java
                        ConcurrencyMetrics.java ExecutionMetrics.java
                        MemoryMetrics.java ExecutionPassage.java
                        ExecutionPassageDetail.java
  Log:
  Added some functions for initial setting.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.2   +7 -8      jboss-profiler/java/src/expansion/org/jboss/profiler/exp/view/servlet/Attic/ExecutionStack.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ExecutionStack.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-profiler/java/src/expansion/org/jboss/profiler/exp/view/servlet/Attic/ExecutionStack.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -b -r1.1.2.1 -r1.1.2.2
  --- ExecutionStack.java	26 Oct 2006 08:58:56 -0000	1.1.2.1
  +++ ExecutionStack.java	6 Nov 2006 07:36:59 -0000	1.1.2.2
  @@ -71,17 +71,18 @@
       @SuppressWarnings("unchecked")
       protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
           
  +        // Gets application parameters
           String profilerServiceName = this.getServletContext().getInitParameter("ProfilerServiceName");
           if(profilerServiceName==null) profilerServiceName = DEFAULT_SERVICE_NAME;
           
  -        // invoke agent to get snapshot of metrics
  +        // Invokes agent to get snapshot of metrics
           Object obj = ServiceManager.invokeLocal(profilerServiceName, "snapMetrics");
           if(obj==null) {
               logger.error("failed to snap the metrics data.");
           }
           Map metricsMap = (Map)obj;
           
  -        // write xml
  +        // Writes xml to response
           response.setContentType("text/plain; charset=UTF-8");
           XMLOutputFactory factory = XMLOutputFactory.newInstance();
           factory.setProperty(XMLOutputFactory.INDENTATION, "  ");
  @@ -119,14 +120,12 @@
           } catch (XMLStreamException e) {
               logger.error("failed to write xml.");
           } finally {
  -            if(writer!=null) {
                   try {
  -                    writer.close();
  +                if(writer!=null) writer.close();
                   } catch (XMLStreamException e) {
                       logger.error("failed to write xml.");
                   }
               }
           }
  -    }
       
   }
  
  
  
  1.1.2.2   +48 -12    jboss-profiler/java/src/expansion/org/jboss/profiler/exp/view/servlet/Attic/ConcurrencyMetrics.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ConcurrencyMetrics.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-profiler/java/src/expansion/org/jboss/profiler/exp/view/servlet/Attic/ConcurrencyMetrics.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -b -r1.1.2.1 -r1.1.2.2
  --- ConcurrencyMetrics.java	26 Oct 2006 08:58:56 -0000	1.1.2.1
  +++ ConcurrencyMetrics.java	6 Nov 2006 07:36:59 -0000	1.1.2.2
  @@ -49,7 +49,7 @@
    * 
    * output exsample:
    * <concurrencyMetrics>
  - *   <recordSet category="AOP Interceptor">
  + *   <recordSet category="Beans">
    *     <record name="packagename"
    *             type="p"
    *             bcMax="3"
  @@ -84,22 +84,52 @@
       private final static MetricName[] targetMetricNames = new MetricName[] 
                                 {MetricName.BLOCK_COUNT, MetricName.BLOCK_TIME, MetricName.WAIT_COUNT, MetricName.WAIT_TIME};
       
  +    private final static String[] targetMetricNameStrings = new String[] 
  +                              {MetricName.BLOCK_COUNT.name(), MetricName.BLOCK_TIME.name(), 
  +                               MetricName.WAIT_COUNT.name(), MetricName.WAIT_TIME.name()};
  +    
       private static Logger logger = Logger.getLogger(ConcurrencyMetrics.class);
       
       @SuppressWarnings("unchecked")
       protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
           
  +        // Gets application parameters
           String profilerServiceName = this.getServletContext().getInitParameter("ProfilerServiceName");
           if(profilerServiceName==null) profilerServiceName = DEFAULT_SERVICE_NAME;
           
  -        // invoke agent to get snapshot of metrics
  -        Object obj = ServiceManager.invokeLocal(profilerServiceName, "snapMetrics");
  +        // Gets session attributes
  +        String[] filters = (String[])request.getSession().getAttribute(Initializer.RPK_FILTER);
  +        Long fromDate = null;
  +        Object fromDateInput = request.getSession().getAttribute(Initializer.RPK_FROM_DATE);
  +        if(fromDateInput!=null) {
  +            fromDate = Long.valueOf(String.valueOf(fromDateInput));
  +        }
  +        Long toDate = null;
  +        Object toDateInput = request.getSession().getAttribute(Initializer.RPK_TO_DATE);
  +        if(toDateInput!=null) {
  +            toDate = Long.valueOf(String.valueOf(toDateInput));
  +        }
  +        
  +        // Invokes agent to get snapshot of metrics
  +        Object obj = null;
  +        if(fromDate!=null || toDate!=null) {
  +            Object[] parameters = new Object[4];
  +            parameters[0] = ScaleMetric.class.getName();
  +            parameters[1] = targetMetricNameStrings;
  +            if(fromDate!=null) parameters[2] = fromDate;
  +            else               parameters[2] = new Long(-1);
  +            if(toDate!=null) parameters[3] = toDate;
  +            else             parameters[3] = new Long(-1);
  +            obj = ServiceManager.invokeLocal(profilerServiceName, "snapMetrics", parameters);
  +        }else {
  +            obj = ServiceManager.invokeLocal(profilerServiceName, "snapMetrics");
  +        }
           if(obj==null) {
               logger.error("failed to snap the metrics data.");
           }
           Map metricsMap = (Map)obj;
           
  -        // get metrics keys
  +        // Gets metrics keys
           Map<String, Signature> categoryMap = new TreeMap<String, Signature>();
           for(Object set : metricsMap.entrySet()) {
               Map.Entry categorySet = (Map.Entry)set;
  @@ -107,12 +137,20 @@
               Map omap = (Map)categorySet.getValue();
               Signature signature = new Signature();
               for(Object operationName : omap.keySet()) {
  -                signature.add(String.valueOf(operationName));
  +                String value = String.valueOf(operationName);
  +                if(filters!=null) {
  +                    boolean target = false;
  +                    for(String filter : filters) {
  +                        if(value.contains(filter)) target = true;
  +                    }
  +                    if(!target) continue;
  +                }
  +                signature.add(value);
               }
               categoryMap.put(category, signature);
           }
           
  -        // write xml
  +        // Writes xml to response
           response.setContentType("text/plain; charset=UTF-8");
           XMLOutputFactory factory = XMLOutputFactory.newInstance();
           factory.setProperty(XMLOutputFactory.INDENTATION, "  ");
  @@ -206,14 +244,12 @@
           } catch (XMLStreamException e) {
               logger.error("failed to write xml.");
           } finally {
  -            if(writer!=null) {
                   try {
  -                    writer.close();
  +                if(writer!=null) writer.close();
                   } catch (XMLStreamException e) {
                       logger.error("failed to write xml.");
                   }
               }
           }
  -    }
       
   }
  
  
  
  1.1.2.2   +49 -15    jboss-profiler/java/src/expansion/org/jboss/profiler/exp/view/servlet/Attic/ExecutionMetrics.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ExecutionMetrics.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-profiler/java/src/expansion/org/jboss/profiler/exp/view/servlet/Attic/ExecutionMetrics.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -b -r1.1.2.1 -r1.1.2.2
  --- ExecutionMetrics.java	26 Oct 2006 08:58:56 -0000	1.1.2.1
  +++ ExecutionMetrics.java	6 Nov 2006 07:36:59 -0000	1.1.2.2
  @@ -49,7 +49,7 @@
    * 
    * output exsample:
    * <executionMetrics>
  - *   <recordSet category="AOP Interceptor">
  + *   <recordSet category="Beans">
    *     <record name="packagename"
    *             type="p"
    *             invocationCount="3"
  @@ -78,23 +78,48 @@
       @SuppressWarnings("unchecked")
       protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
           
  +        // Gets application parameters
           String profilerServiceName = this.getServletContext().getInitParameter("ProfilerServiceName");
           if(profilerServiceName==null) profilerServiceName = DEFAULT_SERVICE_NAME;
           
  +        // Gets session attributes
           MetricName metricName = MetricName.USER_CPU_TIME;
  -        String metricNameInput = request.getParameter("org.jboss.profiler.exp.view.setting.MetricName");
  +        Object metricNameInput = request.getSession().getAttribute(Initializer.RPK_ES_METRIC_NAME);
           if(metricNameInput!=null) {
  -            if(metricNameInput.equals("cpuTime")) metricName = MetricName.CPU_TIME;
  +            metricName = MetricName.valueOf(String.valueOf(metricNameInput));
  +        }
  +        String[] filters = (String[])request.getSession().getAttribute(Initializer.RPK_FILTER);
  +        Long fromDate = null;
  +        Object fromDateInput = request.getSession().getAttribute(Initializer.RPK_FROM_DATE);
  +        if(fromDateInput!=null) {
  +            fromDate = Long.valueOf(String.valueOf(fromDateInput));
  +        }
  +        Long toDate = null;
  +        Object toDateInput = request.getSession().getAttribute(Initializer.RPK_TO_DATE);
  +        if(toDateInput!=null) {
  +            toDate = Long.valueOf(String.valueOf(toDateInput));
  +        }
  +        
  +        // Invokes agent to get snapshot of metrics
  +        Object obj = null;
  +        if(fromDate!=null || toDate!=null) {
  +            Object[] parameters = new Object[4];
  +            parameters[0] = ScaleMetric.class.getName();
  +            parameters[1] = new String[]{metricName.name()};
  +            if(fromDate!=null) parameters[2] = fromDate;
  +            else               parameters[2] = new Long(-1);
  +            if(toDate!=null) parameters[3] = toDate;
  +            else             parameters[3] = new Long(-1);
  +            obj = ServiceManager.invokeLocal(profilerServiceName, "snapMetrics", parameters);
  +        }else {
  +            obj = ServiceManager.invokeLocal(profilerServiceName, "snapMetrics");
           }
  -        
  -        // invoke agent to get snapshot of metrics
  -        Object obj = ServiceManager.invokeLocal(profilerServiceName, "snapMetrics");
           if(obj==null) {
               logger.error("failed to snap the metrics data.");
           }
           Map metricsMap = (Map)obj;
           
  -        // get metrics keys
  +        // Gets metrics keys
           Map<String, Signature> categoryMap = new TreeMap<String, Signature>();
           for(Object set : metricsMap.entrySet()) {
               Map.Entry categorySet = (Map.Entry)set;
  @@ -102,12 +127,20 @@
               Map omap = (Map)categorySet.getValue();
               Signature signature = new Signature();
               for(Object operationName : omap.keySet()) {
  -                signature.add(String.valueOf(operationName));
  +                String value = String.valueOf(operationName);
  +                if(filters!=null) {
  +                    boolean target = false;
  +                    for(String filter : filters) {
  +                        if(value.contains(filter)) target = true;
  +                    }
  +                    if(!target) continue;
  +                }
  +                signature.add(value);
               }
               categoryMap.put(category, signature);
           }
           
  -        // write xml
  +        // Writes xml to response
           response.setContentType("text/plain; charset=UTF-8");
           XMLOutputFactory factory = XMLOutputFactory.newInstance();
           factory.setProperty(XMLOutputFactory.INDENTATION, "  ");
  @@ -136,7 +169,10 @@
                           ScaleMetric metric = (ScaleMetric)mmap.get(metricName);
                           if(metric==null) continue;
                           
  -                        if(metricName.equals(MetricName.USER_CPU_TIME)) {
  +                        // Counts a value if specified metric name is supported.
  +                        if(metricName.equals(MetricName.CPU_TIME) ||
  +                           metricName.equals(MetricName.USER_CPU_TIME) ||
  +                           metricName.equals(MetricName.REAL_TIME)) {
                               invocationCount += metric.getCount();
                               if(metric.getHigh() > maxTime) maxTime = metric.getHigh();
                               if(metric.getLow() < minTime) minTime = metric.getLow();
  @@ -163,14 +199,12 @@
           } catch (XMLStreamException e) {
               logger.error("failed to write xml.");
           } finally {
  -            if(writer!=null) {
                   try {
  -                    writer.close();
  +                if(writer!=null) writer.close();
                   } catch (XMLStreamException e) {
                       logger.error("failed to write xml.");
                   }
               }
           }
  -    }
       
   }
  
  
  
  1.1.2.2   +44 -12    jboss-profiler/java/src/expansion/org/jboss/profiler/exp/view/servlet/Attic/MemoryMetrics.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: MemoryMetrics.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-profiler/java/src/expansion/org/jboss/profiler/exp/view/servlet/Attic/MemoryMetrics.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -b -r1.1.2.1 -r1.1.2.2
  --- MemoryMetrics.java	26 Oct 2006 08:58:56 -0000	1.1.2.1
  +++ MemoryMetrics.java	6 Nov 2006 07:36:59 -0000	1.1.2.2
  @@ -49,7 +49,7 @@
    * 
    * output exsample:
    * <memoryMetrics>
  - *   <recordSet category="AOP Interceptor">
  + *   <recordSet category="Beans">
    *     <record name="packagename"
    *             type="p"
    *             max="3"
  @@ -76,17 +76,43 @@
       @SuppressWarnings("unchecked")
       protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
           
  +        // Gets application parameters
           String profilerServiceName = this.getServletContext().getInitParameter("ProfilerServiceName");
           if(profilerServiceName==null) profilerServiceName = DEFAULT_SERVICE_NAME;
           
  -        // invoke agent to get snapshot of metrics
  -        Object obj = ServiceManager.invokeLocal(profilerServiceName, "snapMetrics");
  +        // Gets session attributes
  +        String[] filters = (String[])request.getSession().getAttribute(Initializer.RPK_FILTER);
  +        Long fromDate = null;
  +        Object fromDateInput = request.getSession().getAttribute(Initializer.RPK_FROM_DATE);
  +        if(fromDateInput!=null) {
  +            fromDate = Long.valueOf(String.valueOf(fromDateInput));
  +        }
  +        Long toDate = null;
  +        Object toDateInput = request.getSession().getAttribute(Initializer.RPK_TO_DATE);
  +        if(toDateInput!=null) {
  +            toDate = Long.valueOf(String.valueOf(toDateInput));
  +        }
  +        
  +        // Invokes agent to get snapshot of metrics
  +        Object obj = null;
  +        if(fromDate!=null || toDate!=null) {
  +            Object[] parameters = new Object[4];
  +            parameters[0] = ScaleMetric.class.getName();
  +            parameters[1] = new String[]{MetricName.MEMORY_USED.name()};
  +            if(fromDate!=null) parameters[2] = fromDate;
  +            else               parameters[2] = new Long(-1);
  +            if(toDate!=null) parameters[3] = toDate;
  +            else             parameters[3] = new Long(-1);
  +            obj = ServiceManager.invokeLocal(profilerServiceName, "snapMetrics", parameters);
  +        }else {
  +            obj = ServiceManager.invokeLocal(profilerServiceName, "snapMetrics");
  +        }
           if(obj==null) {
               logger.error("failed to snap the metrics data.");
           }
           Map metricsMap = (Map)obj;
           
  -        // get metrics keys
  +        // Gets metrics keys
           Map<String, Signature> categoryMap = new TreeMap<String, Signature>();
           for(Object set : metricsMap.entrySet()) {
               Map.Entry categorySet = (Map.Entry)set;
  @@ -94,12 +120,20 @@
               Map omap = (Map)categorySet.getValue();
               Signature signature = new Signature();
               for(Object operationName : omap.keySet()) {
  -                signature.add(String.valueOf(operationName));
  +                String value = String.valueOf(operationName);
  +                if(filters!=null) {
  +                    boolean target = false;
  +                    for(String filter : filters) {
  +                        if(value.contains(filter)) target = true;
  +                    }
  +                    if(!target) continue;
  +                }
  +                signature.add(value);
               }
               categoryMap.put(category, signature);
           }
           
  -        // write xml
  +        // Writes xml to response
           response.setContentType("text/plain; charset=UTF-8");
           XMLOutputFactory factory = XMLOutputFactory.newInstance();
           factory.setProperty(XMLOutputFactory.INDENTATION, "  ");
  @@ -148,14 +182,12 @@
           } catch (XMLStreamException e) {
               logger.error("failed to write xml.");
           } finally {
  -            if(writer!=null) {
                   try {
  -                    writer.close();
  +                if(writer!=null) writer.close();
                   } catch (XMLStreamException e) {
                       logger.error("failed to write xml.");
                   }
               }
           }
  -    }
       
   }
  
  
  
  1.1.2.2   +7 -12     jboss-profiler/java/src/expansion/org/jboss/profiler/exp/view/servlet/Attic/ExecutionPassage.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ExecutionPassage.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-profiler/java/src/expansion/org/jboss/profiler/exp/view/servlet/Attic/ExecutionPassage.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -b -r1.1.2.1 -r1.1.2.2
  --- ExecutionPassage.java	26 Oct 2006 08:58:56 -0000	1.1.2.1
  +++ ExecutionPassage.java	6 Nov 2006 07:36:59 -0000	1.1.2.2
  @@ -69,23 +69,20 @@
       
       protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
           
  +        // Gets application parameters
           String profilerServiceName = this.getServletContext().getInitParameter("ProfilerServiceName");
           if(profilerServiceName==null) profilerServiceName = DEFAULT_SERVICE_NAME;
           
           MetricName metricName = MetricName.USER_CPU_TIME_PASSAGE;
  -        String metricNameInput = request.getParameter("org.jboss.profiler.exp.view.setting.MetricName");
  -        if(metricNameInput!=null) {
  -            if(metricNameInput.equals("cpuTime")) metricName = MetricName.CPU_TIME_PASSAGE;
  -        }
           
  -        // invoke agent to get snapshot of metrics
  +        // Invokes agent to get snapshot of metrics
           Object obj = ServiceManager.invokeLocal(profilerServiceName, "snapMetrics");
           if(obj==null) {
               logger.error("failed to snap the metrics data.");
           }
           Map metricsMap = (Map)obj;
           
  -        // write xml
  +        // Writes xml to response
           response.setContentType("text/plain; charset=UTF-8");
           XMLOutputFactory factory = XMLOutputFactory.newInstance();
           factory.setProperty(XMLOutputFactory.INDENTATION, "  ");
  @@ -118,14 +115,12 @@
           } catch (XMLStreamException e) {
               logger.error("failed to write xml.");
           } finally {
  -            if(writer!=null) {
                   try {
  -                    writer.close();
  +                if(writer!=null) writer.close();
                   } catch (XMLStreamException e) {
                       logger.error("failed to write xml.");
                   }
               }
           }
  -    }
       
   }
  
  
  
  1.1.2.2   +46 -26    jboss-profiler/java/src/expansion/org/jboss/profiler/exp/view/servlet/Attic/ExecutionPassageDetail.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ExecutionPassageDetail.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-profiler/java/src/expansion/org/jboss/profiler/exp/view/servlet/Attic/ExecutionPassageDetail.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -b -r1.1.2.1 -r1.1.2.2
  --- ExecutionPassageDetail.java	26 Oct 2006 08:58:56 -0000	1.1.2.1
  +++ ExecutionPassageDetail.java	6 Nov 2006 07:36:59 -0000	1.1.2.2
  @@ -68,48 +68,70 @@
       
       private final String DEFAULT_SERVICE_NAME = "jboss.profiler:service=ProfilerService";
       
  -    private final String DEFAULT_HR_CATEGORY = "Http Requests";
  -    private final String DEFAULT_BE_CATEGORY = "Beans";
  -    private final String DEFAULT_DA_CATEGORY = "Data Access";
  +//    private final String DEFAULT_HR_CATEGORY = "Http Requests";
  +//    private final String DEFAULT_BE_CATEGORY = "Beans";
  +//    private final String DEFAULT_DA_CATEGORY = "Data Access";
       
       private static Logger logger = Logger.getLogger(ExecutionPassageDetail.class);
       
       protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
           
  +        // Gets application parameters
           String profilerServiceName = this.getServletContext().getInitParameter("ProfilerServiceName");
           if(profilerServiceName==null) profilerServiceName = DEFAULT_SERVICE_NAME;
  +//        String httpRequestCategory = this.getServletContext().getInitParameter("HttpRequestCategory");
  +//        if(httpRequestCategory==null) httpRequestCategory = DEFAULT_HR_CATEGORY;
  +//        String beansCategory = this.getServletContext().getInitParameter("BeansCategory");
  +//        if(beansCategory==null) beansCategory = DEFAULT_BE_CATEGORY;
  +//        String dataAccessCategory = this.getServletContext().getInitParameter("DataAccessCategory");
  +//        if(dataAccessCategory==null) dataAccessCategory = DEFAULT_DA_CATEGORY;
           
  -        String httpRequestCategory = this.getServletContext().getInitParameter("HttpRequestCategory");
  -        if(httpRequestCategory==null) httpRequestCategory = DEFAULT_HR_CATEGORY;
  -        String beansCategory = this.getServletContext().getInitParameter("BeansCategory");
  -        if(beansCategory==null) beansCategory = DEFAULT_BE_CATEGORY;
  -        String dataAccessCategory = this.getServletContext().getInitParameter("DataAccessCategory");
  -        if(dataAccessCategory==null) dataAccessCategory = DEFAULT_DA_CATEGORY;
  -        
  +        // Gets session attributes
           MetricName metricName = MetricName.REAL_TIME_PASSAGE_DETAIL;
  -        String metricNameInput = request.getParameter("org.jboss.profiler.exp.view.setting.MetricName");
  +        Object metricNameInput = request.getSession().getAttribute(Initializer.RPK_WA_METRIC_NAME);
           if(metricNameInput!=null) {
  -            if(metricNameInput.equals("cpu")) metricName = MetricName.CPU_TIME_PASSAGE_DETAIL;
  -            if(metricNameInput.equals("userCpu")) metricName = MetricName.USER_CPU_TIME_PASSAGE_DETAIL;
  +            metricName = MetricName.valueOf(String.valueOf(metricNameInput));
  +        }
  +        Long fromDate = null;
  +        Object fromDateInput = request.getSession().getAttribute(Initializer.RPK_FROM_DATE);
  +        if(fromDateInput!=null) {
  +            fromDate = Long.valueOf(String.valueOf(fromDateInput));
  +        }
  +        Long toDate = null;
  +        Object toDateInput = request.getSession().getAttribute(Initializer.RPK_TO_DATE);
  +        if(toDateInput!=null) {
  +            toDate = Long.valueOf(String.valueOf(toDateInput));
           }
           
  -        String specifiedCategoriesInput = request.getParameter("org.jboss.profiler.exp.view.request.Categories");
  +        // Gets request parameters
  +        String specifiedCategoriesInput = request.getParameter(Initializer.RPK_CATEGORIES);
           String[] specifiedCategories = null;
           if(specifiedCategoriesInput!=null) specifiedCategories = specifiedCategoriesInput.split(",");
  -        String specifiedThreadIdTemp = request.getParameter("org.jboss.profiler.exp.view.request.ThreadId");
  +        String specifiedThreadIdTemp = request.getParameter(Initializer.RPK_THREAD_ID);
           String specifiedThreadId = null;
           if(specifiedThreadIdTemp!=null) specifiedThreadId = specifiedThreadIdTemp;
  +        String specifiedCaller = request.getParameter(Initializer.RPK_CALLER);
           
  -        String specifiedCaller = request.getParameter("org.jboss.profiler.exp.view.request.Caller");
  -        
  -        // invoke agent to get snapshot of metrics
  -        Object obj = ServiceManager.invokeLocal(profilerServiceName, "snapMetrics");
  +        // Invokes agent to get snapshot of metrics
  +        Object obj = null;
  +        if(fromDate!=null || toDate!=null) {
  +            Object[] parameters = new Object[4];
  +            parameters[0] = ThreadMetric.class.getName();
  +            parameters[1] = new String[]{metricName.name()};
  +            if(fromDate!=null) parameters[2] = fromDate;
  +            else               parameters[2] = new Long(-1);
  +            if(toDate!=null) parameters[3] = toDate;
  +            else             parameters[3] = new Long(-1);
  +            obj = ServiceManager.invokeLocal(profilerServiceName, "snapMetrics", parameters);
  +        }else {
  +            obj = ServiceManager.invokeLocal(profilerServiceName, "snapMetrics");
  +        }
           if(obj==null) {
               logger.error("failed to snap the metrics data.");
           }
           Map metricsMap = (Map)obj;
           
  -        // write xml
  +        // Writes xml to response
           response.setContentType("text/plain; charset=UTF-8");
           XMLOutputFactory factory = XMLOutputFactory.newInstance();
           factory.setProperty(XMLOutputFactory.INDENTATION, "  ");
  @@ -136,15 +158,13 @@
           } catch (XMLStreamException e) {
               logger.error("failed to write xml.");
           } finally {
  -            if(writer!=null) {
                   try {
  -                    writer.close();
  +                if(writer!=null) writer.close();
                   } catch (XMLStreamException e) {
                       logger.error("failed to write xml.");
                   }
               }
           }
  -    }
       
       private void writeRecord(XMLStreamWriter writer, Map operationMap, Object threadId, MetricName metricName, String caller) throws XMLStreamException {
           EnumMap mmap = (EnumMap)operationMap.get(threadId);
  
  
  



More information about the jboss-cvs-commits mailing list