Top Description Fields Constructors Methods
org.apache.hc.core5.http.impl.bootstrap

public Class AsyncServer

extends AbstractConnectionInitiatorBase
implements IOReactorService, ConnectionAcceptor
Class Inheritance
All Implemented Interfaces
org.apache.hc.core5.reactor.ConnectionAcceptor, org.apache.hc.core5.reactor.IOReactorService, org.apache.hc.core5.reactor.IOReactor, org.apache.hc.core5.io.ModalCloseable, java.io.Closeable, java.lang.AutoCloseable
Known Direct Subclasses
org.apache.hc.core5.http.impl.bootstrap.HttpAsyncServer
Imports
java.io.IOException, java.net.SocketAddress, java.util.Set, java.util.concurrent.Future, org.apache.hc.core5.annotation.Internal, org.apache.hc.core5.concurrent.DefaultThreadFactory, .FutureCallback, org.apache.hc.core5.function.Callback, .Decorator, org.apache.hc.core5.io.CloseMode, org.apache.hc.core5.reactor.ConnectionAcceptor, .ConnectionInitiator, .DefaultListeningIOReactor, .IOEventHandlerFactory, .IOReactorConfig, .IOReactorService, .IOReactorStatus, .IOSession, .IOSessionListener, .ListenerEndpoint, org.apache.hc.core5.util.TimeValue

Protocol agnostic server side I/O session handler.

Field Summary

Modifier and TypeField and Description
private final DefaultListeningIOReactor

Constructor Summary

AccessConstructor and Description
public
AsyncServer(final IOEventHandlerFactory eventHandlerFactory, final IOReactorConfig ioReactorConfig, final Decorator<IOSession> ioSessionDecorator, final Callback<Exception> exceptionCallback, final IOSessionListener sessionListener, final Callback<IOSession> sessionShutdownCallback)

Method Summary

Modifier and TypeMethod and Description
public void
awaitShutdown(final TimeValue
wait time.
waitTime
)

Implements org.apache.hc.core5.reactor.IOReactor.awaitShutdown.

Blocks for the given period of time in milliseconds awaiting the completion of the reactor shutdown.
public void
close(final CloseMode
How to close the receiver.
closeMode
)

Implements org.apache.hc.core5.reactor.IOReactor.close.

Shuts down the I/O reactor either gracefully or immediately.
public void
close()

Implements java.io.Closeable.close.

Closes this stream and releases any system resources associated with it.
public Set<ListenerEndpoint>
getEndpoints()

Implements org.apache.hc.core5.reactor.ConnectionAcceptor.getEndpoints.

Returns a set of endpoints for this I/O reactor.
pack-priv ConnectionInitiator
public IOReactorStatus
getStatus()

Implements org.apache.hc.core5.reactor.IOReactor.getStatus.

Returns the current status of the reactor.
public void
initiateShutdown()

Implements org.apache.hc.core5.reactor.IOReactor.initiateShutdown.

Initiates shutdown of the reactor without blocking.
public Future<ListenerEndpoint>
listen(final SocketAddress
the socket address to listen on.
address
,
final Object
the attachment object.
attachment
,
final FutureCallback<ListenerEndpoint>
the result callback.
callback
)

Overrides default org.apache.hc.core5.reactor.ConnectionAcceptor.listen.

Opens a new listener endpoint with the given socket address.
public Future<ListenerEndpoint>
listen(final SocketAddress
the socket address to listen on.
address
,
final FutureCallback<ListenerEndpoint>
the result callback.
callback
)

Implements org.apache.hc.core5.reactor.ConnectionAcceptor.listen.

Opens a new listener endpoint with the given socket address.
public Future<ListenerEndpoint>
listen(final SocketAddress address)

public void
pause()

Implements org.apache.hc.core5.reactor.ConnectionAcceptor.pause.

Suspends the I/O reactor preventing it from accepting new connections on all active endpoints.
public void
resume()

Implements org.apache.hc.core5.reactor.ConnectionAcceptor.resume.

Resumes the I/O reactor restoring its ability to accept incoming connections on all active endpoints.
public void
Inherited from org.apache.hc.core5.http.impl.bootstrap.AbstractConnectionInitiatorBase:
connect

Field Detail

ioReactorback to summary
private final DefaultListeningIOReactor ioReactor

Constructor Detail

AsyncServerback to summary
public AsyncServer(final IOEventHandlerFactory eventHandlerFactory, final IOReactorConfig ioReactorConfig, final Decorator<IOSession> ioSessionDecorator, final Callback<Exception> exceptionCallback, final IOSessionListener sessionListener, final Callback<IOSession> sessionShutdownCallback)
Annotations
@Internal

Method Detail

awaitShutdownback to summary
public void awaitShutdown(final TimeValue waitTime) throws InterruptedException

Implements org.apache.hc.core5.reactor.IOReactor.awaitShutdown.

Doc from org.apache.hc.core5.reactor.IOReactor.awaitShutdown.

Blocks for the given period of time in milliseconds awaiting the completion of the reactor shutdown.

Parameters
waitTime:TimeValue

wait time.

Annotations
@Override
closeback to summary
public void close(final CloseMode closeMode)

Implements org.apache.hc.core5.reactor.IOReactor.close.

Doc from org.apache.hc.core5.reactor.IOReactor.close.

Shuts down the I/O reactor either gracefully or immediately. During graceful shutdown individual I/O sessions should be informed about imminent termination and be given a grace period to complete the ongoing I/O sessions. During immediate shutdown all ongoing I/O sessions get aborted immediately.

Parameters
closeMode:CloseMode

Doc from org.apache.hc.core5.io.ModalCloseable.close.

How to close the receiver.

Annotations
@Override
closeback to summary
public void close() throws IOException

Implements java.io.Closeable.close.

Doc from java.io.Closeable.close.

Closes this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect.

As noted in AutoCloseable#close(), cases where the close may fail require careful attention. It is strongly advised to relinquish the underlying resources and to internally mark the Closeable as closed, prior to throwing the IOException.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs
getEndpointsback to summary
public Set<ListenerEndpoint> getEndpoints()

Implements org.apache.hc.core5.reactor.ConnectionAcceptor.getEndpoints.

Doc from org.apache.hc.core5.reactor.ConnectionAcceptor.getEndpoints.

Returns a set of endpoints for this I/O reactor.

Returns:Set<ListenerEndpoint>

set of endpoints.

Annotations
@Override
getIOReactorback to summary
pack-priv ConnectionInitiator getIOReactor()

Implements abstract org.apache.hc.core5.http.impl.bootstrap.AbstractConnectionInitiatorBase.getIOReactor.

Annotations
@Override
getStatusback to summary
public IOReactorStatus getStatus()

Implements org.apache.hc.core5.reactor.IOReactor.getStatus.

Doc from org.apache.hc.core5.reactor.IOReactor.getStatus.

Returns the current status of the reactor.

Returns:IOReactorStatus

reactor status.

Annotations
@Override
initiateShutdownback to summary
public void initiateShutdown()

Implements org.apache.hc.core5.reactor.IOReactor.initiateShutdown.

Doc from org.apache.hc.core5.reactor.IOReactor.initiateShutdown.

Initiates shutdown of the reactor without blocking. The reactor is expected to terminate all active connections, to shut down itself and to release system resources it currently holds

Annotations
@Override
listenback to summary
public Future<ListenerEndpoint> listen(final SocketAddress address, final Object attachment, final FutureCallback<ListenerEndpoint> callback)

Overrides default org.apache.hc.core5.reactor.ConnectionAcceptor.listen.

Doc from org.apache.hc.core5.reactor.ConnectionAcceptor.listen.

Opens a new listener endpoint with the given socket address. Once the endpoint is fully initialized it starts accepting incoming connections and propagates I/O activity notifications to the I/O event dispatcher.

Parameters
address:SocketAddress

the socket address to listen on.

attachment:Object

the attachment object.

callback:FutureCallback<ListenerEndpoint>

the result callback.

Returns:Future<ListenerEndpoint>

listener endpoint.

Annotations
@Override
Since
5.1
listenback to summary
public Future<ListenerEndpoint> listen(final SocketAddress address, final FutureCallback<ListenerEndpoint> callback)

Implements org.apache.hc.core5.reactor.ConnectionAcceptor.listen.

Doc from org.apache.hc.core5.reactor.ConnectionAcceptor.listen.

Opens a new listener endpoint with the given socket address. Once the endpoint is fully initialized it starts accepting incoming connections and propagates I/O activity notifications to the I/O event dispatcher.

Parameters
address:SocketAddress

the socket address to listen on.

callback:FutureCallback<ListenerEndpoint>

the result callback.

Returns:Future<ListenerEndpoint>

listener endpoint.

Annotations
@Override
listenback to summary
public Future<ListenerEndpoint> listen(final SocketAddress address)
pauseback to summary
public void pause() throws IOException

Implements org.apache.hc.core5.reactor.ConnectionAcceptor.pause.

Doc from org.apache.hc.core5.reactor.ConnectionAcceptor.pause.

Suspends the I/O reactor preventing it from accepting new connections on all active endpoints.

Annotations
@Override
Exceptions
IOException:
in case of an I/O error.
resumeback to summary
public void resume() throws IOException

Implements org.apache.hc.core5.reactor.ConnectionAcceptor.resume.

Doc from org.apache.hc.core5.reactor.ConnectionAcceptor.resume.

Resumes the I/O reactor restoring its ability to accept incoming connections on all active endpoints.

Annotations
@Override
Exceptions
IOException:
in case of an I/O error.
startback to summary
public void start()

Implements org.apache.hc.core5.reactor.IOReactorService.start.

Doc from org.apache.hc.core5.reactor.IOReactorService.start.

Starts I/O reactor.

Annotations
@Override