use of org.apache.skywalking.apm.collector.storage.ui.service.ServiceInfo in project incubator-skywalking by apache.
the class ServiceNameServiceH2UIDAO method searchService.
@Override
public List<ServiceInfo> searchService(String keyword, int topN) {
String dynamicSql = "select {0},{1} from {2} where {3} like ? and {4} = ? limit ?";
String sql = SqlBuilder.buildSql(dynamicSql, ServiceNameTable.COLUMN_SERVICE_ID, ServiceNameTable.COLUMN_SERVICE_NAME, ServiceNameTable.TABLE, ServiceNameTable.COLUMN_SERVICE_NAME, ServiceNameTable.COLUMN_SRC_SPAN_TYPE);
Object[] params = new Object[] { keyword, SpanType.Entry_VALUE, topN };
List<ServiceInfo> serviceInfos = new LinkedList<>();
try (ResultSet rs = getClient().executeQuery(sql, params)) {
while (rs.next()) {
ServiceInfo serviceInfo = new ServiceInfo();
serviceInfo.setId(rs.getInt(ServiceNameTable.COLUMN_SERVICE_ID));
serviceInfo.setName(rs.getString(ServiceNameTable.COLUMN_SERVICE_NAME));
serviceInfos.add(serviceInfo);
}
} catch (SQLException | H2ClientException e) {
logger.error(e.getMessage(), e);
}
return serviceInfos;
}
use of org.apache.skywalking.apm.collector.storage.ui.service.ServiceInfo in project incubator-skywalking by apache.
the class ServiceNameServiceEsUIDAO method searchService.
@Override
public List<ServiceInfo> searchService(String keyword, int topN) {
SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(ServiceNameTable.TABLE);
searchRequestBuilder.setTypes(ServiceNameTable.TABLE_TYPE);
searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH);
searchRequestBuilder.setSize(topN);
if (StringUtils.isNotEmpty(keyword)) {
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery();
boolQuery.must().add(QueryBuilders.matchQuery(ServiceNameTable.COLUMN_SERVICE_NAME, keyword));
boolQuery.must().add(QueryBuilders.termQuery(ServiceNameTable.COLUMN_SRC_SPAN_TYPE, SpanType.Entry_VALUE));
searchRequestBuilder.setQuery(boolQuery);
} else {
searchRequestBuilder.setQuery(QueryBuilders.termQuery(ServiceNameTable.COLUMN_SRC_SPAN_TYPE, SpanType.Entry_VALUE));
}
SearchResponse searchResponse = searchRequestBuilder.execute().actionGet();
SearchHit[] searchHits = searchResponse.getHits().getHits();
List<ServiceInfo> serviceInfos = new LinkedList<>();
for (SearchHit searchHit : searchHits) {
ServiceInfo serviceInfo = new ServiceInfo();
serviceInfo.setId(((Number) searchHit.getSource().get(ServiceNameTable.COLUMN_SERVICE_ID)).intValue());
serviceInfo.setName((String) searchHit.getSource().get(ServiceNameTable.COLUMN_SERVICE_NAME));
serviceInfos.add(serviceInfo);
}
return serviceInfos;
}
Aggregations