com.linecorp.armeria.client.Endpoint.isGroup()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(5.3k)|赞(0)|评价(0)|浏览(315)

本文整理了Java中com.linecorp.armeria.client.Endpoint.isGroup()方法的一些代码示例,展示了Endpoint.isGroup()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Endpoint.isGroup()方法的具体详情如下:
包路径:com.linecorp.armeria.client.Endpoint
类名称:Endpoint
方法名:isGroup

Endpoint.isGroup介绍

[英]Returns true if this endpoint refers to a group.
[中]如果此端点引用组,则返回true。

代码示例

代码示例来源:origin: line/armeria

private void ensureGroup() {
  if (!isGroup()) {
    throw new IllegalStateException("not a group endpoint");
  }
}

代码示例来源:origin: line/armeria

private void ensureSingle() {
  if (isGroup()) {
    throw new IllegalStateException("not a host:port endpoint");
  }
}

代码示例来源:origin: line/armeria

@Override
public int compareTo(Endpoint that) {
  if (isGroup()) {
    if (that.isGroup()) {
      return groupName().compareTo(that.groupName());
    } else {
      return -1;
    }
  } else {
    if (that.isGroup()) {
      return 1;
    } else {
      return NON_GROUP_COMPARATOR.compare(this, that);
    }
  }
}

代码示例来源:origin: line/armeria

/**
 * Resolves this endpoint into a host endpoint associated with the specified
 * {@link ClientRequestContext}.
 *
 * @return the {@link Endpoint} resolved by {@link EndpointGroupRegistry}.
 *         {@code this} if this endpoint is already a host endpoint.
 */
public Endpoint resolve(ClientRequestContext ctx) {
  if (isGroup()) {
    return EndpointGroupRegistry.selectNode(ctx, groupName);
  } else {
    return this;
  }
}

代码示例来源:origin: line/armeria

@Override
  public String toString() {
    final ToStringHelper helper = MoreObjects.toStringHelper(this);
    helper.addValue(authority());
    if (!isGroup()) {
      if (hostType == HostType.HOSTNAME_AND_IPv4 ||
        hostType == HostType.HOSTNAME_AND_IPv6) {
        helper.add("ipAddr", ipAddr);
      }
      helper.add("weight", weight);
    }
    return helper.toString();
  }
}

代码示例来源:origin: line/armeria

private static List<Endpoint> loadEndpoints(Properties properties, String endpointKeyPrefix,
                      int defaultPort) {
  final List<Endpoint> newEndpoints = new ArrayList<>();
  for (Entry<Object, Object> e : properties.entrySet()) {
    final String key = (String) e.getKey();
    final String value = (String) e.getValue();
    if (key.startsWith(endpointKeyPrefix)) {
      final Endpoint endpoint = Endpoint.parse(value);
      checkState(!endpoint.isGroup(),
            "properties contains an endpoint group which is not allowed: %s in %s",
            value, properties);
      newEndpoints.add(defaultPort == 0 ? endpoint : endpoint.withDefaultPort(defaultPort));
    }
  }
  checkArgument(!newEndpoints.isEmpty(), "properties contains no hosts: %s", properties);
  return ImmutableList.copyOf(newEndpoints);
}

代码示例来源:origin: line/armeria

@Override
public boolean equals(Object obj) {
  if (this == obj) {
    return true;
  }
  if (!(obj instanceof Endpoint)) {
    return false;
  }
  final Endpoint that = (Endpoint) obj;
  if (isGroup()) {
    if (that.isGroup()) {
      return groupName().equals(that.groupName());
    } else {
      return false;
    }
  } else {
    if (that.isGroup()) {
      return false;
    } else {
      return host().equals(that.host()) &&
          Objects.equals(ipAddr, that.ipAddr) &&
          port == that.port;
    }
  }
}

代码示例来源:origin: line/armeria

/**
 * Converts this endpoint into the authority part of a URI.
 *
 * @return the authority string
 */
public String authority() {
  String authority = this.authority;
  if (authority != null) {
    return authority;
  }
  if (isGroup()) {
    authority = "group:" + groupName;
  } else if (port != 0) {
    if (hostType == HostType.IPv6_ONLY) {
      authority = '[' + host() + "]:" + port;
    } else {
      authority = host() + ':' + port;
    }
  } else if (hostType == HostType.IPv6_ONLY) {
    authority = '[' + host() + ']';
  } else {
    authority = host();
  }
  return this.authority = authority;
}

代码示例来源:origin: line/armeria

if (endpoint.isGroup()) {
  logger().warn("{} Ignoring group endpoint: {}", logPrefix(), endpoint);
} else {

代码示例来源:origin: line/armeria

final ClientRequestContext cCtx = (ClientRequestContext) ctx;
final Endpoint endpoint = cCtx.endpoint();
if (endpoint.isGroup()) {
  authority = endpoint.authority();
} else {

代码示例来源:origin: com.linecorp.armeria/armeria-logback-shaded

final ClientRequestContext cCtx = (ClientRequestContext) ctx;
final Endpoint endpoint = cCtx.endpoint();
if (endpoint.isGroup()) {
  authority = endpoint.authority();
} else {

代码示例来源:origin: com.linecorp.armeria/armeria-logback

final ClientRequestContext cCtx = (ClientRequestContext) ctx;
final Endpoint endpoint = cCtx.endpoint();
if (endpoint.isGroup()) {
  authority = endpoint.authority();
} else {

代码示例来源:origin: line/centraldogma

@Test
public void buildingWithProfile() throws Exception {
  final String groupName = "centraldogma-profile-xip";
  try {
    final ArmeriaCentralDogmaBuilder b = new ArmeriaCentralDogmaBuilder();
    b.healthCheckIntervalMillis(0);
    b.profile("xip");
    final Endpoint endpoint = b.endpoint();
    assertThat(endpoint.isGroup()).isTrue();
    assertThat(endpoint.groupName()).isEqualTo(groupName);
    final EndpointGroup group = EndpointGroupRegistry.get(groupName);
    assertThat(group).isNotNull();
    assertThat(group).isInstanceOf(CompositeEndpointGroup.class);
    final CompositeEndpointGroup compositeGroup = (CompositeEndpointGroup) group;
    final List<EndpointGroup> childGroups = compositeGroup.groups();
    assertThat(childGroups).hasSize(2);
    assertThat(childGroups.get(0)).isInstanceOf(DnsAddressEndpointGroup.class);
    assertThat(childGroups.get(1)).isInstanceOf(DnsAddressEndpointGroup.class);
    await().untilAsserted(() -> {
      final List<Endpoint> endpoints = group.endpoints();
      assertThat(endpoints).isNotNull();
      assertThat(endpoints).containsExactlyInAnyOrder(
          Endpoint.of("1.2.3.4.xip.io", 36462).withIpAddr("1.2.3.4"),
          Endpoint.of("5.6.7.8.xip.io", 8080).withIpAddr("5.6.7.8"));
    });
  } finally {
    EndpointGroupRegistry.unregister(groupName);
  }
}

代码示例来源:origin: line/centraldogma

assertThat(endpoint.isGroup()).isTrue();
assertThat(endpoint.groupName()).isEqualTo(groupName);

相关文章