Package org.miaixz.bus.http.metric.http
Class Http2Connection
java.lang.Object
org.miaixz.bus.http.metric.http.Http2Connection
- All Implemented Interfaces:
Closeable,AutoCloseable
到远程对等点的套接字连接。连接主机可以发送和接收数据流.
- Since:
- Java 17+
- Author:
- Kimi Liu
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classListener of streams and settings initiated by the peer. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes this connection.voidflush()booleanisHealthy(long nowNs) intnewStream(List<Headers.Header> requestHeaders, boolean out) Returns a new locally-initiated stream.intReturns the number ofopen streamson this connection.pushStream(int associatedStreamId, List<Headers.Header> requestHeaders, boolean out) 返回一个新的服务器发起的流.voidsetSettings(Settings settings) Mergessettingsinto this peer's settings and sends them to the remote peer.voidDegrades this connection such that new streams can neither be created locally, nor accepted from the remote peer.voidstart()Sends any initial frames and starts reading frames from the remote peer.voidwriteData(int streamId, boolean outFinished, org.miaixz.bus.core.io.buffer.Buffer buffer, long byteCount) 此方法的调用程序不是线程安全的,有时在应用程序线程上也是如此。 通常,将调用此方法将数据的缓冲区发送给对等方.
-
Method Details
-
openStreamCount
public int openStreamCount()Returns the number ofopen streamson this connection. -
maxConcurrentStreams
public int maxConcurrentStreams() -
pushStream
public Http2Stream pushStream(int associatedStreamId, List<Headers.Header> requestHeaders, boolean out) throws IOException 返回一个新的服务器发起的流.- Parameters:
associatedStreamId- 触发发送方创建此流的流.requestHeaders- 请求头信息out- 创建一个输出流,我们可以使用它将数据发送到远程对等端。对应FLAG_FIN- Returns:
- http请求流
- Throws:
IOException- 异常
-
newStream
Returns a new locally-initiated stream.- Parameters:
out- true to create an output stream that we can use to send data to the remote peer. Corresponds toFLAG_FIN.- Throws:
IOException
-
writeData
public void writeData(int streamId, boolean outFinished, org.miaixz.bus.core.io.buffer.Buffer buffer, long byteCount) throws IOException 此方法的调用程序不是线程安全的,有时在应用程序线程上也是如此。 通常,将调用此方法将数据的缓冲区发送给对等方. 写取决于流和连接的写窗口。在有足够的窗口发送byteCount之前, 调用者将阻塞。例如,HttpURLConnection的用户向输出流刷新的 字节比连接的写窗口多,就会阻塞- Parameters:
streamId- 是否streamIdoutFinished- 是否结束buffer- 缓冲byteCount- 字节流大小- Throws:
IOException- 异常
-
flush
- Throws:
IOException
-
shutdown
Degrades this connection such that new streams can neither be created locally, nor accepted from the remote peer. Existing streams are not impacted. This is intended to permit an endpoint to gracefully stop accepting new requests without harming previously established streams.- Throws:
IOException
-
close
public void close()Closes this connection. This cancels all open streams and unanswered pings. It closes the underlying input and output streams and shuts down internal executor services.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
start
Sends any initial frames and starts reading frames from the remote peer. This should be called afterHttp2Connection.Builder.build()for all new connections.- Throws:
IOException
-
setSettings
Mergessettingsinto this peer's settings and sends them to the remote peer.- Throws:
IOException
-
isHealthy
public boolean isHealthy(long nowNs)
-