JBoss Native SVN: r1747 - trunk/mod_cluster/native/mod_proxy_cluster.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2008-07-11 09:00:50 -0400 (Fri, 11 Jul 2008)
New Revision: 1747
Modified:
trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c
Log:
Skip removed nodes.
Modified: trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c
===================================================================
--- trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c 2008-07-11 11:49:22 UTC (rev 1746)
+++ trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c 2008-07-11 13:00:50 UTC (rev 1747)
@@ -1215,6 +1215,9 @@
while (!checked_standby) {
worker = (proxy_worker *)balancer->workers->elts;
for (i = 0; i < balancer->workers->nelts; i++, worker++) {
+ if (worker->id == 0)
+ continue; /* marked removed */
+
if ( (checking_standby ? !PROXY_WORKER_IS_STANDBY(worker) : PROXY_WORKER_IS_STANDBY(worker)) )
continue;
if (*(worker->s->route) && strcmp(worker->s->route, route) == 0) {
16 years, 5 months
JBoss Native SVN: r1746 - trunk/mod_cluster/test/java/org/jboss/mod_cluster.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2008-07-11 07:49:22 -0400 (Fri, 11 Jul 2008)
New Revision: 1746
Added:
trunk/mod_cluster/test/java/org/jboss/mod_cluster/NodeInfo.java
trunk/mod_cluster/test/java/org/jboss/mod_cluster/TestAddDel.java
Modified:
trunk/mod_cluster/test/java/org/jboss/mod_cluster/Maintest.java
Log:
Add a test that adds and removes 10 nodes.
Modified: trunk/mod_cluster/test/java/org/jboss/mod_cluster/Maintest.java
===================================================================
--- trunk/mod_cluster/test/java/org/jboss/mod_cluster/Maintest.java 2008-07-11 09:59:44 UTC (rev 1745)
+++ trunk/mod_cluster/test/java/org/jboss/mod_cluster/Maintest.java 2008-07-11 11:49:22 UTC (rev 1746)
@@ -49,6 +49,8 @@
public static Test suite() {
TestSuite suite = new TestSuite();
server = (StandardServer) ServerFactory.getServer();
+ suite.addTest(new TestSuite(TestAddDel.class));
+ System.gc();
suite.addTest(new TestSuite(TestBase.class));
System.gc();
suite.addTest(new TestSuite(TestFailover.class));
Added: trunk/mod_cluster/test/java/org/jboss/mod_cluster/NodeInfo.java
===================================================================
--- trunk/mod_cluster/test/java/org/jboss/mod_cluster/NodeInfo.java (rev 0)
+++ trunk/mod_cluster/test/java/org/jboss/mod_cluster/NodeInfo.java 2008-07-11 11:49:22 UTC (rev 1746)
@@ -0,0 +1,81 @@
+/*
+ * mod_cluster
+ *
+ * Copyright(c) 2008 Red Hat Middleware, LLC,
+ * and individual contributors as indicated by the @authors tag.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This library 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 of the License, or (at your option) any later version.
+ *
+ * This library 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 library in the file COPYING.LIB;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * @author Jean-Frederic Clere
+ * @version $Revision$
+ */
+
+package org.jboss.mod_cluster;
+
+import java.util.ArrayList;
+
+public class NodeInfo {
+ String JVMRoute;
+ int status;
+ int lbfactor;
+ int elected;
+ int removed;
+
+ /**
+ * Check that nodes in nodeinfos corresponds to nodes in nodenames
+ */
+ static public boolean check(ArrayList nodes, String [] nodenames)
+ {
+ boolean [] in = new boolean[nodenames.length];
+
+ if (nodes == null || nodenames == null)
+ return false;
+
+ NodeInfo [] nodeinfos = new NodeInfo[nodes.size()];
+ for (int i=0; i<nodeinfos.length; i++) {
+ nodeinfos[i] = (NodeInfo) nodes.get(i);
+ }
+
+ for (int i=0; i<nodenames.length; i++)
+ in[i] = false;
+
+ for (int i=0; i<nodenames.length; i++) {
+ boolean hasit = false;
+ for (int j=0; j<nodeinfos.length; j++) {
+ if (nodeinfos[j].JVMRoute.equals(nodenames[i])) {
+ if (in[i])
+ return false; // twice.
+ if (nodeinfos[j].removed == 0) {
+ in[i] = true;
+ hasit = true;
+ }
+ }
+ }
+ if (!hasit)
+ return false; // not found.
+ }
+ int i = 0;
+ for (int j=0; j<nodeinfos.length; j++) {
+ if (nodeinfos[j].removed == 0)
+ i++;
+ }
+ if (i != nodenames.length)
+ return false; // Too many route entries in httpd.
+ return true;
+ }
+}
Added: trunk/mod_cluster/test/java/org/jboss/mod_cluster/TestAddDel.java
===================================================================
--- trunk/mod_cluster/test/java/org/jboss/mod_cluster/TestAddDel.java (rev 0)
+++ trunk/mod_cluster/test/java/org/jboss/mod_cluster/TestAddDel.java 2008-07-11 11:49:22 UTC (rev 1746)
@@ -0,0 +1,168 @@
+/*
+ * mod_cluster
+ *
+ * Copyright(c) 2008 Red Hat Middleware, LLC,
+ * and individual contributors as indicated by the @authors tag.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This library 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 of the License, or (at your option) any later version.
+ *
+ * This library 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 library in the file COPYING.LIB;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * @author Jean-Frederic Clere
+ * @version $Revision$
+ */
+
+package org.jboss.mod_cluster;
+
+import java.io.IOException;
+
+import java.util.ArrayList;
+
+import junit.framework.TestCase;
+
+import org.apache.catalina.Engine;
+import org.apache.catalina.ServerFactory;
+import org.apache.catalina.Service;
+import org.apache.catalina.LifecycleListener;
+import org.apache.catalina.LifecycleException;
+import org.apache.catalina.connector.Connector;
+import org.apache.catalina.core.StandardServer;
+
+import org.jboss.web.cluster.ClusterListener;
+
+public class TestAddDel extends TestCase {
+
+ /* Test */
+ public void testAddDel() {
+
+ boolean clienterror = false;
+ int numbnodes = 10;
+ String [] nodenames = new String [numbnodes];
+ JBossWeb [] service = new JBossWeb[numbnodes];
+ ClusterListener cluster = null;
+
+ StandardServer server = Maintest.getServer();
+ for (int i=0; i<numbnodes; i++) {
+ try {
+ // server = (StandardServer) ServerFactory.getServer();
+ String name = "node" + i;
+ nodenames[i] = name;
+ service[i] = new JBossWeb(name, "localhost");
+ service[i].addConnector(8009 + i);
+ server.addService(service[i]);
+
+ } catch(IOException ex) {
+ ex.printStackTrace();
+ fail("can't start service");
+ }
+ }
+
+ cluster = new ClusterListener();
+ cluster.setAdvertiseGroupAddress("232.0.0.2");
+ cluster.setAdvertisePort(23364);
+ cluster.setSsl(false);
+ // SSL ?
+ server.addLifecycleListener((LifecycleListener) cluster);
+
+ // Debug Stuff
+ Maintest.listServices();
+
+ // start the server thread.
+ ServerThread wait = new ServerThread(3000, server);
+ wait.start();
+
+ // Wait until httpd as received the nodes information.
+ try {
+ Thread.sleep(30000);
+ } catch (InterruptedException ex) {
+ ex.printStackTrace();
+ }
+
+ // Read the result via INFO.
+ String result = cluster.getProxyInfo();
+ ArrayList nodes = new ArrayList();
+ if (result != null) {
+ System.out.println(result);
+ String [] records = result.split("\n");
+ int l = 0;
+ for (int i=0; i<records.length; i++) {
+ // System.out.println("records[" + i + "]: " + records[i]);
+ NodeInfo nodeinfo = null;
+ String [] results = records[i].split(",");
+ for (int j=0; j<results.length; j++, l++) {
+ // System.out.println("results[" + j + "]: " + results[j]);
+ String [] data = results[j].split(": ");
+ // System.out.println("data[" + 0 + "]: " + data[0] + "*");
+ if ("node".equals(data[0]) && nodeinfo == null) {
+ nodeinfo = new NodeInfo();
+ continue;
+ }
+ if ("JVMRoute".equals(data[0])) {
+ nodeinfo.JVMRoute = data[1];
+ }
+ else if ("status".equals(data[0])) {
+ nodeinfo.status = Integer.valueOf(data[1]).intValue();
+ }
+ else if ("lbfactor".equals(data[0])) {
+ nodeinfo.lbfactor = Integer.valueOf(data[1]).intValue();
+ }
+ else if ("elected".equals(data[0])) {
+ nodeinfo.elected = Integer.valueOf(data[1]).intValue();
+ }
+ else if ("removed".equals(data[0])) {
+ nodeinfo.removed = Integer.valueOf(data[1]).intValue();
+ }
+ }
+ if (nodeinfo != null) {
+ // System.out.println("Adding: " + nodeinfo);
+ nodes.add(nodeinfo);
+ }
+ }
+ } else
+ clienterror = true;
+
+ // Check the nodes.
+ if (!clienterror) {
+ if (!NodeInfo.check(nodes, nodenames))
+ clienterror = true;
+ }
+
+ // Stop the jboss and remove the services.
+ try {
+ wait.stopit();
+ wait.join();
+
+ for (int i=0; i<numbnodes; i++) {
+ server.removeService(service[i]);
+ }
+ server.removeLifecycleListener(cluster);
+ } catch (InterruptedException ex) {
+ ex.printStackTrace();
+ fail("can't stop service");
+ }
+ // Wait until httpd as received the stop messages.
+ System.gc();
+ try {
+ Thread.sleep(20000);
+ } catch (InterruptedException ex) {
+ ex.printStackTrace();
+ }
+
+ if (clienterror)
+ fail("Client error");
+
+ }
+}
16 years, 5 months
JBoss Native SVN: r1745 - trunk/mod_cluster/native/mod_manager.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2008-07-11 05:59:44 -0400 (Fri, 11 Jul 2008)
New Revision: 1745
Modified:
trunk/mod_cluster/native/mod_manager/mod_manager.c
Log:
Make parse of the INFO/DUMP more easy.
Modified: trunk/mod_cluster/native/mod_manager/mod_manager.c
===================================================================
--- trunk/mod_cluster/native/mod_manager/mod_manager.c 2008-07-10 09:28:11 UTC (rev 1744)
+++ trunk/mod_cluster/native/mod_manager/mod_manager.c 2008-07-11 09:59:44 UTC (rev 1745)
@@ -694,7 +694,7 @@
for (i=0; i<size; i++) {
nodeinfo_t *ou;
get_node(nodestatsmem, &ou, id[i]);
- ap_rprintf(r, "node: [%d:%d] Balancer: %s JVMRoute: %s Domain: [%s] Host: %s Port: %s Type: %s flushpackets: %d flushwait: %d ping: %d smax: %d ttl: %d timeout: %d\n",
+ ap_rprintf(r, "node: [%d:%d],Balancer: %s,JVMRoute: %s,Domain: [%s],Host: %s,Port: %s,Type: %s,flushpackets: %d,flushwait: %d,ping: %d,smax: %d,ttl: %d,timeout: %d\n",
id[i], ou->mess.id, ou->mess.balancer, ou->mess.JVMRoute, ou->mess.Domain,
ou->mess.Host, ou->mess.Port, ou->mess.Type,
ou->mess.flushpackets, ou->mess.flushwait/1000, apr_time_sec(ou->mess.ping), ou->mess.smax,
@@ -741,12 +741,12 @@
nodeinfo_t *ou;
proxy_worker_stat *proxystat;
get_node(nodestatsmem, &ou, id[i]);
- ap_rprintf(r, "node: [%d:%d] JVMRoute: %s Domain: [%s] Host: %s Port: %s Type: %s\n",
+ ap_rprintf(r, "node: [%d:%d],JVMRoute: %s,Domain: [%s],Host: %s,Port: %s,Type: %s",
id[i], ou->mess.id, ou->mess.JVMRoute, ou->mess.Domain,
ou->mess.Host, ou->mess.Port, ou->mess.Type);
proxystat = (proxy_worker_stat *) ou->stat;
- ap_rprintf(r, " [%d:%d] (%d) status: %d elected: %d lbstatus: %d lbfactor: %d route: %s\n",
- id[i], ou->mess.id, ou->mess.remove,
+ ap_rprintf(r, ",removed: %d,status: %d,elected: %d,lbstatus: %d,lbfactor: %d,route: %s\n",
+ ou->mess.remove,
proxystat->status, proxystat->elected, proxystat->lbstatus,
proxystat->lbfactor, proxystat->route);
16 years, 5 months
JBoss Native SVN: r1744 - trunk/build/install/xtool.
by jbossnative-commits@lists.jboss.org
Author: mladen.turk(a)jboss.com
Date: 2008-07-10 05:28:11 -0400 (Thu, 10 Jul 2008)
New Revision: 1744
Modified:
trunk/build/install/xtool/commonc.manifest
Log:
It's a tool not installer
Modified: trunk/build/install/xtool/commonc.manifest
===================================================================
--- trunk/build/install/xtool/commonc.manifest 2008-07-10 09:26:59 UTC (rev 1743)
+++ trunk/build/install/xtool/commonc.manifest 2008-07-10 09:28:11 UTC (rev 1744)
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
-<assemblyIdentity version="3.1.0.0" processorArchitecture="*" name="JBoss Installer" type="win32" />
-<description>JBoss Windows Installer</description>
+<assemblyIdentity version="3.1.0.0" processorArchitecture="*" name="JBoss generic build tool" type="win32" />
+<description>JBoss Generic build tool</description>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*" />
16 years, 5 months
JBoss Native SVN: r1743 - trunk/build/install/xtool.
by jbossnative-commits@lists.jboss.org
Author: mladen.turk(a)jboss.com
Date: 2008-07-10 05:26:59 -0400 (Thu, 10 Jul 2008)
New Revision: 1743
Modified:
trunk/build/install/xtool/xtool.c
Log:
Add xcopy program to the descriptions
Modified: trunk/build/install/xtool/xtool.c
===================================================================
--- trunk/build/install/xtool/xtool.c 2008-07-09 14:36:11 UTC (rev 1742)
+++ trunk/build/install/xtool/xtool.c 2008-07-10 09:26:59 UTC (rev 1743)
@@ -3350,6 +3350,7 @@
"msg", "Display MessageBox",
"jdk", "Find JDK/JRE location",
"dir", "Browse for File or Folder",
+ "xcopy", "Copy files or folders with progress",
NULL, NULL
};
16 years, 5 months
JBoss Native SVN: r1742 - trunk/mod_cluster/test/java/org/jboss/mod_cluster.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2008-07-09 10:36:11 -0400 (Wed, 09 Jul 2008)
New Revision: 1742
Added:
trunk/mod_cluster/test/java/org/jboss/mod_cluster/ServerThread.java
Modified:
trunk/mod_cluster/test/java/org/jboss/mod_cluster/Client.java
trunk/mod_cluster/test/java/org/jboss/mod_cluster/TestBase.java
trunk/mod_cluster/test/java/org/jboss/mod_cluster/TestFailover.java
Log:
Use ServerThread for both tests and arrange client.
Modified: trunk/mod_cluster/test/java/org/jboss/mod_cluster/Client.java
===================================================================
--- trunk/mod_cluster/test/java/org/jboss/mod_cluster/Client.java 2008-07-08 07:35:38 UTC (rev 1741)
+++ trunk/mod_cluster/test/java/org/jboss/mod_cluster/Client.java 2008-07-09 14:36:11 UTC (rev 1742)
@@ -38,7 +38,7 @@
private int nbtest = 10;
private int delay = 1000;
private boolean checkcookie = true;
- private boolean success = false;
+ private boolean success = true;
/*
*
* Usage:
@@ -133,10 +133,12 @@
}
} else {
System.out.println("Not 200");
+ success = false;
}
// System.out.println("response:\n" + pm.getResponseBodyAsString(len));
} catch(HttpException e) {
e.printStackTrace();
+ success = false;
}
System.out.println("DONE: " + httpResponseCode);
pm.releaseConnection();
@@ -149,13 +151,18 @@
for (int i = 0; i < nbtest; i++) {
try {
- if (runit() != 0) return;
+ if (runit() != 0) {
+ success = false;
+ return;
+ }
sleep((int)(Math.random() * 1000));
} catch (InterruptedException e) {
- } catch (Exception e) {}
+ success = false;
+ } catch (Exception e) {
+ success = false;
+ }
}
System.out.println("DONE!");
- success = true;
}
public boolean getresultok() {
return success;
Added: trunk/mod_cluster/test/java/org/jboss/mod_cluster/ServerThread.java
===================================================================
--- trunk/mod_cluster/test/java/org/jboss/mod_cluster/ServerThread.java (rev 0)
+++ trunk/mod_cluster/test/java/org/jboss/mod_cluster/ServerThread.java 2008-07-09 14:36:11 UTC (rev 1742)
@@ -0,0 +1,67 @@
+/*
+ * mod_cluster
+ *
+ * Copyright(c) 2008 Red Hat Middleware, LLC,
+ * and individual contributors as indicated by the @authors tag.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This library 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 of the License, or (at your option) any later version.
+ *
+ * This library 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 library in the file COPYING.LIB;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * @author Jean-Frederic Clere
+ * @version $Revision$
+ */
+
+package org.jboss.mod_cluster;
+
+import java.io.IOException;
+
+import org.apache.catalina.Engine;
+import org.apache.catalina.ServerFactory;
+import org.apache.catalina.Service;
+import org.apache.catalina.LifecycleListener;
+import org.apache.catalina.LifecycleException;
+import org.apache.catalina.connector.Connector;
+import org.apache.catalina.core.StandardServer;
+
+import org.jboss.web.cluster.ClusterListener;
+
+public class ServerThread extends Thread {
+ int delay;
+ boolean ok = true;
+ StandardServer server = null;
+
+ public ServerThread(int delay, StandardServer server) {
+ this.delay = delay;
+ this.server = server;
+ }
+ public void run() {
+ try {
+ server.start();
+ while (ok) {
+ Thread.sleep(delay);
+ }
+ // sleep(delay);
+ server.stop();
+ } catch (InterruptedException e) {
+ } catch (LifecycleException ex) {
+ ex.printStackTrace();
+ }
+ }
+ public void stopit() {
+ ok = false;
+ }
+}
Modified: trunk/mod_cluster/test/java/org/jboss/mod_cluster/TestBase.java
===================================================================
--- trunk/mod_cluster/test/java/org/jboss/mod_cluster/TestBase.java 2008-07-08 07:35:38 UTC (rev 1741)
+++ trunk/mod_cluster/test/java/org/jboss/mod_cluster/TestBase.java 2008-07-09 14:36:11 UTC (rev 1742)
@@ -46,6 +46,7 @@
/* Test */
public void testBase() {
+ boolean clienterror = false;
StandardServer server = Maintest.getServer();
JBossWeb service = null;
JBossWeb service2 = null;
@@ -71,14 +72,15 @@
// Debug Stuff
Maintest.listServices();
- server.start();
-
} catch(IOException ex) {
ex.printStackTrace();
- } catch (LifecycleException ex) {
- ex.printStackTrace();
+ fail("can't start service");
}
+ // start the server thread.
+ ServerThread wait = new ServerThread(3000, server);
+ wait.start();
+
// Wait until httpd as received the nodes information.
try {
Thread.sleep(20000);
@@ -96,23 +98,29 @@
client.join();
} catch (Exception ex) {
ex.printStackTrace();
+ clienterror = true;
}
if (client.getresultok())
System.out.println("Test DONE");
- else
+ else {
System.out.println("Test FAILED");
+ clienterror = true;
+ }
- // Stop the server or services.
+ // Stop the jboss and remove the services.
try {
- /// service.stop();
- /// service2.stop();
- server.stop();
+ wait.stopit();
+ wait.join();
+
server.removeService(service);
server.removeService(service2);
server.removeLifecycleListener(cluster);
- } catch (LifecycleException ex) {
+ } catch (InterruptedException ex) {
ex.printStackTrace();
+ fail("can't stop service");
}
+ if (clienterror)
+ fail("Client error");
// Wait until httpd as received the stop messages.
System.gc();
Modified: trunk/mod_cluster/test/java/org/jboss/mod_cluster/TestFailover.java
===================================================================
--- trunk/mod_cluster/test/java/org/jboss/mod_cluster/TestFailover.java 2008-07-08 07:35:38 UTC (rev 1741)
+++ trunk/mod_cluster/test/java/org/jboss/mod_cluster/TestFailover.java 2008-07-09 14:36:11 UTC (rev 1742)
@@ -73,8 +73,8 @@
fail("can't start service");
}
- // start a thread.
- ServerThread wait = new ServerThread(3000);
+ // start the server thread.
+ ServerThread wait = new ServerThread(3000, server);
wait.start();
// Wait until httpd as received the nodes information.
@@ -130,7 +130,7 @@
}
// Start a server thread.
- wait = new ServerThread(3000);
+ wait = new ServerThread(3000, server);
wait.start();
// Run a test on it. (it waits until httpd as received the nodes information).
@@ -169,27 +169,4 @@
if (clienterror)
fail("Client test failed");
}
- public class ServerThread extends Thread {
- int delay;
- boolean ok = true;
- public ServerThread(int delay) {
- this.delay = delay;
- }
- public void run() {
- try {
- server.start();
- while (ok) {
- Thread.sleep(delay);
- }
- // sleep(delay);
- server.stop();
- } catch (InterruptedException e) {
- } catch (LifecycleException ex) {
- ex.printStackTrace();
- }
- }
- public void stopit() {
- ok = false;
- }
- }
}
16 years, 5 months
JBoss Native SVN: r1741 - in trunk/mod_cluster/native: mod_proxy_cluster and 1 other directory.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2008-07-08 03:35:38 -0400 (Tue, 08 Jul 2008)
New Revision: 1741
Modified:
trunk/mod_cluster/native/mod_manager/mod_manager.c
trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c
Log:
Arrange remove logic and fix small bugs.
Modified: trunk/mod_cluster/native/mod_manager/mod_manager.c
===================================================================
--- trunk/mod_cluster/native/mod_manager/mod_manager.c 2008-07-08 07:33:25 UTC (rev 1740)
+++ trunk/mod_cluster/native/mod_manager/mod_manager.c 2008-07-08 07:35:38 UTC (rev 1741)
@@ -487,6 +487,7 @@
nodeinfo.mess.smax = mpm_threads + 1;
nodeinfo.mess.ttl = apr_time_from_sec(60);
nodeinfo.mess.timeout = 0;
+ nodeinfo.mess.id = 0;
/* Fill default balancer values */
memset(&balancerinfo, '\0', sizeof(balancerinfo));
@@ -527,7 +528,7 @@
}
if (strcasecmp(ptr[i], "StickySessionRemove") == 0) {
if (strcasecmp(ptr[i+1], "yes") == 0)
- balancerinfo.StickySession = 1;
+ balancerinfo.StickySessionRemove = 1;
}
if (strcasecmp(ptr[i], "StickySessionForce") == 0) {
if (strcasecmp(ptr[i+1], "no") == 0)
@@ -641,6 +642,7 @@
node = read_node(nodestatsmem, &nodeinfo);
if (node != NULL && node->mess.remove) {
/* Here we can't update it because the old one is still in */
+ strcpy(node->mess.JVMRoute, "REMOVED");
*errtype = TYPEMEM;
return MNODERM;
}
@@ -743,8 +745,9 @@
id[i], ou->mess.id, ou->mess.JVMRoute, ou->mess.Domain,
ou->mess.Host, ou->mess.Port, ou->mess.Type);
proxystat = (proxy_worker_stat *) ou->stat;
- ap_rprintf(r, " [%d:%d] status: %d elected: %d lbstatus: %d lbfactor: %d route: %s\n",
- id[i], ou->mess.id, proxystat->status, proxystat->elected, proxystat->lbstatus,
+ ap_rprintf(r, " [%d:%d] (%d) status: %d elected: %d lbstatus: %d lbfactor: %d route: %s\n",
+ id[i], ou->mess.id, ou->mess.remove,
+ proxystat->status, proxystat->elected, proxystat->lbstatus,
proxystat->lbfactor, proxystat->route);
}
@@ -1115,7 +1118,7 @@
/* XXX: Size limit it? */
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
- "manager_handler %s processing: \"%s\"", r->method, buff);
+ "manager_handler %s (%s) processing: \"%s\"", r->method, r->uri, buff);
decodeenc(buff);
if (strcasecmp(r->method, "CONFIG") == 0)
errstring = process_config(r, buff, &errtype);
Modified: trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c
===================================================================
--- trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c 2008-07-08 07:33:25 UTC (rev 1740)
+++ trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c 2008-07-08 07:35:38 UTC (rev 1741)
@@ -260,8 +260,8 @@
worker++;
}
if (i == conf->workers->nelts) {
- node_storage->remove_node(node);
- return 0; /* Done ? */
+ /* XXX: Another process may use it, can't do: node_storage->remove_node(node); */
+ return 0; /* Done */
}
/* prevent other threads using it */
16 years, 5 months
JBoss Native SVN: r1740 - trunk/mod_cluster/test/java/org/jboss/mod_cluster.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2008-07-08 03:33:25 -0400 (Tue, 08 Jul 2008)
New Revision: 1740
Added:
trunk/mod_cluster/test/java/org/jboss/mod_cluster/TestFailover.java
Modified:
trunk/mod_cluster/test/java/org/jboss/mod_cluster/Client.java
trunk/mod_cluster/test/java/org/jboss/mod_cluster/Maintest.java
trunk/mod_cluster/test/java/org/jboss/mod_cluster/TestBase.java
Log:
Add failover tests.
Modified: trunk/mod_cluster/test/java/org/jboss/mod_cluster/Client.java
===================================================================
--- trunk/mod_cluster/test/java/org/jboss/mod_cluster/Client.java 2008-07-07 06:59:42 UTC (rev 1739)
+++ trunk/mod_cluster/test/java/org/jboss/mod_cluster/Client.java 2008-07-08 07:33:25 UTC (rev 1740)
@@ -36,6 +36,7 @@
private String URL = null;
private String command = null;
private int nbtest = 10;
+ private int delay = 1000;
private boolean checkcookie = true;
private boolean success = false;
/*
@@ -109,11 +110,13 @@
if (jsessionid == null) {
jsessionid = cookie.getValue();
System.out.println("cookie first time: " + jsessionid);
+ pm.releaseConnection();
return 0; // first time ok.
} else {
System.out.println("cookie second time: " + jsessionid);
if (jsessionid.compareTo(cookie.getValue()) == 0) {
System.out.println("cookie ok");
+ pm.releaseConnection();
return 0;
}
}
@@ -122,8 +125,10 @@
} else {
// Look in the response to make sure that there is a cookie.
int len = (int) pm.getResponseContentLength();
- if (pm.getResponseBodyAsString(len).indexOf(jsessionid) != -1)
+ if (pm.getResponseBodyAsString(len).indexOf(jsessionid) != -1) {
+ pm.releaseConnection();
return 0;
+ }
System.out.println("No cookies");
}
} else {
@@ -134,9 +139,14 @@
e.printStackTrace();
}
System.out.println("DONE: " + httpResponseCode);
+ pm.releaseConnection();
return httpResponseCode;
}
public void run() {
+ try {
+ sleep(delay);
+ } catch (InterruptedException e) {}
+
for (int i = 0; i < nbtest; i++) {
try {
if (runit() != 0) return;
@@ -150,5 +160,8 @@
public boolean getresultok() {
return success;
}
+ public void setdelay(int delay) {
+ this.delay = delay;
+ }
}
Modified: trunk/mod_cluster/test/java/org/jboss/mod_cluster/Maintest.java
===================================================================
--- trunk/mod_cluster/test/java/org/jboss/mod_cluster/Maintest.java 2008-07-07 06:59:42 UTC (rev 1739)
+++ trunk/mod_cluster/test/java/org/jboss/mod_cluster/Maintest.java 2008-07-08 07:33:25 UTC (rev 1740)
@@ -34,14 +34,43 @@
import java.lang.Exception;
+import org.apache.catalina.ServerFactory;
+import org.apache.catalina.Service;
+import org.apache.catalina.Engine;
+import org.apache.catalina.core.StandardServer;
+import org.apache.catalina.connector.Connector;
public class Maintest extends TestCase {
+
+ static StandardServer server = null;
public static void main( String args[] ) {
TestRunner.run(suite());
}
public static Test suite() {
TestSuite suite = new TestSuite();
+ server = (StandardServer) ServerFactory.getServer();
suite.addTest(new TestSuite(TestBase.class));
+ System.gc();
+ suite.addTest(new TestSuite(TestFailover.class));
+ System.gc();
return suite;
}
+ static StandardServer getServer() {
+ return server;
+ }
+
+ /* Print the service and connectors the server knows */
+ static void listServices() {
+ Service[] services = server.findServices();
+ for (int i = 0; i < services.length; i++) {
+ System.out.println("service[" + i + "]: " + services[i]);
+ Engine engine = (Engine) services[i].getContainer();
+ System.out.println("engine: " + engine);
+ System.out.println("connectors: " + services[i].findConnectors());
+ Connector [] connectors = services[i].findConnectors();
+ for (int j = 0; j < connectors.length; j++) {
+ System.out.println("connector: " + connectors[j]);
+ }
+ }
+ }
}
Modified: trunk/mod_cluster/test/java/org/jboss/mod_cluster/TestBase.java
===================================================================
--- trunk/mod_cluster/test/java/org/jboss/mod_cluster/TestBase.java 2008-07-07 06:59:42 UTC (rev 1739)
+++ trunk/mod_cluster/test/java/org/jboss/mod_cluster/TestBase.java 2008-07-08 07:33:25 UTC (rev 1740)
@@ -46,11 +46,12 @@
/* Test */
public void testBase() {
- StandardServer server = null;
+ StandardServer server = Maintest.getServer();
JBossWeb service = null;
JBossWeb service2 = null;
+ ClusterListener cluster = null;
try {
- server = (StandardServer) ServerFactory.getServer();
+ // server = (StandardServer) ServerFactory.getServer();
service = new JBossWeb("node1", "localhost");
service.addConnector(8009);
@@ -60,26 +61,15 @@
service2.addConnector(8000);
server.addService(service2);
- ClusterListener cluster = new ClusterListener();
+ cluster = new ClusterListener();
cluster.setAdvertiseGroupAddress("232.0.0.2");
cluster.setAdvertisePort(23364);
cluster.setSsl(false);
// SSL ?
server.addLifecycleListener((LifecycleListener) cluster);
- Service[] services = server.findServices();
- for (int i = 0; i < services.length; i++) {
- System.out.println("service[" + i + "]: " + services[i]);
- Engine engine = (Engine) services[i].getContainer();
- System.out.println("engine: " + engine);
- // System.out.println("service: " + engine.getService());
- // System.out.println("connectors: " + engine.getService().findConnectors());
- System.out.println("JFC connectors: " + services[i].findConnectors());
- Connector [] connectors = services[i].findConnectors();
- for (int j = 0; j < connectors.length; j++) {
- System.out.println("JFC connector: " + connectors[j]);
- }
- }
+ // Debug Stuff
+ Maintest.listServices();
server.start();
@@ -91,7 +81,7 @@
// Wait until httpd as received the nodes information.
try {
- Thread.sleep(15000);
+ Thread.sleep(20000);
} catch (InterruptedException ex) {
ex.printStackTrace();
}
@@ -114,16 +104,20 @@
// Stop the server or services.
try {
+ /// service.stop();
+ /// service2.stop();
server.stop();
- // service.stop();
- // service2.stop();
+ server.removeService(service);
+ server.removeService(service2);
+ server.removeLifecycleListener(cluster);
} catch (LifecycleException ex) {
ex.printStackTrace();
}
// Wait until httpd as received the stop messages.
+ System.gc();
try {
- Thread.sleep(5000);
+ Thread.sleep(20000);
} catch (InterruptedException ex) {
ex.printStackTrace();
}
Added: trunk/mod_cluster/test/java/org/jboss/mod_cluster/TestFailover.java
===================================================================
--- trunk/mod_cluster/test/java/org/jboss/mod_cluster/TestFailover.java (rev 0)
+++ trunk/mod_cluster/test/java/org/jboss/mod_cluster/TestFailover.java 2008-07-08 07:33:25 UTC (rev 1740)
@@ -0,0 +1,195 @@
+/*
+ * mod_cluster
+ *
+ * Copyright(c) 2008 Red Hat Middleware, LLC,
+ * and individual contributors as indicated by the @authors tag.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This library 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 of the License, or (at your option) any later version.
+ *
+ * This library 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 library in the file COPYING.LIB;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * @author Jean-Frederic Clere
+ * @version $Revision$
+ */
+
+package org.jboss.mod_cluster;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.apache.catalina.Engine;
+import org.apache.catalina.ServerFactory;
+import org.apache.catalina.Service;
+import org.apache.catalina.LifecycleListener;
+import org.apache.catalina.LifecycleException;
+import org.apache.catalina.connector.Connector;
+import org.apache.catalina.core.StandardServer;
+
+import org.jboss.web.cluster.ClusterListener;
+
+public class TestFailover extends TestCase {
+
+ StandardServer server = null;
+
+ /* Test failover */
+ public void testFailover() {
+
+ boolean clienterror = false;
+ server = Maintest.getServer();
+ JBossWeb service = null;
+ ClusterListener cluster = null;
+ try {
+ // server = (StandardServer) ServerFactory.getServer();
+
+ service = new JBossWeb("node3", "localhost");
+ service.addConnector(8009);
+ server.addService(service);
+
+ cluster = new ClusterListener();
+ cluster.setAdvertiseGroupAddress("232.0.0.2");
+ cluster.setAdvertisePort(23364);
+ cluster.setSsl(false);
+
+ // SSL ?
+ server.addLifecycleListener((LifecycleListener) cluster);
+ Maintest.listServices();
+
+ } catch(IOException ex) {
+ ex.printStackTrace();
+ fail("can't start service");
+ }
+
+ // start a thread.
+ ServerThread wait = new ServerThread(3000);
+ wait.start();
+
+ // Wait until httpd as received the nodes information.
+ try {
+ Thread.sleep(30000);
+ } catch (InterruptedException ex) {
+ ex.printStackTrace();
+ }
+
+ // Start the client and wait for it.
+ Client client = new Client();
+
+ // Wait for it.
+ try {
+ if (client.runit("http://localhost:7779/ROOT/MyCount", "cmd", 10, true) != 0)
+ clienterror = true;
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ clienterror = true;
+ }
+
+ // Stop jboss.
+ try {
+ wait.stopit();
+ wait.join();
+ server.removeService(service);
+ server.removeLifecycleListener(cluster);
+ } catch (InterruptedException ex) {
+ ex.printStackTrace();
+ fail("can't stop server");
+ }
+
+ if (clienterror)
+ fail("Client error");
+
+ // Start a new one.
+ try {
+ service = new JBossWeb("node4", "localhost");
+ service.addConnector(8000);
+ server.addService(service);
+
+ cluster = new ClusterListener();
+ cluster.setAdvertiseGroupAddress("232.0.0.2");
+ cluster.setAdvertisePort(23364);
+ cluster.setSsl(false);
+
+ // SSL ?
+ server.addLifecycleListener((LifecycleListener) cluster);
+
+ } catch(IOException ex) {
+ ex.printStackTrace();
+ fail("Server start() failed");
+ }
+
+ // Start a server thread.
+ wait = new ServerThread(3000);
+ wait.start();
+
+ // Run a test on it. (it waits until httpd as received the nodes information).
+ try {
+ client.setdelay(30000);
+ client.start();
+ client.join();
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ if (client.getresultok())
+ System.out.println("Test DONE");
+ else {
+ System.out.println("Test FAILED");
+ clienterror = true;
+ }
+
+ // Stop the server or services.
+ try {
+ wait.stopit();
+ wait.join();
+ server.removeService(service);
+ server.removeLifecycleListener(cluster);
+ } catch (InterruptedException ex) {
+ ex.printStackTrace();
+ }
+
+ // Wait until httpd as received the stop messages.
+ try {
+ Thread.sleep(5000);
+ } catch (InterruptedException ex) {
+ ex.printStackTrace();
+ }
+
+ // Test client result.
+ if (clienterror)
+ fail("Client test failed");
+ }
+ public class ServerThread extends Thread {
+ int delay;
+ boolean ok = true;
+ public ServerThread(int delay) {
+ this.delay = delay;
+ }
+ public void run() {
+ try {
+ server.start();
+ while (ok) {
+ Thread.sleep(delay);
+ }
+ // sleep(delay);
+ server.stop();
+ } catch (InterruptedException e) {
+ } catch (LifecycleException ex) {
+ ex.printStackTrace();
+ }
+ }
+ public void stopit() {
+ ok = false;
+ }
+ }
+}
16 years, 5 months
JBoss Native SVN: r1739 - trunk/mod_cluster/test/java.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2008-07-07 02:59:42 -0400 (Mon, 07 Jul 2008)
New Revision: 1739
Modified:
trunk/mod_cluster/test/java/build.xml
Log:
Use debug...
Modified: trunk/mod_cluster/test/java/build.xml
===================================================================
--- trunk/mod_cluster/test/java/build.xml 2008-07-03 13:31:43 UTC (rev 1738)
+++ trunk/mod_cluster/test/java/build.xml 2008-07-07 06:59:42 UTC (rev 1739)
@@ -67,7 +67,7 @@
<!-- Compile -->
<javac srcdir="." destdir="${test.classes}"
- debug="${compile.debug}"
+ debug="on" debuglevel="lines,vars,source"
deprecation="${compile.deprecation}"
source="${compile.source}"
optimize="${compile.optimize}">
16 years, 5 months
JBoss Native SVN: r1738 - trunk/mod_cluster/native/mod_manager.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2008-07-03 09:31:43 -0400 (Thu, 03 Jul 2008)
New Revision: 1738
Modified:
trunk/mod_cluster/native/mod_manager/mod_manager.c
Log:
Make sure we don't (re)insert a node until it has been really removed.
Modified: trunk/mod_cluster/native/mod_manager/mod_manager.c
===================================================================
--- trunk/mod_cluster/native/mod_manager/mod_manager.c 2008-07-03 10:26:27 UTC (rev 1737)
+++ trunk/mod_cluster/native/mod_manager/mod_manager.c 2008-07-03 13:31:43 UTC (rev 1738)
@@ -73,6 +73,7 @@
#define TYPEMEM 2
#define MNODEUI "MEM: Can't update or insert node"
+#define MNODERM "MEM: Old node still exist"
#define MBALAUI "MEM: Can't update or insert balancer"
#define MNODERD "MEM: Can't read node"
#define MHOSTRD "MEM: Can't read host alias"
@@ -447,6 +448,7 @@
{
/* Process the node/balancer description */
nodeinfo_t nodeinfo;
+ nodeinfo_t *node;
balancerinfo_t balancerinfo;
int mpm_threads;
@@ -635,6 +637,14 @@
return MBALAUI;
}
+ /* check for removed node */
+ node = read_node(nodestatsmem, &nodeinfo);
+ if (node != NULL && node->mess.remove) {
+ /* Here we can't update it because the old one is still in */
+ *errtype = TYPEMEM;
+ return MNODERM;
+ }
+
/* Insert or update node description */
if (insert_update_node(nodestatsmem, &nodeinfo, &id) != APR_SUCCESS) {
*errtype = TYPEMEM;
16 years, 5 months