use of com.alipay.sofa.rpc.client.aft.MeasureModel in project sofa-rpc by sofastack.
the class ServiceHorizontalMeasureStrategy method removeMeasureModel.
@Override
public MeasureModel removeMeasureModel(InvocationStat invocationStat) {
InvocationStatDimension statDimension = invocationStat.getDimension();
MeasureModel measureModel = appServiceMeasureModels.get(statDimension.getDimensionKey());
if (measureModel != null) {
measureModel.removeInvocationStat(invocationStat);
}
return measureModel;
}
use of com.alipay.sofa.rpc.client.aft.MeasureModel in project sofa-rpc by sofastack.
the class ServiceHorizontalMeasureStrategy method buildMeasureModel.
/**
* 如果该Invocation不属于一个MeasureModel,那么创建一个MeasureModel。并返回该MeasureModel。
* 如果该Invocation属于一个MeasureModel,那么将该Invocation加入到该MeasureModel中。返回null。
*
* @param invocationStat InvocationStat
* @return MeasureModel
*/
@Override
public MeasureModel buildMeasureModel(InvocationStat invocationStat) {
InvocationStatDimension statDimension = invocationStat.getDimension();
String key = statDimension.getDimensionKey();
MeasureModel measureModel = appServiceMeasureModels.get(key);
if (measureModel == null) {
measureModel = new MeasureModel(statDimension.getAppName(), statDimension.getService());
MeasureModel oldMeasureModel = appServiceMeasureModels.putIfAbsent(key, measureModel);
if (oldMeasureModel == null) {
measureModel.addInvocationStat(invocationStat);
return measureModel;
} else {
oldMeasureModel.addInvocationStat(invocationStat);
return null;
}
} else {
measureModel.addInvocationStat(invocationStat);
return null;
}
}
use of com.alipay.sofa.rpc.client.aft.MeasureModel in project sofa-rpc by sofastack.
the class ServiceHorizontalMeasureStrategy method logMeasureResult.
/**
* Print the measurement result details for each time window.
* @param measureResult
* @param timeWindow
* @param leastWindowCount
* @param averageExceptionRate
* @param leastWindowExceptionRateMultiple
*/
private void logMeasureResult(MeasureResult measureResult, long timeWindow, long leastWindowCount, double averageExceptionRate, double leastWindowExceptionRateMultiple) {
if (measureResult == null) {
return;
}
MeasureModel measureModel = measureResult.getMeasureModel();
String appName = measureModel.getAppName();
if (!LOGGER.isDebugEnabled(appName)) {
return;
}
String service = measureModel.getService();
List<InvocationStat> stats = measureModel.getInvocationStats();
List<MeasureResultDetail> details = measureResult.getAllMeasureResultDetails();
StringBuilder info = new StringBuilder();
info.append("measure info: service[" + service + "];stats{");
for (InvocationStat stat : stats) {
info.append(stat.getDimension().getIp());
info.append(",");
}
if (stats.size() > 0) {
info.deleteCharAt(info.length() - 1);
}
info.append("};details{");
info.append("timeWindow[" + timeWindow + "];leastWindowCount[" + leastWindowCount + "];averageExceptionRate[" + averageExceptionRate + "];leastWindowExceptionRateMultiple[" + leastWindowExceptionRateMultiple + "];");
info.append("detail[");
for (MeasureResultDetail detail : details) {
String ip = detail.getInvocationStatDimension().getIp();
double abnormalRate = detail.getAbnormalRate();
long invocationLeastWindowCount = detail.getLeastWindowCount();
String measureState = detail.getMeasureState().name();
info.append("(ip:" + ip + ",abnormalRate:" + abnormalRate + ",invocationLeastWindowCount:" + invocationLeastWindowCount + ",measureState:" + measureState + ")");
}
info.append("]");
LOGGER.debugWithApp(appName, info.toString());
}
Aggregations