use of com.creditease.uav.profiling.spi.ProfileElementInstance in project uavstack by uavorg.
the class MSCPProfileHandler method loadAppInfo.
/**
* load application info
*
* @param elem
* @param featureRootPath
* @param featureName
*/
private void loadAppInfo(ProfileElement elem, String featureRootPath, String appName) {
ProfileElementInstance inst = elem.getInstance("webapp");
String nodeAppName = ConfigurationManager.getInstance().getContext(IConfigurationManager.NODEAPPNAME);
String profileName = ConfigurationManager.getInstance().getContext(IConfigurationManager.PROFILENAME);
// get app name
inst.setValue("appname", nodeAppName);
// get app des
inst.setValue("appdes", "MSCP Application[" + appName + "] of NodeType[" + nodeAppName + "] with Profile[" + profileName + "]");
// get the real path of application context root
inst.setValue("webapproot", featureRootPath);
// get the app Http URL
inst.setValue("appurl", getServiceURI());
// get app group
getAppGroup(inst);
// get customized metrics
// getCustomizedMetrics(inst);
}
use of com.creditease.uav.profiling.spi.ProfileElementInstance in project uavstack by uavorg.
the class StandardProfileElement method getInstance.
@Override
public ProfileElementInstance getInstance(String id) {
if (null == id) {
return null;
}
ProfileElementInstance inst = this.instances.get(id);
if (null == inst) {
synchronized (instances) {
inst = this.instances.get(id);
if (null == inst) {
inst = new StandardProfileElementInstance(this, id, this.instances.size());
this.instances.put(id, inst);
}
}
}
return inst;
}
use of com.creditease.uav.profiling.spi.ProfileElementInstance in project uavstack by uavorg.
the class LogProfileHandler method profileFromJAppLogs.
/**
* profileFromJAppLogs
*
* @param elem
*/
private void profileFromJAppLogs(ProfileElement elem) {
String JAppLogs = System.getProperty("JAppLogs");
if (JAppLogs == null) {
return;
}
/**
* JAppLogs: goes to log4j
*/
ProfileElementInstance pei = elem.getInstance(LogProfileInfo.LogType.Log4j.toString());
String[] logFilesStr = JAppLogs.split(";");
for (String logFileStr : logFilesStr) {
int index = logFileStr.indexOf("*");
// normal file path
if (index == -1) {
pei.setValue(logFileStr, Collections.emptyMap());
} else // file patterns under folder
{
String folder = logFileStr.substring(0, index);
if (!IOHelper.exists(folder)) {
continue;
}
List<File> files = IOHelper.getFiles(folder);
for (File file : files) {
pei.setValue(file.getAbsolutePath(), Collections.emptyMap());
}
}
}
}
use of com.creditease.uav.profiling.spi.ProfileElementInstance in project uavstack by uavorg.
the class LogProfileHandler method profileFromLogProfileInfo.
/**
* profileFromLogProfileInfo
*
* @param elem
* @param ic
* @param appid
*/
private void profileFromLogProfileInfo(ProfileElement elem, InterceptContext ic, String appid) {
@SuppressWarnings("unchecked") LinkedList<LogProfileInfo> list = (LinkedList<LogProfileInfo>) ic.get(HookConstants.LOG_PROFILE_LIST);
if (list == null || list.size() == 0) {
this.logger.warn("Profile:LOGS FAILs as LogProfileInfo List is null or its size 0", null);
return;
}
// Log Source 1: AUTO Profiling
for (LogProfileInfo logProfileInfo : list) {
if (appid.equals(logProfileInfo.getAppId())) {
ProfileElementInstance pei = elem.getInstance(logProfileInfo.getLogType().toString());
String logPath = logProfileInfo.getFilePath();
// set the log file path
if (null != logPath) {
pei.setValue(logPath, logProfileInfo.getAttributes());
}
}
}
}
use of com.creditease.uav.profiling.spi.ProfileElementInstance in project uavstack by uavorg.
the class ProfileObserver method removeExpireIpLinkPEI.
@SuppressWarnings("unchecked")
private void removeExpireIpLinkPEI() {
long curTime = System.currentTimeMillis();
long appTimeout = DataConvertHelper.toLong(System.getProperty("com.creditease.uav.iplink.app.timeout"), 3600000);
long userTimeout = DataConvertHelper.toLong(System.getProperty("com.creditease.uav.iplink.user.timeout"), 60000);
long proxyTimeout = DataConvertHelper.toLong(System.getProperty("com.creditease.uav.iplink.proxy.timeout"), 3600000);
long proxyAppTimeout = DataConvertHelper.toLong(System.getProperty("com.creditease.uav.iplink.proxy.app.timeout"), 3600000);
long proxyUserTimeout = DataConvertHelper.toLong(System.getProperty("com.creditease.uav.iplink.proxy.user.timeout"), 60000);
ProfileElement pe = this.profile.getRepository().getElement(ProfileConstants.PROELEM_IPLINK);
ProfileElementInstance[] peis = pe.getInstances();
for (ProfileElementInstance pei : peis) {
// step 1: check pei expire
String peiId = pei.getInstanceId();
long peiTimeout = 0;
if (peiId.indexOf("browser") == 0) {
peiTimeout = userTimeout;
} else if (peiId.indexOf("proxy") == 0) {
peiTimeout = proxyTimeout;
} else {
peiTimeout = appTimeout;
}
long ts = (Long) pei.getValues().get("ts");
if (curTime - ts > peiTimeout) {
pe.removeInstance(pei.getInstanceId());
continue;
}
// step 2: check pei's clients expire
if (!pei.getValues().containsKey(ProfileConstants.PEI_CLIENTS)) {
continue;
}
Map<String, Long> clients = (Map<String, Long>) pei.getValues().get(ProfileConstants.PEI_CLIENTS);
for (String key : clients.keySet()) {
Long clientts = (long) clients.get(key);
long clientTimeout = 0;
if (key.indexOf("user") == 0) {
clientTimeout = proxyUserTimeout;
} else {
clientTimeout = proxyAppTimeout;
}
if (curTime - clientts > clientTimeout) {
clients.remove(key);
}
}
}
}
Aggregations