@Service(value=HeartbeatHandler.class) @Reference(referenceInterface=org.osgi.service.http.HttpService.class, cardinality=OPTIONAL_MULTIPLE, policy=DYNAMIC) public class HeartbeatHandler extends org.apache.sling.discovery.base.commons.BaseViewChecker
Local heartbeats are stored in the repository. Remote heartbeats are POSTs to remote TopologyConnectorServlets.
Modifier and Type | Field and Description |
---|---|
protected org.apache.sling.discovery.base.connectors.announcement.AnnouncementRegistry |
announcementRegistry |
protected org.apache.sling.discovery.base.connectors.ping.ConnectorRegistry |
connectorRegistry |
protected String |
failedEstablishedViewId |
protected org.apache.sling.discovery.base.commons.PeriodicBackgroundJob |
periodicCheckJob |
protected org.apache.sling.api.resource.ResourceResolverFactory |
resourceResolverFactory |
protected org.apache.sling.commons.scheduler.Scheduler |
scheduler |
protected org.apache.sling.settings.SlingSettingsService |
slingSettingsService |
Constructor and Description |
---|
HeartbeatHandler() |
Modifier and Type | Method and Description |
---|---|
protected void |
deactivate() |
protected void |
doActivate() |
protected void |
doCheckView()
Check whether the established view matches the reality, ie matches the
heartbeats
|
protected org.apache.sling.discovery.base.connectors.announcement.AnnouncementRegistry |
getAnnouncementRegistry() |
protected org.apache.sling.discovery.base.connectors.BaseConfig |
getConnectorConfig() |
protected org.apache.sling.discovery.base.connectors.ping.ConnectorRegistry |
getConnectorRegistry() |
protected org.apache.sling.api.resource.ResourceResolverFactory |
getResourceResolverFactory() |
protected org.apache.sling.commons.scheduler.Scheduler |
getScheduler() |
protected org.apache.sling.settings.SlingSettingsService |
getSlingSettingsService() |
void |
initialize(DiscoveryServiceImpl discoveryService,
String initialVotingId)
The initialize method is called by the DiscoveryServiceImpl.activate
as we require the discoveryService (and the discoveryService has
a reference on us - but we cant have circular references in osgi).
|
void |
invalidateCurrentEstablishedView()
Mark the current establishedView as invalid - requiring it to be
replaced with a new one, be it by another instance or this one,
via a new vote
|
protected void |
issueClusterLocalHeartbeat()
Issue a cluster local heartbeat (into the repository)
|
protected void |
issueHeartbeat()
Issue a heartbeat.
|
boolean |
resetLeaderElectionId()
Hook that will cause a reset of the leaderElectionId
on next invocation of issueClusterLocalHeartbeat.
|
void |
startNewVoting()
Management function to trigger the otherwise algorithm-dependent
start of a new voting.
|
static HeartbeatHandler |
testConstructor(org.apache.sling.settings.SlingSettingsService slingSettingsService,
org.apache.sling.api.resource.ResourceResolverFactory factory,
org.apache.sling.discovery.base.connectors.announcement.AnnouncementRegistry announcementRegistry,
org.apache.sling.discovery.base.connectors.ping.ConnectorRegistry connectorRegistry,
Config config,
org.apache.sling.commons.scheduler.Scheduler scheduler,
VotingHandler votingHandler)
for testing only
|
protected void |
updateProperties() |
@Reference protected org.apache.sling.settings.SlingSettingsService slingSettingsService
@Reference protected org.apache.sling.api.resource.ResourceResolverFactory resourceResolverFactory
@Reference protected org.apache.sling.discovery.base.connectors.ping.ConnectorRegistry connectorRegistry
@Reference protected org.apache.sling.discovery.base.connectors.announcement.AnnouncementRegistry announcementRegistry
@Reference protected org.apache.sling.commons.scheduler.Scheduler scheduler
protected String failedEstablishedViewId
protected org.apache.sling.discovery.base.commons.PeriodicBackgroundJob periodicCheckJob
public static HeartbeatHandler testConstructor(org.apache.sling.settings.SlingSettingsService slingSettingsService, org.apache.sling.api.resource.ResourceResolverFactory factory, org.apache.sling.discovery.base.connectors.announcement.AnnouncementRegistry announcementRegistry, org.apache.sling.discovery.base.connectors.ping.ConnectorRegistry connectorRegistry, Config config, org.apache.sling.commons.scheduler.Scheduler scheduler, VotingHandler votingHandler)
protected org.apache.sling.discovery.base.connectors.announcement.AnnouncementRegistry getAnnouncementRegistry()
getAnnouncementRegistry
in class org.apache.sling.discovery.base.commons.BaseViewChecker
protected org.apache.sling.discovery.base.connectors.BaseConfig getConnectorConfig()
getConnectorConfig
in class org.apache.sling.discovery.base.commons.BaseViewChecker
protected org.apache.sling.discovery.base.connectors.ping.ConnectorRegistry getConnectorRegistry()
getConnectorRegistry
in class org.apache.sling.discovery.base.commons.BaseViewChecker
protected org.apache.sling.api.resource.ResourceResolverFactory getResourceResolverFactory()
getResourceResolverFactory
in class org.apache.sling.discovery.base.commons.BaseViewChecker
protected org.apache.sling.commons.scheduler.Scheduler getScheduler()
getScheduler
in class org.apache.sling.discovery.base.commons.BaseViewChecker
protected org.apache.sling.settings.SlingSettingsService getSlingSettingsService()
getSlingSettingsService
in class org.apache.sling.discovery.base.commons.BaseViewChecker
protected void doActivate()
doActivate
in class org.apache.sling.discovery.base.commons.BaseViewChecker
protected void deactivate()
deactivate
in class org.apache.sling.discovery.base.commons.BaseViewChecker
public void initialize(DiscoveryServiceImpl discoveryService, String initialVotingId)
The initialVotingId is used to avoid an unnecessary topologyChanged event when starting up an instance in a 1-node cluster: the instance will wait until the first voting has been finished to send the TOPOLOGY_INIT event - BUT even before that the API method getTopology() is open - so if anyone asks for the topology BEFORE the first voting in a 1-node cluster is done, it gets a particular clusterId - that one we aim to reuse for the first voting.
public boolean resetLeaderElectionId()
protected void issueHeartbeat()
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)
issueHeartbeat
in class org.apache.sling.discovery.base.commons.BaseViewChecker
protected void updateProperties()
updateProperties
in class org.apache.sling.discovery.base.commons.BaseViewChecker
protected void issueClusterLocalHeartbeat()
protected void doCheckView()
doCheckView
in class org.apache.sling.discovery.base.commons.BaseViewChecker
public void invalidateCurrentEstablishedView()
public void startNewVoting()
Copyright © 2007–2017 The Apache Software Foundation. All rights reserved.