class HazelcastClusterTopology {

    public static Map<MemberId,RoleInfo> getCoreRoles( HazelcastInstance hazelcastInstance, Set<MemberId> coreMembers )
    {

        Set<String> dbNames = getDBNames( hazelcastInstance );
        Set<MemberId> allLeaders = dbNames.stream()
                .map( n -> getLeaderForDBName( hazelcastInstance, n ) )
                .filter( Optional::isPresent )
                .map( l -> l.get().memberId() )
                .collect( Collectors.toSet() );

        Function<MemberId,RoleInfo> roleMapper = m -> allLeaders.contains( m ) ? RoleInfo.LEADER : RoleInfo.FOLLOWER;

        return coreMembers.stream().collect( Collectors.toMap( Function.identity(), roleMapper ) );
    }

    private  HazelcastClusterTopology();

}