提交 a12e8bad 编写于 作者: 彭勇升 pengys 提交者: wu-sheng

Provide new getEndpointInfo service in query protocol. (#1780)

上级 b367c36d
...@@ -21,7 +21,10 @@ package org.apache.skywalking.oap.server.core.query; ...@@ -21,7 +21,10 @@ package org.apache.skywalking.oap.server.core.query;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import org.apache.skywalking.apm.network.language.agent.SpanLayer; import org.apache.skywalking.apm.network.language.agent.SpanLayer;
import org.apache.skywalking.oap.server.core.CoreModule;
import org.apache.skywalking.oap.server.core.cache.*;
import org.apache.skywalking.oap.server.core.query.entity.*; import org.apache.skywalking.oap.server.core.query.entity.*;
import org.apache.skywalking.oap.server.core.register.EndpointInventory;
import org.apache.skywalking.oap.server.core.storage.StorageModule; import org.apache.skywalking.oap.server.core.storage.StorageModule;
import org.apache.skywalking.oap.server.core.storage.query.IMetadataQueryDAO; import org.apache.skywalking.oap.server.core.storage.query.IMetadataQueryDAO;
import org.apache.skywalking.oap.server.library.module.ModuleManager; import org.apache.skywalking.oap.server.library.module.ModuleManager;
...@@ -33,18 +36,34 @@ public class MetadataQueryService implements org.apache.skywalking.oap.server.li ...@@ -33,18 +36,34 @@ public class MetadataQueryService implements org.apache.skywalking.oap.server.li
private final ModuleManager moduleManager; private final ModuleManager moduleManager;
private IMetadataQueryDAO metadataQueryDAO; private IMetadataQueryDAO metadataQueryDAO;
private ServiceInventoryCache serviceInventoryCache;
private EndpointInventoryCache endpointInventoryCache;
public MetadataQueryService(ModuleManager moduleManager) { public MetadataQueryService(ModuleManager moduleManager) {
this.moduleManager = moduleManager; this.moduleManager = moduleManager;
} }
public IMetadataQueryDAO getMetadataQueryDAO() { private IMetadataQueryDAO getMetadataQueryDAO() {
if (metadataQueryDAO == null) { if (metadataQueryDAO == null) {
metadataQueryDAO = moduleManager.find(StorageModule.NAME).getService(IMetadataQueryDAO.class); metadataQueryDAO = moduleManager.find(StorageModule.NAME).getService(IMetadataQueryDAO.class);
} }
return metadataQueryDAO; return metadataQueryDAO;
} }
private ServiceInventoryCache getServiceInventoryCache() {
if (serviceInventoryCache == null) {
serviceInventoryCache = moduleManager.find(CoreModule.NAME).getService(ServiceInventoryCache.class);
}
return serviceInventoryCache;
}
private EndpointInventoryCache getEndpointInventoryCache() {
if (endpointInventoryCache == null) {
endpointInventoryCache = moduleManager.find(CoreModule.NAME).getService(EndpointInventoryCache.class);
}
return endpointInventoryCache;
}
public ClusterBrief getGlobalBrief(final long startTimestamp, final long endTimestamp) throws IOException { public ClusterBrief getGlobalBrief(final long startTimestamp, final long endTimestamp) throws IOException {
ClusterBrief clusterBrief = new ClusterBrief(); ClusterBrief clusterBrief = new ClusterBrief();
clusterBrief.setNumOfService(getMetadataQueryDAO().numOfService(startTimestamp, endTimestamp)); clusterBrief.setNumOfService(getMetadataQueryDAO().numOfService(startTimestamp, endTimestamp));
...@@ -77,4 +96,15 @@ public class MetadataQueryService implements org.apache.skywalking.oap.server.li ...@@ -77,4 +96,15 @@ public class MetadataQueryService implements org.apache.skywalking.oap.server.li
public Service searchService(final String serviceCode) throws IOException { public Service searchService(final String serviceCode) throws IOException {
return getMetadataQueryDAO().searchService(serviceCode); return getMetadataQueryDAO().searchService(serviceCode);
} }
public EndpointInfo getEndpointInfo(final int endpointId) throws IOException {
EndpointInventory endpointInventory = getEndpointInventoryCache().get(endpointId);
EndpointInfo endpointInfo = new EndpointInfo();
endpointInfo.setId(endpointInventory.getSequence());
endpointInfo.setName(endpointInventory.getName());
endpointInfo.setServiceId(endpointInventory.getServiceId());
endpointInfo.setServiceName(getServiceInventoryCache().get(endpointInventory.getServiceId()).getName());
return endpointInfo;
}
} }
...@@ -26,6 +26,6 @@ import lombok.*; ...@@ -26,6 +26,6 @@ import lombok.*;
@Getter @Getter
@Setter @Setter
public class Endpoint { public class Endpoint {
private String id; private int id;
private String name; private String name;
} }
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.apache.skywalking.oap.server.core.query.entity;
import lombok.*;
/**
* @author peng-yongsheng
*/
@Getter
@Setter
public class EndpointInfo {
private int id;
private String name;
private int serviceId;
private String serviceName;
}
...@@ -85,4 +85,8 @@ public class MetadataQuery implements GraphQLQueryResolver { ...@@ -85,4 +85,8 @@ public class MetadataQuery implements GraphQLQueryResolver {
final int limit) throws IOException { final int limit) throws IOException {
return getMetadataQueryService().searchEndpoint(keyword, serviceId, limit); return getMetadataQueryService().searchEndpoint(keyword, serviceId, limit);
} }
public EndpointInfo getEndpointInfo(final int endpointId) throws IOException {
return getMetadataQueryService().getEndpointInfo(endpointId);
}
} }
Subproject commit 3a83be79a9c23aad6576ed2a4a04b82de6d7a829 Subproject commit 1122e97b5604ae96447bd58ecdb248d7e02952aa
...@@ -25,8 +25,7 @@ import org.apache.skywalking.oap.server.core.register.*; ...@@ -25,8 +25,7 @@ import org.apache.skywalking.oap.server.core.register.*;
import org.apache.skywalking.oap.server.core.source.DetectPoint; import org.apache.skywalking.oap.server.core.source.DetectPoint;
import org.apache.skywalking.oap.server.core.storage.query.IMetadataQueryDAO; import org.apache.skywalking.oap.server.core.storage.query.IMetadataQueryDAO;
import org.apache.skywalking.oap.server.library.client.elasticsearch.ElasticSearchClient; import org.apache.skywalking.oap.server.library.client.elasticsearch.ElasticSearchClient;
import org.apache.skywalking.oap.server.library.util.BooleanUtils; import org.apache.skywalking.oap.server.library.util.*;
import org.apache.skywalking.oap.server.library.util.StringUtils;
import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.base.*; import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.base.*;
import org.elasticsearch.action.get.GetResponse; import org.elasticsearch.action.get.GetResponse;
import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.search.SearchResponse;
...@@ -158,7 +157,7 @@ public class MetadataQueryEsDAO extends EsDAO implements IMetadataQueryDAO { ...@@ -158,7 +157,7 @@ public class MetadataQueryEsDAO extends EsDAO implements IMetadataQueryDAO {
Map<String, Object> sourceAsMap = searchHit.getSourceAsMap(); Map<String, Object> sourceAsMap = searchHit.getSourceAsMap();
Endpoint endpoint = new Endpoint(); Endpoint endpoint = new Endpoint();
endpoint.setId(String.valueOf(sourceAsMap.get(EndpointInventory.SEQUENCE))); endpoint.setId(((Number)sourceAsMap.get(EndpointInventory.SEQUENCE)).intValue());
endpoint.setName((String)sourceAsMap.get(EndpointInventory.NAME)); endpoint.setName((String)sourceAsMap.get(EndpointInventory.NAME));
endpoints.add(endpoint); endpoints.add(endpoint);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册