Votorola

votorola.a.poll
Class Count

java.lang.Object
  extended by Count
All Implemented Interfaces:
Serializable

@ThreadSafe
public class Count
extends Object
implements Serializable

The tallied results of a poll.

See Also:
Serialized Form

Constructor Summary
protected Count(Count count)
          Constructs a count as a copy of another.
(package private) Count(String serviceName, ReadyDirectory readyDirectory, CountTable.RankedCumulate rankedCumulate)
          Partially constructs a Count, for init to finish.
 
Method Summary
 long candidateCount()
          The number of nodes with a receive count of 1 or higher.
 CountTable countTable()
          The relational store of count nodes that (in part) backs this count, or null.
 CountTable.PollView countTablePV()
          The poll view of the count table, or null.
 long holdCount()
          The total hold count for all nodes.
(package private)  void init(CountTable countTable)
          Completes the construction of a new Count.
(package private)  boolean isObjectReadFromSerialFile(ReadyDirectory newReadyDirectory)
          Returns true if this count is probably in sync with the serial file of the specified ready directory; false if that file has since been modified or deleted.
 long msEndSnap()
          The time at which the snapshot of voter input was complete, in milliseconds since the 'epoch'; or Long.MAX_VALUE if the time is unknown.
 long msStartSnap()
          The time at which the snapshot of voter input commenced, in milliseconds since the 'epoch'; or zero if the time is unknown.
 long nodeCount()
          The number of recorded nodes, corresponding to rows in the node table.
 long rankCount()
          The total number of ranks.
(package private) static Count readObjectFromSerialFile(String serviceName, ReadyDirectory readyDirectory)
           
 ReadyDirectory readyDirectory()
          The file part of the backing for this count.
 String serviceName()
          The poll identifier for this count.
 long singleCastCount()
          The total number of votes cast.
(package private)  void writeObjectToSerialFile()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Count

Count(String serviceName,
      ReadyDirectory readyDirectory,
      CountTable.RankedCumulate rankedCumulate)
throws IOException
Partially constructs a Count, for init to finish.

Throws:
IOException
See Also:
serviceName(), readyDirectory()

Count

protected Count(Count count)
Constructs a count as a copy of another.

Method Detail

init

@ThreadRestricted(value="constructor")
final void init(CountTable countTable)
Completes the construction of a new Count.

See Also:
countTable()

isObjectReadFromSerialFile

final boolean isObjectReadFromSerialFile(ReadyDirectory newReadyDirectory)
Returns true if this count is probably in sync with the serial file of the specified ready directory; false if that file has since been modified or deleted. Always returns false if the count was never originally deserialized from that file path.

See Also:
readObjectFromSerialFile(String,ReadyDirectory)

readObjectFromSerialFile

static Count readObjectFromSerialFile(String serviceName,
                                      ReadyDirectory readyDirectory)
                               throws IOException
Throws:
FileNotFoundException - if the count does not include the named poll
IOException
See Also:
writeObjectToSerialFile()

writeObjectToSerialFile

final void writeObjectToSerialFile()
                            throws IOException
Throws:
IOException
See Also:
readObjectFromSerialFile(String,ReadyDirectory)

candidateCount

public final long candidateCount()
The number of nodes with a receive count of 1 or higher.

See Also:
CountNode.receiveCount()

countTable

public final CountTable countTable()
The relational store of count nodes that (in part) backs this count, or null. It is a table named "SCHEMA_NAME.YYYY-MD-S-count_node-S", stored in the count database.

Returns:
reference to relational store, or null if the count was not initialized with a reference
See Also:
Pollserver.Run.outputDatabase(), init(CountTable)

countTablePV

public final CountTable.PollView countTablePV()
The poll view of the count table, or null.

Returns:
the poll view; or null, if the count was not initialized with a count table
See Also:
init(CountTable)

holdCount

public final long holdCount()
The total hold count for all nodes. The implementation of this method returns singleCastCount().

See Also:
CountNode.holdCount()

nodeCount

public final long nodeCount()
The number of recorded nodes, corresponding to rows in the node table. It includes eligible and ineligible voters. It might (in future) include voters who are not participating at all in the poll, but have set some particular flag (such as non-cascading). This value is not meaningful, therefore, except to administrators.

See Also:
CountNode

msEndSnap

public long msEndSnap()
The time at which the snapshot of voter input was complete, in milliseconds since the 'epoch'; or Long.MAX_VALUE if the time is unknown.

See Also:
System.currentTimeMillis()

msStartSnap

public long msStartSnap()
The time at which the snapshot of voter input commenced, in milliseconds since the 'epoch'; or zero if the time is unknown.

See Also:
System.currentTimeMillis()

rankCount

public final long rankCount()
The total number of ranks. This is also the value of the bottom rank, that of the node(s) receiving the lowest number (normally zero) of votes.

Returns:
count of 1 or larger; or 0, if there are no nodes at all
See Also:
CountNode.getRank()

readyDirectory

public final ReadyDirectory readyDirectory()
The file part of the backing for this count.


serviceName

public final String serviceName()
The poll identifier for this count.


singleCastCount

public long singleCastCount()
The total number of votes cast. This is identical to the hold count.

See Also:
CountNode.singleCastCount()

Votorola