org.apache.sling.discovery.impl.cluster.voting

## Class VotingHandler

- java.lang.Object
- - org.apache.sling.discovery.impl.cluster.voting.VotingHandler

All Implemented Interfaces:
  org.osgi.service.event.EventHandler

    @Service(value=VotingHandler.class)
    public class VotingHandler
    extends Object
    implements org.osgi.service.event.EventHandler

The osgi event handler responsible for following any votings and vote accordingly

### Nested Class Summary

Nested Classes
`static class` `VotingHandler.VotingDetail`

### Field Summary

Fields
`protected String` `NAME` the name used for the period job with the scheduler

### Constructor Summary

Constructors
Constructor and Description
`VotingHandler()`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`protected void` `activate(org.osgi.service.component.ComponentContext context)`
`Map<VotingView,VotingHandler.VotingDetail>` `analyzeVotings(org.apache.sling.api.resource.ResourceResolver resourceResolver)` Analyze any ongoing voting in the repository.
`void` `cleanupTimedoutVotings(org.apache.sling.api.resource.ResourceResolver resourceResolver)`
`protected void` `deactivate()`
`void` `handleEvent(org.osgi.service.event.Event event)` handle repository changes and react to ongoing votings
`void` `setLeaderElectionId(String leaderElectionId)`
`static VotingHandler` `testConstructor(org.apache.sling.settings.SlingSettingsService settingsService, org.apache.sling.api.resource.ResourceResolverFactory factory, Config config)` for testing only

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

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

### Field Detail

#### NAME

    protected String NAME

the name used for the period job with the scheduler

### Constructor Detail

#### VotingHandler

    public VotingHandler()

### Method Detail

#### testConstructor

    public static VotingHandler testConstructor(org.apache.sling.settings.SlingSettingsService settingsService,
                                                org.apache.sling.api.resource.ResourceResolverFactory factory,
                                                Config config)

for testing only

#### deactivate

    @Deactivate
    protected void deactivate()

#### activate

    @Activate
    protected void activate(org.osgi.service.component.ComponentContext context)

#### handleEvent

    public void handleEvent(org.osgi.service.event.Event event)

handle repository changes and react to ongoing votings

Specified by:
  `handleEvent` in interface `org.osgi.service.event.EventHandler`

#### analyzeVotings

    public Map<VotingView,VotingHandler.VotingDetail> analyzeVotings(org.apache.sling.api.resource.ResourceResolver resourceResolver)
                                                              throws org.apache.sling.api.resource.PersistenceException

Analyze any ongoing voting in the repository.

SLING-2885: this method must be synchronized as it can be called concurrently by the HearbeatHandler.doCheckView and the VotingHandler.handleEvent.

Throws:
  `org.apache.sling.api.resource.PersistenceException`

#### cleanupTimedoutVotings

    public void cleanupTimedoutVotings(org.apache.sling.api.resource.ResourceResolver resourceResolver)

#### setLeaderElectionId

    public void setLeaderElectionId(String leaderElectionId)