001/*
002 *  This file is part of the Jikes RVM project (http://jikesrvm.org).
003 *
004 *  This file is licensed to You under the Eclipse Public License (EPL);
005 *  You may not use this file except in compliance with the License. You
006 *  may obtain a copy of the License at
007 *
008 *      http://www.opensource.org/licenses/eclipse-1.0.php
009 *
010 *  See the COPYRIGHT.txt file distributed with this work for information
011 *  regarding copyright ownership.
012 */
013package gnu.java.lang.management;
014
015import java.lang.management.MemoryType;
016import java.lang.management.MemoryUsage;
017
018import org.jikesrvm.mm.mminterface.JMXSupport;
019import org.jikesrvm.util.UnimplementedError;
020
021/**
022 * NOTE: Features related to memory usage are currently not implemented.
023 */
024public final class VMMemoryPoolMXBeanImpl {
025
026  /**
027   * Retrieves a list of names for all the pools.
028   *
029   * @return a list of names of the pools.
030   */
031  public static String[] getPoolNames() {
032    return JMXSupport.getPoolNames();
033  }
034
035  /**
036   * Collection usage refers to memory usage within the specified pool
037   * after a garbage collection run.  We currently do no support
038   * this feature and so return <code>null</code>.
039   *
040   * @param name the name of the pool whose usage should be returned.
041   * @return <code>null</code>.
042   */
043  static MemoryUsage getCollectionUsage(String name) {
044    return null;
045  }
046
047  /**
048   * Returns the current threshold level for collection usage on the
049   * specified pool.  This is never called as we don't set the appropriate
050   * property.
051   *
052   * @param name the name of the pool whose usage threshold should be returned.
053   * @return the threshold level.
054   */
055  static long getCollectionUsageThreshold(String name) {
056    throw new UnimplementedError();
057  }
058
059  /**
060   * Returns the number of times the threshold level for collection usage
061   * has been met or exceeded for the specified pool.  This is never called
062   * as we don't set the appropriate property.
063   *
064   * @param name the name of the pool whose usage threshold count should be returned.
065   * @return the number of times the threshold level.
066   */
067  static long getCollectionUsageThresholdCount(String name) {
068    throw new UnimplementedError();
069  }
070
071  /**
072   * Returns the name of the memory manager which manages
073   * the specified pool.  All our pools are managed by our
074   * single memory manager (the active MMTk plan) and so we
075   * just return the name of that, regardless of the pool
076   * given.
077   *
078   * @param name the name of the pool whose memory managers should
079   *             be returned.
080   * @return the name of the active plan.
081   */
082  static String[] getMemoryManagerNames(String name) {
083   return JMXSupport.getMemoryManagerNames(name);
084  }
085
086  /**
087   * Returns the peak usage of the specified pool.
088   *
089   * @param name the name of the pool whose peak usage should be returned.
090   * @return the peak memory usage.
091   */
092  static MemoryUsage getPeakUsage(String name) {
093    throw new UnimplementedError();
094  }
095
096  /**
097   * Returns the type of the specified pool, which can be
098   * either "HEAP" or "NON_HEAP".  We consider immortal spaces
099   * to be non-heap allocated and all others to be from the heap
100   * (as objects can be both created and removed from them).
101   *
102   * @param name the name of the pool whose peak usage should be returned.
103   * @return the type of the memory pool.
104   */
105  static MemoryType getType(String name) {
106    return JMXSupport.getType(name);
107  }
108
109  /**
110   * Returns the memory usage of the specified pool.  The total
111   * memory is considered to be the size of the extent of the pool,
112   * while the used and committed sizes refer to the reserved and
113   * committed pages respectively.  All sizes are in bytes and the initial
114   * size is assumed to be zero.
115   *
116   * @param name the name of the pool whose usage should be returned.
117   * @return the usage of the specified pool.
118   */
119  static MemoryUsage getUsage(String name) {
120    return JMXSupport.getUsage(name);
121  }
122
123  /**
124   * Returns the current threshold level for usage on the
125   * specified pool.  This is never called as we don't set the appropriate
126   * property.
127   *
128   * @param name the name of the pool whose usage threshold should be returned.
129   * @return the threshold level.
130   */
131  static long getUsageThreshold(String name) {
132    throw new UnimplementedError();
133  }
134
135  /**
136   * Returns the number of times the threshold level for usage has been
137   * met or exceeded for the specified pool.  This is never called
138   * as we don't set the appropriate property.
139   *
140   * @param name the name of the pool whose usage threshold count should be returned.
141   * @return the number of times the threshold level.
142   */
143  static long getUsageThresholdCount(String name) {
144    throw new UnimplementedError();
145  }
146
147  /**
148   * We simply assume a pool is valid if it is in the list of pool names
149   * we maintain.
150   *
151   * @param name the pool whose validity should be checked.
152   * @return true if the pool is valid.
153   */
154  static boolean isValid(String name) {
155    return JMXSupport.isValid(name);
156  }
157
158  /**
159   * Resets the current peak usage value to the current usage.
160   */
161  static void resetPeakUsage() {
162    throw new UnimplementedError();
163  }
164
165  /**
166   * Sets the threshold level for collection usage.  This method
167   * is never called as we don't set the appropriate property.
168   *
169   * @param name the name of the pool whose threshold should be set.
170   * @param threshold the new threshold value.
171   */
172  static void setCollectionUsageThreshold(String name, long threshold) {
173    throw new UnimplementedError();
174  }
175
176  /**
177   * Sets the threshold level for memory usage.  This method
178   * is never called as we don't set the appropriate property.
179   *
180   * @param name the name of the pool whose threshold should be set.
181   * @param threshold the new threshold value.
182   */
183  static void setUsageThreshold(String name, long threshold) {
184    throw new UnimplementedError();
185  }
186
187}