Class DBLoadBalancer

java.lang.Object
com.iizix.server.loadbalancer.db.DBLoadBalancer

public class DBLoadBalancer extends Object
Class containing the database functions for the Load Balancer: the hub schema HUB of HUB-DESIGN.md section 5.1, created from createHubTables.sql beside this class.
Author:
Christopher Mindus
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    The table probed to tell whether the schema has been created: the LAST table the script creates, so that a script that died halfway is run again (as createBaseTables.sql is probed by its last table).
    static final String
    The schema of the hub tables.
    static final String
    The name of the SQL script beside this class.
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    Creates the hub tables (schema HUB) if required, on a pooled connection.
    static boolean
    Creates the hub tables (schema HUB) if required, on the connection given, which is committed when they are created.
    static String
    Gets the class-loader resource name of the SQL script.
    static void
    recordMember(String hubName, String memberID, String run, String url, String build, String state)
    Records a member's state in HUB.MEMBERS, informationally (HUB-DESIGN.md 2.4, R-3): the member's row is updated, or inserted when there is none.
  • Field Details

    • SCHEMA

      public static final String SCHEMA
      The schema of the hub tables.
      See Also:
    • PROBE_TABLE

      public static final String PROBE_TABLE
      The table probed to tell whether the schema has been created: the LAST table the script creates, so that a script that died halfway is run again (as createBaseTables.sql is probed by its last table).
      See Also:
    • SCRIPT

      public static final String SCRIPT
      The name of the SQL script beside this class.
      See Also:
  • Method Details

    • getScriptResource

      public static String getScriptResource()
      Gets the class-loader resource name of the SQL script.
      Returns:
      The resource name, e.g. com/iizix/server/loadbalancer/db/createHubTables.sql.
    • recordMember

      public static void recordMember(String hubName, String memberID, String run, String url, String build, String state)
      Records a member's state in HUB.MEMBERS, informationally (HUB-DESIGN.md 2.4, R-3): the member's row is updated, or inserted when there is none. A failure is logged at WARNING and changes nothing: the member table is the principal's memory, not this table.
      Parameters:
      hubName - The hub.
      memberID - The member.
      run - Its run.
      url - Its URL.
      build - Its build.
      state - The state: admitted, gone, or refused: and the reason.
    • createTables

      public static boolean createTables() throws SQLException
      Creates the hub tables (schema HUB) if required, on a pooled connection.
      Returns:
      true if they were created, false otherwise.
      Throws:
      SQLException - For SQL errors.
    • createTables

      public static boolean createTables(Connection conn) throws SQLException
      Creates the hub tables (schema HUB) if required, on the connection given, which is committed when they are created.
      Parameters:
      conn - The connection.
      Returns:
      true if they were created, false otherwise.
      Throws:
      SQLException - For SQL errors.