提交 89dfe7d3 编写于 作者: P peng-yongsheng

Delete service entry analysis.

上级 17edfe8f
......@@ -27,12 +27,12 @@ import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.appli
import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application.metric.ApplicationMetricGraph;
import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application.refmetric.ApplicationReferenceMetricGraph;
import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.global.GlobalTraceGraph;
import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.global.GlobalTraceSpanListener;
import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.instance.mapping.InstanceMappingGraph;
import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.instance.mapping.InstanceMappingSpanListener;
import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.instance.metric.InstanceMetricGraph;
import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.instance.refmetric.InstanceReferenceMetricGraph;
import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.segment.SegmentCostGraph;
import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.service.entry.ServiceEntryGraph;
import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.service.metric.ServiceMetricGraph;
import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.service.refmetric.ServiceReferenceMetricGraph;
import org.apache.skywalking.apm.collector.analysis.segment.parser.define.AnalysisSegmentParserModule;
......@@ -86,8 +86,7 @@ public class AnalysisMetricModuleProvider extends ModuleProvider {
segmentParserListenerRegister.register(new ApplicationComponentSpanListener.Factory());
segmentParserListenerRegister.register(new ApplicationMappingSpanListener.Factory());
segmentParserListenerRegister.register(new InstanceMappingSpanListener.Factory());
// segmentParserListenerRegister.register(new ServiceEntrySpanListener.Factory());
// segmentParserListenerRegister.register(new GlobalTraceSpanListener.Factory());
segmentParserListenerRegister.register(new GlobalTraceSpanListener.Factory());
// segmentParserListenerRegister.register(new SegmentCostSpanListener.Factory());
}
......@@ -119,9 +118,6 @@ public class AnalysisMetricModuleProvider extends ModuleProvider {
InstanceMappingGraph instanceMappingGraph = new InstanceMappingGraph(getManager(), workerCreateListener);
instanceMappingGraph.create();
ServiceEntryGraph serviceEntryGraph = new ServiceEntryGraph(getManager(), workerCreateListener);
serviceEntryGraph.create();
GlobalTraceGraph globalTraceGraph = new GlobalTraceGraph(getManager(), workerCreateListener);
globalTraceGraph.create();
......
/*
* 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.apm.collector.analysis.metric.provider.worker.service.entry;
import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine;
import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractLocalAsyncWorkerProvider;
import org.apache.skywalking.apm.collector.analysis.worker.model.impl.AggregationWorker;
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
import org.apache.skywalking.apm.collector.storage.table.service.ServiceEntry;
/**
* @author peng-yongsheng
*/
public class ServiceEntryAggregationWorker extends AggregationWorker<ServiceEntry, ServiceEntry> {
public ServiceEntryAggregationWorker(ModuleManager moduleManager) {
super(moduleManager);
}
@Override public int id() {
return MetricWorkerIdDefine.SERVICE_ENTRY_AGGREGATION_WORKER_ID;
}
public static class Factory extends AbstractLocalAsyncWorkerProvider<ServiceEntry, ServiceEntry, ServiceEntryAggregationWorker> {
public Factory(ModuleManager moduleManager) {
super(moduleManager);
}
@Override public ServiceEntryAggregationWorker workerInstance(ModuleManager moduleManager) {
return new ServiceEntryAggregationWorker(moduleManager);
}
@Override
public int queueSize() {
return 1024;
}
}
}
/*
* 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.apm.collector.analysis.metric.provider.worker.service.entry;
import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricGraphIdDefine;
import org.apache.skywalking.apm.collector.analysis.worker.model.base.WorkerCreateListener;
import org.apache.skywalking.apm.collector.core.graph.GraphManager;
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
import org.apache.skywalking.apm.collector.remote.RemoteModule;
import org.apache.skywalking.apm.collector.remote.service.RemoteSenderService;
import org.apache.skywalking.apm.collector.storage.table.service.ServiceEntry;
/**
* @author peng-yongsheng
*/
public class ServiceEntryGraph {
private final ModuleManager moduleManager;
private final WorkerCreateListener workerCreateListener;
public ServiceEntryGraph(ModuleManager moduleManager, WorkerCreateListener workerCreateListener) {
this.moduleManager = moduleManager;
this.workerCreateListener = workerCreateListener;
}
public void create() {
RemoteSenderService remoteSenderService = moduleManager.find(RemoteModule.NAME).getService(RemoteSenderService.class);
GraphManager.INSTANCE.createIfAbsent(MetricGraphIdDefine.SERVICE_ENTRY_GRAPH_ID, ServiceEntry.class)
.addNode(new ServiceEntryAggregationWorker.Factory(moduleManager).create(workerCreateListener))
.addNext(new ServiceEntryRemoteWorker.Factory(moduleManager, remoteSenderService, MetricGraphIdDefine.SERVICE_ENTRY_GRAPH_ID).create(workerCreateListener))
.addNext(new ServiceEntryPersistenceWorker.Factory(moduleManager).create(workerCreateListener));
}
}
/*
* 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.apm.collector.analysis.metric.provider.worker.service.entry;
import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine;
import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorker;
import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorkerProvider;
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
import org.apache.skywalking.apm.collector.storage.StorageModule;
import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.IServiceEntryPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.table.service.ServiceEntry;
/**
* @author peng-yongsheng
*/
public class ServiceEntryPersistenceWorker extends PersistenceWorker<ServiceEntry> {
public ServiceEntryPersistenceWorker(ModuleManager moduleManager) {
super(moduleManager);
}
@Override public int id() {
return MetricWorkerIdDefine.SERVICE_ENTRY_PERSISTENCE_WORKER_ID;
}
@Override protected boolean needMergeDBData() {
return true;
}
@SuppressWarnings("unchecked")
@Override protected IPersistenceDAO<?, ?, ServiceEntry> persistenceDAO() {
return getModuleManager().find(StorageModule.NAME).getService(IServiceEntryPersistenceDAO.class);
}
public static class Factory extends PersistenceWorkerProvider<ServiceEntry, ServiceEntryPersistenceWorker> {
public Factory(ModuleManager moduleManager) {
super(moduleManager);
}
@Override public ServiceEntryPersistenceWorker workerInstance(ModuleManager moduleManager) {
return new ServiceEntryPersistenceWorker(moduleManager);
}
@Override
public int queueSize() {
return 1024;
}
}
}
/*
* 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.apm.collector.analysis.metric.provider.worker.service.entry;
import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine;
import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractRemoteWorker;
import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractRemoteWorkerProvider;
import org.apache.skywalking.apm.collector.analysis.worker.model.base.WorkerException;
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
import org.apache.skywalking.apm.collector.remote.service.RemoteSenderService;
import org.apache.skywalking.apm.collector.remote.service.Selector;
import org.apache.skywalking.apm.collector.storage.table.service.ServiceEntry;
/**
* @author peng-yongsheng
*/
public class ServiceEntryRemoteWorker extends AbstractRemoteWorker<ServiceEntry, ServiceEntry> {
public ServiceEntryRemoteWorker(ModuleManager moduleManager) {
super(moduleManager);
}
@Override public int id() {
return MetricWorkerIdDefine.SERVICE_ENTRY_REMOTE_WORKER_ID;
}
@Override protected void onWork(ServiceEntry serviceEntry) throws WorkerException {
onNext(serviceEntry);
}
@Override public Selector selector() {
return Selector.HashCode;
}
public static class Factory extends AbstractRemoteWorkerProvider<ServiceEntry, ServiceEntry, ServiceEntryRemoteWorker> {
public Factory(ModuleManager moduleManager, RemoteSenderService remoteSenderService, int graphId) {
super(moduleManager, remoteSenderService, graphId);
}
@Override public ServiceEntryRemoteWorker workerInstance(ModuleManager moduleManager) {
return new ServiceEntryRemoteWorker(moduleManager);
}
}
}
/*
* 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.apm.collector.analysis.metric.provider.worker.service.entry;
import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricGraphIdDefine;
import org.apache.skywalking.apm.collector.analysis.segment.parser.define.decorator.SpanDecorator;
import org.apache.skywalking.apm.collector.analysis.segment.parser.define.listener.EntrySpanListener;
import org.apache.skywalking.apm.collector.analysis.segment.parser.define.listener.FirstSpanListener;
import org.apache.skywalking.apm.collector.analysis.segment.parser.define.listener.SpanListener;
import org.apache.skywalking.apm.collector.analysis.segment.parser.define.listener.SpanListenerFactory;
import org.apache.skywalking.apm.collector.cache.CacheModule;
import org.apache.skywalking.apm.collector.cache.service.ServiceNameCacheService;
import org.apache.skywalking.apm.collector.core.graph.Graph;
import org.apache.skywalking.apm.collector.core.graph.GraphManager;
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
import org.apache.skywalking.apm.collector.core.util.Const;
import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils;
import org.apache.skywalking.apm.collector.storage.table.service.ServiceEntry;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author peng-yongsheng
*/
public class ServiceEntrySpanListener implements FirstSpanListener, EntrySpanListener {
private final Logger logger = LoggerFactory.getLogger(ServiceEntrySpanListener.class);
private long timeBucket;
private boolean hasReference = false;
private int applicationId;
private int entryServiceId;
private String entryServiceName;
private boolean hasEntry = false;
private final ServiceNameCacheService serviceNameCacheService;
public ServiceEntrySpanListener(ModuleManager moduleManager) {
this.serviceNameCacheService = moduleManager.find(CacheModule.NAME).getService(ServiceNameCacheService.class);
}
@Override
public void parseEntry(SpanDecorator spanDecorator, int applicationId, int instanceId,
String segmentId) {
this.applicationId = applicationId;
this.entryServiceId = spanDecorator.getOperationNameId();
this.entryServiceName = serviceNameCacheService.getSplitServiceName(serviceNameCacheService.get(entryServiceId));
this.hasEntry = true;
if (spanDecorator.getRefsCount() > 0) {
this.hasReference = true;
}
}
@Override
public void parseFirst(SpanDecorator spanDecorator, int applicationId, int instanceId,
String segmentId) {
timeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(spanDecorator.getStartTime());
}
@Override public void build() {
logger.debug("entry service listener build");
if (!hasReference && hasEntry) {
ServiceEntry serviceEntry = new ServiceEntry();
serviceEntry.setId(applicationId + Const.ID_SPLIT + entryServiceId);
serviceEntry.setApplicationId(applicationId);
serviceEntry.setEntryServiceId(entryServiceId);
serviceEntry.setEntryServiceName(entryServiceName);
serviceEntry.setRegisterTime(timeBucket);
serviceEntry.setNewestTime(timeBucket);
logger.debug("push to service entry aggregation worker, id: {}", serviceEntry.getId());
Graph<ServiceEntry> graph = GraphManager.INSTANCE.findGraph(MetricGraphIdDefine.SERVICE_ENTRY_GRAPH_ID, ServiceEntry.class);
graph.start(serviceEntry);
}
}
public static class Factory implements SpanListenerFactory {
@Override public SpanListener create(ModuleManager moduleManager) {
return new ServiceEntrySpanListener(moduleManager);
}
}
}
......@@ -51,8 +51,6 @@ import org.apache.skywalking.apm.collector.storage.dao.ISegmentPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.ISegmentUIDAO;
import org.apache.skywalking.apm.collector.storage.dao.IServiceAlarmListPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.IServiceAlarmPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.IServiceEntryPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.IServiceEntryUIDAO;
import org.apache.skywalking.apm.collector.storage.dao.IServiceNameCacheDAO;
import org.apache.skywalking.apm.collector.storage.dao.IServiceReferenceAlarmListPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.IServiceReferenceAlarmPersistenceDAO;
......@@ -148,7 +146,6 @@ public class StorageModule extends Module {
classes.add(IApplicationReferenceMinuteMetricPersistenceDAO.class);
classes.add(ISegmentCostPersistenceDAO.class);
classes.add(ISegmentPersistenceDAO.class);
classes.add(IServiceEntryPersistenceDAO.class);
classes.add(IServiceMinuteMetricPersistenceDAO.class);
classes.add(IServiceReferenceMinuteMetricPersistenceDAO.class);
......@@ -172,7 +169,6 @@ public class StorageModule extends Module {
classes.add(IApplicationReferenceMetricUIDAO.class);
classes.add(ISegmentCostUIDAO.class);
classes.add(ISegmentUIDAO.class);
classes.add(IServiceEntryUIDAO.class);
classes.add(IServiceReferenceUIDAO.class);
}
......
......@@ -24,5 +24,5 @@ import org.apache.skywalking.apm.collector.storage.table.global.GlobalTrace;
/**
* @author peng-yongsheng
*/
public interface IGlobalTracePersistenceDAO<Insert, Update, DataImpl extends GlobalTrace> extends IPersistenceDAO<Insert, Update, DataImpl> {
public interface IGlobalTracePersistenceDAO<INSERT, UPDATE, STREAM_DATA extends GlobalTrace> extends IPersistenceDAO<INSERT, UPDATE, STREAM_DATA> {
}
/*
* 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.apm.collector.storage.dao;
import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.table.service.ServiceEntry;
/**
* @author peng-yongsheng
*/
public interface IServiceEntryPersistenceDAO<INSERT, UPDATE, STREAM_DATA extends ServiceEntry> extends IPersistenceDAO<INSERT, UPDATE, STREAM_DATA> {
}
/*
* 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.apm.collector.storage.dao;
import com.google.gson.JsonObject;
import org.apache.skywalking.apm.collector.storage.base.dao.DAO;
/**
* @author peng-yongsheng
*/
public interface IServiceEntryUIDAO extends DAO {
JsonObject load(int applicationId, String entryServiceName, long startTime, long endTime, int from, int size);
}
/*
* 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.apm.collector.storage.table.service;
import org.apache.skywalking.apm.collector.core.data.Column;
import org.apache.skywalking.apm.collector.core.data.StreamData;
import org.apache.skywalking.apm.collector.core.data.operator.CoverOperation;
import org.apache.skywalking.apm.collector.core.data.operator.NonOperation;
/**
* @author peng-yongsheng
*/
public class ServiceEntry extends StreamData {
private static final Column[] STRING_COLUMNS = {
new Column(ServiceEntryTable.COLUMN_ID, new NonOperation()),
new Column(ServiceEntryTable.COLUMN_ENTRY_SERVICE_NAME, new CoverOperation()),
};
private static final Column[] LONG_COLUMNS = {
new Column(ServiceEntryTable.COLUMN_REGISTER_TIME, new NonOperation()),
new Column(ServiceEntryTable.COLUMN_NEWEST_TIME, new CoverOperation()),
};
private static final Column[] DOUBLE_COLUMNS = {};
private static final Column[] INTEGER_COLUMNS = {
new Column(ServiceEntryTable.COLUMN_APPLICATION_ID, new CoverOperation()),
new Column(ServiceEntryTable.COLUMN_ENTRY_SERVICE_ID, new CoverOperation()),
};
private static final Column[] BOOLEAN_COLUMNS = {};
private static final Column[] BYTE_COLUMNS = {};
public ServiceEntry() {
super(STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BOOLEAN_COLUMNS, BYTE_COLUMNS);
}
@Override public String getId() {
return getDataString(0);
}
@Override public void setId(String id) {
setDataString(0, id);
}
@Override public String getMetricId() {
return getId();
}
@Override public void setMetricId(String metricId) {
setId(metricId);
}
public String getEntryServiceName() {
return getDataString(1);
}
public void setEntryServiceName(String entryServiceName) {
setDataString(1, entryServiceName);
}
public Long getRegisterTime() {
return getDataLong(0);
}
public void setRegisterTime(Long registerTime) {
setDataLong(0, registerTime);
}
public Long getNewestTime() {
return getDataLong(1);
}
public void setNewestTime(Long newestTime) {
setDataLong(1, newestTime);
}
public Integer getApplicationId() {
return getDataInteger(0);
}
public void setApplicationId(Integer applicationId) {
setDataInteger(0, applicationId);
}
public Integer getEntryServiceId() {
return getDataInteger(1);
}
public void setEntryServiceId(Integer entryServiceId) {
setDataInteger(1, entryServiceId);
}
}
/*
* 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.apm.collector.storage.table.service;
import org.apache.skywalking.apm.collector.core.data.CommonTable;
/**
* @author peng-yongsheng
*/
public class ServiceEntryTable extends CommonTable {
public static final String TABLE = "service_entry";
public static final String COLUMN_APPLICATION_ID = "application_id";
public static final String COLUMN_ENTRY_SERVICE_ID = "entry_service_id";
public static final String COLUMN_ENTRY_SERVICE_NAME = "entry_service_name";
public static final String COLUMN_REGISTER_TIME = "register_time";
public static final String COLUMN_NEWEST_TIME = "newest_time";
}
......@@ -60,8 +60,6 @@ import org.apache.skywalking.apm.collector.storage.dao.ISegmentPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.ISegmentUIDAO;
import org.apache.skywalking.apm.collector.storage.dao.IServiceAlarmListPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.IServiceAlarmPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.IServiceEntryPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.IServiceEntryUIDAO;
import org.apache.skywalking.apm.collector.storage.dao.IServiceNameCacheDAO;
import org.apache.skywalking.apm.collector.storage.dao.IServiceReferenceAlarmListPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.IServiceReferenceAlarmPersistenceDAO;
......@@ -123,8 +121,6 @@ import org.apache.skywalking.apm.collector.storage.es.dao.SegmentEsPersistenceDA
import org.apache.skywalking.apm.collector.storage.es.dao.SegmentEsUIDAO;
import org.apache.skywalking.apm.collector.storage.es.dao.ServiceAlarmEsPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.es.dao.ServiceAlarmListEsPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.es.dao.ServiceEntryEsPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.es.dao.ServiceEntryEsUIDAO;
import org.apache.skywalking.apm.collector.storage.es.dao.ServiceNameEsCacheDAO;
import org.apache.skywalking.apm.collector.storage.es.dao.ServiceReferenceAlarmEsPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.es.dao.ServiceReferenceAlarmListEsPersistenceDAO;
......@@ -270,7 +266,6 @@ public class StorageModuleEsProvider extends ModuleProvider {
this.registerServiceImplementation(IApplicationReferenceMinuteMetricPersistenceDAO.class, new ApplicationReferenceMinuteMetricEsPersistenceDAO(elasticSearchClient));
this.registerServiceImplementation(ISegmentCostPersistenceDAO.class, new SegmentCostEsPersistenceDAO(elasticSearchClient));
this.registerServiceImplementation(ISegmentPersistenceDAO.class, new SegmentEsPersistenceDAO(elasticSearchClient));
this.registerServiceImplementation(IServiceEntryPersistenceDAO.class, new ServiceEntryEsPersistenceDAO(elasticSearchClient));
this.registerServiceImplementation(IServiceMinuteMetricPersistenceDAO.class, new ServiceMinuteMetricEsPersistenceDAO(elasticSearchClient));
this.registerServiceImplementation(IServiceReferenceMinuteMetricPersistenceDAO.class, new ServiceReferenceMinuteMetricEsPersistenceDAO(elasticSearchClient));
......@@ -294,7 +289,6 @@ public class StorageModuleEsProvider extends ModuleProvider {
this.registerServiceImplementation(IApplicationReferenceMetricUIDAO.class, new ApplicationReferenceMetricEsUIDAO(elasticSearchClient));
this.registerServiceImplementation(ISegmentCostUIDAO.class, new SegmentCostEsUIDAO(elasticSearchClient));
this.registerServiceImplementation(ISegmentUIDAO.class, new SegmentEsUIDAO(elasticSearchClient));
this.registerServiceImplementation(IServiceEntryUIDAO.class, new ServiceEntryEsUIDAO(elasticSearchClient));
this.registerServiceImplementation(IServiceReferenceUIDAO.class, new ServiceReferenceEsUIDAO(elasticSearchClient));
}
......
/*
* 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.apm.collector.storage.es.dao;
import java.util.HashMap;
import java.util.Map;
import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient;
import org.apache.skywalking.apm.collector.storage.dao.IServiceEntryPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO;
import org.apache.skywalking.apm.collector.storage.table.service.ServiceEntry;
import org.apache.skywalking.apm.collector.storage.table.service.ServiceEntryTable;
import org.elasticsearch.action.get.GetResponse;
import org.elasticsearch.action.index.IndexRequestBuilder;
import org.elasticsearch.action.update.UpdateRequestBuilder;
/**
* @author peng-yongsheng
*/
public class ServiceEntryEsPersistenceDAO extends EsDAO implements IServiceEntryPersistenceDAO<IndexRequestBuilder, UpdateRequestBuilder, ServiceEntry> {
public ServiceEntryEsPersistenceDAO(ElasticSearchClient client) {
super(client);
}
@Override public ServiceEntry get(String id) {
GetResponse getResponse = getClient().prepareGet(ServiceEntryTable.TABLE, id).get();
if (getResponse.isExists()) {
ServiceEntry serviceEntry = new ServiceEntry();
Map<String, Object> source = getResponse.getSource();
serviceEntry.setId((String)source.get(ServiceEntryTable.COLUMN_ID));
serviceEntry.setApplicationId(((Number)source.get(ServiceEntryTable.COLUMN_APPLICATION_ID)).intValue());
serviceEntry.setEntryServiceId(((Number)source.get(ServiceEntryTable.COLUMN_ENTRY_SERVICE_ID)).intValue());
serviceEntry.setEntryServiceName((String)source.get(ServiceEntryTable.COLUMN_ENTRY_SERVICE_NAME));
serviceEntry.setRegisterTime(((Number)source.get(ServiceEntryTable.COLUMN_REGISTER_TIME)).longValue());
serviceEntry.setNewestTime(((Number)source.get(ServiceEntryTable.COLUMN_NEWEST_TIME)).longValue());
return serviceEntry;
} else {
return null;
}
}
@Override public IndexRequestBuilder prepareBatchInsert(ServiceEntry data) {
Map<String, Object> source = new HashMap<>();
source.put(ServiceEntryTable.COLUMN_APPLICATION_ID, data.getApplicationId());
source.put(ServiceEntryTable.COLUMN_ENTRY_SERVICE_ID, data.getEntryServiceId());
source.put(ServiceEntryTable.COLUMN_ENTRY_SERVICE_NAME, data.getEntryServiceName());
source.put(ServiceEntryTable.COLUMN_REGISTER_TIME, data.getRegisterTime());
source.put(ServiceEntryTable.COLUMN_NEWEST_TIME, data.getNewestTime());
return getClient().prepareIndex(ServiceEntryTable.TABLE, data.getId()).setSource(source);
}
@Override public UpdateRequestBuilder prepareBatchUpdate(ServiceEntry data) {
Map<String, Object> source = new HashMap<>();
source.put(ServiceEntryTable.COLUMN_APPLICATION_ID, data.getApplicationId());
source.put(ServiceEntryTable.COLUMN_ENTRY_SERVICE_ID, data.getEntryServiceId());
source.put(ServiceEntryTable.COLUMN_ENTRY_SERVICE_NAME, data.getEntryServiceName());
source.put(ServiceEntryTable.COLUMN_REGISTER_TIME, data.getRegisterTime());
source.put(ServiceEntryTable.COLUMN_NEWEST_TIME, data.getNewestTime());
return getClient().prepareUpdate(ServiceEntryTable.TABLE, data.getId()).setDoc(source);
}
@Override public void deleteHistory(Long startTimestamp, Long endTimestamp) {
}
}
/*
* 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.apm.collector.storage.es.dao;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient;
import org.apache.skywalking.apm.collector.core.util.ColumnNameUtils;
import org.apache.skywalking.apm.collector.core.util.StringUtils;
import org.apache.skywalking.apm.collector.storage.dao.IServiceEntryUIDAO;
import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO;
import org.apache.skywalking.apm.collector.storage.table.service.ServiceEntryTable;
import org.elasticsearch.action.search.SearchRequestBuilder;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.search.SearchType;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.SearchHits;
import org.elasticsearch.search.sort.SortBuilders;
import org.elasticsearch.search.sort.SortOrder;
/**
* @author peng-yongsheng
*/
public class ServiceEntryEsUIDAO extends EsDAO implements IServiceEntryUIDAO {
public ServiceEntryEsUIDAO(ElasticSearchClient client) {
super(client);
}
@Override
public JsonObject load(int applicationId, String entryServiceName, long startTime, long endTime, int from,
int size) {
SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(ServiceEntryTable.TABLE);
searchRequestBuilder.setTypes(ServiceEntryTable.TABLE_TYPE);
searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH);
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
boolQueryBuilder.must().add(QueryBuilders.rangeQuery(ServiceEntryTable.COLUMN_REGISTER_TIME).lte(endTime));
boolQueryBuilder.must().add(QueryBuilders.rangeQuery(ServiceEntryTable.COLUMN_NEWEST_TIME).gte(startTime));
if (applicationId != 0) {
boolQueryBuilder.must().add(QueryBuilders.matchQuery(ServiceEntryTable.COLUMN_APPLICATION_ID, applicationId));
}
if (StringUtils.isNotEmpty(entryServiceName)) {
boolQueryBuilder.must().add(QueryBuilders.matchQuery(ServiceEntryTable.COLUMN_ENTRY_SERVICE_NAME, entryServiceName));
}
searchRequestBuilder.setQuery(boolQueryBuilder);
searchRequestBuilder.setSize(size);
searchRequestBuilder.setFrom(from);
searchRequestBuilder.addSort(SortBuilders.fieldSort(ServiceEntryTable.COLUMN_ENTRY_SERVICE_NAME).order(SortOrder.ASC));
SearchResponse searchResponse = searchRequestBuilder.execute().actionGet();
return parseResponse(searchResponse);
}
private JsonObject parseResponse(SearchResponse searchResponse) {
SearchHits searchHits = searchResponse.getHits();
JsonArray serviceArray = new JsonArray();
for (SearchHit searchHit : searchHits.getHits()) {
int applicationId = ((Number)searchHit.getSource().get(ServiceEntryTable.COLUMN_APPLICATION_ID)).intValue();
int entryServiceId = ((Number)searchHit.getSource().get(ServiceEntryTable.COLUMN_ENTRY_SERVICE_ID)).intValue();
String entryServiceName = (String)searchHit.getSource().get(ServiceEntryTable.COLUMN_ENTRY_SERVICE_NAME);
JsonObject row = new JsonObject();
row.addProperty(ColumnNameUtils.INSTANCE.rename(ServiceEntryTable.COLUMN_ENTRY_SERVICE_ID), entryServiceId);
row.addProperty(ColumnNameUtils.INSTANCE.rename(ServiceEntryTable.COLUMN_ENTRY_SERVICE_NAME), entryServiceName);
row.addProperty(ColumnNameUtils.INSTANCE.rename(ServiceEntryTable.COLUMN_APPLICATION_ID), applicationId);
serviceArray.add(row);
}
JsonObject response = new JsonObject();
response.addProperty("total", searchHits.totalHits);
response.add("array", serviceArray);
return response;
}
}
......@@ -16,7 +16,6 @@
*
*/
package org.apache.skywalking.apm.collector.storage.es.define;
import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchColumnDefine;
......
/*
* 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.apm.collector.storage.es.define;
import org.apache.skywalking.apm.collector.storage.table.service.ServiceEntryTable;
import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchColumnDefine;
import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchTableDefine;
/**
* @author peng-yongsheng
*/
public class ServiceEntryEsTableDefine extends ElasticSearchTableDefine {
public ServiceEntryEsTableDefine() {
super(ServiceEntryTable.TABLE);
}
@Override public int refreshInterval() {
return 2;
}
@Override public void initialize() {
addColumn(new ElasticSearchColumnDefine(ServiceEntryTable.COLUMN_APPLICATION_ID, ElasticSearchColumnDefine.Type.Integer.name()));
addColumn(new ElasticSearchColumnDefine(ServiceEntryTable.COLUMN_ENTRY_SERVICE_ID, ElasticSearchColumnDefine.Type.Integer.name()));
addColumn(new ElasticSearchColumnDefine(ServiceEntryTable.COLUMN_ENTRY_SERVICE_NAME, ElasticSearchColumnDefine.Type.Text.name()));
addColumn(new ElasticSearchColumnDefine(ServiceEntryTable.COLUMN_REGISTER_TIME, ElasticSearchColumnDefine.Type.Long.name()));
addColumn(new ElasticSearchColumnDefine(ServiceEntryTable.COLUMN_NEWEST_TIME, ElasticSearchColumnDefine.Type.Long.name()));
}
}
......@@ -17,3 +17,5 @@ org.apache.skywalking.apm.collector.storage.es.define.instmapping.InstanceMappin
org.apache.skywalking.apm.collector.storage.es.define.instmapping.InstanceMappingHourEsTableDefine
org.apache.skywalking.apm.collector.storage.es.define.instmapping.InstanceMappingDayEsTableDefine
org.apache.skywalking.apm.collector.storage.es.define.instmapping.InstanceMappingMonthEsTableDefine
org.apache.skywalking.apm.collector.storage.es.define.GlobalTraceEsTableDefine
\ No newline at end of file
......@@ -30,19 +30,12 @@ import org.apache.skywalking.apm.collector.storage.base.dao.IBatchDAO;
import org.apache.skywalking.apm.collector.storage.dao.IApplicationAlarmListPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.IApplicationAlarmPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.IApplicationCacheDAO;
import org.apache.skywalking.apm.collector.storage.dao.acp.IApplicationComponentMinutePersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.IApplicationComponentUIDAO;
import org.apache.skywalking.apm.collector.storage.dao.ampp.IApplicationMappingMinutePersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.IApplicationMappingUIDAO;
import org.apache.skywalking.apm.collector.storage.dao.amp.IApplicationMinuteMetricPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.IApplicationReferenceAlarmListPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.IApplicationReferenceAlarmPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.armp.IApplicationReferenceMinuteMetricPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.IApplicationReferenceMetricUIDAO;
import org.apache.skywalking.apm.collector.storage.dao.register.IApplicationRegisterDAO;
import org.apache.skywalking.apm.collector.storage.dao.cpump.ICpuSecondMetricPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.ICpuMetricUIDAO;
import org.apache.skywalking.apm.collector.storage.dao.gcmp.IGCSecondMetricPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.IGCMetricUIDAO;
import org.apache.skywalking.apm.collector.storage.dao.IGlobalTracePersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.IGlobalTraceUIDAO;
......@@ -50,35 +43,40 @@ import org.apache.skywalking.apm.collector.storage.dao.IInstanceAlarmListPersist
import org.apache.skywalking.apm.collector.storage.dao.IInstanceAlarmPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.IInstanceCacheDAO;
import org.apache.skywalking.apm.collector.storage.dao.IInstanceHeartBeatPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.impp.IInstanceMappingMinutePersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.imp.IInstanceMinuteMetricPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.IInstanceMetricUIDAO;
import org.apache.skywalking.apm.collector.storage.dao.IInstanceReferenceAlarmListPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.IInstanceReferenceAlarmPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.irmp.IInstanceReferenceMinuteMetricPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.register.IInstanceRegisterDAO;
import org.apache.skywalking.apm.collector.storage.dao.IInstanceUIDAO;
import org.apache.skywalking.apm.collector.storage.dao.memorymp.IMemorySecondMetricPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.IMemoryMetricUIDAO;
import org.apache.skywalking.apm.collector.storage.dao.mpoolmp.IMemoryPoolSecondMetricPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.IMemoryPoolMetricUIDAO;
import org.apache.skywalking.apm.collector.storage.dao.INetworkAddressCacheDAO;
import org.apache.skywalking.apm.collector.storage.dao.register.INetworkAddressRegisterDAO;
import org.apache.skywalking.apm.collector.storage.dao.ISegmentCostPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.ISegmentCostUIDAO;
import org.apache.skywalking.apm.collector.storage.dao.ISegmentPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.ISegmentUIDAO;
import org.apache.skywalking.apm.collector.storage.dao.IServiceAlarmListPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.IServiceAlarmPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.IServiceEntryPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.IServiceEntryUIDAO;
import org.apache.skywalking.apm.collector.storage.dao.smp.IServiceMinuteMetricPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.IServiceNameCacheDAO;
import org.apache.skywalking.apm.collector.storage.dao.register.IServiceNameRegisterDAO;
import org.apache.skywalking.apm.collector.storage.dao.IServiceReferenceAlarmListPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.IServiceReferenceAlarmPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.srmp.IServiceReferenceMinuteMetricPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.IServiceReferenceUIDAO;
import org.apache.skywalking.apm.collector.storage.dao.acp.IApplicationComponentMinutePersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.amp.IApplicationMinuteMetricPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.ampp.IApplicationMappingMinutePersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.armp.IApplicationReferenceMinuteMetricPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.cpump.ICpuSecondMetricPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.gcmp.IGCSecondMetricPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.imp.IInstanceMinuteMetricPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.impp.IInstanceMappingMinutePersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.irmp.IInstanceReferenceMinuteMetricPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.memorymp.IMemorySecondMetricPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.mpoolmp.IMemoryPoolSecondMetricPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.register.IApplicationRegisterDAO;
import org.apache.skywalking.apm.collector.storage.dao.register.IInstanceRegisterDAO;
import org.apache.skywalking.apm.collector.storage.dao.register.INetworkAddressRegisterDAO;
import org.apache.skywalking.apm.collector.storage.dao.register.IServiceNameRegisterDAO;
import org.apache.skywalking.apm.collector.storage.dao.smp.IServiceMinuteMetricPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.srmp.IServiceReferenceMinuteMetricPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.h2.base.dao.BatchH2DAO;
import org.apache.skywalking.apm.collector.storage.h2.base.define.H2StorageInstaller;
import org.apache.skywalking.apm.collector.storage.h2.dao.ApplicationAlarmH2PersistenceDAO;
......@@ -92,12 +90,12 @@ import org.apache.skywalking.apm.collector.storage.h2.dao.ApplicationMappingH2UI
import org.apache.skywalking.apm.collector.storage.h2.dao.ApplicationMinuteMetricH2PersistenceDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.ApplicationReferenceAlarmH2PersistenceDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.ApplicationReferenceAlarmListH2PersistenceDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.ApplicationReferenceMinuteMetricH2PersistenceDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.ApplicationReferenceMetricH2UIDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.CpuSecondMetricH2PersistenceDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.ApplicationReferenceMinuteMetricH2PersistenceDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.CpuMetricH2UIDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.GCSecondMetricH2PersistenceDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.CpuSecondMetricH2PersistenceDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.GCMetricH2UIDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.GCSecondMetricH2PersistenceDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.GlobalTraceH2PersistenceDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.GlobalTraceH2UIDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.InstanceAlarmH2PersistenceDAO;
......@@ -107,15 +105,15 @@ import org.apache.skywalking.apm.collector.storage.h2.dao.InstanceH2RegisterDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.InstanceH2UIDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.InstanceHeartBeatH2PersistenceDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.InstanceMappingH2MinutePersistenceDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.InstanceMinuteMetricH2PersistenceDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.InstanceMetricH2UIDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.InstanceMinuteMetricH2PersistenceDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.InstanceReferenceAlarmH2PersistenceDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.InstanceReferenceAlarmListH2PersistenceDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.InstanceReferenceMetricH2PersistenceDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.MemorySecondMetricH2PersistenceDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.MemoryMetricH2UIDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.MemoryPoolSecondMetricH2PersistenceDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.MemoryPoolMetricH2UIDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.MemoryPoolSecondMetricH2PersistenceDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.MemorySecondMetricH2PersistenceDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.NetworkAddressH2CacheDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.NetworkAddressRegisterH2DAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.SegmentCostH2PersistenceDAO;
......@@ -124,8 +122,6 @@ import org.apache.skywalking.apm.collector.storage.h2.dao.SegmentH2PersistenceDA
import org.apache.skywalking.apm.collector.storage.h2.dao.SegmentH2UIDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.ServiceAlarmH2PersistenceDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.ServiceAlarmListH2PersistenceDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.ServiceEntryH2PersistenceDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.ServiceEntryH2UIDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.ServiceMinuteMetricH2PersistenceDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.ServiceNameH2CacheDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.ServiceNameH2RegisterDAO;
......@@ -217,7 +213,6 @@ public class StorageModuleH2Provider extends ModuleProvider {
this.registerServiceImplementation(IApplicationReferenceMinuteMetricPersistenceDAO.class, new ApplicationReferenceMinuteMetricH2PersistenceDAO(h2Client));
this.registerServiceImplementation(ISegmentCostPersistenceDAO.class, new SegmentCostH2PersistenceDAO(h2Client));
this.registerServiceImplementation(ISegmentPersistenceDAO.class, new SegmentH2PersistenceDAO(h2Client));
this.registerServiceImplementation(IServiceEntryPersistenceDAO.class, new ServiceEntryH2PersistenceDAO(h2Client));
this.registerServiceImplementation(IServiceMinuteMetricPersistenceDAO.class, new ServiceMinuteMetricH2PersistenceDAO(h2Client));
this.registerServiceImplementation(IServiceReferenceMinuteMetricPersistenceDAO.class, new ServiceReferenceMetricH2PersistenceDAO(h2Client));
......@@ -242,7 +237,6 @@ public class StorageModuleH2Provider extends ModuleProvider {
this.registerServiceImplementation(IApplicationReferenceMetricUIDAO.class, new ApplicationReferenceMetricH2UIDAO(h2Client));
this.registerServiceImplementation(ISegmentCostUIDAO.class, new SegmentCostH2UIDAO(h2Client));
this.registerServiceImplementation(ISegmentUIDAO.class, new SegmentH2UIDAO(h2Client));
this.registerServiceImplementation(IServiceEntryUIDAO.class, new ServiceEntryH2UIDAO(h2Client));
this.registerServiceImplementation(IServiceReferenceUIDAO.class, new ServiceReferenceH2UIDAO(h2Client));
}
......
/*
* 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.apm.collector.storage.h2.dao;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.skywalking.apm.collector.client.h2.H2Client;
import org.apache.skywalking.apm.collector.client.h2.H2ClientException;
import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder;
import org.apache.skywalking.apm.collector.storage.dao.IServiceEntryPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO;
import org.apache.skywalking.apm.collector.storage.h2.base.define.H2SqlEntity;
import org.apache.skywalking.apm.collector.storage.table.service.ServiceEntry;
import org.apache.skywalking.apm.collector.storage.table.service.ServiceEntryTable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author peng-yongsheng, clevertension
*/
public class ServiceEntryH2PersistenceDAO extends H2DAO implements IServiceEntryPersistenceDAO<H2SqlEntity, H2SqlEntity, ServiceEntry> {
private final Logger logger = LoggerFactory.getLogger(ServiceEntryH2PersistenceDAO.class);
private static final String GET_SERVICE_ENTRY_SQL = "select * from {0} where {1} = ?";
public ServiceEntryH2PersistenceDAO(H2Client client) {
super(client);
}
@Override public ServiceEntry get(String id) {
H2Client client = getClient();
String sql = SqlBuilder.buildSql(GET_SERVICE_ENTRY_SQL, ServiceEntryTable.TABLE, ServiceEntryTable.COLUMN_ID);
Object[] params = new Object[] {id};
try (ResultSet rs = client.executeQuery(sql, params)) {
if (rs.next()) {
ServiceEntry serviceEntry = new ServiceEntry();
serviceEntry.setId(id);
serviceEntry.setApplicationId(rs.getInt(ServiceEntryTable.COLUMN_APPLICATION_ID));
serviceEntry.setEntryServiceId(rs.getInt(ServiceEntryTable.COLUMN_ENTRY_SERVICE_ID));
serviceEntry.setEntryServiceName(rs.getString(ServiceEntryTable.COLUMN_ENTRY_SERVICE_NAME));
serviceEntry.setRegisterTime(rs.getLong(ServiceEntryTable.COLUMN_REGISTER_TIME));
serviceEntry.setNewestTime(rs.getLong(ServiceEntryTable.COLUMN_NEWEST_TIME));
return serviceEntry;
}
} catch (SQLException | H2ClientException e) {
logger.error(e.getMessage(), e);
}
return null;
}
@Override public H2SqlEntity prepareBatchInsert(ServiceEntry data) {
H2SqlEntity entity = new H2SqlEntity();
Map<String, Object> source = new HashMap<>();
source.put(ServiceEntryTable.COLUMN_ID, data.getId());
source.put(ServiceEntryTable.COLUMN_APPLICATION_ID, data.getApplicationId());
source.put(ServiceEntryTable.COLUMN_ENTRY_SERVICE_ID, data.getEntryServiceId());
source.put(ServiceEntryTable.COLUMN_ENTRY_SERVICE_NAME, data.getEntryServiceName());
source.put(ServiceEntryTable.COLUMN_REGISTER_TIME, data.getRegisterTime());
source.put(ServiceEntryTable.COLUMN_NEWEST_TIME, data.getNewestTime());
String sql = SqlBuilder.buildBatchInsertSql(ServiceEntryTable.TABLE, source.keySet());
entity.setSql(sql);
entity.setParams(source.values().toArray(new Object[0]));
return entity;
}
@Override public H2SqlEntity prepareBatchUpdate(ServiceEntry data) {
H2SqlEntity entity = new H2SqlEntity();
Map<String, Object> source = new HashMap<>();
source.put(ServiceEntryTable.COLUMN_APPLICATION_ID, data.getApplicationId());
source.put(ServiceEntryTable.COLUMN_ENTRY_SERVICE_ID, data.getEntryServiceId());
source.put(ServiceEntryTable.COLUMN_ENTRY_SERVICE_NAME, data.getEntryServiceName());
source.put(ServiceEntryTable.COLUMN_REGISTER_TIME, data.getRegisterTime());
source.put(ServiceEntryTable.COLUMN_NEWEST_TIME, data.getNewestTime());
String sql = SqlBuilder.buildBatchUpdateSql(ServiceEntryTable.TABLE, source.keySet(), ServiceEntryTable.COLUMN_ID);
entity.setSql(sql);
List<Object> values = new ArrayList<>(source.values());
values.add(data.getId());
entity.setParams(values.toArray(new Object[0]));
return entity;
}
@Override public void deleteHistory(Long startTimestamp, Long endTimestamp) {
}
}
/*
* 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.apm.collector.storage.h2.dao;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import org.apache.skywalking.apm.collector.client.h2.H2Client;
import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder;
import org.apache.skywalking.apm.collector.storage.dao.IServiceEntryUIDAO;
import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO;
import org.apache.skywalking.apm.collector.storage.table.service.ServiceEntryTable;
import org.apache.skywalking.apm.collector.client.h2.H2ClientException;
import org.apache.skywalking.apm.collector.core.util.ColumnNameUtils;
import org.apache.skywalking.apm.collector.core.util.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author peng-yongsheng
*/
public class ServiceEntryH2UIDAO extends H2DAO implements IServiceEntryUIDAO {
private final Logger logger = LoggerFactory.getLogger(ServiceEntryH2UIDAO.class);
private static final String GET_SERVICE_ENTRY_SQL = "select * from {0} where {1} >= ? and {2} <= ?";
public ServiceEntryH2UIDAO(H2Client client) {
super(client);
}
@Override public JsonObject load(int applicationId, String entryServiceName, long startTime, long endTime, int from,
int size) {
H2Client client = getClient();
String sql = GET_SERVICE_ENTRY_SQL;
List<Object> params = new ArrayList<>();
List<Object> columns = new ArrayList<>();
columns.add(ServiceEntryTable.TABLE);
columns.add(ServiceEntryTable.COLUMN_NEWEST_TIME);
columns.add(ServiceEntryTable.COLUMN_REGISTER_TIME);
params.add(startTime);
params.add(endTime);
int paramIndex = 2;
if (applicationId != 0) {
paramIndex++;
sql = sql + " and {" + paramIndex + "} = ?";
params.add(applicationId);
columns.add(ServiceEntryTable.COLUMN_APPLICATION_ID);
}
if (StringUtils.isNotEmpty(entryServiceName)) {
paramIndex++;
sql = sql + " and {" + paramIndex + "} = ?";
params.add(entryServiceName);
columns.add(ServiceEntryTable.COLUMN_ENTRY_SERVICE_NAME);
}
sql = sql + " limit " + from + "," + size;
sql = SqlBuilder.buildSql(sql, columns);
Object[] p = params.toArray(new Object[0]);
JsonArray serviceArray = new JsonArray();
JsonObject response = new JsonObject();
int index = 0;
try (ResultSet rs = client.executeQuery(sql, p)) {
while (rs.next()) {
int appId = rs.getInt(ServiceEntryTable.COLUMN_APPLICATION_ID);
int entryServiceId = rs.getInt(ServiceEntryTable.COLUMN_ENTRY_SERVICE_ID);
String entryServiceName1 = rs.getString(ServiceEntryTable.COLUMN_ENTRY_SERVICE_NAME);
JsonObject row = new JsonObject();
row.addProperty(ColumnNameUtils.INSTANCE.rename(ServiceEntryTable.COLUMN_ENTRY_SERVICE_ID), entryServiceId);
row.addProperty(ColumnNameUtils.INSTANCE.rename(ServiceEntryTable.COLUMN_ENTRY_SERVICE_NAME), entryServiceName1);
row.addProperty(ColumnNameUtils.INSTANCE.rename(ServiceEntryTable.COLUMN_APPLICATION_ID), appId);
serviceArray.add(row);
index++;
}
} catch (SQLException | H2ClientException e) {
logger.error(e.getMessage(), e);
}
response.addProperty("total", index);
response.add("array", serviceArray);
return response;
}
}
/*
* 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.apm.collector.storage.h2.define;
import org.apache.skywalking.apm.collector.storage.h2.base.define.H2TableDefine;
import org.apache.skywalking.apm.collector.storage.table.service.ServiceEntryTable;
import org.apache.skywalking.apm.collector.storage.h2.base.define.H2ColumnDefine;
/**
* @author peng-yongsheng
*/
public class ServiceEntryH2TableDefine extends H2TableDefine {
public ServiceEntryH2TableDefine() {
super(ServiceEntryTable.TABLE);
}
@Override public void initialize() {
addColumn(new H2ColumnDefine(ServiceEntryTable.COLUMN_ID, H2ColumnDefine.Type.Varchar.name()));
addColumn(new H2ColumnDefine(ServiceEntryTable.COLUMN_APPLICATION_ID, H2ColumnDefine.Type.Int.name()));
addColumn(new H2ColumnDefine(ServiceEntryTable.COLUMN_ENTRY_SERVICE_ID, H2ColumnDefine.Type.Int.name()));
addColumn(new H2ColumnDefine(ServiceEntryTable.COLUMN_ENTRY_SERVICE_NAME, H2ColumnDefine.Type.Varchar.name()));
addColumn(new H2ColumnDefine(ServiceEntryTable.COLUMN_REGISTER_TIME, H2ColumnDefine.Type.Bigint.name()));
addColumn(new H2ColumnDefine(ServiceEntryTable.COLUMN_NEWEST_TIME, H2ColumnDefine.Type.Bigint.name()));
}
}
......@@ -15,6 +15,5 @@ org.apache.skywalking.apm.collector.storage.h2.define.InstanceMappingH2TableDefi
org.apache.skywalking.apm.collector.storage.h2.define.ApplicationReferenceMetricH2TableDefine
org.apache.skywalking.apm.collector.storage.h2.define.SegmentCostH2TableDefine
org.apache.skywalking.apm.collector.storage.h2.define.SegmentH2TableDefine
org.apache.skywalking.apm.collector.storage.h2.define.ServiceEntryH2TableDefine
org.apache.skywalking.apm.collector.storage.h2.define.ServiceMetricH2TableDefine
org.apache.skywalking.apm.collector.storage.h2.define.ServiceReferenceMetricH2TableDefine
......@@ -16,11 +16,9 @@
*
*/
package org.apache.skywalking.apm.collector.ui.jetty;
import java.util.Properties;
import org.apache.skywalking.apm.collector.ui.jetty.handler.time.OneInstanceLastTimeGetHandler;
import org.apache.skywalking.apm.collector.cache.CacheModule;
import org.apache.skywalking.apm.collector.cluster.ClusterModule;
import org.apache.skywalking.apm.collector.cluster.service.ModuleListenerService;
......@@ -46,9 +44,9 @@ import org.apache.skywalking.apm.collector.ui.jetty.handler.instancemetric.Insta
import org.apache.skywalking.apm.collector.ui.jetty.handler.instancemetric.InstanceOsInfoGetHandler;
import org.apache.skywalking.apm.collector.ui.jetty.handler.naming.UIJettyNamingHandler;
import org.apache.skywalking.apm.collector.ui.jetty.handler.naming.UIJettyNamingListener;
import org.apache.skywalking.apm.collector.ui.jetty.handler.servicetree.EntryServiceGetHandler;
import org.apache.skywalking.apm.collector.ui.jetty.handler.servicetree.ServiceTreeGetByIdHandler;
import org.apache.skywalking.apm.collector.ui.jetty.handler.time.AllInstanceLastTimeGetHandler;
import org.apache.skywalking.apm.collector.ui.jetty.handler.time.OneInstanceLastTimeGetHandler;
/**
* @author peng-yongsheng
......@@ -105,7 +103,6 @@ public class UIModuleJettyProvider extends ModuleProvider {
jettyServer.addHandler(new InstanceMetricGetOneTimeBucketHandler(getManager()));
jettyServer.addHandler(new InstanceMetricGetRangeTimeBucketHandler(getManager()));
jettyServer.addHandler(new InstanceOsInfoGetHandler(getManager()));
jettyServer.addHandler(new EntryServiceGetHandler(getManager()));
jettyServer.addHandler(new ServiceTreeGetByIdHandler(getManager()));
jettyServer.addHandler(new AllInstanceLastTimeGetHandler(getManager()));
jettyServer.addHandler(new OneInstanceLastTimeGetHandler(getManager()));
......
/*
* 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.apm.collector.ui.jetty.handler.servicetree;
import com.google.gson.JsonElement;
import javax.servlet.http.HttpServletRequest;
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
import org.apache.skywalking.apm.collector.server.jetty.ArgumentsParseException;
import org.apache.skywalking.apm.collector.server.jetty.JettyHandler;
import org.apache.skywalking.apm.collector.ui.service.ServiceTreeService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author peng-yongsheng
*/
public class EntryServiceGetHandler extends JettyHandler {
private final Logger logger = LoggerFactory.getLogger(EntryServiceGetHandler.class);
@Override public String pathSpec() {
return "/service/entry";
}
private final ServiceTreeService service;
public EntryServiceGetHandler(ModuleManager moduleManager) {
this.service = new ServiceTreeService(moduleManager);
}
@Override protected JsonElement doGet(HttpServletRequest req) throws ArgumentsParseException {
if (!req.getParameterMap().containsKey("applicationId") || !req.getParameterMap().containsKey("entryServiceName")
|| !req.getParameterMap().containsKey("startTime") || !req.getParameterMap().containsKey("endTime")
|| !req.getParameterMap().containsKey("from") || !req.getParameterMap().containsKey("size")) {
throw new ArgumentsParseException("must contains parameters: applicationId, entryServiceName, startTime, endTime, from, size");
}
String applicationIdStr = req.getParameter("applicationId");
String entryServiceName = req.getParameter("entryServiceName");
String startTimeStr = req.getParameter("startTime");
String endTimeStr = req.getParameter("endTime");
String fromStr = req.getParameter("from");
String sizeStr = req.getParameter("size");
logger.debug("service entry getApplicationIdByCode applicationId: {}, entryServiceName: {}, startTime: {}, endTime: {}, from: {}, size: {}", applicationIdStr, entryServiceName, startTimeStr, endTimeStr, fromStr, sizeStr);
int applicationId;
try {
applicationId = Integer.parseInt(applicationIdStr);
} catch (NumberFormatException e) {
throw new ArgumentsParseException("application id must be integer");
}
long startTime;
try {
startTime = Long.parseLong(startTimeStr);
} catch (NumberFormatException e) {
throw new ArgumentsParseException("start time must be long");
}
long endTime;
try {
endTime = Long.parseLong(endTimeStr);
} catch (NumberFormatException e) {
throw new ArgumentsParseException("end time must be long");
}
int from;
try {
from = Integer.parseInt(fromStr);
} catch (NumberFormatException e) {
throw new ArgumentsParseException("from must be integer");
}
int size;
try {
size = Integer.parseInt(sizeStr);
} catch (NumberFormatException e) {
throw new ArgumentsParseException("size must be integer");
}
return service.loadEntryService(applicationId, entryServiceName, startTime, endTime, from, size);
}
@Override protected JsonElement doPost(HttpServletRequest req) throws ArgumentsParseException {
throw new UnsupportedOperationException();
}
}
......@@ -16,23 +16,19 @@
*
*/
package org.apache.skywalking.apm.collector.ui.service;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import java.util.Iterator;
import java.util.Map;
import org.apache.skywalking.apm.collector.core.util.Const;
import org.apache.skywalking.apm.collector.core.util.ObjectUtils;
import org.apache.skywalking.apm.collector.storage.dao.IServiceEntryUIDAO;
import org.apache.skywalking.apm.collector.storage.table.service.ServiceEntryTable;
import org.apache.skywalking.apm.collector.cache.CacheModule;
import org.apache.skywalking.apm.collector.cache.service.ApplicationCacheService;
import org.apache.skywalking.apm.collector.cache.service.ServiceNameCacheService;
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
import org.apache.skywalking.apm.collector.core.util.ColumnNameUtils;
import org.apache.skywalking.apm.collector.core.util.Const;
import org.apache.skywalking.apm.collector.core.util.ObjectUtils;
import org.apache.skywalking.apm.collector.storage.StorageModule;
import org.apache.skywalking.apm.collector.storage.dao.IServiceReferenceUIDAO;
import org.apache.skywalking.apm.collector.storage.table.service.ServiceReferenceMetricTable;
......@@ -42,32 +38,16 @@ import org.apache.skywalking.apm.collector.storage.table.service.ServiceReferenc
*/
public class ServiceTreeService {
private final IServiceEntryUIDAO serviceEntryDAO;
private final IServiceReferenceUIDAO serviceReferenceDAO;
private final ApplicationCacheService applicationCacheService;
private final ServiceNameCacheService serviceNameCacheService;
public ServiceTreeService(ModuleManager moduleManager) {
this.serviceEntryDAO = moduleManager.find(StorageModule.NAME).getService(IServiceEntryUIDAO.class);
this.serviceReferenceDAO = moduleManager.find(StorageModule.NAME).getService(IServiceReferenceUIDAO.class);
this.applicationCacheService = moduleManager.find(CacheModule.NAME).getService(ApplicationCacheService.class);
this.serviceNameCacheService = moduleManager.find(CacheModule.NAME).getService(ServiceNameCacheService.class);
}
public JsonObject loadEntryService(int applicationId, String entryServiceName, long startTime, long endTime,
int from, int size) {
JsonObject response = serviceEntryDAO.load(applicationId, entryServiceName, startTime, endTime, from, size);
JsonArray entryServices = response.get("array").getAsJsonArray();
for (JsonElement element : entryServices) {
JsonObject entryService = element.getAsJsonObject();
int respApplication = entryService.get(ColumnNameUtils.INSTANCE.rename(ServiceEntryTable.COLUMN_APPLICATION_ID)).getAsInt();
String applicationCode = applicationCacheService.getApplicationCodeById(respApplication);
entryService.addProperty("applicationCode", applicationCode);
}
return response;
}
public JsonArray loadServiceTree(int entryServiceId, long startTime, long endTime) {
Map<String, JsonObject> serviceReferenceMap = serviceReferenceDAO.load(entryServiceId, startTime, endTime);
serviceReferenceMap.values().forEach(serviceReference -> {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册