Package gov.usgs.earthquake.aws
Class TrackingIndex
java.lang.Object
gov.usgs.util.DefaultConfigurable
gov.usgs.earthquake.util.JDBCConnection
gov.usgs.earthquake.aws.TrackingIndex
- All Implemented Interfaces:
Configurable,AutoCloseable
Tracking index stores component state in a database.
Only SQLITE or local development should rely on createSchema.
Mysql Schema Example:
CREATE TABLE IF NOT EXISTS tracking_index (id INTEGER PRIMARY KEY AUTO_INCREMENT , created VARCHAR(255) , name VARCHAR(255) , data LONGTEXT , UNIQUE KEY name_index (name) ) ENGINE=innodb CHARSET=utf8;
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringVariable for the default driverstatic final StringVariable for the default tablestatic final StringVariable for the default URLFields inherited from class gov.usgs.earthquake.util.JDBCConnection
DATABASE_SECRET_ARN_PROPERTY -
Constructor Summary
ConstructorsConstructorDescriptionConstruct a TrackingIndex using defaults.TrackingIndex(String driver, String url) Construct a TrackingIndex with the default table.TrackingIndex(String driver, String url, String table) Construct a TrackingIndex with custom driver, url, and table. -
Method Summary
Modifier and TypeMethodDescriptionvoidImplement ConfigurablevoidAttempt to create schema.getTable()javax.json.JsonObjectgetTrackingData(String name) Get tracking data for specified name.voidremoveTrackingData(String name) Remove tracking data.booleanCheck whether schema exists.voidvoidsetTrackingData(String name, javax.json.JsonObject data) Add or update tracking data.voidstartup()After normal startup, check whether schema exists and attempt to create.Methods inherited from class gov.usgs.earthquake.util.JDBCConnection
beginTransaction, buildUrl, close, commitTransaction, connect, getConnection, getDriver, getUrl, rollbackTransaction, setDriver, setUrl, shutdown, verifyConnectionMethods inherited from class gov.usgs.util.DefaultConfigurable
getName, setName
-
Field Details
-
DEFAULT_DRIVER
Variable for the default driver- See Also:
-
DEFAULT_TABLE
Variable for the default table- See Also:
-
DEFAULT_URL
Variable for the default URL- See Also:
-
-
Constructor Details
-
TrackingIndex
public TrackingIndex()Construct a TrackingIndex using defaults. -
TrackingIndex
Construct a TrackingIndex with the default table.- Parameters:
driver- Driver to useurl- URL to use
-
TrackingIndex
Construct a TrackingIndex with custom driver, url, and table.- Parameters:
driver- Driver to useurl- URL to usetable- Table to use
-
-
Method Details
-
getTable
- Returns:
- table
-
setTable
- Parameters:
table- Table to set
-
configure
Description copied from class:JDBCConnectionImplement Configurable- Specified by:
configurein interfaceConfigurable- Overrides:
configurein classJDBCConnection- Parameters:
config- Config to set driver and URL in- Throws:
Exception- Exception
-
startup
After normal startup, check whether schema exists and attempt to create.- Specified by:
startupin interfaceConfigurable- Overrides:
startupin classJDBCConnection- Throws:
Exception- if error occurs
-
schemaExists
Check whether schema exists.- Returns:
- boolean
- Throws:
Exception- if error occurs
-
createSchema
Attempt to create schema. Only supports sqlite or mysql. When not using sqlite, relying on this method is only recommended for local development.- Throws:
Exception- if error occurs
-
getTrackingData
Get tracking data for specified name.- Parameters:
name- name of tracking data.- Returns:
- null if data not found.
- Throws:
Exception- if error occurs
-
removeTrackingData
Remove tracking data.- Parameters:
name- name of tracking data.- Throws:
Exception- if error occurs
-
setTrackingData
Add or update tracking data.- Parameters:
name- name of tracking data.data- data to store.- Throws:
Exception- if error occurs
-