Class TrackingIndex

All Implemented Interfaces:
Configurable, AutoCloseable

public class TrackingIndex extends JDBCConnection
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 Details

  • Constructor Details

    • TrackingIndex

      public TrackingIndex()
      Construct a TrackingIndex using defaults.
    • TrackingIndex

      public TrackingIndex(String driver, String url)
      Construct a TrackingIndex with the default table.
      Parameters:
      driver - Driver to use
      url - URL to use
    • TrackingIndex

      public TrackingIndex(String driver, String url, String table)
      Construct a TrackingIndex with custom driver, url, and table.
      Parameters:
      driver - Driver to use
      url - URL to use
      table - Table to use
  • Method Details

    • getTable

      public String getTable()
      Returns:
      table
    • setTable

      public void setTable(String table)
      Parameters:
      table - Table to set
    • configure

      public void configure(Config config) throws Exception
      Description copied from class: JDBCConnection
      Implement Configurable
      Specified by:
      configure in interface Configurable
      Overrides:
      configure in class JDBCConnection
      Parameters:
      config - Config to set driver and URL in
      Throws:
      Exception - Exception
    • startup

      public void startup() throws Exception
      After normal startup, check whether schema exists and attempt to create.
      Specified by:
      startup in interface Configurable
      Overrides:
      startup in class JDBCConnection
      Throws:
      Exception - if error occurs
    • schemaExists

      public boolean schemaExists() throws Exception
      Check whether schema exists.
      Returns:
      boolean
      Throws:
      Exception - if error occurs
    • createSchema

      public void createSchema() throws Exception
      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

      public javax.json.JsonObject getTrackingData(String name) throws Exception
      Get tracking data for specified name.
      Parameters:
      name - name of tracking data.
      Returns:
      null if data not found.
      Throws:
      Exception - if error occurs
    • removeTrackingData

      public void removeTrackingData(String name) throws Exception
      Remove tracking data.
      Parameters:
      name - name of tracking data.
      Throws:
      Exception - if error occurs
    • setTrackingData

      public void setTrackingData(String name, javax.json.JsonObject data) throws Exception
      Add or update tracking data.
      Parameters:
      name - name of tracking data.
      data - data to store.
      Throws:
      Exception - if error occurs