public CompletableFuture<List<NodeUri>> getControllerServerList() { if (cluster == null) { return Futures.failedFuture(new IllegalStateException("Controller cluster not initialized")); } return CompletableFuture.supplyAsync(() -> { try { return cluster.getClusterMembers().stream() .map(host -> NodeUri.newBuilder().setEndpoint(host.getIpAddr()).setPort(host.getPort()).build()) .collect(Collectors.toList()); } catch (ClusterException e) { // cluster implementation throws checked exceptions which cannot be thrown inside completable futures. throw Exceptions.sneakyThrow(e); } }, executor); }
@Override public String toString() { return this.getIpAddr() + ":" + this.getPort() + ((this.getEndpointId() == null) ? "" : ":" + this.getEndpointId()); }
public Controller.NodeUri getSegmentUri(final String scope, final String stream, final long segmentId, final HostControllerStore hostStore) { final Host host = hostStore.getHostForSegment(scope, stream, segmentId); return Controller.NodeUri.newBuilder().setEndpoint(host.getIpAddr()).setPort(host.getPort()).build(); }
private void validateStore(HostControllerStore hostStore) { // Validate store values. Assert.assertEquals(containerCount, hostStore.getContainerCount()); Host hostObj = hostStore.getHostForSegment("dummyScope", "dummyStream", (int) Math.floor(containerCount * Math.random())); Assert.assertEquals(controllerPort, hostObj.getPort()); Assert.assertEquals(host, hostObj.getIpAddr()); } }