JBoss Native SVN: r1994 - trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/impl.
by jbossnative-commits@lists.jboss.org
Author: pferraro
Date: 2008-10-23 11:34:18 -0400 (Thu, 23 Oct 2008)
New Revision: 1994
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/impl/DefaultMCMPHandler.java
Log:
Fixed regression in sendRequest()
Modified: trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/impl/DefaultMCMPHandler.java
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/impl/DefaultMCMPHandler.java 2008-10-23 13:30:41 UTC (rev 1993)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/impl/DefaultMCMPHandler.java 2008-10-23 15:34:18 UTC (rev 1994)
@@ -459,7 +459,11 @@
{
Map<String, ResetRequestSource.EngineStatus> parsedResponse = this.parseInfoResponse(response);
- this.sendRequests(this.resetRequestSource.getResetRequests(parsedResponse));
+ List<MCMPRequest> requests = this.resetRequestSource.getResetRequests(parsedResponse);
+
+ log.trace(requests);
+
+ this.sendRequests(requests);
}
}
}
@@ -475,6 +479,8 @@
{
if (response == null) return Collections.emptyMap();
+ log.trace(response);
+
Map<String, ResetRequestSource.EngineStatus> result = new HashMap<String, ResetRequestSource.EngineStatus>();
ResetRequestSource.EngineStatus engineStatus = null;
@@ -558,6 +564,8 @@
}
}
+ log.trace(result);
+
return result;
}
@@ -735,14 +743,17 @@
}
builder.append(" HTTP/1.0");
-
+
writer.write(builder.toString());
writer.write("\r\n");
- writer.write("Content-Length: " + encoder.getLength() + "\r\n");
+
+ int length = encoder.getLength();
+
+ writer.write("Content-Length: " + length + "\r\n");
writer.write("User-Agent: ClusterListener/1.0\r\n");
writer.write("Connection: Keep-Alive\r\n");
writer.write("\r\n");
- writer.write(encoder.getBuffer());
+ writer.write(encoder.getBuffer(), 0, length);
writer.write("\r\n");
writer.flush();
15 years, 11 months
JBoss Native SVN: r1993 - trunk/mod_cluster/native/mod_proxy_cluster.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2008-10-23 09:30:41 -0400 (Thu, 23 Oct 2008)
New Revision: 1993
Modified:
trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c
Log:
Skip node if we can't read the information in slotmem.
Modified: trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c
===================================================================
--- trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c 2008-10-23 13:18:58 UTC (rev 1992)
+++ trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c 2008-10-23 13:30:41 UTC (rev 1993)
@@ -354,7 +354,8 @@
/* Only process the nodes that have been updated since our last update */
for (i=0; i<size; i++) {
nodeinfo_t *ou;
- node_storage->read_node(id[i], &ou);
+ if (node_storage->read_node(id[i], &ou) != APR_SUCCESS)
+ continue;
if (ou->updatetime >= last) {
/* The node has changed */
if (ou->mess.remove)
15 years, 11 months
JBoss Native SVN: r1992 - trunk/mod_cluster/native/mod_proxy_cluster.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2008-10-23 09:18:58 -0400 (Thu, 23 Oct 2008)
New Revision: 1992
Modified:
trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c
Log:
Use the information read in the trans().
Modified: trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c
===================================================================
--- trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c 2008-10-23 08:56:12 UTC (rev 1991)
+++ trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c 2008-10-23 13:18:58 UTC (rev 1992)
@@ -777,7 +777,7 @@
* We also try the domain.
*/
static proxy_worker *internal_find_best_byrequests(proxy_balancer *balancer,
- request_rec *r, char *domain, int failoverdomain)
+ request_rec *r, const char *domain, int failoverdomain)
{
int i;
proxy_worker *worker;
@@ -1279,6 +1279,7 @@
"cluster: Found balancer %s for %s", ou->mess.balancer, route);
/* here we have the route and domain for find_session_route ... */
apr_table_setn(r->notes, "CLUSTER_ROUTE", route);
+ apr_table_setn(r->notes, "CLUSTER_STICKY_USED", sticky_used);
if (ou->mess.Domain[0] != '\0') {
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
"cluster: Found domain %s for %s", ou->mess.Domain, route);
@@ -1410,10 +1411,10 @@
*/
static proxy_worker *find_session_route(proxy_balancer *balancer,
request_rec *r,
- char **route,
- char **sticky_used,
+ const char **route,
+ const char **sticky_used,
char **url,
- char **domain)
+ const char **domain)
{
proxy_worker *worker = NULL;
char *sticky, *sticky_path, *path;
@@ -1423,59 +1424,38 @@
if (! (balancer->sticky_force & STSESSION))
return NULL;
- *route = get_route(r, balancer->sticky, *url, sticky_used);
- if (*route) {
+ /* We already should have the route in the notes for the trans() */
+ *route = apr_table_get(r->notes, "CLUSTER_ROUTE");
+ if (*route && (**route)) {
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
- "proxy: CLUSTER: Found value %s for "
- "stickysession %s", *route, balancer->sticky);
- }
+ "cluster: Using route %s", *route);
+ } else
+ return NULL;
- /*
- * If we found a value for sticksession, find the first '.' within.
- * Everything after '.' (if present) is our route.
+ *sticky_used = apr_table_get(r->notes, "CLUSTER_STICKY_USED");
+
+ if (domain)
+ *domain = apr_table_get(r->notes, "CLUSTER_DOMAIN");
+
+ /* We have a route in path or in cookie
+ * Find the worker that has this route defined.
*/
- if ((*route) && ((*route = strchr(*route, '.')) != NULL ))
- (*route)++;
- if ((*route) && (**route)) {
- nodeinfo_t *ou;
- apr_status_t rv;
- ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
- "proxy: CLUSTER: Found route %s", *route);
- /* Read the domain in case we have to make a failover */
- rv = node_storage->find_node(&ou, *route);
- if (rv == APR_SUCCESS) {
- if (ou->mess.Domain[0] != '\0') {
- ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
- "proxy: Found domain %s for %s", ou->mess.Domain, *route);
- if (domain)
- *domain = ou->mess.Domain;
- } else {
- if (domain)
- *domain = NULL;
- }
- }
- /* We have a route in path or in cookie
- * Find the worker that has this route defined.
+ worker = find_route_worker(r, balancer, *route);
+ if (worker && strcmp(*route, worker->s->route)) {
+ /*
+ * Notice that the route of the worker chosen is different from
+ * the route supplied by the client. (mod_proxy compatibility).
*/
- worker = find_route_worker(r, balancer, *route);
- if (worker && strcmp(*route, worker->s->route)) {
- /*
- * Notice that the route of the worker chosen is different from
- * the route supplied by the client. (mod_proxy compatibility).
- */
- apr_table_setn(r->subprocess_env, "BALANCER_ROUTE_CHANGED", "1");
- ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
- "proxy: CLUSTER: Route changed from %s to %s",
- *route, worker->s->route);
- }
- return worker;
+ apr_table_setn(r->subprocess_env, "BALANCER_ROUTE_CHANGED", "1");
+ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
+ "proxy: CLUSTER: Route changed from %s to %s",
+ *route, worker->s->route);
}
- else
- return NULL;
+ return worker;
}
static proxy_worker *find_best_worker(proxy_balancer *balancer,
- request_rec *r, char *domain, int failoverdomain)
+ request_rec *r, const char *domain, int failoverdomain)
{
proxy_worker *candidate = NULL;
apr_status_t rv;
@@ -1638,9 +1618,9 @@
{
int access_status;
proxy_worker *runtime;
- char *route = NULL;
- char *sticky = NULL;
- char *domain = NULL;
+ const char *route = NULL;
+ const char *sticky = NULL;
+ const char *domain = NULL;
int failoverdomain = 0;
apr_status_t rv;
15 years, 11 months
JBoss Native SVN: r1991 - trunk/mod_cluster/native/mod_proxy_cluster.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2008-10-23 04:56:12 -0400 (Thu, 23 Oct 2008)
New Revision: 1991
Modified:
trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c
Log:
Remove the cluster:// from the name.
Modified: trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c
===================================================================
--- trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c 2008-10-23 07:25:10 UTC (rev 1990)
+++ trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c 2008-10-23 08:56:12 UTC (rev 1991)
@@ -1274,15 +1274,17 @@
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
"cluster: Found route %s", route);
if (node_storage->find_node(&ou, route) == APR_SUCCESS) {
- if (!strcmp(balancer->name, ou->mess.balancer)) {
- /* here we have the route and domain for find_session_route ... */
- apr_table_setn(r->notes, "CLUSTER_ROUTE", route);
- if (ou->mess.Domain[0] != '\0') {
+ if (strlen(balancer->name)>10 && !strcmp(&balancer->name[10], ou->mess.balancer)) {
+ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
+ "cluster: Found balancer %s for %s", ou->mess.balancer, route);
+ /* here we have the route and domain for find_session_route ... */
+ apr_table_setn(r->notes, "CLUSTER_ROUTE", route);
+ if (ou->mess.Domain[0] != '\0') {
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
"cluster: Found domain %s for %s", ou->mess.Domain, route);
apr_table_setn(r->notes, "CLUSTER_DOMAIN", ou->mess.Domain);
- }
- return balancer->name;
+ }
+ return &balancer->name[10];
}
}
}
15 years, 11 months
JBoss Native SVN: r1990 - trunk/mod_cluster/native/mod_proxy_cluster.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2008-10-23 03:25:10 -0400 (Thu, 23 Oct 2008)
New Revision: 1990
Modified:
trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c
Log:
Should be debug only...
Modified: trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c
===================================================================
--- trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c 2008-10-23 05:16:30 UTC (rev 1989)
+++ trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c 2008-10-23 07:25:10 UTC (rev 1990)
@@ -203,7 +203,7 @@
/* Create one */
int sizebal, i;
int *bal;
- ap_log_error(APLOG_MARK, APLOG_NOTICE|APLOG_NOERRNO, 0, server,
+ ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, server,
"add_workers_node: Create balancer %s", name);
balancer = apr_array_push(conf->balancers);
memset(balancer, 0, sizeof(proxy_balancer));
15 years, 11 months
JBoss Native SVN: r1989 - in trunk/mod_cluster/src: main/java/org/jboss/modcluster/load/metric and 4 other directories.
by jbossnative-commits@lists.jboss.org
Author: pferraro
Date: 2008-10-23 01:16:30 -0400 (Thu, 23 Oct 2008)
New Revision: 1989
Added:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/SelfSourcedLoadMetric.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/SourcedLoadMetric.java
Removed:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/AbstractLoadMetricSource.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/SingleLoadMetricSource.java
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/impl/DynamicLoadBalanceFactorProvider.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/LoadMetric.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/LoadMetricSource.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/AbstractLoadMetric.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/ActiveSessionsLoadMetric.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/AverageSystemLoadMetric.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/BusyConnectorsLoadMetric.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/ConnectionPoolLoadMetricSource.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/ConnectionPoolUsageLoadMetric.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/HeapMemoryUsageLoadMetric.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/MBeanAttributeLoadMetric.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/MBeanAttributeRatioLoadMetric.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/MBeanLoadMetricSource.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/MBeanQueryLoadMetricSource.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/OperatingSystemLoadMetricSource.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/ReceiveTrafficLoadMetric.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/RequestCountLoadMetric.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/RequestProcessorLoadMetricSource.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/SendTrafficLoadMetric.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/SessionLoadMetricSource.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/SystemMemoryUsageLoadMetric.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/ThreadCountLoadMetric.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/ThreadPoolLoadMetricSource.java
trunk/mod_cluster/src/main/resources/mod-cluster-jboss-beans.xml
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/DynamicLoadBalanceFactorProviderTestCase.java
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/ActiveSessionsLoadMetricTestCase.java
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/AverageSystemLoadMetricTestCase.java
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/BusyConnectorsLoadMetricTestCase.java
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/ConnectionPoolLoadMetricSourceTestCase.java
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/ConnectionPoolUsageLoadMetricTestCase.java
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/MBeanAttributeLoadMetricTestCase.java
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/MBeanAttributeRatioLoadMetricTestCase.java
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/MBeanLoadMetricSourceTestCase.java
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/MBeanQueryLoadMetricSourceTestCase.java
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/OperatingSystemLoadMetricSourceTestCase.java
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/ReceiveTrafficLoadMetricTestCase.java
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/RequestCountLoadMetricTestCase.java
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/RequestProcessorLoadMetricSourceTestCase.java
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/SendTrafficLoadMetricTestCase.java
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/SessionLoadMetricSourceTestCase.java
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/SystemMemoryUsageLoadMetricTestCase.java
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/ThreadPoolLoadMetricSourceTestCase.java
Log:
Revert metric -> source relationship.
LoadBalanceFactorProvider now defines explicit load metrics - instead of sources.
Added convenience default constructors to load metrics that will create necessary source instances, instead of injecting.
Modified: trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/impl/DynamicLoadBalanceFactorProvider.java
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/impl/DynamicLoadBalanceFactorProvider.java 2008-10-22 21:44:32 UTC (rev 1988)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/impl/DynamicLoadBalanceFactorProvider.java 2008-10-23 05:16:30 UTC (rev 1989)
@@ -24,8 +24,10 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.apache.catalina.util.StringManager;
import org.jboss.logging.Logger;
@@ -45,15 +47,27 @@
private final Logger log = Logger.getLogger(this.getClass());
private final StringManager sm = StringManager.getManager(Constants.Package);
- private final Collection<LoadMetricSource<LoadContext>> sources;
+ private final Map<LoadMetricSource<LoadContext>, Collection<LoadMetric<LoadContext>>> metrics = new LinkedHashMap<LoadMetricSource<LoadContext>, Collection<LoadMetric<LoadContext>>>();
private final Map<LoadMetric<LoadContext>, List<Double>> loadHistory = new HashMap<LoadMetric<LoadContext>, List<Double>>();
private volatile int decayFactor = 2;
private volatile int history = 10;
- public DynamicLoadBalanceFactorProvider(Collection<LoadMetricSource<LoadContext>> sources)
+ public DynamicLoadBalanceFactorProvider(Set<LoadMetric<LoadContext>> metrics)
{
- this.sources = sources;
+ for (LoadMetric<LoadContext> metric: metrics)
+ {
+ LoadMetricSource<LoadContext> source = metric.getSource();
+ Collection<LoadMetric<LoadContext>> sourceMetrics = this.metrics.get(source);
+
+ if (sourceMetrics == null)
+ {
+ sourceMetrics = new ArrayList<LoadMetric<LoadContext>>();
+ this.metrics.put(source, sourceMetrics);
+ }
+
+ sourceMetrics.add(metric);
+ }
}
/**
@@ -65,43 +79,44 @@
int totalWeight = 0;
double totalWeightedLoad = 0;
- for (LoadMetricSource<LoadContext> source: this.sources)
+ for (Map.Entry<LoadMetricSource<LoadContext>, Collection<LoadMetric<LoadContext>>> entry: this.metrics.entrySet())
{
- Collection<LoadMetric<LoadContext>> metrics = source.getMetrics();
+ LoadMetricSource<LoadContext> source = entry.getKey();
+ Collection<LoadMetric<LoadContext>> metrics = entry.getValue();
- List<LoadMetric<LoadContext>> metricList = new ArrayList<LoadMetric<LoadContext>>(metrics.size());
+ boolean skip = true;
- // Prune 0 weights since they will not contribute anything
+ // Skip this source if all weights are 0
for (LoadMetric<LoadContext> metric: metrics)
{
- if (metric.getWeight() != 0)
- {
- metricList.add(metric);
- }
+ skip = skip && (metric.getWeight() <= 0);
}
- if (!metricList.isEmpty())
+ if (!skip)
{
LoadContext context = source.createContext();
try
{
- for (LoadMetric<LoadContext> metric: metricList)
+ for (LoadMetric<LoadContext> metric: metrics)
{
- try
+ int weight = metric.getWeight();
+
+ if (weight > 0)
{
- // Normalize load with respect to capacity
- List<Double> queue = this.recordLoad(metric, metric.getLoad(context) / metric.getCapacity());
-
- int weight = metric.getWeight();
-
- totalWeight += weight;
- totalWeightedLoad += this.average(queue) * weight;
+ try
+ {
+ // Normalize load with respect to capacity
+ List<Double> queue = this.recordLoad(metric, metric.getLoad(context) / metric.getCapacity());
+
+ totalWeight += weight;
+ totalWeightedLoad += this.average(queue) * weight;
+ }
+ catch (Exception e)
+ {
+ this.log.error(e.getMessage(), e);
+ }
}
- catch (Exception e)
- {
- this.log.error(e.getMessage(), e);
- }
}
}
finally
Modified: trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/LoadMetric.java
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/LoadMetric.java 2008-10-22 21:44:32 UTC (rev 1988)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/LoadMetric.java 2008-10-23 05:16:30 UTC (rev 1989)
@@ -47,4 +47,6 @@
* @throws Exception if there was an error fetching this metric.
*/
double getLoad(C context) throws Exception;
+
+ LoadMetricSource<C> getSource();
}
Modified: trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/LoadMetricSource.java
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/LoadMetricSource.java 2008-10-22 21:44:32 UTC (rev 1988)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/LoadMetricSource.java 2008-10-23 05:16:30 UTC (rev 1989)
@@ -21,7 +21,6 @@
*/
package org.jboss.modcluster.load.metric;
-import java.util.Collection;
/**
* A source for obtaining load metrics.
@@ -30,12 +29,6 @@
public interface LoadMetricSource<C extends LoadContext>
{
/**
- * Returns the collection of metrics registered with this source.
- * @return the metrics from this source
- */
- Collection<LoadMetric<C>> getMetrics();
-
- /**
* Prepare any resources required to collect load metrics
*/
C createContext();
Modified: trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/AbstractLoadMetric.java
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/AbstractLoadMetric.java 2008-10-22 21:44:32 UTC (rev 1988)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/AbstractLoadMetric.java 2008-10-23 05:16:30 UTC (rev 1989)
@@ -34,7 +34,7 @@
{
private volatile int weight = 1;
private volatile double capacity = 1;
-
+
/**
* @{inheritDoc}
* @see org.jboss.modcluster.load.metric.LoadMetric#getWeight()
Deleted: trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/AbstractLoadMetricSource.java
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/AbstractLoadMetricSource.java 2008-10-22 21:44:32 UTC (rev 1988)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/AbstractLoadMetricSource.java 2008-10-23 05:16:30 UTC (rev 1989)
@@ -1,52 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.modcluster.load.metric.impl;
-
-import java.util.Collection;
-
-import org.jboss.modcluster.load.metric.LoadContext;
-import org.jboss.modcluster.load.metric.LoadMetric;
-import org.jboss.modcluster.load.metric.LoadMetricSource;
-
-/**
- * Abstract {@link LoadMetricSource} that allows a {@link LoadMetric} to register with it.
- *
- * @author Paul Ferraro
- */
-public abstract class AbstractLoadMetricSource<C extends LoadContext> implements LoadMetricSource<C>
-{
- private final Collection<LoadMetric<C>> metrics;
-
- protected AbstractLoadMetricSource(Collection<LoadMetric<C>> metrics)
- {
- this.metrics = metrics;
- }
-
- /**
- * @{inheritDoc}
- * @see org.jboss.modcluster.load.metric.LoadMetricSource#getMetrics()
- */
- public Collection<LoadMetric<C>> getMetrics()
- {
- return this.metrics;
- }
-}
Modified: trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/ActiveSessionsLoadMetric.java
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/ActiveSessionsLoadMetric.java 2008-10-22 21:44:32 UTC (rev 1988)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/ActiveSessionsLoadMetric.java 2008-10-23 05:16:30 UTC (rev 1989)
@@ -21,6 +21,8 @@
*/
package org.jboss.modcluster.load.metric.impl;
+import javax.management.MalformedObjectNameException;
+
import org.jboss.modcluster.load.metric.LoadMetric;
/**
@@ -32,13 +34,18 @@
{
public static final String DEFAULT_ATTRIBUTE = "activeSessions";
- public ActiveSessionsLoadMetric()
+ public ActiveSessionsLoadMetric() throws MalformedObjectNameException
{
- this(DEFAULT_ATTRIBUTE);
+ this(new SessionLoadMetricSource());
}
- public ActiveSessionsLoadMetric(String attribute)
+ public ActiveSessionsLoadMetric(SessionLoadMetricSource source)
{
- super(attribute);
+ super(source, DEFAULT_ATTRIBUTE);
}
+
+ public ActiveSessionsLoadMetric(SessionLoadMetricSource source, String attribute)
+ {
+ super(source, attribute);
+ }
}
Modified: trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/AverageSystemLoadMetric.java
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/AverageSystemLoadMetric.java 2008-10-22 21:44:32 UTC (rev 1988)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/AverageSystemLoadMetric.java 2008-10-23 05:16:30 UTC (rev 1989)
@@ -25,6 +25,7 @@
import javax.management.AttributeNotFoundException;
import javax.management.JMException;
+import javax.management.MalformedObjectNameException;
import org.jboss.logging.Logger;
@@ -34,12 +35,22 @@
*
* @author Paul Ferraro
*/
-public class AverageSystemLoadMetric extends AbstractLoadMetric<MBeanLoadContext>
+public class AverageSystemLoadMetric extends SourcedLoadMetric<MBeanLoadContext>
{
public static final String SYSTEM_LOAD_AVERAGE = "SystemLoadAverage";
private Logger logger = Logger.getLogger(this.getClass());
+ public AverageSystemLoadMetric() throws MalformedObjectNameException
+ {
+ super(new OperatingSystemLoadMetricSource());
+ }
+
+ public AverageSystemLoadMetric(OperatingSystemLoadMetricSource source)
+ {
+ super(source);
+ }
+
/**
* @{inheritDoc}
* @see org.jboss.modcluster.load.metric.LoadMetric#getLoad()
Modified: trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/BusyConnectorsLoadMetric.java
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/BusyConnectorsLoadMetric.java 2008-10-22 21:44:32 UTC (rev 1988)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/BusyConnectorsLoadMetric.java 2008-10-23 05:16:30 UTC (rev 1989)
@@ -21,6 +21,8 @@
*/
package org.jboss.modcluster.load.metric.impl;
+import javax.management.MalformedObjectNameException;
+
import org.jboss.modcluster.load.metric.LoadMetric;
/**
@@ -33,13 +35,18 @@
public static final String DEFAULT_DIVIDEND_ATTRIBUTE = "currentThreadsBusy";
public static final String DEFAULT_DIVISOR_ATTRIBUTE = "maxThreads";
- public BusyConnectorsLoadMetric()
+ public BusyConnectorsLoadMetric() throws MalformedObjectNameException
{
- super(DEFAULT_DIVIDEND_ATTRIBUTE, DEFAULT_DIVISOR_ATTRIBUTE);
+ this(new ThreadPoolLoadMetricSource());
}
- public BusyConnectorsLoadMetric(String currentThreadsBusy, String maxThreads)
+ public BusyConnectorsLoadMetric(ThreadPoolLoadMetricSource source)
{
- super(currentThreadsBusy, maxThreads);
+ super(source, DEFAULT_DIVIDEND_ATTRIBUTE, DEFAULT_DIVISOR_ATTRIBUTE);
}
+
+ public BusyConnectorsLoadMetric(ThreadPoolLoadMetricSource source, String currentThreadsBusy, String maxThreads)
+ {
+ super(source, currentThreadsBusy, maxThreads);
+ }
}
Modified: trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/ConnectionPoolLoadMetricSource.java
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/ConnectionPoolLoadMetricSource.java 2008-10-22 21:44:32 UTC (rev 1988)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/ConnectionPoolLoadMetricSource.java 2008-10-23 05:16:30 UTC (rev 1989)
@@ -21,12 +21,9 @@
*/
package org.jboss.modcluster.load.metric.impl;
-import java.util.Collection;
-
import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
-import org.jboss.modcluster.load.metric.LoadMetric;
import org.jboss.modcluster.load.metric.LoadMetricSource;
/**
@@ -44,9 +41,9 @@
* @param server
* @throws MalformedObjectNameException
*/
- public ConnectionPoolLoadMetricSource(Collection<LoadMetric<MBeanQueryLoadContext>> metrics, MBeanServer server) throws MalformedObjectNameException
+ public ConnectionPoolLoadMetricSource(MBeanServer server) throws MalformedObjectNameException
{
- super(metrics, DEFAULT_PATTERN, server);
+ super(DEFAULT_PATTERN, server);
}
/**
@@ -57,9 +54,9 @@
* @param server
* @throws MalformedObjectNameException
*/
- public ConnectionPoolLoadMetricSource(Collection<LoadMetric<MBeanQueryLoadContext>> metrics, String pattern, MBeanServer server) throws MalformedObjectNameException
+ public ConnectionPoolLoadMetricSource(String pattern, MBeanServer server) throws MalformedObjectNameException
{
- super(metrics, pattern, server);
+ super(pattern, server);
}
/**
@@ -68,9 +65,9 @@
* @param registration
* @throws MalformedObjectNameException
*/
- public ConnectionPoolLoadMetricSource(Collection<LoadMetric<MBeanQueryLoadContext>> metrics) throws MalformedObjectNameException
+ public ConnectionPoolLoadMetricSource() throws MalformedObjectNameException
{
- super(metrics, DEFAULT_PATTERN);
+ super(DEFAULT_PATTERN);
}
/**
@@ -80,8 +77,8 @@
* @param pattern
* @throws MalformedObjectNameException
*/
- public ConnectionPoolLoadMetricSource(Collection<LoadMetric<MBeanQueryLoadContext>> metrics, String pattern) throws MalformedObjectNameException
+ public ConnectionPoolLoadMetricSource(String pattern) throws MalformedObjectNameException
{
- super(metrics, pattern);
+ super(pattern);
}
}
Modified: trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/ConnectionPoolUsageLoadMetric.java
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/ConnectionPoolUsageLoadMetric.java 2008-10-22 21:44:32 UTC (rev 1988)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/ConnectionPoolUsageLoadMetric.java 2008-10-23 05:16:30 UTC (rev 1989)
@@ -21,6 +21,8 @@
*/
package org.jboss.modcluster.load.metric.impl;
+import javax.management.MalformedObjectNameException;
+
import org.jboss.modcluster.load.metric.LoadMetric;
/**
@@ -33,13 +35,18 @@
public static final String DEFAULT_DIVIDEND_ATTRIBUTE = "InUseConnectionCount";
public static final String DEFAULT_DIVISOR_ATTRIBUTE = "MaxSize";
- public ConnectionPoolUsageLoadMetric()
+ public ConnectionPoolUsageLoadMetric() throws MalformedObjectNameException
{
- super(DEFAULT_DIVIDEND_ATTRIBUTE, DEFAULT_DIVISOR_ATTRIBUTE);
+ this(new ConnectionPoolLoadMetricSource());
}
- public ConnectionPoolUsageLoadMetric(String usedAttribute, String maxAttribute)
+ public ConnectionPoolUsageLoadMetric(ConnectionPoolLoadMetricSource source)
{
- super(usedAttribute, maxAttribute);
+ super(source, DEFAULT_DIVIDEND_ATTRIBUTE, DEFAULT_DIVISOR_ATTRIBUTE);
}
+
+ public ConnectionPoolUsageLoadMetric(ConnectionPoolLoadMetricSource source, String usedAttribute, String maxAttribute)
+ {
+ super(source, usedAttribute, maxAttribute);
+ }
}
Modified: trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/HeapMemoryUsageLoadMetric.java
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/HeapMemoryUsageLoadMetric.java 2008-10-22 21:44:32 UTC (rev 1988)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/HeapMemoryUsageLoadMetric.java 2008-10-23 05:16:30 UTC (rev 1989)
@@ -33,7 +33,7 @@
*
* @author Paul Ferraro
*/
-public class HeapMemoryUsageLoadMetric extends SingleLoadMetricSource
+public class HeapMemoryUsageLoadMetric extends SelfSourcedLoadMetric
{
private final MemoryMXBean bean;
Modified: trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/MBeanAttributeLoadMetric.java
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/MBeanAttributeLoadMetric.java 2008-10-22 21:44:32 UTC (rev 1988)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/MBeanAttributeLoadMetric.java 2008-10-23 05:16:30 UTC (rev 1989)
@@ -29,12 +29,14 @@
* Generic {@link LoadMetric} whose load is the aggregated value of an mbean attribute.
* @author Paul Ferraro
*/
-public class MBeanAttributeLoadMetric extends AbstractLoadMetric<MBeanQueryLoadContext>
+public class MBeanAttributeLoadMetric extends SourcedLoadMetric<MBeanQueryLoadContext>
{
private final String attribute;
- public MBeanAttributeLoadMetric(String attribute)
+ public MBeanAttributeLoadMetric(MBeanQueryLoadMetricSource source, String attribute)
{
+ super(source);
+
this.attribute = attribute;
}
Modified: trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/MBeanAttributeRatioLoadMetric.java
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/MBeanAttributeRatioLoadMetric.java 2008-10-22 21:44:32 UTC (rev 1988)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/MBeanAttributeRatioLoadMetric.java 2008-10-23 05:16:30 UTC (rev 1989)
@@ -31,13 +31,15 @@
* Generic {@link LoadMetric} whose load is the ratio of 2 aggregated mbean attributes.
* @author Paul Ferraro
*/
-public class MBeanAttributeRatioLoadMetric extends AbstractLoadMetric<MBeanQueryLoadContext>
+public class MBeanAttributeRatioLoadMetric extends SourcedLoadMetric<MBeanQueryLoadContext>
{
private final String dividendAttribute;
private final String divisorAttribute;
- public MBeanAttributeRatioLoadMetric(String currentAttribute, String maxAttribute)
+ public MBeanAttributeRatioLoadMetric(MBeanQueryLoadMetricSource source, String currentAttribute, String maxAttribute)
{
+ super(source);
+
this.dividendAttribute = currentAttribute;
this.divisorAttribute = maxAttribute;
}
Modified: trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/MBeanLoadMetricSource.java
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/MBeanLoadMetricSource.java 2008-10-22 21:44:32 UTC (rev 1988)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/MBeanLoadMetricSource.java 2008-10-23 05:16:30 UTC (rev 1989)
@@ -22,31 +22,28 @@
package org.jboss.modcluster.load.metric.impl;
import java.lang.management.ManagementFactory;
-import java.util.Collection;
import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
-import org.jboss.modcluster.load.metric.LoadMetric;
+import org.jboss.modcluster.load.metric.LoadMetricSource;
/**
* @author Paul Ferraro
*
*/
-public class MBeanLoadMetricSource extends AbstractLoadMetricSource<MBeanLoadContext>
+public class MBeanLoadMetricSource implements LoadMetricSource<MBeanLoadContext>
{
private final MBeanLoadContext context;
- public MBeanLoadMetricSource(Collection<LoadMetric<MBeanLoadContext>> metrics, String name) throws MalformedObjectNameException
+ public MBeanLoadMetricSource(String name) throws MalformedObjectNameException
{
- this(metrics, name, ManagementFactory.getPlatformMBeanServer());
+ this(name, ManagementFactory.getPlatformMBeanServer());
}
- public MBeanLoadMetricSource(Collection<LoadMetric<MBeanLoadContext>> metrics, String name, MBeanServer server) throws MalformedObjectNameException
+ public MBeanLoadMetricSource(String name, MBeanServer server) throws MalformedObjectNameException
{
- super(metrics);
-
this.context = new MBeanLoadContext(server, ObjectName.getInstance(name));
}
Modified: trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/MBeanQueryLoadMetricSource.java
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/MBeanQueryLoadMetricSource.java 2008-10-22 21:44:32 UTC (rev 1988)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/MBeanQueryLoadMetricSource.java 2008-10-23 05:16:30 UTC (rev 1989)
@@ -22,7 +22,6 @@
package org.jboss.modcluster.load.metric.impl;
import java.lang.management.ManagementFactory;
-import java.util.Collection;
import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
@@ -36,20 +35,18 @@
*
* @author Paul Ferraro
*/
-public class MBeanQueryLoadMetricSource extends AbstractLoadMetricSource<MBeanQueryLoadContext>
+public class MBeanQueryLoadMetricSource implements LoadMetricSource<MBeanQueryLoadContext>
{
private final MBeanServer server;
private final ObjectName name;
- public MBeanQueryLoadMetricSource(Collection<LoadMetric<MBeanQueryLoadContext>> metrics, String pattern) throws MalformedObjectNameException
+ public MBeanQueryLoadMetricSource(String pattern) throws MalformedObjectNameException
{
- this(metrics, pattern, ManagementFactory.getPlatformMBeanServer());
+ this(pattern, ManagementFactory.getPlatformMBeanServer());
}
- public MBeanQueryLoadMetricSource(Collection<LoadMetric<MBeanQueryLoadContext>> metrics, String pattern, MBeanServer server) throws MalformedObjectNameException
+ public MBeanQueryLoadMetricSource(String pattern, MBeanServer server) throws MalformedObjectNameException
{
- super(metrics);
-
this.server = server;
this.name = ObjectName.getInstance(pattern);
}
Modified: trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/OperatingSystemLoadMetricSource.java
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/OperatingSystemLoadMetricSource.java 2008-10-22 21:44:32 UTC (rev 1988)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/OperatingSystemLoadMetricSource.java 2008-10-23 05:16:30 UTC (rev 1989)
@@ -22,12 +22,10 @@
package org.jboss.modcluster.load.metric.impl;
import java.lang.management.ManagementFactory;
-import java.util.Collection;
import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
-import org.jboss.modcluster.load.metric.LoadMetric;
import org.jboss.modcluster.load.metric.LoadMetricSource;
/**
@@ -43,9 +41,9 @@
* @param registration
* @throws MalformedObjectNameException
*/
- public OperatingSystemLoadMetricSource(Collection<LoadMetric<MBeanLoadContext>> metrics) throws MalformedObjectNameException
+ public OperatingSystemLoadMetricSource() throws MalformedObjectNameException
{
- super(metrics, ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME);
+ super(ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME);
}
/**
@@ -54,8 +52,8 @@
* @param registration
* @throws MalformedObjectNameException
*/
- public OperatingSystemLoadMetricSource(Collection<LoadMetric<MBeanLoadContext>> metrics, MBeanServer server) throws MalformedObjectNameException
+ public OperatingSystemLoadMetricSource(MBeanServer server) throws MalformedObjectNameException
{
- super(metrics, ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME, server);
+ super(ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME, server);
}
}
Modified: trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/ReceiveTrafficLoadMetric.java
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/ReceiveTrafficLoadMetric.java 2008-10-22 21:44:32 UTC (rev 1988)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/ReceiveTrafficLoadMetric.java 2008-10-23 05:16:30 UTC (rev 1989)
@@ -22,6 +22,7 @@
package org.jboss.modcluster.load.metric.impl;
import javax.management.JMException;
+import javax.management.MalformedObjectNameException;
import org.jboss.modcluster.load.metric.LoadMetric;
@@ -35,16 +36,21 @@
private final DeterministicLoadState state = new DeterministicLoadState();
- public ReceiveTrafficLoadMetric()
+ public ReceiveTrafficLoadMetric() throws MalformedObjectNameException
{
- super(DEFAULT_ATTRIBUTE);
+ this(new RequestProcessorLoadMetricSource());
}
- public ReceiveTrafficLoadMetric(String attribute)
+ public ReceiveTrafficLoadMetric(RequestProcessorLoadMetricSource source)
{
- super(attribute);
+ super(source, DEFAULT_ATTRIBUTE);
}
+ public ReceiveTrafficLoadMetric(RequestProcessorLoadMetricSource source, String attribute)
+ {
+ super(source, attribute);
+ }
+
/**
* @{inheritDoc}
* @see org.jboss.modcluster.load.metric.impl.MBeanAttributeLoadMetric#getLoad(org.jboss.modcluster.load.metric.impl.MBeanQueryLoadContext)
Modified: trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/RequestCountLoadMetric.java
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/RequestCountLoadMetric.java 2008-10-22 21:44:32 UTC (rev 1988)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/RequestCountLoadMetric.java 2008-10-23 05:16:30 UTC (rev 1989)
@@ -22,6 +22,7 @@
package org.jboss.modcluster.load.metric.impl;
import javax.management.JMException;
+import javax.management.MalformedObjectNameException;
import org.jboss.modcluster.load.metric.LoadMetric;
@@ -36,16 +37,21 @@
private final DeterministicLoadState state = new DeterministicLoadState();
- public RequestCountLoadMetric()
+ public RequestCountLoadMetric() throws MalformedObjectNameException
{
- super(DEFAULT_ATTRIBUTE);
+ this(new RequestProcessorLoadMetricSource());
}
- public RequestCountLoadMetric(String attribute)
+ public RequestCountLoadMetric(RequestProcessorLoadMetricSource source)
{
- super(attribute);
+ super(source, DEFAULT_ATTRIBUTE);
}
+ public RequestCountLoadMetric(RequestProcessorLoadMetricSource source, String attribute)
+ {
+ super(source, attribute);
+ }
+
/**
* @{inheritDoc}
* @see org.jboss.modcluster.load.metric.impl.MBeanAttributeLoadMetric#getLoad(org.jboss.modcluster.load.metric.impl.MBeanQueryLoadContext)
Modified: trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/RequestProcessorLoadMetricSource.java
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/RequestProcessorLoadMetricSource.java 2008-10-22 21:44:32 UTC (rev 1988)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/RequestProcessorLoadMetricSource.java 2008-10-23 05:16:30 UTC (rev 1989)
@@ -21,12 +21,9 @@
*/
package org.jboss.modcluster.load.metric.impl;
-import java.util.Collection;
-
import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
-import org.jboss.modcluster.load.metric.LoadMetric;
import org.jboss.modcluster.load.metric.LoadMetricSource;
/**
@@ -45,9 +42,9 @@
* @param registration
* @throws MalformedObjectNameException
*/
- public RequestProcessorLoadMetricSource(Collection<LoadMetric<MBeanQueryLoadContext>> metrics) throws MalformedObjectNameException
+ public RequestProcessorLoadMetricSource() throws MalformedObjectNameException
{
- super(metrics, DEFAULT_PATTERN);
+ super(DEFAULT_PATTERN);
}
/**
@@ -57,9 +54,9 @@
* @param pattern
* @throws MalformedObjectNameException
*/
- public RequestProcessorLoadMetricSource(Collection<LoadMetric<MBeanQueryLoadContext>> metrics, String pattern) throws MalformedObjectNameException
+ public RequestProcessorLoadMetricSource(String pattern) throws MalformedObjectNameException
{
- super(metrics, pattern);
+ super(pattern);
}
/**
@@ -69,9 +66,9 @@
* @param server
* @throws MalformedObjectNameException
*/
- public RequestProcessorLoadMetricSource(Collection<LoadMetric<MBeanQueryLoadContext>> metrics, MBeanServer server) throws MalformedObjectNameException
+ public RequestProcessorLoadMetricSource(MBeanServer server) throws MalformedObjectNameException
{
- super(metrics, DEFAULT_PATTERN, server);
+ super(DEFAULT_PATTERN, server);
}
/**
@@ -82,8 +79,8 @@
* @param server
* @throws MalformedObjectNameException
*/
- public RequestProcessorLoadMetricSource(Collection<LoadMetric<MBeanQueryLoadContext>> metrics, String pattern, MBeanServer server) throws MalformedObjectNameException
+ public RequestProcessorLoadMetricSource(String pattern, MBeanServer server) throws MalformedObjectNameException
{
- super(metrics, pattern, server);
+ super(pattern, server);
}
}
Copied: trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/SelfSourcedLoadMetric.java (from rev 1988, trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/SingleLoadMetricSource.java)
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/SelfSourcedLoadMetric.java (rev 0)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/SelfSourcedLoadMetric.java 2008-10-23 05:16:30 UTC (rev 1989)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.modcluster.load.metric.impl;
+
+import org.jboss.modcluster.load.metric.LoadContext;
+import org.jboss.modcluster.load.metric.LoadMetric;
+import org.jboss.modcluster.load.metric.LoadMetricSource;
+
+/**
+ * Abstract {@link LoadMetricSource} + {@link LoadMetric} implementation that returns a single metric.
+ *
+ * @author Paul Ferraro
+ */
+public abstract class SelfSourcedLoadMetric extends AbstractLoadMetric<LoadContext> implements LoadMetricSource<LoadContext>
+{
+ // We don't need to use a load context since there's only one metric in this source
+ private final LoadContext context = new LoadContext()
+ {
+ public void close()
+ {
+ // nothing to close
+ }
+ };
+
+ /**
+ * @{inheritDoc}
+ * @see org.jboss.modcluster.load.metric.LoadMetricSource#createContext()
+ */
+ public LoadContext createContext()
+ {
+ return this.context;
+ }
+
+ /**
+ * @{inheritDoc}
+ * @see org.jboss.modcluster.load.metric.LoadMetric#getSource()
+ */
+ public LoadMetricSource<LoadContext> getSource()
+ {
+ return this;
+ }
+}
Property changes on: trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/SelfSourcedLoadMetric.java
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/SendTrafficLoadMetric.java
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/SendTrafficLoadMetric.java 2008-10-22 21:44:32 UTC (rev 1988)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/SendTrafficLoadMetric.java 2008-10-23 05:16:30 UTC (rev 1989)
@@ -22,6 +22,7 @@
package org.jboss.modcluster.load.metric.impl;
import javax.management.JMException;
+import javax.management.MalformedObjectNameException;
import org.jboss.modcluster.load.metric.LoadMetric;
@@ -36,16 +37,21 @@
private final DeterministicLoadState state = new DeterministicLoadState();
- public SendTrafficLoadMetric()
+ public SendTrafficLoadMetric() throws MalformedObjectNameException
{
- this(DEFAULT_ATTRIBUTE);
+ this(new RequestProcessorLoadMetricSource());
}
- public SendTrafficLoadMetric(String attribute)
+ public SendTrafficLoadMetric(RequestProcessorLoadMetricSource source)
{
- super(attribute);
+ this(source, DEFAULT_ATTRIBUTE);
}
+ public SendTrafficLoadMetric(RequestProcessorLoadMetricSource source, String attribute)
+ {
+ super(source, attribute);
+ }
+
/**
* @{inheritDoc}
* @see org.jboss.modcluster.load.metric.impl.MBeanAttributeLoadMetric#getLoad()
Modified: trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/SessionLoadMetricSource.java
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/SessionLoadMetricSource.java 2008-10-22 21:44:32 UTC (rev 1988)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/SessionLoadMetricSource.java 2008-10-23 05:16:30 UTC (rev 1989)
@@ -21,12 +21,9 @@
*/
package org.jboss.modcluster.load.metric.impl;
-import java.util.Collection;
-
import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
-import org.jboss.modcluster.load.metric.LoadMetric;
import org.jboss.modcluster.load.metric.LoadMetricSource;
/**
@@ -45,9 +42,9 @@
* @param registration
* @throws MalformedObjectNameException
*/
- public SessionLoadMetricSource(Collection<LoadMetric<MBeanQueryLoadContext>> metrics) throws MalformedObjectNameException
+ public SessionLoadMetricSource() throws MalformedObjectNameException
{
- super(metrics, DEFAULT_PATTERN);
+ super(DEFAULT_PATTERN);
}
/**
@@ -57,9 +54,9 @@
* @param pattern
* @throws MalformedObjectNameException
*/
- public SessionLoadMetricSource(Collection<LoadMetric<MBeanQueryLoadContext>> metrics, String pattern) throws MalformedObjectNameException
+ public SessionLoadMetricSource(String pattern) throws MalformedObjectNameException
{
- super(metrics, pattern);
+ super(pattern);
}
/**
@@ -69,9 +66,9 @@
* @param server
* @throws MalformedObjectNameException
*/
- public SessionLoadMetricSource(Collection<LoadMetric<MBeanQueryLoadContext>> metrics, MBeanServer server) throws MalformedObjectNameException
+ public SessionLoadMetricSource(MBeanServer server) throws MalformedObjectNameException
{
- super(metrics, DEFAULT_PATTERN, server);
+ super(DEFAULT_PATTERN, server);
}
/**
@@ -82,8 +79,8 @@
* @param server
* @throws MalformedObjectNameException
*/
- public SessionLoadMetricSource(Collection<LoadMetric<MBeanQueryLoadContext>> metrics, String pattern, MBeanServer server) throws MalformedObjectNameException
+ public SessionLoadMetricSource(String pattern, MBeanServer server) throws MalformedObjectNameException
{
- super(metrics, pattern, server);
+ super(pattern, server);
}
}
Deleted: trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/SingleLoadMetricSource.java
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/SingleLoadMetricSource.java 2008-10-22 21:44:32 UTC (rev 1988)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/SingleLoadMetricSource.java 2008-10-23 05:16:30 UTC (rev 1989)
@@ -1,65 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.modcluster.load.metric.impl;
-
-import java.util.Collection;
-import java.util.Collections;
-
-import org.jboss.modcluster.load.metric.LoadContext;
-import org.jboss.modcluster.load.metric.LoadMetric;
-import org.jboss.modcluster.load.metric.LoadMetricSource;
-
-/**
- * Abstract {@link LoadMetricSource} + {@link LoadMetric} implementation that returns a single metric.
- *
- * @author Paul Ferraro
- */
-public abstract class SingleLoadMetricSource extends AbstractLoadMetric<LoadContext> implements LoadMetricSource<LoadContext>
-{
- // We don't need to use a load context since there's only one metric in this source
- private final LoadContext context = new LoadContext()
- {
- public void close()
- {
- // nothing to close
- }
- };
-
- /**
- * @{inheritDoc}
- * @see org.jboss.modcluster.load.metric.LoadMetricSource#createContext()
- */
- public LoadContext createContext()
- {
- return this.context;
- }
-
- /**
- * @{inheritDoc}
- * @see org.jboss.modcluster.load.metric.LoadMetricSource#getMetrics()
- */
- public Collection<LoadMetric<LoadContext>> getMetrics()
- {
- // Silly that we need to down cast to prevent a compiler error, no?
- return Collections.singleton((LoadMetric<LoadContext>) this);
- }
-}
Added: trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/SourcedLoadMetric.java
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/SourcedLoadMetric.java (rev 0)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/SourcedLoadMetric.java 2008-10-23 05:16:30 UTC (rev 1989)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.modcluster.load.metric.impl;
+
+import org.jboss.modcluster.load.metric.LoadContext;
+import org.jboss.modcluster.load.metric.LoadMetricSource;
+
+/**
+ * @author Paul Ferraro
+ *
+ */
+public abstract class SourcedLoadMetric<C extends LoadContext> extends AbstractLoadMetric<C>
+{
+ private final LoadMetricSource<C> source;
+
+ protected SourcedLoadMetric(LoadMetricSource<C> source)
+ {
+ this.source = source;
+ }
+
+ /**
+ * @{inheritDoc}
+ * @see org.jboss.modcluster.load.metric.LoadMetric#getSource()
+ */
+ public LoadMetricSource<C> getSource()
+ {
+ return this.source;
+ }
+}
Modified: trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/SystemMemoryUsageLoadMetric.java
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/SystemMemoryUsageLoadMetric.java 2008-10-22 21:44:32 UTC (rev 1988)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/SystemMemoryUsageLoadMetric.java 2008-10-23 05:16:30 UTC (rev 1989)
@@ -23,6 +23,7 @@
import javax.management.AttributeNotFoundException;
import javax.management.JMException;
+import javax.management.MalformedObjectNameException;
import org.jboss.logging.Logger;
import org.jboss.modcluster.load.metric.LoadMetric;
@@ -33,13 +34,23 @@
*
* @author Paul Ferraro
*/
-public class SystemMemoryUsageLoadMetric extends AbstractLoadMetric<MBeanLoadContext>
+public class SystemMemoryUsageLoadMetric extends SourcedLoadMetric<MBeanLoadContext>
{
public static final String FREE_MEMORY = "FreePhysicalMemorySize";
public static final String TOTAL_MEMORY = "TotalPhysicalMemorySize";
private Logger logger = Logger.getLogger(this.getClass());
+ public SystemMemoryUsageLoadMetric() throws MalformedObjectNameException
+ {
+ super(new OperatingSystemLoadMetricSource());
+ }
+
+ public SystemMemoryUsageLoadMetric(OperatingSystemLoadMetricSource source)
+ {
+ super(source);
+ }
+
/**
* @{inheritDoc}
* @see org.jboss.modcluster.load.metric.LoadMetric#getLoad()
Modified: trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/ThreadCountLoadMetric.java
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/ThreadCountLoadMetric.java 2008-10-22 21:44:32 UTC (rev 1988)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/ThreadCountLoadMetric.java 2008-10-23 05:16:30 UTC (rev 1989)
@@ -30,7 +30,7 @@
* @author Paul Ferraro
*
*/
-public class ThreadCountLoadMetric extends SingleLoadMetricSource
+public class ThreadCountLoadMetric extends SelfSourcedLoadMetric
{
private final ThreadMXBean bean;
Modified: trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/ThreadPoolLoadMetricSource.java
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/ThreadPoolLoadMetricSource.java 2008-10-22 21:44:32 UTC (rev 1988)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/ThreadPoolLoadMetricSource.java 2008-10-23 05:16:30 UTC (rev 1989)
@@ -21,12 +21,9 @@
*/
package org.jboss.modcluster.load.metric.impl;
-import java.util.Collection;
-
import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
-import org.jboss.modcluster.load.metric.LoadMetric;
import org.jboss.modcluster.load.metric.LoadMetricSource;
/**
@@ -45,9 +42,9 @@
* @param registration
* @throws MalformedObjectNameException
*/
- public ThreadPoolLoadMetricSource(Collection<LoadMetric<MBeanQueryLoadContext>> metrics) throws MalformedObjectNameException
+ public ThreadPoolLoadMetricSource() throws MalformedObjectNameException
{
- super(metrics, DEFAULT_PATTERN);
+ super(DEFAULT_PATTERN);
}
/**
@@ -57,9 +54,9 @@
* @param patterh
* @throws MalformedObjectNameException
*/
- public ThreadPoolLoadMetricSource(Collection<LoadMetric<MBeanQueryLoadContext>> metrics, String pattern) throws MalformedObjectNameException
+ public ThreadPoolLoadMetricSource(String pattern) throws MalformedObjectNameException
{
- super(metrics, pattern);
+ super(pattern);
}
/**
@@ -69,9 +66,9 @@
* @param server
* @throws MalformedObjectNameException
*/
- public ThreadPoolLoadMetricSource(Collection<LoadMetric<MBeanQueryLoadContext>> metrics, MBeanServer server) throws MalformedObjectNameException
+ public ThreadPoolLoadMetricSource(MBeanServer server) throws MalformedObjectNameException
{
- super(metrics, DEFAULT_PATTERN, server);
+ super(DEFAULT_PATTERN, server);
}
/**
@@ -82,8 +79,8 @@
* @param server
* @throws MalformedObjectNameException
*/
- public ThreadPoolLoadMetricSource(Collection<LoadMetric<MBeanQueryLoadContext>> metrics, String pattern, MBeanServer server) throws MalformedObjectNameException
+ public ThreadPoolLoadMetricSource(String pattern, MBeanServer server) throws MalformedObjectNameException
{
- super(metrics, pattern, server);
+ super(pattern, server);
}
}
Modified: trunk/mod_cluster/src/main/resources/mod-cluster-jboss-beans.xml
===================================================================
--- trunk/mod_cluster/src/main/resources/mod-cluster-jboss-beans.xml 2008-10-22 21:44:32 UTC (rev 1988)
+++ trunk/mod_cluster/src/main/resources/mod-cluster-jboss-beans.xml 2008-10-23 05:16:30 UTC (rev 1989)
@@ -11,7 +11,7 @@
<!-- Comma separated list of address:port listing the httpd servers
where mod_cluster is running. -->
<!--property name="proxyList"></property-->
- <!-- URL prefix to send with commands to mod_cluster. Default is no prefix.
+ <!-- URL prefix to send with commands to mod_cluster. Default is no prefix. -->
<!--property name="proxyURL"></property-->
<!-- mod_advertise is a small httpd module that advertises the
@@ -51,11 +51,11 @@
<annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.web:service=LoadBalanceFactorProvider",exposedInterface=org.jboss.modcluster.load.impl.DynamicLoadBalanceFactorProviderMBean.class)</annotation>
<constructor>
<parameter>
- <!-- Define the load metric sources to use in your load balance factor calculation here -->
- <collection elementClass="org.jboss.modcluster.load.metric.LoadMetricSource">
- <value><inject bean="ThreadPoolLoadMetricSource"/></value>
- <value><inject bean="HeapMemoryUsageLoadMetric"/></value>
- </collection>
+ <!-- Define the load metrics to use in your load balance factor calculation here -->
+ <set elementClass="org.jboss.modcluster.load.metric.LoadMetricSource">
+ <inject bean="BusyConnectorsLoadMetric"/>
+ <inject bean="HeapMemoryUsageLoadMetric"/>
+ </set>
</parameter>
</constructor>
<!-- The number of historical load values used to determine load factor -->
@@ -65,28 +65,25 @@
</bean>
<!-- Default load metrics/sources -->
- <!-- Queries all JBossWeb ThreadPool mbeans -->
- <bean name="ThreadPoolLoadMetricSource" class="org.jboss.modcluster.load.metric.impl.ThreadPoolLoadMetricSource" mode="On Demand">
- <constructor>
- <parameter>
- <!-- Define the load metrics for this source -->
- <collection elementClass="org.jboss.modcluster.load.metric.LoadMetric">
- <value><inject bean="BusyConnectorsLoadMetric"/></value>
- </collection>
- </parameter>
- <parameter class="javax.management.MBeanServer"><inject bean="JMXKernel" property="mbeanServer"/></parameter>
- <!-- Object name pattern for connector thread pools -->
- <!--parameter>jboss.web:type=ThreadPool,*</parameter-->
- </constructor>
- </bean>
<!-- The JBossWeb connector thread pool usage as a ratio of busy threads to max thread pool size -->
<!-- Analogous to method=B in mod_jk -->
<bean name="BusyConnectorsLoadMetric" class="org.jboss.modcluster.load.metric.impl.BusyConnectorsLoadMetric" mode="On Demand">
<annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.web:service=BusyConnectorsLoadMetric",exposedInterface=org.jboss.modcluster.load.metric.LoadMetricMBean.class)</annotation>
+ <constructor>
+ <parameter><inject bean="ThreadPoolLoadMetricSource"/></parameter>
+ </constructor>
<!-- The weight determines the significance of this metric with respect
to others in the overall load balance factor calculation -->
<property name="weight">2</property>
</bean>
+ <!-- Queries all JBossWeb ThreadPool mbeans -->
+ <bean name="ThreadPoolLoadMetricSource" class="org.jboss.modcluster.load.metric.impl.ThreadPoolLoadMetricSource" mode="On Demand">
+ <constructor>
+ <parameter class="javax.management.MBeanServer"><inject bean="JMXKernel" property="mbeanServer"/></parameter>
+ <!-- Object name pattern for connector thread pools -->
+ <!--parameter>jboss.web:type=ThreadPool,*</parameter-->
+ </constructor>
+ </bean>
<!-- The heap memory usage as a ratio of used heap to max heap size -->
<!-- N.B. This load metric is its own source -->
@@ -126,23 +123,15 @@
<!-- Alternative load metrics, grouped by source -->
- <!-- Uses the platform's OperatingSystemMXBean -->
- <bean name="OperatingSystemLoadMetricSource" class="org.jboss.modcluster.load.metric.impl.OperatingSystemLoadMetricSource" mode="On Demand">
- <constructor>
- <parameter>
- <collection elementClass="org.jboss.modcluster.load.metric.LoadMetric">
- <value><inject bean="AverageSystemLoadMetric"/></value>
- <value><inject bean="SystemMemoryUsageLoadMetric"/></value>
- </collection>
- </parameter>
- </constructor>
- </bean>
<!-- CPU usage -->
<!-- Perhaps the best metric for determining system load - but only available on Java 1.6 or later -->
<bean name="AverageSystemLoadMetric"
class="org.jboss.modcluster.load.metric.impl.AverageSystemLoadMetric"
mode="On Demand">
<annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.web:service=AverageSystemLoadMetric",exposedInterface=org.jboss.modcluster.load.metric.LoadMetricMBean.class)</annotation>
+ <constructor>
+ <parameter><inject bean="OperatingSystemLoadMetricSource"/></parameter>
+ </constructor>
</bean>
<!-- The system memory usage as ratio of used memory to total memory size -->
<!-- Requires com.sun.management.OperatingSystemMXBean -->
@@ -150,31 +139,23 @@
class="org.jboss.modcluster.load.metric.impl.SystemMemoryUsageLoadMetric"
mode="On Demand">
<annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.web:service=SystemMemoryUsageLoadMetric",exposedInterface=org.jboss.modcluster.load.metric.LoadMetricMBean.class)</annotation>
- </bean>
-
-
- <!-- Queries all JBossWeb GlobalRequestProcessor mbeans -->
- <bean name="RequestProcessorLoadMetricSource" class="org.jboss.modcluster.load.metric.impl.RequestProcessorLoadMetricSource" mode="On Demand">
<constructor>
- <parameter>
- <collection elementClass="org.jboss.modcluster.load.metric.LoadMetric">
- <value><inject bean="RequestCountLoadMetric"/></value>
- <value><inject bean="ReceiveTrafficLoadMetric"/></value>
- <value><inject bean="SendTrafficLoadMetric"/></value>
- </collection>
- </parameter>
- <parameter class="javax.management.MBeanServer"><inject bean="JMXKernel" property="mbeanServer"/></parameter>
- <!-- Object name pattern for request processors -->
- <!--parameter>jboss.web:type=GlobalRequestProcessor,*</parameter-->
+ <parameter><inject bean="OperatingSystemLoadMetricSource"/></parameter>
</constructor>
</bean>
+ <!-- Uses the platform's OperatingSystemMXBean -->
+ <bean name="OperatingSystemLoadMetricSource" class="org.jboss.modcluster.load.metric.impl.OperatingSystemLoadMetricSource" mode="On Demand">
+ </bean>
+
+
<!-- The number of requests/sec processed by the JBossWeb connectors, with respect to the defined capacity -->
<!-- Analogous to method=R in mod_jk -->
<bean name="RequestCountLoadMetric" class="org.jboss.modcluster.load.metric.impl.RequestCountLoadMetric" mode="On Demand">
<annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.web:service=RequestCountLoadMetric",exposedInterface=org.jboss.modcluster.load.metric.LoadMetricMBean.class)</annotation>
- <!--constructor>
- <parameter>requestCount</parameter>
- </constructor-->
+ <constructor>
+ <parameter><inject bean="RequestProcessorLoadMetricSource"/></parameter>
+ <!--parameter>requestCount</parameter-->
+ </constructor>
<!-- This metric requires an explicit capacity, e.g. maximum capacity of 1000 requests/sec -->
<property name="capacity">1000</property>
</bean>
@@ -182,90 +163,80 @@
<!-- Analogous to method=T in mod_jk -->
<bean name="ReceiveTrafficLoadMetric" class="org.jboss.modcluster.load.metric.impl.ReceiveTrafficLoadMetric" mode="On Demand">
<annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.web:service=ReceiveTrafficLoadMetric",exposedInterface=org.jboss.modcluster.load.metric.LoadMetricMBean.class)</annotation>
- <!--constructor>
- <parameter>bytesReceived</parameter>
- </constructor-->
+ <constructor>
+ <parameter><inject bean="RequestProcessorLoadMetricSource"/></parameter>
+ <!--parameter>bytesReceived</parameter-->
+ </constructor>
<!-- This metric requires an explicit capacity, e.g. max capacity of 1024 KB/s -->
<property name="capacity">1024</property>
</bean>
<!-- The outgoing traffic sent by JBossWeb connectors in KB/sec, with respect to the defined capacity -->
<bean name="SendTrafficLoadMetric" class="org.jboss.modcluster.load.metric.impl.SendTrafficLoadMetric" mode="On Demand">
<annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.web:service=SendTrafficLoadMetric",exposedInterface=org.jboss.modcluster.load.metric.LoadMetricMBean.class)</annotation>
- <!--constructor>
- <parameter>bytesSent</parameter>
- </constructor-->
+ <constructor>
+ <parameter><inject bean="RequestProcessorLoadMetricSource"/></parameter>
+ <!--parameter>bytesSent</parameter-->
+ </constructor>
<!-- This metric requires an explicit capacity, e.g. max capacity of 512 KB/s -->
<property name="capacity">512</property>
</bean>
-
-
- <!-- Queries all JBossWeb session manager mbeans -->
- <bean name="SessionLoadMetricSource" class="org.jboss.modcluster.load.metric.impl.SessionLoadMetricSource" mode="On Demand">
+ <!-- Queries all JBossWeb GlobalRequestProcessor mbeans -->
+ <bean name="RequestProcessorLoadMetricSource" class="org.jboss.modcluster.load.metric.impl.RequestProcessorLoadMetricSource" mode="On Demand">
<constructor>
- <parameter>
- <collection elementClass="org.jboss.modcluster.load.metric.LoadMetric">
- <value><inject bean="ActiveSessionsLoadMetric"/></value>
- </collection>
- </parameter>
<parameter class="javax.management.MBeanServer"><inject bean="JMXKernel" property="mbeanServer"/></parameter>
- <!-- Object name pattern for session managers -->
- <!--parameter>jboss.web:type=Manager,*</parameter-->
+ <!-- Object name pattern for request processors -->
+ <!--parameter>jboss.web:type=GlobalRequestProcessor,*</parameter-->
</constructor>
</bean>
+
+
<!-- The number of active sessions, with respect to the defined capacity -->
<!-- Analogous to method=S in mod_jk -->
<bean name="ActiveSessionsLoadMetric" class="org.jboss.modcluster.load.metric.impl.ActiveSessionsLoadMetric" mode="On Demand">
<annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.web:service=ActiveSessionsLoadMetric",exposedInterface=org.jboss.modcluster.load.metric.LoadMetricMBean.class)</annotation>
- <!--constructor>
- <parameter>activeSessions</parameter>
- </constructor-->
+ <constructor>
+ <parameter><inject bean="SessionLoadMetricSource"/></parameter>
+ <!--parameter>activeSessions</parameter-->
+ </constructor>
<!-- This metric requires an explicit capacity, e.g. max capacity of 1000 active sessions -->
<property name="capacity">1000</property>
</bean>
+ <!-- Queries all JBossWeb session manager mbeans -->
+ <bean name="SessionLoadMetricSource" class="org.jboss.modcluster.load.metric.impl.SessionLoadMetricSource" mode="On Demand">
+ <constructor>
+ <parameter class="javax.management.MBeanServer"><inject bean="JMXKernel" property="mbeanServer"/></parameter>
+ <!-- Object name pattern for session managers -->
+ <!--parameter>jboss.web:type=Manager,*</parameter-->
+ </constructor>
+ </bean>
+ <!-- Returns the connection pool usage as a ratio of used to max pool size -->
+ <bean name="ConnectionPoolUsageMetric" class="org.jboss.modcluster.load.metric.impl.ConnectionPoolUsageLoadMetric" mode="On Demand">
+ <annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.web:service=ConnectionPoolUsageLoadMetric",exposedInterface=org.jboss.modcluster.load.metric.LoadMetricMBean.class)</annotation>
+ <constructor>
+ <parameter><inject bean="ConnectionPoolLoadMetricSource"/></parameter>
+ <!--parameter>InUseConnectionCount</parameter-->
+ <!--parameter>MaxSize</parameter-->
+ </constructor>
+ </bean>
<!-- Queries all JCA connection pools -->
<bean name="ConnectionPoolLoadMetricSource" class="org.jboss.modcluster.load.metric.impl.ConnectionPoolLoadMetricSource" mode="On Demand">
<constructor>
- <parameter>
- <collection elementClass="org.jboss.modcluster.load.metric.LoadMetric">
- <value><inject bean="ConnectionPoolUsageMetric"/></value>
- </collection>
- </parameter>
<parameter class="javax.management.MBeanServer"><inject bean="JMXKernel" property="mbeanServer"/></parameter>
<!-- Object name pattern for connector thread pools -->
<!--parameter>jboss.jca:service=ManagedConnectionPool,*</parameter-->
</constructor>
</bean>
- <!-- Returns the connection pool usage as a ratio of used to max pool size -->
- <bean name="ConnectionPoolUsageMetric" class="org.jboss.modcluster.load.metric.impl.ConnectionPoolUsageLoadMetric" mode="On Demand">
- <annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.web:service=ConnectionPoolUsageLoadMetric",exposedInterface=org.jboss.modcluster.load.metric.LoadMetricMBean.class)</annotation>
- <!--constructor>
- <parameter>InUseConnectionCount</parameter>
- <parameter>MaxSize</parameter>
- </constructor-->
- </bean>
<!-- Generic load metrics/sources -->
- <!-- Queries for mbeans matching the specified pattern -->
- <bean name="MBeanQueryLoadMetricSource" class="org.jboss.modcluster.load.metric.impl.MBeanQueryLoadMetricSource" mode="On Demand">
- <constructor>
- <parameter>
- <collection elementClass="org.jboss.modcluster.load.metric.LoadMetric">
- <value><bean inject="MBeanAttributeLoadMetric"/></value>
- <value><bean inject="MBeanAttributeRatioLoadMetric"/></value>
- </collection>
- </parameter>
- <parameter><!-- ObjectName pattern --></parameter>
- <parameter><inject bean="JMXKernel" property="mbeanServer"/></parameter>
- </constructor>
- </bean>
<!-- Uses the sum of the values of the specified attribute for each
mbean matching the query, with respect to a defined capacity. -->
<bean name="MBeanAttributeLoadMetric" class="org.jboss.modcluster.load.metric.impl.MBeanAttributeLoadMetric" mode="On Demand">
<annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.web:service=MBeanAttributeLoadMetric",exposedInterface=org.jboss.modcluster.load.metric.LoadMetricMBean.class)</annotation>
<constructor>
+ <parameter><inject bean="MBeanQueryLoadMetricSource"/></parameter>
<parameter><!-- mbean attribute --></parameter>
</constructor>
<property name="capacity">1</property>
@@ -276,9 +247,17 @@
<bean name="MBeanAttributeRatioLoadMetric" class="org.jboss.modcluster.load.metric.impl.MBeanAttributeLoadMetric" mode="On Demand">
<annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.web:service=MBeanAttributeLoadMetric",exposedInterface=org.jboss.modcluster.load.metric.LoadMetricMBean.class)</annotation>
<constructor>
+ <parameter><inject bean="MBeanQueryLoadMetricSource"/></parameter>
<parameter><!-- dividend attribute --></parameter>
<parameter><!-- divisor attribute --></parameter>
</constructor>
</bean>
-
+ <!-- Queries for mbeans matching the specified pattern -->
+ <bean name="MBeanQueryLoadMetricSource" class="org.jboss.modcluster.load.metric.impl.MBeanQueryLoadMetricSource" mode="On Demand">
+ <constructor>
+ <parameter><!-- ObjectName pattern --></parameter>
+ <parameter><inject bean="JMXKernel" property="mbeanServer"/></parameter>
+ </constructor>
+ </bean>
+
</deployment>
\ No newline at end of file
Modified: trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/DynamicLoadBalanceFactorProviderTestCase.java
===================================================================
--- trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/DynamicLoadBalanceFactorProviderTestCase.java 2008-10-22 21:44:32 UTC (rev 1988)
+++ trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/DynamicLoadBalanceFactorProviderTestCase.java 2008-10-23 05:16:30 UTC (rev 1989)
@@ -22,7 +22,7 @@
package org.jboss.modcluster.load;
import java.util.Arrays;
-import java.util.Collections;
+import java.util.LinkedHashSet;
import org.easymock.EasyMock;
import org.jboss.modcluster.load.impl.DynamicLoadBalanceFactorProvider;
@@ -40,14 +40,29 @@
@SuppressWarnings({ "unchecked", "boxing" })
public class DynamicLoadBalanceFactorProviderTestCase
{
+ LoadMetric<LoadContext> metric1 = EasyMock.createStrictMock(LoadMetric.class);
+ LoadMetric<LoadContext> metric2 = EasyMock.createStrictMock(LoadMetric.class);
+ LoadMetric<LoadContext> metric3 = EasyMock.createStrictMock(LoadMetric.class);
private final LoadMetricSource<LoadContext> source1 = EasyMock.createStrictMock(LoadMetricSource.class);
private final LoadMetricSource<LoadContext> source2 = EasyMock.createStrictMock(LoadMetricSource.class);
- private final DynamicLoadBalanceFactorProvider provider = new DynamicLoadBalanceFactorProvider(Arrays.asList(this.source1, this.source2));
+ private DynamicLoadBalanceFactorProvider provider;
+
@Before
public void init() throws Exception
{
+ EasyMock.expect(this.metric1.getSource()).andReturn(this.source1);
+ EasyMock.expect(this.metric2.getSource()).andReturn(this.source1);
+ EasyMock.expect(this.metric3.getSource()).andReturn(this.source2);
+
+ EasyMock.replay(this.metric1, this.metric2, this.metric3);
+
+ this.provider = new DynamicLoadBalanceFactorProvider(new LinkedHashSet<LoadMetric<LoadContext>>(Arrays.asList(this.metric1, this.metric2, this.metric3)));
+
+ EasyMock.verify(this.metric1, this.metric2, this.metric3);
+ EasyMock.reset(this.metric1, this.metric2, this.metric3);
+
this.provider.setHistory(2);
}
@@ -55,103 +70,85 @@
public void getLoadBalanceFactor() throws Exception
{
LoadContext context1 = EasyMock.createStrictMock(LoadContext.class);
- LoadMetric<LoadContext> metric1 = EasyMock.createStrictMock(LoadMetric.class);
- LoadMetric<LoadContext> metric2 = EasyMock.createStrictMock(LoadMetric.class);
- LoadMetric<LoadContext> metric3 = EasyMock.createStrictMock(LoadMetric.class);
- EasyMock.expect(this.source1.getMetrics()).andReturn(Arrays.asList(metric1, metric2));
+ EasyMock.expect(this.metric1.getWeight()).andReturn(1);
- EasyMock.expect(metric1.getWeight()).andReturn(1);
- EasyMock.expect(metric2.getWeight()).andReturn(2);
-
EasyMock.expect(this.source1.createContext()).andReturn(context1);
- EasyMock.expect(metric1.getLoad(context1)).andReturn(0.2);
- EasyMock.expect(metric1.getCapacity()).andReturn(1d);
- EasyMock.expect(metric1.getWeight()).andReturn(1);
+ EasyMock.expect(this.metric1.getWeight()).andReturn(1);
+ EasyMock.expect(this.metric1.getLoad(context1)).andReturn(0.2);
+ EasyMock.expect(this.metric1.getCapacity()).andReturn(1d);
- EasyMock.expect(metric2.getLoad(context1)).andReturn(400d);
- EasyMock.expect(metric2.getCapacity()).andReturn(1000d);
- EasyMock.expect(metric2.getWeight()).andReturn(2);
+ EasyMock.expect(this.metric2.getWeight()).andReturn(2);
+ EasyMock.expect(this.metric2.getLoad(context1)).andReturn(400d);
+ EasyMock.expect(this.metric2.getCapacity()).andReturn(1000d);
context1.close();
- EasyMock.expect(this.source2.getMetrics()).andReturn(Collections.singleton(metric3));
+ EasyMock.expect(this.metric3.getWeight()).andReturn(0);
- EasyMock.expect(metric3.getWeight()).andReturn(0);
+ EasyMock.replay(this.source1, this.source2, context1, this.metric1, this.metric2, this.metric3);
- EasyMock.replay(this.source1, this.source2, context1, metric1, metric2, metric3);
-
int loadBalanceFactor = this.provider.getLoadBalanceFactor();
- EasyMock.verify(this.source1, this.source2, context1, metric1, metric2, metric3);
+ EasyMock.verify(this.source1, this.source2, context1, this.metric1, this.metric2, this.metric3);
Assert.assertEquals(67, loadBalanceFactor);
- EasyMock.reset(this.source1, this.source2, context1, metric1, metric2, metric3);
+ EasyMock.reset(this.source1, this.source2, context1, this.metric1, this.metric2, this.metric3);
// Test time-decay function
- EasyMock.expect(this.source1.getMetrics()).andReturn(Arrays.asList(metric1, metric2));
+ EasyMock.expect(this.metric1.getWeight()).andReturn(1);
- EasyMock.expect(metric1.getWeight()).andReturn(1);
- EasyMock.expect(metric2.getWeight()).andReturn(2);
-
EasyMock.expect(this.source1.createContext()).andReturn(context1);
- EasyMock.expect(metric1.getLoad(context1)).andReturn(0.4);
- EasyMock.expect(metric1.getCapacity()).andReturn(1d);
- EasyMock.expect(metric1.getWeight()).andReturn(1);
+ EasyMock.expect(this.metric1.getWeight()).andReturn(1);
+ EasyMock.expect(this.metric1.getLoad(context1)).andReturn(0.4);
+ EasyMock.expect(this.metric1.getCapacity()).andReturn(1d);
- EasyMock.expect(metric2.getLoad(context1)).andReturn(600d);
- EasyMock.expect(metric2.getCapacity()).andReturn(1000d);
- EasyMock.expect(metric2.getWeight()).andReturn(2);
+ EasyMock.expect(this.metric2.getWeight()).andReturn(2);
+ EasyMock.expect(this.metric2.getLoad(context1)).andReturn(600d);
+ EasyMock.expect(this.metric2.getCapacity()).andReturn(1000d);
context1.close();
- EasyMock.expect(this.source2.getMetrics()).andReturn(Collections.singleton(metric3));
+ EasyMock.expect(this.metric3.getWeight()).andReturn(0);
- EasyMock.expect(metric3.getWeight()).andReturn(0);
+ EasyMock.replay(this.source1, this.source2, context1, this.metric1, this.metric2, this.metric3);
- EasyMock.replay(this.source1, this.source2, context1, metric1, metric2, metric3);
-
loadBalanceFactor = this.provider.getLoadBalanceFactor();
- EasyMock.verify(this.source1, this.source2, context1, metric1, metric2, metric3);
+ EasyMock.verify(this.source1, this.source2, context1, this.metric1, this.metric2, this.metric3);
Assert.assertEquals(53, loadBalanceFactor);
- EasyMock.reset(this.source1, this.source2, context1, metric1, metric2, metric3);
+ EasyMock.reset(this.source1, this.source2, context1, this.metric1, this.metric2, this.metric3);
//Test decay queue overflow
- EasyMock.expect(this.source1.getMetrics()).andReturn(Arrays.asList(metric1, metric2));
+ EasyMock.expect(this.metric1.getWeight()).andReturn(1);
- EasyMock.expect(metric1.getWeight()).andReturn(1);
- EasyMock.expect(metric2.getWeight()).andReturn(2);
-
EasyMock.expect(this.source1.createContext()).andReturn(context1);
- EasyMock.expect(metric1.getLoad(context1)).andReturn(0.3);
- EasyMock.expect(metric1.getCapacity()).andReturn(1d);
- EasyMock.expect(metric1.getWeight()).andReturn(1);
+ EasyMock.expect(this.metric1.getWeight()).andReturn(1);
+ EasyMock.expect(this.metric1.getLoad(context1)).andReturn(0.3);
+ EasyMock.expect(this.metric1.getCapacity()).andReturn(1d);
- EasyMock.expect(metric2.getLoad(context1)).andReturn(300d);
- EasyMock.expect(metric2.getCapacity()).andReturn(1000d);
- EasyMock.expect(metric2.getWeight()).andReturn(2);
+ EasyMock.expect(this.metric2.getWeight()).andReturn(2);
+ EasyMock.expect(this.metric2.getLoad(context1)).andReturn(300d);
+ EasyMock.expect(this.metric2.getCapacity()).andReturn(1000d);
context1.close();
- EasyMock.expect(this.source2.getMetrics()).andReturn(Collections.singleton(metric3));
+ EasyMock.expect(this.metric3.getWeight()).andReturn(0);
- EasyMock.expect(metric3.getWeight()).andReturn(0);
+ EasyMock.replay(this.source1, this.source2, context1, this.metric1, this.metric2, this.metric3);
- EasyMock.replay(this.source1, this.source2, context1, metric1, metric2, metric3);
-
loadBalanceFactor = this.provider.getLoadBalanceFactor();
- EasyMock.verify(this.source1, this.source2, context1, metric1, metric2, metric3);
+ EasyMock.verify(this.source1, this.source2, context1, this.metric1, this.metric2, this.metric3);
Assert.assertEquals(62, loadBalanceFactor);
- EasyMock.reset(this.source1, this.source2, context1, metric1, metric2, metric3);
+ EasyMock.reset(this.source1, this.source2, context1, this.metric1, this.metric2, this.metric3);
}
}
Modified: trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/ActiveSessionsLoadMetricTestCase.java
===================================================================
--- trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/ActiveSessionsLoadMetricTestCase.java 2008-10-22 21:44:32 UTC (rev 1988)
+++ trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/ActiveSessionsLoadMetricTestCase.java 2008-10-23 05:16:30 UTC (rev 1989)
@@ -21,6 +21,8 @@
*/
package org.jboss.modcluster.load.metric;
+import javax.management.MalformedObjectNameException;
+
import org.jboss.modcluster.load.metric.impl.ActiveSessionsLoadMetric;
/**
@@ -29,7 +31,7 @@
*/
public class ActiveSessionsLoadMetricTestCase extends MBeanAttributeLoadMetricTestCase
{
- public ActiveSessionsLoadMetricTestCase()
+ public ActiveSessionsLoadMetricTestCase() throws MalformedObjectNameException
{
super(new ActiveSessionsLoadMetric(), ActiveSessionsLoadMetric.DEFAULT_ATTRIBUTE);
}
Modified: trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/AverageSystemLoadMetricTestCase.java
===================================================================
--- trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/AverageSystemLoadMetricTestCase.java 2008-10-22 21:44:32 UTC (rev 1988)
+++ trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/AverageSystemLoadMetricTestCase.java 2008-10-23 05:16:30 UTC (rev 1989)
@@ -44,7 +44,7 @@
{
private final MBeanServer server = EasyMock.createStrictMock(MBeanServer.class);
- private LoadMetric<MBeanLoadContext> metric = new AverageSystemLoadMetric();
+ private LoadMetric<MBeanLoadContext> metric;
private ObjectName name;
private MBeanLoadContext context;
@@ -52,6 +52,7 @@
@Before
public void prepare() throws MalformedObjectNameException
{
+ this.metric = new AverageSystemLoadMetric();
this.name = ObjectName.getInstance(ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME);
this.context = new MBeanLoadContext(this.server, this.name);
}
Modified: trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/BusyConnectorsLoadMetricTestCase.java
===================================================================
--- trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/BusyConnectorsLoadMetricTestCase.java 2008-10-22 21:44:32 UTC (rev 1988)
+++ trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/BusyConnectorsLoadMetricTestCase.java 2008-10-23 05:16:30 UTC (rev 1989)
@@ -21,6 +21,8 @@
*/
package org.jboss.modcluster.load.metric;
+import javax.management.MalformedObjectNameException;
+
import org.jboss.modcluster.load.metric.impl.BusyConnectorsLoadMetric;
/**
@@ -29,7 +31,7 @@
*/
public class BusyConnectorsLoadMetricTestCase extends MBeanAttributeRatioLoadMetricTestCase
{
- public BusyConnectorsLoadMetricTestCase()
+ public BusyConnectorsLoadMetricTestCase() throws MalformedObjectNameException
{
super(new BusyConnectorsLoadMetric(), BusyConnectorsLoadMetric.DEFAULT_DIVIDEND_ATTRIBUTE, BusyConnectorsLoadMetric.DEFAULT_DIVISOR_ATTRIBUTE);
}
Modified: trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/ConnectionPoolLoadMetricSourceTestCase.java
===================================================================
--- trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/ConnectionPoolLoadMetricSourceTestCase.java 2008-10-22 21:44:32 UTC (rev 1988)
+++ trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/ConnectionPoolLoadMetricSourceTestCase.java 2008-10-23 05:16:30 UTC (rev 1989)
@@ -21,14 +21,11 @@
*/
package org.jboss.modcluster.load.metric;
-import java.util.Collection;
-
import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
+import org.easymock.EasyMock;
import org.jboss.modcluster.load.metric.impl.ConnectionPoolLoadMetricSource;
-import org.jboss.modcluster.load.metric.impl.MBeanQueryLoadContext;
-import org.jboss.modcluster.load.metric.impl.MBeanQueryLoadMetricSource;
/**
* @author Paul Ferraro
@@ -38,12 +35,11 @@
{
public ConnectionPoolLoadMetricSourceTestCase() throws MalformedObjectNameException
{
- super(ConnectionPoolLoadMetricSource.DEFAULT_PATTERN);
+ this(EasyMock.createStrictMock(MBeanServer.class));
}
- @Override
- protected MBeanQueryLoadMetricSource createSource(Collection<LoadMetric<MBeanQueryLoadContext>> metrics, MBeanServer server) throws MalformedObjectNameException
+ private ConnectionPoolLoadMetricSourceTestCase(MBeanServer server) throws MalformedObjectNameException
{
- return new ConnectionPoolLoadMetricSource(metrics, server);
+ super(new ConnectionPoolLoadMetricSource(server), ConnectionPoolLoadMetricSource.DEFAULT_PATTERN, server);
}
}
Modified: trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/ConnectionPoolUsageLoadMetricTestCase.java
===================================================================
--- trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/ConnectionPoolUsageLoadMetricTestCase.java 2008-10-22 21:44:32 UTC (rev 1988)
+++ trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/ConnectionPoolUsageLoadMetricTestCase.java 2008-10-23 05:16:30 UTC (rev 1989)
@@ -21,6 +21,8 @@
*/
package org.jboss.modcluster.load.metric;
+import javax.management.MalformedObjectNameException;
+
import org.jboss.modcluster.load.metric.impl.ConnectionPoolUsageLoadMetric;
@@ -30,7 +32,7 @@
*/
public class ConnectionPoolUsageLoadMetricTestCase extends MBeanAttributeRatioLoadMetricTestCase
{
- public ConnectionPoolUsageLoadMetricTestCase()
+ public ConnectionPoolUsageLoadMetricTestCase() throws MalformedObjectNameException
{
super(new ConnectionPoolUsageLoadMetric(), ConnectionPoolUsageLoadMetric.DEFAULT_DIVIDEND_ATTRIBUTE, ConnectionPoolUsageLoadMetric.DEFAULT_DIVISOR_ATTRIBUTE);
}
Modified: trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/MBeanAttributeLoadMetricTestCase.java
===================================================================
--- trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/MBeanAttributeLoadMetricTestCase.java 2008-10-22 21:44:32 UTC (rev 1988)
+++ trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/MBeanAttributeLoadMetricTestCase.java 2008-10-23 05:16:30 UTC (rev 1989)
@@ -31,6 +31,7 @@
import org.easymock.EasyMock;
import org.jboss.modcluster.load.metric.impl.MBeanAttributeLoadMetric;
import org.jboss.modcluster.load.metric.impl.MBeanQueryLoadContext;
+import org.jboss.modcluster.load.metric.impl.MBeanQueryLoadMetricSource;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -50,14 +51,14 @@
private String attribute;
LoadMetric<MBeanQueryLoadContext> metric;
- public MBeanAttributeLoadMetricTestCase()
+ public MBeanAttributeLoadMetricTestCase() throws MalformedObjectNameException
{
this("attribute");
}
- private MBeanAttributeLoadMetricTestCase(String attribute)
+ private MBeanAttributeLoadMetricTestCase(String attribute) throws MalformedObjectNameException
{
- this(new MBeanAttributeLoadMetric(attribute), attribute);
+ this(new MBeanAttributeLoadMetric(new MBeanQueryLoadMetricSource("domain:*"), attribute), attribute);
}
protected MBeanAttributeLoadMetricTestCase(LoadMetric<MBeanQueryLoadContext> metric, String attribute)
Modified: trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/MBeanAttributeRatioLoadMetricTestCase.java
===================================================================
--- trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/MBeanAttributeRatioLoadMetricTestCase.java 2008-10-22 21:44:32 UTC (rev 1988)
+++ trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/MBeanAttributeRatioLoadMetricTestCase.java 2008-10-23 05:16:30 UTC (rev 1989)
@@ -31,6 +31,7 @@
import org.easymock.EasyMock;
import org.jboss.modcluster.load.metric.impl.MBeanAttributeRatioLoadMetric;
import org.jboss.modcluster.load.metric.impl.MBeanQueryLoadContext;
+import org.jboss.modcluster.load.metric.impl.MBeanQueryLoadMetricSource;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -51,14 +52,14 @@
private String divisor;
private LoadMetric<MBeanQueryLoadContext> metric;
- public MBeanAttributeRatioLoadMetricTestCase()
+ public MBeanAttributeRatioLoadMetricTestCase() throws MalformedObjectNameException
{
this("dividend", "divisor");
}
- private MBeanAttributeRatioLoadMetricTestCase(String dividend, String divisor)
+ private MBeanAttributeRatioLoadMetricTestCase(String dividend, String divisor) throws MalformedObjectNameException
{
- this(new MBeanAttributeRatioLoadMetric(dividend, divisor), dividend, divisor);
+ this(new MBeanAttributeRatioLoadMetric(new MBeanQueryLoadMetricSource("domain:*"), dividend, divisor), dividend, divisor);
}
protected MBeanAttributeRatioLoadMetricTestCase(LoadMetric<MBeanQueryLoadContext> metric, String dividend, String divisor)
Modified: trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/MBeanLoadMetricSourceTestCase.java
===================================================================
--- trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/MBeanLoadMetricSourceTestCase.java 2008-10-22 21:44:32 UTC (rev 1988)
+++ trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/MBeanLoadMetricSourceTestCase.java 2008-10-23 05:16:30 UTC (rev 1989)
@@ -21,10 +21,6 @@
*/
package org.jboss.modcluster.load.metric;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Iterator;
-
import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
@@ -39,30 +35,25 @@
* @author Paul Ferraro
*
*/
-@SuppressWarnings("unchecked")
public class MBeanLoadMetricSourceTestCase
{
- private MBeanServer server = EasyMock.createStrictMock(MBeanServer.class);
- private LoadMetric<MBeanLoadContext> metric1 = EasyMock.createStrictMock(LoadMetric.class);
- private LoadMetric<MBeanLoadContext> metric2 = EasyMock.createStrictMock(LoadMetric.class);
-
- private String name;
+ private MBeanServer server;
private LoadMetricSource<MBeanLoadContext> source;
public MBeanLoadMetricSourceTestCase() throws MalformedObjectNameException
{
- this("domain:name=test");
+ this("domain:name=test", EasyMock.createStrictMock(MBeanServer.class));
}
- protected MBeanLoadMetricSourceTestCase(String name) throws MalformedObjectNameException
+ private MBeanLoadMetricSourceTestCase(String name, MBeanServer server) throws MalformedObjectNameException
{
- this.name = name;
- this.source = this.createSource(Arrays.asList(this.metric1, this.metric2), this.server);
+ this(new MBeanLoadMetricSource(name, server), server);
}
- protected MBeanLoadMetricSource createSource(Collection<LoadMetric<MBeanLoadContext>> metrics, MBeanServer server) throws MalformedObjectNameException
+ protected MBeanLoadMetricSourceTestCase(MBeanLoadMetricSource source, MBeanServer server)
{
- return new MBeanLoadMetricSource(metrics, this.name, server);
+ this.source = source;
+ this.server = server;
}
@Test
@@ -78,17 +69,4 @@
EasyMock.reset(this.server);
}
-
- @Test
- public void getMetrics()
- {
- Collection<LoadMetric<MBeanLoadContext>> metrics = this.source.getMetrics();
-
- Assert.assertEquals(2, metrics.size());
-
- Iterator<LoadMetric<MBeanLoadContext>> iterator = metrics.iterator();
-
- Assert.assertSame(this.metric1, iterator.next());
- Assert.assertSame(this.metric2, iterator.next());
- }
}
Modified: trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/MBeanQueryLoadMetricSourceTestCase.java
===================================================================
--- trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/MBeanQueryLoadMetricSourceTestCase.java 2008-10-22 21:44:32 UTC (rev 1988)
+++ trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/MBeanQueryLoadMetricSourceTestCase.java 2008-10-23 05:16:30 UTC (rev 1989)
@@ -21,10 +21,7 @@
*/
package org.jboss.modcluster.load.metric;
-import java.util.Arrays;
-import java.util.Collection;
import java.util.Collections;
-import java.util.Iterator;
import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
@@ -43,30 +40,27 @@
* @author Paul Ferraro
*
*/
-@SuppressWarnings("unchecked")
public class MBeanQueryLoadMetricSourceTestCase
{
- private MBeanServer server = EasyMock.createStrictMock(MBeanServer.class);
- private LoadMetric<MBeanQueryLoadContext> metric1 = EasyMock.createStrictMock(LoadMetric.class);
- private LoadMetric<MBeanQueryLoadContext> metric2 = EasyMock.createStrictMock(LoadMetric.class);
-
+ private MBeanServer server;
private String pattern;
private LoadMetricSource<MBeanQueryLoadContext> source;
public MBeanQueryLoadMetricSourceTestCase() throws MalformedObjectNameException
{
- this("domain:*");
+ this("domain:*", EasyMock.createStrictMock(MBeanServer.class));
}
- protected MBeanQueryLoadMetricSourceTestCase(String pattern) throws MalformedObjectNameException
+ private MBeanQueryLoadMetricSourceTestCase(String pattern, MBeanServer server) throws MalformedObjectNameException
{
- this.pattern = pattern;
- this.source = this.createSource(Arrays.asList(this.metric1, this.metric2), this.server);
+ this(new MBeanQueryLoadMetricSource(pattern, server), pattern, server);
}
- protected MBeanQueryLoadMetricSource createSource(Collection<LoadMetric<MBeanQueryLoadContext>> metrics, MBeanServer server) throws MalformedObjectNameException
+ protected MBeanQueryLoadMetricSourceTestCase(MBeanQueryLoadMetricSource source, String pattern, MBeanServer server)
{
- return new MBeanQueryLoadMetricSource(metrics, this.pattern, server);
+ this.source = source;
+ this.pattern = pattern;
+ this.server = server;
}
@Test
@@ -88,17 +82,4 @@
EasyMock.reset(this.server);
}
-
- @Test
- public void getMetrics()
- {
- Collection<LoadMetric<MBeanQueryLoadContext>> metrics = this.source.getMetrics();
-
- Assert.assertEquals(2, metrics.size());
-
- Iterator<LoadMetric<MBeanQueryLoadContext>> iterator = metrics.iterator();
-
- Assert.assertSame(this.metric1, iterator.next());
- Assert.assertSame(this.metric2, iterator.next());
- }
}
Modified: trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/OperatingSystemLoadMetricSourceTestCase.java
===================================================================
--- trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/OperatingSystemLoadMetricSourceTestCase.java 2008-10-22 21:44:32 UTC (rev 1988)
+++ trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/OperatingSystemLoadMetricSourceTestCase.java 2008-10-23 05:16:30 UTC (rev 1989)
@@ -21,14 +21,10 @@
*/
package org.jboss.modcluster.load.metric;
-import java.lang.management.ManagementFactory;
-import java.util.Collection;
-
import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
-import org.jboss.modcluster.load.metric.impl.MBeanLoadContext;
-import org.jboss.modcluster.load.metric.impl.MBeanLoadMetricSource;
+import org.easymock.EasyMock;
import org.jboss.modcluster.load.metric.impl.OperatingSystemLoadMetricSource;
/**
@@ -39,16 +35,11 @@
{
public OperatingSystemLoadMetricSourceTestCase() throws MalformedObjectNameException
{
- super(ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME);
+ this(EasyMock.createStrictMock(MBeanServer.class));
}
- /**
- * @{inheritDoc}
- * @see org.jboss.modcluster.load.metric.MBeanLoadMetricSourceTestCase#createSource(java.util.Collection, javax.management.MBeanServer)
- */
- @Override
- protected MBeanLoadMetricSource createSource(Collection<LoadMetric<MBeanLoadContext>> metrics, MBeanServer server) throws MalformedObjectNameException
+ private OperatingSystemLoadMetricSourceTestCase(MBeanServer server) throws MalformedObjectNameException
{
- return new OperatingSystemLoadMetricSource(metrics, server);
+ super(new OperatingSystemLoadMetricSource(server), server);
}
}
Modified: trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/ReceiveTrafficLoadMetricTestCase.java
===================================================================
--- trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/ReceiveTrafficLoadMetricTestCase.java 2008-10-22 21:44:32 UTC (rev 1988)
+++ trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/ReceiveTrafficLoadMetricTestCase.java 2008-10-23 05:16:30 UTC (rev 1989)
@@ -21,6 +21,8 @@
*/
package org.jboss.modcluster.load.metric;
+import javax.management.MalformedObjectNameException;
+
import org.easymock.EasyMock;
import org.jboss.modcluster.load.metric.impl.ReceiveTrafficLoadMetric;
import org.junit.Assert;
@@ -33,7 +35,7 @@
@SuppressWarnings("boxing")
public class ReceiveTrafficLoadMetricTestCase extends MBeanAttributeLoadMetricTestCase
{
- public ReceiveTrafficLoadMetricTestCase()
+ public ReceiveTrafficLoadMetricTestCase() throws MalformedObjectNameException
{
super(new ReceiveTrafficLoadMetric(), ReceiveTrafficLoadMetric.DEFAULT_ATTRIBUTE);
}
Modified: trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/RequestCountLoadMetricTestCase.java
===================================================================
--- trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/RequestCountLoadMetricTestCase.java 2008-10-22 21:44:32 UTC (rev 1988)
+++ trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/RequestCountLoadMetricTestCase.java 2008-10-23 05:16:30 UTC (rev 1989)
@@ -21,6 +21,8 @@
*/
package org.jboss.modcluster.load.metric;
+import javax.management.MalformedObjectNameException;
+
import org.easymock.EasyMock;
import org.jboss.modcluster.load.metric.impl.RequestCountLoadMetric;
import org.junit.Assert;
@@ -33,7 +35,7 @@
@SuppressWarnings("boxing")
public class RequestCountLoadMetricTestCase extends MBeanAttributeLoadMetricTestCase
{
- public RequestCountLoadMetricTestCase()
+ public RequestCountLoadMetricTestCase() throws MalformedObjectNameException
{
super(new RequestCountLoadMetric(), RequestCountLoadMetric.DEFAULT_ATTRIBUTE);
}
Modified: trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/RequestProcessorLoadMetricSourceTestCase.java
===================================================================
--- trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/RequestProcessorLoadMetricSourceTestCase.java 2008-10-22 21:44:32 UTC (rev 1988)
+++ trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/RequestProcessorLoadMetricSourceTestCase.java 2008-10-23 05:16:30 UTC (rev 1989)
@@ -21,13 +21,10 @@
*/
package org.jboss.modcluster.load.metric;
-import java.util.Collection;
-
import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
-import org.jboss.modcluster.load.metric.impl.MBeanQueryLoadContext;
-import org.jboss.modcluster.load.metric.impl.MBeanQueryLoadMetricSource;
+import org.easymock.EasyMock;
import org.jboss.modcluster.load.metric.impl.RequestProcessorLoadMetricSource;
/**
@@ -38,12 +35,11 @@
{
public RequestProcessorLoadMetricSourceTestCase() throws MalformedObjectNameException
{
- super(RequestProcessorLoadMetricSource.DEFAULT_PATTERN);
+ this(EasyMock.createStrictMock(MBeanServer.class));
}
- @Override
- protected MBeanQueryLoadMetricSource createSource(Collection<LoadMetric<MBeanQueryLoadContext>> metrics, MBeanServer server) throws MalformedObjectNameException
+ private RequestProcessorLoadMetricSourceTestCase(MBeanServer server) throws MalformedObjectNameException
{
- return new RequestProcessorLoadMetricSource(metrics, server);
+ super(new RequestProcessorLoadMetricSource(server), RequestProcessorLoadMetricSource.DEFAULT_PATTERN, server);
}
}
Modified: trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/SendTrafficLoadMetricTestCase.java
===================================================================
--- trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/SendTrafficLoadMetricTestCase.java 2008-10-22 21:44:32 UTC (rev 1988)
+++ trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/SendTrafficLoadMetricTestCase.java 2008-10-23 05:16:30 UTC (rev 1989)
@@ -21,6 +21,8 @@
*/
package org.jboss.modcluster.load.metric;
+import javax.management.MalformedObjectNameException;
+
import org.easymock.EasyMock;
import org.jboss.modcluster.load.metric.impl.SendTrafficLoadMetric;
import org.junit.Assert;
@@ -33,7 +35,7 @@
@SuppressWarnings("boxing")
public class SendTrafficLoadMetricTestCase extends MBeanAttributeLoadMetricTestCase
{
- public SendTrafficLoadMetricTestCase()
+ public SendTrafficLoadMetricTestCase() throws MalformedObjectNameException
{
super(new SendTrafficLoadMetric(), SendTrafficLoadMetric.DEFAULT_ATTRIBUTE);
}
Modified: trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/SessionLoadMetricSourceTestCase.java
===================================================================
--- trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/SessionLoadMetricSourceTestCase.java 2008-10-22 21:44:32 UTC (rev 1988)
+++ trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/SessionLoadMetricSourceTestCase.java 2008-10-23 05:16:30 UTC (rev 1989)
@@ -21,13 +21,10 @@
*/
package org.jboss.modcluster.load.metric;
-import java.util.Collection;
-
import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
-import org.jboss.modcluster.load.metric.impl.MBeanQueryLoadContext;
-import org.jboss.modcluster.load.metric.impl.MBeanQueryLoadMetricSource;
+import org.easymock.EasyMock;
import org.jboss.modcluster.load.metric.impl.SessionLoadMetricSource;
/**
@@ -38,12 +35,11 @@
{
public SessionLoadMetricSourceTestCase() throws MalformedObjectNameException
{
- super(SessionLoadMetricSource.DEFAULT_PATTERN);
+ this(EasyMock.createStrictMock(MBeanServer.class));
}
- @Override
- protected MBeanQueryLoadMetricSource createSource(Collection<LoadMetric<MBeanQueryLoadContext>> metrics, MBeanServer server) throws MalformedObjectNameException
+ private SessionLoadMetricSourceTestCase(MBeanServer server) throws MalformedObjectNameException
{
- return new SessionLoadMetricSource(metrics, server);
+ super(new SessionLoadMetricSource(server), SessionLoadMetricSource.DEFAULT_PATTERN, server);
}
}
Modified: trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/SystemMemoryUsageLoadMetricTestCase.java
===================================================================
--- trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/SystemMemoryUsageLoadMetricTestCase.java 2008-10-22 21:44:32 UTC (rev 1988)
+++ trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/SystemMemoryUsageLoadMetricTestCase.java 2008-10-23 05:16:30 UTC (rev 1989)
@@ -43,7 +43,7 @@
{
private final MBeanServer server = EasyMock.createStrictMock(MBeanServer.class);
- private LoadMetric<MBeanLoadContext> metric = new SystemMemoryUsageLoadMetric();
+ private LoadMetric<MBeanLoadContext> metric;
private ObjectName name;
private MBeanLoadContext context;
@@ -51,6 +51,7 @@
@Before
public void prepare() throws MalformedObjectNameException
{
+ this.metric = new SystemMemoryUsageLoadMetric();
this.name = ObjectName.getInstance(ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME);
this.context = new MBeanLoadContext(this.server, this.name);
}
Modified: trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/ThreadPoolLoadMetricSourceTestCase.java
===================================================================
--- trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/ThreadPoolLoadMetricSourceTestCase.java 2008-10-22 21:44:32 UTC (rev 1988)
+++ trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/ThreadPoolLoadMetricSourceTestCase.java 2008-10-23 05:16:30 UTC (rev 1989)
@@ -21,13 +21,10 @@
*/
package org.jboss.modcluster.load.metric;
-import java.util.Collection;
-
import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
-import org.jboss.modcluster.load.metric.impl.MBeanQueryLoadContext;
-import org.jboss.modcluster.load.metric.impl.MBeanQueryLoadMetricSource;
+import org.easymock.EasyMock;
import org.jboss.modcluster.load.metric.impl.ThreadPoolLoadMetricSource;
/**
@@ -38,12 +35,11 @@
{
public ThreadPoolLoadMetricSourceTestCase() throws MalformedObjectNameException
{
- super(ThreadPoolLoadMetricSource.DEFAULT_PATTERN);
+ this(EasyMock.createStrictMock(MBeanServer.class));
}
- @Override
- protected MBeanQueryLoadMetricSource createSource(Collection<LoadMetric<MBeanQueryLoadContext>> metrics, MBeanServer server) throws MalformedObjectNameException
+ private ThreadPoolLoadMetricSourceTestCase(MBeanServer server) throws MalformedObjectNameException
{
- return new ThreadPoolLoadMetricSource(metrics, server);
+ super(new ThreadPoolLoadMetricSource(server), ThreadPoolLoadMetricSource.DEFAULT_PATTERN, server);
}
}
15 years, 11 months
JBoss Native SVN: r1988 - trunk/mod_cluster/native/mod_proxy_cluster.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2008-10-22 17:44:32 -0400 (Wed, 22 Oct 2008)
New Revision: 1988
Modified:
trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c
Log:
Use jsessionid route to find the balancer.
Modified: trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c
===================================================================
--- trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c 2008-10-22 18:02:16 UTC (rev 1987)
+++ trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c 2008-10-22 21:44:32 UTC (rev 1988)
@@ -1247,12 +1247,60 @@
return OK;
}
+/**
+ * Find the balancer corresponding to the node information
+ */
+static const char *get_route_balancer(request_rec *r)
+{
+ proxy_balancer *balancer;
+ char *route = NULL;
+ char *sticky_used;
+ int i;
+ void *sconf = r->server->module_config;
+ proxy_server_conf *conf = (proxy_server_conf *)
+ ap_get_module_config(sconf, &proxy_module);
+
+ balancer = (proxy_balancer *)conf->balancers->elts;
+ for (i = 0; i < conf->balancers->nelts; i++, balancer++) {
+ route = get_route(r, balancer->sticky, r->uri, &sticky_used);
+ if (route) {
+ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
+ "cluster: Found value %s for "
+ "stickysession %s", route, balancer->sticky);
+ if ((route = strchr(route, '.')) != NULL )
+ route++;
+ if (route && *route) {
+ nodeinfo_t *ou;
+ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
+ "cluster: Found route %s", route);
+ if (node_storage->find_node(&ou, route) == APR_SUCCESS) {
+ if (!strcmp(balancer->name, ou->mess.balancer)) {
+ /* here we have the route and domain for find_session_route ... */
+ apr_table_setn(r->notes, "CLUSTER_ROUTE", route);
+ if (ou->mess.Domain[0] != '\0') {
+ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
+ "cluster: Found domain %s for %s", ou->mess.Domain, route);
+ apr_table_setn(r->notes, "CLUSTER_DOMAIN", ou->mess.Domain);
+ }
+ return balancer->name;
+ }
+ }
+ }
+ }
+ }
+ return NULL;
+}
+
/*
* See if we could map the request.
+ * first check is we have a balancer corresponding to the route.
+ * then search the balancer correspond to the context and host.
*/
static int proxy_cluster_trans(request_rec *r)
{
- char *balancer = get_context_host_balancer(r);
+ const char *balancer = get_route_balancer(r);
+ if (!balancer)
+ balancer = get_context_host_balancer(r);
ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_DEBUG, 0, r->server,
"proxy_cluster_trans for %d %s %s uri: %s",
15 years, 11 months
JBoss Native SVN: r1987 - trunk/mod_cluster/native/mod_proxy_cluster.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2008-10-22 14:02:16 -0400 (Wed, 22 Oct 2008)
New Revision: 1987
Modified:
trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c
Log:
Add get_route and remove duplicate code.
Modified: trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c
===================================================================
--- trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c 2008-10-22 16:49:00 UTC (rev 1986)
+++ trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c 2008-10-22 18:02:16 UTC (rev 1987)
@@ -565,6 +565,34 @@
}
/**
+ * Check that the request has a sessionid with a route
+ * @param r the request_rec.
+ * @param stickyval the cookie or/and parameter name.
+ * @param uri part of the URL to for the session parameter.
+ * @param sticky_used the string that was used to find the route
+ */
+static char *get_route(request_rec *r, const char *stickyval, char *uri, char **sticky_used)
+{
+ char *sticky, *sticky_path;
+ char *path;
+ char *route;
+
+ /* for 2.2.x the sticky parameter may contain 2 values */
+ sticky = sticky_path = apr_pstrdup(r->pool, stickyval);
+ if ((path = strchr(sticky, '|'))) {
+ *path++ = '\0';
+ sticky_path = path;
+ }
+ *sticky_used = sticky_path;
+ route = get_path_param(r->pool, uri , sticky_path);
+ if (!route) {
+ route = get_cookie_param(r, sticky);
+ *sticky_used = sticky;
+ }
+ return route;
+}
+
+/**
* Check that the request has a sessionid (even invalid)
* @param r the request_rec.
* @param balancer_name name of the balancer. (to find the balancer)
@@ -577,7 +605,7 @@
proxy_balancer *balancer = balance;
char *route;
char *uri = r->filename + 6;
- char *sticky_path, *sticky, *path;
+ char *sticky_used;
int i;
if (balancer == NULL) {
@@ -597,15 +625,7 @@
if (balancer->sticky == NULL)
return 0;
- /* for 2.2.x the sticky parameter may contain 2 values */
- sticky = sticky_path = apr_pstrdup(r->pool, balancer->sticky);
- if ((path = strchr(sticky, '|'))) {
- *path++ = '\0';
- sticky_path = path;
- }
- route = get_path_param(r->pool, uri , sticky_path);
- if (route == NULL)
- route = get_cookie_param(r, sticky);
+ route = get_route(r, balancer->sticky, uri, &sticky_used);
if (route) {
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
"mod_proxy_cluster: found route %s", route);
@@ -1353,22 +1373,13 @@
if (! (balancer->sticky_force & STSESSION))
return NULL;
- sticky = sticky_path = apr_pstrdup(r->pool, balancer->sticky);
- if ((path = strchr(sticky, '|'))) {
- *path++ = '\0';
- sticky_path = path;
+ *route = get_route(r, balancer->sticky, *url, sticky_used);
+ if (*route) {
+ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
+ "proxy: CLUSTER: Found value %s for "
+ "stickysession %s", *route, balancer->sticky);
}
-
- /* Try to find the sticky route inside url */
- *sticky_used = sticky_path;
- *route = get_path_param(r->pool, *url, sticky_path);
- if (!*route) {
- *route = get_cookie_param(r, sticky);
- *sticky_used = sticky;
- }
- ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
- "proxy: CLUSTER: Found value %s for "
- "stickysession %s", *route, balancer->sticky);
+
/*
* If we found a value for sticksession, find the first '.' within.
* Everything after '.' (if present) is our route.
15 years, 11 months
JBoss Native SVN: r1986 - in trunk/mod_cluster/src/test/java/org/jboss/modcluster: load and 1 other directory.
by jbossnative-commits@lists.jboss.org
Author: pferraro
Date: 2008-10-22 12:49:00 -0400 (Wed, 22 Oct 2008)
New Revision: 1986
Modified:
trunk/mod_cluster/src/test/java/org/jboss/modcluster/BasicClusterListenerTestCase.java
trunk/mod_cluster/src/test/java/org/jboss/modcluster/DefaultJBossWebEventHandlerTestCase.java
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/DynamicLoadBalanceFactorProviderTestCase.java
Log:
Remove references to junit3
Modified: trunk/mod_cluster/src/test/java/org/jboss/modcluster/BasicClusterListenerTestCase.java
===================================================================
--- trunk/mod_cluster/src/test/java/org/jboss/modcluster/BasicClusterListenerTestCase.java 2008-10-22 16:43:53 UTC (rev 1985)
+++ trunk/mod_cluster/src/test/java/org/jboss/modcluster/BasicClusterListenerTestCase.java 2008-10-22 16:49:00 UTC (rev 1986)
@@ -31,20 +31,20 @@
import org.apache.catalina.Server;
import org.apache.catalina.Service;
import org.easymock.EasyMock;
+import org.junit.Test;
-import junit.framework.TestCase;
-
/**
* @author Paul Ferraro
*
*/
-public class BasicClusterListenerTestCase extends TestCase
+public class BasicClusterListenerTestCase
{
private JBossWebEventHandler eventHandler = EasyMock.createStrictMock(JBossWebEventHandler.class);
private BasicClusterListener listener = new BasicClusterListener(this.eventHandler);
- public void testDeployWebApp()
+ @Test
+ public void deployWebApp()
{
Host host = EasyMock.createStrictMock(Host.class);
LifecycleContext context = EasyMock.createStrictMock(LifecycleContext.class);
@@ -62,7 +62,8 @@
EasyMock.reset(this.eventHandler, host, context);
}
- public void testDeployHost()
+ @Test
+ public void deployHost()
{
Engine engine = EasyMock.createStrictMock(Engine.class);
@@ -78,7 +79,8 @@
EasyMock.reset(engine);
}
- public void testUndeployWebApp()
+ @Test
+ public void undeployWebApp()
{
Host host = EasyMock.createStrictMock(Host.class);
LifecycleContext context = EasyMock.createStrictMock(LifecycleContext.class);
@@ -96,7 +98,8 @@
EasyMock.reset(this.eventHandler, host, context);
}
- public void testUndeployHost()
+ @Test
+ public void undeployHost()
{
Engine engine = EasyMock.createStrictMock(Engine.class);
@@ -112,7 +115,8 @@
EasyMock.reset(engine);
}
- public void testStartWebApp()
+ @Test
+ public void startWebApp()
{
LifecycleContext context = EasyMock.createStrictMock(LifecycleContext.class);
@@ -128,7 +132,8 @@
EasyMock.reset(this.eventHandler);
}
- public void testStartServer()
+ @Test
+ public void startServer()
{
LifecycleServer server = EasyMock.createStrictMock(LifecycleServer.class);
Service service = EasyMock.createStrictMock(Service.class);
@@ -164,7 +169,8 @@
EasyMock.reset(this.eventHandler, server, service, engine, container, childContainer);
}
- public void testStopWebApp()
+ @Test
+ public void stopWebApp()
{
LifecycleContext context = EasyMock.createStrictMock(LifecycleContext.class);
@@ -180,7 +186,8 @@
EasyMock.reset(this.eventHandler);
}
- public void testStopServer()
+ @Test
+ public void stopServer()
{
LifecycleServer server = EasyMock.createStrictMock(LifecycleServer.class);
Service service = EasyMock.createStrictMock(Service.class);
@@ -215,7 +222,8 @@
EasyMock.reset(this.eventHandler, server, service, engine, container, childContainer);
}
- public void testPeriodicEvent()
+ @Test
+ public void periodicEvent()
{
LifecycleEngine engine = EasyMock.createStrictMock(LifecycleEngine.class);
@@ -230,7 +238,7 @@
EasyMock.reset(this.eventHandler);
// Init
- this.testStartServer();
+ this.startServer();
// Test initialized
this.eventHandler.status(engine);
Modified: trunk/mod_cluster/src/test/java/org/jboss/modcluster/DefaultJBossWebEventHandlerTestCase.java
===================================================================
--- trunk/mod_cluster/src/test/java/org/jboss/modcluster/DefaultJBossWebEventHandlerTestCase.java 2008-10-22 16:43:53 UTC (rev 1985)
+++ trunk/mod_cluster/src/test/java/org/jboss/modcluster/DefaultJBossWebEventHandlerTestCase.java 2008-10-22 16:49:00 UTC (rev 1986)
@@ -68,10 +68,6 @@
private JBossWebEventHandler handler;
- /**
- * @{inheritDoc}
- * @see junit.framework.TestCase#setUp()
- */
@Before
public void construct() throws Exception
{
Modified: trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/DynamicLoadBalanceFactorProviderTestCase.java
===================================================================
--- trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/DynamicLoadBalanceFactorProviderTestCase.java 2008-10-22 16:43:53 UTC (rev 1985)
+++ trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/DynamicLoadBalanceFactorProviderTestCase.java 2008-10-22 16:49:00 UTC (rev 1986)
@@ -45,10 +45,6 @@
private final DynamicLoadBalanceFactorProvider provider = new DynamicLoadBalanceFactorProvider(Arrays.asList(this.source1, this.source2));
- /**
- * @{inheritDoc}
- * @see junit.framework.TestCase#setUp()
- */
@Before
public void init() throws Exception
{
15 years, 11 months
JBoss Native SVN: r1985 - trunk/mod_cluster/src/test/java/org/jboss/modcluster.
by jbossnative-commits@lists.jboss.org
Author: pferraro
Date: 2008-10-22 12:43:53 -0400 (Wed, 22 Oct 2008)
New Revision: 1985
Modified:
trunk/mod_cluster/src/test/java/org/jboss/modcluster/ModClusterServiceTestCase.java
Log:
Unit tests pass again
Modified: trunk/mod_cluster/src/test/java/org/jboss/modcluster/ModClusterServiceTestCase.java
===================================================================
--- trunk/mod_cluster/src/test/java/org/jboss/modcluster/ModClusterServiceTestCase.java 2008-10-22 16:23:30 UTC (rev 1984)
+++ trunk/mod_cluster/src/test/java/org/jboss/modcluster/ModClusterServiceTestCase.java 2008-10-22 16:43:53 UTC (rev 1985)
@@ -272,9 +272,9 @@
EasyMock.expect(this.partition.getDistributedReplicantManager()).andReturn(drm);
drm.add("myservice:domain", this.modClusterService.drmEntry);
+ EasyMock.expect(engine.getJvmRoute()).andReturn("host1");
EasyMock.expect(engine.getService()).andReturn(service);
EasyMock.expect(service.findConnectors()).andReturn(new Connector[] { connector });
- EasyMock.expect(engine.getJvmRoute()).andReturn("host1");
EasyMock.expect(this.nodeConfig.getDomain()).andReturn("domain");
EasyMock.expect(this.nodeConfig.getFlushPackets()).andReturn(Boolean.TRUE);
@@ -427,6 +427,8 @@
{
Context context = EasyMock.createStrictMock(Context.class);
+ EasyMock.replay(context);
+
// Test not initialized
try
{
@@ -438,49 +440,51 @@
{
// Expected
}
+
+ EasyMock.verify(context);
+ EasyMock.reset(context);
init();
// Test context not started
- Container container = EasyMock.createStrictMock(Container.class);
+ Host host = EasyMock.createStrictMock(Host.class);
- recordAddContext(context, container);
+ recordAddContext(context, host);
- EasyMock.replay(context, container);
+ EasyMock.replay(context, host);
this.modClusterService.addContext(context);
- EasyMock.verify(context, container);
- EasyMock.reset(context, container);
+ EasyMock.verify(context, host);
+ EasyMock.reset(context, host);
// Test context started
Engine engine = EasyMock.createStrictMock(Engine.class);
- Host host = EasyMock.createStrictMock(Host.class);
Capture<MCMPRequest> capturedRequest = new Capture<MCMPRequest>();
// Expect log message
EasyMock.expect(context.getPath()).andReturn("/context");
- EasyMock.expect(context.getParent()).andReturn(container);
- EasyMock.expect(container.getName()).andReturn("parent-container");
+ EasyMock.expect(context.getParent()).andReturn(host);
+ EasyMock.expect(host.getName()).andReturn("host");
EasyMock.expect(context.isStarted()).andReturn(true);
// Building request
- EasyMock.expect(context.getPath()).andReturn("/context");
EasyMock.expect(context.getParent()).andReturn(host);
+ EasyMock.expect(host.getParent()).andReturn(engine);
+ EasyMock.expect(engine.getJvmRoute()).andReturn("host1");
+ EasyMock.expect(context.getParent()).andReturn(host);
EasyMock.expect(host.getName()).andReturn("host");
EasyMock.expect(host.findAliases()).andReturn(new String[] { "alias1", "alias2" });
- EasyMock.expect(context.getParent()).andReturn(container);
- EasyMock.expect(container.getParent()).andReturn(engine);
- EasyMock.expect(engine.getJvmRoute()).andReturn("host1");
+ EasyMock.expect(context.getPath()).andReturn("/context");
this.clusteredMCMPHandler.sendRequest(EasyMock.capture(capturedRequest));
- EasyMock.replay(this.clusteredMCMPHandler, context, container, engine, host);
+ EasyMock.replay(this.clusteredMCMPHandler, context, engine, host);
this.modClusterService.addContext(context);
- EasyMock.verify(this.clusteredMCMPHandler, context, container, engine, host);
+ EasyMock.verify(this.clusteredMCMPHandler, context, engine, host);
MCMPRequest request = capturedRequest.getValue();
@@ -495,7 +499,7 @@
Assert.assertEquals("/context", parameters.get("Context"));
Assert.assertEquals("host,alias1,alias2", parameters.get("Alias"));
- EasyMock.reset(this.clusteredMCMPHandler, context, container, engine, host);
+ EasyMock.reset(this.clusteredMCMPHandler, context, engine, host);
}
@Test
@@ -503,6 +507,8 @@
{
Context context = EasyMock.createStrictMock(Context.class);
+ EasyMock.replay(context);
+
// Test not initialized
try
{
@@ -514,36 +520,38 @@
{
// Expected
}
+
+ EasyMock.verify(context);
+ EasyMock.reset(context);
init();
// Test initialized
- Container container = EasyMock.createStrictMock(Container.class);
Engine engine = EasyMock.createStrictMock(Engine.class);
Host host = EasyMock.createStrictMock(Host.class);
Capture<MCMPRequest> capturedRequest = new Capture<MCMPRequest>();
// Expect log message
EasyMock.expect(context.getPath()).andReturn("/context");
- EasyMock.expect(context.getParent()).andReturn(container);
- EasyMock.expect(container.getName()).andReturn("parent-container");
-
+ EasyMock.expect(context.getParent()).andReturn(host);
+ EasyMock.expect(host.getName()).andReturn("host");
+
// Building request
- EasyMock.expect(context.getPath()).andReturn("/context");
EasyMock.expect(context.getParent()).andReturn(host);
+ EasyMock.expect(host.getParent()).andReturn(engine);
+ EasyMock.expect(engine.getJvmRoute()).andReturn("host1");
+ EasyMock.expect(context.getParent()).andReturn(host);
EasyMock.expect(host.getName()).andReturn("host");
EasyMock.expect(host.findAliases()).andReturn(new String[] { "alias1", "alias2" });
- EasyMock.expect(context.getParent()).andReturn(container);
- EasyMock.expect(container.getParent()).andReturn(engine);
- EasyMock.expect(engine.getJvmRoute()).andReturn("host1");
+ EasyMock.expect(context.getPath()).andReturn("/context");
this.clusteredMCMPHandler.sendRequest(EasyMock.capture(capturedRequest));
- EasyMock.replay(this.clusteredMCMPHandler, context, container, engine, host);
+ EasyMock.replay(this.clusteredMCMPHandler, context, engine, host);
this.modClusterService.startContext(context);
- EasyMock.verify(this.clusteredMCMPHandler, context, container, engine, host);
+ EasyMock.verify(this.clusteredMCMPHandler, context, engine, host);
MCMPRequest request = capturedRequest.getValue();
@@ -558,7 +566,7 @@
Assert.assertEquals("/context", parameters.get("Context"));
Assert.assertEquals("host,alias1,alias2", parameters.get("Alias"));
- EasyMock.reset(this.clusteredMCMPHandler, context, container, engine, host);
+ EasyMock.reset(this.clusteredMCMPHandler, context, engine, host);
}
@Test
@@ -566,6 +574,8 @@
{
Context context = EasyMock.createStrictMock(Context.class);
+ EasyMock.replay(context);
+
// Test not initialized
try
{
@@ -577,36 +587,38 @@
{
// Expected
}
+
+ EasyMock.verify(context);
+ EasyMock.reset(context);
init();
// Test initialized
- Container container = EasyMock.createStrictMock(Container.class);
Engine engine = EasyMock.createStrictMock(Engine.class);
Host host = EasyMock.createStrictMock(Host.class);
Capture<MCMPRequest> capturedRequest = new Capture<MCMPRequest>();
// Expect log message
EasyMock.expect(context.getPath()).andReturn("/context");
- EasyMock.expect(context.getParent()).andReturn(container);
- EasyMock.expect(container.getName()).andReturn("parent-container");
-
+ EasyMock.expect(context.getParent()).andReturn(host);
+ EasyMock.expect(host.getName()).andReturn("host");
+
// Building request
- EasyMock.expect(context.getPath()).andReturn("/context");
EasyMock.expect(context.getParent()).andReturn(host);
+ EasyMock.expect(host.getParent()).andReturn(engine);
+ EasyMock.expect(engine.getJvmRoute()).andReturn("host1");
+ EasyMock.expect(context.getParent()).andReturn(host);
EasyMock.expect(host.getName()).andReturn("host");
EasyMock.expect(host.findAliases()).andReturn(new String[] { "alias1", "alias2" });
- EasyMock.expect(context.getParent()).andReturn(container);
- EasyMock.expect(container.getParent()).andReturn(engine);
- EasyMock.expect(engine.getJvmRoute()).andReturn("host1");
+ EasyMock.expect(context.getPath()).andReturn("/context");
this.clusteredMCMPHandler.sendRequest(EasyMock.capture(capturedRequest));
- EasyMock.replay(this.clusteredMCMPHandler, context, container, engine, host);
+ EasyMock.replay(this.clusteredMCMPHandler, context, engine, host);
this.modClusterService.stopContext(context);
- EasyMock.verify(this.clusteredMCMPHandler, context, container, engine, host);
+ EasyMock.verify(this.clusteredMCMPHandler, context, engine, host);
MCMPRequest request = capturedRequest.getValue();
@@ -621,7 +633,7 @@
Assert.assertEquals("/context", parameters.get("Context"));
Assert.assertEquals("host,alias1,alias2", parameters.get("Alias"));
- EasyMock.reset(this.clusteredMCMPHandler, context, container, engine, host);
+ EasyMock.reset(this.clusteredMCMPHandler, context, engine, host);
}
@Test
@@ -644,48 +656,48 @@
init();
// Test initialized - no jvm route
- Container container = EasyMock.createStrictMock(Container.class);
Engine engine = EasyMock.createStrictMock(Engine.class);
+ Host host = EasyMock.createStrictMock(Host.class);
- this.recordRemoveContext(context, container, engine);
+ this.recordRemoveContext(context, host, engine);
- EasyMock.replay(context, container, engine);
+ EasyMock.replay(context, host, engine);
this.modClusterService.removeContext(context);
- EasyMock.verify(context, container, engine);
- EasyMock.reset(context, container, engine);
+ EasyMock.verify(context, host, engine);
+ EasyMock.reset(context, host, engine);
// Test initialized - jvm route exists
- Host host = EasyMock.createStrictMock(Host.class);
Capture<MCMPRequest> capturedRequest = new Capture<MCMPRequest>();
// Expect log message
EasyMock.expect(context.getPath()).andReturn("/context");
- EasyMock.expect(context.getParent()).andReturn(container);
- EasyMock.expect(container.getName()).andReturn("parent-container");
-
- EasyMock.expect(context.getParent()).andReturn(container);
- EasyMock.expect(container.getParent()).andReturn(engine);
+ EasyMock.expect(context.getParent()).andReturn(host);
+ EasyMock.expect(host.getName()).andReturn("host");
+
+ // jvm route null check
+ EasyMock.expect(context.getParent()).andReturn(host);
+ EasyMock.expect(host.getParent()).andReturn(engine);
EasyMock.expect(engine.getJvmRoute()).andReturn("host1");
-
+
// Building request
- EasyMock.expect(context.getPath()).andReturn("/context");
EasyMock.expect(context.getParent()).andReturn(host);
+ EasyMock.expect(host.getParent()).andReturn(engine);
+ EasyMock.expect(engine.getJvmRoute()).andReturn("host1");
+ EasyMock.expect(context.getParent()).andReturn(host);
EasyMock.expect(host.getName()).andReturn("host");
EasyMock.expect(host.findAliases()).andReturn(new String[] { "alias1", "alias2" });
- EasyMock.expect(context.getParent()).andReturn(container);
- EasyMock.expect(container.getParent()).andReturn(engine);
- EasyMock.expect(engine.getJvmRoute()).andReturn("host1");
+ EasyMock.expect(context.getPath()).andReturn("/context");
this.clusteredMCMPHandler.sendRequest(EasyMock.capture(capturedRequest));
- EasyMock.replay(this.clusteredMCMPHandler, context, container, engine, host);
+ EasyMock.replay(this.clusteredMCMPHandler, context, engine, host);
this.modClusterService.removeContext(context);
- EasyMock.verify(this.clusteredMCMPHandler, context, container, engine, host);
+ EasyMock.verify(this.clusteredMCMPHandler, context, engine, host);
MCMPRequest request = capturedRequest.getValue();
@@ -700,7 +712,7 @@
Assert.assertEquals("/context", parameters.get("Context"));
Assert.assertEquals("host,alias1,alias2", parameters.get("Alias"));
- EasyMock.reset(this.clusteredMCMPHandler, context, container, engine, host);
+ EasyMock.reset(this.clusteredMCMPHandler, context, engine, host);
}
@SuppressWarnings("unchecked")
15 years, 11 months