summaryrefslogtreecommitdiff
path: root/qpid/java/broker-plugins
diff options
context:
space:
mode:
authorKeith Wall <kwall@apache.org>2014-05-23 11:46:46 +0000
committerKeith Wall <kwall@apache.org>2014-05-23 11:46:46 +0000
commitb595da7578a5e421b04cdf5590a2c9bd5af4c08d (patch)
tree888093ed46c8625810d41c5d62d9897a38594df3 /qpid/java/broker-plugins
parent81105f54b26217b7a0760f00e61d5203f8c4255c (diff)
downloadqpid-python-b595da7578a5e421b04cdf5590a2c9bd5af4c08d.tar.gz
QPID-5715: [Java Broker] Prevent sporadic failure of BDB HA REST test testNewMasterElectedWhenVirtualHostIsStopped
* VHN role attribute now mutated after the completion of onMaster/onReplica event * Made BDBHAReplicaVirtualHost a type (BDB_HA_REPLICA) within the VirtualHost category. This no-op vhost represents the virtualhost when the node is replica (and the mastership is elsewhere within the group). Work by Andrew MacBean <andymacbean@gmail.com> and me. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1597066 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/broker-plugins')
-rw-r--r--qpid/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerConnectionDelegate.java20
-rw-r--r--qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/ConnectionOpenMethodHandler.java14
2 files changed, 15 insertions, 19 deletions
diff --git a/qpid/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerConnectionDelegate.java b/qpid/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerConnectionDelegate.java
index 56700b5ebd..6dd4124258 100644
--- a/qpid/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerConnectionDelegate.java
+++ b/qpid/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerConnectionDelegate.java
@@ -211,8 +211,14 @@ public class ServerConnectionDelegate extends ServerDelegate
if(vhost != null)
{
- sconn.setVirtualHost(vhost);
+ if (vhost.getState() != State.ACTIVE)
+ {
+ sconn.setState(Connection.State.CLOSING);
+ sconn.invoke(new ConnectionClose(ConnectionCloseCode.CONNECTION_FORCED, "Virtual host '"+vhostName+"' is not active"));
+ return;
+ }
+ sconn.setVirtualHost(vhost);
try
{
vhost.getSecurityManager().authoriseCreateConnection(sconn);
@@ -224,16 +230,8 @@ public class ServerConnectionDelegate extends ServerDelegate
return;
}
- if (vhost.getState() != State.ACTIVE)
- {
- sconn.setState(Connection.State.CLOSING);
- sconn.invoke(new ConnectionClose(ConnectionCloseCode.CONNECTION_FORCED, "Virtual host '"+vhostName+"' is not active"));
- }
- else
- {
- sconn.setState(Connection.State.OPEN);
- sconn.invoke(new ConnectionOpenOk(Collections.emptyList()));
- }
+ sconn.setState(Connection.State.OPEN);
+ sconn.invoke(new ConnectionOpenOk(Collections.emptyList()));
}
else
{
diff --git a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/ConnectionOpenMethodHandler.java b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/ConnectionOpenMethodHandler.java
index 80a66292bf..632f751756 100644
--- a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/ConnectionOpenMethodHandler.java
+++ b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/ConnectionOpenMethodHandler.java
@@ -81,9 +81,13 @@ public class ConnectionOpenMethodHandler implements StateAwareMethodListener<Con
}
else
{
- session.setVirtualHost(virtualHost);
-
// Check virtualhost access
+ if (virtualHost.getState() != State.ACTIVE)
+ {
+ throw body.getConnectionException(AMQConstant.CONNECTION_FORCED, "Virtual host '" + virtualHost.getName() + "' is not active");
+ }
+
+ session.setVirtualHost(virtualHost);
try
{
virtualHost.getSecurityManager().authoriseCreateConnection(session);
@@ -93,12 +97,6 @@ public class ConnectionOpenMethodHandler implements StateAwareMethodListener<Con
throw body.getConnectionException(AMQConstant.ACCESS_REFUSED, e.getMessage());
}
- if (virtualHost.getState() != State.ACTIVE)
- {
- throw body.getConnectionException(AMQConstant.CONNECTION_FORCED, "Virtual host '" + virtualHost.getName() + "' is not active");
- }
-
-
// See Spec (0.8.2). Section 3.1.2 Virtual Hosts
if (session.getContextKey() == null)
{