Class BaseViewChecker

java.lang.Object
org.apache.sling.discovery.base.commons.BaseViewChecker
All Implemented Interfaces:
Runnable, ViewChecker
Direct Known Subclasses:
OakViewChecker

public abstract class BaseViewChecker extends Object implements ViewChecker, Runnable
The heartbeat handler is responsible and capable of issuing both local and remote heartbeats and registers a periodic job with the scheduler for doing so.

Local heartbeats are stored in the repository. Remote heartbeats are POSTs to remote TopologyConnectorServlets.

  • Field Details

    • logger

      protected final org.slf4j.Logger logger
    • PROPERTY_ID_ENDPOINTS

      protected static final String PROPERTY_ID_ENDPOINTS
      See Also:
    • PROPERTY_ID_SLING_HOME_PATH

      protected static final String PROPERTY_ID_SLING_HOME_PATH
      See Also:
    • PROPERTY_ID_RUNTIME

      protected static final String PROPERTY_ID_RUNTIME
      See Also:
    • NAME

      protected String NAME
      the name used for the period job with the scheduler
    • slingId

      protected String slingId
      the sling id of the local instance
    • runtimeId

      protected String runtimeId
      SLING-2901: the runtimeId is a unique id, set on activation, used for robust duplicate sling.id detection
    • lock

      protected final Object lock
      lock object for synchronizing the run method
    • activated

      protected volatile boolean activated
      SLING-2895: avoid heartbeats after deactivation
    • context

      protected org.osgi.service.component.ComponentContext context
      keep a reference to the component context
    • endpoints

      protected final Map<Long,String[]> endpoints
      SLING-4765 : store endpoints to /clusterInstances for more verbose duplicate slingId/ghost detection
    • periodicPingJob

      protected PeriodicBackgroundJob periodicPingJob
  • Constructor Details

    • BaseViewChecker

      public BaseViewChecker()
  • Method Details

    • getSlingSettingsService

      protected abstract SlingSettingsService getSlingSettingsService()
    • getResourceResolverFactory

      protected abstract ResourceResolverFactory getResourceResolverFactory()
    • getConnectorRegistry

      protected abstract ConnectorRegistry getConnectorRegistry()
    • getAnnouncementRegistry

      protected abstract AnnouncementRegistry getAnnouncementRegistry()
    • getScheduler

      protected abstract Scheduler getScheduler()
    • getConnectorConfig

      protected abstract BaseConfig getConnectorConfig()
    • activate

      protected void activate(org.osgi.service.component.ComponentContext context)
    • doActivate

      protected void doActivate()
    • deactivate

      protected void deactivate()
    • checkView

      public void checkView()
      for testing only
      Specified by:
      checkView in interface ViewChecker
    • run

      public void run()
      Specified by:
      run in interface Runnable
    • heartbeatAndCheckView

      public void heartbeatAndCheckView()
      Description copied from interface: ViewChecker
      Issue a heartbeat and check the view
      Specified by:
      heartbeatAndCheckView in interface ViewChecker
    • triggerAsyncConnectorPing

      public void triggerAsyncConnectorPing()
      Trigger the issuance of the next heartbeat asap instead of at next heartbeat interval
    • issueHeartbeat

      protected void issueHeartbeat()
      Issue a heartbeat.

      This action consists of first updating the local properties, then issuing a cluster-local heartbeat (within the repository) and then a remote heartbeat (to all the topology connectors which announce this part of the topology to others)

    • updateProperties

      protected abstract void updateProperties()
    • issueConnectorPings

      protected void issueConnectorPings()
      Issue a remote heartbeat using the topology connectors
    • doCheckView

      protected void doCheckView()
      Check whether the established view matches the reality, ie matches the heartbeats
    • bindHttpService

      protected void bindHttpService(org.osgi.framework.ServiceReference reference)
      Bind a http service
    • unbindHttpService

      protected void unbindHttpService(org.osgi.framework.ServiceReference reference)
      Unbind a http service
    • getEndpointsAsString

      protected String getEndpointsAsString()