JBoss Native SVN: r1944 - trunk/mod_cluster/test/java/org/jboss/mod_cluster.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2008-10-09 10:21:33 -0400 (Thu, 09 Oct 2008)
New Revision: 1944
Modified:
trunk/mod_cluster/test/java/org/jboss/mod_cluster/JBossWeb.java
Log:
Arrange deployment.
Modified: trunk/mod_cluster/test/java/org/jboss/mod_cluster/JBossWeb.java
===================================================================
--- trunk/mod_cluster/test/java/org/jboss/mod_cluster/JBossWeb.java 2008-10-08 14:44:59 UTC (rev 1943)
+++ trunk/mod_cluster/test/java/org/jboss/mod_cluster/JBossWeb.java 2008-10-09 14:21:33 UTC (rev 1944)
@@ -136,8 +136,12 @@
//Create Host
Host baseHost = createHost( host, appBase);
- baseHost.setBackgroundProcessorDelay(10);
+ baseHost.setDeployOnStartup(true);
+ baseHost.setBackgroundProcessorDelay(1);
StandardHost stdhost = (StandardHost)baseHost;
+ stdhost.setDeployXML(true);
+ stdhost.setConfigClass("org.apache.catalina.startup.ContextConfig");
+ stdhost.setUnpackWARs(true);
HostConfig hostConfig = new HostConfig();
stdhost.addLifecycleListener(hostConfig);
baseEngine.addChild( baseHost );
16 years, 2 months
JBoss Native SVN: r1943 - trunk/mod_cluster/test/java/org/jboss/mod_cluster.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2008-10-08 10:44:59 -0400 (Wed, 08 Oct 2008)
New Revision: 1943
Modified:
trunk/mod_cluster/test/java/org/jboss/mod_cluster/ClientBasicAuthen.java
Log:
Use the LifecycleListener.
Modified: trunk/mod_cluster/test/java/org/jboss/mod_cluster/ClientBasicAuthen.java
===================================================================
--- trunk/mod_cluster/test/java/org/jboss/mod_cluster/ClientBasicAuthen.java 2008-10-07 20:04:15 UTC (rev 1942)
+++ trunk/mod_cluster/test/java/org/jboss/mod_cluster/ClientBasicAuthen.java 2008-10-08 14:44:59 UTC (rev 1943)
@@ -41,8 +41,6 @@
import org.apache.catalina.connector.Connector;
import org.apache.catalina.core.StandardServer;
-import org.jboss.web.cluster.ClusterListener;
-
import org.apache.catalina.core.AprLifecycleListener;
public class ClientBasicAuthen {
@@ -64,7 +62,7 @@
boolean clienterror = false;
StandardServer server = Maintest.getServer();
JBossWeb service = null;
- ClusterListener cluster = null;
+ LifecycleListener cluster = null;
try {
// server = (StandardServer) ServerFactory.getServer();
@@ -77,12 +75,8 @@
service.addWAR("JBWEB-117.war", "node1");
server.addService(service);
- cluster = new ClusterListener();
- cluster.setAdvertiseGroupAddress("232.0.0.2");
- cluster.setAdvertisePort(23364);
- cluster.setSsl(false);
- // SSL ?
- server.addLifecycleListener((LifecycleListener) cluster);
+ cluster = Maintest.createClusterListener("232.0.0.2", 23364, false);
+ server.addLifecycleListener(cluster);
// Add AprLifecycleListener.
if (nat) {
16 years, 2 months
JBoss Native SVN: r1942 - in trunk/mod_cluster/src: test/java/org/jboss/modcluster and 1 other directories.
by jbossnative-commits@lists.jboss.org
Author: pferraro
Date: 2008-10-07 16:04:15 -0400 (Tue, 07 Oct 2008)
New Revision: 1942
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/MCMPUtils.java
trunk/mod_cluster/src/test/java/org/jboss/modcluster/ClusterListenerTestCase.java
trunk/mod_cluster/src/test/java/org/jboss/modcluster/ha/HASingletonAwareResetRequestSourceTestCase.java
Log:
No need to check jvm route for null
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-07 14:23:14 UTC (rev 1941)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/MCMPUtils.java 2008-10-07 20:04:15 UTC (rev 1942)
@@ -242,10 +242,7 @@
for (Service service: services)
{
Engine engine = (Engine) service.getContainer();
- if (engine.getJvmRoute() != null)
- {
- requests.add(MCMPUtils.createRemoveAllRequest(engine));
- }
+ requests.add(MCMPUtils.createRemoveAllRequest(engine));
requests.add(MCMPUtils.createConfigRequest(engine, nodeConfig, balancerConfig));
Container[] children = engine.findChildren();
for (Container element: children)
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-07 14:23:14 UTC (rev 1941)
+++ trunk/mod_cluster/src/test/java/org/jboss/modcluster/ClusterListenerTestCase.java 2008-10-07 20:04:15 UTC (rev 1942)
@@ -93,7 +93,7 @@
EasyMock.expect(service.getContainer()).andReturn(engine);
// create remove-all request
- EasyMock.expect(engine.getJvmRoute()).andReturn("host1").times(2);
+ EasyMock.expect(engine.getJvmRoute()).andReturn("host1");
// create config request
EasyMock.expect(engine.getService()).andReturn(service);
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-07 14:23:14 UTC (rev 1941)
+++ trunk/mod_cluster/src/test/java/org/jboss/modcluster/ha/HASingletonAwareResetRequestSourceTestCase.java 2008-10-07 20:04:15 UTC (rev 1942)
@@ -109,7 +109,7 @@
EasyMock.expect(server.findServices()).andReturn(new Service[] { service });
EasyMock.expect(service.getContainer()).andReturn(engine);
- EasyMock.expect(engine.getJvmRoute()).andReturn("host").times(2);
+ EasyMock.expect(engine.getJvmRoute()).andReturn("host");
EasyMock.expect(engine.getService()).andReturn(service);
EasyMock.expect(service.findConnectors()).andReturn(new Connector[] { connector });
@@ -225,7 +225,7 @@
EasyMock.expect(server.findServices()).andReturn(new Service[] { service });
EasyMock.expect(service.getContainer()).andReturn(engine);
- EasyMock.expect(engine.getJvmRoute()).andReturn("host").times(2);
+ EasyMock.expect(engine.getJvmRoute()).andReturn("host");
EasyMock.expect(engine.getService()).andReturn(service);
EasyMock.expect(service.findConnectors()).andReturn(new Connector[] { connector });
16 years, 2 months
JBoss Native SVN: r1941 - trunk/mod_cluster/native/mod_proxy_cluster.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2008-10-07 10:23:14 -0400 (Tue, 07 Oct 2008)
New Revision: 1941
Modified:
trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c
Log:
Also use informationn between the timestamp to share the load.
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-07 09:36:13 UTC (rev 1940)
+++ trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c 2008-10-07 14:23:14 UTC (rev 1941)
@@ -614,15 +614,12 @@
*/
-static char *get_balancer_by_node(request_rec *r, int nodeid, proxy_server_conf *conf, proxy_balancer *balance)
+static char *get_balancer_by_node(request_rec *r, nodeinfo_t *node, proxy_server_conf *conf, proxy_balancer *balance)
{
- nodeinfo_t *node;
int i;
int sizevhost;
int *vhosts;
- node_storage->read_node(nodeid, &node);
-
/*
* check the hosts and contexts
* A node may have several virtual hosts and
@@ -703,7 +700,9 @@
int *nodes = apr_palloc(r->pool, sizeof(int)*sizenode);
sizenode = node_storage->get_ids_used_node(nodes);
for (n=0; n<sizenode; n++) {
- char *ret = get_balancer_by_node(r, nodes[n], conf, NULL);
+ nodeinfo_t *node;
+ node_storage->read_node(nodes[n], &node);
+ char *ret = get_balancer_by_node(r, node, conf, NULL);
if (ret != NULL) {
return ret;
}
@@ -716,7 +715,7 @@
* memory.
* (See get_context_host_balancer too).
*/
-static int iscontext_host_ok(request_rec *r, proxy_balancer *balancer, int node)
+static int iscontext_host_ok(request_rec *r, proxy_balancer *balancer, nodeinfo_t *node)
{
char *balancername = get_balancer_by_node(r, node, NULL, balancer);
if (balancername != NULL) {
@@ -728,16 +727,14 @@
/*
* Check that the worker corresponds to a node that belongs to the same domain according to the JVMRoute.
*/
-static int isnode_domain_ok(request_rec *r, proxy_worker *worker,
+static int isnode_domain_ok(request_rec *r, nodeinfo_t *node,
const char *domain)
{
- nodeinfo_t *ou;
- node_storage->read_node(worker->id, &ou);
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
- "isnode_domain_ok: domain %s:%s", domain, ou->mess.Domain);
+ "isnode_domain_ok: domain %s:%s", domain, node->mess.Domain);
if (domain == NULL)
return 1; /* OK no domain in the corresponding to the SESSIONID */
- if (strcmp(ou->mess.Domain, domain) == 0)
+ if (strcmp(node->mess.Domain, domain) == 0)
return 1; /* OK */
return 0;
}
@@ -776,6 +773,7 @@
while (!mycandidate && !checked_standby) {
worker = (proxy_worker *)balancer->workers->elts;
for (i = 0; i < balancer->workers->nelts; i++, worker++) {
+ nodeinfo_t *node;
if (worker->id == 0)
continue; /* marked removed */
@@ -796,10 +794,11 @@
* not in error state or not disabled.
* and that can map the context.
*/
- if (PROXY_WORKER_IS_USABLE(worker) && iscontext_host_ok(r, balancer, worker->id)) {
+ node_storage->read_node(worker->id, &node);
+ if (PROXY_WORKER_IS_USABLE(worker) && iscontext_host_ok(r, balancer, node)) {
if (!checked_domain) {
/* First try only nodes in the domain */
- if (!isnode_domain_ok(r, worker, domain)) {
+ if (!isnode_domain_ok(r, node, domain)) {
continue;
}
}
@@ -807,10 +806,19 @@
mycandidate = worker;
break; /* Done */
} else {
- if (!mycandidate
- || worker->s->busy < mycandidate->s->busy
- || (worker->s->busy == mycandidate->s->busy && worker->s->lbstatus < mycandidate->s->lbstatus)) {
+ if (!mycandidate)
mycandidate = worker;
+ else {
+ nodeinfo_t *node1;
+ int lbstatus, lbstatus1;
+
+ node_storage->read_node(mycandidate->id, &node1);
+ lbstatus1 = ((mycandidate->s->elected - node1->mess.oldelected) * 1000)/mycandidate->s->lbfactor;
+ lbstatus = ((worker->s->elected - node->mess.oldelected) * 1000)/worker->s->lbfactor;
+ lbstatus1 = lbstatus1 + mycandidate->s->lbstatus;
+ lbstatus = lbstatus + worker->s->lbstatus;
+ if (lbstatus1> lbstatus)
+ mycandidate = worker;
}
}
}
@@ -1387,7 +1395,6 @@
if (candidate) {
proxy_cluster_helper *helper;
- candidate->s->elected++; /* mark it in use */
helper = (proxy_cluster_helper *) candidate->opaque;
helper->count_active++;
}
16 years, 2 months
JBoss Native SVN: r1940 - trunk/mod_cluster/native/mod_proxy_cluster.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2008-10-07 05:36:13 -0400 (Tue, 07 Oct 2008)
New Revision: 1940
Modified:
trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c
Log:
Fix the 500 after the child is created.
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-07 09:27:14 UTC (rev 1939)
+++ trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c 2008-10-07 09:36:13 UTC (rev 1940)
@@ -1479,9 +1479,14 @@
if (!*balancer &&
!(*balancer = ap_proxy_get_balancer(r->pool, conf, *url))) {
apr_thread_mutex_unlock(lock);
- ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
- "proxy: CLUSTER no balancer for %s", *url);
- return DECLINED;
+ /* May the node has not be created yet */
+ update_workers_node(conf, r->pool, r->server);
+ if (!(*balancer = ap_proxy_get_balancer(r->pool, conf, *url))) {
+ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
+ "proxy: CLUSTER no balancer for %s", *url);
+ return DECLINED;
+ }
+ apr_thread_mutex_lock(lock);
}
/* Step 2: find the session route */
16 years, 2 months
JBoss Native SVN: r1939 - trunk/mod_cluster/native/mod_proxy_cluster.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2008-10-07 05:27:14 -0400 (Tue, 07 Oct 2008)
New Revision: 1939
Modified:
trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c
Log:
Improve traces.
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-07 07:02:57 UTC (rev 1938)
+++ trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c 2008-10-07 09:27:14 UTC (rev 1939)
@@ -376,11 +376,6 @@
id = apr_pcalloc(pool, sizeof(int) * node_storage->get_max_size_node());
size = node_storage->get_ids_used_node(id);
- /* XXX: How to skip the balancer that aren't controled by mod_manager */
-
- ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, server,
- "update_workers_lbstatus starting");
-
/* update lbstatus if needed */
for (i=0; i<size; i++) {
nodeinfo_t *ou;
@@ -400,8 +395,6 @@
stat->lbstatus = ((elected - oldelected) * 1000) / stat->lbfactor;
}
}
- ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, server,
- "update_workers_lbstatus done");
}
/* reslist constructor */
@@ -1486,6 +1479,8 @@
if (!*balancer &&
!(*balancer = ap_proxy_get_balancer(r->pool, conf, *url))) {
apr_thread_mutex_unlock(lock);
+ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
+ "proxy: CLUSTER no balancer for %s", *url);
return DECLINED;
}
16 years, 2 months
JBoss Native SVN: r1938 - trunk/mod_cluster/native/mod_proxy_cluster.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2008-10-07 03:02:57 -0400 (Tue, 07 Oct 2008)
New Revision: 1938
Modified:
trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c
Log:
Oops Arithmetic exception.
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-06 20:52:20 UTC (rev 1937)
+++ trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c 2008-10-07 07:02:57 UTC (rev 1938)
@@ -396,7 +396,8 @@
oldelected = ou->mess.oldelected;
ou->mess.updatetimelb = now;
ou->mess.oldelected = elected;
- stat->lbstatus = ((elected - oldelected) * 1000) / stat->lbfactor;
+ if (stat->lbfactor > 0)
+ stat->lbstatus = ((elected - oldelected) * 1000) / stat->lbfactor;
}
}
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, server,
16 years, 2 months
JBoss Native SVN: r1937 - 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-10-06 16:52:20 -0400 (Mon, 06 Oct 2008)
New Revision: 1937
Modified:
trunk/mod_cluster/native/include/node.h
trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c
Log:
Use a different algorithm.
Modified: trunk/mod_cluster/native/include/node.h
===================================================================
--- trunk/mod_cluster/native/include/node.h 2008-10-06 18:40:04 UTC (rev 1936)
+++ trunk/mod_cluster/native/include/node.h 2008-10-06 20:52:20 UTC (rev 1937)
@@ -67,6 +67,8 @@
/* part updated in httpd */
int id; /* id in table and worker id */
+ apr_time_t updatetimelb; /* time of last update of the lbstatus value */
+ int oldelected; /* value of s->elected when calculating the lbstatus */
};
typedef struct nodemess nodemess_t;
@@ -77,9 +79,9 @@
/* config from jboss/tomcat */
nodemess_t mess;
/* filled by httpd */
- apr_time_t updatetime; /* time of last received message */
- int offset; /* offset to the proxy_worker_stat structure */
- char stat[SIZEOFSCORE]; /* to store the status */
+ apr_time_t updatetime; /* time of last received message */
+ int offset; /* offset to the proxy_worker_stat structure */
+ char stat[SIZEOFSCORE]; /* to store the status */
};
typedef struct nodeinfo nodeinfo_t;
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-06 18:40:04 UTC (rev 1936)
+++ trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c 2008-10-06 20:52:20 UTC (rev 1937)
@@ -65,8 +65,7 @@
#define WAITFORREMOVE 10 /* seconds */
-#define FORGETFACTOR 10 /* Stop changing node lbstatus when too small or too big */
-
+#define TIMEINTERVAL apr_time_from_sec(1) /* recalcul the lbstatus based on number of request in the time interval */
/*
* Create/Get the worker before using it
*/
@@ -362,6 +361,48 @@
"update_workers_node done");
}
+/*
+ * update the lbfactor of each node if needed,
+ */
+static void update_workers_lbstatus(proxy_server_conf *conf, apr_pool_t *pool, server_rec *server)
+{
+ int *id, size, i;
+ apr_time_t now;
+ int notok = 0;
+
+ now = apr_time_now();
+
+ /* read the ident of the nodes */
+ id = apr_pcalloc(pool, sizeof(int) * node_storage->get_max_size_node());
+ size = node_storage->get_ids_used_node(id);
+
+ /* XXX: How to skip the balancer that aren't controled by mod_manager */
+
+ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, server,
+ "update_workers_lbstatus starting");
+
+ /* update lbstatus if needed */
+ for (i=0; i<size; i++) {
+ nodeinfo_t *ou;
+ node_storage->read_node(id[i], &ou);
+ if (ou->mess.updatetimelb < (now - TIMEINTERVAL)) {
+ /* The lbstatus needs to be updated */
+ int elected, oldelected;
+ proxy_worker_stat *stat;
+ char *ptr = (char *) ou;
+ ptr = ptr + ou->offset;
+ stat = (proxy_worker_stat *) ptr;
+ elected = stat->elected;
+ oldelected = ou->mess.oldelected;
+ ou->mess.updatetimelb = now;
+ ou->mess.oldelected = elected;
+ stat->lbstatus = ((elected - oldelected) * 1000) / stat->lbfactor;
+ }
+ }
+ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, server,
+ "update_workers_lbstatus done");
+}
+
/* reslist constructor */
/* XXX: Should use the proxy_util one. */
static apr_status_t connection_constructor(void **resource, void *params,
@@ -718,7 +759,6 @@
request_rec *r)
{
int i;
- int total_factor = 0;
proxy_worker *worker;
proxy_worker *mycandidate = NULL;
int checking_standby = 0;
@@ -773,12 +813,9 @@
mycandidate = worker;
break; /* Done */
} else {
- if (worker->s->lbstatus < FORGETFACTOR * worker->s->lbfactor)
- worker->s->lbstatus += worker->s->lbfactor;
- total_factor += worker->s->lbfactor;
if (!mycandidate
|| worker->s->busy < mycandidate->s->busy
- || (worker->s->busy == mycandidate->s->busy && worker->s->lbstatus > mycandidate->s->lbstatus)) {
+ || (worker->s->busy == mycandidate->s->busy && worker->s->lbstatus < mycandidate->s->lbstatus)) {
mycandidate = worker;
}
}
@@ -791,10 +828,6 @@
}
if (mycandidate) {
- 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);
@@ -1106,6 +1139,8 @@
update_workers_node(conf, pool, s);
/* cleanup removed node in shared memory */
remove_removed_node(pool);
+ /* Calculate the lbstatus for each node */
+ update_workers_lbstatus(conf, pool, s);
apr_pool_destroy(pool);
}
apr_thread_exit(thd, 0);
@@ -1468,34 +1503,7 @@
return DECLINED;
}
if (runtime) {
- int i, total_factor = 0;
- proxy_worker *workers;
- /* We have a sticky load balancer
- * Update the workers status
- * so that even session routes get
- * into account.
- */
- workers = (proxy_worker *)(*balancer)->workers->elts;
- for (i = 0; i < (*balancer)->workers->nelts; i++) {
- /* Take into calculation only the workers that are
- * not in error state or not disabled.
- *
- * TODO: Abstract the below, since this is dependent
- * on the LB implementation
- */
- if (PROXY_WORKER_IS_USABLE(workers)) {
- if (workers->s->lbstatus < FORGETFACTOR * workers->s->lbfactor)
- workers->s->lbstatus += workers->s->lbfactor;
- total_factor += workers->s->lbfactor;
- }
- workers++;
- }
- 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;
}
else if (route && (*balancer)->sticky_force) {
16 years, 2 months
JBoss Native SVN: r1936 - 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-06 14:40:04 -0400 (Mon, 06 Oct 2008)
New Revision: 1936
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:
Rollback mutable server states - add new drm entry constructor accepting jvm routes.
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-06 07:51:14 UTC (rev 1935)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/ModClusterService.java 2008-10-06 18:40:04 UTC (rev 1936)
@@ -453,17 +453,12 @@
throw Utils.convertToUnchecked(e);
}
}
-
- void updateLocalDRMEntry()
- {
- this.updateLocalDRM(this.drmEntry);
- }
- void updateLocalDRM(ModClusterServiceDRMEntry ourNewStatus)
+ void updateLocalDRM(ModClusterServiceDRMEntry status)
{
try
{
- this.getHAPartition().getDistributedReplicantManager().add(this.getHAServiceKey(), ourNewStatus);
+ this.getHAPartition().getDistributedReplicantManager().add(this.getHAServiceKey(), status);
}
catch (Exception e)
{
@@ -564,9 +559,7 @@
{
try
{
- oldStatus.setMCMPServerStates(newStatus.getMCMPServerStates());
- drm.add(key, oldStatus);
-// drm.add(key, new ModClusterServiceDRMEntry(cn, newStatus.getMCMPServerStates()));
+ drm.add(key, new ModClusterServiceDRMEntry(cn, newStatus.getMCMPServerStates(), oldStatus.getJvmRoutes()));
}
catch (Exception e)
{
@@ -908,31 +901,21 @@
ClusterNode node = partition.getClusterNode();
boolean othersFirst = this.coord.narrowCandidateList(allStatuses).contains(node);
- Set<MCMPServerState> oldStates = this.coord.drmEntry.getMCMPServerStates();
- boolean updated = (oldStates != null) ? !oldStates.equals(masterList) : oldStates != masterList;
-// ModClusterServiceDRMEntry ourNewStatus = new ModClusterServiceDRMEntry(node, masterList);
-// boolean updated = !ourNewStatus.equals(ourCurrentStatus);
+ ModClusterServiceDRMEntry newStatus = new ModClusterServiceDRMEntry(node, masterList, this.coord.drmEntry.getJvmRoutes());
+ boolean updated = !newStatus.equals(ourCurrentStatus);
if (othersFirst)
{
this.coord.clusterStatusComplete(statuses);
-
- if (updated)
- {
- this.coord.drmEntry.setMCMPServerStates(masterList);
- this.coord.updateLocalDRMEntry();
-// this.coord.updateLocalDRM(ourNewStatus);
- }
}
- else
+
+ if (updated)
{
- if (updated)
- {
- this.coord.drmEntry.setMCMPServerStates(masterList);
- this.coord.updateLocalDRMEntry();
-// this.coord.updateLocalDRM(ourNewStatus);
- }
-
+ this.coord.updateLocalDRM(newStatus);
+ }
+
+ if (!othersFirst)
+ {
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-06 07:51:14 UTC (rev 1935)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/ModClusterServiceDRMEntry.java 2008-10-06 18:40:04 UTC (rev 1936)
@@ -46,10 +46,15 @@
private final Integer establishedCount;
private final Integer healthyCount;
private final Integer knownCount;
- private final Set<String> jvmRoutes = new HashSet<String>();
+ private final Set<String> jvmRoutes;
public ModClusterServiceDRMEntry(ClusterNode peer, Set<MCMPServerState> mcmpServerStates)
{
+ this(peer, mcmpServerStates, new HashSet<String>());
+ }
+
+ public ModClusterServiceDRMEntry(ClusterNode peer, Set<MCMPServerState> mcmpServerStates, Set<String> jvmRoutes)
+ {
assert peer != null : "peer is null";
this.peer = peer;
@@ -85,6 +90,7 @@
this.healthyCount = Integer.valueOf(healthy);
this.healthyEstablishedCount = Integer.valueOf(healthyEstablished);
this.knownCount = Integer.valueOf(known);
+ this.jvmRoutes = jvmRoutes;
}
public ClusterNode getPeer()
@@ -92,11 +98,6 @@
return this.peer;
}
- public void setMCMPServerStates(Set<MCMPServerState> states)
- {
- this.mcmpServerStates = states;
- }
-
public Set<MCMPServerState> getMCMPServerStates()
{
return this.mcmpServerStates;
16 years, 2 months
JBoss Native SVN: r1935 - trunk/mod_cluster/native/mod_proxy_cluster.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2008-10-06 03:51:14 -0400 (Mon, 06 Oct 2008)
New Revision: 1935
Modified:
trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c
Log:
Remove duplicate code.
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-03 11:24:07 UTC (rev 1934)
+++ trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c 2008-10-06 07:51:14 UTC (rev 1935)
@@ -519,15 +519,36 @@
return NULL;
}
-/*
+/**
* Check that the request has a sessionid (even invalid)
+ * @param r the request_rec.
+ * @param balancer_name name of the balancer. (to find the balancer)
+ * @param conf the proxy configuration.
+ * @param balance the balancer (balancer to use).
+ * @return 1 is it finds a sessionid 0 otherwise.
*/
-static int hassession(request_rec *r, proxy_balancer *balancer)
+static int hassession_byname(request_rec *r, char *balancer_name, proxy_server_conf *conf, proxy_balancer *balance)
{
+ proxy_balancer *balancer = balance;
char *route;
char *uri = r->filename + 6;
char *sticky_path, *sticky, *path;
+ int i;
+ if (balancer == NULL) {
+ balancer = (proxy_balancer *)conf->balancers->elts;
+ for (i = 0; i < conf->balancers->nelts; i++, balancer++) {
+ if (strcasecmp(balancer->name, uri) == 0)
+ break;
+ }
+ if (i == conf->balancers->nelts)
+ balancer = NULL;
+ }
+
+ /* XXX: We don't find the balancer, that is BAD */
+ if (balancer == NULL)
+ return 0;
+
if (balancer->sticky == NULL)
return 0;
@@ -548,20 +569,24 @@
return 0;
}
-/*
- * Check that the worker will handle the host/context.
- * The id of the worker is used to find the (slot) node in the shared
- * memory.
- * (See get_context_host_balancer too).
- */
-static int iscontext_host_ok(request_rec *r, proxy_balancer *balancer,
- proxy_worker *worker)
-{
+/**
+ * Find/Check the balancer corresponding to the request and the node.
+ * @param r the request_rec.
+ * @param node the node to use.
+ * @param conf the proxy configuration.
+ * @param balance the balancer (balancer to use in that case we check it).
+ * @return the name of the balancer or NULL if not found/not corresponding
+ */
+
+
+static char *get_balancer_by_node(request_rec *r, int nodeid, proxy_server_conf *conf, proxy_balancer *balance)
+{
nodeinfo_t *node;
- int sizevhost, i;
+ int i;
+ int sizevhost;
int *vhosts;
- node_storage->read_node(worker->id, &node);
+ node_storage->read_node(nodeid, &node);
/*
* check the hosts and contexts
@@ -571,6 +596,8 @@
sizevhost = host_storage->get_max_size_host();
vhosts = apr_palloc(r->pool, sizeof(int)*sizevhost);
sizevhost = host_storage->get_ids_used_host(vhosts);
+ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
+ "get_balancer_by_node testing node %s for %s", node->mess.JVMRoute, r->uri);
for (i=0; i<sizevhost; i++) {
hostinfo_t *vhost;
host_storage->read_host(vhosts[i], &vhost);
@@ -578,101 +605,57 @@
/* XXX Check the virtual host */
/* Check the contexts */
- int j, len;
+ int j;
int sizecontext = context_storage->get_max_size_context();
int *contexts = apr_palloc(r->pool, sizeof(int)*sizecontext);
sizecontext = context_storage->get_ids_used_context(contexts);
+ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
+ "get_balancer_by_node testing host %s", vhost->host);
for (j=0; j<sizecontext; j++) {
contextinfo_t *context;
+ int len;
context_storage->read_context(contexts[j], &context);
- if (context->vhost != vhost->vhost)
+ if (context->vhost != vhost->vhost || (context->node != node->mess.id))
continue;
+ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
+ "get_balancer_by_node testing context %s", context->context);
/* check for /context[/] in the URL */
len = strlen(context->context);
if (strncmp(r->uri, context->context, len) == 0) {
- if (r->uri[len] == '\0' || r->uri[len] == '/' || len == 1) {
+ if (r->uri[len] == '\0' || r->uri[len] == '/' || len==1) {
/* Check status */
switch (context->status)
{
case ENABLED:
- return 1;
+ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
+ "get_balancer_by_node found context %s", context->context);
+ return node->mess.balancer;
break;
case DISABLED:
/* Only the request with sessionid ok for it */
- if (hassession(r, balancer))
- return 1;
+ if (hassession_byname(r, node->mess.balancer, conf, NULL))
+ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
+ "get_balancer_by_node found (DISABLED) context %s", context->context);
+ return node->mess.balancer;
break;
}
}
}
}
-
+
}
}
- return 0;
-}
-
-/*
- * Check that the worker corresponds to a node that belongs to the same domain according to the JVMRoute.
- */
-static int isnode_domain_ok(request_rec *r, proxy_worker *worker,
- const char *domain)
-{
- nodeinfo_t *ou;
- node_storage->read_node(worker->id, &ou);
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
- "isnode_domain_ok: domain %s:%s", domain, ou->mess.Domain);
- if (domain == NULL)
- return 1; /* OK no domain in the corresponding to the SESSIONID */
- if (strcmp(ou->mess.Domain, domain) == 0)
- return 1; /* OK */
- return 0;
-}
-/*
- * Check that the request has a sessionid (even invalid)
- * Use the name of the balancer.
- */
-static int hassession_byname(request_rec *r, char *balancer_name, proxy_server_conf *conf)
-{
- proxy_balancer *balancer;
- char *route;
- char *uri = r->filename + 6;
- char *sticky_path, *sticky, *path;
- int i;
+ "get_balancer_by_node balancer NOT found");
+ return NULL;
- balancer = (proxy_balancer *)conf->balancers->elts;
- for (i = 0; i < conf->balancers->nelts; i++, balancer++) {
- if (strcasecmp(balancer->name, uri) == 0)
- break;
- }
-
- /* XXX: We don't find the balancer, that is BAD */
- if (i == conf->balancers->nelts)
- return 0;
-
- if (balancer->sticky == NULL)
- return 0;
-
- /* for 2.2.x the sticky parameter may contain 2 values */
- sticky = sticky_path = apr_pstrdup(r->pool, balancer->sticky);
- if ((path = strchr(sticky, '|'))) {
- *path++ = '\0';
- sticky_path = path;
- }
- route = get_path_param(r->pool, uri , sticky_path);
- if (route == NULL)
- route = get_cookie_param(r, sticky);
- if (route) {
- ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
- "mod_proxy_cluster: found route %s", route);
- return 1;
- }
- return 0;
}
-/*
+/**
* Search the balancer that corresponds to the pair context/host
- * (See iscontext_host_ok()).
+ * @param r the request_rec.
+ * @balancer proxy_ ARF....
+ * @return the balancer or NULL if not found.
*/
static char *get_context_host_balancer(request_rec *r)
{
@@ -685,78 +668,46 @@
int *nodes = apr_palloc(r->pool, sizeof(int)*sizenode);
sizenode = node_storage->get_ids_used_node(nodes);
for (n=0; n<sizenode; n++) {
- nodeinfo_t *node;
- int i;
- int sizevhost;
- int *vhosts;
-
- node_storage->read_node(nodes[n], &node);
-
- /*
- * check the hosts and contexts
- * A node may have several virtual hosts and
- * each virtual hosts may have several context
- */
- sizevhost = host_storage->get_max_size_host();
- vhosts = apr_palloc(r->pool, sizeof(int)*sizevhost);
- sizevhost = host_storage->get_ids_used_host(vhosts);
- ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
- "get_context_host_balancer testing node %s for %s", node->mess.JVMRoute, r->uri);
- for (i=0; i<sizevhost; i++) {
- hostinfo_t *vhost;
- host_storage->read_host(vhosts[i], &vhost);
- if (vhost->node == node->mess.id) {
- /* XXX Check the virtual host */
-
- /* Check the contexts */
- int j;
- int sizecontext = context_storage->get_max_size_context();
- int *contexts = apr_palloc(r->pool, sizeof(int)*sizecontext);
- sizecontext = context_storage->get_ids_used_context(contexts);
- ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
- "get_context_host_balancer testing host %s", vhost->host);
- for (j=0; j<sizecontext; j++) {
- contextinfo_t *context;
- int len;
- context_storage->read_context(contexts[j], &context);
- if (context->vhost != vhost->vhost)
- continue;
- ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
- "get_context_host_balancer testing context %s", context->context);
-
- /* check for /context[/] in the URL */
- len = strlen(context->context);
- if (strncmp(r->uri, context->context, len) == 0) {
- if (r->uri[len] == '\0' || r->uri[len] == '/' || len==1) {
- /* Check status */
- switch (context->status)
- {
- case ENABLED:
- ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
- "get_context_host_balancer found context %s", context->context);
- return node->mess.balancer;
- break;
- case DISABLED:
- /* Only the request with sessionid ok for it */
- if (hassession_byname(r, node->mess.balancer, conf))
- ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
- "get_context_host_balancer found (DISABLED) context %s", context->context);
- return node->mess.balancer;
- break;
- }
- }
- }
- }
-
- }
+ char *ret = get_balancer_by_node(r, nodes[n], conf, NULL);
+ if (ret != NULL) {
+ return ret;
}
}
- ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
- "get_context_host_balancer NOT found");
return NULL;
}
+/*
+ * Check that the worker will handle the host/context.
+ * The id of the worker is used to find the (slot) node in the shared
+ * memory.
+ * (See get_context_host_balancer too).
+ */
+static int iscontext_host_ok(request_rec *r, proxy_balancer *balancer, int node)
+{
+ char *balancername = get_balancer_by_node(r, node, NULL, balancer);
+ if (balancername != NULL) {
+ return 1; /* Found */
+ }
+ return 0;
+}
/*
+ * Check that the worker corresponds to a node that belongs to the same domain according to the JVMRoute.
+ */
+static int isnode_domain_ok(request_rec *r, proxy_worker *worker,
+ const char *domain)
+{
+ nodeinfo_t *ou;
+ node_storage->read_node(worker->id, &ou);
+ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
+ "isnode_domain_ok: domain %s:%s", domain, ou->mess.Domain);
+ if (domain == NULL)
+ return 1; /* OK no domain in the corresponding to the SESSIONID */
+ if (strcmp(ou->mess.Domain, domain) == 0)
+ return 1; /* OK */
+ return 0;
+}
+
+/*
* The ModClusterService from the cluster fills the lbfactor values.
* Our logic is a bit different the mod_balancer one. We check the
* context and host to prevent to route to application beeing redeploy or
@@ -811,7 +762,7 @@
* not in error state or not disabled.
* and that can map the context.
*/
- if (PROXY_WORKER_IS_USABLE(worker) && iscontext_host_ok(r, balancer, worker)) {
+ if (PROXY_WORKER_IS_USABLE(worker) && iscontext_host_ok(r, balancer, worker->id)) {
if (!checked_domain) {
/* First try only nodes in the domain */
if (!isnode_domain_ok(r, worker, domain)) {
16 years, 2 months