PageRenderTime 31ms CodeModel.GetById 22ms app.highlight 6ms RepoModel.GetById 1ms 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 */
22package org.jboss.as.modcluster;
23
24import org.jboss.modcluster.load.metric.LoadMetric;
25import org.jboss.modcluster.load.metric.impl.ActiveSessionsLoadMetric;
26import org.jboss.modcluster.load.metric.impl.AverageSystemLoadMetric;
27import org.jboss.modcluster.load.metric.impl.BusyConnectorsLoadMetric;
28import org.jboss.modcluster.load.metric.impl.HeapMemoryUsageLoadMetric;
29import org.jboss.modcluster.load.metric.impl.ReceiveTrafficLoadMetric;
30import org.jboss.modcluster.load.metric.impl.RequestCountLoadMetric;
31import org.jboss.modcluster.load.metric.impl.SendTrafficLoadMetric;
32import org.jboss.modcluster.load.metric.impl.SystemMemoryUsageLoadMetric;
33
34/**
35 * Enumeration of mod_cluster load metrics.
36 * @author Paul Ferraro
37 */
38public enum LoadMetricEnum {
39
40    CPU("cpu", AverageSystemLoadMetric.class),
41    SYSTEM_MEMORY("mem", SystemMemoryUsageLoadMetric.class),
42    HEAP_MEMORY("heap", HeapMemoryUsageLoadMetric.class),
43    ACTIVE_SESSIONS("sessions", ActiveSessionsLoadMetric.class),
44    RECEIVE_TRAFFIC("receive-traffic", ReceiveTrafficLoadMetric.class),
45    SEND_TRAFFIC("send-traffic", SendTrafficLoadMetric.class),
46    REQUEST_COUNT("requests", RequestCountLoadMetric.class),
47    BUSY_CONNECTORS("busyness", BusyConnectorsLoadMetric.class),
48    ;
49
50    private final String type;
51    private final Class<? extends LoadMetric> loadMetricClass;
52
53    private LoadMetricEnum(String type, Class<? extends LoadMetric> loadMetricClass) {
54        this.type = type;
55        this.loadMetricClass = loadMetricClass;
56    }
57
58    public String getType() {
59        return this.type;
60    }
61
62    public Class<? extends LoadMetric> getLoadMetricClass() {
63        return this.loadMetricClass;
64    }
65
66    public static LoadMetricEnum forType(String type) {
67        for (LoadMetricEnum metric: LoadMetricEnum.values()) {
68            if (metric.type.equals(type)) {
69                return metric;
70            }
71        }
72        return null;
73    }
74}