Search in sources :

Example 1 with Role

use of org.neo4j.causalclustering.load_balancing.Role in project neo4j by neo4j.

the class ResultFormatV1 method parse.

private static Map<Role, List<Endpoint>> parse(List<Map<String, Object>> result) {
    Map<Role, List<Endpoint>> endpoints = new HashMap<>();
    for (Map<String, Object> single : result) {
        Role role = Role.valueOf((String) single.get("role"));
        List<Endpoint> addresses = parse((Object[]) single.get("addresses"), role);
        endpoints.put(role, addresses);
    }
    Arrays.stream(Role.values()).forEach(r -> endpoints.putIfAbsent(r, Collections.emptyList()));
    return endpoints;
}
Also used : Role(org.neo4j.causalclustering.load_balancing.Role) Endpoint(org.neo4j.causalclustering.load_balancing.Endpoint) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList)

Aggregations

ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Collectors.toList (java.util.stream.Collectors.toList)1 Endpoint (org.neo4j.causalclustering.load_balancing.Endpoint)1 Role (org.neo4j.causalclustering.load_balancing.Role)1