Author: pferraro
Date: 2009-05-18 17:33:26 -0400 (Mon, 18 May 2009)
New Revision: 2438
Modified:
trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/BusyConnectorsLoadServlet.java
Log:
Avoid maxing out connector thread pool
Modified:
trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/BusyConnectorsLoadServlet.java
===================================================================
---
trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/BusyConnectorsLoadServlet.java 2009-05-18
21:08:48 UTC (rev 2437)
+++
trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/BusyConnectorsLoadServlet.java 2009-05-18
21:33:26 UTC (rev 2438)
@@ -67,10 +67,29 @@
log.info("Sending " + count + " concurrent requests to: " +
url);
+ Thread[] threads = new Thread[count];
+
for (int i = 0; i < count; ++i)
{
- new Thread(task).start();
+ threads[i] = new Thread(task);
}
+
+ for (int i = 0; i < count; ++i)
+ {
+ threads[i].start();
+ }
+
+ for (int i = 0; i < count; ++i)
+ {
+ try
+ {
+ threads[i].join();
+ }
+ catch (InterruptedException e)
+ {
+ Thread.currentThread().interrupt();
+ }
+ }
}
else
{
@@ -79,8 +98,7 @@
if (end > System.currentTimeMillis())
{
String url = this.createLocalURL(request, Collections.singletonMap(END,
String.valueOf(end)));
- Runnable task = new ExecuteMethodTask(url);
- new Thread(task).start();
+ response.sendRedirect(response.encodeRedirectURL(url));
}
}
@@ -101,11 +119,19 @@
Thread.yield();
HttpClient client = new HttpClient();
- HttpMethod method = new HeadMethod(this.url);
+ String url = this.url;
+
try
{
- client.executeMethod(method);
+ while (url != null)
+ {
+ HttpMethod method = new HeadMethod(url);
+
+ int code = client.executeMethod(method);
+
+ url = ((code >= 300) || (code < 400)) ?
method.getResponseHeader("location").getValue() : null;
+ }
}
catch (HttpException e)
{
Show replies by date