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


Java ServerStreamTracer類代碼示例

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


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

示例1: 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

示例2: getPort_notStarted

import io.grpc.ServerStreamTracer; //導入依賴的package包/類
@Test
public void getPort_notStarted() throws Exception {
  InetSocketAddress addr = new InetSocketAddress(0);
  NettyServer ns = new NettyServer(
      addr,
      NioServerSocketChannel.class,
      new HashMap<ChannelOption<?>, Object>(),
      null, // no boss group
      null, // no event group
      new ProtocolNegotiators.PlaintextNegotiator(),
      Collections.<ServerStreamTracer.Factory>emptyList(),
      TransportTracer.getDefaultFactory(),
      1, // ignore
      1, // ignore
      1, // ignore
      1, // ignore
      1, // ignore
      1, 1, // ignore
      1, 1, // ignore
      true, 0); // ignore

  assertThat(ns.getPort()).isEqualTo(-1);
}
 
開發者ID:grpc,項目名稱:grpc-java,代碼行數:24,代碼來源:NettyServerTest.java

示例3: startServer

import io.grpc.ServerStreamTracer; //導入依賴的package包/類
private void startServer(int maxStreamsPerConnection, int maxHeaderListSize) throws IOException {
  server = new NettyServer(
      TestUtils.testServerAddress(0),
      NioServerSocketChannel.class,
      new HashMap<ChannelOption<?>, Object>(),
      group, group, negotiator,
      Collections.<ServerStreamTracer.Factory>emptyList(),
      TransportTracer.getDefaultFactory(),
      maxStreamsPerConnection,
      DEFAULT_WINDOW_SIZE, DEFAULT_MAX_MESSAGE_SIZE, maxHeaderListSize,
      DEFAULT_SERVER_KEEPALIVE_TIME_NANOS, DEFAULT_SERVER_KEEPALIVE_TIMEOUT_NANOS,
      MAX_CONNECTION_IDLE_NANOS_DISABLED,
      MAX_CONNECTION_AGE_NANOS_DISABLED, MAX_CONNECTION_AGE_GRACE_NANOS_INFINITE, true, 0);
  server.start(serverListener);
  address = TestUtils.testServerAddress(server.getPort());
  authority = GrpcUtil.authorityFromHostAndPort(address.getHostString(), address.getPort());
}
 
開發者ID:grpc,項目名稱:grpc-java,代碼行數:18,代碼來源:NettyClientTransportTest.java

示例4: newServerStreamTracer

import io.grpc.ServerStreamTracer; //導入依賴的package包/類
@Override
public ServerStreamTracer newServerStreamTracer(String fullMethodName, Metadata headers) {
  TagContext parentCtx = headers.get(statsHeader);
  if (parentCtx == null) {
    parentCtx = tagger.empty();
  }
  parentCtx =
      tagger
          .toBuilder(parentCtx)
          .put(RpcMeasureConstants.RPC_METHOD, TagValue.create(fullMethodName))
          .build();
  return new ServerTracer(
      CensusStatsModule.this,
      fullMethodName,
      parentCtx,
      stopwatchSupplier,
      tagger,
      recordStartedRpcs,
      recordFinishedRpcs);
}
 
開發者ID:grpc,項目名稱:grpc-java,代碼行數:21,代碼來源:CensusStatsModule.java

示例5: 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

示例6: traceHeadersPropagateSpanContext

import io.grpc.ServerStreamTracer; //導入依賴的package包/類
@Test
public void traceHeadersPropagateSpanContext() throws Exception {
  CensusTracingModule.ClientCallTracer callTracer =
      censusTracing.newClientCallTracer(fakeClientParentSpan, method);
  Metadata headers = new Metadata();
  callTracer.newClientStreamTracer(CallOptions.DEFAULT, headers);

  verify(mockTracingPropagationHandler).toByteArray(same(fakeClientSpanContext));
  verifyNoMoreInteractions(mockTracingPropagationHandler);
  verify(tracer).spanBuilderWithExplicitParent(
      eq("Sent.package1.service2.method3"), same(fakeClientParentSpan));
  verify(spyClientSpanBuilder).setRecordEvents(eq(true));
  verifyNoMoreInteractions(tracer);
  assertTrue(headers.containsKey(censusTracing.tracingHeader));

  ServerStreamTracer serverTracer =
      censusTracing.getServerTracerFactory().newServerStreamTracer(
          method.getFullMethodName(), headers);
  verify(mockTracingPropagationHandler).fromByteArray(same(binarySpanContext));
  verify(tracer).spanBuilderWithRemoteParent(
      eq("Recv.package1.service2.method3"), same(spyClientSpan.getContext()));
  verify(spyServerSpanBuilder).setRecordEvents(eq(true));

  Context filteredContext = serverTracer.filterContext(Context.ROOT);
  assertSame(spyServerSpan, ContextUtils.CONTEXT_SPAN_KEY.get(filteredContext));
}
 
開發者ID:grpc,項目名稱:grpc-java,代碼行數:27,代碼來源:CensusModulesTest.java

示例7: 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

示例8: newServer

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

示例9: serverBuilderBuildTransportServer

import io.grpc.ServerStreamTracer; //導入依賴的package包/類
public static InternalServer serverBuilderBuildTransportServer(
    AbstractServerImplBuilder<?> builder,
    List<ServerStreamTracer.Factory> streamTracerFactories,
    TransportTracer.Factory transportTracerFactory) {
  builder.transportTracerFactory = transportTracerFactory;
  return builder.buildTransportServer(streamTracerFactories);
}
 
開發者ID:grpc,項目名稱:grpc-java,代碼行數:8,代碼來源:AccessProtectedHack.java

示例10: newServerStreamTracer

import io.grpc.ServerStreamTracer; //導入依賴的package包/類
@Override
public ServerStreamTracer newServerStreamTracer(String fullMethodName, Metadata headers) {
  ServerStreamTracerInfo.InteropServerStreamTracer tracer
      = new ServerStreamTracerInfo.InteropServerStreamTracer();
  serverStreamTracers.add(new ServerStreamTracerInfo(fullMethodName, tracer));
  return tracer;
}
 
開發者ID:grpc,項目名稱:grpc-java,代碼行數:8,代碼來源:AbstractInteropTest.java

示例11: 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

示例12: NettyServer

import io.grpc.ServerStreamTracer; //導入依賴的package包/類
NettyServer(
    SocketAddress address, Class<? extends ServerChannel> channelType,
    Map<ChannelOption<?>, ?> channelOptions,
    @Nullable EventLoopGroup bossGroup, @Nullable EventLoopGroup workerGroup,
    ProtocolNegotiator protocolNegotiator, List<ServerStreamTracer.Factory> streamTracerFactories,
    TransportTracer.Factory transportTracerFactory,
    int maxStreamsPerConnection, int flowControlWindow, int maxMessageSize, int maxHeaderListSize,
    long keepAliveTimeInNanos, long keepAliveTimeoutInNanos,
    long maxConnectionIdleInNanos,
    long maxConnectionAgeInNanos, long maxConnectionAgeGraceInNanos,
    boolean permitKeepAliveWithoutCalls, long permitKeepAliveTimeInNanos) {
  this.address = address;
  this.channelType = checkNotNull(channelType, "channelType");
  checkNotNull(channelOptions, "channelOptions");
  this.channelOptions = new HashMap<ChannelOption<?>, Object>(channelOptions);
  this.bossGroup = bossGroup;
  this.workerGroup = workerGroup;
  this.protocolNegotiator = checkNotNull(protocolNegotiator, "protocolNegotiator");
  this.streamTracerFactories = checkNotNull(streamTracerFactories, "streamTracerFactories");
  this.usingSharedBossGroup = bossGroup == null;
  this.usingSharedWorkerGroup = workerGroup == null;
  this.transportTracerFactory = transportTracerFactory;
  this.maxStreamsPerConnection = maxStreamsPerConnection;
  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,代碼行數:35,代碼來源:NettyServer.java

示例13: getPort

import io.grpc.ServerStreamTracer; //導入依賴的package包/類
@Test
public void getPort() throws Exception {
  InetSocketAddress addr = new InetSocketAddress(0);
  NettyServer ns = new NettyServer(
      addr,
      NioServerSocketChannel.class,
      new HashMap<ChannelOption<?>, Object>(),
      null, // no boss group
      null, // no event group
      new ProtocolNegotiators.PlaintextNegotiator(),
      Collections.<ServerStreamTracer.Factory>emptyList(),
      TransportTracer.getDefaultFactory(),
      1, // ignore
      1, // ignore
      1, // ignore
      1, // ignore
      1, // ignore
      1, 1, // ignore
      1, 1, // ignore
      true, 0); // ignore
  ns.start(new ServerListener() {
    @Override
    public ServerTransportListener transportCreated(ServerTransport transport) {
      return null;
    }

    @Override
    public void serverShutdown() {}
  });

  // Check that we got an actual port.
  assertThat(ns.getPort()).isGreaterThan(0);

  // Cleanup
  ns.shutdown();
}
 
開發者ID:grpc,項目名稱:grpc-java,代碼行數:37,代碼來源:NettyServerTest.java

示例14: newServer

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

示例15: 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


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