当前位置: 首页>>代码示例>>Java>>正文


Java Attributes.get方法代码示例

本文整理汇总了Java中io.grpc.Attributes.get方法的典型用法代码示例。如果您正苦于以下问题:Java Attributes.get方法的具体用法?Java Attributes.get怎么用?Java Attributes.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.grpc.Attributes的用法示例。


在下文中一共展示了Attributes.get方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: refreshAffinity

import io.grpc.Attributes; //导入方法依赖的package包/类
public void refreshAffinity(Map<String, Object> affinity) {
  Attributes nameresoveCache =
      (Attributes) affinity.get(GrpcCallOptions.GRPC_NAMERESOVER_ATTRIBUTES);
  this.current_server = (SocketAddress) affinity.get(GrpcCallOptions.GRPC_CURRENT_ADDR_KEY);
  this.registry_servers = nameresoveCache.get(GrpcNameResolverProvider.REMOTE_ADDR_KEYS);
  this.listener = nameresoveCache.get(GrpcNameResolverProvider.NAMERESOVER_LISTENER);
  this.affinity = nameresoveCache;

}
 
开发者ID:venus-boot,项目名称:saluki,代码行数:10,代码来源:NameResolverNotify.java

示例2: transportTerminated

import io.grpc.Attributes; //导入方法依赖的package包/类
@Override
public void transportTerminated(Attributes transportAttrs) {
    checkNotNull(transportAttrs, "transportAttrs");

    UUID sessionId = transportAttrs.get(TRANSPORT_ATTRIBUTES_SESSION_ID);
    if (sessionId != null) {
        SessionLifecycleEvent event = new SessionLifecycleEvent(this, sessionId);
        sessionLifecycleEventListeners.forEach(listener -> listener.sessionEnd(event));
    }
}
 
开发者ID:salesforce,项目名称:grpc-java-contrib,代码行数:11,代码来源:ClientSessionTransportFilter.java

示例3: DnsNameResolver

import io.grpc.Attributes; //导入方法依赖的package包/类
DnsNameResolver(@Nullable String nsAuthority, String name, Attributes params,
    Resource<ScheduledExecutorService> timerServiceResource,
    Resource<ExecutorService> executorResource,
    ProxyDetector proxyDetector) {
  // TODO: if a DNS server is provided as nsAuthority, use it.
  // https://www.captechconsulting.com/blogs/accessing-the-dusty-corners-of-dns-with-java
  this.timerServiceResource = timerServiceResource;
  this.executorResource = executorResource;
  // Must prepend a "//" to the name when constructing a URI, otherwise it will be treated as an
  // opaque URI, thus the authority and host of the resulted URI would be null.
  URI nameUri = URI.create("//" + name);
  authority = Preconditions.checkNotNull(nameUri.getAuthority(),
      "nameUri (%s) doesn't have an authority", nameUri);
  host = Preconditions.checkNotNull(nameUri.getHost(), "host");
  if (nameUri.getPort() == -1) {
    Integer defaultPort = params.get(NameResolver.Factory.PARAMS_DEFAULT_PORT);
    if (defaultPort != null) {
      port = defaultPort;
    } else {
      throw new IllegalArgumentException(
          "name '" + name + "' doesn't contain a port, and default port is not set in params");
    }
  } else {
    port = nameUri.getPort();
  }
  this.proxyDetector = proxyDetector;
}
 
开发者ID:grpc,项目名称:grpc-java,代码行数:28,代码来源:DnsNameResolver.java

示例4: handleResolvedAddressGroups

import io.grpc.Attributes; //导入方法依赖的package包/类
@Override
public void handleResolvedAddressGroups(
    List<EquivalentAddressGroup> updatedServers, Attributes attributes) {
  LbPolicy newLbPolicy = attributes.get(GrpclbConstants.ATTR_LB_POLICY);
  // LB addresses and backend addresses are treated separately
  List<LbAddressGroup> newLbAddressGroups = new ArrayList<LbAddressGroup>();
  List<EquivalentAddressGroup> newBackendServers = new ArrayList<EquivalentAddressGroup>();
  for (EquivalentAddressGroup server : updatedServers) {
    String lbAddrAuthority = server.getAttributes().get(GrpcAttributes.ATTR_LB_ADDR_AUTHORITY);
    if (lbAddrAuthority != null) {
      newLbAddressGroups.add(new LbAddressGroup(server, lbAddrAuthority));
    } else {
      newBackendServers.add(server);
    }
  }

  newLbAddressGroups = Collections.unmodifiableList(newLbAddressGroups);
  newBackendServers = Collections.unmodifiableList(newBackendServers);

  if (!newLbAddressGroups.isEmpty()) {
    if (newLbPolicy != LbPolicy.GRPCLB) {
      newLbPolicy = LbPolicy.GRPCLB;
      logger.log(
          Level.FINE, "[{0}] Switching to GRPCLB because there is at least one balancer", logId);
    }
  }
  if (newLbPolicy == null) {
    logger.log(Level.FINE, "[{0}] New config missing policy. Using PICK_FIRST", logId);
    newLbPolicy = LbPolicy.PICK_FIRST;
  }

  // Switch LB policy if requested
  setLbPolicy(newLbPolicy);

  // Consume the new addresses
  switch (lbPolicy) {
    case PICK_FIRST:
    case ROUND_ROBIN:
      checkNotNull(delegate, "delegate should not be null. newLbPolicy=" + newLbPolicy);
      delegate.handleResolvedAddressGroups(newBackendServers, attributes);
      break;
    case GRPCLB:
      grpclbState.handleAddresses(newLbAddressGroups, newBackendServers);
      break;
    default:
      // Do nothing
  }
}
 
开发者ID:grpc,项目名称:grpc-java,代码行数:49,代码来源:GrpclbLoadBalancer.java


注:本文中的io.grpc.Attributes.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。