Package org.apache.sling.discovery.base.commons

# Class BaseViewChecker

java.lang.Object
org.apache.sling.discovery.base.commons.BaseViewChecker

All Implemented Interfaces:
  `Runnable`, `ViewChecker`

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 Summary

Fields
Modifier and Type
Field
Description
`protected boolean`
`activated`
SLING-2895: avoid heartbeats after deactivation
`protected org.osgi.service.component.ComponentContext`
`context`
keep a reference to the component context
`protected final Map<Long,String[]>`
`endpoints`
SLING-4765 : store endpoints to /clusterInstances for more verbose duplicate slingId/ghost detection
`protected final Object`
`lock`
lock object for synchronizing the run method
`protected final org.slf4j.Logger`
`logger`
`protected String`
`NAME`
the name used for the period job with the scheduler
`protected PeriodicBackgroundJob`
`periodicPingJob`
`protected static final String`
`PROPERTY_ID_ENDPOINTS`
`protected static final String`
`PROPERTY_ID_RUNTIME`
`protected static final String`
`PROPERTY_ID_SLING_HOME_PATH`
`protected String`
`runtimeId`
SLING-2901: the runtimeId is a unique id, set on activation, used for robust duplicate sling.id detection
`protected String`
`slingId`
the sling id of the local instance

## Constructor Summary

Constructors
Constructor
Description
`BaseViewChecker()`

## Method Summary

Modifier and Type
Method
Description
`protected void`
`activate(org.osgi.service.component.ComponentContext context)`
`protected void`
`bindHttpService(org.osgi.framework.ServiceReference reference)`
Bind a http service
`void`
`checkView()`
for testing only
`protected void`
`deactivate()`
`protected void`
`doActivate()`
`protected void`
`doCheckView()`
Check whether the established view matches the reality, ie matches the heartbeats
`protected abstract AnnouncementRegistry`
`getAnnouncementRegistry()`
`protected abstract BaseConfig`
`getConnectorConfig()`
`protected abstract ConnectorRegistry`
`getConnectorRegistry()`
`protected String`
`getEndpointsAsString()`
`protected abstract org.apache.sling.api.resource.ResourceResolverFactory`
`getResourceResolverFactory()`
`protected abstract org.apache.sling.commons.scheduler.Scheduler`
`getScheduler()`
`protected abstract org.apache.sling.settings.SlingSettingsService`
`getSlingSettingsService()`
`void`
`heartbeatAndCheckView()`
Issue a heartbeat and check the view
`protected void`
`issueConnectorPings()`
Issue a remote heartbeat using the topology connectors
`protected void`
`issueHeartbeat()`
Issue a heartbeat.
`void`
`run()`
`void`
`triggerAsyncConnectorPing()`
Trigger the issuance of the next heartbeat asap instead of at next heartbeat interval
`protected void`
`unbindHttpService(org.osgi.framework.ServiceReference reference)`
Unbind a http service
`protected abstract void`
`updateProperties()`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### logger

protected final org.slf4j.Logger logger

### PROPERTY_ID_ENDPOINTS

protected static final String PROPERTY_ID_ENDPOINTS

See Also:
  - Constant Field Values

### PROPERTY_ID_SLING_HOME_PATH

protected static final String PROPERTY_ID_SLING_HOME_PATH

See Also:
  - Constant Field Values

### PROPERTY_ID_RUNTIME

protected static final String PROPERTY_ID_RUNTIME

See Also:
  - Constant Field Values

### 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 org.apache.sling.settings.SlingSettingsService getSlingSettingsService()

### getResourceResolverFactory

protected abstract org.apache.sling.api.resource.ResourceResolverFactory getResourceResolverFactory()

### getConnectorRegistry

protected abstract ConnectorRegistry getConnectorRegistry()

### getAnnouncementRegistry

protected abstract AnnouncementRegistry getAnnouncementRegistry()

### getScheduler

protected abstract org.apache.sling.commons.scheduler.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()