You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by or...@apache.org on 2018/05/02 23:23:10 UTC
[2/3] qpid-broker-j git commit: QPID-8167: [Broker-J] Fix quiescing
virtualhosts in management mode
QPID-8167: [Broker-J] Fix quiescing virtualhosts in management mode
Project: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/commit/b14319e3
Tree: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/tree/b14319e3
Diff: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/diff/b14319e3
Branch: refs/heads/master
Commit: b14319e30a0a09f8ce12a8d4e98e19a686c0c1ed
Parents: c8fae15
Author: Alex Rudyy <or...@apache.org>
Authored: Wed May 2 19:07:28 2018 +0100
Committer: Alex Rudyy <or...@apache.org>
Committed: Thu May 3 00:22:00 2018 +0100
----------------------------------------------------------------------
.../store/ManagementModeStoreHandler.java | 21 +++++++++---------
.../AbstractVirtualHostNode.java | 7 ++++++
.../store/ManagementModeStoreHandlerTest.java | 23 ++++++++++----------
3 files changed, 30 insertions(+), 21 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/b14319e3/broker-core/src/main/java/org/apache/qpid/server/configuration/store/ManagementModeStoreHandler.java
----------------------------------------------------------------------
diff --git a/broker-core/src/main/java/org/apache/qpid/server/configuration/store/ManagementModeStoreHandler.java b/broker-core/src/main/java/org/apache/qpid/server/configuration/store/ManagementModeStoreHandler.java
index b3e962d..0d0cf85 100644
--- a/broker-core/src/main/java/org/apache/qpid/server/configuration/store/ManagementModeStoreHandler.java
+++ b/broker-core/src/main/java/org/apache/qpid/server/configuration/store/ManagementModeStoreHandler.java
@@ -34,6 +34,7 @@ import org.slf4j.LoggerFactory;
import org.apache.qpid.server.configuration.IllegalConfigurationException;
import org.apache.qpid.server.model.Broker;
+import org.apache.qpid.server.model.BrokerImpl;
import org.apache.qpid.server.model.ConfiguredObject;
import org.apache.qpid.server.model.ConfiguredObjectAttribute;
import org.apache.qpid.server.model.ConfiguredObjectTypeRegistry;
@@ -44,7 +45,7 @@ import org.apache.qpid.server.model.Protocol;
import org.apache.qpid.server.model.State;
import org.apache.qpid.server.model.SystemConfig;
import org.apache.qpid.server.model.VirtualHost;
-import org.apache.qpid.server.model.BrokerImpl;
+import org.apache.qpid.server.model.VirtualHostNode;
import org.apache.qpid.server.store.ConfiguredObjectRecord;
import org.apache.qpid.server.store.ConfiguredObjectRecordImpl;
import org.apache.qpid.server.store.DurableConfigurationStore;
@@ -57,8 +58,8 @@ public class ManagementModeStoreHandler implements DurableConfigurationStore
private static final String MANAGEMENT_MODE_PORT_PREFIX = "MANAGEMENT-MODE-PORT-";
private static final String PORT_TYPE = Port.class.getSimpleName();
- private static final String VIRTUAL_HOST_TYPE = VirtualHost.class.getSimpleName();
- private static final String ATTRIBUTE_STATE = VirtualHost.STATE;
+ private static final String VIRTUAL_HOST_NODE_TYPE = VirtualHostNode.class.getSimpleName();
+ private static final String ATTRIBUTE_DESIRED_STATE = ConfiguredObject.DESIRED_STATE;
private static final Object MANAGEMENT_MODE_AUTH_PROVIDER = "mm-auth";
private enum StoreState { CLOSED, CONFIGURED, OPEN };
@@ -282,7 +283,7 @@ public class ManagementModeStoreHandler implements DurableConfigurationStore
String entryType = entry.getType();
Map<String, Object> attributes = entry.getAttributes();
boolean quiesce = false;
- if (VIRTUAL_HOST_TYPE.equals(entryType) && options.isManagementModeQuiesceVirtualHosts())
+ if (VIRTUAL_HOST_NODE_TYPE.equals(entryType) && options.isManagementModeQuiesceVirtualHosts())
{
quiesce = true;
}
@@ -317,7 +318,7 @@ public class ManagementModeStoreHandler implements DurableConfigurationStore
LOGGER.debug("Management mode quiescing entry {}", entry);
// save original state
- quiescedEntries.put(entry.getId(), attributes.get(ATTRIBUTE_STATE));
+ quiescedEntries.put(entry.getId(), attributes.get(ATTRIBUTE_DESIRED_STATE));
}
}
@@ -347,11 +348,11 @@ public class ManagementModeStoreHandler implements DurableConfigurationStore
Map<String, Object> attributes = new HashMap<String, Object>(entry.getAttributes());
if (state == null)
{
- attributes.remove(ATTRIBUTE_STATE);
+ attributes.remove(ATTRIBUTE_DESIRED_STATE);
}
else
{
- attributes.put(ATTRIBUTE_STATE, state);
+ attributes.put(ATTRIBUTE_DESIRED_STATE, state);
}
return new ConfiguredObjectRecordImpl(entry.getId(), entry.getType(), attributes, entry.getParents());
}
@@ -382,7 +383,7 @@ public class ManagementModeStoreHandler implements DurableConfigurationStore
String entryType = object.getType();
Map<String, Object> attributes = object.getAttributes();
boolean quiesce = false;
- if (VIRTUAL_HOST_TYPE.equals(entryType) && _systemConfig.isManagementModeQuiesceVirtualHosts())
+ if (VIRTUAL_HOST_NODE_TYPE.equals(entryType) && _systemConfig.isManagementModeQuiesceVirtualHosts())
{
quiesce = true;
}
@@ -417,9 +418,9 @@ public class ManagementModeStoreHandler implements DurableConfigurationStore
LOGGER.debug("Management mode quiescing entry {}", object);
// save original state
- _quiescedEntriesOriginalState.put(object.getId(), attributes.get(ATTRIBUTE_STATE));
+ _quiescedEntriesOriginalState.put(object.getId(), attributes.get(ATTRIBUTE_DESIRED_STATE));
Map<String, Object> modifiedAttributes = new HashMap<String, Object>(attributes);
- modifiedAttributes.put(ATTRIBUTE_STATE, State.QUIESCED);
+ modifiedAttributes.put(ATTRIBUTE_DESIRED_STATE, State.QUIESCED);
ConfiguredObjectRecord record = new ConfiguredObjectRecordImpl(object.getId(),
object.getType(),
modifiedAttributes,
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/b14319e3/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/AbstractVirtualHostNode.java
----------------------------------------------------------------------
diff --git a/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/AbstractVirtualHostNode.java b/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/AbstractVirtualHostNode.java
index fb58433..b17b998 100644
--- a/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/AbstractVirtualHostNode.java
+++ b/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/AbstractVirtualHostNode.java
@@ -152,6 +152,13 @@ public abstract class AbstractVirtualHostNode<X extends AbstractVirtualHostNode<
super.onCreate();
}
+ @StateTransition(currentState = State.UNINITIALIZED, desiredState = State.QUIESCED)
+ protected ListenableFuture<Void> startQuiesced()
+ {
+ setState(State.QUIESCED);
+ return Futures.immediateFuture(null);
+ }
+
@StateTransition( currentState = {State.UNINITIALIZED, State.STOPPED, State.ERRORED }, desiredState = State.ACTIVE )
protected ListenableFuture<Void> doActivate()
{
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/b14319e3/broker-core/src/test/java/org/apache/qpid/server/configuration/store/ManagementModeStoreHandlerTest.java
----------------------------------------------------------------------
diff --git a/broker-core/src/test/java/org/apache/qpid/server/configuration/store/ManagementModeStoreHandlerTest.java b/broker-core/src/test/java/org/apache/qpid/server/configuration/store/ManagementModeStoreHandlerTest.java
index 33e04a4..cfe7aba 100644
--- a/broker-core/src/test/java/org/apache/qpid/server/configuration/store/ManagementModeStoreHandlerTest.java
+++ b/broker-core/src/test/java/org/apache/qpid/server/configuration/store/ManagementModeStoreHandlerTest.java
@@ -62,6 +62,7 @@ import org.apache.qpid.server.model.State;
import org.apache.qpid.server.model.StateTransition;
import org.apache.qpid.server.model.SystemConfig;
import org.apache.qpid.server.model.VirtualHost;
+import org.apache.qpid.server.model.VirtualHostNode;
import org.apache.qpid.server.store.ConfiguredObjectRecord;
import org.apache.qpid.server.store.ConfiguredObjectRecordImpl;
import org.apache.qpid.server.store.DurableConfigurationStore;
@@ -291,7 +292,7 @@ public class ManagementModeStoreHandlerTest extends UnitTestBase
ConfiguredObjectRecord portEntry = getEntry(records, _portEntryId);
assertEquals("Unexpected entry id", _portEntryId, portEntry.getId());
assertTrue("Unexpected children", getChildrenIds(records, portEntry).isEmpty());
- assertEquals("Unexpected state", State.QUIESCED, portEntry.getAttributes().get(Port.STATE));
+ assertEquals("Unexpected state", State.QUIESCED, portEntry.getAttributes().get(Port.DESIRED_STATE));
}
@Test
@@ -321,7 +322,7 @@ public class ManagementModeStoreHandlerTest extends UnitTestBase
Collection<ConfiguredObjectRecord> records = openAndGetRecords();
ConfiguredObjectRecord portEntry = getEntry(records, _portEntryId);
- assertEquals("Unexpected state", State.QUIESCED, portEntry.getAttributes().get(Port.STATE));
+ assertEquals("Unexpected state", State.QUIESCED, portEntry.getAttributes().get(Port.DESIRED_STATE));
}
@Test
@@ -338,11 +339,11 @@ public class ManagementModeStoreHandlerTest extends UnitTestBase
private void virtualHostEntryQuiescedStatusTestImpl(boolean mmQuiesceVhosts)
{
- UUID virtualHostId = UUID.randomUUID();
+ UUID virtualHostNodeId = UUID.randomUUID();
Map<String, Object> attributes = new HashMap<String, Object>();
- attributes.put(VirtualHost.TYPE, "STANDARD");
+ attributes.put(VirtualHostNode.TYPE, "JSON");
- final ConfiguredObjectRecord virtualHost = new ConfiguredObjectRecordImpl(virtualHostId, VirtualHost.class.getSimpleName(), attributes, Collections.singletonMap(Broker.class.getSimpleName(), _root.getId()));
+ final ConfiguredObjectRecord virtualHostNodeRecord = new ConfiguredObjectRecordImpl(virtualHostNodeId, VirtualHostNode.class.getSimpleName(), attributes, Collections.singletonMap(Broker.class.getSimpleName(), _root.getId()));
final ArgumentCaptor<ConfiguredObjectRecordHandler> recovererArgumentCaptor = ArgumentCaptor.forClass(ConfiguredObjectRecordHandler.class);
doAnswer(
new Answer()
@@ -353,7 +354,7 @@ public class ManagementModeStoreHandlerTest extends UnitTestBase
ConfiguredObjectRecordHandler recoverer = recovererArgumentCaptor.getValue();
recoverer.handle(_root);
recoverer.handle(_portEntry);
- recoverer.handle(virtualHost);
+ recoverer.handle(virtualHostNodeRecord);
return false;
}
}
@@ -369,11 +370,11 @@ public class ManagementModeStoreHandlerTest extends UnitTestBase
_handler.init(_systemConfig);
Collection<ConfiguredObjectRecord> records = openAndGetRecords();
- ConfiguredObjectRecord hostEntry = getEntry(records, virtualHostId);
- Map<String, Object> hostAttributes = new HashMap<String, Object>(hostEntry.getAttributes());
- assertEquals("Unexpected state", expectedState, hostAttributes.get(VirtualHost.STATE));
- hostAttributes.remove(VirtualHost.STATE);
- assertEquals("Unexpected attributes", attributes, hostAttributes);
+ ConfiguredObjectRecord nodeEntry = getEntry(records, virtualHostNodeId);
+ Map<String, Object> nodeAttributes = new HashMap<String, Object>(nodeEntry.getAttributes());
+ assertEquals("Unexpected state", expectedState, nodeAttributes.get(VirtualHostNode.DESIRED_STATE));
+ nodeAttributes.remove(VirtualHostNode.DESIRED_STATE);
+ assertEquals("Unexpected attributes", attributes, nodeAttributes);
}
@SuppressWarnings("unchecked")
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org