Top Description Inners Fields Constructors Methods
io.vertx.core.net.impl

public Class NetServerImpl

extends TCPServerBase
implements Closeable, MetricsProvider, NetServer
Class Inheritance
All Implemented Interfaces
io.vertx.core.net.NetServer, io.vertx.core.metrics.Measured, io.vertx.core.spi.metrics.MetricsProvider, io.vertx.core.Closeable
Imports
io.netty.channel.Channel, .ChannelPipeline, .ChannelPromise, io.netty.handler.codec.haproxy.HAProxyMessageDecoder, io.netty.handler.logging.LoggingHandler, io.netty.handler.stream.ChunkedWriteHandler, io.netty.handler.timeout.IdleStateHandler, io.netty.handler.traffic.GlobalTrafficShapingHandler, io.netty.util.concurrent.GenericFutureListener, io.vertx.core.AsyncResult, .Closeable, .Future, .Handler, .Promise, io.vertx.core.http.impl.HttpUtils, io.vertx.core.impl.ContextInternal, .VertxInternal, io.vertx.core.impl.logging.Logger, .LoggerFactory, io.vertx.core.net.NetServer, .NetServerOptions, .NetSocket, .SocketAddress, io.vertx.core.spi.metrics.MetricsProvider, .TCPMetrics, .VertxMetrics, io.vertx.core.streams.ReadStream, java.util.function.BiConsumer

This class is thread-safe
Author
Tim Fox

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
private class

Field Summary

Modifier and TypeField and Description
private final NetServerImpl.NetSocketStream
private long
private Handler<Void>
private Handler<Throwable>
private Handler<NetSocket>
private static final Logger
Inherited from io.vertx.core.net.impl.TCPServerBase:
creatingContextoptionsvertx

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected synchronized boolean
protected BiConsumer<Channel, SslChannelProvider>
public Future<Void>
close()

Implements abstract io.vertx.core.net.impl.TCPServerBase.close.

Implements io.vertx.core.net.NetServer.close.

Close the server.

public void
close(Handler<AsyncResult<Void>>
the handler
completionHandler
)

Implements io.vertx.core.net.NetServer.close.

Like close but supplying a handler that will be notified when close is complete.

public synchronized void
close(Promise<Void>
the promise to signal when close has completed
completion
)

Overrides io.vertx.core.net.impl.TCPServerBase.close.

Implements io.vertx.core.Closeable.close.

Close this resource, the completion promise must be notified when the operation has completed.

public synchronized Handler<NetSocket>
public synchronized NetServer
public ReadStream<NetSocket>
connectStream()

Implements io.vertx.core.net.NetServer.connectStream.

Return the connect stream for this server.

protected TCPMetrics<?>
public synchronized NetServer
exceptionHandler(Handler<Throwable>
the handler to set
handler
)

Implements io.vertx.core.net.NetServer.exceptionHandler.

Set an exception handler called for socket errors happening before the connection is passed to the connectHandler, e.g during the TLS handshake.

private synchronized void
fetchAccepting(long amount)

protected void
initChannel(ChannelPipeline pipeline, boolean ssl)

public boolean
public synchronized Future<NetServer>
listen(SocketAddress
the local address to listen on
localAddress
)

Implements io.vertx.core.net.NetServer.listen.

Start listening on the specified local address, ignoring port and host configured in the io.vertx.core.net.NetServerOptions used when creating the server.

public Future<NetServer>
listen()

Implements io.vertx.core.net.NetServer.listen.

Start listening on the port and host as configured in the io.vertx.core.net.NetServerOptions used when creating the server.

private synchronized void
private synchronized void
Inherited from io.vertx.core.net.impl.TCPServerBase:
actualPortbindcreateSSLHelpercreateTrafficShapingHandlergetMetricsisListeningisMetricsEnabledsniEntrySizesslContextProviderupdateSSLOptionsupdateTrafficShapingOptions

Field Detail

connectStreamback to summary
private final NetServerImpl.NetSocketStream connectStream
demandback to summary
private long demand
endHandlerback to summary
private Handler<Void> endHandler
exceptionHandlerback to summary
private Handler<Throwable> exceptionHandler
handlerback to summary
private Handler<NetSocket> handler
logback to summary
private static final Logger log

Hides io.vertx.core.net.impl.TCPServerBase.log.

Constructor Detail

NetServerImplback to summary
public NetServerImpl(VertxInternal vertx, NetServerOptions options)

Method Detail

acceptback to summary
protected synchronized boolean accept()
childHandlerback to summary
protected BiConsumer<Channel, SslChannelProvider> childHandler(ContextInternal context, SocketAddress socketAddress, GlobalTrafficShapingHandler trafficShapingHandler)

Implements abstract io.vertx.core.net.impl.TCPServerBase.childHandler.

Annotations
@Override
closeback to summary
public Future<Void> close()

Implements abstract io.vertx.core.net.impl.TCPServerBase.close.

Implements io.vertx.core.net.NetServer.close.

Doc from io.vertx.core.net.NetServer.close.

Close the server. This will close any currently open connections. The close may not complete until after this method has returned.

Returns:Future<Void>

a future completed with the listen operation result

closeback to summary
public void close(Handler<AsyncResult<Void>> completionHandler)

Implements io.vertx.core.net.NetServer.close.

Doc from io.vertx.core.net.NetServer.close.

Like close but supplying a handler that will be notified when close is complete.

Parameters
completionHandler:Handler<AsyncResult<Void>>

the handler

Annotations
@Override
closeback to summary
public synchronized void close(Promise<Void> completion)

Overrides io.vertx.core.net.impl.TCPServerBase.close.

Implements io.vertx.core.Closeable.close.

Doc from io.vertx.core.Closeable.close.

Close this resource, the completion promise must be notified when the operation has completed.

Parameters
completion:Promise<Void>

the promise to signal when close has completed

Annotations
@Override
connectHandlerback to summary
public synchronized Handler<NetSocket> connectHandler()

Implements io.vertx.core.net.NetServer.connectHandler.

Annotations
@Override
connectHandlerback to summary
public synchronized NetServer connectHandler(Handler<NetSocket> handler)
Annotations
@Override
connectStreamback to summary
public ReadStream<NetSocket> connectStream()

Implements io.vertx.core.net.NetServer.connectStream.

Doc from io.vertx.core.net.NetServer.connectStream.

Return the connect stream for this server. The server can only have at most one handler at any one time. As the server accepts TCP or SSL connections it creates an instance of NetSocket and passes it to the connect stream ReadStream#handler(io.vertx.core.Handler).

Returns:ReadStream<NetSocket>

the connect stream

Annotations
@Override
createMetricsback to summary
protected TCPMetrics<?> createMetrics(SocketAddress localAddress)

Overrides io.vertx.core.net.impl.TCPServerBase.createMetrics.

Annotations
@Override
exceptionHandlerback to summary
public synchronized NetServer exceptionHandler(Handler<Throwable> handler)

Implements io.vertx.core.net.NetServer.exceptionHandler.

Doc from io.vertx.core.net.NetServer.exceptionHandler.

Set an exception handler called for socket errors happening before the connection is passed to the connectHandler, e.g during the TLS handshake.

Parameters
handler:Handler<Throwable>

the handler to set

Returns:NetServer

a reference to this, so the API can be used fluently

Annotations
@Override
fetchAcceptingback to summary
private synchronized void fetchAccepting(long amount)
initChannelback to summary
protected void initChannel(ChannelPipeline pipeline, boolean ssl)
isClosedback to summary
public boolean isClosed()
listenback to summary
public synchronized Future<NetServer> listen(SocketAddress localAddress)

Implements io.vertx.core.net.NetServer.listen.

Doc from io.vertx.core.net.NetServer.listen.

Start listening on the specified local address, ignoring port and host configured in the io.vertx.core.net.NetServerOptions used when creating the server.

The server may not be listening until some time after the call to listen has returned.

Parameters
localAddress:SocketAddress

the local address to listen on

Returns:Future<NetServer>

a future completed with the listen operation result

Annotations
@Override
listenback to summary
public Future<NetServer> listen()

Implements io.vertx.core.net.NetServer.listen.

Doc from io.vertx.core.net.NetServer.listen.

Start listening on the port and host as configured in the io.vertx.core.net.NetServerOptions used when creating the server.

The server may not be listening until some time after the call to listen has returned.

Returns:Future<NetServer>

a future completed with the listen operation result

Annotations
@Override
pauseAcceptingback to summary
private synchronized void pauseAccepting()
resumeAcceptingback to summary
private synchronized void resumeAccepting()
io.vertx.core.net.impl back to summary

private Class NetServerImpl.NetServerWorker

extends Object
implements BiConsumer<Channel, SslChannelProvider>
Class Inheritance
All Implemented Interfaces
java.util.function.BiConsumer

Field Summary

Modifier and TypeField and Description
private final Handler<NetSocket>
private final ContextInternal
private final Handler<Throwable>
private final GlobalTrafficShapingHandler

Constructor Summary

AccessConstructor and Description
pack-priv
NetServerWorker(ContextInternal context, Handler<NetSocket> connectionHandler, Handler<Throwable> exceptionHandler, GlobalTrafficShapingHandler trafficShapingHandler)

Method Summary

Modifier and TypeMethod and Description
public void
accept(Channel
the first input argument
ch
,
SslChannelProvider
the second input argument
sslChannelProvider
)

Implements java.util.function.BiConsumer.accept.

Performs this operation on the given arguments.

private void
private void
connected(Channel ch, SslChannelProvider sslChannelProvider)

private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

connectionHandlerback to summary
private final Handler<NetSocket> connectionHandler
contextback to summary
private final ContextInternal context
exceptionHandlerback to summary
private final Handler<Throwable> exceptionHandler
trafficShapingHandlerback to summary
private final GlobalTrafficShapingHandler trafficShapingHandler

Constructor Detail

NetServerWorkerback to summary
pack-priv NetServerWorker(ContextInternal context, Handler<NetSocket> connectionHandler, Handler<Throwable> exceptionHandler, GlobalTrafficShapingHandler trafficShapingHandler)

Method Detail

acceptback to summary
public void accept(Channel ch, SslChannelProvider sslChannelProvider)

Implements java.util.function.BiConsumer.accept.

Doc from java.util.function.BiConsumer.accept.

Performs this operation on the given arguments.

Parameters
ch:Channel

the first input argument

sslChannelProvider:SslChannelProvider

the second input argument

Annotations
@Override
configurePipelineback to summary
private void configurePipeline(Channel ch, SslChannelProvider sslChannelProvider)
connectedback to summary
private void connected(Channel ch, SslChannelProvider sslChannelProvider)
handleExceptionback to summary
private void handleException(Throwable cause)
io.vertx.core.net.impl back to summary

private Class NetServerImpl.NetSocketStream

extends Object
implements ReadStream<NetSocket>
Class Inheritance
All Implemented Interfaces
io.vertx.core.streams.ReadStream, io.vertx.core.streams.StreamBase

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public NetServerImpl.NetSocketStream
public NetServerImpl.NetSocketStream
public ReadStream<NetSocket>
fetch(long amount)

Implements io.vertx.core.streams.ReadStream.fetch.

Fetch the specified amount of elements.

public NetServerImpl.NetSocketStream
public NetServerImpl.NetSocketStream
pause()

Implements io.vertx.core.streams.ReadStream.pause.

Pause the ReadStream, it sets the buffer in fetch mode and clears the actual demand.

public NetServerImpl.NetSocketStream
resume()

Implements io.vertx.core.streams.ReadStream.resume.

Resume reading, and sets the buffer in flowing mode.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

NetSocketStreamback to summary
private NetSocketStream()

Method Detail

endHandlerback to summary
public NetServerImpl.NetSocketStream endHandler(Handler<Void> handler)
Annotations
@Override
exceptionHandlerback to summary
public NetServerImpl.NetSocketStream exceptionHandler(Handler<Throwable> handler)
Annotations
@Override
fetchback to summary
public ReadStream<NetSocket> fetch(long amount)

Implements io.vertx.core.streams.ReadStream.fetch.

Doc from io.vertx.core.streams.ReadStream.fetch.

Fetch the specified amount of elements. If the ReadStream has been paused, reading will recommence with the specified amount of items, otherwise the specified amount will be added to the current stream demand.

Returns:ReadStream<NetSocket>

a reference to this, so the API can be used fluently

Annotations
@Override
handlerback to summary
public NetServerImpl.NetSocketStream handler(Handler<NetSocket> handler)
Annotations
@Override
pauseback to summary
public NetServerImpl.NetSocketStream pause()

Implements io.vertx.core.streams.ReadStream.pause.

Doc from io.vertx.core.streams.ReadStream.pause.

Pause the ReadStream, it sets the buffer in fetch mode and clears the actual demand.

While it's paused, no data will be sent to the data handler.

Returns:NetServerImpl.NetSocketStream

a reference to this, so the API can be used fluently

Annotations
@Override
resumeback to summary
public NetServerImpl.NetSocketStream resume()

Implements io.vertx.core.streams.ReadStream.resume.

Doc from io.vertx.core.streams.ReadStream.resume.

Resume reading, and sets the buffer in flowing mode.

If the ReadStream has been paused, reading will recommence on it.

Returns:NetServerImpl.NetSocketStream

a reference to this, so the API can be used fluently

Annotations
@Override