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

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

本文整理了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

  1. private void ensureGroup() {
  2. if (!isGroup()) {
  3. throw new IllegalStateException("not a group endpoint");
  4. }
  5. }

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

  1. private void ensureSingle() {
  2. if (isGroup()) {
  3. throw new IllegalStateException("not a host:port endpoint");
  4. }
  5. }

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

  1. @Override
  2. public int compareTo(Endpoint that) {
  3. if (isGroup()) {
  4. if (that.isGroup()) {
  5. return groupName().compareTo(that.groupName());
  6. } else {
  7. return -1;
  8. }
  9. } else {
  10. if (that.isGroup()) {
  11. return 1;
  12. } else {
  13. return NON_GROUP_COMPARATOR.compare(this, that);
  14. }
  15. }
  16. }

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

  1. /**
  2. * Resolves this endpoint into a host endpoint associated with the specified
  3. * {@link ClientRequestContext}.
  4. *
  5. * @return the {@link Endpoint} resolved by {@link EndpointGroupRegistry}.
  6. * {@code this} if this endpoint is already a host endpoint.
  7. */
  8. public Endpoint resolve(ClientRequestContext ctx) {
  9. if (isGroup()) {
  10. return EndpointGroupRegistry.selectNode(ctx, groupName);
  11. } else {
  12. return this;
  13. }
  14. }

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

  1. @Override
  2. public String toString() {
  3. final ToStringHelper helper = MoreObjects.toStringHelper(this);
  4. helper.addValue(authority());
  5. if (!isGroup()) {
  6. if (hostType == HostType.HOSTNAME_AND_IPv4 ||
  7. hostType == HostType.HOSTNAME_AND_IPv6) {
  8. helper.add("ipAddr", ipAddr);
  9. }
  10. helper.add("weight", weight);
  11. }
  12. return helper.toString();
  13. }
  14. }

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

  1. private static List<Endpoint> loadEndpoints(Properties properties, String endpointKeyPrefix,
  2. int defaultPort) {
  3. final List<Endpoint> newEndpoints = new ArrayList<>();
  4. for (Entry<Object, Object> e : properties.entrySet()) {
  5. final String key = (String) e.getKey();
  6. final String value = (String) e.getValue();
  7. if (key.startsWith(endpointKeyPrefix)) {
  8. final Endpoint endpoint = Endpoint.parse(value);
  9. checkState(!endpoint.isGroup(),
  10. "properties contains an endpoint group which is not allowed: %s in %s",
  11. value, properties);
  12. newEndpoints.add(defaultPort == 0 ? endpoint : endpoint.withDefaultPort(defaultPort));
  13. }
  14. }
  15. checkArgument(!newEndpoints.isEmpty(), "properties contains no hosts: %s", properties);
  16. return ImmutableList.copyOf(newEndpoints);
  17. }

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

  1. @Override
  2. public boolean equals(Object obj) {
  3. if (this == obj) {
  4. return true;
  5. }
  6. if (!(obj instanceof Endpoint)) {
  7. return false;
  8. }
  9. final Endpoint that = (Endpoint) obj;
  10. if (isGroup()) {
  11. if (that.isGroup()) {
  12. return groupName().equals(that.groupName());
  13. } else {
  14. return false;
  15. }
  16. } else {
  17. if (that.isGroup()) {
  18. return false;
  19. } else {
  20. return host().equals(that.host()) &&
  21. Objects.equals(ipAddr, that.ipAddr) &&
  22. port == that.port;
  23. }
  24. }
  25. }

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

  1. /**
  2. * Converts this endpoint into the authority part of a URI.
  3. *
  4. * @return the authority string
  5. */
  6. public String authority() {
  7. String authority = this.authority;
  8. if (authority != null) {
  9. return authority;
  10. }
  11. if (isGroup()) {
  12. authority = "group:" + groupName;
  13. } else if (port != 0) {
  14. if (hostType == HostType.IPv6_ONLY) {
  15. authority = '[' + host() + "]:" + port;
  16. } else {
  17. authority = host() + ':' + port;
  18. }
  19. } else if (hostType == HostType.IPv6_ONLY) {
  20. authority = '[' + host() + ']';
  21. } else {
  22. authority = host();
  23. }
  24. return this.authority = authority;
  25. }

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

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

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

  1. final ClientRequestContext cCtx = (ClientRequestContext) ctx;
  2. final Endpoint endpoint = cCtx.endpoint();
  3. if (endpoint.isGroup()) {
  4. authority = endpoint.authority();
  5. } else {

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

  1. final ClientRequestContext cCtx = (ClientRequestContext) ctx;
  2. final Endpoint endpoint = cCtx.endpoint();
  3. if (endpoint.isGroup()) {
  4. authority = endpoint.authority();
  5. } else {

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

  1. final ClientRequestContext cCtx = (ClientRequestContext) ctx;
  2. final Endpoint endpoint = cCtx.endpoint();
  3. if (endpoint.isGroup()) {
  4. authority = endpoint.authority();
  5. } else {

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

  1. @Test
  2. public void buildingWithProfile() throws Exception {
  3. final String groupName = "centraldogma-profile-xip";
  4. try {
  5. final ArmeriaCentralDogmaBuilder b = new ArmeriaCentralDogmaBuilder();
  6. b.healthCheckIntervalMillis(0);
  7. b.profile("xip");
  8. final Endpoint endpoint = b.endpoint();
  9. assertThat(endpoint.isGroup()).isTrue();
  10. assertThat(endpoint.groupName()).isEqualTo(groupName);
  11. final EndpointGroup group = EndpointGroupRegistry.get(groupName);
  12. assertThat(group).isNotNull();
  13. assertThat(group).isInstanceOf(CompositeEndpointGroup.class);
  14. final CompositeEndpointGroup compositeGroup = (CompositeEndpointGroup) group;
  15. final List<EndpointGroup> childGroups = compositeGroup.groups();
  16. assertThat(childGroups).hasSize(2);
  17. assertThat(childGroups.get(0)).isInstanceOf(DnsAddressEndpointGroup.class);
  18. assertThat(childGroups.get(1)).isInstanceOf(DnsAddressEndpointGroup.class);
  19. await().untilAsserted(() -> {
  20. final List<Endpoint> endpoints = group.endpoints();
  21. assertThat(endpoints).isNotNull();
  22. assertThat(endpoints).containsExactlyInAnyOrder(
  23. Endpoint.of("1.2.3.4.xip.io", 36462).withIpAddr("1.2.3.4"),
  24. Endpoint.of("5.6.7.8.xip.io", 8080).withIpAddr("5.6.7.8"));
  25. });
  26. } finally {
  27. EndpointGroupRegistry.unregister(groupName);
  28. }
  29. }

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

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

相关文章