Class ScheduledExecutorUtil
- java.lang.Object
-
- org.apache.iotdb.commons.concurrent.threadpool.ScheduledExecutorUtil
-
public class ScheduledExecutorUtil extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description ScheduledExecutorUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.RuntimeExceptionpropagate(java.lang.Throwable throwable)static java.util.concurrent.ScheduledFuture<?>safelyScheduleAtFixedRate(java.util.concurrent.ScheduledExecutorService executor, java.lang.Runnable command, long initialDelay, long period, java.util.concurrent.TimeUnit unit)A safe wrapper method to make sure the exception thrown by the previous running will not affect the next one.static java.util.concurrent.ScheduledFuture<?>safelyScheduleWithFixedDelay(java.util.concurrent.ScheduledExecutorService executor, java.lang.Runnable command, long initialDelay, long delay, java.util.concurrent.TimeUnit unit)A safe wrapper method to make sure the exception thrown by the previous running will not affect the next one.static java.util.concurrent.ScheduledFuture<?>unsafelyScheduleAtFixedRate(java.util.concurrent.ScheduledExecutorService executor, java.lang.Runnable command, long initialDelay, long period, java.util.concurrent.TimeUnit unit)A wrapper method to have the same semantic withScheduledExecutorService.scheduleAtFixedRate(Runnable, long, long, TimeUnit), except for logging an error log when any uncaught exception happens.static java.util.concurrent.ScheduledFuture<?>unsafelyScheduleWithFixedDelay(java.util.concurrent.ScheduledExecutorService executor, java.lang.Runnable command, long initialDelay, long delay, java.util.concurrent.TimeUnit unit)A wrapper method to have the same semantic withScheduledExecutorService.scheduleWithFixedDelay(Runnable, long, long, TimeUnit), except for logging an error log when any uncaught exception happens.
-
-
-
Method Detail
-
safelyScheduleAtFixedRate
public static java.util.concurrent.ScheduledFuture<?> safelyScheduleAtFixedRate(java.util.concurrent.ScheduledExecutorService executor, java.lang.Runnable command, long initialDelay, long period, java.util.concurrent.TimeUnit unit)A safe wrapper method to make sure the exception thrown by the previous running will not affect the next one. Please reference the javadoc ofScheduledExecutorService.scheduleAtFixedRate(Runnable, long, long, TimeUnit)for more details.- Parameters:
executor- the ScheduledExecutorService instance.command- same parameter inScheduledExecutorService.scheduleAtFixedRate(Runnable, long, long, TimeUnit).initialDelay- same parameter inScheduledExecutorService.scheduleAtFixedRate(Runnable, long, long, TimeUnit).period- same parameter inScheduledExecutorService.scheduleAtFixedRate(Runnable, long, long, TimeUnit).unit- same parameter inScheduledExecutorService.scheduleAtFixedRate(Runnable, long, long, TimeUnit).- Returns:
- the same return value of
ScheduledExecutorService.scheduleAtFixedRate(Runnable, long, long, TimeUnit).
-
safelyScheduleWithFixedDelay
public static java.util.concurrent.ScheduledFuture<?> safelyScheduleWithFixedDelay(java.util.concurrent.ScheduledExecutorService executor, java.lang.Runnable command, long initialDelay, long delay, java.util.concurrent.TimeUnit unit)A safe wrapper method to make sure the exception thrown by the previous running will not affect the next one. Please reference the javadoc ofScheduledExecutorService.scheduleWithFixedDelay(Runnable, long, long, TimeUnit)for more details.- Parameters:
executor- the ScheduledExecutorService instance.command- same parameter inScheduledExecutorService.scheduleWithFixedDelay(Runnable, long, long, TimeUnit).initialDelay- same parameter inScheduledExecutorService.scheduleWithFixedDelay(Runnable, long, long, TimeUnit).delay- same parameter inScheduledExecutorService.scheduleWithFixedDelay(Runnable, long, long, TimeUnit).unit- same parameter inScheduledExecutorService.scheduleWithFixedDelay(Runnable, long, long, TimeUnit).- Returns:
- the same return value of
ScheduledExecutorService.scheduleWithFixedDelay(Runnable, long, long, TimeUnit).
-
unsafelyScheduleAtFixedRate
public static java.util.concurrent.ScheduledFuture<?> unsafelyScheduleAtFixedRate(java.util.concurrent.ScheduledExecutorService executor, java.lang.Runnable command, long initialDelay, long period, java.util.concurrent.TimeUnit unit)A wrapper method to have the same semantic withScheduledExecutorService.scheduleAtFixedRate(Runnable, long, long, TimeUnit), except for logging an error log when any uncaught exception happens.- Parameters:
executor- the ScheduledExecutorService instance.command- same parameter inScheduledExecutorService.scheduleAtFixedRate(Runnable, long, long, TimeUnit).initialDelay- same parameter inScheduledExecutorService.scheduleAtFixedRate(Runnable, long, long, TimeUnit).period- same parameter inScheduledExecutorService.scheduleAtFixedRate(Runnable, long, long, TimeUnit).unit- same parameter inScheduledExecutorService.scheduleAtFixedRate(Runnable, long, long, TimeUnit).- Returns:
- the same return value of
ScheduledExecutorService.scheduleAtFixedRate(Runnable, long, long, TimeUnit).
-
unsafelyScheduleWithFixedDelay
public static java.util.concurrent.ScheduledFuture<?> unsafelyScheduleWithFixedDelay(java.util.concurrent.ScheduledExecutorService executor, java.lang.Runnable command, long initialDelay, long delay, java.util.concurrent.TimeUnit unit)A wrapper method to have the same semantic withScheduledExecutorService.scheduleWithFixedDelay(Runnable, long, long, TimeUnit), except for logging an error log when any uncaught exception happens.- Parameters:
executor- the ScheduledExecutorService instance.command- same parameter inScheduledExecutorService.scheduleWithFixedDelay(Runnable, long, long, TimeUnit).initialDelay- same parameter inScheduledExecutorService.scheduleWithFixedDelay(Runnable, long, long, TimeUnit).delay- same parameter inScheduledExecutorService.scheduleWithFixedDelay(Runnable, long, long, TimeUnit).unit- same parameter inScheduledExecutorService.scheduleWithFixedDelay(Runnable, long, long, TimeUnit).- Returns:
- the same return value of
ScheduledExecutorService.scheduleWithFixedDelay(Runnable, long, long, TimeUnit).
-
propagate
public static java.lang.RuntimeException propagate(java.lang.Throwable throwable)
-
-