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

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

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

Endpoint.groupName介绍

[英]Returns the group name of this 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

@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/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.groupName()).isEqualTo(groupName);

相关文章