Top Inners Fields Constructors Methods
org.apache.sshd.common.util.threads

public Class SshThreadPoolExecutor

extends ThreadPoolExecutor
implements CloseableExecutorService
Class Inheritance
All Implemented Interfaces
org.apache.sshd.common.util.threads.CloseableExecutorService, org.apache.sshd.common.Closeable, java.nio.channels.Channel, java.io.Closeable, java.lang.AutoCloseable, java.util.concurrent.ExecutorService, java.util.concurrent.Executor
Imports
java.util.List, java.util.concurrent.BlockingQueue, .RejectedExecutionHandler, .ThreadFactory, .ThreadPoolExecutor, .TimeUnit, org.apache.sshd.common.future.CloseFuture, .SshFutureListener, org.apache.sshd.common.util.closeable.AbstractCloseable

Author
Apache MINA SSHD Project

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected class

Field Summary

Modifier and TypeField and Description
protected final SshThreadPoolExecutor.DelegateCloseable

Constructor Summary

AccessConstructor and Description
public
SshThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue)

public
SshThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, ThreadFactory threadFactory)

public
SshThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, RejectedExecutionHandler handler)

public
SshThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, ThreadFactory threadFactory, RejectedExecutionHandler handler)

Method Summary

Modifier and TypeMethod and Description
public void
addCloseFutureListener(SshFutureListener<CloseFuture>
The notification SshFutureListener - never null
listener
)

Implements org.apache.sshd.common.Closeable.addCloseFutureListener.

Pre-register a listener to be informed when resource is closed.

public boolean
awaitTermination(long
the maximum time to wait
timeout
,
TimeUnit
the time unit of the timeout argument
unit
)

Overrides java.util.concurrent.ThreadPoolExecutor.awaitTermination.

Implements java.util.concurrent.ExecutorService.awaitTermination.

Blocks until all tasks have completed execution after a shutdown request, or the timeout occurs, or the current thread is interrupted, whichever happens first.

public CloseFuture
close(boolean
true if the resource should be shut down abruptly, false for a graceful close
immediately
)

Implements org.apache.sshd.common.Closeable.close.

Close this resource asynchronously and return a future.

public boolean
isClosed()

Implements org.apache.sshd.common.Closeable.isClosed.

Returns true if this object has been closed.

public boolean
isClosing()

Implements org.apache.sshd.common.Closeable.isClosing.

Returns true if the close(boolean) method has been called.

public boolean
isShutdown()

Overrides java.util.concurrent.ThreadPoolExecutor.isShutdown.

Implements java.util.concurrent.ExecutorService.isShutdown.

Returns true if this executor has been shut down.

public boolean
isTerminated()

Overrides java.util.concurrent.ThreadPoolExecutor.isTerminated.

Implements java.util.concurrent.ExecutorService.isTerminated.

Returns true if all tasks have completed following shut down.

public boolean
isTerminating()

Overrides java.util.concurrent.ThreadPoolExecutor.isTerminating.

Returns true if this executor is in the process of terminating after shutdown or shutdownNow but has not completely terminated.

public void
removeCloseFutureListener(SshFutureListener<CloseFuture>
The register SshFutureListener - never null. Ignored if not registered or resource already closed
listener
)

Implements org.apache.sshd.common.Closeable.removeCloseFutureListener.

Remove a pre-registered close event listener

public void
shutdown()

Overrides java.util.concurrent.ThreadPoolExecutor.shutdown.

Implements java.util.concurrent.ExecutorService.shutdown.

Initiates an orderly shutdown in which previously submitted tasks are executed, but no new tasks will be accepted.

public List<Runnable>
shutdownNow()

Overrides java.util.concurrent.ThreadPoolExecutor.shutdownNow.

Implements java.util.concurrent.ExecutorService.shutdownNow.

Attempts to stop all actively executing tasks, halts the processing of waiting tasks, and returns a list of the tasks that were awaiting execution.

protected void
terminated()

Overrides java.util.concurrent.ThreadPoolExecutor.terminated.

Method invoked when the Executor has terminated.

Inherited from java.util.concurrent.ThreadPoolExecutor:
afterExecuteallowCoreThreadTimeOutallowsCoreThreadTimeOutbeforeExecuteexecutefinalizegetActiveCountgetCompletedTaskCountgetCorePoolSizegetKeepAliveTimegetLargestPoolSizegetMaximumPoolSizegetPoolSizegetQueuegetRejectedExecutionHandlergetTaskCountgetThreadFactoryprestartAllCoreThreadsprestartCoreThreadpurgeremovesetCorePoolSizesetKeepAliveTimesetMaximumPoolSizesetRejectedExecutionHandlersetThreadFactorytoString

Field Detail

closeableback to summary
protected final SshThreadPoolExecutor.DelegateCloseable closeable

Constructor Detail

SshThreadPoolExecutorback to summary
public SshThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue)
SshThreadPoolExecutorback to summary
public SshThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, ThreadFactory threadFactory)
SshThreadPoolExecutorback to summary
public SshThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, RejectedExecutionHandler handler)
SshThreadPoolExecutorback to summary
public SshThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, ThreadFactory threadFactory, RejectedExecutionHandler handler)

Method Detail

addCloseFutureListenerback to summary
public void addCloseFutureListener(SshFutureListener<CloseFuture> listener)

Implements org.apache.sshd.common.Closeable.addCloseFutureListener.

Doc from org.apache.sshd.common.Closeable.addCloseFutureListener.

Pre-register a listener to be informed when resource is closed. If resource is already closed, the listener will be invoked immediately and not registered for future notification

Parameters
listener:SshFutureListener<CloseFuture>

The notification SshFutureListener - never null

Annotations
@Override
awaitTerminationback to summary
public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException

Overrides java.util.concurrent.ThreadPoolExecutor.awaitTermination.

Implements java.util.concurrent.ExecutorService.awaitTermination.

Doc from java.util.concurrent.ExecutorService.awaitTermination.

Blocks until all tasks have completed execution after a shutdown request, or the timeout occurs, or the current thread is interrupted, whichever happens first.

Parameters
timeout:long

the maximum time to wait

unit:TimeUnit

the time unit of the timeout argument

Returns:boolean

true if this executor terminated and false if the timeout elapsed before termination

Annotations
@Override
Exceptions
InterruptedException:
if interrupted while waiting
closeback to summary
public CloseFuture close(boolean immediately)

Implements org.apache.sshd.common.Closeable.close.

Doc from org.apache.sshd.common.Closeable.close.

Close this resource asynchronously and return a future. Resources support two closing modes: a graceful mode which will cleanly close the resource and an immediate mode which will close the resources abruptly.

Parameters
immediately:boolean

true if the resource should be shut down abruptly, false for a graceful close

Returns:CloseFuture

a CloseFuture representing the close request

Annotations
@Override
isClosedback to summary
public boolean isClosed()

Implements org.apache.sshd.common.Closeable.isClosed.

Doc from org.apache.sshd.common.Closeable.isClosed.

Returns true if this object has been closed.

Returns:boolean

true if closing

Annotations
@Override
isClosingback to summary
public boolean isClosing()

Implements org.apache.sshd.common.Closeable.isClosing.

Doc from org.apache.sshd.common.Closeable.isClosing.

Returns true if the close(boolean) method has been called. Note that this method will return true even if this isClosed() returns true.

Returns:boolean

true if closing

Annotations
@Override
isShutdownback to summary
public boolean isShutdown()

Overrides java.util.concurrent.ThreadPoolExecutor.isShutdown.

Implements java.util.concurrent.ExecutorService.isShutdown.

Doc from java.util.concurrent.ExecutorService.isShutdown.

Returns true if this executor has been shut down.

Returns:boolean

true if this executor has been shut down

Annotations
@Override
isTerminatedback to summary
public boolean isTerminated()

Overrides java.util.concurrent.ThreadPoolExecutor.isTerminated.

Implements java.util.concurrent.ExecutorService.isTerminated.

Doc from java.util.concurrent.ExecutorService.isTerminated.

Returns true if all tasks have completed following shut down. Note that isTerminated is never true unless either shutdown or shutdownNow was called first.

Returns:boolean

true if all tasks have completed following shut down

Annotations
@Override
isTerminatingback to summary
public boolean isTerminating()

Overrides java.util.concurrent.ThreadPoolExecutor.isTerminating.

Doc from java.util.concurrent.ThreadPoolExecutor.isTerminating.

Returns true if this executor is in the process of terminating after shutdown or shutdownNow but has not completely terminated. This method may be useful for debugging. A return of true reported a sufficient period after shutdown may indicate that submitted tasks have ignored or suppressed interruption, causing this executor not to properly terminate.

Returns:boolean

true if terminating but not yet terminated

Annotations
@Override
removeCloseFutureListenerback to summary
public void removeCloseFutureListener(SshFutureListener<CloseFuture> listener)

Implements org.apache.sshd.common.Closeable.removeCloseFutureListener.

Doc from org.apache.sshd.common.Closeable.removeCloseFutureListener.

Remove a pre-registered close event listener

Parameters
listener:SshFutureListener<CloseFuture>

The register SshFutureListener - never null. Ignored if not registered or resource already closed

Annotations
@Override
shutdownback to summary
public void shutdown()

Overrides java.util.concurrent.ThreadPoolExecutor.shutdown.

Implements java.util.concurrent.ExecutorService.shutdown.

Doc from java.util.concurrent.ExecutorService.shutdown.

Initiates an orderly shutdown in which previously submitted tasks are executed, but no new tasks will be accepted. Invocation has no additional effect if already shut down.

This method does not wait for previously submitted tasks to complete execution. Use awaitTermination to do that.

Annotations
@Override
shutdownNowback to summary
public List<Runnable> shutdownNow()

Overrides java.util.concurrent.ThreadPoolExecutor.shutdownNow.

Implements java.util.concurrent.ExecutorService.shutdownNow.

Doc from java.util.concurrent.ExecutorService.shutdownNow.

Attempts to stop all actively executing tasks, halts the processing of waiting tasks, and returns a list of the tasks that were awaiting execution.

This method does not wait for actively executing tasks to terminate. Use awaitTermination to do that.

There are no guarantees beyond best-effort attempts to stop processing actively executing tasks. For example, typical implementations will cancel via Thread#interrupt, so any task that fails to respond to interrupts may never terminate.

Returns:List<Runnable>

list of tasks that never commenced execution

Annotations
@Override
terminatedback to summary
protected void terminated()

Overrides java.util.concurrent.ThreadPoolExecutor.terminated.

Doc from java.util.concurrent.ThreadPoolExecutor.terminated.

Method invoked when the Executor has terminated. Default implementation does nothing.

Note

To properly nest multiple overridings, subclasses should generally invoke super.terminated within this method.

Annotations
@Override
org.apache.sshd.common.util.threads back to summary

protected Class SshThreadPoolExecutor.DelegateCloseable

extends AbstractCloseable
Class Inheritance

Field Summary

Inherited from org.apache.sshd.common.util.closeable.AbstractCloseable:
closeFuturefutureLockstate

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
protected CloseFuture
protected void
doCloseImmediately()

Overrides org.apache.sshd.common.util.closeable.AbstractCloseable.doCloseImmediately.

doCloseImmediately is called once and only once with state == Immediate Overriding methods should always call the base implementation.

protected void
Inherited from org.apache.sshd.common.util.closeable.AbstractCloseable:
addCloseFutureListenerbuilderclosegetFutureLockisClosedisClosingpreCloseremoveCloseFutureListener

Constructor Detail

DelegateCloseableback to summary
protected DelegateCloseable()

Method Detail

doCloseGracefullyback to summary
protected CloseFuture doCloseGracefully()

Overrides org.apache.sshd.common.util.closeable.AbstractCloseable.doCloseGracefully.

Annotations
@Override
doCloseImmediatelyback to summary
protected void doCloseImmediately()

Overrides org.apache.sshd.common.util.closeable.AbstractCloseable.doCloseImmediately.

Doc from org.apache.sshd.common.util.closeable.AbstractCloseable.doCloseImmediately.

doCloseImmediately is called once and only once with state == Immediate Overriding methods should always call the base implementation. It may be called concurrently while preClose() or doCloseGracefully is executing

Annotations
@Override
setClosedback to summary
protected void setClosed()