[BugFix]Escape '/' on InfluxDB query (#4589)
* Escape '/' on InfluxDB * fix checkstyle
This commit is contained in:
parent
4474907fef
commit
f56d98dc94
|
|
@ -46,6 +46,8 @@ import static org.influxdb.querybuilder.BuiltQuery.QueryBuilder.select;
|
|||
*/
|
||||
public class InfluxMetadataQueryDAO extends H2MetadataQueryDAO {
|
||||
private InfluxClient client;
|
||||
// 'name' is InfluxDB keyword, so escapes it
|
||||
private static final String ENDPOINT_NAME = '\"' + EndpointTraffic.NAME + '\"';
|
||||
|
||||
public InfluxMetadataQueryDAO(final InfluxClient client, final JDBCHikariCPClient h2Client,
|
||||
final int metadataQueryMaxSize) {
|
||||
|
|
@ -75,17 +77,15 @@ public class InfluxMetadataQueryDAO extends H2MetadataQueryDAO {
|
|||
public List<Endpoint> searchEndpoint(final String keyword,
|
||||
final int serviceId,
|
||||
final int limit) throws IOException {
|
||||
final String endpointName = '\"' + EndpointTraffic.NAME + '\"';
|
||||
|
||||
WhereQueryImpl<SelectQueryImpl> endpointQuery = select()
|
||||
.column(EndpointTraffic.SERVICE_ID)
|
||||
.column(endpointName)
|
||||
.column(ENDPOINT_NAME)
|
||||
.column(EndpointTraffic.DETECT_POINT)
|
||||
.from(client.getDatabase(), EndpointTraffic.INDEX_NAME)
|
||||
.where();
|
||||
endpointQuery.where(eq(MetricsDAO.TAG_ENDPOINT_OWNER_SERVICE, String.valueOf(serviceId)));
|
||||
if (!Strings.isNullOrEmpty(keyword)) {
|
||||
endpointQuery.where(contains(MetricsDAO.TAG_ENDPOINT_NAME, keyword.replaceAll("/", "////")));
|
||||
endpointQuery.where(contains(MetricsDAO.TAG_ENDPOINT_NAME, keyword.replaceAll("/", "\\\\/")));
|
||||
}
|
||||
endpointQuery.limit(limit);
|
||||
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ public class TraceQuery implements ITraceQueryDAO {
|
|||
recallQuery.and(lte(SegmentRecord.LATENCY, maxDuration));
|
||||
}
|
||||
if (!Strings.isNullOrEmpty(endpointName)) {
|
||||
recallQuery.and(contains(SegmentRecord.ENDPOINT_NAME, endpointName));
|
||||
recallQuery.and(contains(SegmentRecord.ENDPOINT_NAME, endpointName.replaceAll("/", "\\\\/")));
|
||||
}
|
||||
if (serviceId != 0) {
|
||||
recallQuery.and(eq(RecordDAO.TAG_SERVICE_ID, String.valueOf(serviceId)));
|
||||
|
|
|
|||
Loading…
Reference in New Issue