SimpleChannelPromiseAggregator Class — netty Architecture
Architecture documentation for the SimpleChannelPromiseAggregator class in Http2CodecUtil.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 813242d1_b443_a14c_2a77_4049dd5cb9eb["SimpleChannelPromiseAggregator"] 0a43bf95_f934_af94_70a3_0ca258434af9["Http2CodecUtil.java"] 813242d1_b443_a14c_2a77_4049dd5cb9eb -->|defined in| 0a43bf95_f934_af94_70a3_0ca258434af9 f3492b35_71cb_1294_2103_cb2873405302["SimpleChannelPromiseAggregator()"] 813242d1_b443_a14c_2a77_4049dd5cb9eb -->|method| f3492b35_71cb_1294_2103_cb2873405302 1e82379e_52f6_76be_5da5_4ebf15ae9751["ChannelPromise()"] 813242d1_b443_a14c_2a77_4049dd5cb9eb -->|method| 1e82379e_52f6_76be_5da5_4ebf15ae9751 a5922733_5084_9339_61b4_ce2859f55045["tryFailure()"] 813242d1_b443_a14c_2a77_4049dd5cb9eb -->|method| a5922733_5084_9339_61b4_ce2859f55045 43c2ecae_9083_852e_3e39_d2a0e7c5a17b["trySuccess()"] 813242d1_b443_a14c_2a77_4049dd5cb9eb -->|method| 43c2ecae_9083_852e_3e39_d2a0e7c5a17b 9cb7a4b9_00fb_1588_bd61_c0abe9023f0c["allowFailure()"] 813242d1_b443_a14c_2a77_4049dd5cb9eb -->|method| 9cb7a4b9_00fb_1588_bd61_c0abe9023f0c 6cd970cd_1aec_a4c3_f5fc_e410c3100c61["awaitingPromises()"] 813242d1_b443_a14c_2a77_4049dd5cb9eb -->|method| 6cd970cd_1aec_a4c3_f5fc_e410c3100c61 b97d6a18_2ebb_9671_5952_8044f2131e9d["allPromisesDone()"] 813242d1_b443_a14c_2a77_4049dd5cb9eb -->|method| b97d6a18_2ebb_9671_5952_8044f2131e9d 1df80efb_eee7_d0dc_d199_f67d78d9f517["tryPromise()"] 813242d1_b443_a14c_2a77_4049dd5cb9eb -->|method| 1df80efb_eee7_d0dc_d199_f67d78d9f517 11437eae_092b_cef8_597d_b51e675981df["setAggregateFailure()"] 813242d1_b443_a14c_2a77_4049dd5cb9eb -->|method| 11437eae_092b_cef8_597d_b51e675981df
Relationship Graph
Source Code
codec-http2/src/main/java/io/netty/handler/codec/http2/Http2CodecUtil.java lines 261–395
static final class SimpleChannelPromiseAggregator extends DefaultChannelPromise {
private final ChannelPromise promise;
private int expectedCount;
private int doneCount;
private Throwable aggregateFailure;
private boolean doneAllocating;
SimpleChannelPromiseAggregator(ChannelPromise promise, Channel c, EventExecutor e) {
super(c, e);
assert promise != null && !promise.isDone();
this.promise = promise;
}
/**
* Allocate a new promise which will be used to aggregate the overall success of this promise aggregator.
* @return A new promise which will be aggregated.
* {@code null} if {@link #doneAllocatingPromises()} was previously called.
*/
public ChannelPromise newPromise() {
assert !doneAllocating : "Done allocating. No more promises can be allocated.";
++expectedCount;
return this;
}
/**
* Signify that no more {@link #newPromise()} allocations will be made.
* The aggregation can not be successful until this method is called.
* @return The promise that is the aggregation of all promises allocated with {@link #newPromise()}.
*/
public ChannelPromise doneAllocatingPromises() {
if (!doneAllocating) {
doneAllocating = true;
if (doneCount == expectedCount || expectedCount == 0) {
return setPromise();
}
}
return this;
}
@Override
public boolean tryFailure(Throwable cause) {
if (allowFailure()) {
++doneCount;
setAggregateFailure(cause);
if (allPromisesDone()) {
return tryPromise();
}
// TODO: We break the interface a bit here.
// Multiple failure events can be processed without issue because this is an aggregation.
return true;
}
return false;
}
/**
* Fail this object if it has not already been failed.
* <p>
* This method will NOT throw an {@link IllegalStateException} if called multiple times
* because that may be expected.
*/
@Override
public ChannelPromise setFailure(Throwable cause) {
if (allowFailure()) {
++doneCount;
setAggregateFailure(cause);
if (allPromisesDone()) {
return setPromise();
}
}
return this;
}
@Override
public ChannelPromise setSuccess(Void result) {
if (awaitingPromises()) {
++doneCount;
if (allPromisesDone()) {
setPromise();
}
}
return this;
Source
Frequently Asked Questions
What is the SimpleChannelPromiseAggregator class?
SimpleChannelPromiseAggregator is a class in the netty codebase, defined in codec-http2/src/main/java/io/netty/handler/codec/http2/Http2CodecUtil.java.
Where is SimpleChannelPromiseAggregator defined?
SimpleChannelPromiseAggregator is defined in codec-http2/src/main/java/io/netty/handler/codec/http2/Http2CodecUtil.java at line 261.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free