use of io.etcd.jetcd.launcher.EtcdCluster in project jetcd by coreos.
the class EtcdClusterExtension method before.
protected synchronized void before(ExtensionContext context) {
EtcdCluster oldCluster = CLUSTERS.put(cluster.clusterName(), cluster);
if (oldCluster != null) {
oldCluster.stop();
}
cluster.start();
}
use of io.etcd.jetcd.launcher.EtcdCluster in project jetcd by coreos.
the class EtcdClusterNameResolver method doResolve.
private void doResolve() {
Listener savedListener;
synchronized (lock) {
if (shutdown) {
return;
}
resolving = true;
savedListener = listener;
}
try {
if (authority == null) {
throw new RuntimeException("Unable to resolve endpoint " + targetUri);
}
EtcdCluster cluster = EtcdClusterExtension.cluster(authority);
if (cluster == null) {
throw new RuntimeException("Unable to find cluster " + authority);
}
List<EquivalentAddressGroup> servers = cluster.containers().stream().map(container -> {
return new EquivalentAddressGroup(container.getClientAddress(), Attributes.newBuilder().set(EquivalentAddressGroup.ATTR_AUTHORITY_OVERRIDE, container.node()).build());
}).collect(Collectors.toList());
savedListener.onAddresses(servers, Attributes.EMPTY);
} catch (Exception e) {
LOGGER.warn("Error wile getting list of servers", e);
savedListener.onError(Status.NOT_FOUND);
} finally {
resolving = false;
}
}
Aggregations