Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,16 @@ target
.idea
*.ipr
*.iml

# Native built files
native/*/*.log
native/*/*.slo
native/*/*.so
native/*/*.lo
native/*/*.o
native/*/.libs/
native/*/Makefile
native/*/autom4te.cache/
native/*/config.status
native/*/configure

4 changes: 0 additions & 4 deletions demo/client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
<artifactId>mod_cluster-demo-client</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
</dependency>
<dependency>
<groupId>jfree</groupId>
<artifactId>jfreechart</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,7 @@ private JPanel createServerLoadControlPanel() {

EnumSet<ServerLoadServlets> es = EnumSet.allOf(ServerLoadServlets.class);
Vector<ServerLoadServlets> v = new Vector<ServerLoadServlets>(es);
// Don't parametrize as this breaks JDK 1.6 compilation
final JComboBox targetLoadServletCombo = new JComboBox(v);
targetLoadServletCombo.setRenderer(new ServerLoadServletCellRenderer());
gridBagConstraints = new GridBagConstraints();
Expand Down Expand Up @@ -930,13 +931,14 @@ public void run() {

}

// Don't parametrize as this breaks JDK 1.6 compilation
private class ServerLoadServletCellRenderer extends JLabel implements ListCellRenderer {
private static final long serialVersionUID = -8010662328204072428L;

public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
boolean cellHasFocus) {
setText(value.toString());
setToolTipText(((ServerLoadServlets) value).getDescription());
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
this.setText(value.toString());
this.setToolTipText(((ServerLoadServlets) value).getDescription());
return this;
}
}
Expand Down
8 changes: 4 additions & 4 deletions demo/server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>catalina</artifactId>
<groupId>org.jboss.spec.javax.servlet</groupId>
<artifactId>jboss-servlet-api_3.0_spec</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,16 @@
package org.jboss.modcluster.demo.servlet;

import java.io.IOException;
import java.net.URI;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpMethod;
import org.apache.commons.httpclient.methods.HeadMethod;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpHead;
import org.apache.http.client.utils.HttpClientUtils;
import org.apache.http.impl.client.DefaultHttpClient;

/**
* @author Paul Ferraro
Expand All @@ -46,8 +48,7 @@ public class ActiveSessionsLoadServlet extends LoadServlet {
@Override
protected void doHead(HttpServletRequest request, HttpServletResponse response) {
HttpSession session = request.getSession(true);
this.log("Handling session load request from: " + request.getRequestURL().toString() + ", using session id: "
+ session.getId());
this.log("Handling session load request from: " + request.getRequestURL().toString() + ", using session id: " + session.getId());
}

/**
Expand All @@ -59,16 +60,19 @@ protected void doHead(HttpServletRequest request, HttpServletResponse response)
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
int count = Integer.parseInt(this.getParameter(request, COUNT, "20"));

String url = this.createLocalURL(request, null);
URI uri = this.createLocalURI(request, null);

this.log("Sending " + count + " requests to: " + url);
this.log("Sending " + count + " requests to: " + uri);

for (int i = 0; i < count; ++i) {
HttpClient client = new HttpClient();
HttpMethod method = new HeadMethod(url);
client.executeMethod(method);
HttpClient client = new DefaultHttpClient();
try {
for (int i = 0; i < count; ++i) {
HttpClientUtils.closeQuietly(client.execute(new HttpHead(uri)));
}
} finally {
HttpClientUtils.closeQuietly(client);
}

this.writeLocalName(request, response);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,19 @@
package org.jboss.modcluster.demo.servlet;

import java.io.IOException;
import java.net.URI;
import java.util.Collections;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.HttpMethod;
import org.apache.commons.httpclient.methods.HeadMethod;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpHead;
import org.apache.http.client.params.ClientPNames;
import org.apache.http.client.utils.HttpClientUtils;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.HttpParams;

/**
* @author Paul Ferraro
Expand All @@ -56,12 +60,12 @@ protected void service(HttpServletRequest request, HttpServletResponse response)

long end = System.currentTimeMillis() + duration;

String url = this.createLocalURL(request, Collections.singletonMap(END, String.valueOf(end)));
Runnable task = new ExecuteMethodTask(url);
URI uri = this.createLocalURI(request, Collections.singletonMap(END, String.valueOf(end)));
Runnable task = new ExecuteMethodTask(uri);

int count = Integer.parseInt(this.getParameter(request, COUNT, "50"));

this.log("Sending " + count + " concurrent requests to: " + url);
this.log("Sending " + count + " concurrent requests to: " + uri);

Thread[] threads = new Thread[count];

Expand All @@ -86,39 +90,46 @@ protected void service(HttpServletRequest request, HttpServletResponse response)
long end = Long.parseLong(parameter);

if (end > System.currentTimeMillis()) {
String url = this.createLocalURL(request, Collections.singletonMap(END, String.valueOf(end)));
response.setStatus(307);
response.setHeader("location", response.encodeRedirectURL(url));
URI uri = this.createLocalURI(request, Collections.singletonMap(END, String.valueOf(end)));
response.setStatus(HttpServletResponse.SC_TEMPORARY_REDIRECT);
response.setHeader("location", response.encodeRedirectURL(uri.toString()));
}
}
}

private class ExecuteMethodTask implements Runnable {
private final String url;
private final URI uri;

ExecuteMethodTask(String url) {
this.url = url;
ExecuteMethodTask(URI uri) {
this.uri = uri;
}

@Override
public void run() {
HttpClient client = new HttpClient();
String url = this.url;
URI uri = this.uri;

HttpClient client = new DefaultHttpClient();
try {
while (url != null) {
HttpMethod method = new HeadMethod(url);
while (uri != null) {
HttpHead head = new HttpHead(uri);
HttpParams params = head.getParams();
// Disable auto redirect following, to allow circular redirect
method.setFollowRedirects(false);

int code = client.executeMethod(method);

url = (code == 307) ? method.getResponseHeader("location").getValue() : null;
params.setParameter(ClientPNames.HANDLE_REDIRECTS, Boolean.FALSE);
head.setParams(params);

HttpResponse response = client.execute(head);
try {
int code = response.getStatusLine().getStatusCode();

uri = (code == HttpServletResponse.SC_TEMPORARY_REDIRECT) ? URI.create(response.getFirstHeader("location").getValue()) : null;
} finally {
HttpClientUtils.closeQuietly(response);
}
}
} catch (HttpException e) {
BusyConnectorsLoadServlet.this.log(e.getLocalizedMessage(), e);
} catch (IOException e) {
BusyConnectorsLoadServlet.this.log(e.getLocalizedMessage(), e);
} finally {
HttpClientUtils.closeQuietly(client);
}
}
}
Expand Down
Loading