JBoss Native SVN: r1934 - trunk/mod_cluster/src/main/java/org/jboss/modcluster.
by jbossnative-commits@lists.jboss.org
Author: pferraro
Date: 2008-10-03 07:24:07 -0400 (Fri, 03 Oct 2008)
New Revision: 1934
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ModClusterService.java
Log:
Fixed NullPointerException checking whether drm entry was updated.
Modified: trunk/mod_cluster/src/main/java/org/jboss/modcluster/ModClusterService.java
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/ModClusterService.java 2008-10-03 11:19:02 UTC (rev 1933)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/ModClusterService.java 2008-10-03 11:24:07 UTC (rev 1934)
@@ -909,7 +909,7 @@
boolean othersFirst = this.coord.narrowCandidateList(allStatuses).contains(node);
Set<MCMPServerState> oldStates = this.coord.drmEntry.getMCMPServerStates();
- boolean updated = !oldStates.equals(masterList);
+ boolean updated = (oldStates != null) ? !oldStates.equals(masterList) : oldStates != masterList;
// ModClusterServiceDRMEntry ourNewStatus = new ModClusterServiceDRMEntry(node, masterList);
// boolean updated = !ourNewStatus.equals(ourCurrentStatus);
16 years, 3 months
JBoss Native SVN: r1933 - in trunk/mod_cluster/src/main/java/org/jboss/modcluster: ha and 1 other directory.
by jbossnative-commits@lists.jboss.org
Author: pferraro
Date: 2008-10-03 07:19:02 -0400 (Fri, 03 Oct 2008)
New Revision: 1933
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ModClusterService.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/ModClusterServiceDRMEntry.java
Log:
Update drm entry states instead of creating new one.
Modified: trunk/mod_cluster/src/main/java/org/jboss/modcluster/ModClusterService.java
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/ModClusterService.java 2008-10-03 10:39:58 UTC (rev 1932)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/ModClusterService.java 2008-10-03 11:19:02 UTC (rev 1933)
@@ -454,6 +454,11 @@
}
}
+ void updateLocalDRMEntry()
+ {
+ this.updateLocalDRM(this.drmEntry);
+ }
+
void updateLocalDRM(ModClusterServiceDRMEntry ourNewStatus)
{
try
@@ -555,11 +560,13 @@
DistributedReplicantManager drm = partition.getDistributedReplicantManager();
String key = this.coord.getHAServiceKey();
ModClusterServiceDRMEntry oldStatus = (ModClusterServiceDRMEntry) drm.lookupLocalReplicant(key);
- if (newStatus.equals(oldStatus) == false)
+ if (!newStatus.equals(oldStatus))
{
try
{
- drm.add(key, new ModClusterServiceDRMEntry(cn, newStatus.getMCMPServerStates()));
+ oldStatus.setMCMPServerStates(newStatus.getMCMPServerStates());
+ drm.add(key, oldStatus);
+// drm.add(key, new ModClusterServiceDRMEntry(cn, newStatus.getMCMPServerStates()));
}
catch (Exception e)
{
@@ -901,8 +908,10 @@
ClusterNode node = partition.getClusterNode();
boolean othersFirst = this.coord.narrowCandidateList(allStatuses).contains(node);
- ModClusterServiceDRMEntry ourNewStatus = new ModClusterServiceDRMEntry(node, masterList);
- boolean updated = !ourNewStatus.equals(ourCurrentStatus);
+ Set<MCMPServerState> oldStates = this.coord.drmEntry.getMCMPServerStates();
+ boolean updated = !oldStates.equals(masterList);
+// ModClusterServiceDRMEntry ourNewStatus = new ModClusterServiceDRMEntry(node, masterList);
+// boolean updated = !ourNewStatus.equals(ourCurrentStatus);
if (othersFirst)
{
@@ -910,14 +919,18 @@
if (updated)
{
- this.coord.updateLocalDRM(ourNewStatus);
+ this.coord.drmEntry.setMCMPServerStates(masterList);
+ this.coord.updateLocalDRMEntry();
+// this.coord.updateLocalDRM(ourNewStatus);
}
}
else
{
if (updated)
{
- this.coord.updateLocalDRM(ourNewStatus);
+ this.coord.drmEntry.setMCMPServerStates(masterList);
+ this.coord.updateLocalDRMEntry();
+// this.coord.updateLocalDRM(ourNewStatus);
}
this.coord.clusterStatusComplete(statuses);
Modified: trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/ModClusterServiceDRMEntry.java
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/ModClusterServiceDRMEntry.java 2008-10-03 10:39:58 UTC (rev 1932)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/ModClusterServiceDRMEntry.java 2008-10-03 11:19:02 UTC (rev 1933)
@@ -41,7 +41,7 @@
private static final long serialVersionUID = 8275232749243297786L;
private final ClusterNode peer;
- private final Set<MCMPServerState> mcmpServerStates;
+ private volatile Set<MCMPServerState> mcmpServerStates;
private final Integer healthyEstablishedCount;
private final Integer establishedCount;
private final Integer healthyCount;
@@ -92,6 +92,11 @@
return this.peer;
}
+ public void setMCMPServerStates(Set<MCMPServerState> states)
+ {
+ this.mcmpServerStates = states;
+ }
+
public Set<MCMPServerState> getMCMPServerStates()
{
return this.mcmpServerStates;
16 years, 3 months
JBoss Native SVN: r1932 - trunk/mod_cluster/src/main/java/org/jboss/modcluster.
by jbossnative-commits@lists.jboss.org
Author: pferraro
Date: 2008-10-03 06:39:58 -0400 (Fri, 03 Oct 2008)
New Revision: 1932
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ModClusterService.java
Log:
Use local handler to establish jvmRoute - not clustered handler.
Modified: trunk/mod_cluster/src/main/java/org/jboss/modcluster/ModClusterService.java
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/ModClusterService.java 2008-10-03 10:02:25 UTC (rev 1931)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/ModClusterService.java 2008-10-03 10:39:58 UTC (rev 1932)
@@ -696,7 +696,7 @@
@Override
protected void config(Engine engine)
{
- this.config(engine, this.coord.clusteredHandler);
+ this.config(engine, this.coord.localHandler);
}
@Override
16 years, 3 months
JBoss Native SVN: r1931 - trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet.
by jbossnative-commits@lists.jboss.org
Author: pferraro
Date: 2008-10-03 06:02:25 -0400 (Fri, 03 Oct 2008)
New Revision: 1931
Modified:
trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/LoadServlet.java
Log:
Oops - make sure jvmRoute gets set
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-10-03 09:35:33 UTC (rev 1930)
+++ trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/LoadServlet.java 2008-10-03 10:02:25 UTC (rev 1931)
@@ -31,6 +31,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.apache.catalina.Engine;
import org.apache.catalina.ServerFactory;
import org.apache.catalina.connector.Connector;
@@ -48,6 +49,7 @@
protected static final String COUNT = "count";
private static final String PORT = "port";
+ private static final String JVM_ROUTE = "jvmRoute";
/**
* @{inheritDoc}
@@ -65,6 +67,9 @@
config.getServletContext().setAttribute(PORT, Integer.valueOf(connector.getPort()));
}
}
+
+ Engine engine = (Engine) ServerFactory.getServer().findServices()[0].getContainer();
+ config.getServletContext().setAttribute(JVM_ROUTE, engine.getJvmRoute());
}
protected String createServerURL(HttpServletRequest request, Map<String, String> parameterMap)
@@ -127,6 +132,6 @@
protected void writeLocalName(HttpServletRequest request, HttpServletResponse response) throws IOException
{
- response.getWriter().append("Handled By: ").append((String) this.getServletContext().getAttribute("jvmRoute"));
+ response.getWriter().append("Handled By: ").append((String) this.getServletContext().getAttribute(JVM_ROUTE));
}
}
16 years, 3 months
JBoss Native SVN: r1930 - trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet.
by jbossnative-commits@lists.jboss.org
Author: pferraro
Date: 2008-10-03 05:35:33 -0400 (Fri, 03 Oct 2008)
New Revision: 1930
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/ConnectionPoolLoadServlet.java
trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/HeapMemoryLoadServlet.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/RequestCountLoadServlet.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
trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/ThreadCountLoadServlet.java
Log:
Added jvmRoute to load servlet response
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-10-03 07:04:58 UTC (rev 1929)
+++ trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/ActiveSessionsLoadServlet.java 2008-10-03 09:35:33 UTC (rev 1930)
@@ -64,5 +64,7 @@
HttpMethod method = new HeadMethod(this.createLocalURL(request, null));
client.executeMethod(method);
}
+
+ this.writeLocalName(request, response);
}
}
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-10-03 07:04:58 UTC (rev 1929)
+++ trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/BusyConnectorsLoadServlet.java 2008-10-03 09:35:33 UTC (rev 1930)
@@ -67,6 +67,8 @@
{
new Thread(task).start();
}
+
+ this.writeLocalName(request, response);
}
else
{
Modified: trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/ConnectionPoolLoadServlet.java
===================================================================
--- trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/ConnectionPoolLoadServlet.java 2008-10-03 07:04:58 UTC (rev 1929)
+++ trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/ConnectionPoolLoadServlet.java 2008-10-03 09:35:33 UTC (rev 1930)
@@ -21,6 +21,7 @@
*/
package org.jboss.modcluster.demo.servlet;
+import java.io.IOException;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;
@@ -49,7 +50,7 @@
* @see javax.servlet.http.HttpServlet#service(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
@Override
- protected void service(HttpServletRequest request, HttpServletResponse response)
+ protected void service(HttpServletRequest request, HttpServletResponse response) throws IOException
{
String name = this.getParameter(request, DATASOURCE, "java:/DefaultDS");
@@ -101,5 +102,7 @@
{
this.log(e.getMessage(), e);
}
+
+ this.writeLocalName(request, response);
}
}
Modified: trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/HeapMemoryLoadServlet.java
===================================================================
--- trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/HeapMemoryLoadServlet.java 2008-10-03 07:04:58 UTC (rev 1929)
+++ trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/HeapMemoryLoadServlet.java 2008-10-03 09:35:33 UTC (rev 1930)
@@ -21,6 +21,8 @@
*/
package org.jboss.modcluster.demo.servlet;
+import java.io.IOException;
+
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -38,7 +40,7 @@
* @see javax.servlet.http.HttpServlet#service(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
@Override
- protected void service(HttpServletRequest request, HttpServletResponse response)
+ protected void service(HttpServletRequest request, HttpServletResponse response) throws IOException
{
int duration = Integer.parseInt(this.getParameter(request, DURATION, DEFAULT_DURATION));
@@ -68,5 +70,7 @@
array = null;
System.gc();
+
+ this.writeLocalName(request, response);
}
}
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-10-03 07:04:58 UTC (rev 1929)
+++ trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/LoadServlet.java 2008-10-03 09:35:33 UTC (rev 1930)
@@ -21,6 +21,7 @@
*/
package org.jboss.modcluster.demo.servlet;
+import java.io.IOException;
import java.util.Iterator;
import java.util.Map;
@@ -28,6 +29,7 @@
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
import org.apache.catalina.ServerFactory;
import org.apache.catalina.connector.Connector;
@@ -122,4 +124,9 @@
return (value != null) ? value : defaultValue;
}
+
+ protected void writeLocalName(HttpServletRequest request, HttpServletResponse response) throws IOException
+ {
+ response.getWriter().append("Handled By: ").append((String) this.getServletContext().getAttribute("jvmRoute"));
+ }
}
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-10-03 07:04:58 UTC (rev 1929)
+++ trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/ReceiveTrafficLoadServlet.java 2008-10-03 09:35:33 UTC (rev 1930)
@@ -77,5 +77,7 @@
}
}
}
+
+ this.writeLocalName(request, response);
}
}
Modified: trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/RequestCountLoadServlet.java
===================================================================
--- trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/RequestCountLoadServlet.java 2008-10-03 07:04:58 UTC (rev 1929)
+++ trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/RequestCountLoadServlet.java 2008-10-03 09:35:33 UTC (rev 1930)
@@ -49,5 +49,9 @@
{
response.sendRedirect(this.createLocalURL(request, Collections.singletonMap(COUNT, String.valueOf(count - 1))));
}
+ else
+ {
+ this.writeLocalName(request, response);
+ }
}
}
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-10-03 07:04:58 UTC (rev 1929)
+++ trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/SendTrafficLoadServlet.java 2008-10-03 09:35:33 UTC (rev 1930)
@@ -89,5 +89,7 @@
}
}
}
+
+ this.writeLocalName(request, response);
}
}
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-10-03 07:04:58 UTC (rev 1929)
+++ trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/SystemLoadServlet.java 2008-10-03 09:35:33 UTC (rev 1930)
@@ -21,6 +21,8 @@
*/
package org.jboss.modcluster.demo.servlet;
+import java.io.IOException;
+
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -38,7 +40,7 @@
* @see javax.servlet.http.HttpServlet#service(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
@Override
- protected void service(HttpServletRequest request, HttpServletResponse response)
+ protected void service(HttpServletRequest request, HttpServletResponse response) throws IOException
{
long start = System.currentTimeMillis();
@@ -59,5 +61,7 @@
}
}
}
+
+ this.writeLocalName(request, response);
}
}
\ No newline at end of file
Modified: trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/ThreadCountLoadServlet.java
===================================================================
--- trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/ThreadCountLoadServlet.java 2008-10-03 07:04:58 UTC (rev 1929)
+++ trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/ThreadCountLoadServlet.java 2008-10-03 09:35:33 UTC (rev 1930)
@@ -21,6 +21,8 @@
*/
package org.jboss.modcluster.demo.servlet;
+import java.io.IOException;
+
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -38,7 +40,7 @@
* @see javax.servlet.http.HttpServlet#service(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
@Override
- protected void service(HttpServletRequest request, HttpServletResponse response)
+ protected void service(HttpServletRequest request, HttpServletResponse response) throws IOException
{
final int duration = Integer.parseInt(this.getParameter(request, DURATION, DEFAULT_DURATION)) * 1000;
@@ -64,5 +66,7 @@
thread.start();
}
+
+ this.writeLocalName(request, response);
}
}
16 years, 3 months
JBoss Native SVN: r1929 - trunk/mod_cluster/native/mod_proxy_cluster.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2008-10-03 03:04:58 -0400 (Fri, 03 Oct 2008)
New Revision: 1929
Modified:
trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c
Log:
Some more tries with the algo.
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-02 20:35:33 UTC (rev 1928)
+++ trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c 2008-10-03 07:04:58 UTC (rev 1929)
@@ -840,8 +840,10 @@
}
if (mycandidate) {
- if (mycandidate->s->lbstatus > - FORGETFACTOR * mycandidate->s->lbfactor)
+ if ((mycandidate->s->lbstatus-total_factor) > - FORGETFACTOR * mycandidate->s->lbfactor)
mycandidate->s->lbstatus -= total_factor;
+ else
+ mycandidate->s->lbstatus = - FORGETFACTOR * mycandidate->s->lbfactor;
mycandidate->s->elected++;
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
"proxy: byrequests balancer DONE (%s)", mycandidate->name);
@@ -1537,8 +1539,10 @@
}
workers++;
}
- if (runtime->s->lbstatus > - FORGETFACTOR * runtime->s->lbfactor)
+ if (runtime->s->lbstatus-total_factor > - FORGETFACTOR * runtime->s->lbfactor)
runtime->s->lbstatus -= total_factor;
+ else
+ runtime->s->lbstatus = - FORGETFACTOR * runtime->s->lbfactor;
runtime->s->elected++;
*worker = runtime;
16 years, 3 months
JBoss Native SVN: r1928 - trunk/mod_cluster/native/mod_proxy_cluster.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2008-10-02 16:35:33 -0400 (Thu, 02 Oct 2008)
New Revision: 1928
Modified:
trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c
Log:
Use smaller value ;-)
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-02 17:37:14 UTC (rev 1927)
+++ trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c 2008-10-02 20:35:33 UTC (rev 1928)
@@ -65,7 +65,7 @@
#define WAITFORREMOVE 10 /* seconds */
-#define FORGETFACTOR 1000 /* Stop changing node lbstatus when too small or too big */
+#define FORGETFACTOR 10 /* Stop changing node lbstatus when too small or too big */
/*
* Create/Get the worker before using it
16 years, 3 months
JBoss Native SVN: r1927 - trunk/mod_cluster/test/java.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2008-10-02 13:37:14 -0400 (Thu, 02 Oct 2008)
New Revision: 1927
Modified:
trunk/mod_cluster/test/java/installhttpd.sh
Log:
Remove mod_proxy_balancer because it interferes with
our loadbalancing logic.
Modified: trunk/mod_cluster/test/java/installhttpd.sh
===================================================================
--- trunk/mod_cluster/test/java/installhttpd.sh 2008-10-02 16:27:48 UTC (rev 1926)
+++ trunk/mod_cluster/test/java/installhttpd.sh 2008-10-02 17:37:14 UTC (rev 1927)
@@ -44,6 +44,7 @@
file=$HOME/opt/jboss/httpd/httpd/conf/httpd.conf
cp -p $file $file.new
echo "s/Listen 80/Listen @IP@:8000/" > sed.cmd
+echo "s/LoadModule proxy_balancer/#LoadModule proxy_balancer/" >> sed.cmd
sed -f sed.cmd $file > $file.new
cat >> $file.new <<EOF
<IfModule manager_module>
16 years, 3 months
JBoss Native SVN: r1926 - in trunk/mod_cluster/src: main/java/org/jboss/modcluster/mcmp/impl and 2 other directories.
by jbossnative-commits@lists.jboss.org
Author: pferraro
Date: 2008-10-02 12:27:48 -0400 (Thu, 02 Oct 2008)
New Revision: 1926
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/MCMPRequest.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/MCMPUtils.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/impl/DefaultMCMPHandler.java
trunk/mod_cluster/src/test/java/org/jboss/modcluster/ClusterListenerTestCase.java
trunk/mod_cluster/src/test/java/org/jboss/modcluster/DefaultJBossWebEventHandlerTestCase.java
trunk/mod_cluster/src/test/java/org/jboss/modcluster/ModClusterServiceTestCase.java
trunk/mod_cluster/src/test/java/org/jboss/modcluster/ha/ClusteredMCMPHandlerTestCase.java
trunk/mod_cluster/src/test/java/org/jboss/modcluster/ha/HASingletonAwareResetRequestSourceTestCase.java
Log:
Expose JVMRoute from MCMPRequest. Adjust message creation accordingly.
Modified: trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/MCMPRequest.java
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/MCMPRequest.java 2008-10-02 15:31:06 UTC (rev 1925)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/MCMPRequest.java 2008-10-02 16:27:48 UTC (rev 1926)
@@ -24,7 +24,6 @@
import java.io.Serializable;
import java.util.Collections;
-import java.util.HashMap;
import java.util.Map;
import net.jcip.annotations.Immutable;
@@ -44,15 +43,17 @@
private final MCMPRequestType requestType;
private final boolean wildcard;
private final Map<String, String> parameters;
+ private final String jvmRoute;
/**
* Create a new ModClusterRequest.
*/
- public MCMPRequest(MCMPRequestType requestType, boolean wildcard, Map<String, String> parameters)
+ public MCMPRequest(MCMPRequestType requestType, boolean wildcard, String jvmRoute, Map<String, String> parameters)
{
this.requestType = requestType;
this.wildcard = wildcard;
- this.parameters = Collections.unmodifiableMap(new HashMap<String, String>(parameters));
+ this.jvmRoute = jvmRoute;
+ this.parameters = Collections.unmodifiableMap(parameters);
}
public MCMPRequestType getRequestType()
@@ -65,6 +66,11 @@
return this.wildcard;
}
+ public String getJvmRoute()
+ {
+ return this.jvmRoute;
+ }
+
public Map<String, String> getParameters()
{
return this.parameters;
@@ -74,12 +80,10 @@
public String toString()
{
StringBuilder sb = new StringBuilder(getClass().getName());
- sb.append("{requestType=");
- sb.append(this.requestType);
- sb.append(",wildcard=");
- sb.append(this.wildcard);
- sb.append(",parameters=");
- sb.append(this.parameters);
+ sb.append("{requestType=").append(this.requestType);
+ sb.append(",wildcard=").append(this.wildcard);
+ sb.append(",jvmRoute=").append(this.jvmRoute);
+ sb.append(",parameters=").append(this.parameters);
sb.append("}");
return sb.toString();
Modified: trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/MCMPUtils.java
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/MCMPUtils.java 2008-10-02 15:31:06 UTC (rev 1925)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/MCMPUtils.java 2008-10-02 16:27:48 UTC (rev 1926)
@@ -55,7 +55,9 @@
{
public static final int DEFAULT_PORT = 8000;
- private static final MCMPRequest INFO = new MCMPRequest(MCMPRequestType.INFO, false, new HashMap<String, String>());
+ private static final Map<String, String> EMPTY_MAP = Collections.emptyMap();
+ public static final MCMPRequest INFO_REQUEST = new MCMPRequest(MCMPRequestType.INFO, false, null, EMPTY_MAP);
+ public static final MCMPRequest DUMP_REQUEST = new MCMPRequest(MCMPRequestType.DUMP, true, null, EMPTY_MAP);
private static final Logger log = Logger.getLogger(MCMPUtils.class);
@@ -68,7 +70,6 @@
{
Connector connector = Utils.findProxyConnector(engine.getService().findConnectors());
Map<String, String> parameters = new HashMap<String, String>();
- parameters.put("JVMRoute", engine.getJvmRoute());
ProtocolHandler handler = connector.getProtocolHandler();
@@ -166,7 +167,7 @@
parameters.put("Maxattempts", "" + maxAttempts);
}
- return new MCMPRequest(MCMPRequestType.CONFIG, false, parameters);
+ return new MCMPRequest(MCMPRequestType.CONFIG, false, engine.getJvmRoute(), parameters);
}
public static MCMPRequest createEnableAppRequest(Context context)
@@ -192,14 +193,13 @@
private static MCMPRequest createRequest(MCMPRequestType type, Context context)
{
Map<String, String> parameters = new HashMap<String, String>();
- parameters.put("JVMRoute", Utils.getJvmRoute(context));
String path = context.getPath();
parameters.put("Context", "".equals(path) ? "/" : path);
parameters.put("Alias", Utils.getHost(context));
- return new MCMPRequest(type, false, parameters);
+ return new MCMPRequest(type, false, Utils.getJvmRoute(context), parameters);
}
public static MCMPRequest createStatusRequest(Engine engine, int lbf)
@@ -209,10 +209,7 @@
public static MCMPRequest createStatusRequest(String jvmRoute, int lbf)
{
- Map<String, String> parameters = new HashMap<String, String>();
- parameters.put("JVMRoute", jvmRoute);
- parameters.put("Load", String.valueOf(lbf));
- return new MCMPRequest(MCMPRequestType.STATUS, false, parameters);
+ return new MCMPRequest(MCMPRequestType.STATUS, false, jvmRoute, Collections.singletonMap("Load", String.valueOf(lbf)));
}
public static MCMPRequest createEnableEngineRequest(Engine engine)
@@ -232,7 +229,7 @@
private static MCMPRequest createRequest(MCMPRequestType type, Engine engine)
{
- return new MCMPRequest(type, true, Collections.singletonMap("JVMRoute", engine.getJvmRoute()));
+ return new MCMPRequest(type, true, engine.getJvmRoute(), EMPTY_MAP);
}
/**
@@ -268,11 +265,6 @@
return requests;
}
- public static MCMPRequest getInfoRequest()
- {
- return INFO;
- }
-
public static AddressPort parseAddressPort(String addressPort)
{
try
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-02 15:31:06 UTC (rev 1925)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/impl/DefaultMCMPHandler.java 2008-10-02 16:27:48 UTC (rev 1926)
@@ -33,7 +33,6 @@
import java.net.Socket;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
@@ -60,7 +59,6 @@
import org.jboss.modcluster.mcmp.AddressPort;
import org.jboss.modcluster.mcmp.MCMPHandler;
import org.jboss.modcluster.mcmp.MCMPRequest;
-import org.jboss.modcluster.mcmp.MCMPRequestType;
import org.jboss.modcluster.mcmp.MCMPServerState;
import org.jboss.modcluster.mcmp.MCMPUtils;
import org.jboss.modcluster.mcmp.ResetRequestSource;
@@ -319,39 +317,23 @@
*/
public String getProxyConfiguration()
{
- Map<String, String> parameters = new HashMap<String, String>();
// Send DUMP * request
- StringBuilder result = new StringBuilder();
-
- Lock lock = this.proxiesLock.readLock();
- lock.lock();
-
- try
- {
- for (int i = 0; i < this.proxies.size(); ++i)
- {
- Proxy proxy = this.proxies.get(i);
- result.append("Proxy[").append(i).append("]: [").append(proxy.getAddress()).append(':').append(proxy.getPort()).append("]: \r\n");
- result.append(this.sendRequest(new MCMPRequest(MCMPRequestType.DUMP, true, parameters), proxy)).append("\r\n");
- }
- }
- finally
- {
- lock.unlock();
- }
- return result.toString();
+ return this.getProxyMessage(MCMPUtils.DUMP_REQUEST);
}
/**
* Retrieves the full proxy info message.
*
- *
* @return the proxy info confguration
*/
public String getProxyInfo()
{
- Map<String, String> parameters = new HashMap<String, String>();
// Send INFO * request
+ return this.getProxyMessage(MCMPUtils.INFO_REQUEST);
+ }
+
+ private String getProxyMessage(MCMPRequest request)
+ {
StringBuilder result = new StringBuilder();
Lock lock = this.proxiesLock.readLock();
@@ -363,7 +345,7 @@
{
Proxy proxy = this.proxies.get(i);
result.append("Proxy[").append(i).append("]: [").append(proxy.getAddress()).append(':').append(proxy.getPort()).append("]: \r\n");
- result.append(this.sendRequest(new MCMPRequest(MCMPRequestType.INFO, true, parameters), proxy)).append("\r\n");
+ result.append(this.sendRequest(request, proxy)).append("\r\n");
}
}
finally
@@ -467,7 +449,7 @@
{
proxy.setState(Proxy.State.OK);
- this.sendRequest(MCMPUtils.getInfoRequest(), proxy);
+ this.sendRequest(MCMPUtils.INFO_REQUEST, proxy);
if (proxy.getState() == Proxy.State.OK)
{
@@ -594,6 +576,7 @@
String command = request.getRequestType().getCommand();
boolean wildcard = request.isWildcard();
+ String jvmRoute = request.getJvmRoute();
Map<String, String> parameters = request.getParameters();
UEncoder encoder = new UEncoder();
@@ -605,27 +588,18 @@
body = encoder.encodeURL("", 0, 0);
body.recycle();
+ if (jvmRoute != null)
+ {
+ body = this.encodeParameter(encoder, "JVMRoute", jvmRoute, !parameters.isEmpty());
+ }
+
Iterator<Map.Entry<String, String>> entries = parameters.entrySet().iterator();
while (entries.hasNext())
{
Map.Entry<String, String> entry = entries.next();
- String key = entry.getKey();
- String value = entry.getValue();
-
- if (value == null)
- {
- throw new IllegalArgumentException(this.sm.getString("modcluster.error.nullAttribute", key));
- }
- body = encoder.encodeURL(key, 0, key.length());
- body.append('=');
- body = encoder.encodeURL(value, 0, value.length());
-
- if (entries.hasNext())
- {
- body.append('&');
- }
+ body = this.encodeParameter(encoder, entry.getKey(), entry.getValue(), entries.hasNext());
}
}
catch (IOException e)
@@ -813,6 +787,25 @@
return null;
}
+ private CharChunk encodeParameter(UEncoder encoder, String key, String value, boolean hasNext) throws IOException
+ {
+ if (value == null)
+ {
+ throw new IllegalArgumentException(this.sm.getString("modcluster.error.nullAttribute", key));
+ }
+
+ encoder.encodeURL(key, 0, key.length()).append('=');
+
+ CharChunk body = encoder.encodeURL(value, 0, value.length());
+
+ if (hasNext)
+ {
+ body.append('&');
+ }
+
+ return body;
+ }
+
/**
* This class represents a front-end httpd server.
*/
Modified: trunk/mod_cluster/src/test/java/org/jboss/modcluster/ClusterListenerTestCase.java
===================================================================
--- trunk/mod_cluster/src/test/java/org/jboss/modcluster/ClusterListenerTestCase.java 2008-10-02 15:31:06 UTC (rev 1925)
+++ trunk/mod_cluster/src/test/java/org/jboss/modcluster/ClusterListenerTestCase.java 2008-10-02 16:27:48 UTC (rev 1926)
@@ -105,13 +105,13 @@
EasyMock.expect(context.isStarted()).andReturn(true);
// create enable-app request
- EasyMock.expect(context.getParent()).andReturn(container);
- EasyMock.expect(container.getParent()).andReturn(engine);
- EasyMock.expect(engine.getJvmRoute()).andReturn("host1");
EasyMock.expect(context.getPath()).andReturn("/context");
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.replay(server, service, engine, container, context, host);
@@ -124,16 +124,15 @@
assertSame(MCMPRequestType.REMOVE_APP, request.getRequestType());
assertTrue(request.isWildcard());
- assertEquals(1, parameters.size());
- assertEquals("host1", parameters.get("JVMRoute"));
+ assertEquals("host1", request.getJvmRoute());
request = requests.get(1);
parameters = request.getParameters();
assertSame(MCMPRequestType.CONFIG, request.getRequestType());
assertFalse(request.isWildcard());
- assertEquals(17, parameters.size());
- assertEquals("host1", parameters.get("JVMRoute"));
+ assertEquals("host1", request.getJvmRoute());
+ assertEquals(16, parameters.size());
assertEquals("127.0.0.1", parameters.get("Host"));
assertEquals("0", parameters.get("Port"));
assertEquals("ajp", parameters.get("Type"));
@@ -156,8 +155,8 @@
assertSame(MCMPRequestType.ENABLE_APP, request.getRequestType());
assertFalse(request.isWildcard());
- assertEquals(3, parameters.size());
- assertEquals("host1", parameters.get("JVMRoute"));
+ assertEquals("host1", request.getJvmRoute());
+ assertEquals(2, parameters.size());
assertEquals("/context", parameters.get("Context"));
assertEquals("host,alias1,alias2", parameters.get("Alias"));
@@ -225,12 +224,11 @@
assertTrue(result);
MCMPRequest request = capturedRequest.getValue();
- Map<String, String> parameters = request.getParameters();
assertSame(MCMPRequestType.ENABLE_APP, request.getRequestType());
assertTrue(request.isWildcard());
- assertEquals(1, parameters.size());
- assertEquals("host1", parameters.get("JVMRoute"));
+ assertEquals("host1", request.getJvmRoute());
+ assertTrue(request.getParameters().isEmpty());
EasyMock.reset(this.mcmpHandler, server, service, engine);
}
@@ -257,12 +255,11 @@
assertTrue(result);
MCMPRequest request = capturedRequest.getValue();
- Map<String, String> parameters = request.getParameters();
assertSame(MCMPRequestType.DISABLE_APP, request.getRequestType());
assertTrue(request.isWildcard());
- assertEquals(1, parameters.size());
- assertEquals("host1", parameters.get("JVMRoute"));
+ assertEquals("host1", request.getJvmRoute());
+ assertTrue(request.getParameters().isEmpty());
EasyMock.reset(this.mcmpHandler, server, service, 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-02 15:31:06 UTC (rev 1925)
+++ trunk/mod_cluster/src/test/java/org/jboss/modcluster/DefaultJBossWebEventHandlerTestCase.java 2008-10-02 16:27:48 UTC (rev 1926)
@@ -246,13 +246,13 @@
EasyMock.expect(context.isStarted()).andReturn(true);
// Building request
- EasyMock.expect(context.getParent()).andReturn(container);
- EasyMock.expect(container.getParent()).andReturn(engine);
- EasyMock.expect(engine.getJvmRoute()).andReturn("host1");
EasyMock.expect(context.getPath()).andReturn("/context");
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");
this.mcmpHandler.sendRequest(EasyMock.capture(capturedRequest));
@@ -266,12 +266,12 @@
assertSame(MCMPRequestType.ENABLE_APP, request.getRequestType());
assertFalse(request.isWildcard());
+ assertEquals("host1", request.getJvmRoute());
Map<String, String> parameters = request.getParameters();
- assertEquals(3, parameters.size());
+ assertEquals(2, parameters.size());
- assertEquals("host1", parameters.get("JVMRoute"));
assertEquals("/context", parameters.get("Context"));
assertEquals("host,alias1,alias2", parameters.get("Alias"));
@@ -318,13 +318,13 @@
EasyMock.expect(container.getName()).andReturn("parent-container");
// Building request
- EasyMock.expect(context.getParent()).andReturn(container);
- EasyMock.expect(container.getParent()).andReturn(engine);
- EasyMock.expect(engine.getJvmRoute()).andReturn("host1");
EasyMock.expect(context.getPath()).andReturn("/context");
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");
this.mcmpHandler.sendRequest(EasyMock.capture(capturedRequest));
@@ -338,12 +338,12 @@
assertSame(MCMPRequestType.ENABLE_APP, request.getRequestType());
assertFalse(request.isWildcard());
+ assertEquals("host1", request.getJvmRoute());
Map<String, String> parameters = request.getParameters();
- assertEquals(3, parameters.size());
+ assertEquals(2, parameters.size());
- assertEquals("host1", parameters.get("JVMRoute"));
assertEquals("/context", parameters.get("Context"));
assertEquals("host,alias1,alias2", parameters.get("Alias"));
@@ -380,13 +380,13 @@
EasyMock.expect(container.getName()).andReturn("parent-container");
// Building request
- EasyMock.expect(context.getParent()).andReturn(container);
- EasyMock.expect(container.getParent()).andReturn(engine);
- EasyMock.expect(engine.getJvmRoute()).andReturn("host1");
EasyMock.expect(context.getPath()).andReturn("/context");
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");
this.mcmpHandler.sendRequest(EasyMock.capture(capturedRequest));
@@ -400,12 +400,12 @@
assertSame(MCMPRequestType.STOP_APP, request.getRequestType());
assertFalse(request.isWildcard());
+ assertEquals("host1", request.getJvmRoute());
Map<String, String> parameters = request.getParameters();
- assertEquals(3, parameters.size());
+ assertEquals(2, parameters.size());
- assertEquals("host1", parameters.get("JVMRoute"));
assertEquals("/context", parameters.get("Context"));
assertEquals("host,alias1,alias2", parameters.get("Alias"));
@@ -458,13 +458,13 @@
EasyMock.expect(engine.getJvmRoute()).andReturn("host1");
// Building request
- EasyMock.expect(context.getParent()).andReturn(container);
- EasyMock.expect(container.getParent()).andReturn(engine);
- EasyMock.expect(engine.getJvmRoute()).andReturn("host1");
EasyMock.expect(context.getPath()).andReturn("/context");
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");
this.mcmpHandler.sendRequest(EasyMock.capture(capturedRequest));
@@ -478,12 +478,12 @@
assertSame(MCMPRequestType.REMOVE_APP, request.getRequestType());
assertFalse(request.isWildcard());
+ assertEquals("host1", request.getJvmRoute());
Map<String, String> parameters = request.getParameters();
- assertEquals(3, parameters.size());
+ assertEquals(2, parameters.size());
- assertEquals("host1", parameters.get("JVMRoute"));
assertEquals("/context", parameters.get("Context"));
assertEquals("host,alias1,alias2", parameters.get("Alias"));
@@ -543,11 +543,11 @@
assertSame(MCMPRequestType.STATUS, request.getRequestType());
assertFalse(request.isWildcard());
+ assertEquals("host1", request.getJvmRoute());
Map<String, String> parameters = request.getParameters();
- assertEquals(2, parameters.size());
- assertEquals("host1", parameters.get("JVMRoute"));
+ assertEquals(1, parameters.size());
assertEquals("10", parameters.get("Load"));
EasyMock.reset(this.mcmpHandler, this.provider, engine);
@@ -627,11 +627,11 @@
assertSame(MCMPRequestType.CONFIG, request.getRequestType());
assertFalse(request.isWildcard());
+ assertEquals("host1", request.getJvmRoute());
Map<String, String> parameters = request.getParameters();
- assertEquals(17, parameters.size());
- assertEquals("host1", parameters.get("JVMRoute"));
+ assertEquals(16, parameters.size());
assertEquals("127.0.0.1", parameters.get("Host"));
assertEquals("0", parameters.get("Port"));
assertEquals("ajp", parameters.get("Type"));
@@ -701,7 +701,8 @@
assertSame(MCMPRequestType.REMOVE_APP, request.getRequestType());
assertTrue(request.isWildcard());
- assertEquals(Collections.singletonMap("JVMRoute", "host1"), request.getParameters());
+ assertEquals("host1", request.getJvmRoute());
+ assertTrue(request.getParameters().isEmpty());
EasyMock.reset(this.mcmpHandler, this.nodeConfig, this.balancerConfig, server, service, engine, container, context);
}
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-02 15:31:06 UTC (rev 1925)
+++ trunk/mod_cluster/src/test/java/org/jboss/modcluster/ModClusterServiceTestCase.java 2008-10-02 16:27:48 UTC (rev 1926)
@@ -30,7 +30,6 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.TreeMap;
import java.util.TreeSet;
import junit.framework.TestCase;
@@ -303,11 +302,10 @@
assertSame(MCMPRequestType.CONFIG, request.getRequestType());
assertFalse(request.isWildcard());
-
+ assertEquals("host1", request.getJvmRoute());
Map<String, String> parameters = request.getParameters();
- assertEquals(17, parameters.size());
- assertEquals("host1", parameters.get("JVMRoute"));
+ assertEquals(16, parameters.size());
assertEquals("127.0.0.1", parameters.get("Host"));
assertEquals("0", parameters.get("Port"));
assertEquals("ajp", parameters.get("Type"));
@@ -398,7 +396,8 @@
assertSame(MCMPRequestType.REMOVE_APP, request.getRequestType());
assertTrue(request.isWildcard());
- assertEquals(Collections.singletonMap("JVMRoute", "host1"), request.getParameters());
+ assertEquals("host1", request.getJvmRoute());
+ assertTrue(request.getParameters().isEmpty());
assertTrue(this.modClusterService.drmEntry.getJvmRoutes().isEmpty());
@@ -460,13 +459,13 @@
EasyMock.expect(context.isStarted()).andReturn(true);
// Building request
- EasyMock.expect(context.getParent()).andReturn(container);
- EasyMock.expect(container.getParent()).andReturn(engine);
- EasyMock.expect(engine.getJvmRoute()).andReturn("host1");
EasyMock.expect(context.getPath()).andReturn("/context");
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");
this.clusteredMCMPHandler.sendRequest(EasyMock.capture(capturedRequest));
@@ -480,12 +479,12 @@
assertSame(MCMPRequestType.ENABLE_APP, request.getRequestType());
assertFalse(request.isWildcard());
+ assertEquals("host1", request.getJvmRoute());
Map<String, String> parameters = request.getParameters();
- assertEquals(3, parameters.size());
+ assertEquals(2, parameters.size());
- assertEquals("host1", parameters.get("JVMRoute"));
assertEquals("/context", parameters.get("Context"));
assertEquals("host,alias1,alias2", parameters.get("Alias"));
@@ -522,13 +521,13 @@
EasyMock.expect(container.getName()).andReturn("parent-container");
// Building request
- EasyMock.expect(context.getParent()).andReturn(container);
- EasyMock.expect(container.getParent()).andReturn(engine);
- EasyMock.expect(engine.getJvmRoute()).andReturn("host1");
EasyMock.expect(context.getPath()).andReturn("/context");
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");
this.clusteredMCMPHandler.sendRequest(EasyMock.capture(capturedRequest));
@@ -542,12 +541,12 @@
assertSame(MCMPRequestType.ENABLE_APP, request.getRequestType());
assertFalse(request.isWildcard());
+ assertEquals("host1", request.getJvmRoute());
Map<String, String> parameters = request.getParameters();
- assertEquals(3, parameters.size());
+ assertEquals(2, parameters.size());
- assertEquals("host1", parameters.get("JVMRoute"));
assertEquals("/context", parameters.get("Context"));
assertEquals("host,alias1,alias2", parameters.get("Alias"));
@@ -584,13 +583,13 @@
EasyMock.expect(container.getName()).andReturn("parent-container");
// Building request
- EasyMock.expect(context.getParent()).andReturn(container);
- EasyMock.expect(container.getParent()).andReturn(engine);
- EasyMock.expect(engine.getJvmRoute()).andReturn("host1");
EasyMock.expect(context.getPath()).andReturn("/context");
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");
this.clusteredMCMPHandler.sendRequest(EasyMock.capture(capturedRequest));
@@ -604,12 +603,12 @@
assertSame(MCMPRequestType.STOP_APP, request.getRequestType());
assertFalse(request.isWildcard());
+ assertEquals("host1", request.getJvmRoute());
Map<String, String> parameters = request.getParameters();
- assertEquals(3, parameters.size());
+ assertEquals(2, parameters.size());
- assertEquals("host1", parameters.get("JVMRoute"));
assertEquals("/context", parameters.get("Context"));
assertEquals("host,alias1,alias2", parameters.get("Alias"));
@@ -662,13 +661,13 @@
EasyMock.expect(engine.getJvmRoute()).andReturn("host1");
// Building request
- EasyMock.expect(context.getParent()).andReturn(container);
- EasyMock.expect(container.getParent()).andReturn(engine);
- EasyMock.expect(engine.getJvmRoute()).andReturn("host1");
EasyMock.expect(context.getPath()).andReturn("/context");
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");
this.clusteredMCMPHandler.sendRequest(EasyMock.capture(capturedRequest));
@@ -682,12 +681,12 @@
assertSame(MCMPRequestType.REMOVE_APP, request.getRequestType());
assertFalse(request.isWildcard());
+ assertEquals("host1", request.getJvmRoute());
Map<String, String> parameters = request.getParameters();
- assertEquals(3, parameters.size());
+ assertEquals(2, parameters.size());
- assertEquals("host1", parameters.get("JVMRoute"));
assertEquals("/context", parameters.get("Context"));
assertEquals("host,alias1,alias2", parameters.get("Alias"));
@@ -769,8 +768,9 @@
MCMPServerDiscoveryEvent event1 = new MCMPServerDiscoveryEvent(remoteNode1, new AddressPort(address1, 1), true, 1);
MCMPServerDiscoveryEvent event2 = new MCMPServerDiscoveryEvent(remoteNode2, new AddressPort(address2, 2), false, 2);
- MCMPRequest request1 = new MCMPRequest(MCMPRequestType.ENABLE_APP, false, new TreeMap<String, String>());
- MCMPRequest request2 = new MCMPRequest(MCMPRequestType.DISABLE_APP, false, new TreeMap<String, String>());
+ Map<String, String> emptyMap = Collections.emptyMap();
+ MCMPRequest request1 = new MCMPRequest(MCMPRequestType.ENABLE_APP, false, "route", emptyMap);
+ MCMPRequest request2 = new MCMPRequest(MCMPRequestType.DISABLE_APP, false, "route", emptyMap);
Capture<List<MCMPRequest>> capturedRequests = new Capture<List<MCMPRequest>>();
Capture<ModClusterServiceDRMEntry> capturedEntry = new Capture<ModClusterServiceDRMEntry>();
Capture<Object[]> capturedArgs = new Capture<Object[]>();
@@ -844,14 +844,14 @@
assertSame(MCMPRequestType.STATUS, requests.get(0).getRequestType());
assertFalse(requests.get(0).isWildcard());
- assertEquals(2, requests.get(0).getParameters().size());
- assertEquals("host2", requests.get(0).getParameters().get("JVMRoute"));
+ assertEquals("host2", requests.get(0).getJvmRoute());
+ assertEquals(1, requests.get(0).getParameters().size());
assertEquals("20", requests.get(0).getParameters().get("Load"));
assertSame(MCMPRequestType.STATUS, requests.get(1).getRequestType());
assertFalse(requests.get(1).isWildcard());
- assertEquals(2, requests.get(1).getParameters().size());
- assertEquals("host1", requests.get(1).getParameters().get("JVMRoute"));
+ assertEquals("host1", requests.get(1).getJvmRoute());
+ assertEquals(1, requests.get(1).getParameters().size());
assertEquals("10", requests.get(1).getParameters().get("Load"));
ModClusterServiceDRMEntry entry = capturedEntry.getValue();
Modified: trunk/mod_cluster/src/test/java/org/jboss/modcluster/ha/ClusteredMCMPHandlerTestCase.java
===================================================================
--- trunk/mod_cluster/src/test/java/org/jboss/modcluster/ha/ClusteredMCMPHandlerTestCase.java 2008-10-02 15:31:06 UTC (rev 1925)
+++ trunk/mod_cluster/src/test/java/org/jboss/modcluster/ha/ClusteredMCMPHandlerTestCase.java 2008-10-02 16:27:48 UTC (rev 1926)
@@ -665,7 +665,7 @@
public void testSendRequest() throws Exception
{
- MCMPRequest request = new MCMPRequest(MCMPRequestType.INFO, false, Collections.singletonMap("name", "value"));
+ MCMPRequest request = new MCMPRequest(MCMPRequestType.INFO, false, "route", Collections.singletonMap("name", "value"));
// Test master use case
EasyMock.expect(this.singleton.isMasterNode()).andReturn(true);
Modified: trunk/mod_cluster/src/test/java/org/jboss/modcluster/ha/HASingletonAwareResetRequestSourceTestCase.java
===================================================================
--- trunk/mod_cluster/src/test/java/org/jboss/modcluster/ha/HASingletonAwareResetRequestSourceTestCase.java 2008-10-02 15:31:06 UTC (rev 1925)
+++ trunk/mod_cluster/src/test/java/org/jboss/modcluster/ha/HASingletonAwareResetRequestSourceTestCase.java 2008-10-02 16:27:48 UTC (rev 1926)
@@ -63,8 +63,9 @@
public void testGetResetRequests() throws Exception
{
- MCMPRequest request1 = new MCMPRequest(MCMPRequestType.ENABLE_APP, false, Collections.singletonMap("JVMRoute", "host1"));
- MCMPRequest request2 = new MCMPRequest(MCMPRequestType.REMOVE_APP, false, Collections.singletonMap("JVMRoute", "host2"));
+ Map<String, String> emptyMap = Collections.emptyMap();
+ MCMPRequest request1 = new MCMPRequest(MCMPRequestType.ENABLE_APP, false, "host1", emptyMap);
+ MCMPRequest request2 = new MCMPRequest(MCMPRequestType.REMOVE_APP, false, "host2", emptyMap);
ResetRequestGroupRpcResponse response1 = new ResetRequestGroupRpcResponse(EasyMock.createMock(ClusterNode.class), Collections.singletonList(request1));
ResetRequestGroupRpcResponse response2 = new ResetRequestGroupRpcResponse(EasyMock.createMock(ClusterNode.class), Collections.singletonList(request2));
@@ -133,13 +134,13 @@
EasyMock.expect(container.findChildren()).andReturn(new Container[] { context });
EasyMock.expect(context.isStarted()).andReturn(true);
- EasyMock.expect(context.getParent()).andReturn(container);
- EasyMock.expect(container.getParent()).andReturn(engine);
- EasyMock.expect(engine.getJvmRoute()).andReturn("host1");
EasyMock.expect(context.getPath()).andReturn("/context");
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.replay(this.singleton, this.key, this.partition, server, service, engine, container, context, host, this.nodeConfig, this.balancerConfig);
@@ -154,16 +155,16 @@
assertSame(MCMPRequestType.REMOVE_APP, request.getRequestType());
assertTrue(request.isWildcard());
- assertEquals(1, parameters.size());
- assertEquals("host", parameters.get("JVMRoute"));
+ assertEquals("host", request.getJvmRoute());
+ assertTrue(request.getParameters().isEmpty());
request = results.get(1);
parameters = request.getParameters();
assertSame(MCMPRequestType.CONFIG, request.getRequestType());
assertFalse(request.isWildcard());
- assertEquals(17, parameters.size());
- assertEquals("host1", parameters.get("JVMRoute"));
+ assertEquals("host1", request.getJvmRoute());
+ assertEquals(16, parameters.size());
assertEquals("127.0.0.1", parameters.get("Host"));
assertEquals("0", parameters.get("Port"));
assertEquals("ajp", parameters.get("Type"));
@@ -186,8 +187,8 @@
assertSame(MCMPRequestType.ENABLE_APP, request.getRequestType());
assertFalse(request.isWildcard());
- assertEquals(3, parameters.size());
- assertEquals("host1", parameters.get("JVMRoute"));
+ assertEquals("host1", request.getJvmRoute());
+ assertEquals(2, parameters.size());
assertEquals("/context", parameters.get("Context"));
assertEquals("host,alias1,alias2", parameters.get("Alias"));
@@ -249,13 +250,13 @@
EasyMock.expect(container.findChildren()).andReturn(new Container[] { context });
EasyMock.expect(context.isStarted()).andReturn(true);
- EasyMock.expect(context.getParent()).andReturn(container);
- EasyMock.expect(container.getParent()).andReturn(engine);
- EasyMock.expect(engine.getJvmRoute()).andReturn("host1");
EasyMock.expect(context.getPath()).andReturn("/context");
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.replay(this.singleton, this.key, this.partition, server, service, engine, container, context, host, this.nodeConfig, this.balancerConfig);
@@ -266,20 +267,19 @@
assertEquals(3, results.size());
MCMPRequest request = results.get(0);
- Map<String, String> parameters = request.getParameters();
assertSame(MCMPRequestType.REMOVE_APP, request.getRequestType());
assertTrue(request.isWildcard());
- assertEquals(1, parameters.size());
- assertEquals("host", parameters.get("JVMRoute"));
+ assertEquals("host", request.getJvmRoute());
+ assertTrue(request.getParameters().isEmpty());
request = results.get(1);
- parameters = request.getParameters();
+ Map<String, String> parameters = request.getParameters();
assertSame(MCMPRequestType.CONFIG, request.getRequestType());
assertFalse(request.isWildcard());
- assertEquals(17, parameters.size());
- assertEquals("host1", parameters.get("JVMRoute"));
+ assertEquals("host1", request.getJvmRoute());
+ assertEquals(16, parameters.size());
assertEquals("127.0.0.1", parameters.get("Host"));
assertEquals("0", parameters.get("Port"));
assertEquals("ajp", parameters.get("Type"));
@@ -302,8 +302,8 @@
assertSame(MCMPRequestType.ENABLE_APP, request.getRequestType());
assertFalse(request.isWildcard());
- assertEquals(3, parameters.size());
- assertEquals("host1", parameters.get("JVMRoute"));
+ assertEquals("host1", request.getJvmRoute());
+ assertEquals(2, parameters.size());
assertEquals("/context", parameters.get("Context"));
assertEquals("host,alias1,alias2", parameters.get("Alias"));
16 years, 3 months
JBoss Native SVN: r1925 - in trunk/mod_cluster/native: mod_manager and 1 other directory.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2008-10-02 11:31:06 -0400 (Thu, 02 Oct 2008)
New Revision: 1925
Modified:
trunk/mod_cluster/native/include/node.h
trunk/mod_cluster/native/mod_manager/mod_manager.c
trunk/mod_cluster/native/mod_manager/node.c
Log:
Make the lock/unlock stuff available to mod_proxy_cluster.
Modified: trunk/mod_cluster/native/include/node.h
===================================================================
--- trunk/mod_cluster/native/include/node.h 2008-10-01 14:46:13 UTC (rev 1924)
+++ trunk/mod_cluster/native/include/node.h 2008-10-02 15:31:06 UTC (rev 1925)
@@ -117,6 +117,20 @@
*/
apr_status_t remove_node(mem_t *s, nodeinfo_t *node);
+/**
+ * Lock the whole the shared table
+ * @param pointer to the shared table.
+ * @return APR_SUCCESS if all went well
+ */
+apr_status_t lock_node(mem_t *s);
+
+/**
+ * Unlock the whole the shared table
+ * @param pointer to the shared table.
+ * @return APR_SUCCESS if all went well
+ */
+apr_status_t unlock_node(mem_t *s);
+
/*
* get the ids for the used (not free) nodes in the table
* @param pointer to the shared table.
@@ -188,5 +202,13 @@
* Find the node using the JVMRoute information
*/
int (*find_node)(nodeinfo_t **node, const char *route);
+/*
+ * Lock the whole node table
+ */
+int (*lock_nodes)();
+/*
+ * Unlock the whole node table
+ */
+int (*unlock_nodes)();
};
#endif /*NODE_H*/
Modified: trunk/mod_cluster/native/mod_manager/mod_manager.c
===================================================================
--- trunk/mod_cluster/native/mod_manager/mod_manager.c 2008-10-01 14:46:13 UTC (rev 1924)
+++ trunk/mod_cluster/native/mod_manager/mod_manager.c 2008-10-02 15:31:06 UTC (rev 1925)
@@ -134,6 +134,14 @@
{
return (find_node(nodestatsmem, node, route));
}
+static apr_status_t loc_unlock_node()
+{
+ return (unlock_node(nodestatsmem));
+}
+static apr_status_t loc_lock_node()
+{
+ return (lock_node(nodestatsmem));
+}
/* Check is the nodes (in shared memory) were modified since last
* call to worker_nodes_are_updated().
@@ -182,7 +190,9 @@
loc_worker_nodes_need_update,
loc_worker_nodes_are_updated,
loc_remove_node,
- loc_find_node
+ loc_find_node,
+ loc_lock_node,
+ loc_unlock_node
};
/*
Modified: trunk/mod_cluster/native/mod_manager/node.c
===================================================================
--- trunk/mod_cluster/native/mod_manager/node.c 2008-10-01 14:46:13 UTC (rev 1924)
+++ trunk/mod_cluster/native/mod_manager/node.c 2008-10-02 15:31:06 UTC (rev 1925)
@@ -213,6 +213,26 @@
return rv;
}
+/**
+ * Lock the shared table
+ * @param pointer to the shared table.
+ * @return APR_SUCCESS if all went well
+ */
+apr_status_t lock_node(mem_t *s)
+{
+ return (s->storage->ap_slotmem_lock(s->slotmem));
+}
+
+/**
+ * Unlock the shared table
+ * @param pointer to the shared table.
+ * @return APR_SUCCESS if all went well
+ */
+apr_status_t unlock_node(mem_t *s)
+{
+ return (s->storage->ap_slotmem_unlock(s->slotmem));
+}
+
/*
* get the ids for the used (not free) nodes in the table
* @param pointer to the shared table.
16 years, 3 months