Merge branch 'master' of nstopkimsk/pinpoint

from pull-request 266

* refs/heads/master:
  Merge remote-tracking branch 'upstream/master'
  convert comments in English
This commit is contained in:
Woonduk Kang
2014-12-18 14:05:32 +09:00
9 changed files with 38 additions and 33 deletions
@@ -3,7 +3,8 @@ package com.navercorp.pinpoint.bootstrap;
import java.util.concurrent.Callable;
/**
* contextClassLoader에 별도의 classLoader를 세팅하고 실행하는 template
* This template is used for changing the current thread's classloader to assigned one and execute callable.
*
* @author emeroad
*/
public class ContextClassLoaderExecuteTemplate<V> {
@@ -24,8 +25,9 @@ public class ContextClassLoaderExecuteTemplate<V> {
try {
return callable.call();
} finally {
// null일 경우도 다시 원복하는게 맞음.
// getContextClassLoader 호출시 에러가 발생하였을 경우 여기서 호출당하지 않으므로 이부분에서 원복하는게 맞음.
// even though the before classloader is null, rollback is needed.
// if an exception occurs before callable.call(), the call flow can't reach here.
// so rollback here is right.
currentThread.setContextClassLoader(before);
}
} catch (BootStrapException ex){
@@ -38,8 +38,9 @@ public class PinpointBootStrap {
}
final boolean duplicated = checkDuplicateLoadState();
if (duplicated) {
// 중복 케이스는 내가 처리하면 안됨. 아래와 같은 코드는 없어야 한다.
//loadStateChange(BOOT_STRAP_LOAD_STATE_ERROR);
// Don't handle the duplicated state. Don't use it as bellow.
//changeLoadState(BOOT_STRAP_LOAD_STATE_ERROR);
logPinpointAgentLoadFail();
return;
}
@@ -47,56 +48,56 @@ public class PinpointBootStrap {
ClassPathResolver classPathResolver = new ClassPathResolver();
boolean agentJarNotFound = classPathResolver.findAgentJar();
if (!agentJarNotFound) {
// TODO 이거 변경해야 함.
// TODO must modify this
logger.severe("pinpoint-bootstrap-x.x.x.jar not found.");
loadStateChange(BOOT_STRAP_LOAD_STATE_ERROR);
changeLoadState(BOOT_STRAP_LOAD_STATE_ERROR);
logPinpointAgentLoadFail();
return;
}
if (!isValidId("pinpoint.agentId", PinpointConstants.AGENT_NAME_MAX_LEN)) {
loadStateChange(BOOT_STRAP_LOAD_STATE_ERROR);
changeLoadState(BOOT_STRAP_LOAD_STATE_ERROR);
logPinpointAgentLoadFail();
return;
}
if (!isValidId("pinpoint.applicationName", PinpointConstants.APPLICATION_NAME_MAX_LEN)) {
loadStateChange(BOOT_STRAP_LOAD_STATE_ERROR);
changeLoadState(BOOT_STRAP_LOAD_STATE_ERROR);
logPinpointAgentLoadFail();
return;
}
String configPath = getConfigPath(classPathResolver);
if (configPath == null ) {
loadStateChange(BOOT_STRAP_LOAD_STATE_ERROR);
// 설정파일을 못찾으므로 종료.
changeLoadState(BOOT_STRAP_LOAD_STATE_ERROR);
logPinpointAgentLoadFail();
return;
}
// 로그가 저장될 위치를 시스템 properties로 저장한다.
// set the path of log file as a system property
saveLogFilePath(classPathResolver);
try {
// 설정파일 로드 이게 bootstrap에 있어야 되나는게 맞나?
// Is it right to load the configuration in the bootstrap?
ProfilerConfig profilerConfig = ProfilerConfig.load(configPath);
// 이게 로드할 lib List임.
// this is the library list that must be loaded
List<URL> libUrlList = resolveLib(classPathResolver);
AgentClassLoader agentClassLoader = new AgentClassLoader(libUrlList.toArray(new URL[libUrlList.size()]));
agentClassLoader.setBootClass(BOOT_CLASS);
logger.info("pinpoint agent start.");
agentClassLoader.boot(classPathResolver.getAgentDirPath(), agentArgs, instrumentation, profilerConfig);
logger.info("pinpoint agent start success.");
loadStateChange(BOOT_STRAP_LOAD_STATE_COMPLETE);
changeLoadState(BOOT_STRAP_LOAD_STATE_COMPLETE);
} catch (Exception e) {
// unexpected exception that did not be checked above
logger.log(Level.SEVERE, ProductInfo.CAMEL_NAME + " start fail. Caused:" + e.getMessage(), e);
// 위에서 리턴하는거에서 세는게 이
loadStateChange(BOOT_STRAP_LOAD_STATE_ERROR);
changeLoadState(BOOT_STRAP_LOAD_STATE_ERROR);
logPinpointAgentLoadFail();
}
}
private static void loadStateChange(String loadState) {
private static void changeLoadState(String loadState) {
System.setProperty(BOOT_STRAP_LOAD_STATE, loadState);
}
@@ -111,7 +112,7 @@ public class PinpointBootStrap {
private static boolean checkDuplicateLoadState() {
final String exist = System.getProperty(BOOT_STRAP_LOAD_STATE);
if (exist == null) {
loadStateChange(BOOT_STRAP_LOAD_STATE_LOADING);
changeLoadState(BOOT_STRAP_LOAD_STATE_LOADING);
} else {
if (logger.isLoggable(Level.SEVERE)) {
logger.severe("pinpoint-bootstrap already started. skip agent loading. loadState:" + exist);
@@ -128,7 +129,7 @@ public class PinpointBootStrap {
logger.severe("-D" + propertyName + " is null. value:null");
return false;
}
// 문자열 앞뒤에 공백은 허용되지 않음.
// blanks not permitted around value
value = value.trim();
if (value.isEmpty()) {
logger.severe("-D" + propertyName + " is empty. value:''");
@@ -182,7 +183,7 @@ public class PinpointBootStrap {
private static List<URL> resolveLib(ClassPathResolver classPathResolver) {
// 절대경로만 처리되지 않나함. 상대 경로(./../agentlib/lib등)일 경우의 처리가 있어야 될것 같음.
// this method may handle only absolute path, need to handle relative path (./..agentlib/lib)
String agentJarFullPath = classPathResolver.getAgentJarFullPath();
String agentLibPath = classPathResolver.getAgentLibPath();
List<URL> urlList = classPathResolver.resolveLib();
@@ -27,7 +27,7 @@ public class ProfilableClassFilter implements Filter<String> {
}
/**
* TODO remove this. 테스트 장비에서 call stack view가 잘 보이는지 테스트 하려고 추가함.
* TODO remove this. Added this method to test the "call stack view" on a test server
*
* @param className
* @return
@@ -559,7 +559,7 @@ public class ProfilerConfig {
// fortest
void readPropertyValues() {
// TODO : use Properties defaultvalue instead of using temp variable.
// TODO : use Properties's defaultvalue instead of using temp variable.
final ValueResolver placeHolderResolver = new PlaceHolderResolver();
this.profileEnable = readBoolean("profiler.enable", true);
@@ -674,7 +674,7 @@ public class ProfilerConfig {
this.nbaseArcPipeline = readBoolean("profiler.nbase_arc.pipeline", true);
//
// FIXME 임시용, line game netty configuration
// FIXME For temporary, netty configuration of Line Game
//
this.lineGameNettyParamDumpSize = readInt("profiler.line.game.netty.param.dumpsize", 512);
this.lineGameNettyEntityDumpSize = readInt("profiler.line.game.netty.entity.dumpsize", 512);
@@ -691,7 +691,7 @@ public class ProfilerConfig {
this.samplingEnable = readBoolean("profiler.sampling.enable", true);
this.samplingRate = readInt("profiler.sampling.rate", 1);
// 샘플링 + io 조절 bufferSize 결정
// configuration for sampling and IO buffer
this.ioBufferingEnable = readBoolean("profiler.io.buffering.enable", true);
// 버퍼 사이즈는 여기에 있는것은 문제가 있는것도 같음. 설정 조정의 필요성이 있음.
this.ioBufferingBufferSize = readInt("profiler.io.buffering.buffersize", 20);
@@ -704,10 +704,11 @@ public class ProfilerConfig {
// service type
this.applicationServerType = readServiceType("profiler.applicationservertype");
// profile package include
// TODO 제거, 서비스 적용에 call stack view가 잘 보이는지 테스트하려고 추가함.
// 수집 데이터 크기 문제로 실 서비스에서는 사용 안함.
// 나중에 필요에 따라 정규식으로 바꿔도 되고...
// TODO have to remove
// profile package include to test "call stack view".
// this config must not be used in service environment because the size of profiling information get heavy.
// We need change configuration to regular expression.
final String profileableClass = readString("profiler.include", "");
if (!profileableClass.isEmpty()) {
this.profilableClassFilter = new ProfilableClassFilter(profileableClass);
@@ -68,6 +68,8 @@ public interface RecordableTrace {
* 이 데이터는 서버맵에서 WAS끼리 호출관계를 알아낼 떄 필요하다.
*
* @param host host 값은 WAS를 호출한 URL상의 host를 가져와야 한다.
*
* WAS_A -> WAS_B
*/
void recordAcceptorHost(String host);
@@ -22,7 +22,7 @@ public class AgentStatDataCollector extends DataCollector {
private final ApplicationIndexDao applicationIndexDao;
private final long timeSlotEndTime;
private final long slotInterval;
private final AtomicBoolean init =new AtomicBoolean(false);// 동시에 checker들이 동작 되면 동시성 고려가 필요함
private final AtomicBoolean init =new AtomicBoolean(false); // need to consider the concurrency situation when checkers start simultaneously.
private final Map<String, Long> agentHeapUsageRate = new HashMap<String, Long>();
private final Map<String, Long> agentGcCount = new HashMap<String, Long>();
@@ -24,7 +24,7 @@ public class MapStatisticsCallerDataCollector extends DataCollector {
private long timeSlotEndTime;
private long slotInterval;
private Map<String, LinkCallData> calleStatMap = new HashMap<String, LinkCallData>();
private final AtomicBoolean init =new AtomicBoolean(false);// 동시에 checker들이 동작 되면 동시성 고려가 필요함
private final AtomicBoolean init =new AtomicBoolean(false); // need to consider the concurrency situation when checkers start simultaneously.
public MapStatisticsCallerDataCollector(DataCollectorCategory category, Application application, MapStatisticsCallerDao mapStatisticsCallerDao, long timeSlotEndTime, long slotInterval) {
super(category);
@@ -20,7 +20,7 @@ public class ResponseTimeDataCollector extends DataCollector {
private final MapResponseDao responseDao;
private final long timeSlotEndTime;
private final long slotInterval;
private final AtomicBoolean init =new AtomicBoolean(false);// 동시에 checker들이 동작 되면 동시성 고려가 필요함
private final AtomicBoolean init =new AtomicBoolean(false); // need to consider the concurrency situation when checkers start simultaneously.
private long slowCount = 0;
private long errorCount = 0;
@@ -48,7 +48,6 @@ public class ApplicationMapBuilder {
appendNodeResponseTime(nodeList, linkList, nodeHistogramDataSource);
// agentInfo를 넣는다.
appendAgentInfo(nodeList, linkDataDuplexMap, agentInfoService);
final ApplicationMap map = new ApplicationMap(range, nodeList, linkList);