dpillot     2005/12/09 12:24:56 CET

  Modified files:
    core/src/java/org/jahia/ajax/monitors PDisplayAction.java 
  Log:
  added running info
  
  Revision  Changes    Path
  1.3       +46 -42    
jahia/core/src/java/org/jahia/ajax/monitors/PDisplayAction.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/java/org/jahia/ajax/monitors/PDisplayAction.java.diff?r1=1.2&r2=1.3&f=h
  
  
  
  Index: PDisplayAction.java
  ===================================================================
  RCS file: 
/home/cvs/repository/jahia/core/src/java/org/jahia/ajax/monitors/PDisplayAction.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- PDisplayAction.java       9 Dec 2005 10:26:27 -0000       1.2
  +++ PDisplayAction.java       9 Dec 2005 11:24:55 -0000       1.3
  @@ -24,11 +24,11 @@
   /**
    * Process Display Action.
    * this ajax action class return a count of processes waiting in the pool<br>
  - * (the better approximation we have for now of the "charge" of process 
server).
  - *
  + * and an indication of concurrent threads currently running to execute the 
jobs scheduled in the pool.<br>
  + * (the better approximation we have for now of the "working charge" of 
process server).
    *
    * @author joepi
  - * @version $Id: PDisplayAction.java,v 1.2 2005/12/09 10:26:27 xlawrence Exp 
$
  + * @version $Id: PDisplayAction.java,v 1.3 2005/12/09 11:24:55 dpillot Exp $
    */
   public class PDisplayAction extends AjaxAction {
   
  @@ -50,40 +50,41 @@
        */
       public ActionForward execute(final ActionMapping mapping, final 
ActionForm form, final HttpServletRequest request, final HttpServletResponse 
response) throws IOException, ServletException {
   
  -        boolean isRoot=false;// user have right to access to server process
  -        boolean isSiteAdmin=false;// user have right to access to site 
process
  -        List process;//process list
  +        boolean isRoot = false;// user have right to access to all server 
process
  +        boolean isSiteAdmin = false;// user have right to access to site 
process
  +        List process;//process (jobdetails) list
           try {
   
  -            final JahiaUser currentUser = 
(JahiaUser)request.getSession().getAttribute(ParamBean.SESSION_USER);
  +            final JahiaUser currentUser = (JahiaUser) 
request.getSession().getAttribute(ParamBean.SESSION_USER);
               final JahiaSite site = (JahiaSite) 
request.getSession().getAttribute("org.jahia.services.sites.jahiasite");
   
  -            if (currentUser == null || site == null || !currentUser.isRoot() 
|| !currentUser.isAdminMember(site.getID())){
  +            if (currentUser == null || site == null || !currentUser.isRoot() 
|| !currentUser.isAdminMember(site.getID())) {
                   logger.warn("Unauthorized attempt to use AJAX Struts Action 
- Process display");
                   response.sendError(HttpServletResponse.SC_FORBIDDEN,
                           "Error: Must be logged in and have 'Admin' access");
                   return null;
               }
   
  -            if(currentUser.isRoot()) {
  -                isRoot=true;
  -                logger.debug("welcome root user");
  -                process =getAllProcess();
  -            } else if(currentUser.isAdminMember(site.getID())) {
  -                isSiteAdmin=true;
  -                logger.debug("you are siteadmin on site "+site.getID());
  -                process =getSiteProcessList(site.getSiteKey());
  +            if (currentUser.isRoot()) {
  +                isRoot = true;
  +                process = getAllProcess();
  +            } else if (currentUser.isAdminMember(site.getID())) {
  +                isSiteAdmin = true;
  +                process = getSiteProcessList(site.getSiteKey());
               } else {
                   process = getUserProcessList(currentUser);
               }
  +            // concurrent threads running
  +            int threadCount = service.getCurrentlyExecutingJobs().size();
   
  -            final Vector tagnames = new Vector ();
  -            final Vector tagvals = new Vector();
  -            tagnames.addElement("count");
  -            tagvals.addElement(""+process.size());
  -
  +            final List tagnames = new Vector();
  +            final List tagvals = new Vector();
  +            tagnames.add("count");
  +            tagvals.add("" + process.size());
  +            tagnames.add("running");
  +            tagvals.add("" + threadCount);
   
  -            sendResponse(tagnames,tagvals,response);
  +            sendResponse(tagnames, tagvals, response);
   
   
           } catch (Exception e) {
  @@ -97,16 +98,17 @@
   
       /**
        * to get all process names
  +     *
        * @return a list of jobdetails
        * @throws JahiaException
        */
       private List getAllProcess() throws JahiaException {
  -        String[] process=service.getJobNames(Scheduler.DEFAULT_GROUP);
  +        String[] process = service.getJobNames(Scheduler.DEFAULT_GROUP);
   
  -        List list=new Vector();
  -        if(process.length==0) return list;
  -        for(int n=0;n<process.length;n++){
  -            org.quartz.JobDetail jd =service.getJobDetail(process[n], 
Scheduler.DEFAULT_GROUP);
  +        List list = new Vector();
  +        if (process.length == 0) return list;
  +        for (int n = 0; n < process.length; n++) {
  +            org.quartz.JobDetail jd = service.getJobDetail(process[n], 
Scheduler.DEFAULT_GROUP);
               list.add(jd);
           }
           return list;
  @@ -114,25 +116,26 @@
   
       /**
        * to get only Site Process
  +     *
        * @param sitekey
        * @return a list containing only jobdetails on the site
        */
  -    private List getSiteProcessList(String sitekey){
  +    private List getSiteProcessList(String sitekey) {
           List all;
  -        List list=new Vector();
  +        List list = new Vector();
           try {
               all = getAllProcess();
           } catch (JahiaException e) {
               logger.error(e);
               return list;
           }
  -        if(all==null || all.isEmpty()) return list;
  +        if (all == null || all.isEmpty()) return list;
   
  -        for(Iterator it=all.iterator();it.hasNext();){
  -            org.quartz.JobDetail jd= (org.quartz.JobDetail) it.next();
  +        for (Iterator it = all.iterator(); it.hasNext();) {
  +            org.quartz.JobDetail jd = (org.quartz.JobDetail) it.next();
   
               org.quartz.JobDataMap data = jd.getJobDataMap();
  -            if(data.get("sitekey")!=null 
&&((String)data.get("sitekey")).equalsIgnoreCase(sitekey)){
  +            if (data.get("sitekey") != null && ((String) 
data.get("sitekey")).equalsIgnoreCase(sitekey)) {
                   list.add(jd);
               }
           }
  @@ -141,32 +144,36 @@
   
       /**
        * to get only User process
  +     *
        * @param user
        * @return a list containing only jobdetails for current user
        */
  -    private List getUserProcessList(JahiaUser user){
  +    private List getUserProcessList(JahiaUser user) {
           List all;
  -        List list=new Vector();
  +        List list = new Vector();
           try {
               all = getAllProcess();
           } catch (JahiaException e) {
               logger.error(e);
               return list;
           }
  -        if(all==null || all.isEmpty()) return list;
  +        if (all == null || all.isEmpty()) return list;
   
  -        for(Iterator it=all.iterator();it.hasNext();){
  -           org.quartz.JobDetail jd= (org.quartz.JobDetail) it.next();
  +        for (Iterator it = all.iterator(); it.hasNext();) {
  +            org.quartz.JobDetail jd = (org.quartz.JobDetail) it.next();
               org.quartz.JobDataMap data = jd.getJobDataMap();
  -            if(data.get("userkey")!=null 
&&((String)data.get("userkey")).equalsIgnoreCase(user.getUserKey())){
  -               list.add(jd);
  +            if (data.get("userkey") != null && ((String) 
data.get("userkey")).equalsIgnoreCase(user.getUserKey())) {
  +                list.add(jd);
               }
           }
           return list;
       }
   
  -    private SchedulerService service= 
ServicesRegistry.getInstance().getSchedulerService();
  +    private SchedulerService service = 
ServicesRegistry.getInstance().getSchedulerService();
   }
   /**
  - *$Log $
  + * $Log: PDisplayAction.java,v $
  + * Revision 1.3  2005/12/09 11:24:55  dpillot
  + * added running info
  + *
    */
  \ No newline at end of file
  

Reply via email to