Search in sources :

Example 1 with InstanceInvoker

use of cn.polarismesh.agent.plugin.dubbox.entity.InstanceInvoker in project polaris-java-agent by polarismesh.

the class PolarisLoadBalance method doSelect.

@SuppressWarnings("unchecked")
@Override
protected <T> Invoker<T> doSelect(List<Invoker<T>> invokers, URL url, Invocation invocation) {
    if (null == invokers || invokers.size() == 0) {
        return null;
    }
    String service = url.getServiceInterface();
    LOGGER.info("[POLARIS] select instance for service {} by PolarisLoadBalance", service);
    String key = invokers.get(0).getUrl().getServiceKey() + "." + invocation.getMethodName();
    List<Instance> instances = (List<Instance>) ((List<?>) invokers);
    Instance instance = PolarisSingleton.getPolarisOperator().loadBalance(service, key, instances);
    return (InstanceInvoker<T>) instance;
}
Also used : Instance(com.tencent.polaris.api.pojo.Instance) List(java.util.List) InstanceInvoker(cn.polarismesh.agent.plugin.dubbox.entity.InstanceInvoker)

Aggregations

InstanceInvoker (cn.polarismesh.agent.plugin.dubbox.entity.InstanceInvoker)1 Instance (com.tencent.polaris.api.pojo.Instance)1 List (java.util.List)1