UnetC3 database agent base class.
Modifiers | Name | Description |
---|---|---|
protected String |
DBPASSWORD |
Password for the database connection. |
protected String |
DBURL |
Database connection URL. |
protected String |
DBUSERNAME |
Username for the database connection. |
static String |
DEFAULT_DBPASSWORD |
|
static String |
DEFAULT_DBURL |
Default database URL for all DBAgents. |
static String |
DEFAULT_DBUSERNAME |
|
protected ExecutorService |
executor |
Executor to process blocking operations. |
Fields inherited from class | Fields |
---|---|
class Agent |
NON_BLOCKING, BLOCKING |
Type Params | Return Type | Name and description |
---|---|---|
<T> |
protected Future<T> |
async(Callable<T> task) Runs a long-running task asynchronously in a non-agent thread. |
|
protected Future<?> |
async(Runnable task) Runs a long-running task asynchronously in a non-agent thread. |
|
protected Connection |
connect() Gets a connection to the database. |
|
protected String |
getBuildInfo() Gets the build string for a given class. |
|
protected void |
init() Initialize the C3 database agent and its behaviors. |
|
protected void |
processMessage(Message msg) An agent wishing to process all messages other than requests and queries may override this method to handle incoming messages. |
|
protected boolean |
processRequest(Message msg) An agent supporting requests should override this method to handle incoming requests. |
|
protected void |
setup() Called by DBAgent when the agent is being initialized. |
|
protected void |
shutdown() |
|
protected void |
startup() Called by DBAgent after all agents are fully initialized. |
|
protected void |
subscribeForService(String service) Subscribe to all agents providing a specified service. |
|
protected void |
subscribeForService(Enum<?> service) Subscribe to all agents providing a specified service. |
|
protected boolean |
tableExists(String table) Checks if a table exists in the database. |
|
protected void |
unsubscribeForService(String service) Unsubscribe from all agents providing a specified service. |
|
protected void |
unsubscribeForService(Enum<?> service) Unsubscribe from all agents providing a specified service. |
Methods inherited from class | Name |
---|---|
class Agent |
send, receive, receive, receive, receive, receive, receive, receive, receive, setLogLevel, getPlatform, request, request, getStore, subscribe, deregister, deregister, getContainer, println, run, add, toString, register, register, clone, currentTimeMillis, nanoTime, getName, stop, getState, getAgentID, prepareRequest, platformSend, setQueueSize, unsubscribe, agentForService, agentForService, agentsForService, agentsForService, topic, topic, topic, topic, topic, topic, agent, wake, wait, wait, wait, equals, hashCode, getClass, notify, notifyAll |
Password for the database connection.
Database connection URL. This may be modified by an agent at construction. The database connection is established just before setup, using this URL.
Username for the database connection.
Default database URL for all DBAgents. This may be setup in the initrc or equivalent as a global default. If an agent does not set DBURL at construction, this URL is used for a database connection just before setup.
Executor to process blocking operations. This may be created by an agent during setup, or is automatically defaulted to use SingleThreadExecutor at first use. The executor should not be directly used, but instead via the async() method.
Runs a long-running task asynchronously in a non-agent thread.
task
- task to runRuns a long-running task asynchronously in a non-agent thread.
task
- task to runGets a connection to the database.
Gets the build string for a given class. The build information is extracted from the jar is available.
Initialize the C3 database agent and its behaviors.
An agent wishing to process all messages other than requests and queries may override this method to handle incoming messages. This method should not block for any substantial amount of time. If any operation requires waiting, it may be spawned off to a separate thread using the executor service, or triggered on the agent's thread later using a behavior.
msg
- incoming message.An agent supporting requests should override this method to handle incoming requests. This method should not block for any substantial amount of time. If any operation requires waiting, it may be spawned off to a separate thread using the executor service, or triggered on the agent's thread later using a behavior.
msg
- incoming request.Called by DBAgent when the agent is being initialized.
Called by DBAgent after all agents are fully initialized.
Subscribe to all agents providing a specified service.
service
- name of the serviceSubscribe to all agents providing a specified service.
service
- name of the serviceChecks if a table exists in the database.
table
- name of the tableUnsubscribe from all agents providing a specified service.
service
- name of the serviceUnsubscribe from all agents providing a specified service.
service
- name of the service