You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ss...@apache.org on 2024/12/12 14:48:20 UTC

(sling-org-apache-sling-discovery-api) branch feature/SLING-12558-parent-62 created (now e6aac7a)

This is an automated email from the ASF dual-hosted git repository.

sseifert pushed a change to branch feature/SLING-12558-parent-62
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-discovery-api.git


      at e6aac7a  SLING-12558 apply spotless formatting

This branch includes the following new commits:

     new f2c8f8c  SLING-12558 Update to parent 62
     new e6aac7a  SLING-12558 apply spotless formatting

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(sling-org-apache-sling-discovery-api) 02/02: SLING-12558 apply spotless formatting

Posted by ss...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

sseifert pushed a commit to branch feature/SLING-12558-parent-62
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-discovery-api.git

commit e6aac7ae5bf24de9e146ea1da757dcf273c7ac52
Author: Stefan Seifert <st...@users.noreply.github.com>
AuthorDate: Thu Dec 12 15:48:10 2024 +0100

    SLING-12558 apply spotless formatting
---
 pom.xml                                            | 16 +++---
 .../org/apache/sling/discovery/ClusterView.java    |  1 -
 .../apache/sling/discovery/DiscoveryService.java   | 37 ++++++------
 .../sling/discovery/InstanceDescription.java       | 56 +++++++++----------
 .../org/apache/sling/discovery/InstanceFilter.java | 19 +++----
 .../apache/sling/discovery/PropertyProvider.java   | 24 ++++----
 .../org/apache/sling/discovery/TopologyEvent.java  | 23 ++++----
 .../sling/discovery/TopologyEventListener.java     | 65 +++++++++++-----------
 .../org/apache/sling/discovery/package-info.java   |  2 -
 9 files changed, 116 insertions(+), 127 deletions(-)

diff --git a/pom.xml b/pom.xml
index a3111c9..ec1f06b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
+<?xml version="1.0" encoding="UTF-8"?>
 <!--
   Licensed to the Apache Software Foundation (ASF) under one
   or more contributor license agreements.  See the NOTICE file
@@ -30,14 +30,7 @@
     <version>1.0.5-SNAPSHOT</version>
 
     <name>Apache Sling Discovery API</name>
-    <description>
-        Support for topology discovery of instances.
-    </description>
-
-    <properties>
-        <project.build.outputTimestamp>1</project.build.outputTimestamp>
-        <sling.java.version>8</sling.java.version>
-    </properties>
+    <description>Support for topology discovery of instances.</description>
 
     <scm>
         <connection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-discovery-api.git</connection>
@@ -45,6 +38,11 @@
         <url>https://github.com/apache/sling-org-apache-sling-discovery-api.git</url>
     </scm>
 
+    <properties>
+        <project.build.outputTimestamp>1</project.build.outputTimestamp>
+        <sling.java.version>8</sling.java.version>
+    </properties>
+
     <dependencies>
         <dependency>
             <groupId>org.osgi</groupId>
diff --git a/src/main/java/org/apache/sling/discovery/ClusterView.java b/src/main/java/org/apache/sling/discovery/ClusterView.java
index 3fe4f57..cf9d089 100644
--- a/src/main/java/org/apache/sling/discovery/ClusterView.java
+++ b/src/main/java/org/apache/sling/discovery/ClusterView.java
@@ -22,7 +22,6 @@ import java.util.List;
 
 import org.osgi.annotation.versioning.ProviderType;
 
-
 /**
  * A ClusterView represents the instances of a cluster that are
  * up and running and that all can see each other at a certain point in time.
diff --git a/src/main/java/org/apache/sling/discovery/DiscoveryService.java b/src/main/java/org/apache/sling/discovery/DiscoveryService.java
index 9983ae4..410e5a1 100644
--- a/src/main/java/org/apache/sling/discovery/DiscoveryService.java
+++ b/src/main/java/org/apache/sling/discovery/DiscoveryService.java
@@ -30,24 +30,23 @@ import org.osgi.annotation.versioning.ProviderType;
 @ProviderType
 public interface DiscoveryService {
 
-	/**
-	 * Returns the topology that was last discovered by this service.
-	 * <p>
-	 * If for some reason the service is currently not able to do topology discovery
-	 * it will return the last valid topology marked with <code>false</code> in the call
-	 * to <code>TopologyView.isCurrent()</code>. This is also true if the service
-	 * has noticed a potential change in the topology and is in the process of
-	 * settling the change in the topology (eg with peers, ie voting).
-	 * <p>
-	 * Note that this call is synchronized with <code>TopologyEventListener.handleTopologyEvent()</code>
-	 * calls: ie if calls to <code>TopologyEventListener.handleTopologyEvent()</code> are currently
-	 * ongoing, then the call to this method will block until all <code>TopologyEventListener</code>s
-	 * have been called. Be careful not to cause deadlock situations.
-	 * <p>
-	 * @return the topology that was last discovered by this service. This will never
-	 * be null (ie even if a change in the topology is ongoing at the moment or the
-	 * cluster consists only of the local instance).
-	 */
+    /**
+     * Returns the topology that was last discovered by this service.
+     * <p>
+     * If for some reason the service is currently not able to do topology discovery
+     * it will return the last valid topology marked with <code>false</code> in the call
+     * to <code>TopologyView.isCurrent()</code>. This is also true if the service
+     * has noticed a potential change in the topology and is in the process of
+     * settling the change in the topology (eg with peers, ie voting).
+     * <p>
+     * Note that this call is synchronized with <code>TopologyEventListener.handleTopologyEvent()</code>
+     * calls: ie if calls to <code>TopologyEventListener.handleTopologyEvent()</code> are currently
+     * ongoing, then the call to this method will block until all <code>TopologyEventListener</code>s
+     * have been called. Be careful not to cause deadlock situations.
+     * <p>
+     * @return the topology that was last discovered by this service. This will never
+     * be null (ie even if a change in the topology is ongoing at the moment or the
+     * cluster consists only of the local instance).
+     */
     TopologyView getTopology();
-
 }
diff --git a/src/main/java/org/apache/sling/discovery/InstanceDescription.java b/src/main/java/org/apache/sling/discovery/InstanceDescription.java
index 3cf3997..809b85f 100644
--- a/src/main/java/org/apache/sling/discovery/InstanceDescription.java
+++ b/src/main/java/org/apache/sling/discovery/InstanceDescription.java
@@ -55,44 +55,44 @@ public interface InstanceDescription {
     String PROPERTY_ENDPOINTS = "org.apache.sling.instance.endpoints";
 
     /**
-	 * Returns the ClusterView of which this instance is part of.
-	 *
-	 * Every instance is part of a ClusterView even if it is standalone.
-	 * @return the ClusterView
-	 */
+     * Returns the ClusterView of which this instance is part of.
+     *
+     * Every instance is part of a ClusterView even if it is standalone.
+     * @return the ClusterView
+     */
     ClusterView getClusterView();
 
-	/**
-	 * If an instance is part of a cluster, it can potentially be a leader of that cluster -
-	 * this information is queried here.
-	 *
-	 * If an instance is not part of a cluster, this method returns true.
-	 *
-	 * Only one instance of a cluster is guaranteed to be the leader at any time.
-	 * This guarantee is provided by this service.
-	 * If the leader goes down, the service elects a new leader and announces it to
-	 * TopologyEventListener listeners.
-	 * @return true if this instance is the - only -  leader in this cluster,
-	 * false if it is one of the slaves, or true if it is not at all part of a cluster
-	 */
-	boolean isLeader();
+    /**
+     * If an instance is part of a cluster, it can potentially be a leader of that cluster -
+     * this information is queried here.
+     *
+     * If an instance is not part of a cluster, this method returns true.
+     *
+     * Only one instance of a cluster is guaranteed to be the leader at any time.
+     * This guarantee is provided by this service.
+     * If the leader goes down, the service elects a new leader and announces it to
+     * TopologyEventListener listeners.
+     * @return true if this instance is the - only -  leader in this cluster,
+     * false if it is one of the slaves, or true if it is not at all part of a cluster
+     */
+    boolean isLeader();
 
-	/**
-	 * Determines whether this InstanceDescription is representing the local instance.
-	 * @return whether this InstanceDescription is representing the local instance.
-	 */
-	boolean isLocal();
+    /**
+     * Determines whether this InstanceDescription is representing the local instance.
+     * @return whether this InstanceDescription is representing the local instance.
+     */
+    boolean isLocal();
 
     /**
      * The identifier of the running Sling instance.
-	 *
-	 * @return the identifier of this instance
+     *
+     * @return the identifier of this instance
      */
     String getSlingId();
 
     /**
      * Returns the value of a particular property.
-	 *
+     *
      * Note that there are no hard guarantees or requirements as to how quickly
      * a property is available once it is set on a distant instance.
      * @param name The property name
@@ -106,5 +106,5 @@ public interface InstanceDescription {
      * is not modifiable.
      * @return a Map containing all properties of this instance
      */
-    Map<String,String> getProperties();
+    Map<String, String> getProperties();
 }
diff --git a/src/main/java/org/apache/sling/discovery/InstanceFilter.java b/src/main/java/org/apache/sling/discovery/InstanceFilter.java
index f74693c..3013dfe 100644
--- a/src/main/java/org/apache/sling/discovery/InstanceFilter.java
+++ b/src/main/java/org/apache/sling/discovery/InstanceFilter.java
@@ -22,19 +22,18 @@ import org.osgi.annotation.versioning.ConsumerType;
 
 /**
  * Used to filter InstanceDescriptions in a TopologyView.
- * 
+ *
  * @see TopologyView#findInstances(InstanceFilter)
  */
 @ConsumerType
 public interface InstanceFilter {
 
-	/**
-	 * Returns true if this InstanceFilter selects the given InstanceDescription.
-	 *
-	 * @param instance the InstanceDescription for which to decide if this
-	 * InstanceFilter accepts it or not.
-	 * @return true if this InstanceFilter selects the given InstanceDescription
-	 */
-	boolean accept(InstanceDescription instance);
-
+    /**
+     * Returns true if this InstanceFilter selects the given InstanceDescription.
+     *
+     * @param instance the InstanceDescription for which to decide if this
+     * InstanceFilter accepts it or not.
+     * @return true if this InstanceFilter selects the given InstanceDescription
+     */
+    boolean accept(InstanceDescription instance);
 }
diff --git a/src/main/java/org/apache/sling/discovery/PropertyProvider.java b/src/main/java/org/apache/sling/discovery/PropertyProvider.java
index e0c3fe9..8ef98e9 100644
--- a/src/main/java/org/apache/sling/discovery/PropertyProvider.java
+++ b/src/main/java/org/apache/sling/discovery/PropertyProvider.java
@@ -43,16 +43,16 @@ public interface PropertyProvider {
      */
     String PROPERTY_PROPERTIES = "instance.properties";
 
-	/**
-	 * Retrieves a property that is subsequently set on the local instance
-	 * and broadcast to the <code>TopologyView</code> instances.
-	 *
-	 * These properties are non-persistent and disappear after the local instance goes down.
-	 *
-	 * @param name The property name
-	 * @return The value of the property or <code>null</code>. If the property
-	 *         value can't be provided or if the provider does not support this
-	 *         property, it must return <code>null</code>.
-	 */
-	String getProperty(final String name);
+    /**
+     * Retrieves a property that is subsequently set on the local instance
+     * and broadcast to the <code>TopologyView</code> instances.
+     *
+     * These properties are non-persistent and disappear after the local instance goes down.
+     *
+     * @param name The property name
+     * @return The value of the property or <code>null</code>. If the property
+     *         value can't be provided or if the provider does not support this
+     *         property, it must return <code>null</code>.
+     */
+    String getProperty(final String name);
 }
diff --git a/src/main/java/org/apache/sling/discovery/TopologyEvent.java b/src/main/java/org/apache/sling/discovery/TopologyEvent.java
index 20180e0..19af393 100644
--- a/src/main/java/org/apache/sling/discovery/TopologyEvent.java
+++ b/src/main/java/org/apache/sling/discovery/TopologyEvent.java
@@ -20,17 +20,17 @@ 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.
- * 
+ *
  * @see TopologyEventListener
  */
 public class TopologyEvent {
 
     public static enum Type {
         /**
-         * Informs the service about the initial topology state - this is only 
+         * Informs the service about the initial topology state - this is only
          * sent once at bind-time and is the first one a TopologyEventListener
          * receives (after the implementation bundle was activated).
          */
@@ -44,7 +44,7 @@ public class TopologyEvent {
          * <p>
          * After receiving a TOPOLOGY_CHANGING and before receiving a
          * TOPOLOGY_CHANGED event a TopologyEventListener cannot make any
-         * assumptions wrt the topology whatsoever, including whether or not 
+         * assumptions wrt the topology whatsoever, including whether or not
          * the local instance is part of it at all (partitioning).
          * <p>
          * An implementation must always send a TOPOLOGY_CHANGING before a
@@ -61,7 +61,7 @@ public class TopologyEvent {
          * <li>A restart of an instance - or more precisely: when the
          * corresponding implementation bundle is deactivated/activated</li>
          * <li>A cluster structure - either its members or the cluster
-         * view id - changed. The cluster view id changes when an instance joins, 
+         * view id - changed. The cluster view id changes when an instance joins,
          * leaves or was restarted (its bundle deactivated/activated)</li>
          * </ul>
          * <p>
@@ -77,15 +77,13 @@ public class TopologyEvent {
          * This event is sent when otherwise the topology remains identical.
          */
         PROPERTIES_CHANGED
-
     }
 
     private final Type type;
     private final TopologyView oldView;
     private final TopologyView newView;
 
-    public TopologyEvent(final Type type, final TopologyView oldView,
-            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");
         }
@@ -124,7 +122,7 @@ public class TopologyEvent {
 
     /**
      * Returns the type of this event
-     * 
+     *
      * @return the type of this event
      */
     public Type getType() {
@@ -135,7 +133,7 @@ public class TopologyEvent {
      * 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
      */
@@ -147,7 +145,7 @@ public class TopologyEvent {
      * 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>
      */
@@ -157,7 +155,6 @@ public class TopologyEvent {
 
     @Override
     public String toString() {
-        return "TopologyEvent [type=" + type + ", oldView=" + oldView
-                + ", newView=" + newView + "]";
+        return "TopologyEvent [type=" + type + ", oldView=" + oldView + ", newView=" + newView + "]";
     }
 }
diff --git a/src/main/java/org/apache/sling/discovery/TopologyEventListener.java b/src/main/java/org/apache/sling/discovery/TopologyEventListener.java
index 0188f5b..4191393 100644
--- a/src/main/java/org/apache/sling/discovery/TopologyEventListener.java
+++ b/src/main/java/org/apache/sling/discovery/TopologyEventListener.java
@@ -30,37 +30,36 @@ import org.osgi.annotation.versioning.ConsumerType;
 @ConsumerType
 public interface TopologyEventListener {
 
-	/**
-	 * Inform the service about an event in the topology - or in the discovery
-	 * of the topology.
-	 * <p>
-	 * Implementors of this method must ensure that this method returns quickly
-	 * and that no locks are being acquired that could cause deadlocks (ie the
-	 * framework might call this method holding locks).
-	 * <p>
-	 * The <code>TopologyEvent</code> contains details about what changed.
-	 * The supported event types are:
-	 * <ul>
-	 *  <li><code>TOPOLOGY_INIT</code> sent when the <code>TopologyEventListener</code>
-	 *  was first bound to the discovery service - represents the initial state
-	 *  of the topology at that time.</li>
-	 *  <li><code>TOPOLOGY_CHANGING</code> sent when the discovery service
-	 *  discovered a change in the topology and has started to settle the change.
-	 *  This event is sent before <code>TOPOLOGY_CHANGED</code> but is optional</li>
-	 *  <li><code>TOPOLOGY_CHANGED</code> sent when the discovery service
-	 *  discovered a change in the topology and has settled it.</li>
-	 *  <li><code>PROPERTIES_CHANGED</code> sent when the one or many properties
-	 *  have changed in an instance in the current topology</li>
-	 * </ul>
-	 * A note on instance restarts: it is currently not a requirement on the
-	 * discovery service to send a TopologyEvent should an instance restart
-	 * occur rapidly (ie within the change detection timeout). A TopologyEvent
-	 * is only sent if the number of instances or any property changes.
-	 * Should there be a requirement to detect a restart in a guaranteed fashion,
-	 * it is always possible to set a particular property (using the PropertyProvider)
-	 * to the instance start time and have others detect a change in that property.
-	 * @param event The topology event
-	 */
-	void handleTopologyEvent(TopologyEvent event);
-
+    /**
+     * Inform the service about an event in the topology - or in the discovery
+     * of the topology.
+     * <p>
+     * Implementors of this method must ensure that this method returns quickly
+     * and that no locks are being acquired that could cause deadlocks (ie the
+     * framework might call this method holding locks).
+     * <p>
+     * The <code>TopologyEvent</code> contains details about what changed.
+     * The supported event types are:
+     * <ul>
+     *  <li><code>TOPOLOGY_INIT</code> sent when the <code>TopologyEventListener</code>
+     *  was first bound to the discovery service - represents the initial state
+     *  of the topology at that time.</li>
+     *  <li><code>TOPOLOGY_CHANGING</code> sent when the discovery service
+     *  discovered a change in the topology and has started to settle the change.
+     *  This event is sent before <code>TOPOLOGY_CHANGED</code> but is optional</li>
+     *  <li><code>TOPOLOGY_CHANGED</code> sent when the discovery service
+     *  discovered a change in the topology and has settled it.</li>
+     *  <li><code>PROPERTIES_CHANGED</code> sent when the one or many properties
+     *  have changed in an instance in the current topology</li>
+     * </ul>
+     * A note on instance restarts: it is currently not a requirement on the
+     * discovery service to send a TopologyEvent should an instance restart
+     * occur rapidly (ie within the change detection timeout). A TopologyEvent
+     * is only sent if the number of instances or any property changes.
+     * Should there be a requirement to detect a restart in a guaranteed fashion,
+     * it is always possible to set a particular property (using the PropertyProvider)
+     * to the instance start time and have others detect a change in that property.
+     * @param event The topology event
+     */
+    void handleTopologyEvent(TopologyEvent event);
 }
diff --git a/src/main/java/org/apache/sling/discovery/package-info.java b/src/main/java/org/apache/sling/discovery/package-info.java
index 8b2bfda..009c3d2 100644
--- a/src/main/java/org/apache/sling/discovery/package-info.java
+++ b/src/main/java/org/apache/sling/discovery/package-info.java
@@ -25,5 +25,3 @@
  */
 @org.osgi.annotation.versioning.Version("1.0.3")
 package org.apache.sling.discovery;
-
-


(sling-org-apache-sling-discovery-api) 01/02: SLING-12558 Update to parent 62

Posted by ss...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

sseifert pushed a commit to branch feature/SLING-12558-parent-62
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-discovery-api.git

commit f2c8f8c348a8516ccd96cad386787fae2acc8655
Author: Stefan Seifert <st...@users.noreply.github.com>
AuthorDate: Thu Dec 12 15:47:46 2024 +0100

    SLING-12558 Update to parent 62
---
 .sling-module.json | 5 +++++
 pom.xml            | 3 ++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/.sling-module.json b/.sling-module.json
new file mode 100644
index 0000000..cfad4d2
--- /dev/null
+++ b/.sling-module.json
@@ -0,0 +1,5 @@
+{
+  "jenkins": {
+    "jdks": [17, 21]
+  }
+}
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index e301a1e..a3111c9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
     <parent>
         <groupId>org.apache.sling</groupId>
         <artifactId>sling-bundle-parent</artifactId>
-        <version>48</version>
+        <version>62</version>
     </parent>
 
     <artifactId>org.apache.sling.discovery.api</artifactId>
@@ -49,6 +49,7 @@
         <dependency>
             <groupId>org.osgi</groupId>
             <artifactId>org.osgi.annotation.versioning</artifactId>
+            <scope>provided</scope>
         </dependency>
     </dependencies>
 </project>