Skip to content

Commit 916aead

Browse files
Using Profiler class, from the utils package, instead of System.currentTimeMillis()
Signed-off-by: wilderrodrigues <[email protected]> This closes #525
1 parent 212ae88 commit 916aead

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

framework/cluster/src/com/cloud/cluster/ClusterServiceServletImpl.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
import org.apache.commons.httpclient.params.HttpClientParams;
2828
import org.apache.log4j.Logger;
2929

30+
import com.cloud.utils.Profiler;
31+
3032
public class ClusterServiceServletImpl implements ClusterService {
3133
private static final long serialVersionUID = 4574025200012566153L;
3234
private static final Logger s_logger = Logger.getLogger(ClusterServiceServletImpl.class);
@@ -87,16 +89,19 @@ private String executePostMethod(final HttpClient client, final PostMethod metho
8789
int response = 0;
8890
String result = null;
8991
try {
90-
final long startTick = System.currentTimeMillis();
92+
final Profiler profiler = new Profiler();
93+
profiler.start();
9194
response = client.executeMethod(method);
9295
if (response == HttpStatus.SC_OK) {
9396
result = method.getResponseBodyAsString();
97+
profiler.stop();
9498
if (s_logger.isDebugEnabled()) {
95-
s_logger.debug("POST " + _serviceUrl + " response :" + result + ", responding time: " + (System.currentTimeMillis() - startTick) + " ms");
99+
s_logger.debug("POST " + _serviceUrl + " response :" + result + ", responding time: " + profiler.getDurationInMillis() + " ms");
96100
}
97101
} else {
102+
profiler.stop();
98103
s_logger.error("Invalid response code : " + response + ", from : " + _serviceUrl + ", method : " + method.getParameter("method") + " responding time: " +
99-
(System.currentTimeMillis() - startTick));
104+
profiler.getDurationInMillis());
100105
}
101106
} catch (final HttpException e) {
102107
s_logger.error("HttpException from : " + _serviceUrl + ", method : " + method.getParameter("method"));

0 commit comments

Comments
 (0)