public synchronized Answer[] waitFor(int s) throws InterruptedException { if (_disconnected) { return null; } if (_answers != null) { return _answers; } Profiler profiler = new Profiler(); profiler.start(); if (s <= 0) { wait(); } else { int ms = s * 1000; wait(ms); } profiler.stop(); if (s_logger.isTraceEnabled()) { s_logger.trace("Synchronized command - sending completed, time: " + profiler.getDurationInMillis() + ", answer: " + (_answers != null ? _answers[0].toString() : "null")); } return _answers; }
@Test public void testProfilerInMillis() { //Given final long sleepTimeMillis = SLEEP_TIME_NANO / 1000000L; //When pf.start(); pf.stop(); //Then Assert.assertTrue(pf.getDurationInMillis() == sleepTimeMillis); }
@Test public void testProfilerInNano() { //Given final long sleepTimeNano = SLEEP_TIME_NANO; //When pf.start(); pf.stop(); //Then Assert.assertTrue(pf.getDuration() == sleepTimeNano); }
@Test public void testProfilerNoStop() { //Given final long expectedAnswer = -1; //When pf.start(); //Then Assert.assertTrue(pf.getDurationInMillis() == expectedAnswer); Assert.assertFalse(pf.isStopped()); } }
@Test public void testProfilerNoStart() { //Given final long expectedAnswer = -1; //When pf.stop(); //Then Assert.assertTrue(pf.getDurationInMillis() == expectedAnswer); Assert.assertFalse(pf.isStarted()); }
@Before public void setUp() { pf = new Profiler(); PowerMockito.mockStatic(System.class); PowerMockito.when(System.nanoTime()).thenReturn(0L, SLEEP_TIME_NANO); }
@Override public String toString() { if (startTickNanoSeconds == null) { return "Not Started"; } if (stopTickNanoSeconds == null) { return "Started but not stopped"; } return "Done. Duration: " + getDurationInMillis() + "ms"; } }
RestAdapter restAdapter = new RestAdapter.Builder() //other stuff .setProfiler(new Profiler() { @Override public Object beforeCall() { return null; } @Override public void afterCall(RequestInformation requestInfo, long elapsedTime, int statusCode, Object beforeCallData) { //get what I need } }) .setLogLevel(RestAdapter.LogLevel.FULL).build();
@Override public String toString() { if (startTickNanoSeconds == null) { return "Not Started"; } if (stopTickNanoSeconds == null) { return "Started but not stopped"; } return "Done. Duration: " + getDurationInMillis() + "ms"; }
private String executePostMethod(final HttpClient client, final PostMethod method) { int response = 0; String result = null; try { final Profiler profiler = new Profiler(); profiler.start(); response = client.executeMethod(method); if (response == HttpStatus.SC_OK) { result = method.getResponseBodyAsString(); profiler.stop(); if (s_logger.isDebugEnabled()) { s_logger.debug("POST " + _serviceUrl + " response :" + result + ", responding time: " + profiler.getDurationInMillis() + " ms"); } } else { profiler.stop(); s_logger.error("Invalid response code : " + response + ", from : " + _serviceUrl + ", method : " + method.getParameter("method") + " responding time: " + profiler.getDurationInMillis()); } } catch (final HttpException e) { s_logger.error("HttpException from : " + _serviceUrl + ", method : " + method.getParameter("method")); } catch (final IOException e) { s_logger.error("IOException from : " + _serviceUrl + ", method : " + method.getParameter("method")); } catch (final Throwable e) { s_logger.error("Exception from : " + _serviceUrl + ", method : " + method.getParameter("method") + ", exception :", e); } finally { method.releaseConnection(); } return result; }
loader.addTranslator(ClassPool.getDefault(), new Profiler()); try { if (args.length < 1) {
Profiler p = new Profiler(); p.start(); int updated = 0; if (updateSeqno) { p.stop(); if (s_logger.isDebugEnabled()) { s_logger.debug("Security Group Mgr v2: done scheduling ruleset updates for " + workItems.size() + " vms: num new jobs=" + newJobs + " num rows insert or updated=" + updated + " time taken=" + p.getDurationInMillis());
final TransactionLegacy txn = TransactionLegacy.open("ClusterHeartbeat"); try { final Profiler profiler = new Profiler(); final Profiler profilerHeartbeatUpdate = new Profiler(); final Profiler profilerPeerScan = new Profiler(); profiler.start(); profilerHeartbeatUpdate.start(); txn.transitToAutoManagedConnection(TransactionLegacy.CLOUD_DB); if (s_logger.isTraceEnabled()) { profilerHeartbeatUpdate.stop(); profilerPeerScan.start(); if (s_logger.isTraceEnabled()) { s_logger.trace("Cluster manager peer-scan, id:" + _mshostId); profilerPeerScan.stop(); profiler.stop(); if (profiler.getDurationInMillis() >= HeartbeatInterval.value()) { if (s_logger.isDebugEnabled()) { s_logger.debug("Management server heartbeat takes too long to finish. profiler: " + profiler.toString() + ", profilerHeartbeatUpdate: " + profilerHeartbeatUpdate.toString() + ", profilerPeerScan: " + profilerPeerScan.toString());
public boolean lock(int timeoutSeconds) { int remainingMilliSeconds = timeoutSeconds * 1000; Profiler profiler = new Profiler(); boolean interrupted = false; try { profiler.start(); try { wait((timeoutSeconds) * 1000L); interrupted = true; profiler.stop(); remainingMilliSeconds -= profiler.getDurationInMillis(); if (remainingMilliSeconds < 0) return false;
case nodeAdded: if (msg.getNodes() != null && msg.getNodes().size() > 0) { final Profiler profiler = new Profiler(); profiler.start(); profiler.stop(); if (profiler.getDurationInMillis() > 1000) { if (s_logger.isDebugEnabled()) { s_logger.debug("Notifying management server join event took " + profiler.getDurationInMillis() + " ms"); s_logger.warn("Notifying management server join event took " + profiler.getDurationInMillis() + " ms"); final Profiler profiler = new Profiler(); profiler.start(); profiler.stop(); if (profiler.getDurationInMillis() > 1000) { if (s_logger.isDebugEnabled()) { s_logger.debug("Notifying management server leave event took " + profiler.getDurationInMillis() + " ms"); s_logger.warn("Notifying management server leave event took " + profiler.getDurationInMillis() + " ms");
final Profiler profiler = new Profiler(); profiler.start(); final Profiler profilerQueryActiveList = new Profiler(); profilerQueryActiveList.start(); final List<ManagementServerHostVO> currentList = _mshostDao.getActiveList(new Date(cutTime.getTime() - HeartbeatThreshold.value())); profilerQueryActiveList.stop(); final Profiler profilerSyncClusterInfo = new Profiler(); profilerSyncClusterInfo.start(); final List<ManagementServerHostVO> removedNodeList = new ArrayList<ManagementServerHostVO>(); final List<ManagementServerHostVO> invalidatedNodeList = new ArrayList<ManagementServerHostVO>(); profilerSyncClusterInfo.stop(); final Profiler profilerInvalidatedNodeList = new Profiler(); profilerInvalidatedNodeList.start(); profilerInvalidatedNodeList.stop(); final Profiler profilerRemovedList = new Profiler(); profilerRemovedList.start(); profilerRemovedList.stop(); profiler.stop(); if (profiler.getDurationInMillis() >= HeartbeatInterval.value()) { if (s_logger.isDebugEnabled()) {
final Profiler profiler = new Profiler(); profiler.start(); profiler.stop(); profiler.getDurationInMillis() + "ms. agent: " + pdu.getAgentId() + ", pdu seq: " + pdu.getSequenceId() + ", pdu ack seq: " + pdu.getAckSequenceId() + ", json: " + pdu.getJsonPackage());
private String executePostMethod(final HttpClient client, final PostMethod method) { int response = 0; String result = null; try { final Profiler profiler = new Profiler(); profiler.start(); response = client.executeMethod(method); if (response == HttpStatus.SC_OK) { result = method.getResponseBodyAsString(); profiler.stop(); if (s_logger.isDebugEnabled()) { s_logger.debug("POST " + _serviceUrl + " response :" + result + ", responding time: " + profiler.getDurationInMillis() + " ms"); } } else { profiler.stop(); s_logger.error("Invalid response code : " + response + ", from : " + _serviceUrl + ", method : " + method.getParameter("method") + " responding time: " + profiler.getDurationInMillis()); } } catch (final HttpException e) { s_logger.error("HttpException from : " + _serviceUrl + ", method : " + method.getParameter("method")); } catch (final IOException e) { s_logger.error("IOException from : " + _serviceUrl + ", method : " + method.getParameter("method")); } finally { method.releaseConnection(); } return result; } }
case nodeAdded: if (msg.getNodes() != null && msg.getNodes().size() > 0) { final Profiler profiler = new Profiler(); profiler.start(); profiler.stop(); if (profiler.getDurationInMillis() > 1000) { if (s_logger.isDebugEnabled()) { s_logger.debug("Notifying management server join event took " + profiler.getDurationInMillis() + " ms"); s_logger.warn("Notifying management server join event took " + profiler.getDurationInMillis() + " ms"); final Profiler profiler = new Profiler(); profiler.start(); profiler.stop(); if (profiler.getDurationInMillis() > 1000) { if (s_logger.isDebugEnabled()) { s_logger.debug("Notifying management server leave event took " + profiler.getDurationInMillis() + " ms"); s_logger.warn("Notifying management server leave event took " + profiler.getDurationInMillis() + " ms");
public boolean lock(final int timeoutSeconds) { int remainingMilliSeconds = timeoutSeconds * 1000; final Profiler profiler = new Profiler(); boolean interrupted = false; try { profiler.start(); try { wait((timeoutSeconds) * 1000L); interrupted = true; profiler.stop(); remainingMilliSeconds -= profiler.getDurationInMillis(); if (remainingMilliSeconds < 0) { return false;