diff options
author | Alex Rudyy <orudyy@apache.org> | 2014-05-24 19:39:56 +0000 |
---|---|---|
committer | Alex Rudyy <orudyy@apache.org> | 2014-05-24 19:39:56 +0000 |
commit | b3d93c60bf55ea13cc43eba4f9e429d7fe1b0af3 (patch) | |
tree | bbe79d15d86cf349db83072df77cd28f3f2f7307 /java/broker-core/src | |
parent | 78e1d29ecefa2db572cbcc8158792133302aba9f (diff) | |
download | qpid-python-b3d93c60bf55ea13cc43eba4f9e429d7fe1b0af3.tar.gz |
QPID-5715: On virtual host node deletion delete virtual host first, in order to allow listeners to hear virtual host deletion. JMX Management needs to unregister virtual host MBean on host deletion
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1597340 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/broker-core/src')
4 files changed, 42 insertions, 23 deletions
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java b/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java index e67191b744..812ffc618d 100644 --- a/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java +++ b/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java @@ -1324,6 +1324,16 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im return _attributeResolver; } + protected boolean isAttributePersisted(String name) + { + ConfiguredObjectAttribute<X,?> attr = (ConfiguredObjectAttribute<X, ?>) _attributeTypes.get(name); + if(attr != null) + { + return attr.isPersisted(); + } + return false; + } + //========================================================================================= static String interpolate(ConfiguredObject<?> object, String value) diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/store/JsonFileConfigStore.java b/java/broker-core/src/main/java/org/apache/qpid/server/store/JsonFileConfigStore.java index dcacb1ae7f..afdd3a9136 100644 --- a/java/broker-core/src/main/java/org/apache/qpid/server/store/JsonFileConfigStore.java +++ b/java/broker-core/src/main/java/org/apache/qpid/server/store/JsonFileConfigStore.java @@ -378,7 +378,11 @@ public class JsonFileConfigStore implements DurableConfigurationStore List<UUID> ids = _idsByType.get(_rootClass.getSimpleName()); if (ids == null) { - throw new IllegalStateException("Root entry of type " + _rootClass.getSimpleName() + " does not exist in the store."); + return null; + } + if (ids.size() == 0) + { + return null; } return ids.get(0); } @@ -386,7 +390,16 @@ public class JsonFileConfigStore implements DurableConfigurationStore private void save() { UUID rootId = getRootId(); - Map<String, Object> data = build(_rootClass, rootId); + Map<String, Object> data = null; + + if (rootId == null) + { + data = Collections.emptyMap(); + } + else + { + data = build(_rootClass, rootId); + } try { diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java b/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java index 86c19941f8..26da911e1f 100644 --- a/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java +++ b/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java @@ -695,16 +695,6 @@ public abstract class AbstractVirtualHost<X extends AbstractVirtualHost<X>> exte _eventLogger.message(VirtualHostMessages.CLOSED(getName())); } - @Override - protected void changeAttributes(final Map<String, Object> attributes) - { - super.changeAttributes(attributes); - if (isDurable() && getState() != State.DELETED) - { - getDurableConfigurationStore().update(false, asObjectRecord()); - } - } - private void closeMessageStore() { if (getMessageStore() != null) @@ -1447,7 +1437,7 @@ public abstract class AbstractVirtualHost<X extends AbstractVirtualHost<X>> exte @Override public void stateChanged(final ConfiguredObject<?> object, final State oldState, final State newState) { - if (newState == State.DELETED) + if (object == AbstractVirtualHost.this && isDurable() && newState == State.DELETED) { getDurableConfigurationStore().remove(asObjectRecord()); object.removeChangeListener(this); @@ -1472,7 +1462,11 @@ public abstract class AbstractVirtualHost<X extends AbstractVirtualHost<X>> exte final Object oldAttributeValue, final Object newAttributeValue) { - getDurableConfigurationStore().update(false, asObjectRecord()); + if (object == AbstractVirtualHost.this && isDurable() && getState() != State.DELETED && isAttributePersisted(attributeName) + && !(attributeName.equals(VirtualHost.DESIRED_STATE) && newAttributeValue.equals(State.DELETED))) + { + getDurableConfigurationStore().update(false, asObjectRecord()); + } } } diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/AbstractVirtualHostNode.java b/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/AbstractVirtualHostNode.java index 2f8860a3a0..f52558e298 100644 --- a/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/AbstractVirtualHostNode.java +++ b/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/AbstractVirtualHostNode.java @@ -194,23 +194,25 @@ public abstract class AbstractVirtualHostNode<X extends AbstractVirtualHostNode< @StateTransition( currentState = { State.ACTIVE, State.STOPPED, State.ERRORED}, desiredState = State.DELETED ) protected void doDelete() { - - close(); _state.set(State.DELETED); - VirtualHost<?, ?, ?> virtualHost = getVirtualHost(); - if (virtualHost != null) - { - virtualHost.delete(); - } - + deleteVirtualHostIfExists(); + close(); deleted(); - if (getConfigurationStore() instanceof MessageStore) { ((MessageStore)getConfigurationStore()).onDelete(); } } + protected void deleteVirtualHostIfExists() + { + VirtualHost<?, ?, ?> virtualHost = getVirtualHost(); + if (virtualHost != null) + { + virtualHost.delete(); + } + } + @StateTransition( currentState = { State.ACTIVE, State.ERRORED, State.UNINITIALIZED }, desiredState = State.STOPPED ) protected void doStop() { |