public interface DbAdapter extends Serializable
Modifier and Type | Method and Description |
---|---|
void |
cleanupFailedCheckpoints(String stateId,
Connection con,
long checkpointTimestamp,
long recoveryTimestamp)
Clean up states between the checkpoint and recovery timestamp.
|
void |
compactKvStates(String kvStateId,
Connection con,
long lowerTs,
long upperTs)
Compact the states between two checkpoint timestamp by only keeping the
most recent.
|
void |
createCheckpointsTable(String jobId,
Connection con)
Initialize tables for storing non-partitioned checkpoints for the given
job id and database connection.
|
void |
createKVStateTable(String stateId,
Connection con)
Initialize the necessary tables for the given stateId.
|
void |
deleteCheckpoint(String jobId,
Connection con,
long checkpointId,
long checkpointTs,
long handleId)
Remove the given checkpoint from the database.
|
void |
disposeAllStateForJob(String jobId,
Connection con)
Remove all states for the given
JobID ,
by for instance dropping the entire table. |
byte[] |
getCheckpoint(String jobId,
Connection con,
long checkpointId,
long checkpointTs,
long handleId)
Retrieve the serialized checkpoint data from the database.
|
void |
insertBatch(String stateId,
DbBackendConfig conf,
Connection con,
PreparedStatement insertStatement,
long checkpointTimestamp,
List<Tuple2<byte[],byte[]>> toInsert)
Insert a list of Key-Value pairs into the database.
|
void |
keepAlive(Connection con)
Execute a simple operation to refresh the current database connection in
case no data is written for a longer time period.
|
byte[] |
lookupKey(String stateId,
PreparedStatement lookupStatement,
byte[] key,
long lookupId)
Retrieve the latest value from the database for a given key and
timestamp.
|
PreparedStatement |
prepareCheckpointInsert(String jobId,
Connection con)
Checkpoints will be inserted in the database using prepared statements.
|
String |
prepareKeyLookup(String stateId)
Prepare the statement that will be used to lookup keys from the database.
|
String |
prepareKVCheckpointInsert(String stateId)
Prepare the the statement that will be used to insert key-value pairs in
the database.
|
void |
setCheckpointInsertParams(String jobId,
PreparedStatement insertStatement,
long checkpointId,
long timestamp,
long handleId,
byte[] checkpoint)
Set the
PreparedStatement parameters for the statement returned
by prepareCheckpointInsert(String, Connection) . |
void createCheckpointsTable(String jobId, Connection con) throws SQLException
SQLException
PreparedStatement prepareCheckpointInsert(String jobId, Connection con) throws SQLException
SQLException
void setCheckpointInsertParams(String jobId, PreparedStatement insertStatement, long checkpointId, long timestamp, long handleId, byte[] checkpoint) throws SQLException
PreparedStatement
parameters for the statement returned
by prepareCheckpointInsert(String, Connection)
.jobId
- Id of the current job.insertStatement
- Statement returned by
prepareCheckpointInsert(String, Connection)
.checkpointId
- Global checkpoint id.timestamp
- Global checkpoint timestamp.handleId
- Unique id assigned to this state checkpoint (should be primary
key).checkpoint
- The serialized checkpoint.SQLException
byte[] getCheckpoint(String jobId, Connection con, long checkpointId, long checkpointTs, long handleId) throws SQLException
jobId
- Id of the current job.con
- Database connectioncheckpointId
- Global checkpoint id.checkpointTs
- Global checkpoint timestamp.handleId
- Unique id assigned to this state checkpoint (should be primary
key).SQLException
void deleteCheckpoint(String jobId, Connection con, long checkpointId, long checkpointTs, long handleId) throws SQLException
jobId
- Id of the current job.con
- Database connectioncheckpointId
- Global checkpoint id.checkpointTs
- Global checkpoint timestamp.handleId
- Unique id assigned to this state checkpoint (should be primary
key).SQLException
void disposeAllStateForJob(String jobId, Connection con) throws SQLException
JobID
,
by for instance dropping the entire table.SQLException
void createKVStateTable(String stateId, Connection con) throws SQLException
SQLException
String prepareKVCheckpointInsert(String stateId) throws SQLException
SQLException
String prepareKeyLookup(String stateId) throws SQLException
SQLException
byte[] lookupKey(String stateId, PreparedStatement lookupStatement, byte[] key, long lookupId) throws SQLException
stateId
- Unique identifier of the kvstate (usually the table name).lookupStatement
- The statement returned by
#prepareKeyLookup(String, Connection)
.key
- The key to lookup.SQLException
void cleanupFailedCheckpoints(String stateId, Connection con, long checkpointTimestamp, long recoveryTimestamp) throws SQLException
SQLException
void insertBatch(String stateId, DbBackendConfig conf, Connection con, PreparedStatement insertStatement, long checkpointTimestamp, List<Tuple2<byte[],byte[]>> toInsert) throws IOException
IOException
void compactKvStates(String kvStateId, Connection con, long lowerTs, long upperTs) throws SQLException
SQLException
void keepAlive(Connection con) throws SQLException
SQLException
Copyright © 2014–2017 The Apache Software Foundation. All rights reserved.