PageRenderTime 54ms CodeModel.GetById 16ms RepoModel.GetById 7ms app.codeStats 0ms

/jboss-as-7.1.1.Final/modcluster/src/main/java/org/jboss/as/modcluster/LoadMetricEnum.java

#
Java | 74 lines | 41 code | 8 blank | 25 comment | 2 complexity | d25e033b04eacf0a749a30e79e5912a6 MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0
  1. /*
  2. * JBoss, Home of Professional Open Source
  3. * Copyright 2012, Red Hat Inc., and individual contributors as indicated
  4. * by the @authors tag. See the copyright.txt in the distribution for a
  5. * full listing of individual contributors.
  6. *
  7. * This is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU Lesser General Public License as
  9. * published by the Free Software Foundation; either version 2.1 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This software is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with this software; if not, write to the Free
  19. * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  20. * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  21. */
  22. package org.jboss.as.modcluster;
  23. import org.jboss.modcluster.load.metric.LoadMetric;
  24. import org.jboss.modcluster.load.metric.impl.ActiveSessionsLoadMetric;
  25. import org.jboss.modcluster.load.metric.impl.AverageSystemLoadMetric;
  26. import org.jboss.modcluster.load.metric.impl.BusyConnectorsLoadMetric;
  27. import org.jboss.modcluster.load.metric.impl.HeapMemoryUsageLoadMetric;
  28. import org.jboss.modcluster.load.metric.impl.ReceiveTrafficLoadMetric;
  29. import org.jboss.modcluster.load.metric.impl.RequestCountLoadMetric;
  30. import org.jboss.modcluster.load.metric.impl.SendTrafficLoadMetric;
  31. import org.jboss.modcluster.load.metric.impl.SystemMemoryUsageLoadMetric;
  32. /**
  33. * Enumeration of mod_cluster load metrics.
  34. * @author Paul Ferraro
  35. */
  36. public enum LoadMetricEnum {
  37. CPU("cpu", AverageSystemLoadMetric.class),
  38. SYSTEM_MEMORY("mem", SystemMemoryUsageLoadMetric.class),
  39. HEAP_MEMORY("heap", HeapMemoryUsageLoadMetric.class),
  40. ACTIVE_SESSIONS("sessions", ActiveSessionsLoadMetric.class),
  41. RECEIVE_TRAFFIC("receive-traffic", ReceiveTrafficLoadMetric.class),
  42. SEND_TRAFFIC("send-traffic", SendTrafficLoadMetric.class),
  43. REQUEST_COUNT("requests", RequestCountLoadMetric.class),
  44. BUSY_CONNECTORS("busyness", BusyConnectorsLoadMetric.class),
  45. ;
  46. private final String type;
  47. private final Class<? extends LoadMetric> loadMetricClass;
  48. private LoadMetricEnum(String type, Class<? extends LoadMetric> loadMetricClass) {
  49. this.type = type;
  50. this.loadMetricClass = loadMetricClass;
  51. }
  52. public String getType() {
  53. return this.type;
  54. }
  55. public Class<? extends LoadMetric> getLoadMetricClass() {
  56. return this.loadMetricClass;
  57. }
  58. public static LoadMetricEnum forType(String type) {
  59. for (LoadMetricEnum metric: LoadMetricEnum.values()) {
  60. if (metric.type.equals(type)) {
  61. return metric;
  62. }
  63. }
  64. return null;
  65. }
  66. }