public class VotingView extends View
VIEW_PROPERTY_CLUSTER_ID, VIEW_PROPERTY_CLUSTER_ID_DEFINED_AT, VIEW_PROPERTY_CLUSTER_ID_DEFINED_BY
Constructor and Description |
---|
VotingView(org.apache.sling.api.resource.Resource viewResource)
Construct a voting view based on the given resource
|
Modifier and Type | Method and Description |
---|---|
Boolean |
getVote(String slingId)
Get the vote of the instance with the given slingId
|
String |
getVotingId() |
boolean |
hasNoVotes()
Checks whether there are any no votes on this voting
|
boolean |
hasVotedYes(String slingId)
Checks whether the given slingId has voted yes for this voting
|
boolean |
isInitiatedBy(String slingId)
Checks whether this voting was initiated by the given slingId
|
boolean |
isOngoingVoting(Config config)
Checks whether this voting is still ongoing - that is, whether
a valid votingStart is set and whether that's within the heartbeat timeout configured
|
boolean |
isTimedoutVoting(Config config)
Checks whether this voting has timed out - that is, whether
there is a valid votingStart set and whether that has timed out
|
boolean |
isWinning()
Checks whether this voting is winning - winning is when it has
votes from each of the members and all are yes votes
|
String |
matchesLiveView(Config config)
Checks if this voting matches the current live view
|
static VotingView |
newVoting(org.apache.sling.api.resource.ResourceResolver resourceResolver,
Config config,
String newViewId,
String initiatorId,
Set<String> liveInstances)
Create a new voting with the given list of instances, the given
voting/view id and the given slingid of the initiator.
|
String |
toString() |
void |
vote(String slingId,
Boolean vote,
String leaderElectionId)
add a vote from the given slingId to this voting
|
equals, getResource, getViewId, hashCode, matches, matchesLiveView, remove
public VotingView(org.apache.sling.api.resource.Resource viewResource)
viewResource
- the resource which is the place the voting is keptpublic static VotingView newVoting(org.apache.sling.api.resource.ResourceResolver resourceResolver, Config config, String newViewId, String initiatorId, Set<String> liveInstances) throws org.apache.sling.api.resource.PersistenceException
newViewId
- the new voting/view idinitiatorId
- the slingid of the initiatorliveInstances
- the list of live instances to add to the votingorg.apache.sling.api.resource.PersistenceException
public String getVotingId()
public boolean isOngoingVoting(Config config)
config
- public boolean isTimedoutVoting(Config config)
public boolean hasNoVotes()
public boolean hasVotedYes(String slingId)
slingId
- the sling id to check forpublic Boolean getVote(String slingId)
slingId
- public boolean isInitiatedBy(String slingId)
public void vote(String slingId, Boolean vote, String leaderElectionId)
slingId
- the slingId which is votingvote
- true for a yes-vote, false for a no-votepublic boolean isWinning()
Copyright © 2007–2017 The Apache Software Foundation. All rights reserved.