|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjimm.evote.VoteServer
Stores Vote
s that come from Booth
s and runs a few
hard-coded queries.
Field Summary | |
protected VSDbEnv |
dbEnvironment
Manages database housekeeping. |
Constructor Summary | |
VoteServer(java.lang.String databaseDirectory)
Opens the databases read-write. |
|
VoteServer(java.lang.String databaseDirectory,
boolean readOnly)
Opens the databases. |
Method Summary | |
void |
acceptVotesAtomically(Booth booth)
Accepts the votes from a voting booth. |
void |
emptyDatabases()
Empties the databases. |
java.lang.String |
getSomeBoothState()
Returns a state string. |
static void |
main(java.lang.String[] args)
usage: VoteServer /path/to/database/directory |
void |
printPresidentialResults()
Prints the number of presidential race votes by party, then announces the winner. |
void |
printPresidentialVotes()
Runs a query that prints the total number of presidential votes. |
void |
printSingleStateBoothList()
Finds a state and prints the list of booths in that state. |
void |
printSingleStateBoothListUsingCursor(java.lang.String state,
byte[] key)
Prints the booths in state using a cursor. |
void |
printSingleStateBoothListUsingIterator(java.lang.String state,
byte[] key)
Prints the booths in state using a map and an iterator. |
void |
printSingleVote()
Runs a query that uses a specific key to find a single record. |
void |
printTotalVotes()
Print the number of votes in the vote database. |
void |
runQueries()
Runs a few hard-coded queries and outputs the results. |
void |
shutDown()
Gracefully shuts down the databases. |
protected void |
storeBooth(Transaction txn,
Booth booth)
Stores booth in the booth database. |
protected void |
storeVote(Transaction txn,
Vote vote)
Stores vote in the vote database. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected VSDbEnv dbEnvironment
Constructor Detail |
public VoteServer(java.lang.String databaseDirectory)
databaseDirectory
- path to the database directorypublic VoteServer(java.lang.String databaseDirectory, boolean readOnly)
databaseDirectory
- path to the database directoryreadOnly
- if true
, databases will be opened read-onlyMethod Detail |
public void shutDown()
public void acceptVotesAtomically(Booth booth)
This method must be thread safe, not because the transactions require it
but because ElectionDay
uses multiple threads when it tells booths
to send votes to the server. Being thread safe does not mean it
has to be synchronized, nor do we have to worry about using
dbEnvironment safely because the objects it holds (environment,
database) are already thread safe.
booth
- a voting booth ripe with votesprotected void storeBooth(Transaction txn, Booth booth) throws DatabaseException, java.io.IOException
BoothBinding
translates the booth into a format suitable for storage.
txn
- a transaction; if null
and the database is
transactional then autocommit is usedbooth
-
DatabaseException
java.io.IOException
protected void storeVote(Transaction txn, Vote vote) throws DatabaseException, java.io.IOException
txn
- a transaction; if null
and the database is
transactional then autocommit is usedvote
- a vote
DatabaseException
java.io.IOException
public void runQueries()
public void printTotalVotes()
public void printSingleVote() throws java.io.UnsupportedEncodingException, DatabaseException, java.io.IOException
java.io.UnsupportedEncodingException
DatabaseException
java.io.IOException
public void printSingleStateBoothList() throws java.io.UnsupportedEncodingException, DatabaseException, java.io.IOException
java.io.UnsupportedEncodingException
DatabaseException
java.io.IOException
public void printSingleStateBoothListUsingCursor(java.lang.String state, byte[] key)
public void printSingleStateBoothListUsingIterator(java.lang.String state, byte[] key)
public java.lang.String getSomeBoothState() throws DatabaseException, java.io.IOException
DatabaseException
java.io.IOException
public void printPresidentialVotes() throws java.io.IOException
java.io.IOException
public void printPresidentialResults() throws java.io.UnsupportedEncodingException, java.io.IOException
java.io.UnsupportedEncodingException
java.io.IOException
public void emptyDatabases()
public static void main(java.lang.String[] args)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |