Provide new getEndpointInfo service in query protocol. (#1780)
This commit is contained in:
parent
b367c36db9
commit
a12e8badb8
|
|
@ -21,7 +21,10 @@ package org.apache.skywalking.oap.server.core.query;
|
|||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
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.register.EndpointInventory;
|
||||
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.library.module.ModuleManager;
|
||||
|
|
@ -33,18 +36,34 @@ public class MetadataQueryService implements org.apache.skywalking.oap.server.li
|
|||
|
||||
private final ModuleManager moduleManager;
|
||||
private IMetadataQueryDAO metadataQueryDAO;
|
||||
private ServiceInventoryCache serviceInventoryCache;
|
||||
private EndpointInventoryCache endpointInventoryCache;
|
||||
|
||||
public MetadataQueryService(ModuleManager moduleManager) {
|
||||
this.moduleManager = moduleManager;
|
||||
}
|
||||
|
||||
public IMetadataQueryDAO getMetadataQueryDAO() {
|
||||
private IMetadataQueryDAO getMetadataQueryDAO() {
|
||||
if (metadataQueryDAO == null) {
|
||||
metadataQueryDAO = moduleManager.find(StorageModule.NAME).getService(IMetadataQueryDAO.class);
|
||||
}
|
||||
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 {
|
||||
ClusterBrief clusterBrief = new ClusterBrief();
|
||||
clusterBrief.setNumOfService(getMetadataQueryDAO().numOfService(startTimestamp, endTimestamp));
|
||||
|
|
@ -77,4 +96,15 @@ public class MetadataQueryService implements org.apache.skywalking.oap.server.li
|
|||
public Service searchService(final String serviceCode) throws IOException {
|
||||
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.*;
|
|||
@Getter
|
||||
@Setter
|
||||
public class Endpoint {
|
||||
private String id;
|
||||
private int id;
|
||||
private String name;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* 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 {
|
|||
final int limit) throws IOException {
|
||||
return getMetadataQueryService().searchEndpoint(keyword, serviceId, limit);
|
||||
}
|
||||
|
||||
public EndpointInfo getEndpointInfo(final int endpointId) throws IOException {
|
||||
return getMetadataQueryService().getEndpointInfo(endpointId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 3a83be79a9c23aad6576ed2a4a04b82de6d7a829
|
||||
Subproject commit 1122e97b5604ae96447bd58ecdb248d7e02952aa
|
||||
|
|
@ -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.storage.query.IMetadataQueryDAO;
|
||||
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.StringUtils;
|
||||
import org.apache.skywalking.oap.server.library.util.*;
|
||||
import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.base.*;
|
||||
import org.elasticsearch.action.get.GetResponse;
|
||||
import org.elasticsearch.action.search.SearchResponse;
|
||||
|
|
@ -158,7 +157,7 @@ public class MetadataQueryEsDAO extends EsDAO implements IMetadataQueryDAO {
|
|||
Map<String, Object> sourceAsMap = searchHit.getSourceAsMap();
|
||||
|
||||
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));
|
||||
endpoints.add(endpoint);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue