Top Description Inners Fields Constructors Methods
io.undertow.client.http2

public Class Http2ClientConnection

extends Object
implements ClientConnection
Class Inheritance
All Implemented Interfaces
io.undertow.client.ClientConnection, java.nio.channels.Channel, java.io.Closeable, java.lang.AutoCloseable
Imports
io.undertow.UndertowLogger, .UndertowMessages, io.undertow.client.ClientCallback, .ClientConnection, .ClientExchange, .ClientRequest, .ClientStatistics, io.undertow.connector.ByteBufferPool, io.undertow.protocols.http2.AbstractHttp2StreamSourceChannel, .Http2Channel, .Http2DataStreamSinkChannel, .Http2GoAwayStreamSourceChannel, .Http2HeadersStreamSinkChannel, .Http2PingStreamSourceChannel, .Http2PushPromiseStreamSourceChannel, .Http2RstStreamStreamSourceChannel, .Http2StreamSourceChannel, io.undertow.server.protocol.http.HttpAttachments, io.undertow.util.HeaderMap, .HeaderValues, .Headers, .HttpString, .Methods, .Protocols, org.xnio.ChannelExceptionHandler, .ChannelListener, .ChannelListeners, .IoUtils, .Option, .StreamConnection, .XnioIoThread, .XnioWorker, org.xnio.channels.Channels, .StreamSinkChannel, java.io.IOException, java.net.SocketAddress, java.nio.channels.ClosedChannelException, java.util.Arrays, .HashMap, .List, .Map, java.util.concurrent.ConcurrentHashMap, .CopyOnWriteArrayList, .TimeUnit, java.util.concurrent.atomic.AtomicLong, java.util.function.Supplier

ClientConnection implementation for HTTP2 protocol.
Authors
Stuart Douglas, Flavia Rainone

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
private static class

Field Summary

Modifier and TypeField and Description
private final ClientStatistics
private final List<ChannelListener<ClientConnection>>
private final ChannelListener.SimpleSetter<ClientConnection>
private final ChannelListener<Http2Channel>
private final Map<Integer, Http2ClientExchange>
private final String
private final Http2Channel
private boolean
private final Map<Http2ClientConnection.PingKey, ClientConnection.PingListener>
private static final AtomicLong
private final boolean

Constructor Summary

AccessConstructor and Description
public
Http2ClientConnection(Http2Channel http2Channel, boolean initialUpgradeRequest, String defaultHost, ClientStatistics clientStatistics, boolean secure)

public
Http2ClientConnection(Http2Channel http2Channel, ClientCallback<ClientExchange> upgradeReadyCallback, ClientRequest clientRequest, String defaultHost, ClientStatistics clientStatistics, boolean secure)

Method Summary

Modifier and TypeMethod and Description
public void
addCloseListener(ChannelListener<ClientConnection>
The close listener
listener
)

Implements io.undertow.client.ClientConnection.addCloseListener.

Adds a close listener, than will be invoked with the connection is closed

public void
close()

Implements java.nio.channels.Channel.close.

Closes this channel.

public ByteBufferPool
public ChannelListener.Setter<? extends ClientConnection>
public XnioIoThread
public SocketAddress
public <A extends SocketAddress> A
public <T> T
public SocketAddress
public <A extends SocketAddress> A
public ClientStatistics
public XnioWorker
private void
public boolean
public boolean
isOpen()

Implements io.undertow.client.ClientConnection.isOpen.

Tells whether or not this channel is open.

public boolean
public boolean
public boolean
public boolean
public StreamConnection
performUpgrade()

Implements io.undertow.client.ClientConnection.performUpgrade.

Upgrade the connection, if the underlying protocol supports it.

public void
public void
sendRequest(ClientRequest
The request to send.
request
,
ClientCallback<ClientExchange> clientCallback)

Implements io.undertow.client.ClientConnection.sendRequest.

Sends a client request.

public <T> T
public boolean
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

clientStatisticsback to summary
private final ClientStatistics clientStatistics
closeListenersback to summary
private final List<ChannelListener<ClientConnection>> closeListeners
closeSetterback to summary
private final ChannelListener.SimpleSetter<ClientConnection> closeSetter
closeTaskback to summary
private final ChannelListener<Http2Channel> closeTask
currentExchangesback to summary
private final Map<Integer, Http2ClientExchange> currentExchanges
defaultHostback to summary
private final String defaultHost
http2Channelback to summary
private final Http2Channel http2Channel
initialUpgradeRequestback to summary
private boolean initialUpgradeRequest
outstandingPingsback to summary
private final Map<Http2ClientConnection.PingKey, ClientConnection.PingListener> outstandingPings
PING_COUNTERback to summary
private static final AtomicLong PING_COUNTER
secureback to summary
private final boolean secure

Constructor Detail

Http2ClientConnectionback to summary
public Http2ClientConnection(Http2Channel http2Channel, boolean initialUpgradeRequest, String defaultHost, ClientStatistics clientStatistics, boolean secure)
Http2ClientConnectionback to summary
public Http2ClientConnection(Http2Channel http2Channel, ClientCallback<ClientExchange> upgradeReadyCallback, ClientRequest clientRequest, String defaultHost, ClientStatistics clientStatistics, boolean secure)

Method Detail

addCloseListenerback to summary
public void addCloseListener(ChannelListener<ClientConnection> listener)

Implements io.undertow.client.ClientConnection.addCloseListener.

Doc from io.undertow.client.ClientConnection.addCloseListener.

Adds a close listener, than will be invoked with the connection is closed

Parameters
listener:ChannelListener<ClientConnection>

The close listener

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

Implements java.nio.channels.Channel.close.

Doc from java.nio.channels.Channel.close.

Closes this channel.

After a channel is closed, any further attempt to invoke I/O operations upon it will cause a ClosedChannelException to be thrown.

If this channel is already closed then invoking this method has no effect.

This method may be invoked at any time. If some other thread has already invoked it, however, then another invocation will block until the first invocation is complete, after which it will return without effect.

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs
getBufferPoolback to summary
public ByteBufferPool getBufferPool()

Implements io.undertow.client.ClientConnection.getBufferPool.

Returns:ByteBufferPool

Doc from io.undertow.client.ClientConnection.getBufferPool.

The buffer pool used by the client

Annotations
@Override
getCloseSetterback to summary
public ChannelListener.Setter<? extends ClientConnection> getCloseSetter()

Implements io.undertow.client.ClientConnection.getCloseSetter.

Annotations
@Override
getIoThreadback to summary
public XnioIoThread getIoThread()

Implements io.undertow.client.ClientConnection.getIoThread.

Annotations
@Override
getLocalAddressback to summary
public SocketAddress getLocalAddress()

Implements io.undertow.client.ClientConnection.getLocalAddress.

Annotations
@Override
getLocalAddressback to summary
public <A extends SocketAddress> A getLocalAddress(Class<A> type)

Implements io.undertow.client.ClientConnection.getLocalAddress.

Annotations
@Override
getOptionback to summary
public <T> T getOption(Option<T> option) throws IOException

Implements io.undertow.client.ClientConnection.getOption.

Annotations
@Override
getPeerAddressback to summary
public SocketAddress getPeerAddress()

Implements io.undertow.client.ClientConnection.getPeerAddress.

Annotations
@Override
getPeerAddressback to summary
public <A extends SocketAddress> A getPeerAddress(Class<A> type)

Implements io.undertow.client.ClientConnection.getPeerAddress.

Annotations
@Override
getStatisticsback to summary
public ClientStatistics getStatistics()

Implements io.undertow.client.ClientConnection.getStatistics.

Returns:ClientStatistics

Doc from io.undertow.client.ClientConnection.getStatistics.

the statistics information, or null if statistics are not supported or disabled

Annotations
@Override
getWorkerback to summary
public XnioWorker getWorker()

Implements io.undertow.client.ClientConnection.getWorker.

Annotations
@Override
handleErrorback to summary
private void handleError(Throwable t)
isMultiplexingSupportedback to summary
public boolean isMultiplexingSupported()

Implements io.undertow.client.ClientConnection.isMultiplexingSupported.

Returns:boolean

Doc from io.undertow.client.ClientConnection.isMultiplexingSupported.

true if this client supports multiplexing

Annotations
@Override
isOpenback to summary
public boolean isOpen()

Implements io.undertow.client.ClientConnection.isOpen.

Doc from java.nio.channels.Channel.isOpen.

Tells whether or not this channel is open.

Returns:boolean

true if, and only if, this channel is open

Annotations
@Override
isPingSupportedback to summary
public boolean isPingSupported()

Overrides default io.undertow.client.ClientConnection.isPingSupported.

Returns:boolean

Doc from io.undertow.client.ClientConnection.isPingSupported.

true if the underlying protocol supports sending a ping

Annotations
@Override
isPushSupportedback to summary
public boolean isPushSupported()

Implements io.undertow.client.ClientConnection.isPushSupported.

Returns:boolean

Doc from io.undertow.client.ClientConnection.isPushSupported.

true if this connection support server push

Annotations
@Override
isUpgradedback to summary
public boolean isUpgraded()

Implements io.undertow.client.ClientConnection.isUpgraded.

Annotations
@Override
isUpgradeSupportedback to summary
public boolean isUpgradeSupported()

Implements io.undertow.client.ClientConnection.isUpgradeSupported.

Annotations
@Override
performUpgradeback to summary
public StreamConnection performUpgrade() throws IOException

Implements io.undertow.client.ClientConnection.performUpgrade.

Doc from io.undertow.client.ClientConnection.performUpgrade.

Upgrade the connection, if the underlying protocol supports it. This should only be called after an upgrade request has been submitted and the target server has accepted the upgrade.

Returns:StreamConnection

The resulting StreamConnection

Annotations
@Override
sendPingback to summary
public void sendPing(ClientConnection.PingListener listener, long timeout, TimeUnit timeUnit)

Overrides default io.undertow.client.ClientConnection.sendPing.

Annotations
@Override
sendRequestback to summary
public void sendRequest(ClientRequest request, ClientCallback<ClientExchange> clientCallback)

Implements io.undertow.client.ClientConnection.sendRequest.

Doc from io.undertow.client.ClientConnection.sendRequest.

Sends a client request. The request object should not be modified after it has been submitted to the connection.

Request objects can be queued. Once the request is in a state that it is ready to be sent the clientCallback is invoked to provide the caller with the ClientExchange

If isMultiplexingSupported() returns true then multiple requests may be active at the same time, and a later request may complete before an earlier one.

Note that the request header may not be written out until after the callback has been invoked. This allows the client to write out a header with a gathering write if the request contains content.

Parameters
request:ClientRequest

The request to send.

Annotations
@Override
setOptionback to summary
public <T> T setOption(Option<T> option, T value) throws IllegalArgumentException, IOException

Implements io.undertow.client.ClientConnection.setOption.

Annotations
@Override
supportsOptionback to summary
public boolean supportsOption(Option<?> option)

Implements io.undertow.client.ClientConnection.supportsOption.

Annotations
@Override
io.undertow.client.http2 back to summary

private Class Http2ClientConnection.Http2ReceiveListener

extends Object
implements ChannelListener<Http2Channel>
Class Inheritance
  • java.lang.Object
  • io.undertow.client.http2.Http2ClientConnection.Http2ReceiveListener
All Implemented Interfaces
org.xnio.ChannelListener, java.util.EventListener

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
handleEvent(Http2Channel
the channel event
channel
)

Implements org.xnio.ChannelListener.handleEvent.

Handle the event on this channel.

private void
private void
private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

Http2ReceiveListenerback to summary
private Http2ReceiveListener()

Method Detail

handleEventback to summary
public void handleEvent(Http2Channel channel)

Implements org.xnio.ChannelListener.handleEvent.

Doc from org.xnio.ChannelListener.handleEvent.

Handle the event on this channel.

Parameters
channel:Http2Channel

the channel event

Annotations
@Override
handleFinalResponseback to summary
private void handleFinalResponse(Http2Channel channel, Http2ClientExchange request, Http2StreamSourceChannel response) throws IOException
handlePingback to summary
private void handlePing(Http2PingStreamSourceChannel frame)
handleThrowableback to summary
private void handleThrowable(Throwable t)
io.undertow.client.http2 back to summary

private Class Http2ClientConnection.Http2ReceiveListener.ContinueReceiveListener

extends Object
implements ChannelListener<AbstractHttp2StreamSourceChannel>
Class Inheritance
  • java.lang.Object
  • io.undertow.client.http2.Http2ClientConnection.Http2ReceiveListener.ContinueReceiveListener
All Implemented Interfaces
org.xnio.ChannelListener, java.util.EventListener

Field Summary

Modifier and TypeField and Description
private final Http2Channel

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
handleEvent(AbstractHttp2StreamSourceChannel
the channel event
sourceChannel
)

Implements org.xnio.ChannelListener.handleEvent.

Handle the event on this channel.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

http2Channelback to summary
private final Http2Channel http2Channel

Constructor Detail

ContinueReceiveListenerback to summary
pack-priv ContinueReceiveListener(Http2Channel http2Channel)

Method Detail

handleEventback to summary
public void handleEvent(AbstractHttp2StreamSourceChannel sourceChannel)

Implements org.xnio.ChannelListener.handleEvent.

Doc from org.xnio.ChannelListener.handleEvent.

Handle the event on this channel.

Parameters
sourceChannel:AbstractHttp2StreamSourceChannel

the channel event

Annotations
@Override
io.undertow.client.http2 back to summary

private final Class Http2ClientConnection.PingKey

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final byte[]

Constructor Summary

AccessConstructor and Description
private
PingKey(byte[] data)

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object
the reference object with which to compare.
o
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

databack to summary
private final byte[] data

Constructor Detail

PingKeyback to summary
private PingKey(byte[] data)

Method Detail

equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override