class LocalPreferenceLoadBalancer extends RandomLoadBalancer {

    @Override
    public ProviderInfo doSelect(SofaRequest invocation, List<ProviderInfo> providerInfos) {
        String localhost = SystemInfo.getLocalHost();
        if (StringUtils.isEmpty(localhost)) {
            return super.doSelect(invocation, providerInfos);
        }
        List<ProviderInfo> localProviderInfo = new ArrayList<ProviderInfo>();
        for (ProviderInfo providerInfo : providerInfos) { // 解析IP，看是否和本地一致
            if (localhost.equals(providerInfo.getHost())) {
                localProviderInfo.add(providerInfo);
            }
        }
        if (CommonUtils.isNotEmpty(localProviderInfo)) { // 命中本机的服务端
            return super.doSelect(invocation, localProviderInfo);
        } else { // 没有命中本机上的服务端
            return super.doSelect(invocation, providerInfos);
        }
    }

    public  LocalPreferenceLoadBalancer(ConsumerBootstrap consumerBootstrap);

}