You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/11/07 09:25:29 UTC
[sling-org-apache-sling-discovery-api] 11/29: SLING-2827 : javadoc
of Type clarified - plus a source code reformat
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.discovery.api-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-discovery-api.git
commit 57d974d5635cbd70e97681083064b65abffbf09a
Author: Stefan Egli <st...@apache.org>
AuthorDate: Tue Apr 23 09:37:15 2013 +0000
SLING-2827 : javadoc of Type clarified - plus a source code reformat
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/discovery/api@1470861 13f79535-47bb-0310-9956-ffa450edef68
---
.../org/apache/sling/discovery/TopologyEvent.java | 194 +++++++++++++--------
1 file changed, 119 insertions(+), 75 deletions(-)
diff --git a/src/main/java/org/apache/sling/discovery/TopologyEvent.java b/src/main/java/org/apache/sling/discovery/TopologyEvent.java
index fb9bcdd..6b515bd 100644
--- a/src/main/java/org/apache/sling/discovery/TopologyEvent.java
+++ b/src/main/java/org/apache/sling/discovery/TopologyEvent.java
@@ -20,92 +20,136 @@ package org.apache.sling.discovery;
/**
* A topology event is sent whenever a change in the topology occurs.
- *
- * This event object might be extended in the future with new event types
- * and methods.
+ *
+ * This event object might be extended in the future with new event types and
+ * methods.
+ *
* @see TopologyEventListener
*/
public class TopologyEvent {
- public static enum Type {
- TOPOLOGY_INIT, // Inform the service about the initial topology state
- TOPOLOGY_CHANGING, // Inform the service about the fact that a state change was detected
- // in the cluster topology and that a voting amongst the members about
- // a new, valid view has just started.
- // Note that implementations might not support this event at all.
- TOPOLOGY_CHANGED, // Inform the service about a state change in the cluster topology.
- PROPERTIES_CHANGED // one or many properties have been changed on an instance which is part
- // of the topology
+ public static enum Type {
+ /**
+ * Inform the service about the initial topology state and is only sent
+ * once at bind-time.
+ * <p>
+ * This event type will be the first one a TopologyEventListener
+ * receives.
+ */
+ TOPOLOGY_INIT,
+
+ /**
+ * Inform the service about the fact that a state change was detected in
+ * the topology/cluster and that a voting amongst the members about a
+ * new, valid topology/cluster view has just started.
+ * <p>
+ * An implementation must always send a TOPOLOGY_CHANGING before a
+ * TOPOLOGY_CHANGED.
+ */
+ TOPOLOGY_CHANGING,
+
+ /**
+ * Inform the service about a state change in the topology.
+ * <p>
+ * A state change includes:
+ * <ul>
+ * <li>A joining or leaving instance</li>
+ * <li>A restart of an instance - or more precisely: when the
+ * corresponding implementation bundle is deactivated/activated</li>
+ * <li>A cluster structure changed: either its members or the cluster
+ * view id. The cluster view id changes when an instance joins, leaves
+ * or was restarted (the bundle deactivated/activated)</li>
+ * </ul>
+ * <p>
+ * Note that tha TOPOLOGY_CHANGED can also include changes in the
+ * properties!
+ */
+ TOPOLOGY_CHANGED,
+
+ /**
+ * One or many properties have been changed on an instance which is part
+ * of the topology.
+ * <p>
+ * This event is sent when otherwise the topology remains identical.
+ */
+ PROPERTIES_CHANGED
+
}
- private final Type type;
- private final TopologyView oldView;
- private final TopologyView newView;
+ private final Type type;
+ private final TopologyView oldView;
+ private final TopologyView newView;
- public TopologyEvent(final Type type, final TopologyView oldView, final TopologyView newView) {
- if (type==null) {
- throw new IllegalArgumentException("type must not be null");
- }
+ public TopologyEvent(final Type type, final TopologyView oldView,
+ final TopologyView newView) {
+ if (type == null) {
+ throw new IllegalArgumentException("type must not be null");
+ }
- if (type==Type.TOPOLOGY_INIT) {
- // then oldView is null
- if (oldView!=null) {
- throw new IllegalArgumentException("oldView must be null");
- }
- // and newView must be not null
- if (newView==null) {
- throw new IllegalArgumentException("newView must not be null");
- }
- } else if (type==Type.TOPOLOGY_CHANGING) {
- // then newView is null
- if (newView!=null) {
- throw new IllegalArgumentException("newView must be null");
- }
- // and oldView must not be null
- if (oldView==null) {
- throw new IllegalArgumentException("oldView must not be null");
- }
- } else {
- // in all other cases both oldView and newView must not be null
- if (oldView==null) {
- throw new IllegalArgumentException("oldView must not be null");
- }
- if (newView==null) {
- throw new IllegalArgumentException("newView must not be null");
- }
- }
- this.type = type;
- this.oldView = oldView;
- this.newView = newView;
- }
+ if (type == Type.TOPOLOGY_INIT) {
+ // then oldView is null
+ if (oldView != null) {
+ throw new IllegalArgumentException("oldView must be null");
+ }
+ // and newView must be not null
+ if (newView == null) {
+ throw new IllegalArgumentException("newView must not be null");
+ }
+ } else if (type == Type.TOPOLOGY_CHANGING) {
+ // then newView is null
+ if (newView != null) {
+ throw new IllegalArgumentException("newView must be null");
+ }
+ // and oldView must not be null
+ if (oldView == null) {
+ throw new IllegalArgumentException("oldView must not be null");
+ }
+ } else {
+ // in all other cases both oldView and newView must not be null
+ if (oldView == null) {
+ throw new IllegalArgumentException("oldView must not be null");
+ }
+ if (newView == null) {
+ throw new IllegalArgumentException("newView must not be null");
+ }
+ }
+ this.type = type;
+ this.oldView = oldView;
+ this.newView = newView;
+ }
- /**
- * Returns the type of this event
- * @return the type of this event
- */
- public Type getType() {
- return type;
- }
+ /**
+ * Returns the type of this event
+ *
+ * @return the type of this event
+ */
+ public Type getType() {
+ return type;
+ }
- /**
- * Returns the view which was valid up until now.
- * <p>
- * This is null in case of <code>TOPOLOGY_INIT</code>
- * @return the view which was valid up until now, or null in case of a fresh instance start
- */
- public TopologyView getOldView() {
- return oldView;
- }
+ /**
+ * Returns the view which was valid up until now.
+ * <p>
+ * This is null in case of <code>TOPOLOGY_INIT</code>
+ *
+ * @return the view which was valid up until now, or null in case of a fresh
+ * instance start
+ */
+ public TopologyView getOldView() {
+ return oldView;
+ }
- /**
- * Returns the view which is currently (i.e. newly) valid.
- * <p>
- * This is null in case of <code>TOPOLOGY_CHANGING</code>
- * @return the view which is currently valid, or null in case of <code>TOPOLOGY_CHANGING</code>
- */
- public TopologyView getNewView() {
- return newView;
- }
+ /**
+ * Returns the view which is currently (i.e. newly) valid.
+ * <p>
+ * This is null in case of <code>TOPOLOGY_CHANGING</code>
+ *
+ * @return the view which is currently valid, or null in case of
+ * <code>TOPOLOGY_CHANGING</code>
+ */
+ public TopologyView getNewView() {
+ return newView;
+ }
@Override
public String toString() {
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.