use of com.creditease.uav.profiling.spi.ProfileElement 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);
}
}
}
}
use of com.creditease.uav.profiling.spi.ProfileElement in project uavstack by uavorg.
the class StandardProfile method doProfiling.
@Override
public void doProfiling(ProfileContext context) {
ProfileElement[] pes = repository.getElements();
int state = 1;
repository.setState(state);
Set<String> IncludePes = context.getPE();
for (ProfileElement pe : pes) {
if (IncludePes.size() > 0 && (!IncludePes.contains(pe.getElemId()))) {
continue;
}
String hClass = pe.getElemHandlerClass();
if (null == hClass) {
continue;
}
/**
* select profiling handler to process
*/
ProfileHandler handler = selectHandler(hClass);
try {
handler.doProfiling(pe, context);
} catch (Exception e) {
this.logger.error("ProfileHandler[" + hClass + "] do profile FAILs ", e);
state = 3;
}
}
if (state == 1) {
state = 2;
}
repository.setState(state);
}
Aggregations