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


Java ServerStreamTracer.Factory方法代碼示例

本文整理匯總了Java中io.grpc.ServerStreamTracer.Factory方法的典型用法代碼示例。如果您正苦於以下問題:Java ServerStreamTracer.Factory方法的具體用法?Java ServerStreamTracer.Factory怎麽用?Java ServerStreamTracer.Factory使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在io.grpc.ServerStreamTracer的用法示例。


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

示例1: getTracerFactories

import io.grpc.ServerStreamTracer; //導入方法依賴的package包/類
@VisibleForTesting
final List<ServerStreamTracer.Factory> getTracerFactories() {
  ArrayList<ServerStreamTracer.Factory> tracerFactories =
      new ArrayList<ServerStreamTracer.Factory>();
  if (statsEnabled) {
    CensusStatsModule censusStats = this.censusStatsOverride;
    if (censusStats == null) {
      censusStats = new CensusStatsModule(GrpcUtil.STOPWATCH_SUPPLIER, true);
    }
    tracerFactories.add(
        censusStats.getServerTracerFactory(recordStartedRpcs, recordFinishedRpcs));
  }
  if (tracingEnabled) {
    CensusTracingModule censusTracing =
        new CensusTracingModule(Tracing.getTracer(),
            Tracing.getPropagationComponent().getBinaryFormat());
    tracerFactories.add(censusTracing.getServerTracerFactory());
  }
  tracerFactories.addAll(streamTracerFactories);
  return tracerFactories;
}
 
開發者ID:grpc,項目名稱:grpc-java,代碼行數:22,代碼來源:AbstractServerImplBuilder.java

示例2: buildTransportServer

import io.grpc.ServerStreamTracer; //導入方法依賴的package包/類
@Override
@CheckReturnValue
protected NettyServer buildTransportServer(
    List<ServerStreamTracer.Factory> streamTracerFactories) {
  ProtocolNegotiator negotiator = protocolNegotiator;
  if (negotiator == null) {
    negotiator = sslContext != null ? ProtocolNegotiators.serverTls(sslContext) :
            ProtocolNegotiators.serverPlaintext();
  }

  return new NettyServer(
      address, channelType, channelOptions, bossEventLoopGroup, workerEventLoopGroup,
      negotiator, streamTracerFactories, transportTracerFactory,
      maxConcurrentCallsPerConnection, flowControlWindow,
      maxMessageSize, maxHeaderListSize, keepAliveTimeInNanos, keepAliveTimeoutInNanos,
      maxConnectionIdleInNanos,
      maxConnectionAgeInNanos, maxConnectionAgeGraceInNanos,
      permitKeepAliveWithoutCalls, permitKeepAliveTimeInNanos);
}
 
開發者ID:grpc,項目名稱:grpc-java,代碼行數:20,代碼來源:NettyServerBuilder.java

示例3: serverTracingSampledToLocalSpanStore

import io.grpc.ServerStreamTracer; //導入方法依賴的package包/類
@Test
public void serverTracingSampledToLocalSpanStore() {
  ServerStreamTracer.Factory tracerFactory = censusTracing.getServerTracerFactory();
  ServerStreamTracer serverStreamTracer =
      tracerFactory.newServerStreamTracer(sampledMethod.getFullMethodName(), new Metadata());

  serverStreamTracer.filterContext(Context.ROOT);

  serverStreamTracer.serverCallStarted(
      new ServerCallInfoImpl<String, String>(sampledMethod, Attributes.EMPTY, null));

  serverStreamTracer.streamClosed(Status.CANCELLED);

  verify(spyServerSpan).end(
      EndSpanOptions.builder()
          .setStatus(io.opencensus.trace.Status.CANCELLED)
          .setSampleToLocalSpanStore(true)
          .build());
}
 
開發者ID:grpc,項目名稱:grpc-java,代碼行數:20,代碼來源:CensusModulesTest.java

示例4: newServer

import io.grpc.ServerStreamTracer; //導入方法依賴的package包/類
@Override
protected InternalServer newServer(
    InternalServer server, List<ServerStreamTracer.Factory> streamTracerFactories) {
  int port = server.getPort();
  return AccessProtectedHack.serverBuilderBuildTransportServer(
      NettyServerBuilder
          .forPort(port)
          .flowControlWindow(65 * 1024),
      streamTracerFactories,
      fakeClockTransportTracer);
}
 
開發者ID:grpc,項目名稱:grpc-java,代碼行數:12,代碼來源:OkHttpTransportTest.java

示例5: NettyServerTransport

import io.grpc.ServerStreamTracer; //導入方法依賴的package包/類
NettyServerTransport(
    Channel channel,
    ChannelPromise channelUnused,
    ProtocolNegotiator protocolNegotiator,
    List<ServerStreamTracer.Factory> streamTracerFactories,
    TransportTracer transportTracer,
    int maxStreams,
    int flowControlWindow,
    int maxMessageSize,
    int maxHeaderListSize,
    long keepAliveTimeInNanos,
    long keepAliveTimeoutInNanos,
    long maxConnectionIdleInNanos,
    long maxConnectionAgeInNanos,
    long maxConnectionAgeGraceInNanos,
    boolean permitKeepAliveWithoutCalls,
    long permitKeepAliveTimeInNanos) {
  this.channel = Preconditions.checkNotNull(channel, "channel");
  this.channelUnused = channelUnused;
  this.protocolNegotiator = Preconditions.checkNotNull(protocolNegotiator, "protocolNegotiator");
  this.streamTracerFactories =
      Preconditions.checkNotNull(streamTracerFactories, "streamTracerFactories");
  this.transportTracer = Preconditions.checkNotNull(transportTracer, "transportTracer");
  this.maxStreams = maxStreams;
  this.flowControlWindow = flowControlWindow;
  this.maxMessageSize = maxMessageSize;
  this.maxHeaderListSize = maxHeaderListSize;
  this.keepAliveTimeInNanos = keepAliveTimeInNanos;
  this.keepAliveTimeoutInNanos = keepAliveTimeoutInNanos;
  this.maxConnectionIdleInNanos = maxConnectionIdleInNanos;
  this.maxConnectionAgeInNanos = maxConnectionAgeInNanos;
  this.maxConnectionAgeGraceInNanos = maxConnectionAgeGraceInNanos;
  this.permitKeepAliveWithoutCalls = permitKeepAliveWithoutCalls;
  this.permitKeepAliveTimeInNanos = permitKeepAliveTimeInNanos;
}
 
開發者ID:grpc,項目名稱:grpc-java,代碼行數:36,代碼來源:NettyServerTransport.java

示例6: getTracerFactories_default

import io.grpc.ServerStreamTracer; //導入方法依賴的package包/類
@Test
public void getTracerFactories_default() {
  builder.addStreamTracerFactory(DUMMY_USER_TRACER);
  List<ServerStreamTracer.Factory> factories = builder.getTracerFactories();
  assertEquals(3, factories.size());
  assertThat(factories.get(0)).isInstanceOf(CensusStatsModule.ServerTracerFactory.class);
  assertThat(factories.get(1)).isInstanceOf(CensusTracingModule.ServerTracerFactory.class);
  assertThat(factories.get(2)).isSameAs(DUMMY_USER_TRACER);
}
 
開發者ID:grpc,項目名稱:grpc-java,代碼行數:10,代碼來源:AbstractServerImplBuilderTest.java

示例7: getTracerFactories_disableTracing

import io.grpc.ServerStreamTracer; //導入方法依賴的package包/類
@Test
public void getTracerFactories_disableTracing() {
  builder.addStreamTracerFactory(DUMMY_USER_TRACER);
  builder.setTracingEnabled(false);
  List<ServerStreamTracer.Factory> factories = builder.getTracerFactories();
  assertEquals(2, factories.size());
  assertThat(factories.get(0)).isInstanceOf(CensusStatsModule.ServerTracerFactory.class);
  assertThat(factories.get(1)).isSameAs(DUMMY_USER_TRACER);
}
 
開發者ID:grpc,項目名稱:grpc-java,代碼行數:10,代碼來源:AbstractServerImplBuilderTest.java

示例8: newServer

import io.grpc.ServerStreamTracer; //導入方法依賴的package包/類
@Override
protected InternalServer newServer(
    InternalServer server, List<ServerStreamTracer.Factory> streamTracerFactories) {
  int port = server.getPort();
  return NettyServerBuilder
      .forPort(port)
      .flowControlWindow(65 * 1024)
      .setTransportTracerFactory(fakeClockTransportTracer)
      .buildTransportServer(streamTracerFactories);
}
 
開發者ID:grpc,項目名稱:grpc-java,代碼行數:11,代碼來源:NettyTransportTest.java

示例9: getTracerFactories_disableStats

import io.grpc.ServerStreamTracer; //導入方法依賴的package包/類
@Test
public void getTracerFactories_disableStats() {
  builder.addStreamTracerFactory(DUMMY_USER_TRACER);
  builder.setStatsEnabled(false);
  List<ServerStreamTracer.Factory> factories = builder.getTracerFactories();
  assertEquals(2, factories.size());
  assertThat(factories.get(0)).isInstanceOf(CensusTracingModule.ServerTracerFactory.class);
  assertThat(factories.get(1)).isSameAs(DUMMY_USER_TRACER);
}
 
開發者ID:grpc,項目名稱:grpc-java,代碼行數:10,代碼來源:AbstractServerImplBuilderTest.java

示例10: InProcessServer

import io.grpc.ServerStreamTracer; //導入方法依賴的package包/類
@VisibleForTesting
InProcessServer(
    String name, ObjectPool<ScheduledExecutorService> schedulerPool,
    List<ServerStreamTracer.Factory> streamTracerFactories) {
  this.name = name;
  this.schedulerPool = schedulerPool;
  this.streamTracerFactories =
      Collections.unmodifiableList(checkNotNull(streamTracerFactories, "streamTracerFactories"));
}
 
開發者ID:grpc,項目名稱:grpc-java,代碼行數:10,代碼來源:InProcessServer.java

示例11: getTracerFactories_disableBoth

import io.grpc.ServerStreamTracer; //導入方法依賴的package包/類
@Test
public void getTracerFactories_disableBoth() {
  builder.addStreamTracerFactory(DUMMY_USER_TRACER);
  builder.setTracingEnabled(false);
  builder.setStatsEnabled(false);
  List<ServerStreamTracer.Factory> factories = builder.getTracerFactories();
  assertThat(factories).containsExactly(DUMMY_USER_TRACER);
}
 
開發者ID:grpc,項目名稱:grpc-java,代碼行數:9,代碼來源:AbstractServerImplBuilderTest.java

示例12: serverTracingNotSampledToLocalSpanStore_whenServerCallNotCreated

import io.grpc.ServerStreamTracer; //導入方法依賴的package包/類
@Test
public void serverTracingNotSampledToLocalSpanStore_whenServerCallNotCreated() {
  ServerStreamTracer.Factory tracerFactory = censusTracing.getServerTracerFactory();
  ServerStreamTracer serverStreamTracer =
      tracerFactory.newServerStreamTracer(sampledMethod.getFullMethodName(), new Metadata());

  serverStreamTracer.streamClosed(Status.CANCELLED);

  verify(spyServerSpan).end(
      EndSpanOptions.builder()
          .setStatus(io.opencensus.trace.Status.CANCELLED)
          .setSampleToLocalSpanStore(false)
          .build());
}
 
開發者ID:grpc,項目名稱:grpc-java,代碼行數:15,代碼來源:CensusModulesTest.java

示例13: newHandler

import io.grpc.ServerStreamTracer; //導入方法依賴的package包/類
static NettyServerHandler newHandler(
    ServerTransportListener transportListener,
    ChannelPromise channelUnused,
    List<ServerStreamTracer.Factory> streamTracerFactories,
    TransportTracer transportTracer,
    int maxStreams,
    int flowControlWindow,
    int maxHeaderListSize,
    int maxMessageSize,
    long keepAliveTimeInNanos,
    long keepAliveTimeoutInNanos,
    long maxConnectionIdleInNanos,
    long maxConnectionAgeInNanos,
    long maxConnectionAgeGraceInNanos,
    boolean permitKeepAliveWithoutCalls,
    long permitKeepAliveTimeInNanos) {
  Preconditions.checkArgument(maxHeaderListSize > 0, "maxHeaderListSize must be positive");
  Http2FrameLogger frameLogger = new Http2FrameLogger(LogLevel.DEBUG, NettyServerHandler.class);
  Http2HeadersDecoder headersDecoder = new GrpcHttp2ServerHeadersDecoder(maxHeaderListSize);
  Http2FrameReader frameReader = new Http2InboundFrameLogger(
      new DefaultHttp2FrameReader(headersDecoder), frameLogger);
  Http2FrameWriter frameWriter =
      new Http2OutboundFrameLogger(new DefaultHttp2FrameWriter(), frameLogger);
  return newHandler(
      channelUnused,
      frameReader,
      frameWriter,
      transportListener,
      streamTracerFactories,
      transportTracer,
      maxStreams,
      flowControlWindow,
      maxHeaderListSize,
      maxMessageSize,
      keepAliveTimeInNanos,
      keepAliveTimeoutInNanos,
      maxConnectionIdleInNanos,
      maxConnectionAgeInNanos,
      maxConnectionAgeGraceInNanos,
      permitKeepAliveWithoutCalls,
      permitKeepAliveTimeInNanos);
}
 
開發者ID:grpc,項目名稱:grpc-java,代碼行數:43,代碼來源:NettyServerHandler.java

示例14: serverBasicTracingNoHeaders

import io.grpc.ServerStreamTracer; //導入方法依賴的package包/類
@Test
public void serverBasicTracingNoHeaders() {
  ServerStreamTracer.Factory tracerFactory = censusTracing.getServerTracerFactory();
  ServerStreamTracer serverStreamTracer =
      tracerFactory.newServerStreamTracer(method.getFullMethodName(), new Metadata());
  verifyZeroInteractions(mockTracingPropagationHandler);
  verify(tracer).spanBuilderWithRemoteParent(
      eq("Recv.package1.service2.method3"), isNull(SpanContext.class));
  verify(spyServerSpanBuilder).setRecordEvents(eq(true));

  Context filteredContext = serverStreamTracer.filterContext(Context.ROOT);
  assertSame(spyServerSpan, ContextUtils.CONTEXT_SPAN_KEY.get(filteredContext));

  serverStreamTracer.serverCallStarted(
      new ServerCallInfoImpl<String, String>(method, Attributes.EMPTY, null));

  verify(spyServerSpan, never()).end(any(EndSpanOptions.class));

  serverStreamTracer.outboundMessage(0);
  serverStreamTracer.outboundMessageSent(0, 882, -1);
  serverStreamTracer.inboundMessage(0);
  serverStreamTracer.outboundMessage(1);
  serverStreamTracer.outboundMessageSent(1, -1, 27);
  serverStreamTracer.inboundMessageRead(0, 255, 90);

  serverStreamTracer.streamClosed(Status.CANCELLED);

  InOrder inOrder = inOrder(spyServerSpan);
  inOrder.verify(spyServerSpan, times(3)).addNetworkEvent(networkEventCaptor.capture());
  List<NetworkEvent> events = networkEventCaptor.getAllValues();
  assertEquals(
      NetworkEvent.builder(Type.SENT, 0).setCompressedMessageSize(882).build(), events.get(0));
  assertEquals(
      NetworkEvent.builder(Type.SENT, 1).setUncompressedMessageSize(27).build(), events.get(1));
  assertEquals(
      NetworkEvent.builder(Type.RECV, 0)
          .setCompressedMessageSize(255)
          .setUncompressedMessageSize(90)
          .build(),
      events.get(2));
  inOrder.verify(spyServerSpan).end(
      EndSpanOptions.builder()
          .setStatus(io.opencensus.trace.Status.CANCELLED)
          .setSampleToLocalSpanStore(false)
          .build());
  verifyNoMoreInteractions(spyServerSpan);
}
 
開發者ID:grpc,項目名稱:grpc-java,代碼行數:48,代碼來源:CensusModulesTest.java

示例15: getServerTracerFactory

import io.grpc.ServerStreamTracer; //導入方法依賴的package包/類
/**
 * Returns the server tracer factory.
 */
ServerStreamTracer.Factory getServerTracerFactory() {
  return serverTracerFactory;
}
 
開發者ID:grpc,項目名稱:grpc-java,代碼行數:7,代碼來源:CensusTracingModule.java


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