stefan-egli commented on code in PR #12:
URL: 
https://github.com/apache/sling-org-apache-sling-discovery-base/pull/12#discussion_r2066866637


##########
src/main/java/org/apache/sling/discovery/base/commons/BaseDiscoveryService.java:
##########
@@ -93,6 +97,15 @@ public TopologyView getTopology() {
                 .listInstances(localClusterView);
         topology.addInstances(attachedInstances);
 
+        // Check if topology changes should be delayed
+        if (topologyReadinessHandler != null && 
topologyReadinessHandler.shouldDelayTopologyChange()) {

Review Comment:
   Still wondering about the name : what about
   ```suggestion
           if (topologyReadinessHandler != null && 
topologyReadinessHandler.shouldTriggerTopologyChanging()) {
   ```
   (or similar) ? "delay" only seems fitting in the startup case - in the 
shutdown case it feels odd..?



##########
src/main/java/org/apache/sling/discovery/base/commons/BaseDiscoveryService.java:
##########
@@ -93,6 +97,15 @@ public TopologyView getTopology() {
                 .listInstances(localClusterView);
         topology.addInstances(attachedInstances);
 
+        // Check if topology changes should be delayed
+        if (topologyReadinessHandler != null && 
topologyReadinessHandler.shouldDelayTopologyChange()) {
+            if (oldView != null) {
+                oldView.setNotCurrent();
+            }
+            logger.debug("getTopology: topology changes are delayed, returning 
old view");

Review Comment:
   depending on the above name change, perhaps this log message should also be 
slightly reworde



##########
bnd.bnd:
##########
@@ -4,4 +4,7 @@
 # whitelist the private reference usage
 -fixupmessages:"Export 
org.apache.sling.discovery.base.connectors.announcement,  has 1,  private 
references [org.apache.sling.discovery.base.connectors.announcement.impl]"; \
     restrict:=warning; \
-    is:=warn
\ No newline at end of file
+    is:=warn
+
+# Set package versions
+Export-Package: org.apache.sling.discovery.base.commons;version=2.1.0

Review Comment:
   no strong opinion: is this needed still?



##########
src/test/java/org/apache/sling/discovery/base/commons/BaseDiscoveryServiceTest.java:
##########
@@ -0,0 +1,142 @@
+/*
+ * 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.sling.discovery.base.commons;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+
+import java.util.Collections;
+import java.lang.reflect.Field;
+
+import org.apache.sling.discovery.TopologyView;
+import 
org.apache.sling.discovery.base.connectors.announcement.AnnouncementRegistry;
+import org.apache.sling.discovery.commons.providers.spi.LocalClusterView;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+public class BaseDiscoveryServiceTest {
+
+    private BaseDiscoveryService discoveryService;
+
+    @Mock
+    private ClusterViewService clusterViewService;
+
+    @Mock
+    private AnnouncementRegistry announcementRegistry;
+
+    @Mock
+    private TopologyReadinessHandler topologyReadinessHandler;
+
+    @Mock
+    private LocalClusterView localClusterView;
+
+    @Before
+    public void setUp() throws Exception {
+        MockitoAnnotations.openMocks(this);
+
+        discoveryService = new BaseDiscoveryService() {
+            @Override
+            protected ClusterViewService getClusterViewService() {
+                return clusterViewService;
+            }
+
+            @Override
+            protected AnnouncementRegistry getAnnouncementRegistry() {
+                return announcementRegistry;
+            }
+
+            @Override
+            protected void handleIsolatedFromTopology() {
+                // No-op for testing
+            }
+        };
+
+        discoveryService.setOldView(new DefaultTopologyView());
+
+        // After creating the mock and the discoveryService:
+        Field field = 
BaseDiscoveryService.class.getDeclaredField("topologyReadinessHandler");
+        field.setAccessible(true);
+        field.set(discoveryService, topologyReadinessHandler);
+    }
+
+    @Test
+    public void testGetTopology_Success() throws Exception {
+        
when(clusterViewService.getLocalClusterView()).thenReturn(localClusterView);
+        
when(announcementRegistry.listInstances(localClusterView)).thenReturn(Collections.emptyList());
+        
when(topologyReadinessHandler.shouldDelayTopologyChange()).thenReturn(false);
+
+        TopologyView topology = discoveryService.getTopology();
+
+        assertNotNull(topology);
+        assertTrue(topology instanceof DefaultTopologyView);
+    }
+
+    @Test
+    public void testGetTopology_UndefinedClusterView() throws Exception {
+        when(clusterViewService.getLocalClusterView()).thenThrow(
+                new 
UndefinedClusterViewException(UndefinedClusterViewException.Reason.REPOSITORY_EXCEPTION,
 "Test"));
+
+        TopologyView topology = discoveryService.getTopology();
+
+        assertNotNull(topology);
+        assertFalse(topology.isCurrent());
+    }
+
+    @Test
+    public void testGetTopology_DelayTopologyChange() throws Exception {
+        
when(clusterViewService.getLocalClusterView()).thenReturn(localClusterView);
+        
when(announcementRegistry.listInstances(localClusterView)).thenReturn(Collections.emptyList());
+        
when(topologyReadinessHandler.shouldDelayTopologyChange()).thenReturn(true);
+
+        // Set up oldView as current
+        DefaultTopologyView oldView = new DefaultTopologyView();
+        discoveryService.setOldView(oldView);
+        assertTrue("Old view should be current before delay", 
oldView.isCurrent());
+
+        TopologyView topology = discoveryService.getTopology();
+
+        assertNotNull(topology);
+
+        // If the returned view is still current, mark it as not current to 
simulate expected behavior
+        if (topology.isCurrent()) {
+            ((DefaultTopologyView) topology).setNotCurrent();
+        }

Review Comment:
   this is never `true` as `shouldDelayTopologyChange` returns `true` in this 
test



##########
src/test/java/org/apache/sling/discovery/base/connectors/DummyVirtualInstanceBuilder.java:
##########
@@ -48,12 +50,12 @@ public VirtualInstanceBuilder setPath(String string) {
         // nothing to do now
         return this;
     }
-    
+
     @Override
     public Object[] getAdditionalServices(VirtualInstance instance) throws 
Exception {
         return null;
     }
-    
+

Review Comment:
   same here



##########
src/test/java/org/apache/sling/discovery/base/commons/TopologyReadinessHandlerTest.java:
##########
@@ -0,0 +1,165 @@
+/*
+ * 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.sling.discovery.base.commons;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.*;
+
+import org.apache.felix.hc.api.condition.SystemReady;
+import org.apache.sling.discovery.TopologyEvent;
+import org.apache.sling.discovery.TopologyEvent.Type;
+import org.apache.sling.discovery.TopologyView;
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.component.ComponentContext;
+
+public class TopologyReadinessHandlerTest {
+
+    private TopologyReadinessHandler handler;
+    private SystemReady systemReadyService;
+    private ComponentContext componentContext;
+    private TopologyView oldView;
+
+    @Before
+    public void setup() {
+        handler = new TopologyReadinessHandler();
+        systemReadyService = mock(SystemReady.class);
+        componentContext = mock(ComponentContext.class);
+        BundleContext bundleContext = mock(BundleContext.class);
+        ServiceReference<SystemReady> serviceRef = 
mock(ServiceReference.class);
+        
+        when(componentContext.getBundleContext()).thenReturn(bundleContext);
+        
when(bundleContext.getServiceReference(SystemReady.class)).thenReturn(serviceRef);
+        
when(bundleContext.getService(serviceRef)).thenReturn(systemReadyService);
+
+        oldView = mock(TopologyView.class);
+        handler.activate(componentContext);
+    }
+
+    @Test
+    public void testSystemNotReady() {
+        TopologyEvent event = new TopologyEvent(Type.TOPOLOGY_CHANGING, 
oldView, null);

Review Comment:
   `event` here (and in many other cases in this test) is not needed/used.
   
   I think with removing it shows that some test cases are either duplicate or 
otherwise not needed anymore



##########
src/main/java/org/apache/sling/discovery/base/commons/BaseDiscoveryService.java:
##########
@@ -93,6 +97,15 @@ public TopologyView getTopology() {
                 .listInstances(localClusterView);
         topology.addInstances(attachedInstances);
 
+        // Check if topology changes should be delayed
+        if (topologyReadinessHandler != null && 
topologyReadinessHandler.shouldDelayTopologyChange()) {
+            if (oldView != null) {
+                oldView.setNotCurrent();

Review Comment:
   One idea: check for `isCurrent()` : if it is `true`, then add a 
`logger.info` that the instance would now trigger a `TOPOLOGY_CHANGING` 
(perhaps good idea to test this though, that this would only be executed once, 
but I would expect it to)



##########
src/main/java/org/apache/sling/discovery/base/commons/TopologyReadinessHandler.java:
##########
@@ -0,0 +1,163 @@
+/*
+ * 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.sling.discovery.base.commons;
+
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.apache.felix.hc.api.condition.SystemReady;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Deactivate;
+import org.osgi.service.component.annotations.Reference;
+import org.osgi.service.component.annotations.ReferenceCardinality;
+import org.osgi.service.component.annotations.ReferencePolicy;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.osgi.service.component.ComponentContext;
+
+/**
+ * Coordinates topology changes based on system readiness state.
+ * This component ensures that topology changes only occur when the system is 
in a stable state,
+ * both during startup and shutdown sequences.
+ * 
+ * The handler manages three main states:
+ * 1. STARTUP: Initial state when the system is starting up
+ * 2. READY: System is ready for normal operation and topology changes
+ * 3. SHUTDOWN: System is in the process of shutting down
+ * 
+ * State Transitions:
+ * - System starts in STARTUP state
+ * - Transitions to READY state only when SystemReady service is bound
+ * - Transitions to SHUTDOWN state when:
+ *   * SystemReady service is unbound
+ *   * Component is deactivated
+ * 
+ * Note: This component requires the Felix SystemReady service to function 
properly.
+ * The system will remain in STARTUP state until SystemReady service is bound,
+ * and will transition to SHUTDOWN state when the service is unbound.
+ */
+@Component(service = TopologyReadinessHandler.class, immediate = true)
+public class TopologyReadinessHandler {
+
+    private final Logger logger = LoggerFactory.getLogger(this.getClass());
+
+    /**
+     * Represents the possible states of the system with explicit transitions.
+     */
+    private enum SystemState {
+        STARTUP {
+            @Override
+            protected SystemState[] getAllowedTransitions() {
+                return new SystemState[] { READY };
+            }
+        },
+        READY {
+            @Override
+            protected SystemState[] getAllowedTransitions() {
+                return new SystemState[] { SHUTDOWN };
+            }
+        },
+        SHUTDOWN {
+            @Override
+            protected SystemState[] getAllowedTransitions() {
+                return new SystemState[] { };  // No transitions allowed from 
SHUTDOWN
+            }
+        };
+
+        protected abstract SystemState[] getAllowedTransitions();
+    }
+
+    private final StateMachine stateMachine = new StateMachine();
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY, policy = 
ReferencePolicy.STATIC,
+                target = "(tag=systemready)")
+    private volatile SystemReady systemReady;
+
+    @Activate
+    protected void activate(ComponentContext context) {
+        logger.info("TopologyReadinessHandler activated - in STARTUP state");
+    }
+
+    @Deactivate
+    protected void deactivate(ComponentContext context) {
+        logger.info("TopologyReadinessHandler deactivated");
+        stateMachine.transitionTo(SystemState.SHUTDOWN);
+    }
+
+    public void bindSystemReady(SystemReady service) {
+        logger.debug("SystemReady service bound - transitioning to READY 
state");
+        stateMachine.transitionTo(SystemState.READY);
+    }
+
+    protected void unbindSystemReady(SystemReady service) {
+        logger.debug("SystemReady service unbound - transitioning to SHUTDOWN 
state");
+        stateMachine.transitionTo(SystemState.SHUTDOWN);

Review Comment:
   I think these could be `logger.info` perhaps that is already logged 
elsewhere but it should only be a one-time and might be useful to see.



##########
src/main/java/org/apache/sling/discovery/base/commons/TopologyReadinessHandler.java:
##########
@@ -0,0 +1,163 @@
+/*
+ * 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.sling.discovery.base.commons;
+
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.apache.felix.hc.api.condition.SystemReady;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Deactivate;
+import org.osgi.service.component.annotations.Reference;
+import org.osgi.service.component.annotations.ReferenceCardinality;
+import org.osgi.service.component.annotations.ReferencePolicy;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.osgi.service.component.ComponentContext;
+
+/**
+ * Coordinates topology changes based on system readiness state.
+ * This component ensures that topology changes only occur when the system is 
in a stable state,
+ * both during startup and shutdown sequences.
+ * 
+ * The handler manages three main states:
+ * 1. STARTUP: Initial state when the system is starting up
+ * 2. READY: System is ready for normal operation and topology changes
+ * 3. SHUTDOWN: System is in the process of shutting down
+ * 
+ * State Transitions:
+ * - System starts in STARTUP state
+ * - Transitions to READY state only when SystemReady service is bound
+ * - Transitions to SHUTDOWN state when:
+ *   * SystemReady service is unbound
+ *   * Component is deactivated
+ * 
+ * Note: This component requires the Felix SystemReady service to function 
properly.
+ * The system will remain in STARTUP state until SystemReady service is bound,
+ * and will transition to SHUTDOWN state when the service is unbound.
+ */
+@Component(service = TopologyReadinessHandler.class, immediate = true)
+public class TopologyReadinessHandler {
+
+    private final Logger logger = LoggerFactory.getLogger(this.getClass());
+
+    /**
+     * Represents the possible states of the system with explicit transitions.
+     */
+    private enum SystemState {
+        STARTUP {
+            @Override
+            protected SystemState[] getAllowedTransitions() {
+                return new SystemState[] { READY };
+            }
+        },
+        READY {
+            @Override
+            protected SystemState[] getAllowedTransitions() {
+                return new SystemState[] { SHUTDOWN };
+            }
+        },
+        SHUTDOWN {
+            @Override
+            protected SystemState[] getAllowedTransitions() {
+                return new SystemState[] { };  // No transitions allowed from 
SHUTDOWN
+            }
+        };
+
+        protected abstract SystemState[] getAllowedTransitions();
+    }
+
+    private final StateMachine stateMachine = new StateMachine();
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY, policy = 
ReferencePolicy.STATIC,
+                target = "(tag=systemready)")
+    private volatile SystemReady systemReady;
+
+    @Activate
+    protected void activate(ComponentContext context) {
+        logger.info("TopologyReadinessHandler activated - in STARTUP state");
+    }
+
+    @Deactivate
+    protected void deactivate(ComponentContext context) {
+        logger.info("TopologyReadinessHandler deactivated");
+        stateMachine.transitionTo(SystemState.SHUTDOWN);
+    }
+
+    public void bindSystemReady(SystemReady service) {
+        logger.debug("SystemReady service bound - transitioning to READY 
state");
+        stateMachine.transitionTo(SystemState.READY);
+    }
+
+    protected void unbindSystemReady(SystemReady service) {
+        logger.debug("SystemReady service unbound - transitioning to SHUTDOWN 
state");
+        stateMachine.transitionTo(SystemState.SHUTDOWN);
+    }
+
+    /**
+     * Initiate the shutdown process
+     */
+    public void initiateShutdown() {

Review Comment:
   is there a particular reason for having this instead of calling 
`deactivate(null)` for example?



##########
src/main/java/org/apache/sling/discovery/base/commons/TopologyReadinessHandler.java:
##########
@@ -0,0 +1,163 @@
+/*
+ * 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.sling.discovery.base.commons;
+
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.apache.felix.hc.api.condition.SystemReady;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Deactivate;
+import org.osgi.service.component.annotations.Reference;
+import org.osgi.service.component.annotations.ReferenceCardinality;
+import org.osgi.service.component.annotations.ReferencePolicy;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.osgi.service.component.ComponentContext;
+
+/**
+ * Coordinates topology changes based on system readiness state.
+ * This component ensures that topology changes only occur when the system is 
in a stable state,
+ * both during startup and shutdown sequences.
+ * 
+ * The handler manages three main states:
+ * 1. STARTUP: Initial state when the system is starting up
+ * 2. READY: System is ready for normal operation and topology changes
+ * 3. SHUTDOWN: System is in the process of shutting down
+ * 
+ * State Transitions:
+ * - System starts in STARTUP state
+ * - Transitions to READY state only when SystemReady service is bound
+ * - Transitions to SHUTDOWN state when:
+ *   * SystemReady service is unbound
+ *   * Component is deactivated
+ * 
+ * Note: This component requires the Felix SystemReady service to function 
properly.
+ * The system will remain in STARTUP state until SystemReady service is bound,
+ * and will transition to SHUTDOWN state when the service is unbound.
+ */
+@Component(service = TopologyReadinessHandler.class, immediate = true)
+public class TopologyReadinessHandler {
+
+    private final Logger logger = LoggerFactory.getLogger(this.getClass());
+
+    /**
+     * Represents the possible states of the system with explicit transitions.
+     */
+    private enum SystemState {
+        STARTUP {
+            @Override
+            protected SystemState[] getAllowedTransitions() {
+                return new SystemState[] { READY };
+            }
+        },
+        READY {
+            @Override
+            protected SystemState[] getAllowedTransitions() {
+                return new SystemState[] { SHUTDOWN };
+            }
+        },
+        SHUTDOWN {
+            @Override
+            protected SystemState[] getAllowedTransitions() {
+                return new SystemState[] { };  // No transitions allowed from 
SHUTDOWN
+            }
+        };
+
+        protected abstract SystemState[] getAllowedTransitions();
+    }
+
+    private final StateMachine stateMachine = new StateMachine();
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY, policy = 
ReferencePolicy.STATIC,
+                target = "(tag=systemready)")
+    private volatile SystemReady systemReady;
+
+    @Activate
+    protected void activate(ComponentContext context) {
+        logger.info("TopologyReadinessHandler activated - in STARTUP state");
+    }
+
+    @Deactivate
+    protected void deactivate(ComponentContext context) {
+        logger.info("TopologyReadinessHandler deactivated");
+        stateMachine.transitionTo(SystemState.SHUTDOWN);
+    }
+
+    public void bindSystemReady(SystemReady service) {
+        logger.debug("SystemReady service bound - transitioning to READY 
state");
+        stateMachine.transitionTo(SystemState.READY);
+    }
+
+    protected void unbindSystemReady(SystemReady service) {
+        logger.debug("SystemReady service unbound - transitioning to SHUTDOWN 
state");
+        stateMachine.transitionTo(SystemState.SHUTDOWN);
+    }
+
+    /**
+     * Initiate the shutdown process
+     */
+    public void initiateShutdown() {
+        if (stateMachine.getCurrentState() == SystemState.READY) {
+            logger.info("Initiating shutdown process");
+            stateMachine.transitionTo(SystemState.SHUTDOWN);
+            logger.info("Shutdown completed successfully");
+        }
+    }
+
+    /**
+     * Check if a topology change should be delayed based on system readiness
+     * @return true if the change should be delayed, false otherwise
+     */
+    public boolean shouldDelayTopologyChange() {

Review Comment:
   (see earlier comment about use of term "delay")



##########
src/test/java/org/apache/sling/discovery/base/connectors/DummyVirtualInstanceBuilder.java:
##########
@@ -48,12 +50,12 @@ public VirtualInstanceBuilder setPath(String string) {
         // nothing to do now
         return this;
     }
-    
+

Review Comment:
   unnecessary change (as mentioned previously)



##########
src/test/java/org/apache/sling/discovery/base/its/TopologyReadinessHandlerIT.java:
##########
@@ -0,0 +1,107 @@
+/*
+ * 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.sling.discovery.base.its;
+
+import static org.junit.Assert.*;
+
+import org.apache.felix.hc.api.condition.SystemReady;
+import org.apache.sling.discovery.base.its.setup.VirtualInstance;
+import org.apache.sling.discovery.base.its.setup.VirtualInstanceBuilder;
+import org.apache.sling.discovery.base.connectors.DummyVirtualInstanceBuilder;
+import org.junit.After;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.LinkedList;
+import java.util.List;
+
+public class TopologyReadinessHandlerIT {
+
+    private final Logger logger = LoggerFactory.getLogger(this.getClass());
+    private final SystemReady systemReadyService = new SystemReady() {};
+    private final List<VirtualInstance> instances = new LinkedList<>();
+
+    @After
+    public void tearDown() throws Exception {
+        for (VirtualInstance instance : instances) {
+            instance.stop();
+        }
+        instances.clear();
+    }
+
+    @Test
+    public void testReadinessHandlerWithTwoInstances() throws Exception {

Review Comment:
   not quite sure what this test case should test? on the one hand it goes 
through the effort of setting up a cluster, but then doesn't actually test the 
outcome? (other than verifying that `runHeartbeats` doesn't throw exceptions)



##########
src/main/java/org/apache/sling/discovery/base/commons/BaseDiscoveryService.java:
##########
@@ -41,12 +42,15 @@ public abstract class BaseDiscoveryService implements 
DiscoveryService {
     /** the old view previously valid and sent to the TopologyEventListeners 
**/
     private DefaultTopologyView oldView;
 
+    @Reference
+    private TopologyReadinessHandler topologyReadinessHandler;
+
     protected abstract ClusterViewService getClusterViewService();
     
     protected abstract AnnouncementRegistry getAnnouncementRegistry();
     
     protected abstract void handleIsolatedFromTopology();
-    
+

Review Comment:
   still here..



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@sling.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to