Compare commits

...
Author SHA1 Message Date
vinci 67da4b68d6 query executor 2025-04-05 20:30:47 +08:00
6 changed files with 13 additions and 13 deletions
@@ -55,7 +55,7 @@ public class MetricsDataQueryController {
@Parameter(description = "Query type", example = "promql")
@RequestParam String type,
@Parameter(description = "Query timestamp", example = "1725854804451")
@RequestParam long time) {
@RequestParam Long time) {
return ResponseEntity.ok(Message.success(queryService.query(queries, type, time)));
}
@@ -67,9 +67,9 @@ public class MetricsDataQueryController {
@Parameter(description = "Query type", example = "promql")
@RequestParam String type,
@Parameter(description = "Query start timestamp", example = "1725854804451")
@RequestParam long start,
@RequestParam Long start,
@Parameter(description = "Query end timestamp", example = "1733630804452")
@RequestParam long end,
@RequestParam Long end,
@Parameter(description = "Query step", example = "4m")
@RequestParam String step
) {
@@ -143,14 +143,14 @@ public abstract class PromqlQueryExecutor implements QueryExecutor {
return http_promql(params);
}
public List<Map<String, Object>> query(String queryString, long time) {
public List<Map<String, Object>> query(String queryString, Long time) {
Map<String, Object> params = new HashMap<>();
params.put(HTTP_QUERY_PARAM, URLEncoder.encode(queryString, StandardCharsets.UTF_8));
params.put(HTTP_TIME_PARAM, time);
return http_promql(params);
}
public List<Map<String, Object>> query_range(String queryString, long start, long end, String step) {
public List<Map<String, Object>> query_range(String queryString, Long start, Long end, String step) {
Map<String, Object> params = new HashMap<>();
params.put(HTTP_QUERY_PARAM, URLEncoder.encode(queryString, StandardCharsets.UTF_8));
params.put(HTTP_START_PARAM, start);
@@ -31,9 +31,9 @@ public interface QueryExecutor {
List<Map<String, Object>> execute(String query);
List<Map<String, Object>> query(String query, long time);
List<Map<String, Object>> query(String query, Long time);
List<Map<String, Object>> query_range(String query, long start, long end, String step);
List<Map<String, Object>> query_range(String query, Long start, Long end, String step);
boolean support(String datasource);
}
@@ -55,9 +55,9 @@ public abstract class SqlQueryExecutor implements QueryExecutor {
public abstract List<Map<String, Object>> execute(String query);
public abstract List<Map<String, Object>> query(String query, long time);
public abstract List<Map<String, Object>> query(String query, Long time);
public abstract List<Map<String, Object>> query_range(String query, long start, long end, String step);
public abstract List<Map<String, Object>> query_range(String query, Long start, Long end, String step);
public boolean support(String datasource) {
@@ -32,7 +32,7 @@ public interface MetricsDataQueryService {
* @param time time
* @return data
*/
List<MetricQueryData> query(List<String> queries, String queryType, long time);
List<MetricQueryData> query(List<String> queries, String queryType, Long time);
/**
* Query metrics data range
@@ -42,5 +42,5 @@ public interface MetricsDataQueryService {
* @param step step
* @return data
*/
List<MetricQueryData> queryRange(List<String> queries, String queryType, long start, long end, String step);
List<MetricQueryData> queryRange(List<String> queries, String queryType, Long start, Long end, String step);
}
@@ -34,7 +34,7 @@ public class MetricsDataQueryServiceImpl implements MetricsDataQueryService {
List<QueryExecutor> executors;
@Override
public List<MetricQueryData> query(List<String> queries, String queryType, long time) {
public List<MetricQueryData> query(List<String> queries, String queryType, Long time) {
if (queries == null || executors.isEmpty()) {
throw new IllegalArgumentException("No query executor found");
}
@@ -50,7 +50,7 @@ public class MetricsDataQueryServiceImpl implements MetricsDataQueryService {
}
@Override
public List<MetricQueryData> queryRange(List<String> queries, String queryType, long start, long end, String step) {
public List<MetricQueryData> queryRange(List<String> queries, String queryType, Long start, Long end, String step) {
if (queries == null || executors.isEmpty()) {
throw new IllegalArgumentException("No query executor found");
}