Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Searchbackpressure Service Reader and UTs added #427

Merged
merged 11 commits into from
Jul 3, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -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";
khushbr marked this conversation as resolved.
Show resolved Hide resolved
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);
}

khushbr marked this conversation as resolved.
Show resolved Hide resolved
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));
khushbr marked this conversation as resolved.
Show resolved Hide resolved

// 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
Loading