Class HubClusterId
java.lang.Object
com.iizix.server.hub.HubClusterId
The shared-DB identity of a hub,
HUB-DESIGN.md section 2.3: one row of HUB.CLUSTER per hub holding a random UUID. The first eligible member to start on an empty HUB schema inserts it (ensure(String), called by the hub module after it created the tables); every member reads it from ITS OWN connection pool (read(String)) and reports the UUID at registration, so that two pools that return the same row are the same database - a measurement, not a configuration flag. A member whose database has no HUB schema, or no row, reports an empty db: a local-DB member, never in a transfer and never principal.- Author:
- Christopher Mindus
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe qualified table: "HUB.CLUSTER".static final StringThe SQLState of a unique-key violation on Derby and PostgreSQL ("23505") and on MySQL ("23000"): the other writer committed first.static final StringThe SQLState of a unique-key violation on Derby and PostgreSQL ("23505") and on MySQL ("23000"): the other writer committed first.Method Summary
Modifier and TypeMethodDescriptionstatic StringInserts the hub's row with a random UUID when there is none, on this server's own pool: the first eligible member wins the race, the other reads the winner's row.static Stringensure(Connection conn, String hubName) Inserts the hub's row with a random UUID when there is none, on a connection that is committed or rolled back here.static StringReads the hub's cluster UUID from this server's own connection pool.static Stringread(Connection conn, String hubName) Reads the hub's cluster UUID on a connection.
Field Details
TABLE
UNIQUE_VIOLATION
UNIQUE_VIOLATION_MYSQL
Method Details
read
Reads the hub's cluster UUID from this server's own connection pool.- Parameters:
hubName- The hub's name, the key of the row.- Returns:
- The UUID, or null when the database holds no
HUBschema, no row, or cannot be reached (logged at FINE: a member without the hub module has no schema).
read
Reads the hub's cluster UUID on a connection.- Parameters:
conn- The connection.hubName- The hub's name.- Returns:
- The UUID, or null for no row.
- Throws:
SQLException- For SQL errors, e.g. noHUBschema.
ensure
Inserts the hub's row with a random UUID when there is none, on this server's own pool: the first eligible member wins the race, the other reads the winner's row.- Parameters:
hubName- The hub's name.- Returns:
- The UUID in the database after the call.
- Throws:
SQLException- For SQL errors.
ensure
Inserts the hub's row with a random UUID when there is none, on a connection that is committed or rolled back here.- Parameters:
conn- The connection.hubName- The hub's name.- Returns:
- The UUID in the database after the call.
- Throws:
SQLException- For SQL errors.