Skip to content

Commit

Permalink
Display available repair metrics in the UI
Browse files Browse the repository at this point in the history
  • Loading branch information
adejanovski committed Dec 2, 2019
1 parent b074623 commit da5a058
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 9 deletions.
Expand Up @@ -109,6 +109,10 @@ public final class RepairRunStatus {
@JsonProperty("repair_thread_count")
private int repairThreadCount;

@JsonProperty("repair_unit_id")
private UUID repairUnitId;


/**
* Default public constructor Required for Jackson JSON parsing.
*/
Expand Down Expand Up @@ -136,7 +140,8 @@ public RepairRunStatus(
Collection<String> nodes,
Collection<String> datacenters,
Collection<String> blacklistedTables,
int repairThreadCount) {
int repairThreadCount,
UUID repairUnitId) {

this.id = runId;
this.cause = cause;
Expand Down Expand Up @@ -194,6 +199,8 @@ public RepairRunStatus(
estimatedTimeOfArrival = new DateTime(now + millisecondsPerSegment * segmentsLeft);
}
}

this.repairUnitId = repairUnitId;
}

public RepairRunStatus(RepairRun repairRun, RepairUnit repairUnit, int segmentsRepaired) {
Expand All @@ -218,7 +225,8 @@ public RepairRunStatus(RepairRun repairRun, RepairUnit repairUnit, int segmentsR
repairUnit.getNodes(),
repairUnit.getDatacenters(),
repairUnit.getBlacklistedTables(),
repairUnit.getRepairThreadCount());
repairUnit.getRepairThreadCount(),
repairRun.getRepairUnitId());
}

@JsonProperty("creation_time")
Expand Down Expand Up @@ -487,4 +495,13 @@ static double roundDoubleNicely(double intensity) {
public static String dateTimeToIso8601(@Nullable DateTime dateTime) {
return null != dateTime ? ISODateTimeFormat.dateTimeNoMillis().print(dateTime) : null;
}

public UUID getRepairUnitId() {
return repairUnitId;
}

public void setRepairUnitId(UUID repairUnitId) {
this.repairUnitId = repairUnitId;
}

}
Expand Up @@ -497,7 +497,8 @@ public Collection<RepairRunStatus> getClusterRunStatuses(String clusterName, int
unit.getNodes(),
unit.getDatacenters(),
unit.getBlacklistedTables(),
unit.getRepairThreadCount()));
unit.getRepairThreadCount(),
unit.getId()));
}
return runStatuses;
}
Expand Down
Expand Up @@ -210,7 +210,7 @@ public interface IStoragePostgreSql {
// View-specific queries
//
String SQL_CLUSTER_RUN_OVERVIEW = "SELECT repair_run.id, repair_unit.cluster_name, keyspace_name, column_families, "
+ "nodes, datacenters, blacklisted_tables, "
+ "nodes, datacenters, blacklisted_tables, repair_run.repair_unit_id, "
+ "(SELECT COUNT(case when state = 2 then 1 else null end) "
+ "FROM repair_segment "
+ "WHERE run_id = repair_run.id) AS segments_repaired, "
Expand Down
Expand Up @@ -36,6 +36,7 @@ public final class RepairRunStatusMapper implements ResultSetMapper<RepairRunSta
@Override
public RepairRunStatus map(int index, ResultSet rs, StatementContext ctx) throws SQLException {
long runId = rs.getLong("id");
long unitId = rs.getLong("repair_unit_id");
String clusterName = rs.getString("cluster_name");
String keyspaceName = rs.getString("keyspace_name");

Expand Down Expand Up @@ -98,6 +99,7 @@ public RepairRunStatus map(int index, ResultSet rs, StatementContext ctx) throws
nodes,
datacenters,
blacklistedTables,
repairThreadCount);
repairThreadCount,
UuidUtil.fromSequenceId(unitId));
}
}
Expand Up @@ -78,7 +78,8 @@ public void testRunningRepairDuration() {
Collections.EMPTY_LIST, // nodes
Collections.EMPTY_LIST, // datacenters
Collections.EMPTY_LIST, // blacklist
1); // repair thread count
1,
UUID.randomUUID()); // repair thread count

assertEquals("1 minute 0 seconds", repairStatus.getDuration());
}
Expand Down Expand Up @@ -106,7 +107,8 @@ public void testFinishedRepairDuration() {
Collections.EMPTY_LIST, // nodes
Collections.EMPTY_LIST, // datacenters
Collections.EMPTY_LIST, // blacklist
1); // repair thread count
1,
UUID.randomUUID()); // repair thread count

assertEquals("1 minute 30 seconds", repairStatus.getDuration());
}
Expand Down Expand Up @@ -134,7 +136,8 @@ public void testPausedRepairDuration() {
Collections.EMPTY_LIST, // nodes
Collections.EMPTY_LIST, // datacenters
Collections.EMPTY_LIST, // blacklist
1); // repair thread count
1,
UUID.randomUUID()); // repair thread count

assertEquals("1 minute 50 seconds", repairStatus.getDuration());
}
Expand Down Expand Up @@ -162,7 +165,8 @@ public void testAbortedRepairDuration() {
Collections.EMPTY_LIST, // nodes
Collections.EMPTY_LIST, // datacenters
Collections.EMPTY_LIST, // blacklist
1); // repair thread count
1,
UUID.randomUUID()); // repair thread count

assertEquals("1 minute 30 seconds", repairStatus.getDuration());
}
Expand Down
12 changes: 12 additions & 0 deletions src/ui/app/jsx/repair-list.jsx
Expand Up @@ -156,6 +156,14 @@ const TableRowDetails = React.createClass({
placeholder="repair intensity" />;
}

var metrics = ["io.cassandrareaper.service.RepairRunner.repairProgress", "io.cassandrareaper.service.RepairRunner.segmentsDone",
"io.cassandrareaper.service.RepairRunner.segmentsTotal", "io.cassandrareaper.service.RepairRunner.millisSinceLastRepair"];
let cleanupRegex = /[^A-Za-z0-9]/mg
let availableMetrics = metrics.map(metric => <div key={metric + this.props.row.repair_unit_id}>
{metric + "."
+ this.props.row.cluster_name.replace(cleanupRegex, "") + "."
+ this.props.row.keyspace_name.replace(cleanupRegex, "") + "."
+ this.props.row.repair_unit_id.replace(cleanupRegex, "")}</div>)
return (
<tr id={rowID} className="collapse out">
<td colSpan="7">
Expand Down Expand Up @@ -233,6 +241,10 @@ const TableRowDetails = React.createClass({
<td>Creation time</td>
<td>{createdAt}</td>
</tr>
<tr>
<td>Available metrics<br/><i>(can require a full run before appearing)</i></td>
<td>{availableMetrics}</td>
</tr>
</tbody>
</table>
</td>
Expand Down

0 comments on commit da5a058

Please sign in to comment.