From b595da7578a5e421b04cdf5590a2c9bd5af4c08d Mon Sep 17 00:00:00 2001 From: Keith Wall Date: Fri, 23 May 2014 11:46:46 +0000 Subject: 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 and me. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1597066 13f79535-47bb-0310-9956-ffa450edef68 --- .../protocol/v0_10/ServerConnectionDelegate.java | 20 +++++++++----------- .../v0_8/handler/ConnectionOpenMethodHandler.java | 14 ++++++-------- 2 files changed, 15 insertions(+), 19 deletions(-) (limited to 'qpid/java/broker-plugins') 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