|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.sling.discovery.impl.common.View
org.apache.sling.discovery.impl.cluster.voting.VotingView
public class VotingView
DAO for an ongoing voting, providing a few helper methods
Field Summary |
---|
Fields inherited from class org.apache.sling.discovery.impl.common.View |
---|
VIEW_PROPERTY_CLUSTER_ID, VIEW_PROPERTY_CLUSTER_ID_DEFINED_AT, VIEW_PROPERTY_CLUSTER_ID_DEFINED_BY |
Constructor Summary | |
---|---|
VotingView(org.apache.sling.api.resource.Resource viewResource)
Construct a voting view based on the given resource |
Method Summary | |
---|---|
boolean |
hasNoVotes()
Checks whether there are any no votes on this voting |
boolean |
hasVotedOrIsInitiator(String slingId)
Checks whether the given slingId has voted yes or is the initiator of 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 |
boolean |
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)
add a vote from the given slingId to this voting |
Methods inherited from class org.apache.sling.discovery.impl.common.View |
---|
equals, getResource, getViewId, hashCode, matches, matchesLiveView, remove |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public VotingView(org.apache.sling.api.resource.Resource viewResource)
viewResource
- the resource which is the place the voting is keptMethod Detail |
---|
public 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 voting
org.apache.sling.api.resource.PersistenceException
public String toString()
toString
in class Object
public boolean isOngoingVoting(Config config)
config
-
public boolean isTimedoutVoting(Config config)
public boolean hasNoVotes()
public boolean hasVotedOrIsInitiator(String slingId)
slingId
- the sling id to check for
public boolean isInitiatedBy(String slingId)
public void vote(String slingId, Boolean vote)
slingId
- the slingId which is votingvote
- true for a yes-vote, false for a no-votepublic boolean isWinning()
public boolean matchesLiveView(Config config)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |