Search in sources :

Example 1 with LoadBalance

use of com.alibaba.dubbo.registry.common.domain.LoadBalance in project dubbo by alibaba.

the class Loadbalances method show.

public void show(Long id, Map<String, Object> context) {
    LoadBalance loadbalance = OverrideUtils.overrideToLoadBalance(overrideService.findById(id));
    context.put("loadbalance", loadbalance);
}
Also used : LoadBalance(com.alibaba.dubbo.registry.common.domain.LoadBalance)

Example 2 with LoadBalance

use of com.alibaba.dubbo.registry.common.domain.LoadBalance in project dubbo by alibaba.

the class OverrideUtils method overridesToLoadBalances.

public static List<LoadBalance> overridesToLoadBalances(List<Override> overrides) {
    List<LoadBalance> loadBalances = new ArrayList<LoadBalance>();
    if (overrides == null) {
        return loadBalances;
    }
    for (Override o : overrides) {
        if (StringUtils.isEmpty(o.getParams())) {
            continue;
        } else {
            Map<String, String> params = StringUtils.parseQueryString(o.getParams());
            for (Map.Entry<String, String> entry : params.entrySet()) {
                if (entry.getKey().endsWith("loadbalance")) {
                    LoadBalance loadBalance = new LoadBalance();
                    String method = null;
                    if (entry.getKey().endsWith(".loadbalance")) {
                        method = entry.getKey().split(".loadbalance")[0];
                    } else {
                        method = "*";
                    }
                    loadBalance.setMethod(method);
                    loadBalance.setId(o.getId());
                    loadBalance.setService(o.getService());
                    loadBalance.setStrategy(entry.getValue());
                    loadBalances.add(loadBalance);
                }
            }
        }
    }
    return loadBalances;
}
Also used : LoadBalance(com.alibaba.dubbo.registry.common.domain.LoadBalance) ArrayList(java.util.ArrayList) Override(com.alibaba.dubbo.registry.common.domain.Override) Map(java.util.Map)

Aggregations

LoadBalance (com.alibaba.dubbo.registry.common.domain.LoadBalance)2 Override (com.alibaba.dubbo.registry.common.domain.Override)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1