Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ public RepairUnit load(UUID repairUnitId) throws Exception {

/* prepared stmts */
private PreparedStatement insertClusterPrepStmt;
private PreparedStatement updateClusterPrepStmt;
private PreparedStatement getClusterPrepStmt;
private PreparedStatement deleteClusterPrepStmt;
private PreparedStatement insertRepairRunPrepStmt;
Expand Down Expand Up @@ -323,6 +324,11 @@ private void prepareStatements() {
"INSERT INTO cluster(name, partitioner, seed_hosts, properties, state, last_contact)"
+ " values(?, ?, ?, ?, ?, ?)")
.setConsistencyLevel(ConsistencyLevel.QUORUM);
updateClusterPrepStmt = session
.prepare(
"INSERT INTO cluster(name, seed_hosts, state, last_contact)"
+ " values(?, ?, ?, ?)")
.setConsistencyLevel(ConsistencyLevel.LOCAL_ONE);
getClusterPrepStmt = session
.prepare("SELECT * FROM cluster WHERE name = ?")
.setConsistencyLevel(ConsistencyLevel.QUORUM)
Expand Down Expand Up @@ -547,7 +553,18 @@ public boolean addCluster(Cluster cluster) {

@Override
public boolean updateCluster(Cluster newCluster) {
return addCluster(newCluster);
try {
session.execute(
updateClusterPrepStmt.bind(
newCluster.getName(),
newCluster.getSeedHosts(),
newCluster.getState().name(),
java.sql.Date.valueOf(newCluster.getLastContact())));
} catch (RuntimeException e) {
LOG.error("Failed updating cluster", e);
throw new IllegalStateException(e);
}
return true;
}

private boolean addClusterAssertions(Cluster cluster) {
Expand Down