JBoss Native SVN: r1891 - in trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo: servlet and 1 other directory.
by jbossnative-commits@lists.jboss.org
Author: pferraro
Date: 2008-09-23 10:48:47 -0400 (Tue, 23 Sep 2008)
New Revision: 1891
Modified:
trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/client/RequestDriver.java
trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/RecordServlet.java
Log:
Fixed constants usage
Modified: trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/client/RequestDriver.java
===================================================================
--- trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/client/RequestDriver.java 2008-09-23 13:53:53 UTC (rev 1890)
+++ trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/client/RequestDriver.java 2008-09-23 14:48:47 UTC (rev 1891)
@@ -11,6 +11,8 @@
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
+import org.jboss.modcluster.demo.Constants;
+
/**
* @author Brian Stansberry
* @version $Id: PerfTest2.java 68892 2008-01-11 14:39:07Z bela(a)jboss.com $
@@ -19,8 +21,6 @@
{
private Client[] clients;
- public static final String NODE_HEADER = "X-ClusterNode";
-
private final ConcurrentMap<String, AtomicInteger> requestCounts = new ConcurrentHashMap<String, AtomicInteger>();
private final ConcurrentMap<String, AtomicInteger> sessionCounts = new ConcurrentHashMap<String, AtomicInteger>();
@@ -300,7 +300,7 @@
}
input.close(); // discard data
- String handlerNode = conn.getHeaderField(NODE_HEADER);
+ String handlerNode = conn.getHeaderField(Constants.NODE_HEADER);
String tmp_cookie = conn.getHeaderField("set-cookie");
if (tmp_cookie != null && cookie == null)
{
Modified: trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/RecordServlet.java
===================================================================
--- trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/RecordServlet.java 2008-09-23 13:53:53 UTC (rev 1890)
+++ trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/RecordServlet.java 2008-09-23 14:48:47 UTC (rev 1891)
@@ -43,6 +43,7 @@
private static final String DESTROY = "destroy";
private static final String TIMEOUT = "timeout";
+ private static final String JVM_ROUTE = "jvmRoute";
/**
* @{inheritDoc}
@@ -54,7 +55,7 @@
super.init(config);
Engine engine = (Engine) ServerFactory.getServer().findServices()[0].getContainer();
- config.getServletContext().setAttribute("jvmRoute", engine.getJvmRoute());
+ config.getServletContext().setAttribute(JVM_ROUTE, engine.getJvmRoute());
}
/**
@@ -82,6 +83,6 @@
}
}
- response.setHeader(Constants.NODE_HEADER, (String) this.getServletContext().getAttribute("jvmRoute"));
+ response.setHeader(Constants.NODE_HEADER, (String) this.getServletContext().getAttribute(JVM_ROUTE));
}
}
16 years, 3 months
JBoss Native SVN: r1890 - trunk/mod_cluster.
by jbossnative-commits@lists.jboss.org
Author: pferraro
Date: 2008-09-23 09:53:53 -0400 (Tue, 23 Sep 2008)
New Revision: 1890
Added:
trunk/mod_cluster/build-demo.xml
Log:
created
Added: trunk/mod_cluster/build-demo.xml
===================================================================
--- trunk/mod_cluster/build-demo.xml (rev 0)
+++ trunk/mod_cluster/build-demo.xml 2008-09-23 13:53:53 UTC (rev 1890)
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--======================================================================-->
+<!-- -->
+<!-- JBoss, the OpenSource J2EE webOS -->
+<!-- -->
+<!-- Distributable under LGPL license. -->
+<!-- See terms of license at http://www.gnu.org. -->
+<!-- -->
+<!--======================================================================-->
+<project default="main" name="JBoss/mod_cluster Demo" xmlns:server="http://jboss.org/ns/test/ant/server">
+
+ <property environment="env"></property>
+
+ <!-- TODO: consolidate common properties with build-test.xml -->
+ <property name="module.output" location="${basedir}/target"/>
+ <property name="module.src" location="${basedir}/src"/>
+
+ <property name="demo.src" location="${module.src}/demo"/>
+ <property name="demo.src.java" location="${demo.src}/java"/>
+ <property name="demo.src.resources" location="${demo.src}/resources"/>
+ <property name="demo.output" location="${module.output}/demo"/>
+ <property name="demo.output.classes" location="${demo.output}/classes"/>
+ <property name="demo.output.client" location="${demo.output}/client"/>
+ <property name="demo.output.server" location="${demo.output}/server"/>
+ <property name="demo.client.jar" value="mod-cluster-demo.jar"></property>
+ <property name="demo.server.war" value="demo.war"></property>
+ <property name="demo.dependencies.lib" location="${module.output}/dependencies/lib"></property>
+
+ <path id="demo">
+ <pathelement location="${demo.dependencies.lib}/*.jar"/>
+ </path>
+
+ <target name="main" depends="init, compile-demo">
+ <jar destfile="${demo.output.client}/${demo.client.jar}">
+ <fileset dir="${demo.output.classes}" excludes="**/server/**"></fileset>
+ <manifest>
+ <attribute name="Main-Class" value="org.jboss.modcluster.demo.client.ModClusterDemo"/>
+ </manifest>
+ </jar>
+ <war destfile="${demo.output.server}/${demo.server.war}" webxml="${demo.src.resources}/web.xml">
+ <classes dir="${demo.output.classes}" excludes="**/client/**"></classes>
+ <lib dir="${demo.dependencies.lib}">
+ <include name="commons-httpclient.jar"/>
+ <include name="commons-codec.jar"/>
+ </lib>
+ </war>
+ </target>
+
+ <target name="init">
+ <mkdir dir="${demo.output}"/>
+ <mkdir dir="${demo.output.client}"/>
+ <mkdir dir="${demo.output.server}"/>
+ </target>
+
+ <target name="compile-demo">
+ <!-- Why doesn't this work? -->
+ <!--javac target="${demo.output.classes}" srcdir="${demo.src.java}" classpathref="demo"/-->
+ </target>
+
+ <target name="run-demo" depends="main">
+ <java jar="${demo.output.client}/${demo.client.jar}" classpathref="demo" fork="true"></java>
+ </target>
+</project>
\ No newline at end of file
16 years, 3 months
JBoss Native SVN: r1889 - trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo.
by jbossnative-commits@lists.jboss.org
Author: pferraro
Date: 2008-09-23 00:50:40 -0400 (Tue, 23 Sep 2008)
New Revision: 1889
Added:
trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/Constants.java
Log:
Share constants
Added: trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/Constants.java
===================================================================
--- trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/Constants.java (rev 0)
+++ trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/Constants.java 2008-09-23 04:50:40 UTC (rev 1889)
@@ -0,0 +1,31 @@
+/*
+ * 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.demo;
+
+/**
+ * @author Paul Ferraro
+ *
+ */
+public interface Constants
+{
+ public static final String NODE_HEADER = "X-ClusterNode";
+}
16 years, 3 months
JBoss Native SVN: r1888 - trunk/mod_cluster.
by jbossnative-commits@lists.jboss.org
Author: pferraro
Date: 2008-09-23 00:50:04 -0400 (Tue, 23 Sep 2008)
New Revision: 1888
Modified:
trunk/mod_cluster/.classpath
Log:
Add separate build target for demo
Modified: trunk/mod_cluster/.classpath
===================================================================
--- trunk/mod_cluster/.classpath 2008-09-23 04:49:31 UTC (rev 1887)
+++ trunk/mod_cluster/.classpath 2008-09-23 04:50:04 UTC (rev 1888)
@@ -2,7 +2,7 @@
<classpath>
<classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
- <classpathentry kind="src" path="src/demo/java"/>
+ <classpathentry kind="src" output="target/demo/classes" path="src/demo/java"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="var" path="M2_REPO/org/jboss/cluster/jboss-ha-server-api/1.1.0.GA/jboss-ha-server-api-1.1.0.GA.jar"/>
<classpathentry kind="var" path="M2_REPO/jboss/web/jbossweb/2.1.1.CR6/jbossweb-2.1.1.CR6.jar"/>
16 years, 3 months
JBoss Native SVN: r1887 - trunk/mod_cluster.
by jbossnative-commits@lists.jboss.org
Author: pferraro
Date: 2008-09-23 00:49:31 -0400 (Tue, 23 Sep 2008)
New Revision: 1887
Modified:
trunk/mod_cluster/pom.xml
Log:
Add demo profile
Modified: trunk/mod_cluster/pom.xml
===================================================================
--- trunk/mod_cluster/pom.xml 2008-09-23 04:48:55 UTC (rev 1886)
+++ trunk/mod_cluster/pom.xml 2008-09-23 04:49:31 UTC (rev 1887)
@@ -226,30 +226,30 @@
</activation>
<build>
<plugins>
- <!-- The individual integration tests are built and run using Ant -->
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-antrun-plugin</artifactId>
- <executions>
- <execution>
- <id>build-tests</id>
- <goals>
- <goal>run</goal>
- </goals>
- <phase>integration-test</phase>
- <configuration>
- <tasks>
-
- <!-- Execute the Test Build -->
- <ant antfile="build-test.xml" target="main" />
-
- <!-- Execute the integration tests that require httpd -->
- <ant antfile="build-test.xml" target="tests-apache-integration" />
-
- </tasks>
- </configuration>
- </execution>
- </executions>
+ <!-- The individual integration tests are built and run using Ant -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>build-tests</id>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <phase>integration-test</phase>
+ <configuration>
+ <tasks>
+
+ <!-- Execute the Test Build -->
+ <ant antfile="build-test.xml" target="main" />
+
+ <!-- Execute the integration tests that require httpd -->
+ <ant antfile="build-test.xml" target="tests-apache-integration" />
+
+ </tasks>
+ </configuration>
+ </execution>
+ </executions>
<dependencies>
<dependency>
<groupId>ant</groupId>
@@ -262,9 +262,73 @@
<version>4.4</version>
</dependency>
</dependencies>
- </plugin>
+ </plugin>
</plugins>
</build>
</profile>
+
+ <profile>
+ <id>demo</id>
+ <activation>
+ <activeByDefault>false</activeByDefault>
+ <property>
+ <name>maven.demo</name>
+ <value>true</value>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-core-dependencies</id>
+ <phase>process-resources</phase>
+ <goals>
+ <goal>copy-dependencies</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.jboss.native</groupId>
+ <artifactId>mod-cluster</artifactId>
+ </artifactItem>
+ </artifactItems>
+ <outputDirectory>${project.build.directory}/dependencies/lib</outputDirectory>
+ <overWriteIfNewer>true</overWriteIfNewer>
+ <stripVersion>true</stripVersion>
+ <!-- <excludeTransitive>true</excludeTransitive> -->
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>build-demo</id>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <tasks>
+
+ <!-- Execute the Test Build -->
+ <ant antfile="build-demo.xml" target="main" />
+
+ <!-- Execute the demo that require httpd -->
+ <ant antfile="build-demo.xml" target="run-demo" />
+
+ </tasks>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
</profiles>
</project>
16 years, 3 months
JBoss Native SVN: r1886 - trunk/mod_cluster.
by jbossnative-commits@lists.jboss.org
Author: pferraro
Date: 2008-09-23 00:48:55 -0400 (Tue, 23 Sep 2008)
New Revision: 1886
Modified:
trunk/mod_cluster/build-test.xml
Log:
Fix module name
Modified: trunk/mod_cluster/build-test.xml
===================================================================
--- trunk/mod_cluster/build-test.xml 2008-09-23 04:46:47 UTC (rev 1885)
+++ trunk/mod_cluster/build-test.xml 2008-09-23 04:48:55 UTC (rev 1886)
@@ -60,14 +60,14 @@
<property name="node1.http.url" value="http://${node1}:8080" />
<property name="node1.jndi.url" value="jnp://${node1}:1099" />
<property name="node1.jgroups.bind_addr" value="${node1}" />
- <property name="node2" value="${env.MYTESTIP_3}" />
+ <!--property name="node2" value="${env.MYTESTIP_3}" />
<property name="node2.http.url" value="http://${node2}:8080" />
<property name="node2.jndi.url" value="jnp://${node2}:1099" />
<property name="node2.jgroups.bind_addr" value="${node2}" />
<property name="node3" value="${env.MYTESTIP_4}" />
<property name="node3.http.url" value="http://${node3}:8080" />
<property name="node3.jndi.url" value="jnp://${node3}:1099" />
- <property name="node3.jgroups.bind_addr" value="${node3}" />
+ <property name="node3.jgroups.bind_addr" value="${node3}" /-->
<!-- UDP Group, must be done before server-config.xml -->
<!-- The value of the -u option passed to jboss -->
@@ -108,7 +108,7 @@
<import file="${location.dependencies.unpacked.jboss-test:jboss.test}/server-config.xml" />
<!-- Module name(s) & version -->
- <property name="module.name" value="ejb3" />
+ <property name="module.name" value="mod-cluster" />
<property name="module.Name" value="JBoss Testsuite" />
<property name="module.version" value="DEV" />
<property name="module.source" value="${basedir}/src" />
@@ -317,7 +317,7 @@
config="${location.apache.config}" action-type="start" />
- <server:start name="mod-cluster-0" />
+ <server:start name="mod-cluster-0" />
<server:start name="mod-cluster-1" />
<echo message="Nodes have started, waiting for cluster to stablize..." />
16 years, 3 months
JBoss Native SVN: r1885 - trunk/mod_cluster/src/main/java/org/jboss/modcluster.
by jbossnative-commits@lists.jboss.org
Author: pferraro
Date: 2008-09-23 00:46:47 -0400 (Tue, 23 Sep 2008)
New Revision: 1885
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ModClusterServiceMBean.java
Log:
Add isMasterNode()
Modified: trunk/mod_cluster/src/main/java/org/jboss/modcluster/ModClusterServiceMBean.java
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/ModClusterServiceMBean.java 2008-09-23 04:45:47 UTC (rev 1884)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/ModClusterServiceMBean.java 2008-09-23 04:46:47 UTC (rev 1885)
@@ -22,6 +22,7 @@
package org.jboss.modcluster;
+import org.jboss.ha.framework.interfaces.HASingletonMBean;
import org.jboss.modcluster.mcmp.MCMPRequestType;
import org.jboss.modcluster.mcmp.MCMPServerState;
@@ -30,7 +31,7 @@
*
* @author Brian Stansberry
*/
-public interface ModClusterServiceMBean
+public interface ModClusterServiceMBean extends HASingletonMBean
{
/**
* Add a proxy to the list of those with which this handler communicates.
16 years, 3 months
JBoss Native SVN: r1884 - trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/client.
by jbossnative-commits@lists.jboss.org
Author: pferraro
Date: 2008-09-23 00:45:47 -0400 (Tue, 23 Sep 2008)
New Revision: 1884
Modified:
trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/client/ModClusterDemo.java
Log:
New defaults
Modified: trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/client/ModClusterDemo.java
===================================================================
--- trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/client/ModClusterDemo.java 2008-09-23 04:44:46 UTC (rev 1883)
+++ trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/client/ModClusterDemo.java 2008-09-23 04:45:47 UTC (rev 1884)
@@ -32,9 +32,9 @@
*/
public class ModClusterDemo
{
- private static final String DEFAULT_HOST_NAME = "cluster10.qa.atl2.redhat.com:8888";
- private static final String DEFAULT_REQUEST_URL = "web/index.jsp";
- private static final String DEFAULT_DESTROY_URL = "web/destroy.jsp";
+ private static final String DEFAULT_HOST_NAME = "localhost:8888";
+ private static final String DEFAULT_REQUEST_URL = "demo/record?timeout=10";
+ private static final String DEFAULT_DESTROY_URL = "demo/record?destroy=true";
private static final int DEFAULT_NUM_THREADS = 200;
private static final int DEFAULT_SESSION_LIFE = 10;
private static final int DEFAULT_SLEEP_TIME = 0;
16 years, 3 months
JBoss Native SVN: r1883 - trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet.
by jbossnative-commits@lists.jboss.org
Author: pferraro
Date: 2008-09-23 00:44:46 -0400 (Tue, 23 Sep 2008)
New Revision: 1883
Modified:
trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/ActiveSessionsLoadServlet.java
trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/BusyConnectorsLoadServlet.java
trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/LoadServlet.java
trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/ReceiveTrafficLoadServlet.java
trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/RecordServlet.java
trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/SendTrafficLoadServlet.java
trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/SystemLoadServlet.java
Log:
improve load reliability
Modified: trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/ActiveSessionsLoadServlet.java
===================================================================
--- trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/ActiveSessionsLoadServlet.java 2008-09-23 03:56:50 UTC (rev 1882)
+++ trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/ActiveSessionsLoadServlet.java 2008-09-23 04:44:46 UTC (rev 1883)
@@ -58,11 +58,10 @@
{
int count = Integer.parseInt(this.getParameter(request, COUNT, "20"));
- HttpClient client = new HttpClient();
- HttpMethod method = new HeadMethod(this.createLocalURL(request, null));
-
for (int i = 0; i < count; ++i)
{
+ HttpClient client = new HttpClient();
+ HttpMethod method = new HeadMethod(this.createLocalURL(request, null));
client.executeMethod(method);
}
}
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 2008-09-23 03:56:50 UTC (rev 1882)
+++ trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/BusyConnectorsLoadServlet.java 2008-09-23 04:44:46 UTC (rev 1883)
@@ -30,7 +30,6 @@
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.HttpMethod;
-import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
import org.apache.commons.httpclient.methods.HeadMethod;
/**
@@ -59,9 +58,8 @@
long end = System.currentTimeMillis() + duration;
- HttpClient client = new HttpClient(new MultiThreadedHttpConnectionManager());
- HttpMethod method = new HeadMethod(this.createLocalURL(request, Collections.singletonMap(END, String.valueOf(end))));
- Runnable task = new ExecuteMethodTask(client, method);
+ String url = this.createLocalURL(request, Collections.singletonMap(END, String.valueOf(end)));
+ Runnable task = new ExecuteMethodTask(url);
int count = Integer.parseInt(this.getParameter(request, COUNT, "50"));
@@ -83,20 +81,21 @@
private class ExecuteMethodTask implements Runnable
{
- private final HttpClient client;
- private final HttpMethod method;
+ private final String url;
- ExecuteMethodTask(HttpClient client, HttpMethod method)
+ ExecuteMethodTask(String url)
{
- this.client = client;
- this.method = method;
+ this.url = url;
}
public void run()
{
+ HttpClient client = new HttpClient();
+ HttpMethod method = new HeadMethod(this.url);
+
try
{
- this.client.executeMethod(this.method);
+ client.executeMethod(method);
}
catch (HttpException e)
{
Modified: trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/LoadServlet.java
===================================================================
--- trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/LoadServlet.java 2008-09-23 03:56:50 UTC (rev 1882)
+++ trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/LoadServlet.java 2008-09-23 04:44:46 UTC (rev 1883)
@@ -24,9 +24,14 @@
import java.util.Iterator;
import java.util.Map;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
+import org.apache.catalina.ServerFactory;
+import org.apache.catalina.connector.Connector;
+
/**
* @author Paul Ferraro
*
@@ -40,6 +45,26 @@
protected static final String DEFAULT_DURATION = "15";
protected static final String COUNT = "count";
+ private static final String PORT = "port";
+
+ /**
+ * @{inheritDoc}
+ * @see javax.servlet.GenericServlet#init(javax.servlet.ServletConfig)
+ */
+ @Override
+ public void init(ServletConfig config) throws ServletException
+ {
+ super.init(config);
+
+ for (Connector connector: ServerFactory.getServer().findServices()[0].findConnectors())
+ {
+ if (connector.getProtocol().startsWith("HTTP"))
+ {
+ config.getServletContext().setAttribute(PORT, Integer.valueOf(connector.getPort()));
+ }
+ }
+ }
+
protected String createServerURL(HttpServletRequest request, Map<String, String> parameterMap)
{
return this.createURL(request, request.getServerName(), request.getServerPort(), parameterMap);
@@ -47,7 +72,8 @@
protected String createLocalURL(HttpServletRequest request, Map<String, String> parameterMap)
{
- return this.createURL(request, request.getLocalName(), request.getLocalPort(), parameterMap);
+ Integer port = (Integer) this.getServletContext().getAttribute(PORT);
+ return this.createURL(request, request.getLocalName(), (port != null) ? port.intValue() : request.getLocalPort(), parameterMap);
}
private String createURL(HttpServletRequest request, String host, int port, Map<String, String> parameterMap)
Modified: trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/ReceiveTrafficLoadServlet.java
===================================================================
--- trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/ReceiveTrafficLoadServlet.java 2008-09-23 03:56:50 UTC (rev 1882)
+++ trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/ReceiveTrafficLoadServlet.java 2008-09-23 04:44:46 UTC (rev 1883)
@@ -53,24 +53,29 @@
int size = Integer.parseInt(this.getParameter(request, SIZE, "100")) * 1000;
HttpClient client = new HttpClient();
- PutMethod method = new PutMethod(this.createLocalURL(request, null));
RequestEntity entity = new ByteArrayRequestEntity(new byte[size]);
- method.setRequestEntity(entity);
for (int i = 0; i < duration; ++i)
{
long start = System.currentTimeMillis();
+ PutMethod method = new PutMethod(this.createLocalURL(request, null));
+ method.setRequestEntity(entity);
client.executeMethod(method);
- try
+ long ms = 1000 - (System.currentTimeMillis() - start);
+
+ if (ms > 0)
{
- Thread.sleep(1000 - System.currentTimeMillis() - start);
+ try
+ {
+ Thread.sleep(ms);
+ }
+ catch (InterruptedException e)
+ {
+ Thread.currentThread().interrupt();
+ }
}
- catch (InterruptedException e)
- {
- Thread.currentThread().interrupt();
- }
}
}
}
Modified: trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/RecordServlet.java
===================================================================
--- trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/RecordServlet.java 2008-09-23 03:56:50 UTC (rev 1882)
+++ trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/RecordServlet.java 2008-09-23 04:44:46 UTC (rev 1883)
@@ -21,12 +21,16 @@
*/
package org.jboss.modcluster.demo.servlet;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
-import org.jboss.modcluster.demo.client.RequestDriver;
+import org.apache.catalina.Engine;
+import org.apache.catalina.ServerFactory;
+import org.jboss.modcluster.demo.Constants;
/**
* @author Paul Ferraro
@@ -42,6 +46,19 @@
/**
* @{inheritDoc}
+ * @see javax.servlet.GenericServlet#init(javax.servlet.ServletConfig)
+ */
+ @Override
+ public void init(ServletConfig config) throws ServletException
+ {
+ super.init(config);
+
+ Engine engine = (Engine) ServerFactory.getServer().findServices()[0].getContainer();
+ config.getServletContext().setAttribute("jvmRoute", engine.getJvmRoute());
+ }
+
+ /**
+ * @{inheritDoc}
* @see javax.servlet.http.HttpServlet#service(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
@Override
@@ -65,6 +82,6 @@
}
}
- response.setHeader(RequestDriver.NODE_HEADER, request.getLocalName());
+ response.setHeader(Constants.NODE_HEADER, (String) this.getServletContext().getAttribute("jvmRoute"));
}
}
Modified: trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/SendTrafficLoadServlet.java
===================================================================
--- trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/SendTrafficLoadServlet.java 2008-09-23 03:56:50 UTC (rev 1882)
+++ trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/SendTrafficLoadServlet.java 2008-09-23 04:44:46 UTC (rev 1883)
@@ -52,6 +52,7 @@
int size = Integer.parseInt(request.getParameter(SIZE)) * 1000;
response.getOutputStream().write(new byte[size]);
+ response.flushBuffer();
}
/**
@@ -74,14 +75,19 @@
client.executeMethod(method);
- try
+ long ms = 1000 - (System.currentTimeMillis() - start);
+
+ if (ms > 0)
{
- Thread.sleep(1000 - System.currentTimeMillis() - start);
+ try
+ {
+ Thread.sleep(ms);
+ }
+ catch (InterruptedException e)
+ {
+ Thread.currentThread().interrupt();
+ }
}
- catch (InterruptedException e)
- {
- Thread.currentThread().interrupt();
- }
}
}
}
Modified: trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/SystemLoadServlet.java
===================================================================
--- trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/SystemLoadServlet.java 2008-09-23 03:56:50 UTC (rev 1882)
+++ trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/SystemLoadServlet.java 2008-09-23 04:44:46 UTC (rev 1883)
@@ -47,14 +47,17 @@
// Naughty loop
while (System.currentTimeMillis() - start < duration)
{
- try
+ if ((System.currentTimeMillis() % 10) == 0)
{
- Thread.sleep(1);
+ try
+ {
+ Thread.sleep(1);
+ }
+ catch (InterruptedException e)
+ {
+ break;
+ }
}
- catch (InterruptedException e)
- {
- break;
- }
}
}
}
\ No newline at end of file
16 years, 3 months
JBoss Native SVN: r1882 - trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet.
by jbossnative-commits@lists.jboss.org
Author: pferraro
Date: 2008-09-22 23:56:50 -0400 (Mon, 22 Sep 2008)
New Revision: 1882
Added:
trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/BusyConnectorsLoadServlet.java
Removed:
trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/BusyConnectorsServlet.java
Log:
Renamed
Copied: trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/BusyConnectorsLoadServlet.java (from rev 1876, trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/BusyConnectorsServlet.java)
===================================================================
--- trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/BusyConnectorsLoadServlet.java (rev 0)
+++ trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/BusyConnectorsLoadServlet.java 2008-09-23 03:56:50 UTC (rev 1882)
@@ -0,0 +1,111 @@
+/*
+ * 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.demo.servlet;
+
+import java.io.IOException;
+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.MultiThreadedHttpConnectionManager;
+import org.apache.commons.httpclient.methods.HeadMethod;
+
+/**
+ * @author Paul Ferraro
+ *
+ */
+public class BusyConnectorsLoadServlet extends LoadServlet
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -946741803216943778L;
+
+ private static final String END = "end";
+
+ /**
+ * @{inheritDoc}
+ * @see javax.servlet.http.HttpServlet#service(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
+ */
+ @Override
+ protected void service(HttpServletRequest request, HttpServletResponse response) throws IOException
+ {
+ String parameter = request.getParameter(END);
+
+ if (parameter == null)
+ {
+ int duration = Integer.parseInt(this.getParameter(request, DURATION, "15")) * 1000;
+
+ long end = System.currentTimeMillis() + duration;
+
+ HttpClient client = new HttpClient(new MultiThreadedHttpConnectionManager());
+ HttpMethod method = new HeadMethod(this.createLocalURL(request, Collections.singletonMap(END, String.valueOf(end))));
+ Runnable task = new ExecuteMethodTask(client, method);
+
+ int count = Integer.parseInt(this.getParameter(request, COUNT, "50"));
+
+ for (int i = 0; i < count; ++i)
+ {
+ new Thread(task).start();
+ }
+ }
+ else
+ {
+ long end = Long.parseLong(parameter);
+
+ if (end < System.currentTimeMillis())
+ {
+ response.sendRedirect(response.encodeRedirectURL(this.createLocalURL(request, Collections.singletonMap(END, String.valueOf(end)))));
+ }
+ }
+ }
+
+ private class ExecuteMethodTask implements Runnable
+ {
+ private final HttpClient client;
+ private final HttpMethod method;
+
+ ExecuteMethodTask(HttpClient client, HttpMethod method)
+ {
+ this.client = client;
+ this.method = method;
+ }
+
+ public void run()
+ {
+ try
+ {
+ this.client.executeMethod(this.method);
+ }
+ catch (HttpException e)
+ {
+ BusyConnectorsLoadServlet.this.log(e.getMessage(), e);
+ }
+ catch (IOException e)
+ {
+ BusyConnectorsLoadServlet.this.log(e.getMessage(), e);
+ }
+ }
+ }
+}
Property changes on: trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/BusyConnectorsLoadServlet.java
___________________________________________________________________
Name: svn:mergeinfo
+
Deleted: trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/BusyConnectorsServlet.java
===================================================================
--- trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/BusyConnectorsServlet.java 2008-09-22 16:12:40 UTC (rev 1881)
+++ trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/BusyConnectorsServlet.java 2008-09-23 03:56:50 UTC (rev 1882)
@@ -1,111 +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.demo.servlet;
-
-import java.io.IOException;
-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.MultiThreadedHttpConnectionManager;
-import org.apache.commons.httpclient.methods.HeadMethod;
-
-/**
- * @author Paul Ferraro
- *
- */
-public class BusyConnectorsServlet extends LoadServlet
-{
- /** The serialVersionUID */
- private static final long serialVersionUID = -946741803216943778L;
-
- private static final String END = "end";
-
- /**
- * @{inheritDoc}
- * @see javax.servlet.http.HttpServlet#service(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
- */
- @Override
- protected void service(HttpServletRequest request, HttpServletResponse response) throws IOException
- {
- String parameter = request.getParameter(END);
-
- if (parameter == null)
- {
- int duration = Integer.parseInt(this.getParameter(request, DURATION, "15")) * 1000;
-
- long end = System.currentTimeMillis() + duration;
-
- HttpClient client = new HttpClient(new MultiThreadedHttpConnectionManager());
- HttpMethod method = new HeadMethod(this.createLocalURL(request, Collections.singletonMap(END, String.valueOf(end))));
- Runnable task = new ExecuteMethodTask(client, method);
-
- int count = Integer.parseInt(this.getParameter(request, COUNT, "50"));
-
- for (int i = 0; i < count; ++i)
- {
- new Thread(task).start();
- }
- }
- else
- {
- long end = Long.parseLong(parameter);
-
- if (end < System.currentTimeMillis())
- {
- response.sendRedirect(response.encodeRedirectURL(this.createLocalURL(request, Collections.singletonMap(END, String.valueOf(end)))));
- }
- }
- }
-
- private class ExecuteMethodTask implements Runnable
- {
- private final HttpClient client;
- private final HttpMethod method;
-
- ExecuteMethodTask(HttpClient client, HttpMethod method)
- {
- this.client = client;
- this.method = method;
- }
-
- public void run()
- {
- try
- {
- this.client.executeMethod(this.method);
- }
- catch (HttpException e)
- {
- BusyConnectorsServlet.this.log(e.getMessage(), e);
- }
- catch (IOException e)
- {
- BusyConnectorsServlet.this.log(e.getMessage(), e);
- }
- }
- }
-}
16 years, 3 months