當前位置: 首頁>>代碼示例>>Java>>正文


Java Http2Stream類代碼示例

本文整理匯總了Java中io.netty.handler.codec.http2.Http2Stream的典型用法代碼示例。如果您正苦於以下問題:Java Http2Stream類的具體用法?Java Http2Stream怎麽用?Java Http2Stream使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Http2Stream類屬於io.netty.handler.codec.http2包,在下文中一共展示了Http2Stream類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: validateStream

import io.netty.handler.codec.http2.Http2Stream; //導入依賴的package包/類
private ChannelFuture validateStream(ChannelHandlerContext ctx, int streamId) {
    final Http2Stream stream = encoder.connection().stream(streamId);
    if (stream != null) {
        switch (stream.state()) {
            case RESERVED_LOCAL:
            case OPEN:
            case HALF_CLOSED_REMOTE:
                break;
            default:
                // The response has been sent already.
                return ctx.newFailedFuture(ClosedPublisherException.get());
        }
    } else if (encoder.connection().streamMayHaveExisted(streamId)) {
        // Stream has been removed because it has been closed completely.
        return ctx.newFailedFuture(ClosedPublisherException.get());
    }

    return null;
}
 
開發者ID:line,項目名稱:armeria,代碼行數:20,代碼來源:Http2ObjectEncoder.java

示例2: forcefulClose

import io.netty.handler.codec.http2.Http2Stream; //導入依賴的package包/類
private void forcefulClose(final ChannelHandlerContext ctx, final ForcefulCloseCommand msg,
    ChannelPromise promise) throws Exception {
  close(ctx, promise);
  connection().forEachActiveStream(new Http2StreamVisitor() {
    @Override
    public boolean visit(Http2Stream stream) throws Http2Exception {
      NettyServerStream.TransportState serverStream = serverStream(stream);
      if (serverStream != null) {
        serverStream.transportReportStatus(msg.getStatus());
        resetStream(ctx, stream.id(), Http2Error.CANCEL.code(), ctx.newPromise());
      }
      stream.close();
      return true;
    }
  });
}
 
開發者ID:grpc,項目名稱:grpc-java,代碼行數:17,代碼來源:NettyServerHandler.java

示例3: forcefulClose

import io.netty.handler.codec.http2.Http2Stream; //導入依賴的package包/類
private void forcefulClose(final ChannelHandlerContext ctx, final ForcefulCloseCommand msg,
    ChannelPromise promise) throws Exception {
  // close() already called by NettyClientTransport, so just need to clean up streams
  connection().forEachActiveStream(new Http2StreamVisitor() {
    @Override
    public boolean visit(Http2Stream stream) throws Http2Exception {
      NettyClientStream.TransportState clientStream = clientStream(stream);
      if (clientStream != null) {
        clientStream.transportReportStatus(msg.getStatus(), true, new Metadata());
        resetStream(ctx, stream.id(), Http2Error.CANCEL.code(), ctx.newPromise());
      }
      stream.close();
      return true;
    }
  });
}
 
開發者ID:grpc,項目名稱:grpc-java,代碼行數:17,代碼來源:NettyClientHandler.java

示例4: goingAway

import io.netty.handler.codec.http2.Http2Stream; //導入依賴的package包/類
/**
 * Handler for a GOAWAY being either sent or received. Fails any streams created after the
 * last known stream.
 */
private void goingAway(Status status) {
  lifecycleManager.notifyShutdown(status);
  final Status goAwayStatus = lifecycleManager.getShutdownStatus();
  final int lastKnownStream = connection().local().lastStreamKnownByPeer();
  try {
    connection().forEachActiveStream(new Http2StreamVisitor() {
      @Override
      public boolean visit(Http2Stream stream) throws Http2Exception {
        if (stream.id() > lastKnownStream) {
          NettyClientStream.TransportState clientStream = clientStream(stream);
          if (clientStream != null) {
            clientStream.transportReportStatus(goAwayStatus, false, new Metadata());
          }
          stream.close();
        }
        return true;
      }
    });
  } catch (Http2Exception e) {
    throw new RuntimeException(e);
  }
}
 
開發者ID:grpc,項目名稱:grpc-java,代碼行數:27,代碼來源:NettyClientHandler.java

示例5: windowShouldNotExceedMaxWindowSize

import io.netty.handler.codec.http2.Http2Stream; //導入依賴的package包/類
@Test
public void windowShouldNotExceedMaxWindowSize() throws Exception {
  manualSetUp();
  makeStream();
  AbstractNettyHandler handler = (AbstractNettyHandler) handler();
  handler.setAutoTuneFlowControl(true);
  Http2Stream connectionStream = connection().connectionStream();
  Http2LocalFlowController localFlowController = connection().local().flowController();
  int maxWindow = handler.flowControlPing().maxWindow();

  handler.flowControlPing().setDataSizeSincePing(maxWindow);
  int payload = handler.flowControlPing().payload();
  ByteBuf buffer = handler.ctx().alloc().buffer(8);
  buffer.writeLong(payload);
  channelRead(pingFrame(true, buffer));

  assertEquals(maxWindow, localFlowController.initialWindowSize(connectionStream));
}
 
開發者ID:grpc,項目名稱:grpc-java,代碼行數:19,代碼來源:NettyHandlerTestBase.java

示例6: onStreamClosed

import io.netty.handler.codec.http2.Http2Stream; //導入依賴的package包/類
@Override
public void onStreamClosed(Http2Stream stream) {
    final HttpResponseWrapper res = getResponse(streamIdToId(stream.id()), true);
    if (res != null) {
        res.close(ClosedSessionException.get());
    }
}
 
開發者ID:line,項目名稱:armeria,代碼行數:8,代碼來源:Http2ResponseDecoder.java

示例7: setHttp2Stream

import io.netty.handler.codec.http2.Http2Stream; //導入依賴的package包/類
/**
 * Sets the underlying Netty {@link Http2Stream} for this stream. This must be called in the
 * context of the transport thread.
 */
public void setHttp2Stream(Http2Stream http2Stream) {
  checkNotNull(http2Stream, "http2Stream");
  checkState(this.http2Stream == null, "Can only set http2Stream once");
  this.http2Stream = http2Stream;

  // Now that the stream has actually been initialized, call the listener's onReady callback if
  // appropriate.
  onStreamAllocated();
}
 
開發者ID:grpc,項目名稱:grpc-java,代碼行數:14,代碼來源:NettyClientStream.java

示例8: TransportState

import io.netty.handler.codec.http2.Http2Stream; //導入依賴的package包/類
public TransportState(
    NettyServerHandler handler,
    EventLoop eventLoop,
    Http2Stream http2Stream,
    int maxMessageSize,
    StatsTraceContext statsTraceCtx,
    TransportTracer transportTracer) {
  super(maxMessageSize, statsTraceCtx, transportTracer);
  this.http2Stream = checkNotNull(http2Stream, "http2Stream");
  this.handler = checkNotNull(handler, "handler");
  this.eventLoop = eventLoop;
}
 
開發者ID:grpc,項目名稱:grpc-java,代碼行數:13,代碼來源:NettyServerStream.java

示例9: channelInactive

import io.netty.handler.codec.http2.Http2Stream; //導入依賴的package包/類
/**
 * Handler for the Channel shutting down.
 */
@Override
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
  try {
    if (keepAliveManager != null) {
      keepAliveManager.onTransportTermination();
    }
    if (maxConnectionIdleManager != null) {
      maxConnectionIdleManager.onTransportTermination();
    }
    if (maxConnectionAgeMonitor != null) {
      maxConnectionAgeMonitor.cancel(false);
    }
    final Status status =
        Status.UNAVAILABLE.withDescription("connection terminated for unknown reason");
    // Any streams that are still active must be closed
    connection().forEachActiveStream(new Http2StreamVisitor() {
      @Override
      public boolean visit(Http2Stream stream) throws Http2Exception {
        NettyServerStream.TransportState serverStream = serverStream(stream);
        if (serverStream != null) {
          serverStream.transportReportStatus(status);
        }
        return true;
      }
    });
  } finally {
    super.channelInactive(ctx);
  }
}
 
開發者ID:grpc,項目名稱:grpc-java,代碼行數:33,代碼來源:NettyServerHandler.java

示例10: returnProcessedBytes

import io.netty.handler.codec.http2.Http2Stream; //導入依賴的package包/類
/**
 * Returns the given processed bytes back to inbound flow control.
 */
void returnProcessedBytes(Http2Stream http2Stream, int bytes) {
  try {
    decoder().flowController().consumeBytes(http2Stream, bytes);
  } catch (Http2Exception e) {
    throw new RuntimeException(e);
  }
}
 
開發者ID:grpc,項目名稱:grpc-java,代碼行數:11,代碼來源:NettyServerHandler.java

示例11: requireHttp2Stream

import io.netty.handler.codec.http2.Http2Stream; //導入依賴的package包/類
private Http2Stream requireHttp2Stream(int streamId) {
  Http2Stream stream = connection().stream(streamId);
  if (stream == null) {
    // This should never happen.
    throw new AssertionError("Stream does not exist: " + streamId);
  }
  return stream;
}
 
開發者ID:grpc,項目名稱:grpc-java,代碼行數:9,代碼來源:NettyServerHandler.java

示例12: returnProcessedBytes

import io.netty.handler.codec.http2.Http2Stream; //導入依賴的package包/類
/**
 * Returns the given processed bytes back to inbound flow control.
 */
void returnProcessedBytes(Http2Stream stream, int bytes) {
  try {
    decoder().flowController().consumeBytes(stream, bytes);
  } catch (Http2Exception e) {
    throw new RuntimeException(e);
  }
}
 
開發者ID:grpc,項目名稱:grpc-java,代碼行數:11,代碼來源:NettyClientHandler.java

示例13: channelInactive

import io.netty.handler.codec.http2.Http2Stream; //導入依賴的package包/類
/**
 * Handler for the Channel shutting down.
 */
@Override
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
  try {
    logger.fine("Network channel is closed");
    Status status = Status.UNAVAILABLE.withDescription("Network closed for unknown reason");
    lifecycleManager.notifyShutdown(status);
    try {
      cancelPing(lifecycleManager.getShutdownThrowable());
      // Report status to the application layer for any open streams
      connection().forEachActiveStream(new Http2StreamVisitor() {
        @Override
        public boolean visit(Http2Stream stream) throws Http2Exception {
          NettyClientStream.TransportState clientStream = clientStream(stream);
          if (clientStream != null) {
            clientStream.transportReportStatus(
                lifecycleManager.getShutdownStatus(), false, new Metadata());
          }
          return true;
        }
      });
    } finally {
      lifecycleManager.notifyTerminated(status);
    }
  } finally {
    // Close any open streams
    super.channelInactive(ctx);
    if (keepAliveManager != null) {
      keepAliveManager.onTransportTermination();
    }
  }
}
 
開發者ID:grpc,項目名稱:grpc-java,代碼行數:35,代碼來源:NettyClientHandler.java

示例14: sendInitialConnectionWindow

import io.netty.handler.codec.http2.Http2Stream; //導入依賴的package包/類
/**
 * Sends initial connection window to the remote endpoint if necessary.
 */
private void sendInitialConnectionWindow() throws Http2Exception {
  if (ctx.channel().isActive() && initialConnectionWindow > 0) {
    Http2Stream connectionStream = connection().connectionStream();
    int currentSize = connection().local().flowController().windowSize(connectionStream);
    int delta = initialConnectionWindow - currentSize;
    decoder().flowController().incrementWindowSize(connectionStream, delta);
    initialConnectionWindow = -1;
    ctx.flush();
  }
}
 
開發者ID:grpc,項目名稱:grpc-java,代碼行數:14,代碼來源:AbstractNettyHandler.java

示例15: connectionWindowShouldBeOverridden

import io.netty.handler.codec.http2.Http2Stream; //導入依賴的package包/類
@Test
public void connectionWindowShouldBeOverridden() throws Exception {
  flowControlWindow = 1048576; // 1MiB
  manualSetUp();

  Http2Stream connectionStream = connection().connectionStream();
  Http2LocalFlowController localFlowController = connection().local().flowController();
  int actualInitialWindowSize = localFlowController.initialWindowSize(connectionStream);
  int actualWindowSize = localFlowController.windowSize(connectionStream);
  assertEquals(flowControlWindow, actualWindowSize);
  assertEquals(flowControlWindow, actualInitialWindowSize);
}
 
開發者ID:grpc,項目名稱:grpc-java,代碼行數:13,代碼來源:NettyServerHandlerTest.java


注:本文中的io.netty.handler.codec.http2.Http2Stream類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。