diff --git a/web/src/main/java/com/navercorp/pinpoint/web/controller/MapController.java b/web/src/main/java/com/navercorp/pinpoint/web/controller/MapController.java index 7c23e3ea9..c3f79c155 100644 --- a/web/src/main/java/com/navercorp/pinpoint/web/controller/MapController.java +++ b/web/src/main/java/com/navercorp/pinpoint/web/controller/MapController.java @@ -17,11 +17,11 @@ package com.navercorp.pinpoint.web.controller; import com.navercorp.pinpoint.common.service.ServiceTypeRegistryService; -import com.navercorp.pinpoint.common.trace.ServiceType; import com.navercorp.pinpoint.web.applicationmap.ApplicationMap; import com.navercorp.pinpoint.web.applicationmap.MapWrap; import com.navercorp.pinpoint.web.applicationmap.histogram.Histogram; import com.navercorp.pinpoint.web.applicationmap.histogram.NodeHistogram; +import com.navercorp.pinpoint.web.service.ApplicationFactory; import com.navercorp.pinpoint.web.service.MapService; import com.navercorp.pinpoint.web.util.Limiter; import com.navercorp.pinpoint.web.util.TimeUtils; @@ -35,11 +35,11 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.servlet.ModelAndView; import java.io.IOException; import java.util.List; @@ -64,11 +64,14 @@ public class MapController { @Autowired private ServiceTypeRegistryService registry; + @Autowired + private ApplicationFactory applicationFactory; + private static final String DEFAULT_SEARCH_DEPTH = "8"; private static final int DEFAULT_MAX_SEARCH_DEPTH = 8; /** - * Server map data query within from ~ to timeframe + * Server map data query within from ~ to timeframe * * @param applicationName * @param serviceTypeCode @@ -85,12 +88,21 @@ public class MapController { @RequestParam("to") long to, @RequestParam(value = "callerRange", defaultValue = DEFAULT_SEARCH_DEPTH) int callerRange, @RequestParam(value = "calleeRange", defaultValue = DEFAULT_SEARCH_DEPTH) int calleeRange) { - ServiceType serviceType = registry.findServiceType(serviceTypeCode); - return getServerMapData(applicationName, serviceType.getName(), from, to, callerRange, calleeRange); + final Range range = new Range(from, to); + this.dateLimit.limit(range); + + SearchOption searchOption = new SearchOption(callerRange, calleeRange); + assertSearchOption(searchOption); + + Application application = applicationFactory.createApplication(applicationName, serviceTypeCode); + + return selectApplicationMap(application, range, searchOption); } + + /** - * Server map data query within from ~ to timeframe + * Server map data query within from ~ to timeframe * * @param applicationName * @param serviceTypeName @@ -108,16 +120,28 @@ public class MapController { @RequestParam(value = "callerRange", defaultValue = DEFAULT_SEARCH_DEPTH) int callerRange, @RequestParam(value = "calleeRange", defaultValue = DEFAULT_SEARCH_DEPTH) int calleeRange) { final Range range = new Range(from, to); - this.dateLimit.limit(from, to); + this.dateLimit.limit(range); SearchOption searchOption = new SearchOption(callerRange, calleeRange); assertSearchOption(searchOption); - logger.info("getServerMap() applicationName:{} range:{} searchOption:{}", applicationName, TimeUnit.MILLISECONDS.toMinutes(range.getRange()), searchOption); + Application application = applicationFactory.createApplicationByTypeName(applicationName, serviceTypeName); + return selectApplicationMap(application, range, searchOption); + } - ServiceType serviceType = registry.findServiceTypeByName(serviceTypeName); - Application application = new Application(applicationName, serviceType); + private MapWrap selectApplicationMap(Application application, Range range, SearchOption searchOption) { + if (application == null) { + throw new NullPointerException("application must not be null"); + } + if (range == null) { + throw new NullPointerException("range must not be null"); + } + if (searchOption == null) { + throw new NullPointerException("searchOption must not be null"); + } + + logger.info("getServerMap() application:{} range:{} searchOption:{}", application, range, searchOption); ApplicationMap map = mapService.selectApplicationMap(application, range, searchOption); @@ -142,7 +166,7 @@ public class MapController { } /** - * Server map data query for the last "Period" timeframe + * Server map data query for the last "Period" timeframe * * @param applicationName * @param serviceTypeCode @@ -160,11 +184,20 @@ public class MapController { long to = TimeUtils.getDelayLastTime(); long from = to - period; - return getServerMapData(applicationName, serviceTypeCode, from, to, callerRange, calleeRange); + + final Range range = new Range(from, to); + this.dateLimit.limit(range); + + SearchOption searchOption = new SearchOption(callerRange, calleeRange); + assertSearchOption(searchOption); + + Application application = applicationFactory.createApplication(applicationName, serviceTypeCode); + + return selectApplicationMap(application, range, searchOption); } /** - * Server map data query for the last "Period" timeframe + * Server map data query for the last "Period" timeframe * * @param applicationName * @param serviceTypeName @@ -182,14 +215,21 @@ public class MapController { long to = TimeUtils.getDelayLastTime(); long from = to - period; - return getServerMapData(applicationName, serviceTypeName, from, to, callerRange, calleeRange); + + final Range range = new Range(from, to); + this.dateLimit.limit(range); + + SearchOption searchOption = new SearchOption(callerRange, calleeRange); + assertSearchOption(searchOption); + + Application application = applicationFactory.createApplicationByTypeName(applicationName, serviceTypeName); + return selectApplicationMap(application, range, searchOption); } /** * Possible deprecation expected when UI change push forward to pick a map first from UI * Unfiltered server map request data query * - * @param model * @param from * @param to * @param sourceApplicationName @@ -200,23 +240,22 @@ public class MapController { */ @Deprecated @RequestMapping(value = "/linkStatistics", method = RequestMethod.GET, params={"sourceServiceType", "targetServiceType"}) - public String getLinkStatistics(Model model, - @RequestParam("from") long from, + public ModelAndView getLinkStatistics(@RequestParam("from") long from, @RequestParam("to") long to, @RequestParam("sourceApplicationName") String sourceApplicationName, @RequestParam("sourceServiceType") short sourceServiceType, @RequestParam("targetApplicationName") String targetApplicationName, @RequestParam("targetServiceType") short targetServiceType) { - String sourceServiceTypeName = registry.findServiceType(sourceServiceType).getName(); - String targetServiceTypeName = registry.findServiceType(targetServiceType).getName(); - return getLinkStatistics(model, from, to, sourceApplicationName, sourceServiceTypeName, targetApplicationName, targetServiceTypeName); + final Application sourceApplication = this.applicationFactory.createApplication(sourceApplicationName, sourceServiceType); + final Application destinationApplication = this.applicationFactory.createApplication(targetApplicationName, targetServiceType); + final Range range = new Range(from, to); + return getLinkStatistics(sourceApplication, destinationApplication, range); } /** * Possible deprecation expected when UI change push forward to pick a map first from UI * Unfiltered server map request data query * - * @param model * @param from * @param to * @param sourceApplicationName @@ -227,46 +266,49 @@ public class MapController { */ @Deprecated @RequestMapping(value = "/linkStatistics", method = RequestMethod.GET, params={"sourceServiceTypeName", "targetServiceTypeName"}) - public String getLinkStatistics(Model model, - @RequestParam("from") long from, + public ModelAndView getLinkStatistics(@RequestParam("from") long from, @RequestParam("to") long to, @RequestParam("sourceApplicationName") String sourceApplicationName, @RequestParam("sourceServiceTypeName") String sourceServiceTypeName, @RequestParam("targetApplicationName") String targetApplicationName, @RequestParam("targetServiceTypeName") String targetServiceTypeName) { - final Application sourceApplication = new Application(sourceApplicationName, registry.findServiceTypeByName(sourceServiceTypeName)); - final Application destinationApplication = new Application(targetApplicationName, registry.findServiceTypeByName(targetServiceTypeName)); - final Range range = new Range(from, to); - - NodeHistogram nodeHistogram = mapService.linkStatistics(sourceApplication, destinationApplication, range); - - model.addAttribute("range", range); - - model.addAttribute("sourceApplication", sourceApplication); - - model.addAttribute("targetApplication", destinationApplication); - - Histogram applicationHistogram = nodeHistogram.getApplicationHistogram(); - model.addAttribute("linkStatistics", applicationHistogram); - - - List applicationTimeSeriesHistogram = nodeHistogram.getApplicationTimeHistogram(); - String applicationTimeSeriesHistogramJson = null; - try { - applicationTimeSeriesHistogramJson = MAPPER.writeValueAsString(applicationTimeSeriesHistogram); - } catch (IOException e) { - throw new RuntimeException(e.getMessage(), e); - } - model.addAttribute("timeSeriesHistogram", applicationTimeSeriesHistogramJson); - - // looks like we need to specify "from, to" to the result. but data got passed thru as it is. - model.addAttribute("resultFrom", from); - model.addAttribute("resultTo", to); - - - return "linkStatistics"; + final Application sourceApplication = this.applicationFactory.createApplicationByTypeName(sourceApplicationName, sourceServiceTypeName); + final Application destinationApplication = this.applicationFactory.createApplicationByTypeName(targetApplicationName, targetServiceTypeName); + final Range range = new Range(from, to); + return getLinkStatistics(sourceApplication, destinationApplication, range); } + private ModelAndView getLinkStatistics(Application sourceApplication, Application destinationApplication, Range range) { + + NodeHistogram nodeHistogram = mapService.linkStatistics(sourceApplication, destinationApplication, range); + + final ModelAndView mav = new ModelAndView("linkStatistics"); + mav.addObject("range", range); + + mav.addObject("sourceApplication", sourceApplication); + + mav.addObject("targetApplication", destinationApplication); + + Histogram applicationHistogram = nodeHistogram.getApplicationHistogram(); + mav.addObject("linkStatistics", applicationHistogram); + + + List applicationTimeSeriesHistogram = nodeHistogram.getApplicationTimeHistogram(); + String applicationTimeSeriesHistogramJson = null; + try { + applicationTimeSeriesHistogramJson = MAPPER.writeValueAsString(applicationTimeSeriesHistogram); + } catch (IOException e) { + throw new RuntimeException(e.getMessage(), e); + } + mav.addObject("timeSeriesHistogram", applicationTimeSeriesHistogramJson); + + // looks like we need to specify "from, to" to the result. but data got passed thru as it is. + mav.addObject("resultFrom", range.getFrom()); + mav.addObject("resultTo", range.getTo()); + + return mav; + } + @Deprecated private final static ObjectMapper MAPPER = new ObjectMapper(); } diff --git a/web/src/main/java/com/navercorp/pinpoint/web/mapper/ApplicationNameMapper.java b/web/src/main/java/com/navercorp/pinpoint/web/mapper/ApplicationNameMapper.java index 0e94d89d8..e73a12158 100644 --- a/web/src/main/java/com/navercorp/pinpoint/web/mapper/ApplicationNameMapper.java +++ b/web/src/main/java/com/navercorp/pinpoint/web/mapper/ApplicationNameMapper.java @@ -22,6 +22,7 @@ import java.util.HashSet; import java.util.List; import java.util.Set; +import com.navercorp.pinpoint.web.service.ApplicationFactory; import org.apache.hadoop.hbase.Cell; import org.apache.hadoop.hbase.CellUtil; import org.apache.hadoop.hbase.client.Result; @@ -40,7 +41,7 @@ import com.navercorp.pinpoint.web.vo.Application; public class ApplicationNameMapper implements RowMapper> { @Autowired - private ServiceTypeRegistryService registry; + private ApplicationFactory applicationFactory; @Override public List mapRow(Result result, int rowNum) throws Exception { @@ -55,10 +56,11 @@ public class ApplicationNameMapper implements RowMapper> { short serviceTypeCode = Bytes.toShort(CellUtil.cloneValue(cell)); uniqueTypeCodes.add(serviceTypeCode); } - List applications = new ArrayList(); + List applicationList = new ArrayList(); for (short serviceTypeCode : uniqueTypeCodes) { - applications.add(new Application(applicationName, registry.findServiceType(serviceTypeCode))); + final Application application = applicationFactory.createApplication(applicationName, serviceTypeCode); + applicationList.add(application); } - return applications; + return applicationList; } } diff --git a/web/src/main/java/com/navercorp/pinpoint/web/mapper/HostApplicationMapper.java b/web/src/main/java/com/navercorp/pinpoint/web/mapper/HostApplicationMapper.java index 50e5077fc..23221dee0 100644 --- a/web/src/main/java/com/navercorp/pinpoint/web/mapper/HostApplicationMapper.java +++ b/web/src/main/java/com/navercorp/pinpoint/web/mapper/HostApplicationMapper.java @@ -21,6 +21,7 @@ import java.util.Arrays; import com.navercorp.pinpoint.common.service.ServiceTypeRegistryService; import com.navercorp.pinpoint.common.trace.ServiceType; +import com.navercorp.pinpoint.web.service.ApplicationFactory; import org.apache.hadoop.hbase.client.Result; import org.apache.hadoop.hbase.util.Bytes; import org.slf4j.Logger; @@ -43,7 +44,7 @@ public class HostApplicationMapper implements RowMapper { private final Logger logger = LoggerFactory.getLogger(this.getClass()); @Autowired - private ServiceTypeRegistryService registry; + private ApplicationFactory applicationFactory; @Override public Application mapRow(Result result, int rowNum) throws Exception { @@ -58,7 +59,6 @@ public class HostApplicationMapper implements RowMapper { String applicationName = Bytes.toString(value, 0, HBaseTables.APPLICATION_NAME_MAX_LEN - 1).trim(); short serviceTypeCode = Bytes.toShort(value, HBaseTables.APPLICATION_NAME_MAX_LEN); - ServiceType serviceType = registry.findServiceType(serviceTypeCode); - return new Application(applicationName, serviceType); + return this.applicationFactory.createApplication(applicationName, serviceTypeCode); } } diff --git a/web/src/main/java/com/navercorp/pinpoint/web/mapper/HostApplicationMapperVer2.java b/web/src/main/java/com/navercorp/pinpoint/web/mapper/HostApplicationMapperVer2.java index 381b12611..8a92a4d4e 100644 --- a/web/src/main/java/com/navercorp/pinpoint/web/mapper/HostApplicationMapperVer2.java +++ b/web/src/main/java/com/navercorp/pinpoint/web/mapper/HostApplicationMapperVer2.java @@ -18,8 +18,7 @@ package com.navercorp.pinpoint.web.mapper; import com.navercorp.pinpoint.common.buffer.Buffer; import com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer; -import com.navercorp.pinpoint.common.service.ServiceTypeRegistryService; -import com.navercorp.pinpoint.common.trace.ServiceType; +import com.navercorp.pinpoint.web.service.ApplicationFactory; import com.navercorp.pinpoint.web.service.map.AcceptApplication; import com.navercorp.pinpoint.web.vo.Application; @@ -47,7 +46,7 @@ public class HostApplicationMapperVer2 implements RowMapper mapRow(Result result, int rowNum) throws Exception { @@ -81,8 +80,7 @@ public class HostApplicationMapperVer2 implements RowMapper { @Autowired private ServiceTypeRegistryService registry; + @Autowired + private ApplicationFactory applicationFactory; + public MapStatisticsCalleeMapper() { this(SkipLinkFilter.FILTER); } @@ -114,17 +118,14 @@ public class MapStatisticsCalleeMapper implements RowMapper { } else { callerApplicationName = ApplicationMapStatisticsUtils.getDestApplicationNameFromColumnName(qualifier); } - return createApplication(callerApplicationName, callerServiceType); + return this.applicationFactory.createApplication(callerApplicationName, callerServiceType); } private Application readCalleeApplication(Buffer row) { String calleeApplicationName = row.read2PrefixedString(); short calleeServiceType = row.readShort(); - return createApplication(calleeApplicationName, calleeServiceType); + + return this.applicationFactory.createApplication(calleeApplicationName, calleeServiceType); } - private Application createApplication(String applicationName, short serviceTypeCode) { - ServiceType serviceType = registry.findServiceType(serviceTypeCode); - return new Application(applicationName, serviceType); - } } diff --git a/web/src/main/java/com/navercorp/pinpoint/web/mapper/MapStatisticsCallerMapper.java b/web/src/main/java/com/navercorp/pinpoint/web/mapper/MapStatisticsCallerMapper.java index d8fdd46a9..827b0c4ac 100644 --- a/web/src/main/java/com/navercorp/pinpoint/web/mapper/MapStatisticsCallerMapper.java +++ b/web/src/main/java/com/navercorp/pinpoint/web/mapper/MapStatisticsCallerMapper.java @@ -23,10 +23,10 @@ import com.navercorp.pinpoint.common.buffer.FixedBuffer; import com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer; import com.navercorp.pinpoint.common.hbase.HBaseTables; import com.navercorp.pinpoint.common.service.ServiceTypeRegistryService; -import com.navercorp.pinpoint.common.trace.ServiceType; import com.navercorp.pinpoint.common.util.ApplicationMapStatisticsUtils; import com.navercorp.pinpoint.common.util.TimeUtils; import com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataMap; +import com.navercorp.pinpoint.web.service.ApplicationFactory; import com.navercorp.pinpoint.web.vo.Application; import org.apache.commons.lang3.StringUtils; @@ -56,6 +56,9 @@ public class MapStatisticsCallerMapper implements RowMapper { @Autowired private ServiceTypeRegistryService registry; + @Autowired + private ApplicationFactory applicationFactory; + public MapStatisticsCallerMapper() { this(SkipLinkFilter.FILTER); } @@ -148,24 +151,20 @@ public class MapStatisticsCallerMapper implements RowMapper { private Application readCalleeApplication(byte[] qualifier) { String calleeApplicationName = ApplicationMapStatisticsUtils.getDestApplicationNameFromColumnName(qualifier); short calleeServiceType = ApplicationMapStatisticsUtils.getDestServiceTypeFromColumnName(qualifier); - return createApplication(calleeApplicationName, calleeServiceType); + return applicationFactory.createApplication(calleeApplicationName, calleeServiceType); } private Application readCalleeApplication(Buffer buffer) { short calleeServiceType = buffer.readShort(); String calleeApplicationName = buffer.readPrefixedString(); - return createApplication(calleeApplicationName, calleeServiceType); + return applicationFactory.createApplication(calleeApplicationName, calleeServiceType); } private Application readCallerApplication(Buffer row) { String callerApplicationName = row.read2PrefixedString(); short callerServiceType = row.readShort(); - return createApplication(callerApplicationName, callerServiceType); + return this.applicationFactory.createApplication(callerApplicationName, callerServiceType); } - private Application createApplication(String applicationName, short serviceTypeCode) { - ServiceType serviceType = registry.findServiceType(serviceTypeCode); - return new Application(applicationName, serviceType); - } } diff --git a/web/src/main/java/com/navercorp/pinpoint/web/service/ApplicationFactory.java b/web/src/main/java/com/navercorp/pinpoint/web/service/ApplicationFactory.java new file mode 100644 index 000000000..ff88812f6 --- /dev/null +++ b/web/src/main/java/com/navercorp/pinpoint/web/service/ApplicationFactory.java @@ -0,0 +1,32 @@ +/* + * Copyright 2014 NAVER Corp. + * + * Licensed 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 com.navercorp.pinpoint.web.service; + +import com.navercorp.pinpoint.common.trace.ServiceType; +import com.navercorp.pinpoint.web.vo.Application; + +/** + * @author emeroad + */ +public interface ApplicationFactory { + + Application createApplication(String applicationName, short serviceTypeCode); + + Application createApplication(String applicationName, ServiceType serviceType); + + Application createApplicationByTypeName(String applicationName, String serviceTypeName); +} diff --git a/web/src/main/java/com/navercorp/pinpoint/web/service/DefaultApplicationFactory.java b/web/src/main/java/com/navercorp/pinpoint/web/service/DefaultApplicationFactory.java new file mode 100644 index 000000000..d6972a105 --- /dev/null +++ b/web/src/main/java/com/navercorp/pinpoint/web/service/DefaultApplicationFactory.java @@ -0,0 +1,62 @@ +/* + * Copyright 2014 NAVER Corp. + * + * Licensed 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 com.navercorp.pinpoint.web.service; + +import com.navercorp.pinpoint.common.service.ServiceTypeRegistryService; +import com.navercorp.pinpoint.common.trace.ServiceType; +import com.navercorp.pinpoint.web.vo.Application; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * @author emeroad + */ +@Component +public class DefaultApplicationFactory implements ApplicationFactory { + + @Autowired + private ServiceTypeRegistryService registry; + + @Override + public Application createApplication(String applicationName, short serviceTypeCode) { + if (applicationName == null) { + throw new NullPointerException("applicationName must not be null"); + } + + final ServiceType serviceType = registry.findServiceType(serviceTypeCode); + return new Application(applicationName, serviceType); + } + + @Override + public Application createApplication(String applicationName, ServiceType serviceType) { + return new Application(applicationName, serviceType); + } + + @Override + public Application createApplicationByTypeName(String applicationName, String serviceTypeName) { + if (applicationName == null) { + throw new NullPointerException("applicationName must not be null"); + } + if (serviceTypeName == null) { + throw new NullPointerException("serviceTypeName must not be null"); + } + + final ServiceType serviceType = registry.findServiceTypeByName(serviceTypeName); + return new Application(applicationName, serviceType); + } + +} diff --git a/web/src/main/java/com/navercorp/pinpoint/web/service/DotExtractor.java b/web/src/main/java/com/navercorp/pinpoint/web/service/DotExtractor.java index 6228709e0..11faf4683 100644 --- a/web/src/main/java/com/navercorp/pinpoint/web/service/DotExtractor.java +++ b/web/src/main/java/com/navercorp/pinpoint/web/service/DotExtractor.java @@ -38,20 +38,20 @@ public class DotExtractor { private final Logger logger = LoggerFactory.getLogger(this.getClass()); private final Range range; - private final ServiceTypeRegistryService registry; + private final ApplicationFactory applicationFactory; private Map> dotMap = new HashMap>(); - public DotExtractor(Range range, ServiceTypeRegistryService registry) { + public DotExtractor(Range range, ApplicationFactory applicationFactory) { if (range == null) { throw new NullPointerException("range must not be null"); } - if (registry == null) { - throw new NullPointerException("registry must not be null"); + if (applicationFactory == null) { + throw new NullPointerException("applicationFactory must not be null"); } this.range = range; - this.registry = registry; + this.applicationFactory = applicationFactory; } public void addDot(SpanBo span) { @@ -59,7 +59,7 @@ public class DotExtractor { throw new NullPointerException("span must not be null"); } - Application spanApplication = new Application(span.getApplicationId(), registry.findServiceType(span.getApplicationServiceType())); + Application spanApplication = this.applicationFactory.createApplication(span.getApplicationId(), span.getApplicationServiceType()); final List dotList = getDotList(spanApplication); final TransactionId transactionId = new TransactionId(span.getTraceAgentId(), span.getTraceAgentStartTime(), span.getTraceTransactionSequence()); @@ -87,18 +87,4 @@ public class DotExtractor { } return applicationScatterScanResult; } - - public static class Key { - private String applicationId; - private short serviceType; - - public Key(String applicationId, short serviceType) { - if (applicationId == null) { - throw new NullPointerException("applicationId must not be null"); - } - this.applicationId = applicationId; - this.serviceType = serviceType; - } - - } } diff --git a/web/src/main/java/com/navercorp/pinpoint/web/service/FilteredMapServiceImpl.java b/web/src/main/java/com/navercorp/pinpoint/web/service/FilteredMapServiceImpl.java index acf3d6c26..b5876b0e1 100755 --- a/web/src/main/java/com/navercorp/pinpoint/web/service/FilteredMapServiceImpl.java +++ b/web/src/main/java/com/navercorp/pinpoint/web/service/FilteredMapServiceImpl.java @@ -75,6 +75,9 @@ public class FilteredMapServiceImpl implements FilteredMapService { @Autowired private ServiceTypeRegistryService registry; + @Autowired + private ApplicationFactory applicationFactory; + private static final Object V = new Object(); @Override @@ -234,7 +237,7 @@ public class FilteredMapServiceImpl implements FilteredMapService { final LinkDataDuplexMap linkDataDuplexMap = new LinkDataDuplexMap(); - final DotExtractor dotExtractor = new DotExtractor(scanRange, registry); + final DotExtractor dotExtractor = new DotExtractor(scanRange, applicationFactory); final ResponseHistogramBuilder mapHistogramSummary = new ResponseHistogramBuilder(range); /** * Convert to statistical data @@ -244,7 +247,7 @@ public class FilteredMapServiceImpl implements FilteredMapService { for (SpanBo span : transaction) { final Application parentApplication = createParentApplication(span, transactionSpanMap); - final Application spanApplication = new Application(span.getApplicationId(), registry.findServiceType(span.getApplicationServiceType())); + final Application spanApplication = this.applicationFactory.createApplication(span.getApplicationId(), span.getApplicationServiceType()); // records the Span's response time statistics recordSpanResponseTime(spanApplication, span, mapHistogramSummary, span.getCollectorAcceptTime()); @@ -323,7 +326,7 @@ public class FilteredMapServiceImpl implements FilteredMapService { if (CollectionUtils.isEmpty(spanEventBoList)) { return; } - final Application srcApplication = new Application(span.getApplicationId(), registry.findServiceType(span.getApplicationServiceType())); + final Application srcApplication = applicationFactory.createApplication(span.getApplicationId(), span.getApplicationServiceType()); LinkDataMap sourceLinkDataMap = linkDataDuplexMap.getSourceLinkDataMap(); for (SpanEventBo spanEvent : spanEventBoList) { @@ -343,11 +346,11 @@ public class FilteredMapServiceImpl implements FilteredMapService { } String dest = spanEvent.getDestinationId(); - if(dest == null) { + if (dest == null) { dest = "Unknown"; } - final Application destApplication = new Application(dest, destServiceType); + final Application destApplication = this.applicationFactory.createApplication(dest, destServiceType); final short slotTime = getHistogramSlotTime(spanEvent, destServiceType); @@ -367,12 +370,11 @@ public class FilteredMapServiceImpl implements FilteredMapService { if (span.isRoot() || parentSpan == null) { String applicationName = span.getApplicationId(); ServiceType serviceType = ServiceType.USER; - return new Application(applicationName, serviceType); + return this.applicationFactory.createApplication(applicationName, serviceType); } else { String parentApplicationName = parentSpan.getApplicationId(); - - ServiceType serviceType = registry.findServiceType(parentSpan.getApplicationServiceType()); - return new Application(parentApplicationName, serviceType); + short parentServiceType = parentSpan.getApplicationServiceType(); + return this.applicationFactory.createApplication(parentApplicationName, parentServiceType); } } diff --git a/web/src/main/java/com/navercorp/pinpoint/web/service/MapServiceImpl.java b/web/src/main/java/com/navercorp/pinpoint/web/service/MapServiceImpl.java index 1aa7a4119..cb748da7a 100644 --- a/web/src/main/java/com/navercorp/pinpoint/web/service/MapServiceImpl.java +++ b/web/src/main/java/com/navercorp/pinpoint/web/service/MapServiceImpl.java @@ -59,6 +59,9 @@ public class MapServiceImpl implements MapService { @Autowired private HostApplicationMapDao hostApplicationMapDao; + @Autowired + private ApplicationFactory applicationFactory; + @Autowired(required=false) private MatcherGroup matcherGroup; @@ -116,7 +119,7 @@ public class MapServiceImpl implements MapService { for (TimeHistogram timeHistogram : histogram.getTimeHistogram()) { Application toApplication = linkData.getToApplication(); if (toApplication.getServiceType().isRpcClient()) { - toApplication = new Application(toApplication.getName(), ServiceType.UNKNOWN); + toApplication = this.applicationFactory.createApplication(toApplication.getName(), ServiceType.UNKNOWN); } responseHistogramSummary.addLinkHistogram(toApplication, histogram.getId(), timeHistogram); }