class SwitchToMaster implements AutoCloseable {

    static URI getMasterUri( URI me, MasterServer masterServer, Config config )
    {
        String hostname = config.get( HaSettings.ha_server ).getHost();
        InetSocketAddress masterSocketAddress = masterServer.getSocketAddress();

        if ( hostname == null || isWildcard( hostname ) )
        {
            InetAddress masterAddress = masterSocketAddress.getAddress();
            hostname = masterAddress.isAnyLocalAddress() ? me.getHost() : ServerUtil.getHostString( masterSocketAddress );
            hostname = ensureWrapForIPv6Uri( hostname );
        }

        return URI.create( "ha://" + hostname + ":" + masterSocketAddress.getPort() + "?serverId=" + myId( config ) );
    }

    public  SwitchToMaster( LogService logService,
            HaIdGeneratorFactory idGeneratorFactory, Config config, Supplier<SlaveFactory> slaveFactorySupplier,
            Function<Locks, ConversationManager> conversationManagerFactory,
            BiFunction<ConversationManager, LifeSupport, Master> masterFactory,
            BiFunction<Master, ConversationManager, MasterServer> masterServerFactory,
            DelegateInvocationHandler<Master> masterDelegateHandler, ClusterMemberAvailability clusterMemberAvailability,
            Supplier<NeoStoreDataSource> dataSourceSupplier );

}