Skip to content

Commit

Permalink
refactoring tagcnt
Browse files Browse the repository at this point in the history
  • Loading branch information
ScouterProject committed Jul 14, 2015
1 parent c693744 commit 57da863
Show file tree
Hide file tree
Showing 9 changed files with 220 additions and 189 deletions.
7 changes: 6 additions & 1 deletion scouter.client/src/scouter/client/tags/TagCount.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,10 @@ protected int getChildSize() {
if (childs == null) return 0;
return childs.size();
}


@Override
public String toString() {
return "TagCount [tagName=" + tagName + ", value=" + value + ", count="
+ count + ", childs size = " + (childs == null ? "null" : childs.size()) + "]";
}
}
62 changes: 28 additions & 34 deletions scouter.client/src/scouter/client/tags/TagCountUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import scouter.client.model.TextProxy;
import scouter.lang.AlertLevel;
import scouter.lang.constants.TagConstants;
import scouter.lang.value.DecimalValue;
import scouter.lang.value.IP4Value;
import scouter.lang.value.ListValue;
Expand All @@ -42,55 +43,48 @@ public static List<String> loadTagString(int serverId, String date, List<Value>
for (Value v : vList) {
lv.add(CastUtil.cint(v.toJavaObject()));
}
if (tagName.equals("object")){
if (tagName.equals(TagConstants.NAME_OBJECT)){
TextProxy.object.load(date, lv, serverId);
for (int i = 0; i < lv.size(); i++) {
resultList.add(TextProxy.object.getText(lv.getInt(i)));
}
} else if (tagName.equals("service") || tagName.startsWith("service-")) {
} else if (tagName.equals(TagConstants.NAME_SERVICE)
|| tagName.equals(TagConstants.NAME_SERVICE_ELAPSED)
|| tagName.equals(TagConstants.NAME_SERVICE_BYTES)
|| tagName.equals(TagConstants.NAME_SERVICE_ERRORS)) {
TextProxy.service.load(date, lv, serverId);
for (int i = 0; i < lv.size(); i++) {
resultList.add(TextProxy.service.getText(lv.getInt(i)));
}
} else if (tagName.equals("user-agent")) {
} else if (tagName.equals(TagConstants.NAME_USER_AGENT)) {
TextProxy.userAgent.load(date, lv, serverId);
for (int i = 0; i < lv.size(); i++) {
resultList.add(TextProxy.userAgent.getText(lv.getInt(i)));
}
} else if (tagName.equals("group")) {
} else if (tagName.equals(TagConstants.NAME_GROUP)) {
TextProxy.group.load(date, lv, serverId);
for (int i = 0; i < lv.size(); i++) {
resultList.add(TextProxy.group.getText(lv.getInt(i)));
}
} else if (tagName.equals("city")) {
} else if (tagName.equals(TagConstants.NAME_CITY)) {
TextProxy.city.load(date, lv, serverId);
for (int i = 0; i < lv.size(); i++) {
resultList.add(TextProxy.city.getText(lv.getInt(i)));
}
} else if (tagName.equals("referer")) {
} else if (tagName.equals(TagConstants.NAME_REFERER)) {
TextProxy.referer.load(date, lv, serverId);
for (int i = 0; i < lv.size(); i++) {
resultList.add(TextProxy.referer.getText(lv.getInt(i)));
}
} else if (tagName.equals("error")) {
} else if (tagName.equals(TagConstants.NAME_ERROR)) {
TextProxy.error.load(date, lv, serverId);
for (int i = 0; i < lv.size(); i++) {
resultList.add(TextProxy.error.getText(lv.getInt(i)));
}
} else if (tagName.equals("sql")) {
TextProxy.sql.load(date, lv, serverId);
for (int i = 0; i < lv.size(); i++) {
resultList.add(TextProxy.sql.getText(lv.getInt(i)));
}
} else if (tagName.equals("apicall")) {
TextProxy.apicall.load(date, lv, serverId);
for (int i = 0; i < lv.size(); i++) {
resultList.add(TextProxy.apicall.getText(lv.getInt(i)));
}
}
break;
case ValueEnum.DECIMAL:
if (tagName.equals("level")) {
if (tagName.equals(TagConstants.NAME_LEVEL)) {
for (Value v : vList) {
resultList.add(AlertLevel.getName((byte)((DecimalValue)v).value));
}
Expand Down Expand Up @@ -120,25 +114,25 @@ public static List<String> loadTagString(int serverId, String date, List<Value>
}

public static Value convertTagToValue(String tagName, String tagValue) {
if (tagName.equals("object")
|| tagName.equals("service")
|| tagName.startsWith("service-")
|| tagName.equals("group")
|| tagName.equals("user-agent")
|| tagName.equals("referer")
|| tagName.equals("city")
|| tagName.equals("error")
|| tagName.equals("object")
|| tagName.equals("object")) {
if (tagName.equals(TagConstants.NAME_OBJECT)
|| tagName.equals(TagConstants.NAME_SERVICE)
|| tagName.equals(TagConstants.NAME_SERVICE_ELAPSED)
|| tagName.equals(TagConstants.NAME_SERVICE_BYTES)
|| tagName.equals(TagConstants.NAME_SERVICE_ERRORS)
|| tagName.equals(TagConstants.NAME_GROUP)
|| tagName.equals(TagConstants.NAME_USER_AGENT)
|| tagName.equals(TagConstants.NAME_REFERER)
|| tagName.equals(TagConstants.NAME_CITY)
|| tagName.equals(TagConstants.NAME_ERROR)) {
return new TextHashValue(tagValue);
} else if (tagName.equals("visitor")
|| tagName.equals("elapsed")
|| tagName.equals("sqltime")
|| tagName.equals("apitime")){
} else if (tagName.equals(TagConstants.NAME_VISITOR)
|| tagName.equals(TagConstants.NAME_ELAPSED)
|| tagName.equals(TagConstants.NAME_SQLTIME)
|| tagName.equals(TagConstants.NAME_APITIME)){
return new DecimalValue(Long.valueOf(tagValue));
} else if(tagName.equals("level")) {
} else if(tagName.equals(TagConstants.NAME_LEVEL)) {
return new DecimalValue(AlertLevel.getValue(tagValue));
} else if (tagName.equals("ip")) {
} else if (tagName.equals(TagConstants.NAME_IP)) {
return new IP4Value(tagValue);
}
return new TextValue(tagValue);
Expand Down
Loading

0 comments on commit 57da863

Please sign in to comment.