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

com.zhizus.forest.thrift.client.cluster.ha.FailedFastStrategy Maven / Gradle / Ivy

The newest version!
package com.zhizus.forest.thrift.client.cluster.ha;

import com.zhizus.forest.thrift.client.cluster.HAStrategy;
import com.zhizus.forest.thrift.client.cluster.IClusterProvider;
import com.zhizus.forest.thrift.client.cluster.LoadBalance;
import org.apache.thrift.TServiceClient;

/**
 * Created by Dempe on 2016/12/26.
 */
public class FailedFastStrategy implements HAStrategy {

    private IClusterProvider provider;

    public FailedFastStrategy(IClusterProvider provider) {
        this.provider = provider;
    }

    @Override
    public  X iface(LoadBalance loadBalance, String key, Class ifaceClass) throws Exception {

        T select = loadBalance.select(key);
        if (select == null) {
            throw new IllegalArgumentException("ServerInfo is null !");
        }
        return (X) provider.iface(select, ifaceClass);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy