未验证 提交 929dc0e9 编写于 作者: Z zhang-wei 提交者: GitHub

support search browser service (#7975)

上级 2fb4fe1b
......@@ -46,6 +46,7 @@ Release Notes.
* Add `Message Queue Avg Consuming Latency` metric for MQ consuming service and endpoint.
* Support `-Inf` as bucket in the meter system.
* Fix setting wrong field when combining `Event`s.
* Support search browser service.
#### UI
......
......@@ -23,6 +23,7 @@ import java.util.List;
import java.util.stream.Collectors;
import org.apache.skywalking.oap.server.core.Const;
import org.apache.skywalking.oap.server.core.analysis.IDManager;
import org.apache.skywalking.oap.server.core.analysis.NodeType;
import org.apache.skywalking.oap.server.core.query.type.Database;
import org.apache.skywalking.oap.server.core.query.type.Endpoint;
import org.apache.skywalking.oap.server.core.query.type.EndpointInfo;
......@@ -69,7 +70,18 @@ public class MetadataQueryService implements org.apache.skywalking.oap.server.li
public List<Service> searchServices(final long startTimestamp, final long endTimestamp,
final String keyword) throws IOException {
return getMetadataQueryDAO().searchServices(keyword).stream().distinct().collect(Collectors.toList());
return getMetadataQueryDAO().searchServices(NodeType.Normal, keyword)
.stream()
.distinct()
.collect(Collectors.toList());
}
public List<Service> searchBrowserServices(final long startTimestamp, final long endTimestamp,
final String keyword) throws IOException {
return getMetadataQueryDAO().searchServices(NodeType.Browser, keyword)
.stream()
.distinct()
.collect(Collectors.toList());
}
public List<ServiceInstance> getServiceInstances(final long startTimestamp, final long endTimestamp,
......@@ -85,7 +97,11 @@ public class MetadataQueryService implements org.apache.skywalking.oap.server.li
}
public Service searchService(final String serviceCode) throws IOException {
return getMetadataQueryDAO().searchService(serviceCode);
return getMetadataQueryDAO().searchService(NodeType.Normal, serviceCode);
}
public Service searchBrowserService(final String serviceCode) throws IOException {
return getMetadataQueryDAO().searchService(NodeType.Browser, serviceCode);
}
public EndpointInfo getEndpointInfo(final String endpointId) throws IOException {
......
......@@ -20,6 +20,7 @@ package org.apache.skywalking.oap.server.core.storage.query;
import java.io.IOException;
import java.util.List;
import org.apache.skywalking.oap.server.core.analysis.NodeType;
import org.apache.skywalking.oap.server.core.query.type.Database;
import org.apache.skywalking.oap.server.core.query.type.Endpoint;
import org.apache.skywalking.oap.server.core.query.type.Service;
......@@ -44,16 +45,18 @@ public interface IMetadataQueryDAO extends DAO {
List<Database> getAllDatabases() throws IOException;
/**
* @param keyword to filter the normal service
* @param nodeType describe which kind of node of Service
* @param keyword to filter the normal service
* @return the list of normal services matching the given keyword
*/
List<Service> searchServices(final String keyword) throws IOException;
List<Service> searchServices(final NodeType nodeType, final String keyword) throws IOException;
/**
* @param nodeType describe which kind of node of Service
* @param serviceCode to literal match
* @return the service matching the given full name.
*/
Service searchService(final String serviceCode) throws IOException;
Service searchService(final NodeType nodeType, final String serviceCode) throws IOException;
/**
* @param keyword to filter the endpoints
......
......@@ -81,6 +81,16 @@ public class MetadataQuery implements GraphQLQueryResolver {
return getMetadataQueryService().searchService(serviceCode);
}
public List<Service> searchBrowserServices(final Duration duration,
final String keyword) throws IOException, ParseException {
return getMetadataQueryService().searchBrowserServices(
duration.getStartTimestamp(), duration.getEndTimestamp(), keyword);
}
public Service searchBrowserService(final String serviceCode) throws IOException {
return getMetadataQueryService().searchBrowserService(serviceCode);
}
public List<ServiceInstance> getServiceInstances(final Duration duration,
final String serviceId) throws IOException, ParseException {
return getMetadataQueryService().getServiceInstances(
......
Subproject commit 47202fc1eaa1864c587a78f423a0685ffbe294ad
Subproject commit 2d1b72baab57126e0341e2984e2beb95b39cb385
......@@ -109,13 +109,13 @@ public class MetadataQueryEsDAO extends EsDAO implements IMetadataQueryDAO {
}
@Override
public List<Service> searchServices(String keyword) throws IOException {
public List<Service> searchServices(final NodeType nodeType, final String keyword) throws IOException {
final String index =
IndexController.LogicIndicesRegister.getPhysicalTableName(ServiceTraffic.INDEX_NAME);
final BoolQueryBuilder query =
Query.bool()
.must(Query.term(ServiceTraffic.NODE_TYPE, NodeType.Normal.value()));
.must(Query.term(ServiceTraffic.NODE_TYPE, nodeType.value()));
final SearchBuilder search = Search.builder().query(query).size(queryMaxSize);
if (!Strings.isNullOrEmpty(keyword)) {
......@@ -128,12 +128,12 @@ public class MetadataQueryEsDAO extends EsDAO implements IMetadataQueryDAO {
}
@Override
public Service searchService(String serviceCode) throws IOException {
public Service searchService(final NodeType nodeType, final String serviceCode) throws IOException {
final String index =
IndexController.LogicIndicesRegister.getPhysicalTableName(ServiceTraffic.INDEX_NAME);
final BoolQueryBuilder query =
Query.bool()
.must(Query.term(ServiceTraffic.NODE_TYPE, NodeType.Normal.value()))
.must(Query.term(ServiceTraffic.NODE_TYPE, nodeType.value()))
.must(Query.term(ServiceTraffic.NAME, serviceCode));
final SearchBuilder search = Search.builder().query(query).size(1);
......
......@@ -110,10 +110,10 @@ public class MetadataQuery implements IMetadataQueryDAO {
}
@Override
public List<Service> searchServices(String keyword) throws IOException {
public List<Service> searchServices(final NodeType nodeType, final String keyword) throws IOException {
final WhereQueryImpl<SelectQueryImpl> where = select(ID_COLUMN, NAME, ServiceTraffic.GROUP)
.from(client.getDatabase(), ServiceTraffic.INDEX_NAME)
.where(eq(TagName.NODE_TYPE, String.valueOf(NodeType.Normal.value())));
.where(eq(TagName.NODE_TYPE, String.valueOf(nodeType.value())));
if (!Strings.isNullOrEmpty(keyword)) {
where.and(contains(NAME, keyword));
}
......@@ -121,10 +121,10 @@ public class MetadataQuery implements IMetadataQueryDAO {
}
@Override
public Service searchService(String serviceCode) throws IOException {
public Service searchService(final NodeType nodeType, final String serviceCode) throws IOException {
final WhereQueryImpl<SelectQueryImpl> whereQuery = select(ID_COLUMN, NAME, ServiceTraffic.GROUP)
.from(client.getDatabase(), ServiceTraffic.INDEX_NAME)
.where(eq(TagName.NODE_TYPE, String.valueOf(NodeType.Normal.value())));
.where(eq(TagName.NODE_TYPE, String.valueOf(nodeType.value())));
whereQuery.and(eq(NAME, serviceCode));
return buildServices(whereQuery).get(0);
}
......
......@@ -123,12 +123,12 @@ public class H2MetadataQueryDAO implements IMetadataQueryDAO {
}
@Override
public List<Service> searchServices(String keyword) throws IOException {
public List<Service> searchServices(final NodeType nodeType, final String keyword) throws IOException {
StringBuilder sql = new StringBuilder();
List<Object> condition = new ArrayList<>(5);
sql.append("select * from ").append(ServiceTraffic.INDEX_NAME).append(" where ");
sql.append(ServiceTraffic.NODE_TYPE).append("=?");
condition.add(NodeType.Normal.value());
condition.add(nodeType.value());
if (!Strings.isNullOrEmpty(keyword)) {
sql.append(" and ").append(ServiceTraffic.NAME).append(" like concat('%',?,'%')");
condition.add(keyword);
......@@ -146,12 +146,12 @@ public class H2MetadataQueryDAO implements IMetadataQueryDAO {
}
@Override
public Service searchService(String serviceCode) throws IOException {
public Service searchService(NodeType nodeType, String serviceCode) throws IOException {
StringBuilder sql = new StringBuilder();
List<Object> condition = new ArrayList<>(5);
sql.append("select * from ").append(ServiceTraffic.INDEX_NAME).append(" where ");
sql.append(ServiceTraffic.NODE_TYPE).append("=?");
condition.add(NodeType.Normal.value());
condition.add(nodeType.value());
sql.append(" and ").append(ServiceTraffic.NAME).append(" = ?");
condition.add(serviceCode);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册