JBoss Native SVN: r2275 - trunk/mod_cluster/test/java.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2009-02-10 16:09:04 -0500 (Tue, 10 Feb 2009)
New Revision: 2275
Modified:
trunk/mod_cluster/test/java/installhttpd.sh
Log:
Make sure that spaces are not taken as 2 tasks.
Modified: trunk/mod_cluster/test/java/installhttpd.sh
===================================================================
--- trunk/mod_cluster/test/java/installhttpd.sh 2009-02-10 20:32:49 UTC (rev 2274)
+++ trunk/mod_cluster/test/java/installhttpd.sh 2009-02-10 21:09:04 UTC (rev 2275)
@@ -132,13 +132,13 @@
BASELOC=`pwd`
if [ ! -f ${PACKVER}-${BUILD_SYS}-${BUILD_CPU}.${EXT} ]
then
- ant downloadfile -Dsourcefile=${TARBALL} -Ddestfile=${PACKVER}-${BUILD_SYS}-${BUILD_CPU}.${EXT} -Ddestdir=$BASELOC
+ ant downloadfile -Dsourcefile=${TARBALL} -Ddestfile=${PACKVER}-${BUILD_SYS}-${BUILD_CPU}.${EXT} -Ddestdir="$BASELOC"
fi
else
if [ "x${BUILDTEST}" = "x" ]
then
rm -f ${PACKVER}-${BUILD_SYS}-${BUILD_CPU}.${EXT}
- ant downloadfile -Dsourcefile=${TARBALL} -Ddestfile=${PACKVER}-${BUILD_SYS}-${BUILD_CPU}.${EXT} -Ddestdir=$BASELOC
+ ant downloadfile -Dsourcefile=${TARBALL} -Ddestfile=${PACKVER}-${BUILD_SYS}-${BUILD_CPU}.${EXT} -Ddestdir="$BASELOC"
else
echo "Using $root"
EXT=file
15 years, 10 months
JBoss Native SVN: r2274 - trunk/mod_cluster/native/mod_proxy_cluster.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2009-02-10 15:32:49 -0500 (Tue, 10 Feb 2009)
New Revision: 2274
Modified:
trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c
Log:
use unparsed_uri instead of uri (parsed one).
Modified: trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c
===================================================================
--- trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c 2009-02-10 15:47:17 UTC (rev 2273)
+++ trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c 2009-02-10 20:32:49 UTC (rev 2274)
@@ -1503,8 +1503,8 @@
const char *balancer;
ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_DEBUG, 0, r->server,
- "proxy_cluster_trans for %d %s %s uri: %s",
- r->proxyreq, r->filename, r->handler, r->uri);
+ "proxy_cluster_trans for %d %s %s uri: %s args: %s unparsed_uri: %s",
+ r->proxyreq, r->filename, r->handler, r->uri, r->args, r->unparsed_uri);
balancer = get_route_balancer(r);
if (!balancer) {
@@ -1519,7 +1519,7 @@
balancer = get_context_host_balancer(r);
if (balancer) {
- r->filename = apr_pstrcat(r->pool, "proxy:cluster://", balancer, r->uri, NULL);
+ r->filename = apr_pstrcat(r->pool, "proxy:cluster://", balancer, r->unparsed_uri, NULL);
r->handler = "proxy-server";
r->proxyreq = PROXYREQ_REVERSE;
ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_DEBUG, 0, r->server,
15 years, 10 months
JBoss Native SVN: r2273 - trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha.
by jbossnative-commits@lists.jboss.org
Author: pferraro
Date: 2009-02-10 10:47:17 -0500 (Tue, 10 Feb 2009)
New Revision: 2273
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/ClusteredMCMPHandlerImpl.java
Log:
cosmetic
Modified: trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/ClusteredMCMPHandlerImpl.java
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/ClusteredMCMPHandlerImpl.java 2009-02-10 14:37:12 UTC (rev 2272)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/ClusteredMCMPHandlerImpl.java 2009-02-10 15:47:17 UTC (rev 2273)
@@ -74,7 +74,7 @@
private enum ResetState
{
- NONE, REQUIRED, PENDING;
+ NONE, REQUIRED, PENDING
}
private AtomicReference<ResetState> resetState = new AtomicReference<ResetState>(ResetState.NONE);
15 years, 10 months
JBoss Native SVN: r2272 - trunk/mod_cluster/native/mod_proxy_cluster.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2009-02-10 09:37:12 -0500 (Tue, 10 Feb 2009)
New Revision: 2272
Modified:
trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c
Log:
Fix for MODCLUSTER-44.
Modified: trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c
===================================================================
--- trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c 2009-02-10 12:22:33 UTC (rev 2271)
+++ trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c 2009-02-10 14:37:12 UTC (rev 2272)
@@ -687,12 +687,23 @@
return NULL;
}
-static char *get_cookie_param(request_rec *r, const char *name)
+/*
+ * Read the cookie corresponding to name
+ * @param r request.
+ * @param name name of the cookie
+ * @param in tells if cookie should read from the request or the response
+ * @return the value of the cookie
+ */
+static char *get_cookie_param(request_rec *r, const char *name, int in)
{
const char *cookies;
const char *start_cookie;
- if ((cookies = apr_table_get(r->headers_in, "Cookie"))) {
+ if (in)
+ cookies = apr_table_get(r->headers_in, "Cookie");
+ else
+ cookies = apr_table_get(r->headers_out, "Set-Cookie");
+ if (cookies) {
for (start_cookie = ap_strstr_c(cookies, name); start_cookie;
start_cookie = ap_strstr_c(start_cookie + 1, name)) {
if (start_cookie == cookies ||
@@ -744,7 +755,7 @@
*sticky_used = sticky_path;
route = get_path_param(r->pool, uri , sticky_path);
if (!route) {
- route = get_cookie_param(r, sticky);
+ route = get_cookie_param(r, sticky, 1);
*sticky_used = sticky;
}
return route;
@@ -1981,6 +1992,9 @@
proxy_cluster_helper *helper;
const char *sessionid;
const char *route;
+ char *cookie = NULL;
+ const char *sticky;
+ char *oroute;
if ((rv = PROXY_THREAD_LOCK(balancer)) != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_ERR, rv, r->server,
@@ -2004,8 +2018,32 @@
worker->s->busy--;
/* Add information about sessions corresponding to a node */
+ sticky = apr_table_get(r->notes, "session-sticky");
+ if (sticky == NULL) {
+ char *path, *stick;
+ stick = apr_pstrdup(r->pool, balancer->sticky);
+ if ((path = strchr(stick, '|'))) {
+ *path++ = '\0';
+ }
+ sticky = (const char *) stick;
+ }
+ cookie = get_cookie_param(r, sticky, 0);
sessionid = apr_table_get(r->notes, "session-id");
route = apr_table_get(r->notes, "session-route");
+ if (cookie) {
+ if (sessionid && strcmp(cookie, sessionid)) {
+ /* The cookie has changed, remove the old one and store the next one */
+ sessionidinfo_t ou;
+ strncpy(ou.sessionid, sessionid, SESSIONIDSZ);
+ ou.id = 0;
+ sessionid_storage->remove_sessionid(&ou);
+ }
+ if ((oroute = strchr(cookie, '.')) != NULL )
+ oroute++;
+ route = oroute;
+ sessionid = cookie;
+ }
+
if (sessionid && route) {
sessionidinfo_t ou;
strncpy(ou.sessionid, sessionid, SESSIONIDSZ);
15 years, 10 months
JBoss Native SVN: r2271 - in trunk/mod_cluster/src/main/java/org/jboss/modcluster: mcmp/impl and 1 other directory.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2009-02-10 07:22:33 -0500 (Tue, 10 Feb 2009)
New Revision: 2271
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/Utils.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/impl/DefaultMCMPRequestFactory.java
Log:
Fix MODCLUSTER-52.
Modified: trunk/mod_cluster/src/main/java/org/jboss/modcluster/Utils.java
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/Utils.java 2009-02-09 08:13:41 UTC (rev 2270)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/Utils.java 2009-02-10 12:22:33 UTC (rev 2271)
@@ -74,10 +74,18 @@
for (Connector connector: connectors)
{
- if (connector.getProtocol().startsWith("AJP")) // Return any AJP connector found
+ /* Possible AJP protocol for the AJP connectors:
+ * protocol="org.apache.coyote.ajp.AjpProtocol"
+ * protocol="AJP/1.3"
+ */
+ if (connector.getProtocol().startsWith("AJP")) // Return the first AJP connector found
{
return connector;
}
+ if (connector.getProtocol().startsWith("org.apache.coyote.ajp")) // Return the first AJP connector found
+ {
+ return connector;
+ }
ProtocolHandler handler = connector.getProtocolHandler();
Modified: trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/impl/DefaultMCMPRequestFactory.java
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/impl/DefaultMCMPRequestFactory.java 2009-02-09 08:13:41 UTC (rev 2270)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/impl/DefaultMCMPRequestFactory.java 2009-02-10 12:22:33 UTC (rev 2271)
@@ -62,7 +62,12 @@
boolean reverseConnection = Boolean.TRUE.equals(IntrospectionUtils.getProperty(handler, "reverseConnection"));
boolean ssl = Boolean.TRUE.equals(IntrospectionUtils.getProperty(handler, "SSLEnabled"));
+ // The name is not enough when using org.apache.jk.common.ChannelSocket (it is container).
boolean ajp = ((String) IntrospectionUtils.getProperty(handler, "name")).startsWith("ajp-");
+ if (!ajp)
+ ajp = ((String) IntrospectionUtils.getProperty(connector, "protocol")).startsWith("AJP");
+ if (!ajp)
+ ajp = ((String) IntrospectionUtils.getProperty(connector, "protocol")).startsWith("org.apache.coyote.ajp");
if (reverseConnection)
{
15 years, 10 months
JBoss Native SVN: r2270 - trunk/mod_cluster/test/java.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2009-02-09 03:13:41 -0500 (Mon, 09 Feb 2009)
New Revision: 2270
Modified:
trunk/mod_cluster/test/java/installhttpd.sh
Log:
127.0.0.1 looks better than localhost for the tests.
Modified: trunk/mod_cluster/test/java/installhttpd.sh
===================================================================
--- trunk/mod_cluster/test/java/installhttpd.sh 2009-02-08 17:54:17 UTC (rev 2269)
+++ trunk/mod_cluster/test/java/installhttpd.sh 2009-02-09 08:13:41 UTC (rev 2270)
@@ -6,7 +6,7 @@
# $3: sub network to accept cluster management requests.
IP=localhost
ADVIP=232.0.0.2
-SUBIP=localhost
+SUBIP=127.0.0.1
if [ "x$1" != "x" ]
then
IP=$1
15 years, 10 months
JBoss Native SVN: r2269 - trunk/mod_cluster/test/java.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2009-02-08 12:54:17 -0500 (Sun, 08 Feb 2009)
New Revision: 2269
Modified:
trunk/mod_cluster/test/java/installhttpd.sh
Log:
Allow only localhost... Otherwise the tests are failing when 2 httpd
are running at the same time in the lab machines.
Modified: trunk/mod_cluster/test/java/installhttpd.sh
===================================================================
--- trunk/mod_cluster/test/java/installhttpd.sh 2009-02-06 16:57:27 UTC (rev 2268)
+++ trunk/mod_cluster/test/java/installhttpd.sh 2009-02-08 17:54:17 UTC (rev 2269)
@@ -6,7 +6,7 @@
# $3: sub network to accept cluster management requests.
IP=localhost
ADVIP=232.0.0.2
-SUBIP=all
+SUBIP=localhost
if [ "x$1" != "x" ]
then
IP=$1
15 years, 10 months
JBoss Native SVN: r2268 - in trunk/mod_cluster/src: test/java/org/jboss/modcluster/ha and 1 other directory.
by jbossnative-commits@lists.jboss.org
Author: pferraro
Date: 2009-02-06 11:57:27 -0500 (Fri, 06 Feb 2009)
New Revision: 2268
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/ClusteredMCMPHandler.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/ClusteredMCMPHandlerImpl.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/HAModClusterService.java
trunk/mod_cluster/src/test/java/org/jboss/modcluster/ha/ClusteredMCMPHandlerTestCase.java
Log:
Replaced awkward/buggy errorState List<Boolean> with ResetState enum.
Cleaned up ClusteredMCMPHandler interface.
Modified: trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/ClusteredMCMPHandler.java
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/ClusteredMCMPHandler.java 2009-02-05 18:55:04 UTC (rev 2267)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/ClusteredMCMPHandler.java 2009-02-06 16:57:27 UTC (rev 2268)
@@ -36,18 +36,12 @@
*/
public interface ClusteredMCMPHandler extends MCMPHandler
{
- public static final String HA_SERVICE_NAME = "ModClusterService";
-
List<MCMPServerDiscoveryEvent> getPendingDiscoveryEvents();
void discoveryEventsReceived(PeerMCMPDiscoveryStatus status);
Set<MCMPServerState> updateServersFromMasterNode(Set<MCMPServer> masterList);
- boolean getNeedsResetTransmission();
- void recordResetTransmission();
- void recordResetSuccess();
-
- String getHAServiceName();
-
- String getPartitionName();
+ boolean isResetNecessary();
+ void resetInitiated();
+ void resetCompleted();
}
Modified: trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/ClusteredMCMPHandlerImpl.java
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/ClusteredMCMPHandlerImpl.java 2009-02-05 18:55:04 UTC (rev 2267)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/ClusteredMCMPHandlerImpl.java 2009-02-06 16:57:27 UTC (rev 2268)
@@ -31,6 +31,7 @@
import java.util.List;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicReference;
import net.jcip.annotations.GuardedBy;
import net.jcip.annotations.ThreadSafe;
@@ -70,12 +71,14 @@
private final MCMPHandler localHandler;
private final HASingletonMBean singleton;
private final ClusteredMCMPHandlerRpcHandler rpcStub = new RpcStub();
+
+ private enum ResetState
+ {
+ NONE, REQUIRED, PENDING;
+ }
- private volatile String haServiceName;
+ private AtomicReference<ResetState> resetState = new AtomicReference<ResetState>(ResetState.NONE);
- @GuardedBy("errorState")
- private final List<Boolean> errorState = new ArrayList<Boolean>();
-
@GuardedBy("pendingDiscoveryEvents")
private List<MCMPServerDiscoveryEvent> pendingDiscoveryEvents = new LinkedList<MCMPServerDiscoveryEvent>();
@@ -97,33 +100,6 @@
/**
* @{inheritDoc}
- * @see org.jboss.modcluster.ha.ClusteredMCMPHandler#getHAServiceName()
- */
- public String getHAServiceName()
- {
- return this.haServiceName;
- }
-
- /**
- * @{inheritDoc}
- * @see org.jboss.modcluster.ha.ClusteredMCMPHandler#setHAServiceName(java.lang.String)
- */
- public void setHAServiceName(String serviceName)
- {
- this.haServiceName = serviceName;
- }
-
- /**
- * @{inheritDoc}
- * @see org.jboss.modcluster.ha.ClusteredMCMPHandler#getPartitionName()
- */
- public String getPartitionName()
- {
- return this.serviceKeyProvider.getHAPartition().getPartitionName();
- }
-
- /**
- * @{inheritDoc}
* @see org.jboss.modcluster.ha.ClusteredMCMPHandler#getPendingDiscoveryEvents()
*/
public List<MCMPServerDiscoveryEvent> getPendingDiscoveryEvents()
@@ -182,44 +158,29 @@
/**
* @{inheritDoc}
- * @see org.jboss.modcluster.ha.ClusteredMCMPHandler#getNeedsResetTransmission()
+ * @see org.jboss.modcluster.ha.ClusteredMCMPHandler#isResetNecessary()
*/
- public boolean getNeedsResetTransmission()
+ public boolean isResetNecessary()
{
- synchronized (this.errorState)
- {
- return !this.errorState.isEmpty() && !this.errorState.get(this.errorState.size() - 1).booleanValue();
- }
+ return this.resetState.get() == ResetState.REQUIRED;
}
/**
* @{inheritDoc}
- * @see org.jboss.modcluster.ha.ClusteredMCMPHandler#recordResetTransmission()
+ * @see org.jboss.modcluster.ha.ClusteredMCMPHandler#resetInitiated()
*/
- public void recordResetTransmission()
+ public void resetInitiated()
{
- synchronized (this.errorState)
- {
- if (!this.errorState.isEmpty())
- {
- this.errorState.set(0, Boolean.TRUE);
- }
- }
+ this.resetState.set(ResetState.PENDING);
}
/**
* @{inheritDoc}
- * @see org.jboss.modcluster.ha.ClusteredMCMPHandler#recordResetSuccess()
+ * @see org.jboss.modcluster.ha.ClusteredMCMPHandler#resetCompleted()
*/
- public void recordResetSuccess()
+ public void resetCompleted()
{
- synchronized (this.errorState)
- {
- if (this.errorState.size() > 0 && this.errorState.get(this.errorState.size() - 1).booleanValue())
- {
- this.errorState.remove(0);
- }
- }
+ this.resetState.compareAndSet(ResetState.PENDING, ResetState.NONE);
}
// ------------------------------------------------------------ MCMPHandler
@@ -452,13 +413,7 @@
void recordRequestFailure()
{
- synchronized (this.errorState)
- {
- if (this.errorState.size() == 0 || this.errorState.get(this.errorState.size() - 1).booleanValue())
- {
- this.errorState.add(Boolean.FALSE);
- }
- }
+ this.resetState.set(ResetState.REQUIRED);
}
class RpcStub implements ClusteredMCMPHandlerRpcHandler
Modified: trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/HAModClusterService.java
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/HAModClusterService.java 2009-02-05 18:55:04 UTC (rev 2267)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/HAModClusterService.java 2009-02-06 16:57:27 UTC (rev 2268)
@@ -572,7 +572,7 @@
Set<MCMPServerState> ourStates = this.coord.clusteredHandler.updateServersFromMasterNode(masterList);
- boolean needReset = this.coord.clusteredHandler.getNeedsResetTransmission();
+ boolean needReset = this.coord.clusteredHandler.isResetNecessary();
Map<String, Set<ResetRequestSource.VirtualHost>> map = Collections.emptyMap();
List<MCMPRequest> resetRequests = needReset ? this.coord.resetRequestSource.getLocalResetRequests(map) : null;
@@ -584,7 +584,7 @@
if (needReset)
{
- this.coord.clusteredHandler.recordResetTransmission();
+ this.coord.clusteredHandler.resetInitiated();
}
return response;
@@ -604,7 +604,7 @@
this.coord.clusteredHandler.discoveryEventsReceived(status);
// Notify our handler that any reset requests have been processed
- this.coord.clusteredHandler.recordResetSuccess();
+ this.coord.clusteredHandler.resetCompleted();
DistributedReplicantManager drm = partition.getDistributedReplicantManager();
String key = this.coord.getHAServiceKey();
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 2009-02-05 18:55:04 UTC (rev 2267)
+++ trunk/mod_cluster/src/test/java/org/jboss/modcluster/ha/ClusteredMCMPHandlerTestCase.java 2009-02-06 16:57:27 UTC (rev 2268)
@@ -63,25 +63,6 @@
private ClusteredMCMPHandler handler = new ClusteredMCMPHandlerImpl(this.localHandler, this.singleton, this.keyProvider);
@Test
- public void getPartitionName()
- {
- String expected = "name";
-
- EasyMock.expect(this.keyProvider.getHAPartition()).andReturn(this.partition);
- EasyMock.expect(this.partition.getPartitionName()).andReturn(expected);
-
- EasyMock.replay(this.keyProvider, this.partition);
-
- String result = this.handler.getPartitionName();
-
- EasyMock.verify(this.keyProvider, this.partition);
-
- Assert.assertSame(expected, result);
-
- EasyMock.reset(this.keyProvider, this.partition);
- }
-
- @Test
public void init() throws Exception
{
ClusterNode node = EasyMock.createMock(ClusterNode.class);
@@ -774,4 +755,54 @@
EasyMock.verify(this.localHandler);
EasyMock.reset(this.localHandler);
}
+
+ @Test
+ public void getNeedsResetTransmission()
+ {
+ Assert.assertFalse(this.handler.isResetNecessary());
+
+ // Set State to ERROR
+ EasyMock.expect(this.singleton.isMasterNode()).andReturn(true);
+ this.localHandler.markProxiesInError();
+
+ EasyMock.replay(this.singleton, this.localHandler);
+
+ this.handler.markProxiesInError();
+
+ EasyMock.verify(this.singleton, this.localHandler);
+
+ Assert.assertTrue(this.handler.isResetNecessary());
+
+ EasyMock.reset(this.singleton, this.localHandler);
+
+ this.handler.resetInitiated();
+
+ Assert.assertFalse(this.handler.isResetNecessary());
+
+ // Set State to ERROR again
+ EasyMock.expect(this.singleton.isMasterNode()).andReturn(true);
+ this.localHandler.markProxiesInError();
+
+ EasyMock.replay(this.singleton, this.localHandler);
+
+ this.handler.markProxiesInError();
+
+ EasyMock.verify(this.singleton, this.localHandler);
+
+ Assert.assertTrue(this.handler.isResetNecessary());
+
+ EasyMock.reset(this.singleton, this.localHandler);
+
+ this.handler.resetCompleted();
+
+ Assert.assertTrue(this.handler.isResetNecessary());
+
+ this.handler.resetInitiated();
+
+ Assert.assertFalse(this.handler.isResetNecessary());
+
+ this.handler.resetCompleted();
+
+ Assert.assertFalse(this.handler.isResetNecessary());
+ }
}
15 years, 10 months
JBoss Native SVN: r2267 - in trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha: rpc and 1 other directory.
by jbossnative-commits@lists.jboss.org
Author: pferraro
Date: 2009-02-05 13:55:04 -0500 (Thu, 05 Feb 2009)
New Revision: 2267
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/ClusteredMCMPHandler.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/ClusteredMCMPHandlerImpl.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/HAModClusterService.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/rpc/MCMPServerDiscoveryEvent.java
Log:
[MODCLUSTER-47] Master node enters tight loop calling getClusterCoordinatorState on remote node
Modified: trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/ClusteredMCMPHandler.java
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/ClusteredMCMPHandler.java 2009-02-05 18:12:08 UTC (rev 2266)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/ClusteredMCMPHandler.java 2009-02-05 18:55:04 UTC (rev 2267)
@@ -25,10 +25,11 @@
import java.util.List;
import java.util.Set;
+import org.jboss.modcluster.ha.rpc.MCMPServerDiscoveryEvent;
+import org.jboss.modcluster.ha.rpc.PeerMCMPDiscoveryStatus;
import org.jboss.modcluster.mcmp.MCMPHandler;
import org.jboss.modcluster.mcmp.MCMPServer;
import org.jboss.modcluster.mcmp.MCMPServerState;
-import org.jboss.modcluster.ha.rpc.MCMPServerDiscoveryEvent;
/**
* @author Brian Stansberry
@@ -38,7 +39,7 @@
public static final String HA_SERVICE_NAME = "ModClusterService";
List<MCMPServerDiscoveryEvent> getPendingDiscoveryEvents();
- void discoveryEventsReceived(MCMPServerDiscoveryEvent lastReceived);
+ void discoveryEventsReceived(PeerMCMPDiscoveryStatus status);
Set<MCMPServerState> updateServersFromMasterNode(Set<MCMPServer> masterList);
Modified: trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/ClusteredMCMPHandlerImpl.java
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/ClusteredMCMPHandlerImpl.java 2009-02-05 18:12:08 UTC (rev 2266)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/ClusteredMCMPHandlerImpl.java 2009-02-05 18:55:04 UTC (rev 2267)
@@ -27,6 +27,7 @@
import java.net.InetSocketAddress;
import java.util.ArrayList;
import java.util.Iterator;
+import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
@@ -45,6 +46,7 @@
import org.jboss.modcluster.ha.rpc.GroupRpcResponse;
import org.jboss.modcluster.ha.rpc.GroupRpcResponseFilter;
import org.jboss.modcluster.ha.rpc.MCMPServerDiscoveryEvent;
+import org.jboss.modcluster.ha.rpc.PeerMCMPDiscoveryStatus;
import org.jboss.modcluster.ha.rpc.StringGroupRpcResponse;
import org.jboss.modcluster.ha.rpc.ThrowableGroupRpcResponse;
import org.jboss.modcluster.mcmp.AbstractMCMPHandler;
@@ -74,8 +76,8 @@
@GuardedBy("errorState")
private final List<Boolean> errorState = new ArrayList<Boolean>();
- @GuardedBy("this")
- private List<MCMPServerDiscoveryEvent> pendingDiscoveryEvents = new ArrayList<MCMPServerDiscoveryEvent>();
+ @GuardedBy("pendingDiscoveryEvents")
+ private List<MCMPServerDiscoveryEvent> pendingDiscoveryEvents = new LinkedList<MCMPServerDiscoveryEvent>();
private AtomicInteger discoveryEventIndex = new AtomicInteger();
@@ -124,30 +126,32 @@
* @{inheritDoc}
* @see org.jboss.modcluster.ha.ClusteredMCMPHandler#getPendingDiscoveryEvents()
*/
- public synchronized List<MCMPServerDiscoveryEvent> getPendingDiscoveryEvents()
+ public List<MCMPServerDiscoveryEvent> getPendingDiscoveryEvents()
{
- return new ArrayList<MCMPServerDiscoveryEvent>(this.pendingDiscoveryEvents);
+ synchronized (this.pendingDiscoveryEvents)
+ {
+ return new ArrayList<MCMPServerDiscoveryEvent>(this.pendingDiscoveryEvents);
+ }
}
/**
* @{inheritDoc}
* @see org.jboss.modcluster.ha.ClusteredMCMPHandler#discoveryEventsReceived(org.jboss.modcluster.ha.rpc.MCMPServerDiscoveryEvent)
*/
- public synchronized void discoveryEventsReceived(MCMPServerDiscoveryEvent lastReceived)
+ public void discoveryEventsReceived(PeerMCMPDiscoveryStatus status)
{
- if (lastReceived != null)
+ MCMPServerDiscoveryEvent latestEvent = status.getLatestDiscoveryEvent();
+
+ if (latestEvent != null)
{
- for (Iterator<MCMPServerDiscoveryEvent> it = this.pendingDiscoveryEvents.iterator(); it.hasNext();)
+ synchronized (this.pendingDiscoveryEvents)
{
- MCMPServerDiscoveryEvent event = it.next();
- if (event.getEventIndex() <= lastReceived.getEventIndex())
+ Iterator<MCMPServerDiscoveryEvent> events = this.pendingDiscoveryEvents.iterator();
+
+ while (events.hasNext() && (latestEvent.compareTo(events.next()) >= 0))
{
- it.remove();
+ events.remove();
}
- else
- {
- return;
- }
}
}
}
@@ -156,7 +160,7 @@
* @{inheritDoc}
* @see org.jboss.modcluster.ha.ClusteredMCMPHandler#updateServersFromMasterNode(java.util.Set)
*/
- public synchronized Set<MCMPServerState> updateServersFromMasterNode(Set<MCMPServer> masterList)
+ public Set<MCMPServerState> updateServersFromMasterNode(Set<MCMPServer> masterList)
{
for (MCMPServer server : masterList)
{
@@ -184,7 +188,7 @@
{
synchronized (this.errorState)
{
- return this.errorState.size() > 0 && (this.errorState.get(this.errorState.size() - 1).booleanValue() == false);
+ return !this.errorState.isEmpty() && !this.errorState.get(this.errorState.size() - 1).booleanValue();
}
}
@@ -196,7 +200,7 @@
{
synchronized (this.errorState)
{
- if (this.errorState.size() > 0)
+ if (!this.errorState.isEmpty())
{
this.errorState.set(0, Boolean.TRUE);
}
@@ -224,7 +228,7 @@
* @{inheritDoc}
* @see org.jboss.modcluster.mcmp.MCMPHandler#addProxy(java.net.InetAddress, int)
*/
- public synchronized void addProxy(InetAddress address, int port)
+ public void addProxy(InetAddress address, int port)
{
if (this.singleton.isMasterNode())
{
@@ -249,7 +253,7 @@
* @{inheritDoc}
* @see org.jboss.modcluster.mcmp.MCMPHandler#removeProxy(java.net.InetAddress, int)
*/
- public synchronized void removeProxy(InetAddress address, int port)
+ public void removeProxy(InetAddress address, int port)
{
if (this.singleton.isMasterNode())
{
@@ -424,19 +428,25 @@
}
}
- private synchronized void sendDiscoveryEventToPartition(InetAddress address, int port, boolean addition)
+ private void sendDiscoveryEventToPartition(InetAddress address, int port, boolean addition)
{
InetSocketAddress socketAddress = new InetSocketAddress(address, port);
- MCMPServerDiscoveryEvent event = new MCMPServerDiscoveryEvent(this.serviceKeyProvider.getHAPartition().getClusterNode(), socketAddress, addition, this.discoveryEventIndex.incrementAndGet());
- this.pendingDiscoveryEvents.add(event);
- GroupRpcResponse response = this.rpcStub.mcmpServerDiscoveryEvent(event);
-
- if (response instanceof ThrowableGroupRpcResponse)
+ synchronized (this.pendingDiscoveryEvents)
{
- // Just log it; we'll retry later
- String msg = addition ? "modcluster.error.discovery.add" : "modcluster.error.discovery.remove";
- log.error(this.sm.getString(msg, address, Integer.valueOf(port)), ((ThrowableGroupRpcResponse) response).getValue());
+ // Ensure discovery event enters queue sequentially by index
+ MCMPServerDiscoveryEvent event = new MCMPServerDiscoveryEvent(this.serviceKeyProvider.getHAPartition().getClusterNode(), socketAddress, addition, this.discoveryEventIndex.incrementAndGet());
+
+ this.pendingDiscoveryEvents.add(event);
+
+ GroupRpcResponse response = this.rpcStub.mcmpServerDiscoveryEvent(event);
+
+ if (response instanceof ThrowableGroupRpcResponse)
+ {
+ // Just log it; we'll retry later
+ String msg = addition ? "modcluster.error.discovery.add" : "modcluster.error.discovery.remove";
+ log.error(this.sm.getString(msg, address, Integer.valueOf(port)), ((ThrowableGroupRpcResponse) response).getValue());
+ }
}
}
Modified: trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/HAModClusterService.java
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/HAModClusterService.java 2009-02-05 18:12:08 UTC (rev 2266)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/HAModClusterService.java 2009-02-05 18:55:04 UTC (rev 2267)
@@ -103,8 +103,7 @@
final MCMPRequestFactory requestFactory;
final ClusteredMCMPHandler clusteredHandler;
final HASingletonAwareResetRequestSource resetRequestSource;
- final Map<ClusterNode, MCMPServerDiscoveryEvent> proxyChangeDigest =
- new HashMap<ClusterNode, MCMPServerDiscoveryEvent>();
+ final Map<ClusterNode, MCMPServerDiscoveryEvent> proxyChangeDigest = new HashMap<ClusterNode, MCMPServerDiscoveryEvent>();
final ModClusterServiceDRMEntry drmEntry;
/**
@@ -524,6 +523,7 @@
/**
* This is the object that gets invoked on via reflection by HAPartition.
*/
+ @SuppressWarnings("synthetic-access")
protected class RpcHandler extends HASingletonImpl<HAServiceEvent>.RpcHandler implements ModClusterServiceRpcHandler<GroupRpcResponse, MCMPServer>, ClusteredMCMPHandlerRpcHandler, ResetRequestSourceRpcHandler<GroupRpcResponse>
{
private final HAModClusterService coord = HAModClusterService.this;
@@ -597,23 +597,23 @@
{
HAPartition partition = this.coord.getHAPartition();
ClusterNode cn = partition.getClusterNode();
- PeerMCMPDiscoveryStatus newStatus = statuses.get(cn);
- if (newStatus != null)
+ PeerMCMPDiscoveryStatus status = statuses.get(cn);
+ if (status != null)
{
// Notify our handler that discovery events have been processed
- this.coord.clusteredHandler.discoveryEventsReceived(newStatus.getLatestDiscoveryEvent());
+ this.coord.clusteredHandler.discoveryEventsReceived(status);
// Notify our handler that any reset requests have been processed
this.coord.clusteredHandler.recordResetSuccess();
DistributedReplicantManager drm = partition.getDistributedReplicantManager();
String key = this.coord.getHAServiceKey();
- ModClusterServiceDRMEntry oldStatus = (ModClusterServiceDRMEntry) drm.lookupLocalReplicant(key);
- if (!newStatus.equals(oldStatus))
+ ModClusterServiceDRMEntry previousStatus = (ModClusterServiceDRMEntry) drm.lookupLocalReplicant(key);
+ if (!status.equals(previousStatus))
{
try
{
- drm.add(key, new ModClusterServiceDRMEntry(cn, newStatus.getMCMPServerStates(), oldStatus.getJvmRoutes()));
+ drm.add(key, new ModClusterServiceDRMEntry(cn, status.getMCMPServerStates(), previousStatus.getJvmRoutes()));
}
catch (Exception e)
{
@@ -722,6 +722,7 @@
}
}
+ @SuppressWarnings("synthetic-access")
private class ClusteredCatalinaEventHandler extends CatalinaEventHandler
{
private final HAModClusterService coord = HAModClusterService.this;
@@ -767,7 +768,7 @@
{
this.checkInit();
- log.debug(this.coord.sm.getString("modcluster.engine.status", engine.getName()));
+ this.coord.log.debug(this.coord.sm.getString("modcluster.engine.status", engine.getName()));
this.coord.latestLoad = this.getLoadBalanceFactor();
@@ -794,7 +795,7 @@
HAPartition partition = this.coord.getHAPartition();
DistributedReplicantManager drm = partition.getDistributedReplicantManager();
boolean resync = false;
-
+
do
{
resync = false;
@@ -817,7 +818,7 @@
nonresponsive.remove(partition.getClusterNode());
// FIXME -- what about our own dropped discovery events if we just became master?
- List responses = this.coord.getClusterCoordinatorState(masterList);
+ List<?> responses = this.coord.getClusterCoordinatorState(masterList);
// Gather up all the reset requests in one list
// FIXME -- what about our own dropped requests if we just became master?
@@ -826,7 +827,7 @@
// Gather all the load balance factors
loadBalanceFactors.clear();
- // Add our own lbf - it is not returned via getclusterCoordinatorState(...)
+ // Add our own lbf - it is not returned via getClusterCoordinatorState(...)
for (String jvmRoute: this.coord.drmEntry.getJvmRoutes())
{
loadBalanceFactors.put(jvmRoute, Integer.valueOf(this.coord.latestLoad));
@@ -840,33 +841,31 @@
if (response instanceof ModClusterServiceStateGroupRpcResponse)
{
ModClusterServiceStateGroupRpcResponse mcssgrr = (ModClusterServiceStateGroupRpcResponse) response;
- ClusterNode cn = mcssgrr.getSender();
+ ClusterNode node = mcssgrr.getSender();
// Check for discovery events we haven't processed
- MCMPServerDiscoveryEvent latestEvent = latestEvents.get(cn);
-
- for (MCMPServerDiscoveryEvent toCheck: mcssgrr.getUnacknowledgedEvents())
+ MCMPServerDiscoveryEvent latestEvent = latestEvents.get(node);
+
+ for (MCMPServerDiscoveryEvent event: mcssgrr.getUnacknowledgedEvents())
{
- if (latestEvent != null && latestEvent.getEventIndex() <= toCheck.getEventIndex())
+ if ((latestEvent == null) || (latestEvent.compareTo(event) < 0))
{
- continue; // already processed it
+ InetSocketAddress socketAddress = event.getMCMPServer();
+ if (event.isAddition())
+ {
+ this.coord.localHandler.addProxy(socketAddress.getAddress(), socketAddress.getPort());
+ }
+ else
+ {
+ this.coord.localHandler.removeProxy(socketAddress.getAddress(), socketAddress.getPort());
+ }
+ resync = true;
}
-
- InetSocketAddress socketAddress = toCheck.getMCMPServer();
- if (toCheck.isAddition())
- {
- this.coord.localHandler.addProxy(socketAddress.getAddress(), socketAddress.getPort());
- }
- else
- {
- this.coord.localHandler.removeProxy(socketAddress.getAddress(), socketAddress.getPort());
- }
- resync = true;
}
if (!resync) // don't bother if we are going to start over
{
- statuses.put(cn, new PeerMCMPDiscoveryStatus(cn, mcssgrr.getStates(), latestEvent));
+ statuses.put(node, new PeerMCMPDiscoveryStatus(node, mcssgrr.getStates(), latestEvent));
List<MCMPRequest> toAdd = mcssgrr.getResetRequests();
if (toAdd != null)
@@ -874,7 +873,7 @@
resetRequests.addAll(toAdd);
}
- ModClusterServiceDRMEntry removed = nonresponsive.remove(cn);
+ ModClusterServiceDRMEntry removed = nonresponsive.remove(node);
if (removed != null)
{
Integer lbf = Integer.valueOf(mcssgrr.getLoadBalanceFactor());
@@ -890,18 +889,18 @@
ThrowableGroupRpcResponse tgrr = (ThrowableGroupRpcResponse) response;
ClusterNode cn = tgrr.getSender();
- log.warn(this.coord.sm.getString("modcluster.error.rpc.known", "getClusterCoordinatorState", cn), tgrr.getValue());
+ this.coord.log.warn(this.coord.sm.getString("modcluster.error.rpc.known", "getClusterCoordinatorState", cn), tgrr.getValue());
// Don't remove from nonresponsive list and we'll pass back an error
// status (null server list) to this peer
}
else if (response instanceof Throwable)
{
- log.warn(this.coord.sm.getString("modcluster.error.rpc.unknown", "getClusterCoordinatorState"), (Throwable) response);
+ this.coord.log.warn(this.coord.sm.getString("modcluster.error.rpc.unknown", "getClusterCoordinatorState"), (Throwable) response);
}
else
{
- log.error(this.coord.sm.getString("modcluster.error.rpc.unexpected", response, "getClusterCoordinatorState"));
+ this.coord.log.error(this.coord.sm.getString("modcluster.error.rpc.unexpected", response, "getClusterCoordinatorState"));
}
}
}
@@ -931,6 +930,7 @@
{
statusRequests.add(this.coord.requestFactory.createStatusRequest(entry.getKey(), entry.getValue().intValue()));
}
+
this.coord.localHandler.sendRequests(statusRequests);
// Advise the members the process is done and that they should update DRM
Modified: trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/rpc/MCMPServerDiscoveryEvent.java
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/rpc/MCMPServerDiscoveryEvent.java 2009-02-05 18:12:08 UTC (rev 2266)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/rpc/MCMPServerDiscoveryEvent.java 2009-02-05 18:55:04 UTC (rev 2267)
@@ -37,7 +37,7 @@
* @author Brian Stansberry
*/
@Immutable
-public class MCMPServerDiscoveryEvent implements Serializable
+public class MCMPServerDiscoveryEvent implements Serializable, Comparable<MCMPServerDiscoveryEvent>
{
/** The serialVersionUID */
private static final long serialVersionUID = -4615651826967237065L;
@@ -85,9 +85,30 @@
{
return this.addition;
}
-
+
public int getEventIndex()
{
return this.eventIndex;
}
+
+ @Override
+ public String toString()
+ {
+ StringBuilder builder = new StringBuilder();
+ builder.append("{sender=").append(this.sender);
+ builder.append(", mcmpServer=").append(this.mcmpServer);
+ builder.append(", addition=").append(this.addition);
+ builder.append(", eventIndex=").append(this.eventIndex);
+ builder.append("}");
+ return builder.toString();
+ }
+
+ /**
+ * @{inheritDoc}
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo(MCMPServerDiscoveryEvent event)
+ {
+ return this.eventIndex - event.eventIndex;
+ }
}
15 years, 10 months
JBoss Native SVN: r2266 - trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/impl.
by jbossnative-commits@lists.jboss.org
Author: pferraro
Date: 2009-02-05 13:12:08 -0500 (Thu, 05 Feb 2009)
New Revision: 2266
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/impl/DefaultMCMPHandler.java
Log:
Cosmetic toString() fix
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 2009-02-03 16:04:29 UTC (rev 2265)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/impl/DefaultMCMPHandler.java 2009-02-05 18:12:08 UTC (rev 2266)
@@ -1272,10 +1272,11 @@
public String toString()
{
StringBuilder sb = new StringBuilder(this.getClass().getSimpleName());
- sb.append("{address=").append(this.address)
- .append(",port=").append(this.port)
- .append(",state=").append(this.state)
- .append(",established").append(this.established).append("}");
+ sb.append("{address=").append(this.address);
+ sb.append(",port=").append(this.port);
+ sb.append(",state=").append(this.state);
+ sb.append(",established=").append(this.established);
+ sb.append("}");
return sb.toString();
}
}
15 years, 10 months