public Pair<Integer, String> buildEdgeState(String domain, Dependency dependency) {
String type = formatType(dependency.getType());
String from = domain;
String to = dependency.getTarget();
EdgeConfig config = queryEdgeConfig(type, from, to);
long error = dependency.getErrorCount();
StringBuilder sb = new StringBuilder();
int errorCode = OK;
if (config != null) {
double avg = dependency.getAvg();
sb.append(buildDes(type, TOTAL_STR, String.valueOf(dependency.getTotalCount()))).append(GraphConstrant.ENTER);
if (avg >= config.getErrorResponseTime()) {
errorCode = ERROR;
sb.append(buildErrorDes(type, AVG_STR, m_df.format(avg), MILLISECOND)).append(GraphConstrant.ENTER);
} else if (avg >= config.getWarningResponseTime()) {
errorCode = WARN;
sb.append(buildWarningDes(type, AVG_STR, m_df.format(avg), MILLISECOND)).append(GraphConstrant.ENTER);
} else {
sb.append(buildDes(type, AVG_STR, m_df.format(avg), MILLISECOND)).append(GraphConstrant.ENTER);
}
if (error >= config.getErrorThreshold()) {
errorCode = ERROR;
sb.append(buildErrorDes(type, ERROR_STR, String.valueOf(error))).append(GraphConstrant.ENTER);
} else if (error >= config.getWarningThreshold()) {
errorCode = WARN;
sb.append(buildWarningDes(type, ERROR_STR, String.valueOf(error))).append(GraphConstrant.ENTER);
} else if (error > 0) {
sb.append(buildDes(type, ERROR_STR, String.valueOf(error))).append(GraphConstrant.ENTER);
}