Skip to content

Commit

Permalink
[#2801] Add parallel link selection
Browse files Browse the repository at this point in the history
  • Loading branch information
Xylus committed Jun 14, 2017
1 parent b95f632 commit 2e7748c
Show file tree
Hide file tree
Showing 28 changed files with 1,271 additions and 1,121 deletions.
Expand Up @@ -110,6 +110,7 @@ public ApplicationMap build(NodeList nodeList, LinkList linkList) {
}

private ApplicationMap build(LinkDataDuplexMap linkDataDuplexMap, NodeHistogramAppender nodeHistogramAppender, ServerInfoAppender serverInfoAppender) {
logger.info("Building application map");
NodeList nodeList = buildNode(linkDataDuplexMap);
LinkList linkList = buildLink(nodeList, linkDataDuplexMap);
return build(nodeList, linkList, linkDataDuplexMap, nodeHistogramAppender, serverInfoAppender);
Expand Down
Expand Up @@ -50,8 +50,9 @@ public class NodeHistogramAppenderFactory {
public NodeHistogramAppenderFactory(
@Value("#{pinpointWebProps['web.servermap.appender.mode'] ?: 'serial'}") String mode,
@Value("#{pinpointWebProps['web.servermap.appender.parallel.maxthreads'] ?: 16}") int maxThreads) {
logger.info("NodeHistogramAppender mode : {}", mode);
this.mode = mode;
if (this.mode.equals("parallel")) {
if (this.mode.equalsIgnoreCase("parallel")) {
executorService = Executors.newFixedThreadPool(maxThreads, new PinpointThreadFactory("Pinpoint-node-histogram-appender", true));
} else {
executorService = null;
Expand Down Expand Up @@ -93,9 +94,8 @@ public NodeHistogram createNodeHistogram(Application application, Range range) {
return from(nodeHistogramDataSource);
}

private NodeHistogramAppender from(NodeHistogramDataSource nodeHistogramDataSource) {
logger.debug("NodeHistogramAppender mode : {}", mode);
if (mode.equals("parallel")) {
public NodeHistogramAppender from(NodeHistogramDataSource nodeHistogramDataSource) {
if (mode.equalsIgnoreCase("parallel")) {
return new ParallelNodeHistogramAppender(nodeHistogramDataSource, executorService);
}
return new SerialNodeHistogramAppender(nodeHistogramDataSource);
Expand All @@ -106,7 +106,7 @@ public void preDestroy() {
if (executorService != null) {
executorService.shutdown();
try {
executorService.awaitTermination(5000, TimeUnit.MILLISECONDS);
executorService.awaitTermination(10, TimeUnit.SECONDS);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
Expand Down
Expand Up @@ -49,8 +49,9 @@ public class ServerInfoAppenderFactory {
public ServerInfoAppenderFactory(
@Value("#{pinpointWebProps['web.servermap.appender.mode'] ?: 'serial'}") String mode,
@Value("#{pinpointWebProps['web.servermap.appender.parallel.maxthreads'] ?: 16}") int maxThreads) {
logger.info("ServerInfoAppender mode : {}", mode);
this.mode = mode;
if (this.mode.equals("parallel")) {
if (this.mode.equalsIgnoreCase("parallel")) {
executorService = Executors.newFixedThreadPool(maxThreads, new PinpointThreadFactory("Pinpoint-node-histogram-appender", true));
} else {
executorService = null;
Expand All @@ -75,9 +76,8 @@ public ServerInfoAppender createAppender(AgentInfoService agentInfoService) {
return from(serverInstanceListDataSource);
}

private ServerInfoAppender from(ServerInstanceListDataSource serverInstanceListDataSource) {
logger.debug("ServerInfoAppender mode : {}", mode);
if (mode.equals("parallel")) {
public ServerInfoAppender from(ServerInstanceListDataSource serverInstanceListDataSource) {
if (mode.equalsIgnoreCase("parallel")) {
return new ParallelServerInfoAppender(serverInstanceListDataSource, executorService);
}
return new SerialServerInfoAppender(serverInstanceListDataSource);
Expand All @@ -88,7 +88,7 @@ public void preDestroy() {
if (executorService != null) {
executorService.shutdown();
try {
executorService.awaitTermination(5000, TimeUnit.MILLISECONDS);
executorService.awaitTermination(10, TimeUnit.SECONDS);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
Expand Down
Expand Up @@ -16,16 +16,14 @@

package com.navercorp.pinpoint.web.service.map;

import com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataMap;
import com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataDuplexMap;
import com.navercorp.pinpoint.web.vo.Application;
import com.navercorp.pinpoint.web.vo.Range;

/**
* @author HyunGil Jeong
*/
public interface LinkDataMapCreator {
public interface ApplicationMapCreator {

LinkDataMap createCallerLinkDataMap(Application application, Range range);
LinkDataDuplexMap createMap(Application application, LinkSelectContext linkSelectContext);

LinkDataMap createCalleeLinkDataMap(Application application, Range range);
}
Expand Up @@ -16,13 +16,15 @@

package com.navercorp.pinpoint.web.service.map;

import com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataDuplexMap;
import com.navercorp.pinpoint.web.vo.Application;

import java.util.List;

/**
* @author HyunGil Jeong
*/
@Deprecated
public class DFSLinkSelectorTest extends LinkSelectorTestBase {
@Override
protected String getSelectorMode() {
return "dfs";
}
public interface ApplicationsMapCreator {

LinkDataDuplexMap createLinkDataDuplexMap(List<Application> applications, LinkSelectContext linkSelectContext);
}
@@ -0,0 +1,73 @@
/*
* Copyright 2017 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.map;

import com.navercorp.pinpoint.common.util.PinpointThreadFactory;
import com.navercorp.pinpoint.web.dao.HostApplicationMapDao;
import com.navercorp.pinpoint.web.service.LinkDataMapService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
* @author HyunGil Jeong
*/
@Component
public class ApplicationsMapCreatorFactory {

private final Logger logger = LoggerFactory.getLogger(this.getClass());

private final String mode;

private final LinkDataMapService linkDataMapService;

private final HostApplicationMapDao hostApplicationMapDao;

private final ExecutorService executorService;

@Autowired
public ApplicationsMapCreatorFactory(
@Value("#{pinpointWebProps['web.servermap.creator.mode'] ?: 'serial'}") String mode,
@Value("#{pinpointWebProps['web.servermap.creator.parallel.maxthreads'] ?: '16'}") int threadCount,
HostApplicationMapDao hostApplicationMapDao,
LinkDataMapService linkDataMapService) {
logger.info("ApplicationsMapCreatorFactory mode : {}", mode);
this.mode = mode;
this.linkDataMapService = linkDataMapService;
this.hostApplicationMapDao = hostApplicationMapDao;
if (this.mode.equalsIgnoreCase("parallel")) {
this.executorService = Executors.newFixedThreadPool(threadCount, new PinpointThreadFactory("Pinpoint-parallel-link-selector", true));
} else {
this.executorService = null;
}
}

public ApplicationsMapCreator create(VirtualLinkMarker virtualLinkMarker) {
RpcCallReplacer rpcCallReplacer = new RpcCallReplacer(hostApplicationMapDao, virtualLinkMarker);
ApplicationMapCreator applicationMapCreator = new DefaultApplicationMapCreator(linkDataMapService, rpcCallReplacer);
if (mode.equalsIgnoreCase("parallel")) {
return new ParallelApplicationsMapCreator(applicationMapCreator, executorService);
}
return new SerialApplicationsMapCreator(applicationMapCreator);
}

}

0 comments on commit 2e7748c

Please sign in to comment.