From fe5444dc80beeabeae42b8fb4bf5b2f662dd6604 Mon Sep 17 00:00:00 2001 From: Chisu Yu Date: Mon, 18 Feb 2013 06:56:42 +0000 Subject: [PATCH] =?UTF-8?q?[=EC=9C=A0=EC=B9=98=EC=88=98]=20[NOBTS]=20serve?= =?UTF-8?q?r=20map=EC=97=90=EC=84=9C=20request=20count=EA=B0=80=20?= =?UTF-8?q?=EB=A7=9E=EC=A7=80=20=EC=95=8A=EB=8A=94=20=ED=98=84=EC=83=81=20?= =?UTF-8?q?=EC=88=98=EC=A0=95.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://svn.bds.nhncorp.com/pe/hippo-web/trunk@1215 84d0f5b1-2673-498c-a247-62c4ff18d310 --- .../nhn/hippo/web/vo/ResponseHistogram.java | 43 ++++++++++++++++++- .../nhn/hippo/web/vo/TerminalStatistics.java | 4 +- 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/nhn/hippo/web/vo/ResponseHistogram.java b/src/main/java/com/nhn/hippo/web/vo/ResponseHistogram.java index 670caea6d..f412a8a91 100644 --- a/src/main/java/com/nhn/hippo/web/vo/ResponseHistogram.java +++ b/src/main/java/com/nhn/hippo/web/vo/ResponseHistogram.java @@ -1,6 +1,5 @@ package com.nhn.hippo.web.vo; -import java.util.Arrays; import java.util.List; import com.profiler.common.Histogram; @@ -81,6 +80,48 @@ public class ResponseHistogram { return total; } + public void mergeWith(ResponseHistogram histogram) { + if (!this.equals(histogram)) { + throw new IllegalArgumentException(); + } + + long[] otherValues = histogram.values; + for (int i = 0; i < values.length; i++) { + values[i] += otherValues[i]; + } + + this.errorCount += histogram.errorCount; + this.slowCount += histogram.slowCount; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((histogram == null) ? 0 : histogram.hashCode()); + result = prime * result + ((serviceType == null) ? 0 : serviceType.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + ResponseHistogram other = (ResponseHistogram) obj; + if (histogram == null) { + if (other.histogram != null) + return false; + } else if (!histogram.equals(other.histogram)) + return false; + if (serviceType != other.serviceType) + return false; + return true; + } + @Override public String toString() { StringBuilder sb = new StringBuilder(); diff --git a/src/main/java/com/nhn/hippo/web/vo/TerminalStatistics.java b/src/main/java/com/nhn/hippo/web/vo/TerminalStatistics.java index 457f62150..32ed22482 100644 --- a/src/main/java/com/nhn/hippo/web/vo/TerminalStatistics.java +++ b/src/main/java/com/nhn/hippo/web/vo/TerminalStatistics.java @@ -49,9 +49,7 @@ public class TerminalStatistics { public TerminalStatistics mergeWith(TerminalStatistics terminalRequest) { if (this.equals(terminalRequest)) { - // TODO merge histogram here. - - // this.histogram.mergeWith(terminalRequest.getHistogram()); + histogram.mergeWith(terminalRequest.getHistogram()); return this; } else { throw new IllegalArgumentException("Can't merge with different link.");