View Javadoc
1   /*
2    * Licensed under the GPL License. You may not use this file except in compliance with the License.
3    * You may obtain a copy of the License at
4    *
5    *   https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
6    *
7    * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
8    * WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
9    * PURPOSE.
10   */
11  package psiprobe.controllers.cluster;
12  
13  import jakarta.inject.Inject;
14  import jakarta.servlet.http.HttpServletRequest;
15  import jakarta.servlet.http.HttpServletResponse;
16  
17  import org.springframework.web.servlet.ModelAndView;
18  
19  import psiprobe.TomcatContainer;
20  import psiprobe.beans.ClusterWrapperBean;
21  import psiprobe.controllers.AbstractTomcatContainerController;
22  import psiprobe.model.jmx.Cluster;
23  
24  /**
25   * The Class BaseClusterStatsController.
26   */
27  public class BaseClusterStatsController extends AbstractTomcatContainerController {
28  
29    /** The cluster wrapper. */
30    @Inject
31    private ClusterWrapperBean clusterWrapper;
32  
33    /** The load members. */
34    private boolean loadMembers = true;
35  
36    /** The collection period. */
37    private long collectionPeriod;
38  
39    /**
40     * Checks if is load members.
41     *
42     * @return true, if is load members
43     */
44    public boolean isLoadMembers() {
45      return loadMembers;
46    }
47  
48    /**
49     * Sets the load members.
50     *
51     * @param loadMembers the new load members
52     */
53    public void setLoadMembers(boolean loadMembers) {
54      this.loadMembers = loadMembers;
55    }
56  
57    /**
58     * Gets the collection period.
59     *
60     * @return the collection period
61     */
62    public long getCollectionPeriod() {
63      return collectionPeriod;
64    }
65  
66    /**
67     * Sets the collection period.
68     *
69     * @param collectionPeriod the new collection period
70     */
71    public void setCollectionPeriod(long collectionPeriod) {
72      this.collectionPeriod = collectionPeriod;
73    }
74  
75    @Override
76    protected ModelAndView handleRequestInternal(HttpServletRequest request,
77        HttpServletResponse response) throws Exception {
78  
79      TomcatContainer container = containerWrapper.getTomcatContainer();
80      Cluster cluster =
81          clusterWrapper.getCluster(container.getName(), container.getHostName(), isLoadMembers());
82      return new ModelAndView(getViewName()).addObject("cluster", cluster)
83          .addObject("collectionPeriod", getCollectionPeriod());
84    }
85  
86  }