Class AbstractShutdownableResource<R>
java.lang.Object
com.linkedin.alpini.base.registry.AbstractShutdownableResource<R>
- All Implemented Interfaces:
Shutdownable,ShutdownableResource
- Direct Known Subclasses:
SyncShutdownableAdapter
public abstract class AbstractShutdownableResource<R>
extends Object
implements ShutdownableResource
A simplified implementation of a
ShutdownableResource.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract RunnableconstructShutdown(R object) The constructed runnable must callsignalShutdownInitiated()method to indicate that shutdown has started.final booleanReturns true if this resource has been shut down.final booleanReturns true if the resource has completed shutting down.final voidshutdown()Starts the shutdown process.protected final voidCalled by the Runnable to indicate that shutdown has started.final StringtoString()final voidWaits for shutdown to completefinal voidwaitForShutdown(long timeoutInMs) Waits for shutdown to complete with a timeout
-
Constructor Details
-
AbstractShutdownableResource
-
-
Method Details
-
signalShutdownInitiated
protected final void signalShutdownInitiated()Called by the Runnable to indicate that shutdown has started. -
constructShutdown
The constructed runnable must callsignalShutdownInitiated()method to indicate that shutdown has started.- Parameters:
object- Object to be shutdown- Returns:
- Runnable instance
-
isShutdown
public final boolean isShutdown()Returns true if this resource has been shut down.- Specified by:
isShutdownin interfaceShutdownableResource- Returns:
- true if this resource has been shut down
-
isTerminated
public final boolean isTerminated()Returns true if the resource has completed shutting down. Note that isTerminated is never true unless shutdown was called first.- Specified by:
isTerminatedin interfaceShutdownableResource- Returns:
- true if the resource has completed shutting down.
-
shutdown
public final void shutdown()Starts the shutdown process. The Runnable returned by constructShutdown() must callsignalShutdownInitiated().- Specified by:
shutdownin interfaceShutdownable
-
waitForShutdown
Waits for shutdown to complete- Specified by:
waitForShutdownin interfaceShutdownable- Throws:
InterruptedException- when the wait is interruptedIllegalStateException- when the method is invoked when the shutdown has yet to start
-
waitForShutdown
public final void waitForShutdown(long timeoutInMs) throws InterruptedException, IllegalStateException, TimeoutException Waits for shutdown to complete with a timeout- Specified by:
waitForShutdownin interfaceShutdownable- Parameters:
timeoutInMs- number of milliseconds to wait before throwing TimeoutException- Throws:
InterruptedException- when the wait is interruptedIllegalStateException- when the method is invoked when the shutdown has yet to startTimeoutException- when the operation times out
-
toString
-