public class RdbmsCoordinationDaoImpl extends Object
| Constructor and Description |
|---|
RdbmsCoordinationDaoImpl(DataSource datasource)
Default constructor which uses the provided datasource.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
checkIfCoordinatorValid(int age)
Check if the coordinator is invalid using the heart beat value.
|
boolean |
checkIsCoordinator(String nodeId)
Check if the given node is the coordinator.
|
protected void |
close(Connection connection,
String task)
Closes the provided connection, on failure logs the error.
|
protected void |
close(PreparedStatement preparedStatement,
String task)
Close the prepared statement resource.
|
protected void |
close(ResultSet resultSet,
String task)
Close the result set resource.
|
boolean |
createCoordinatorEntry(String nodeId)
Method to create coordinator entry (i.e - make this node the coordinator).
|
void |
createNodeHeartbeatEntry(String nodeId)
Method to create the node heartbeat entry.
|
List<NodeHeartbeatData> |
getAllHeartBeatData()
Get node heart beat status for all the existing nodes.
|
protected Connection |
getConnection()
Create a connection using a thread pooled data source object and return the connection.
|
String |
getCoordinatorNodeId()
Retrieve the current coordinator's node ID.
|
void |
markNodeAsNotNew(String nodeId)
Method to indicate that the coordinator detected a node addition.
|
void |
removeCoordinator()
Remove current coordinator entry from database.
|
void |
removeNodeHeartbeat(String nodeId)
Remove heartbeat entry for the given node.
|
protected void |
rollback(Connection connection,
String task)
On database update failure try to rollback.
|
boolean |
updateCoordinatorHeartbeat(String nodeId)
Update coordinator heartbeat value to current time.
|
boolean |
updateNodeHeartbeat(String nodeId)
Method to update the node heartbeat value to the current time.
|
public RdbmsCoordinationDaoImpl(DataSource datasource)
datasource - the datasource to usepublic void removeNodeHeartbeat(String nodeId) throws CoordinationException
nodeId - local node IDCoordinationException - if an error occurs while removing the node heartbeat entry (mostly due to a DB
error)public List<NodeHeartbeatData> getAllHeartBeatData() throws CoordinationException
CoordinationException - if an error is detected while calling the store (mostly due to a DB error)public String getCoordinatorNodeId() throws CoordinationException
CoordinationException - if an error is detected while retrieving the node ID of the coordinatorpublic void removeCoordinator()
throws CoordinationException
CoordinationException - if an error is detected while removing the coordinator entry.public boolean checkIfCoordinatorValid(int age)
throws CoordinationException
age - maximum relative age with respect to the current time in milliseconds.CoordinationException - if an error occurs checking if the coordinator is valid.public boolean updateNodeHeartbeat(String nodeId) throws CoordinationException
nodeId - local node IDCoordinationException - if an error is detected while updating the node heartbeat.public void createNodeHeartbeatEntry(String nodeId) throws CoordinationException
nodeId - local node IDCoordinationException - if an error is detected while creating the node heartbeat entry.public boolean updateCoordinatorHeartbeat(String nodeId) throws CoordinationException
nodeId - local node IDCoordinationException - if an error is detected while updating the coordinator heartbeat.public void markNodeAsNotNew(String nodeId) throws CoordinationException
nodeId - local node IDCoordinationException - if an error is detected while marking the node as not new.public boolean createCoordinatorEntry(String nodeId) throws CoordinationException
nodeId - local node IDCoordinationException - if an error is detected while creating the coordinator entrypublic boolean checkIsCoordinator(String nodeId) throws CoordinationException
nodeId - local node IDCoordinationException - if an error is detected while checking if coordinatorprotected Connection getConnection() throws SQLException
SQLException - if an error occurs with database accessprotected void close(ResultSet resultSet, String task)
resultSet - the ResultSettask - the task that was done by the closed result setprotected void close(PreparedStatement preparedStatement, String task)
preparedStatement - the PreparedStatementtask - the task that was done by the closed prepared statementprotected void close(Connection connection, String task)
connection - the Connectiontask - the task that was done before closingprotected void rollback(Connection connection, String task)
connection - the database connectiontask - the task that was being doneCopyright © 2018 WSO2. All rights reserved.