All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.netflix.astyanax.connectionpool.impl.OldHostSupplierAdapter Maven / Gradle / Ivy

There is a newer version: 3.10.2
Show newest version
package com.netflix.astyanax.connectionpool.impl;

import java.math.BigInteger;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

import com.google.common.base.Supplier;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.netflix.astyanax.connectionpool.Host;

public class OldHostSupplierAdapter implements Supplier> {
    private final Supplier>> source;
    
    public OldHostSupplierAdapter(Supplier>> source) {
        this.source = source;
    }
    
    @Override
    public List get() {
        Map> tokenHostMap = source.get();
        Set hosts = Sets.newHashSet();
        for (Entry> entry : tokenHostMap.entrySet()) { 
            for (Host host : entry.getValue()) {
                if (!hosts.contains(host)) {
                    hosts.add(host);
                }
                
                String token = entry.getKey().toString();
                host.getTokenRanges().add(new TokenRangeImpl(token, token, null));
            }
        }
        return Lists.newArrayList(hosts);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy