Skip to content

Commit

Permalink
Add comments and adjust UTs (Signed-off-by: Jeffrey Liu ujeffliu@amaz…
Browse files Browse the repository at this point in the history
…on.com)

Signed-off-by: CoderJeffrey <[email protected]>
  • Loading branch information
CoderJeffrey committed Jun 30, 2023
1 parent 55cd8c0 commit 6578073
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ public void construct() {
// Use EVALUATION_INTERVAL_SECONDS instead of RCA_PERIOD which resolved to 12 seconds.
// This is resulting in this RCA not getting executed in every 5 seconds.
Rca<ResourceFlowUnit<HotNodeSummary>> threadMetricsRca =
new ThreadMetricsRca(threadBlockedTime, threadWaitedTime, EVALUATION_INTERVAL_SECONDS);
new ThreadMetricsRca(
threadBlockedTime, threadWaitedTime, EVALUATION_INTERVAL_SECONDS);
threadMetricsRca.addTag(
RcaConsts.RcaTagConstants.TAG_LOCUS,
RcaConsts.RcaTagConstants.LOCUS_DATA_CLUSTER_MANAGER_NODE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -756,8 +756,10 @@ public static void emitSearchBackPressureMetrics(
Result<Record> searchbp_records = searchBackPressureMetricsSnapShot.fetchAll();

// String SEARCHBP_MODE_DIM = "searchbp_mode";
String SEARCHBP_TYPE_DIM = AllMetrics.SearchBackPressureStatsValue.SEARCHBP_TYPE_DIM.toString();
String SEARCHBP_TABLE_NAME = AllMetrics.SearchBackPressureStatsValue.SEARCHBP_TABLE_NAME.toString();
String SEARCHBP_TYPE_DIM =
AllMetrics.SearchBackPressureStatsValue.SEARCHBP_TYPE_DIM.toString();
String SEARCHBP_TABLE_NAME =
AllMetrics.SearchBackPressureStatsValue.SEARCHBP_TABLE_NAME.toString();

List<String> dims =
new ArrayList<String>() {
Expand Down Expand Up @@ -838,8 +840,6 @@ public static void emitSearchBackPressureMetrics(
for (Record record : searchbp_records) {
for (String stats_type : stats_types) {
Optional<Object> tmpStatsObj = Optional.ofNullable(record.get(stats_type));
// LOG.info(stats_type + " is: " + tmpStatsObj.map(o ->
// Long.parseLong(o.toString())).toString());

handle.bind(
stats_type,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ static SearchBackPressureMetricsProcessor buildSearchBackPressureMetricsProcesso
currentWindowStartTime, searchBackPressureMetricsSnapShot);
return new SearchBackPressureMetricsProcessor(searchBackPressureMetricsSnapShot);
}

return new SearchBackPressureMetricsProcessor(
searchBackPressureSnapshotNavigableMap.get(currentWindowStartTime));
}
Expand Down Expand Up @@ -105,7 +105,7 @@ private void parseJsonLine(final String jsonString) {
if (map.isEmpty()) {
throw new RuntimeException("Missing SearchBackPressure Metrics payload.");
}

// A list of dims to be collected
ArrayList<String> required_searchbp_dims =
new ArrayList<String>() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,14 @@ public class SearchBackPressureMetricsSnapShot implements Removable {
// entry point to interact with SQLite db
private final DSLContext create;

/*
* This is a tmp table created to populate searchbp stats
* table name is the search_back_pressure_ + windowStartTime
*/
private final String tableName;

/* columns are the key metrics to be collected (e.g. shar-level search back pressure cancellation count)
*/
private List<Field<?>> columns;

// Create a table with specifed fields (columns)
Expand All @@ -47,14 +54,14 @@ public SearchBackPressureMetricsSnapShot(Connection conn, Long windowStartTime)
AllMetrics.SearchBackPressureStatsValue
.SEARCHBP_SHARD_STATS_CANCELLATIONCOUNT
.toString()),
Long.class));
Integer.class));
this.add(
DSL.field(
DSL.name(
AllMetrics.SearchBackPressureStatsValue
.SEARCHBP_TASK_STATS_CANCELLATIONCOUNT
.toString()),
Long.class));
Integer.class));

// Shard Stats Resource Heap / CPU Usage
this.add(
Expand All @@ -63,43 +70,43 @@ public SearchBackPressureMetricsSnapShot(Connection conn, Long windowStartTime)
AllMetrics.SearchBackPressureStatsValue
.SEARCHBP_SHARD_STATS_RESOURCE_HEAP_USAGE_CANCELLATIONCOUNT
.toString()),
Long.class));
Integer.class));
this.add(
DSL.field(
DSL.name(
AllMetrics.SearchBackPressureStatsValue
.SEARCHBP_SHARD_STATS_RESOURCE_HEAP_USAGE_CURRENTMAX
.toString()),
Long.class));
Integer.class));
this.add(
DSL.field(
DSL.name(
AllMetrics.SearchBackPressureStatsValue
.SEARCHBP_SHARD_STATS_RESOURCE_HEAP_USAGE_ROLLINGAVG
.toString()),
Long.class));
Integer.class));
this.add(
DSL.field(
DSL.name(
AllMetrics.SearchBackPressureStatsValue
.SEARCHBP_SHARD_STATS_RESOURCE_CPU_USAGE_CANCELLATIONCOUNT
.toString()),
Long.class));
Integer.class));

this.add(
DSL.field(
DSL.name(
AllMetrics.SearchBackPressureStatsValue
.SEARCHBP_SHARD_STATS_RESOURCE_CPU_USAGE_CURRENTMAX
.toString()),
Long.class));
Integer.class));
this.add(
DSL.field(
DSL.name(
AllMetrics.SearchBackPressureStatsValue
.SEARCHBP_SHARD_STATS_RESOURCE_CPU_USAGE_CURRENTAVG
.toString()),
Long.class));
Integer.class));

// Task Stats Resource Heap / CPU Usage
this.add(
Expand All @@ -108,43 +115,43 @@ public SearchBackPressureMetricsSnapShot(Connection conn, Long windowStartTime)
AllMetrics.SearchBackPressureStatsValue
.SEARCHBP_TASK_STATS_RESOURCE_HEAP_USAGE_CANCELLATIONCOUNT
.toString()),
Long.class));
Integer.class));
this.add(
DSL.field(
DSL.name(
AllMetrics.SearchBackPressureStatsValue
.SEARCHBP_TASK_STATS_RESOURCE_HEAP_USAGE_CURRENTMAX
.toString()),
Long.class));
Integer.class));
this.add(
DSL.field(
DSL.name(
AllMetrics.SearchBackPressureStatsValue
.SEARCHBP_TASK_STATS_RESOURCE_HEAP_USAGE_ROLLINGAVG
.toString()),
Long.class));
Integer.class));
this.add(
DSL.field(
DSL.name(
AllMetrics.SearchBackPressureStatsValue
.SEARCHBP_TASK_STATS_RESOURCE_CPU_USAGE_CANCELLATIONCOUNT
.toString()),
Long.class));
Integer.class));

this.add(
DSL.field(
DSL.name(
AllMetrics.SearchBackPressureStatsValue
.SEARCHBP_TASK_STATS_RESOURCE_CPU_USAGE_CURRENTMAX
.toString()),
Long.class));
Integer.class));
this.add(
DSL.field(
DSL.name(
AllMetrics.SearchBackPressureStatsValue
.SEARCHBP_TASK_STATS_RESOURCE_CPU_USAGE_CURRENTAVG
.toString()),
Long.class));
Integer.class));
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public void testSearchBackPressureProcessEvent() throws Exception {
// SEARCHBP_SHARD_STATS_RESOURCE_HEAP_USAGE_ROLLINGAVG value is 3L according to the
// SERIALIZED_EVENT, should EQUAL
Assert.assertEquals(
3L,
3,
result.get(0)
.get(
AllMetrics.SearchBackPressureStatsValue
Expand All @@ -102,7 +102,7 @@ public void testSearchBackPressureProcessEvent() throws Exception {
// SEARCHBP_TASK_STATS_RESOURCE_CPU_USAGE_CANCELLATIONCOUNT value is 0L according to the
// SERIALIZED_EVENT, should EQUAL
Assert.assertEquals(
0L,
0,
result.get(0)
.get(
AllMetrics.SearchBackPressureStatsValue
Expand All @@ -112,7 +112,7 @@ public void testSearchBackPressureProcessEvent() throws Exception {
// SEARCHBP_TASK_STATS_RESOURCE_CPU_USAGE_CANCELLATIONCOUNT value is 0L according to the
// SERIALIZED_EVENT, should NOT EQUAL
Assert.assertNotEquals(
2L,
2,
result.get(0)
.get(
AllMetrics.SearchBackPressureStatsValue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public void testReadSearchBackPressureMetricsSnapshot() throws Exception {
assertEquals(1, result.size());
// for 14 (length of required_searchbp_dims) fields, each assign a value from 0 to 13
// test each field and verify the result
for (long i = 0; i < required_searchbp_dims.size(); i++) {
for (int i = 0; i < required_searchbp_dims.size(); i++) {
Assert.assertEquals(
AllMetrics.SearchBackPressureStatsValue.SEARCHBP_SHARD_STATS_CANCELLATIONCOUNT
.toString()
Expand All @@ -128,7 +128,7 @@ public void tearDown() throws Exception {
private void insertIntoTable(BatchBindStep handle) {
Object[] bindVals = new Object[required_searchbp_dims.size()];
for (int i = 0; i < required_searchbp_dims.size(); i++) {
bindVals[i] = Long.valueOf(i);
bindVals[i] = Integer.valueOf(i);
}

handle.bind(bindVals).execute();
Expand Down

0 comments on commit 6578073

Please sign in to comment.