private void check() throws MetaException{ try { if (startTime < 0) { throw new DeadlineException("Should execute startTimer() method before " + "checkTimeout. Error happens in method: " + method); } if (startTime + timeout < System.currentTimeMillis()) { throw new DeadlineException("Timeout when executing method: " + method); } } catch (DeadlineException e) { throw newMetaException(e); } }
private void check() throws MetaException{ try { if (startTime < 0) { throw new DeadlineException("Should execute startTimer() method before " + "checkTimeout. Error happens in method: " + method); } if (startTime + timeout < System.currentTimeMillis()) { throw new DeadlineException("Timeout when executing method: " + method); } } catch (DeadlineException e) { throw newMetaException(e); } }
/** * reset the timeout value of this timer. * @param timeout */ public static void resetTimeout(long timeout) throws MetaException { if (timeout <= 0) { throw newMetaException(new DeadlineException("The reset timeout value should be " + "larger than 0: " + timeout)); } Deadline deadline = getCurrentDeadline(); if (deadline != null) { deadline.timeout = timeout; } else { throw newMetaException(new DeadlineException("The threadlocal Deadline is null," + " please register it firstly.")); } }
/** * end the time after a method is done. */ public static void stopTimer() throws MetaException { Deadline deadline = getCurrentDeadline(); if (deadline != null) { deadline.startTime = -1; deadline.method = null; } else { throw newMetaException(new DeadlineException("The threadlocal Deadline is null," + " please register it firstly.")); } }
/** * reset the timeout value of this timer. * @param timeout */ public static void resetTimeout(long timeout) throws MetaException { if (timeout <= 0) { throw newMetaException(new DeadlineException("The reset timeout value should be " + "larger than 0: " + timeout)); } Deadline deadline = getCurrentDeadline(); if (deadline != null) { deadline.timeout = timeout; } else { throw newMetaException(new DeadlineException("The threadlocal Deadline is null," + " please register it firstly.")); } }
/** * start the timer before a method is invoked. * @param method */ public static void startTimer(String method) throws MetaException { Deadline deadline = getCurrentDeadline(); if (deadline != null) { deadline.startTime = System.currentTimeMillis(); deadline.method = method; } else { throw newMetaException(new DeadlineException("The threadlocal Deadline is null," + " please register it firstly.")); } }
/** * start the timer before a method is invoked. * @param method */ public static void startTimer(String method) throws MetaException { Deadline deadline = getCurrentDeadline(); if (deadline != null) { deadline.startTime = System.currentTimeMillis(); deadline.method = method; } else { throw newMetaException(new DeadlineException("The threadlocal Deadline is null," + " please register it firstly.")); } }
/** * end the time after a method is done. */ public static void stopTimer() throws MetaException { Deadline deadline = getCurrentDeadline(); if (deadline != null) { deadline.startTime = -1; deadline.method = null; } else { throw newMetaException(new DeadlineException("The threadlocal Deadline is null," + " please register it firstly.")); } }
/** * Check whether the timer is started. * @return * @throws MetaException */ public static boolean isStarted() throws MetaException { Deadline deadline = getCurrentDeadline(); if (deadline != null) { return deadline.startTime >= 0; } else { throw newMetaException(new DeadlineException("The threadlocal Deadline is null," + " please register it firstly.")); } }
/** * Check whether the timer is started. * @return * @throws MetaException */ public static boolean isStarted() throws MetaException { Deadline deadline = getCurrentDeadline(); if (deadline != null) { return deadline.startTime >= 0; } else { throw newMetaException(new DeadlineException("The threadlocal Deadline is null," + " please register it firstly.")); } }
/** * Check whether the long running method timeout. * @throws DeadlineException when the method timeout */ public static void checkTimeout() throws MetaException { Deadline deadline = getCurrentDeadline(); if (deadline != null) { deadline.check(); } else { throw newMetaException(new DeadlineException("The threadlocal Deadline is null," + " please register it first.")); } }
/** * Check whether the long running method timeout. * @throws DeadlineException when the method timeout */ public static void checkTimeout() throws MetaException { Deadline deadline = getCurrentDeadline(); if (deadline != null) { deadline.check(); } else { throw newMetaException(new DeadlineException("The threadlocal Deadline is null," + " please register it first.")); } }