Votorola

votorola.a
Class Pollserver.Run

java.lang.Object
  extended by Pollserver.Run
Enclosing class:
Pollserver

@ThreadSafe
public final class Pollserver.Run
extends Object

A run of the pollserver.


Field Summary
 AtomicReference<Thread> constructionThreadA
           
(package private)  ReentrantLock singleServiceLock
           
 
Constructor Summary
Pollserver.Run(boolean isSingleThreaded)
          Constructs a Run.
 
Method Summary
 Geocode.Table geocodeTable()
          The relational cache of geocoded residential addresses.
 Database getOrInitializeDatabase(Database keyDatabase)
          Returns an already-initialized instance of the specified keyDatabase.
 void init_done()
          Records that initialization is complete - that no further calls will be made to init_ methods.
 void init_ensureAllVoterServices()
          Ensures that all voter services of the pollserver are created and stored for later retrieval.
<S extends VoterService>
S
init_ensureVoterService(File startupConfigurationFile, Class<S> serviceClass)
          Returns a voter service, creating it if necessary, and storing it for later retrieval.
 void init_putVoterService(VoterService service)
          Stores a voter service in this run, for later retrieval.
 boolean isSingleThreaded()
          Returns true if this run is restricted to a single client thread; false if multiple client threads are allowed.
 VoterService[] newVoterServiceArray()
          Returns all voter services provided in this run.
 Database outputDatabase()
          The database for storing the relational parts of the output store, such as mounted voter lists and poll counts.
 Pollserver pollserver()
          The pollserver for this run.
 Register register()
          The voter register for this pollserver.
 Poll.PollserverScope.Run scopePoll()
          API for all polls within the scope of this pollserver run.
 ReentrantLock singleServiceLock()
          Returns the thread access lock shared by all services; or null if all services do not share the same lock.
 UserSettings.Table userTable()
          The relational store of service preferences and other settings, for the users of this pollserver.
 Database voterInputDatabase()
          The database of voter input for all voter services.
 VoterService voterService(String name)
          Returns a voter service provided in this run.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

constructionThreadA

@Warning(value="non-API")
public final AtomicReference<Thread> constructionThreadA

singleServiceLock

final ReentrantLock singleServiceLock
Constructor Detail

Pollserver.Run

public Pollserver.Run(boolean isSingleThreaded)
               throws IOException,
                      ScriptException,
                      SQLException
Constructs a Run.

Parameters:
isSingleThreaded - per isSingleThreaded() - if false (multi-threaded), the client should call init_done() after initialization is complete
Throws:
IOException
ScriptException
SQLException
Method Detail

init_done

public void init_done()
Records that initialization is complete - that no further calls will be made to init_ methods. Single-threaded clients need not call this method; it only enables thread-safety assertions in the init_ methods. [No longer true, as some late constructs will now throw an IllegalStateException if this method has not been called.]


init_ensureAllVoterServices

@ThreadRestricted(value="constructor")
public void init_ensureAllVoterServices()
                                 throws IOException,
                                        ScriptException,
                                        SQLException
Ensures that all voter services of the pollserver are created and stored for later retrieval.

Throws:
IOException
ScriptException
SQLException
See Also:
init_ensureVoterService(File,Class)

init_ensureVoterService

@ThreadRestricted(value="constructor")
public <S extends VoterService> S init_ensureVoterService(File startupConfigurationFile,
                                                                                Class<S> serviceClass)
                                               throws IOException,
                                                      ScriptException,
                                                      SQLException
Returns a voter service, creating it if necessary, and storing it for later retrieval.

Parameters:
startupConfigurationFile - the startup configuration file for the service
serviceClass - the class of the service
Throws:
VoterService.NoSuchServiceException - if startupConfigurationFile does not exist
IOException
ScriptException
SQLException
See Also:
init_ensureAllVoterServices(), init_putVoterService(VoterService), voterService(String)

init_putVoterService

@ThreadRestricted(value="constructor")
public void init_putVoterService(VoterService service)
Stores a voter service in this run, for later retrieval.

Throws:
IllegalStateException - if an instance of the same service was already stored
See Also:
init_ensureVoterService(File,Class), voterService(String), init_ensureAllVoterServices()

geocodeTable

@Warning(value="thread restricted object")
public Geocode.Table geocodeTable()
The relational cache of geocoded residential addresses.

See Also:
Pollserver.ConstructionContext.geocodeDatabase()

getOrInitializeDatabase

public Database getOrInitializeDatabase(Database keyDatabase)
                                 throws ScriptException,
                                        SQLException
Returns an already-initialized instance of the specified keyDatabase. If no instance has already been initialized, the keyDatabase is initialized and returned, after caching it for later reuse.

Parameters:
keyDatabase - a database (typically uninitialized), to use as a key in searching for an already initialized instance of the same database in the cache
Throws:
ScriptException
SQLException

isSingleThreaded

public boolean isSingleThreaded()
Returns true if this run is restricted to a single client thread; false if multiple client threads are allowed.


newVoterServiceArray

public VoterService[] newVoterServiceArray()
Returns all voter services provided in this run.

Returns:
newly created array of voter services
See Also:
voterService(String)

outputDatabase

@Warning(value="thread restricted object")
public Database outputDatabase()
The database for storing the relational parts of the output store, such as mounted voter lists and poll counts.

See Also:
Pollserver.ConstructionContext.outputDatabase()

pollserver

public Pollserver pollserver()
The pollserver for this run.


register

@Warning(value="thread restricted object")
public Register register()
The voter register for this pollserver.


scopePoll

public Poll.PollserverScope.Run scopePoll()
API for all polls within the scope of this pollserver run.


singleServiceLock

public ReentrantLock singleServiceLock()
Returns the thread access lock shared by all services; or null if all services do not share the same lock. They share the same lock only if the run is single threaded.

See Also:
VoterService.lock()

userTable

@Warning(value="thread restricted object")
public UserSettings.Table userTable()
The relational store of service preferences and other settings, for the users of this pollserver.

See Also:
Pollserver.ConstructionContext.userDatabase()

voterInputDatabase

@Warning(value="thread restricted object")
public Database voterInputDatabase()
The database of voter input for all voter services.

See Also:
VoterInputTable, Pollserver.ConstructionContext.voterInputDatabase()

voterService

public VoterService voterService(String name)
Returns a voter service provided in this run.

Parameters:
name - per VoterService.name()
See Also:
init_ensureVoterService(File,Class), init_putVoterService(VoterService), newVoterServiceArray(), Poll.PollserverScope.Run.districtDivisionalChildren(String)

Votorola