public class Threads extends Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
Threads.Timer
Expires after defined time period.
|
static interface |
Threads.TimeSince
Measures the amount time that has elapsed since the last
reset. |
| Modifier and Type | Field and Description |
|---|---|
private static String |
DEBEZIUM_THREAD_NAME_PREFIX |
private static org.slf4j.Logger |
LOGGER |
| Modifier | Constructor and Description |
|---|---|
private |
Threads() |
| Modifier and Type | Method and Description |
|---|---|
static Thread |
interruptAfterTimeout(String threadName,
long timeout,
TimeUnit timeoutUnit,
Threads.TimeSince elapsedTimer)
Create a thread that will interrupt the calling thread when the
elapsed time has exceeded the
specified amount. |
static Thread |
interruptAfterTimeout(String threadName,
long timeout,
TimeUnit timeoutUnit,
Threads.TimeSince elapsedTimer,
Thread threadToInterrupt)
Create a thread that will interrupt the given thread when the
elapsed time has exceeded the
specified amount. |
static ExecutorService |
newFixedThreadPool(Class<? extends org.apache.kafka.connect.source.SourceConnector> connector,
String connectorId,
String name,
int threadCount) |
static ExecutorService |
newSingleThreadExecutor(Class<? extends org.apache.kafka.connect.source.SourceConnector> connector,
String connectorId,
String name) |
static ExecutorService |
newSingleThreadExecutor(Class<? extends org.apache.kafka.connect.source.SourceConnector> connector,
String connectorId,
String name,
boolean daemon) |
static ThreadFactory |
threadFactory(Class<? extends org.apache.kafka.connect.source.SourceConnector> connector,
String connectorId,
String name,
boolean indexed,
boolean daemon)
Returns a thread factory that creates threads conforming to Debezium thread naming
pattern
debezium-<connector class>-<connector-id>-<thread-name>. |
static ThreadFactory |
threadFactory(Class<? extends org.apache.kafka.connect.source.SourceConnector> connector,
String connectorId,
String name,
boolean indexed,
boolean daemon,
Consumer<Thread> callback)
Returns a thread factory that creates threads conforming to Debezium thread naming
pattern
debezium-<connector class>-<connector-id>-<thread-name>. |
static Thread |
timeout(String threadName,
long timeout,
TimeUnit timeoutUnit,
long sleepInterval,
TimeUnit sleepUnit,
LongSupplier elapsedTime,
Runnable uponStart,
Runnable uponTimeout)
Create a thread that will call the supplied function when the elapsed time has exceeded the
specified amount.
|
static Thread |
timeout(String threadName,
long timeout,
TimeUnit timeoutUnit,
long sleepInterval,
TimeUnit sleepUnit,
Threads.TimeSince elapsedTimer,
Runnable uponTimeout)
Create a thread that will call the supplied function when the
elapsed time has exceeded the
specified amount. |
static Thread |
timeout(String threadName,
long timeout,
TimeUnit timeoutUnit,
Threads.TimeSince elapsedTimer,
Runnable uponTimeout)
Create a thread that will call the supplied function when the
elapsed time has exceeded the
specified amount. |
static Threads.Timer |
timer(Clock clock,
Duration time)
Obtain a
Threads.Timer that uses the given clock to indicate that a pre-defined time period expired. |
static Threads.TimeSince |
timeSince(Clock clock)
Obtain a
Threads.TimeSince that uses the given clock to record the time elapsed. |
private static final String DEBEZIUM_THREAD_NAME_PREFIX
private static final org.slf4j.Logger LOGGER
public static Threads.TimeSince timeSince(Clock clock)
Threads.TimeSince that uses the given clock to record the time elapsed.clock - the clock; may not be nullThreads.TimeSince object; never nullpublic static Threads.Timer timer(Clock clock, Duration time)
Threads.Timer that uses the given clock to indicate that a pre-defined time period expired.clock - the clock; may not be nulltime - a time interval to expireThreads.Timer object; never nullpublic static Thread interruptAfterTimeout(String threadName, long timeout, TimeUnit timeoutUnit, Threads.TimeSince elapsedTimer)
elapsed time has exceeded the
specified amount. The supplied Threads.TimeSince object will be reset when the
new thread is started, and should also be reset any time the elapsed time should be reset to 0.threadName - the name of the new thread; may not be nulltimeout - the maximum amount of time that can elapse before the thread is interrupted; must be positivetimeoutUnit - the unit for timeout; may not be nullelapsedTimer - the component used to measure the elapsed time; may not be nullstarted; never nullpublic static Thread interruptAfterTimeout(String threadName, long timeout, TimeUnit timeoutUnit, Threads.TimeSince elapsedTimer, Thread threadToInterrupt)
elapsed time has exceeded the
specified amount. The supplied Threads.TimeSince object will be reset when the
new thread is started, and should also be reset any time the elapsed time should be reset to 0.threadName - the name of the new thread; may not be nulltimeout - the maximum amount of time that can elapse before the thread is interrupted; must be positivetimeoutUnit - the unit for timeout; may not be nullelapsedTimer - the component used to measure the elapsed time; may not be nullthreadToInterrupt - the thread that should be interrupted upon timeout; may not be nullstarted; never nullpublic static Thread timeout(String threadName, long timeout, TimeUnit timeoutUnit, Threads.TimeSince elapsedTimer, Runnable uponTimeout)
elapsed time has exceeded the
specified amount. The supplied Threads.TimeSince object will be reset when the
new thread is started, and should also be reset any time the elapsed time should be reset to 0.
The thread checks the elapsed time every 100 milliseconds.
threadName - the name of the new thread; may not be nulltimeout - the maximum amount of time that can elapse before the thread is interrupted; must be positivetimeoutUnit - the unit for timeout; may not be nullelapsedTimer - the component used to measure the elapsed time; may not be nulluponTimeout - the function to be called when the maximum amount of time has elapsed; may not be nullstarted; never nullpublic static Thread timeout(String threadName, long timeout, TimeUnit timeoutUnit, long sleepInterval, TimeUnit sleepUnit, Threads.TimeSince elapsedTimer, Runnable uponTimeout)
elapsed time has exceeded the
specified amount. The supplied Threads.TimeSince object will be reset when the
new thread is started, and should also be reset any time the elapsed time should be reset to 0.
The thread checks the elapsed time every 100 milliseconds.
threadName - the name of the new thread; may not be nulltimeout - the maximum amount of time that can elapse before the thread is interrupted; must be positivetimeoutUnit - the unit for timeout; may not be nullsleepInterval - the amount of time for the new thread to sleep after checking the elapsed time; must be positivesleepUnit - the unit for sleepInterval; may not be nullelapsedTimer - the component used to measure the elapsed time; may not be nulluponTimeout - the function to be called when the maximum amount of time has elapsed; may not be nullstarted; never nullpublic static Thread timeout(String threadName, long timeout, TimeUnit timeoutUnit, long sleepInterval, TimeUnit sleepUnit, LongSupplier elapsedTime, Runnable uponStart, Runnable uponTimeout)
threadName - the name of the new thread; may not be nulltimeout - the maximum amount of time that can elapse before the thread is interrupted; must be positivetimeoutUnit - the unit for timeout; may not be nullsleepInterval - the amount of time for the new thread to sleep after checking the elapsed time; must be positivesleepUnit - the unit for sleepInterval; may not be nullelapsedTime - the function that returns the total elapsed time; may not be nulluponStart - the function that will be called when the returned thread is started; may be nulluponTimeout - the function to be called when the maximum amount of time has elapsed; may not be nullstarted; never nullpublic static ThreadFactory threadFactory(Class<? extends org.apache.kafka.connect.source.SourceConnector> connector, String connectorId, String name, boolean indexed, boolean daemon)
debezium-<connector class>-<connector-id>-<thread-name>.connector - - the source connector classconnectorId - - the identifier to differentiate between connector instancesname - - the name of the threadindexed - - true if the thread name should be appended with an indexdaemon - - true if the thread should be a daemon threadpublic static ThreadFactory threadFactory(Class<? extends org.apache.kafka.connect.source.SourceConnector> connector, String connectorId, String name, boolean indexed, boolean daemon, Consumer<Thread> callback)
debezium-<connector class>-<connector-id>-<thread-name>.connector - - the source connector classconnectorId - - the identifier to differentiate between connector instancesname - - the name of the threadindexed - - true if the thread name should be appended with an indexdaemon - - true if the thread should be a daemon threadcallback - - a callback called on every thread createdpublic static ExecutorService newSingleThreadExecutor(Class<? extends org.apache.kafka.connect.source.SourceConnector> connector, String connectorId, String name, boolean daemon)
public static ExecutorService newFixedThreadPool(Class<? extends org.apache.kafka.connect.source.SourceConnector> connector, String connectorId, String name, int threadCount)
public static ExecutorService newSingleThreadExecutor(Class<? extends org.apache.kafka.connect.source.SourceConnector> connector, String connectorId, String name)
Copyright © 2021 JBoss by Red Hat. All rights reserved.