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/02/26 16:41:11 UTC
[1/2] qpid-broker-j git commit: QPID-8110: [Broker-J] Add ability to
check ERRORED state of entire configured object hierarchy
Repository: qpid-broker-j
Updated Branches:
refs/heads/7.0.x 7c69d1704 -> f57f6deb1
QPID-8110: [Broker-J] Add ability to check ERRORED state of entire configured object hierarchy
This closes #4
https://github.com/apache/qpid-broker-j/pull/4
(cherry picked from commit b720d7d1e81324441b8fbc2850ef19ca0fdf9bda)
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/3bbf01a0
Tree: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/tree/3bbf01a0
Diff: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/diff/3bbf01a0
Branch: refs/heads/7.0.x
Commit: 3bbf01a0b44192fd3e04264230ebc14e4abe3c7a
Parents: 7c69d17
Author: Alex Rudyy <or...@apache.org>
Authored: Fri Feb 23 15:58:12 2018 +0000
Committer: Alex Rudyy <or...@apache.org>
Committed: Mon Feb 26 16:38:56 2018 +0000
----------------------------------------------------------------------
.../org/apache/qpid/server/model/Broker.java | 4 +
.../apache/qpid/server/model/BrokerImpl.java | 85 +++++++++++++++-----
.../qpid/server/model/DescendantType.java | 26 ++++++
3 files changed, 93 insertions(+), 22 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/3bbf01a0/broker-core/src/main/java/org/apache/qpid/server/model/Broker.java
----------------------------------------------------------------------
diff --git a/broker-core/src/main/java/org/apache/qpid/server/model/Broker.java b/broker-core/src/main/java/org/apache/qpid/server/model/Broker.java
index 6f7b74c..3bb26d4 100644
--- a/broker-core/src/main/java/org/apache/qpid/server/model/Broker.java
+++ b/broker-core/src/main/java/org/apache/qpid/server/model/Broker.java
@@ -54,6 +54,7 @@ public interface Broker<X extends Broker<X>> extends ConfiguredObject<X>, EventL
String CHANNEL_FLOW_CONTROL_ENFORCEMENT_TIMEOUT = "channel.flowControlEnforcementTimeout";
String BROKER_FLOW_TO_DISK_THRESHOLD = "broker.flowToDiskThreshold";
String BROKER_FAIL_STARTUP_WITH_ERRORED_CHILD = "broker.failStartupWithErroredChild";
+ String BROKER_FAIL_STARTUP_WITH_ERRORED_CHILD_SCOPE = "broker.failStartupWithErroredChildScope";
String BROKER_MSG_AUTH = "qpid.broker_msg_auth";
@@ -99,6 +100,9 @@ public interface Broker<X extends Broker<X>> extends ConfiguredObject<X>, EventL
@ManagedContextDefault(name = BROKER_FAIL_STARTUP_WITH_ERRORED_CHILD)
boolean DEFAULT_BROKER_FAIL_STARTUP_WITH_ERRORED_CHILD = false;
+ @ManagedContextDefault(name = BROKER_FAIL_STARTUP_WITH_ERRORED_CHILD_SCOPE)
+ DescendantType DEFAULT_BROKER_FAIL_STARTUP_WITH_ERRORED_CHILD_SCOPE = DescendantType.IMMEDIATE;
+
@ManagedContextDefault(name = BROKER_MSG_AUTH)
boolean DEFAULT_BROKER_MSG_AUTH = false;
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/3bbf01a0/broker-core/src/main/java/org/apache/qpid/server/model/BrokerImpl.java
----------------------------------------------------------------------
diff --git a/broker-core/src/main/java/org/apache/qpid/server/model/BrokerImpl.java b/broker-core/src/main/java/org/apache/qpid/server/model/BrokerImpl.java
index ad11a7b..42a83c1 100644
--- a/broker-core/src/main/java/org/apache/qpid/server/model/BrokerImpl.java
+++ b/broker-core/src/main/java/org/apache/qpid/server/model/BrokerImpl.java
@@ -27,6 +27,7 @@ import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
+import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
@@ -270,6 +271,28 @@ public class BrokerImpl extends AbstractContainer<BrokerImpl> implements Broker<
{
throw new IllegalConfigurationException("Cannot change the model version");
}
+
+ if (changedAttributes.contains(CONTEXT))
+ {
+ @SuppressWarnings("unchecked")
+ Map<String, String> context = (Map<String, String>) proxyForValidation.getAttribute(CONTEXT);
+ if (context.containsKey(BROKER_FAIL_STARTUP_WITH_ERRORED_CHILD_SCOPE))
+ {
+ String value = context.get(BROKER_FAIL_STARTUP_WITH_ERRORED_CHILD_SCOPE);
+ try
+ {
+ DescendantType.valueOf(value);
+ }
+ catch (Exception e)
+ {
+ throw new IllegalConfigurationException(String.format(
+ "Unsupported value '%s' is specified for context variable '%s'. Please, change it to any of supported : %s",
+ value,
+ BROKER_FAIL_STARTUP_WITH_ERRORED_CHILD_SCOPE,
+ EnumSet.allOf(DescendantType.class)));
+ }
+ }
+ }
}
@Override
@@ -359,38 +382,32 @@ public class BrokerImpl extends AbstractContainer<BrokerImpl> implements Broker<
private void performActivation()
{
- boolean hasBrokerAnyErroredChildren = false;
+ final DescendantType descendantScope = getContextValue(DescendantType.class,
+ BROKER_FAIL_STARTUP_WITH_ERRORED_CHILD_SCOPE);
+ List<ConfiguredObject<?>> failedChildren = getChildrenInState(this, State.ERRORED, descendantScope);
- List<ConfiguredObject<?>> failedChildren = new ArrayList<>();
- for (final Class<? extends ConfiguredObject> childClass : getModel().getChildTypes(getCategoryClass()))
+ if (!failedChildren.isEmpty())
{
- final Collection<? extends ConfiguredObject> children = getChildren(childClass);
- if (children != null) {
- for (final ConfiguredObject<?> child : children)
- {
- if (child.getState() == State.ERRORED )
- {
- hasBrokerAnyErroredChildren = true;
- LOGGER.warn("Broker child object '{}' of type '{}' is {}",
- child.getName(), childClass.getSimpleName(), State.ERRORED);
- failedChildren.add(child);
- }
- }
+ for (ConfiguredObject<?> o : failedChildren)
+ {
+ LOGGER.warn("{} child object '{}' of type '{}' is {}",
+ o.getParent().getCategoryClass().getSimpleName(),
+ o.getName(),
+ o.getClass().getSimpleName(),
+ State.ERRORED);
}
- }
-
- if(!failedChildren.isEmpty())
- {
getEventLogger().message(BrokerMessages.FAILED_CHILDREN(failedChildren.toString()));
}
_documentationUrl = getContextValue(String.class, QPID_DOCUMENTATION_URL);
final boolean brokerShutdownOnErroredChild = getContextValue(Boolean.class,
BROKER_FAIL_STARTUP_WITH_ERRORED_CHILD);
- if (!_parent.isManagementMode() && brokerShutdownOnErroredChild && hasBrokerAnyErroredChildren)
+ if (!_parent.isManagementMode() && brokerShutdownOnErroredChild && !failedChildren.isEmpty())
{
- throw new IllegalStateException(String.format("Broker context variable %s is set and the broker has %s children",
- BROKER_FAIL_STARTUP_WITH_ERRORED_CHILD, State.ERRORED));
+ throw new IllegalStateException(String.format(
+ "Broker context variable %s is set and the broker has %s children",
+ BROKER_FAIL_STARTUP_WITH_ERRORED_CHILD,
+ State.ERRORED));
}
updateAccessControl();
@@ -419,6 +436,30 @@ public class BrokerImpl extends AbstractContainer<BrokerImpl> implements Broker<
setState(State.ACTIVE);
}
+ private List<ConfiguredObject<?>> getChildrenInState(final ConfiguredObject<?> configuredObject,
+ final State state,
+ final DescendantType descendantScope)
+ {
+ List<ConfiguredObject<?>> foundChildren = new ArrayList<>();
+ Class<? extends ConfiguredObject> categoryClass = configuredObject.getCategoryClass();
+ for (final Class<? extends ConfiguredObject> childClass : getModel().getChildTypes(categoryClass))
+ {
+ final Collection<? extends ConfiguredObject> children = configuredObject.getChildren(childClass);
+ for (final ConfiguredObject<?> child : children)
+ {
+ if (child.getState() == state)
+ {
+ foundChildren.add(child);
+ }
+ if (descendantScope == DescendantType.ALL)
+ {
+ foundChildren.addAll(getChildrenInState(child, state, descendantScope));
+ }
+ }
+ }
+ return foundChildren;
+ }
+
private void checkDirectMemoryUsage()
{
if (_compactMemoryThreshold >= 0
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/3bbf01a0/broker-core/src/main/java/org/apache/qpid/server/model/DescendantType.java
----------------------------------------------------------------------
diff --git a/broker-core/src/main/java/org/apache/qpid/server/model/DescendantType.java b/broker-core/src/main/java/org/apache/qpid/server/model/DescendantType.java
new file mode 100644
index 0000000..66d296a
--- /dev/null
+++ b/broker-core/src/main/java/org/apache/qpid/server/model/DescendantType.java
@@ -0,0 +1,26 @@
+package org.apache.qpid.server.model;/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+public enum DescendantType
+{
+ IMMEDIATE,
+ ALL
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[2/2] qpid-broker-j git commit: QPID-8110: Minor tidy-up
Posted by or...@apache.org.
QPID-8110: Minor tidy-up
(cherry picked from commit 51472013e85fc66ff99d59c80e402261f5775ac5)
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/f57f6deb
Tree: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/tree/f57f6deb
Diff: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/diff/f57f6deb
Branch: refs/heads/7.0.x
Commit: f57f6deb190066a76a6a3e6ed449b88471b07d0d
Parents: 3bbf01a
Author: Keith Wall <kw...@apache.org>
Authored: Fri Feb 23 18:14:49 2018 +0000
Committer: Alex Rudyy <or...@apache.org>
Committed: Mon Feb 26 16:39:01 2018 +0000
----------------------------------------------------------------------
.../org/apache/qpid/server/model/Broker.java | 2 +-
.../apache/qpid/server/model/BrokerImpl.java | 12 ++++-----
.../qpid/server/model/DescendantScope.java | 27 ++++++++++++++++++++
.../qpid/server/model/DescendantType.java | 26 -------------------
4 files changed, 34 insertions(+), 33 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/f57f6deb/broker-core/src/main/java/org/apache/qpid/server/model/Broker.java
----------------------------------------------------------------------
diff --git a/broker-core/src/main/java/org/apache/qpid/server/model/Broker.java b/broker-core/src/main/java/org/apache/qpid/server/model/Broker.java
index 3bb26d4..7978b1b 100644
--- a/broker-core/src/main/java/org/apache/qpid/server/model/Broker.java
+++ b/broker-core/src/main/java/org/apache/qpid/server/model/Broker.java
@@ -101,7 +101,7 @@ public interface Broker<X extends Broker<X>> extends ConfiguredObject<X>, EventL
boolean DEFAULT_BROKER_FAIL_STARTUP_WITH_ERRORED_CHILD = false;
@ManagedContextDefault(name = BROKER_FAIL_STARTUP_WITH_ERRORED_CHILD_SCOPE)
- DescendantType DEFAULT_BROKER_FAIL_STARTUP_WITH_ERRORED_CHILD_SCOPE = DescendantType.IMMEDIATE;
+ DescendantScope DEFAULT_BROKER_FAIL_STARTUP_WITH_ERRORED_CHILD_SCOPE = DescendantScope.IMMEDIATE;
@ManagedContextDefault(name = BROKER_MSG_AUTH)
boolean DEFAULT_BROKER_MSG_AUTH = false;
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/f57f6deb/broker-core/src/main/java/org/apache/qpid/server/model/BrokerImpl.java
----------------------------------------------------------------------
diff --git a/broker-core/src/main/java/org/apache/qpid/server/model/BrokerImpl.java b/broker-core/src/main/java/org/apache/qpid/server/model/BrokerImpl.java
index 42a83c1..9eac92f 100644
--- a/broker-core/src/main/java/org/apache/qpid/server/model/BrokerImpl.java
+++ b/broker-core/src/main/java/org/apache/qpid/server/model/BrokerImpl.java
@@ -281,7 +281,7 @@ public class BrokerImpl extends AbstractContainer<BrokerImpl> implements Broker<
String value = context.get(BROKER_FAIL_STARTUP_WITH_ERRORED_CHILD_SCOPE);
try
{
- DescendantType.valueOf(value);
+ DescendantScope.valueOf(value);
}
catch (Exception e)
{
@@ -289,7 +289,7 @@ public class BrokerImpl extends AbstractContainer<BrokerImpl> implements Broker<
"Unsupported value '%s' is specified for context variable '%s'. Please, change it to any of supported : %s",
value,
BROKER_FAIL_STARTUP_WITH_ERRORED_CHILD_SCOPE,
- EnumSet.allOf(DescendantType.class)));
+ EnumSet.allOf(DescendantScope.class)));
}
}
}
@@ -382,8 +382,8 @@ public class BrokerImpl extends AbstractContainer<BrokerImpl> implements Broker<
private void performActivation()
{
- final DescendantType descendantScope = getContextValue(DescendantType.class,
- BROKER_FAIL_STARTUP_WITH_ERRORED_CHILD_SCOPE);
+ final DescendantScope descendantScope = getContextValue(DescendantScope.class,
+ BROKER_FAIL_STARTUP_WITH_ERRORED_CHILD_SCOPE);
List<ConfiguredObject<?>> failedChildren = getChildrenInState(this, State.ERRORED, descendantScope);
if (!failedChildren.isEmpty())
@@ -438,7 +438,7 @@ public class BrokerImpl extends AbstractContainer<BrokerImpl> implements Broker<
private List<ConfiguredObject<?>> getChildrenInState(final ConfiguredObject<?> configuredObject,
final State state,
- final DescendantType descendantScope)
+ final DescendantScope descendantScope)
{
List<ConfiguredObject<?>> foundChildren = new ArrayList<>();
Class<? extends ConfiguredObject> categoryClass = configuredObject.getCategoryClass();
@@ -451,7 +451,7 @@ public class BrokerImpl extends AbstractContainer<BrokerImpl> implements Broker<
{
foundChildren.add(child);
}
- if (descendantScope == DescendantType.ALL)
+ if (descendantScope == DescendantScope.ALL)
{
foundChildren.addAll(getChildrenInState(child, state, descendantScope));
}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/f57f6deb/broker-core/src/main/java/org/apache/qpid/server/model/DescendantScope.java
----------------------------------------------------------------------
diff --git a/broker-core/src/main/java/org/apache/qpid/server/model/DescendantScope.java b/broker-core/src/main/java/org/apache/qpid/server/model/DescendantScope.java
new file mode 100644
index 0000000..d749ea2
--- /dev/null
+++ b/broker-core/src/main/java/org/apache/qpid/server/model/DescendantScope.java
@@ -0,0 +1,27 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.server.model;
+
+public enum DescendantScope
+{
+ IMMEDIATE,
+ ALL
+}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/f57f6deb/broker-core/src/main/java/org/apache/qpid/server/model/DescendantType.java
----------------------------------------------------------------------
diff --git a/broker-core/src/main/java/org/apache/qpid/server/model/DescendantType.java b/broker-core/src/main/java/org/apache/qpid/server/model/DescendantType.java
deleted file mode 100644
index 66d296a..0000000
--- a/broker-core/src/main/java/org/apache/qpid/server/model/DescendantType.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package org.apache.qpid.server.model;/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-public enum DescendantType
-{
- IMMEDIATE,
- ALL
-}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org