public class DerbySchemaHandler extends Object implements SchemaHandler
Schema handler for Derby Database. This handler uses the following schema:
FL_EVENT: The main event table. This table contains an auto-generated event ID along with the first 16kb of payload data. If the payload is larger than 16kb, a spill indicator flag is set and the remaining data is recorded in the FL_PLSPILL table.
+-------------------------------+ | FL_EVENT | +-------------------------------+ | FLE_ID : BIGINT PK | (auto-gen sequence) | FLE_PAYLOAD: VARBINARY(16384) | (16kb payload) | FLE_SPILL : BOOLEAN | (true if payload spills) | FLE_CHANNEL: VARCHAR(64) | +-------------------------------+
FL_PLSPILL: This table holds payloads in excess of 16kb and relates back to the FL_EVENT table using foreign key reference via FLP_EVENT column.
+---------------------+ | FL_PLSPILL | +---------------------+ | FLP_EVENT : BIGINT | (FK into FL_EVENT.FLE_ID) | FLP_SPILL : BLOB | +---------------------+
FL_HEADER: The table that holds headers. This table contains name value pairs of headers less than or up to first 255 bytes each. If a name is longer than 255 bytes, a spill indicator flag is set and the remaining bytes are recorded in FL_NMSPILL table. Similarly if the value is longer than 255 bytes, a spill indicator flag is set and the remaining bytes are recorded in FL_VLSPILL table. Each header record relates back to the FL_EVENT table using foreign key reference via FLH_EVENT column.
+--------------------------+ | FL_HEADER | +--------------------------+ | FLH_ID : BIGINT PK | (auto-gen sequence) | FLH_EVENT : BIGINT | (FK into FL_EVENT.FLE_ID) | FLH_NAME : VARCHAR(251)| | FLH_VALUE : VARCHAR(251)| | FLH_NMSPILL: BOOLEAN | (true if name spills) | FLH_VLSPILL: BOOLEAN | (true if value spills) +--------------------------+
FL_NMSPILL: The table that holds header names in excess of 255 bytes and relates back to the FL_HEADER table using foreign key reference via FLN_HEADER column.
+----------------------+ | FL_NMSPILL | +----------------------+ | FLN_HEADER : BIGINT | (FK into FL_HEADER.FLH_ID) | FLN_SPILL : CLOB | +----------------------+
FL_VLSPILL: The table that holds header values in excess of 255 bytes and relates back to the FL_HEADER table using foreign key reference via FLV_HEADER column.
+----------------------+ | FL_VLSPILL | +----------------------+ | FLV_HEADER : BIGINT | (FK into FL_HEADER.FLH_ID) | FLV_SPILL : CLOB | +----------------------+
NOTE: The values that decide the spill boundary and storage length limits are defined in ConfigurationConstants class.
ConfigurationConstants| Modifier | Constructor and Description |
|---|---|
protected |
DerbySchemaHandler(DataSource dataSource) |
| Modifier and Type | Method and Description |
|---|---|
void |
createSchemaObjects(boolean createForeignKeys,
boolean createIndex)
Creates the schema.
|
PersistableEvent |
fetchAndDeleteEvent(String channel,
Connection connection)
Retrieves the next persistent event from the database.
|
long |
getChannelSize(Connection connection)
Returns the current size of the channel using the connection specified that
must have an active transaction ongoing.
|
boolean |
schemaExists() |
void |
storeEvent(PersistableEvent pe,
Connection connection)
Inserts the given persistent event into the database.
|
void |
validateSchema()
Validates the schema.
|
public static final String QUERY_CREATE_SCHEMA_FLUME
public static final String QUERY_CREATE_TABLE_FL_EVENT
public static final String QUERY_CREATE_INDEX_FLE_CHANNEL
public static final String QUERY_CREATE_TABLE_FL_PLSPILL_FMT
public static final String QUERY_CREATE_TABLE_FL_PLSPILL_FK
public static final String QUERY_CREATE_TABLE_FL_PLSPILL_NOFK
public static final String QUERY_CREATE_INDEX_FLP_EVENT
public static final String QUERY_CREATE_TABLE_FL_HEADER_FMT
public static final String QUERY_CREATE_TABLE_FL_HEADER_FK
public static final String QUERY_CREATE_TABLE_FL_HEADER_NOFK
public static final String QUERY_CREATE_INDEX_FLH_EVENT
public static final String QUERY_CREATE_TABLE_FL_NMSPILL_FMT
public static final String QUERY_CREATE_TABLE_FL_NMSPILL_FK
public static final String QUERY_CREATE_TABLE_FL_NMSPILL_NOFK
public static final String QUERY_CREATE_INDEX_FLN_HEADER
public static final String QUERY_CREATE_TABLE_FL_VLSPILL_FMT
public static final String QUERY_CREATE_TABLE_FL_VLSPILL_FK
public static final String QUERY_CREATE_TABLE_FL_VLSPILL_NOFK
public static final String QUERY_CREATE_INDEX_FLV_HEADER
public static final String COLUMN_LOOKUP_QUERY
public static final String QUERY_CHANNEL_SIZE
public static final String STMT_INSERT_EVENT_BASE
public static final String STMT_INSERT_EVENT_SPILL
public static final String STMT_INSERT_HEADER_BASE
public static final String STMT_INSERT_HEADER_NAME_SPILL
public static final String STMT_INSERT_HEADER_VALUE_SPILL
public static final String STMT_FETCH_PAYLOAD_BASE
public static final String STMT_FETCH_PAYLOAD_SPILL
public static final String STMT_FETCH_HEADER_BASE
public static final String STMT_FETCH_HEADER_NAME_SPILL
public static final String STMT_FETCH_HEADER_VALUE_SPILL
public static final String STMT_DELETE_HEADER_VALUE_SPILL
public static final String STMT_DELETE_HEADER_NAME_SPILL
public static final String STMT_DELETE_EVENT_SPILL
public static final String STMT_DELETE_HEADER_BASE
public static final String STMT_DELETE_EVENT_BASE
protected DerbySchemaHandler(DataSource dataSource)
public boolean schemaExists()
schemaExists in interface SchemaHandlerpublic void createSchemaObjects(boolean createForeignKeys,
boolean createIndex)
SchemaHandlercreateSchemaObjects in interface SchemaHandlercreateForeignKeys - a flag which indicates if the foreign key
constraints should be created where necessary.createIndex - a flag which indicates if indexes must be created during
the creation of the schema.public void validateSchema()
SchemaHandlervalidateSchema in interface SchemaHandlerpublic void storeEvent(PersistableEvent pe, Connection connection)
SchemaHandlerstoreEvent in interface SchemaHandlerpe - the event to persistconnection - the connection to usepublic PersistableEvent fetchAndDeleteEvent(String channel, Connection connection)
SchemaHandlerfetchAndDeleteEvent in interface SchemaHandlerchannel - the channel name from which event will be retrievedconnection - the connection to usepublic long getChannelSize(Connection connection)
SchemaHandlergetChannelSize in interface SchemaHandlerCopyright © 2009-2022 Apache Software Foundation. All Rights Reserved.