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.model.jmx;
12  
13  import java.util.Locale;
14  
15  /**
16   * The Class MemoryPool.
17   */
18  public class MemoryPool {
19  
20    /** The name. */
21    private String name;
22  
23    /** The init. */
24    private long init;
25  
26    /** The max. */
27    private long max;
28  
29    /** The used. */
30    private long used;
31  
32    /** The committed. */
33    private long committed;
34  
35    /** The type. */
36    private String type;
37  
38    /** The id. */
39    private String id;
40  
41    /**
42     * Gets the name.
43     *
44     * @return the name
45     */
46    public String getName() {
47      return name;
48    }
49  
50    /**
51     * Sets the name.
52     *
53     * @param name the new name
54     */
55    public void setName(String name) {
56      this.name = name;
57      this.id = name != null ? name.replace(' ', '_').toLowerCase(Locale.ENGLISH) : null;
58    }
59  
60    /**
61     * Gets the inits the.
62     *
63     * @return the inits the
64     */
65    public long getInit() {
66      return init;
67    }
68  
69    /**
70     * Sets the inits the.
71     *
72     * @param init the new inits the
73     */
74    public void setInit(long init) {
75      this.init = init;
76    }
77  
78    /**
79     * Gets the max.
80     *
81     * @return the max
82     */
83    public long getMax() {
84      return max;
85    }
86  
87    /**
88     * Sets the max.
89     *
90     * @param max the new max
91     */
92    public void setMax(long max) {
93      this.max = max;
94    }
95  
96    /**
97     * Gets the used.
98     *
99     * @return the used
100    */
101   public long getUsed() {
102     return used;
103   }
104 
105   /**
106    * Sets the used.
107    *
108    * @param used the new used
109    */
110   public void setUsed(long used) {
111     this.used = used;
112   }
113 
114   /**
115    * Gets the committed.
116    *
117    * @return the committed
118    */
119   public long getCommitted() {
120     return committed;
121   }
122 
123   /**
124    * Sets the committed.
125    *
126    * @param committed the new committed
127    */
128   public void setCommitted(long committed) {
129     this.committed = committed;
130   }
131 
132   /**
133    * Gets the type.
134    *
135    * @return the type
136    */
137   public String getType() {
138     return type;
139   }
140 
141   /**
142    * Sets the type.
143    *
144    * @param type the new type
145    */
146   public void setType(String type) {
147     this.type = type;
148   }
149 
150   /**
151    * Gets the usage score.
152    *
153    * @return the usage score
154    */
155   public int getUsageScore() {
156     long div;
157     if (max == -1) {
158       /*
159        * Some memory pools have an undefined maximum size. In this case, report how much of the
160        * currently allocated memory is used.
161        */
162       div = committed;
163     } else {
164       div = max;
165     }
166     return div == 0 ? 0 : (int) (used * 100 / div);
167   }
168 
169   /**
170    * Gets the id.
171    *
172    * @return the id
173    */
174   public String getId() {
175     return id;
176   }
177 
178 }