diff options
| author | Keith Wall <kwall@apache.org> | 2014-07-08 21:40:01 +0000 |
|---|---|---|
| committer | Keith Wall <kwall@apache.org> | 2014-07-08 21:40:01 +0000 |
| commit | 790ce3196c5cef5a138bae29fa7ac9f03fee5b1b (patch) | |
| tree | ad4141bcb804a4662c93a1ee50ef69a6578447fe /qpid/java | |
| parent | fc1519a03845766cedf3154e4db97ee307cbbf06 (diff) | |
| download | qpid-python-790ce3196c5cef5a138bae29fa7ac9f03fee5b1b.tar.gz | |
QPID-5885: [Java Broker] Virtualhostnode to replace real virtualhost with replica virtualhost in the event that the BDB HA goes into detached state
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1608956 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java')
4 files changed, 21 insertions, 40 deletions
diff --git a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/replication/ReplicatedEnvironmentFacade.java b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/replication/ReplicatedEnvironmentFacade.java index 8b9039c792..f8b9636c5d 100644 --- a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/replication/ReplicatedEnvironmentFacade.java +++ b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/replication/ReplicatedEnvironmentFacade.java @@ -846,23 +846,6 @@ public class ReplicatedEnvironmentFacade implements EnvironmentFacade, StateChan { try { - if (environment.isValid()) - { - environment.setStateChangeListener(new StateChangeListener() - { - @Override - public void stateChange(StateChangeEvent stateChangeEvent) throws RuntimeException - { - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug( - "When restarting a state change event is received on NOOP listener for state:" - + stateChangeEvent.getState()); - } - } - }); - } - try { closeSequences(); diff --git a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNodeImpl.java b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNodeImpl.java index 3868025096..0bbbff0f98 100644 --- a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNodeImpl.java +++ b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNodeImpl.java @@ -46,7 +46,6 @@ import com.sleepycat.je.rep.utilint.HostPortPair; import org.apache.log4j.Logger; import org.apache.qpid.server.configuration.updater.Task; -import org.apache.qpid.server.configuration.updater.VoidTask; import org.apache.qpid.server.logging.messages.ConfigStoreMessages; import org.apache.qpid.server.model.Broker; import org.apache.qpid.server.model.BrokerModel; @@ -104,6 +103,7 @@ public class BDBHAVirtualHostNodeImpl extends AbstractVirtualHostNode<BDBHAVirtu @ManagedAttributeField(afterSet="postSetPriority") private int _priority; + @ManagedAttributeField(afterSet="postSetQuorumOverride") private int _quorumOverride; @@ -426,11 +426,22 @@ public class BDBHAVirtualHostNodeImpl extends AbstractVirtualHostNode<BDBHAVirtu private void onReplica() { + createReplicaVirtualHost(); + } + + + private void onDetached() + { + createReplicaVirtualHost(); + } + + private void createReplicaVirtualHost() + { try { closeVirtualHostIfExist(); - Map<String, Object> hostAttributes = new HashMap<String, Object>(); + Map<String, Object> hostAttributes = new HashMap<>(); hostAttributes.put(VirtualHost.MODEL_VERSION, BrokerModel.MODEL_VERSION); hostAttributes.put(VirtualHost.NAME, getGroupName()); hostAttributes.put(VirtualHost.TYPE, "BDB_HA_REPLICA"); @@ -442,11 +453,6 @@ public class BDBHAVirtualHostNodeImpl extends AbstractVirtualHostNode<BDBHAVirtu } } - private void onDetached() - { - closeVirtualHostIfExist(); - } - protected void closeVirtualHostIfExist() { VirtualHost<?,?,?> virtualHost = getVirtualHost(); @@ -478,11 +484,9 @@ public class BDBHAVirtualHostNodeImpl extends AbstractVirtualHostNode<BDBHAVirtu onReplica(); break; case DETACHED: - LOGGER.error("BDB replicated node in detached state, therefore passivating."); onDetached(); break; case UNKNOWN: - LOGGER.warn("BDB replicated node in unknown state (hopefully temporarily)"); break; default: LOGGER.error("Unexpected state change: " + state); diff --git a/qpid/java/bdbstore/systests/src/main/java/org/apache/qpid/server/store/berkeleydb/HAClusterTwoNodeTest.java b/qpid/java/bdbstore/systests/src/main/java/org/apache/qpid/server/store/berkeleydb/HAClusterTwoNodeTest.java index 24296246b8..8df419c3a7 100644 --- a/qpid/java/bdbstore/systests/src/main/java/org/apache/qpid/server/store/berkeleydb/HAClusterTwoNodeTest.java +++ b/qpid/java/bdbstore/systests/src/main/java/org/apache/qpid/server/store/berkeleydb/HAClusterTwoNodeTest.java @@ -22,11 +22,7 @@ package org.apache.qpid.server.store.berkeleydb; import java.io.File; import javax.jms.Connection; -import javax.jms.Destination; import javax.jms.JMSException; -import javax.jms.Message; -import javax.jms.MessageConsumer; -import javax.jms.Session; import javax.management.ObjectName; import org.apache.qpid.jms.ConnectionURL; @@ -36,8 +32,6 @@ import org.apache.qpid.test.utils.QpidBrokerTestCase; public class HAClusterTwoNodeTest extends QpidBrokerTestCase { - private static final long RECEIVE_TIMEOUT = 5000l; - private static final String VIRTUAL_HOST = "test"; private static final String MANAGED_OBJECT_QUERY = "org.apache.qpid:type=BDBHAMessageStore,name=" + ObjectName.quote(VIRTUAL_HOST); @@ -123,20 +117,22 @@ public class HAClusterTwoNodeTest extends QpidBrokerTestCase assertProducingConsuming(connection); } - public void testPersistentOperationsFailOnNonDesignatedPrimarysAfterSecondaryStopped() throws Exception + public void testPersistentOperationsFailOnNonDesignatedPrimaryAfterSecondaryStopped() throws Exception { startCluster(false); _clusterCreator.stopNode(_clusterCreator.getBrokerPortNumberOfSecondaryNode()); - final Connection connection = getConnection(_brokerFailoverUrl); - assertNotNull("Expected to get a valid connection to primary", connection); + try { + Connection connection = getConnection(_brokerFailoverUrl); assertProducingConsuming(connection); - fail("JMS peristent operations succeded on Master 'not designated primary' buy they should fail as replica is not available"); + fail("Exception not thrown"); } catch(JMSException e) { - // JMSException should be thrown on transaction start/commit + // JMSException should be thrown either on getConnection, or produce/consume + // depending on whether the relative timing of the node discovering that the + // secondary has gone. } } @@ -166,7 +162,7 @@ public class HAClusterTwoNodeTest extends QpidBrokerTestCase assertFalse("Expected secondary node to NOT be set as designated primary", secondaryStoreBean.getDesignatedPrimary()); } - public void testSecondaryDesignatedAsPrimaryAfterOrginalPrimaryStopped() throws Exception + public void testSecondaryDesignatedAsPrimaryAfterOriginalPrimaryStopped() throws Exception { startCluster(true); final ManagedBDBHAMessageStore storeBean = getStoreBeanForNodeAtBrokerPort(_clusterCreator.getBrokerPortNumberOfSecondaryNode()); diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java index 31f740c82e..67cc87e103 100755 --- a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java @@ -1052,7 +1052,6 @@ public class QpidBrokerTestCase extends QpidTestCase */ public InitialContext getInitialContext() throws NamingException { - _logger.info("get InitialContext"); if (_initialContext == null) { _initialContext = new InitialContext(); @@ -1070,7 +1069,6 @@ public class QpidBrokerTestCase extends QpidTestCase */ public AMQConnectionFactory getConnectionFactory() throws NamingException { - _logger.info("get ConnectionFactory"); if (_connectionFactory == null) { if (Boolean.getBoolean(PROFILE_USE_SSL)) |
