Search in sources :

Example 6 with DefaultServiceInstances

use of com.tencent.polaris.api.pojo.DefaultServiceInstances in project polaris-java-agent by polarismesh.

the class PolarisOperator method route.

public List<Instance> route(String service, String method, Map<String, String> labels, List<Instance> instances) {
    ServiceKey serviceKey = new ServiceKey(polarisConfig.getNamespace(), service);
    DefaultServiceInstances defaultServiceInstances = new DefaultServiceInstances(serviceKey, instances);
    ServiceInfo serviceInfo = null;
    if (null != labels && labels.size() > 0) {
        serviceInfo = new ServiceInfo();
        serviceInfo.setMetadata(labels);
    }
    ProcessRoutersRequest request = new ProcessRoutersRequest();
    request.setDstInstances(defaultServiceInstances);
    request.setMethod(method);
    request.setSourceService(serviceInfo);
    ProcessRoutersResponse processRoutersResponse = routerAPI.processRouters(request);
    return processRoutersResponse.getServiceInstances().getInstances();
}
Also used : ServiceInfo(com.tencent.polaris.api.pojo.ServiceInfo) ProcessRoutersResponse(com.tencent.polaris.router.api.rpc.ProcessRoutersResponse) ProcessRoutersRequest(com.tencent.polaris.router.api.rpc.ProcessRoutersRequest) ServiceKey(com.tencent.polaris.api.pojo.ServiceKey) DefaultServiceInstances(com.tencent.polaris.api.pojo.DefaultServiceInstances)

Aggregations

DefaultServiceInstances (com.tencent.polaris.api.pojo.DefaultServiceInstances)6 ServiceKey (com.tencent.polaris.api.pojo.ServiceKey)6 Instance (com.tencent.polaris.api.pojo.Instance)4 Server (com.netflix.loadbalancer.Server)3 DefaultInstance (com.tencent.polaris.api.pojo.DefaultInstance)3 ArrayList (java.util.ArrayList)3 PolarisServer (com.tencent.cloud.common.pojo.PolarisServer)2 ServiceInfo (com.tencent.polaris.api.pojo.ServiceInfo)2 ServiceInstances (com.tencent.polaris.api.pojo.ServiceInstances)2 ProcessRoutersRequest (com.tencent.polaris.router.api.rpc.ProcessRoutersRequest)2 ProcessRoutersResponse (com.tencent.polaris.router.api.rpc.ProcessRoutersResponse)2 PolarisServer (com.tencent.cloud.polaris.pojo.PolarisServer)1 Criteria (com.tencent.polaris.api.rpc.Criteria)1 ProcessLoadBalanceRequest (com.tencent.polaris.router.api.rpc.ProcessLoadBalanceRequest)1 ProcessLoadBalanceResponse (com.tencent.polaris.router.api.rpc.ProcessLoadBalanceResponse)1 LinkedList (java.util.LinkedList)1