use of org.neo4j.causalclustering.load_balancing.plugins.server_policies.ServerInfo in project neo4j by neo4j.
the class UserDefinedConfigurationStrategy method upstreamDatabase.
@Override
public Optional<MemberId> upstreamDatabase() throws UpstreamDatabaseSelectionException {
try {
Filter<ServerInfo> filters = FilterConfigParser.parse(config.get(CausalClusteringSettings.user_defined_upstream_selection_strategy));
Set<ServerInfo> possibleReaders = topologyService.readReplicas().members().entrySet().stream().map(entry -> new ServerInfo(entry.getValue().connectors().boltAddress(), entry.getKey(), entry.getValue().groups())).collect(Collectors.toSet());
CoreTopology coreTopology = topologyService.coreServers();
for (MemberId validCore : coreTopology.members().keySet()) {
Optional<CoreServerInfo> coreServerInfo = coreTopology.find(validCore);
if (coreServerInfo.isPresent()) {
CoreServerInfo serverInfo = coreServerInfo.get();
possibleReaders.add(new ServerInfo(serverInfo.connectors().boltAddress(), validCore, serverInfo.groups()));
}
}
return filters.apply(possibleReaders).stream().map(ServerInfo::memberId).findAny();
} catch (InvalidFilterSpecification invalidFilterSpecification) {
return Optional.empty();
}
}
Aggregations