Skip to content

Commit

Permalink
Remove comments and refactor (Signed-off-by: Jeffrey Liu ujeffliu@ama…
Browse files Browse the repository at this point in the history
…zon.com)

Signed-off-by: CoderJeffrey <[email protected]>
  • Loading branch information
CoderJeffrey committed Jun 29, 2023
1 parent 55cd8c0 commit dab5350
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -755,9 +755,10 @@ public static void emitSearchBackPressureMetrics(
long mCurrT = System.currentTimeMillis();
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 +839,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 @@ -48,15 +48,7 @@ static SearchBackPressureMetricsProcessor buildSearchBackPressureMetricsProcesso
Connection connection,
NavigableMap<Long, SearchBackPressureMetricsSnapShot>
searchBackPressureSnapshotNavigableMap) {
// if current metrics is in searchBackPressureSnapshotNavigableMap map
if (searchBackPressureSnapshotNavigableMap.get(currentWindowStartTime) == null) {
SearchBackPressureMetricsSnapShot searchBackPressureMetricsSnapShot =
new SearchBackPressureMetricsSnapShot(connection, currentWindowStartTime);
searchBackPressureSnapshotNavigableMap.put(
currentWindowStartTime, searchBackPressureMetricsSnapShot);
return new SearchBackPressureMetricsProcessor(searchBackPressureMetricsSnapShot);
}

searchBackPressureSnapshotNavigableMap.putIfAbsent(currentWindowStartTime, new SearchBackPressureMetricsSnapShot(connection, currentWindowStartTime));
return new SearchBackPressureMetricsProcessor(
searchBackPressureSnapshotNavigableMap.get(currentWindowStartTime));
}
Expand Down Expand Up @@ -105,7 +97,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

0 comments on commit dab5350

Please sign in to comment.