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 java.lang.Object implements ShutdownableResource
A simplified implementation of aShutdownableResource.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractShutdownableResource(R object)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract java.lang.RunnableconstructShutdown(R object)The constructed runnable must callsignalShutdownInitiated()method to indicate that shutdown has started.booleanisShutdown()Returns true if this resource has been shut down.booleanisTerminated()Returns true if the resource has completed shutting down.voidshutdown()Starts the shutdown process.protected voidsignalShutdownInitiated()Called by the Runnable to indicate that shutdown has started.java.lang.StringtoString()voidwaitForShutdown()Waits for shutdown to completevoidwaitForShutdown(long timeoutInMs)Waits for shutdown to complete with a timeout
-
-
-
Constructor Detail
-
AbstractShutdownableResource
protected AbstractShutdownableResource(R object)
-
-
Method Detail
-
signalShutdownInitiated
protected final void signalShutdownInitiated()
Called by the Runnable to indicate that shutdown has started.
-
constructShutdown
protected abstract java.lang.Runnable constructShutdown(R object)
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
public final void waitForShutdown() throws java.lang.InterruptedException, java.lang.IllegalStateExceptionWaits for shutdown to complete- Specified by:
waitForShutdownin interfaceShutdownable- Throws:
java.lang.InterruptedException- when the wait is interruptedjava.lang.IllegalStateException- when the method is invoked when the shutdown has yet to start
-
waitForShutdown
public final void waitForShutdown(long timeoutInMs) throws java.lang.InterruptedException, java.lang.IllegalStateException, java.util.concurrent.TimeoutExceptionWaits for shutdown to complete with a timeout- Specified by:
waitForShutdownin interfaceShutdownable- Parameters:
timeoutInMs- number of milliseconds to wait before throwing TimeoutException- Throws:
java.lang.InterruptedException- when the wait is interruptedjava.lang.IllegalStateException- when the method is invoked when the shutdown has yet to startjava.util.concurrent.TimeoutException- when the operation times out
-
toString
public final java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-