use of com.webpieces.http2engine.impl.shared.data.Stream in project webpieces by deanhiller.
the class Level5AStates method checkForClosedState.
/**
* Returns if calling this resulted in closing the stream and cleaning up state
*/
private boolean checkForClosedState(Stream stream, Http2Msg cause, boolean keepDelayedState) {
//If a stream ends up in closed state, for request type streams, we must release a permit on
//max concurrent streams
boolean isClosed = isInClosedState(stream);
if (!isClosed)
//do nothing
return false;
log.info(logId + "stream closed=" + stream.getStreamId());
// if(!keepDelayedState) {
Stream removedStream = streamState.remove(stream, cause);
if (removedStream == null)
//someone else closed the stream. they beat us to it so just return
return false;
return true;
// } else {
// //streamState.addDelayedRemove(stream, afterResetExpireSeconds);
// throw new UnsupportedOperationException("not supported");
// }
}
use of com.webpieces.http2engine.impl.shared.data.Stream in project webpieces by deanhiller.
the class Level5BResets method resetAllClientStreams.
private void resetAllClientStreams(ConnectionCancelled reset) {
ConcurrentMap<Integer, Stream> streams = streamState.closeEngine();
for (Stream stream : streams.values()) {
ShutdownStream str = new ShutdownStream(stream.getStreamId(), reset);
fireRstToClient(stream, str);
}
}
use of com.webpieces.http2engine.impl.shared.data.Stream in project webpieces by deanhiller.
the class Level5AStates method fireToStateMachine.
private CompletableFuture<Void> fireToStateMachine(Http2SendRecieve type, Stream stream, Http2Msg payload, boolean keepDelayedState) {
Http2Event event = translate(type, payload);
CompletableFuture<Void> future = stream.getLock().synchronizeD(() -> {
fireToStatemachineImpl(stream, event);
return checkForClosedState(stream, payload, keepDelayedState);
}).thenApply(isReleased -> {
release(isReleased, stream, payload);
return null;
});
return future.handle((v, e) -> {
if (e == null) {
return CompletableFuture.completedFuture(v);
} else {
return translateException(stream, e);
}
}).thenCompose(Function.identity());
}
use of com.webpieces.http2engine.impl.shared.data.Stream in project webpieces by deanhiller.
the class Level5ClientStateMachine method sendResponse.
public CompletableFuture<Void> sendResponse(Http2Response frame) {
Stream stream = streamState.getStream(frame, true);
CompletableFuture<Void> future = fireToClient(stream, frame);
return future;
}
use of com.webpieces.http2engine.impl.shared.data.Stream in project webpieces by deanhiller.
the class Level6RemoteFlowControl method trySendPayload.
private void trySendPayload(DataTry data) {
long length = data.getDataFrame().getTransmitFrameLength();
Stream stream = data.getStream();
boolean send;
long min = Math.min(remoteWindowSize, stream.getRemoteWindowSize());
long lengthToSend = Math.min(length, min);
if (length != lengthToSend) {
//must split DataFrame into two since WindowUpdateSize is not large enough
List<DataTry> tuple = splitDataFrame(data, lengthToSend);
//swap the right size to send
data = tuple.get(0);
dataQueue.add(0, tuple.get(1));
}
if (lengthToSend > 0) {
stream.incrementRemoteWindow(-lengthToSend);
remoteWindowSize -= lengthToSend;
send = true;
} else if (data.isWasQueuedBefore()) {
//insert BACK at beginning of queue
dataQueue.add(0, data);
send = false;
} else {
//insert at end of queue
dataQueue.add(data);
send = false;
}
log.info("flow control. send=" + send + " window=" + remoteWindowSize + " streamWindow=" + stream.getRemoteWindowSize());
if (send) {
DataTry finalTry = data;
layer6NotifyListener.sendFrameToSocket(data.getDataFrame()).handle((v, t) -> processComplete(v, t, finalTry.getFuture()));
}
}
Aggregations